[
  {
    "path": ".gitattributes",
    "content": "dist/*\tmerge=ours\ncubesviewer/cubesviewer.templates.js  merge=ours\n"
  },
  {
    "path": ".gitignore",
    "content": "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\n#dist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\n#lib\n#lib64\nnode_modules\nbower_components\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n\n# SQLite databases\n*.sqlite\n\n# Eclipse\n.settings\n\n#/ROADMAP\n\n#/virtualenv\n/env\n\n*.log\n*.pyc\nlocal_settings.py\n.idea\n*.DS_Store\n\n\n/dist\n"
  },
  {
    "path": "AUTHORS.txt",
    "content": "Authors\n=======\n\nCubesViewer by Jose Juan Montes.\n\nDevelopment:\n\n* José Juan Montes <jjmontes@gmail.com>\n  https://twitter.com/jjmontes\n\n* Stefan Urbanek <stefan@stiivi.com>\n  http://stiivi.com/\n\nOther contributors:\n\n* Enrique Hernández\n* Alexander Bessonov\n* Nuno Khan\n* Devin Howard\n\n"
  },
  {
    "path": "CHANGES.txt",
    "content": "[2.0.3]\n\n    * Fixed chart figure export (was not working). Chart images can again be exported as PNG.\n    * Fixed series missing data with same label but different key value.\n\n[2.0.2]\n\n    * Fixed export bug causing table not to be exported if dataset was too large.\n    * Facts view now shows attribute details (#76).\n    * Fixed 'apply already in progress' bug when loading a cube after first time.\n    * Added masonry library to show improve alignment of Studio views.\n    * Added drill more/less buttons to drilldown, horizontal dimension tags and dimension filter.\n    * Added dimension filter item filtering based on current view cut.\n    * Fixed dimension filter empty list if dimension members contains repeated values.\n    * Select next drill level (if available) when clicking on an item in explore mode.\n    * Fixed dimension sorting when grid was reused or multiple grids on screen (fixes #71).\n    * Fixed CSV export in explore mode (#72).\n\n[2.0.1]\n\n    * Column sorting now follows order_attribute from model.\n    * Added AngularJS integration example.\n    * Added chart image export support.\n    * Line charts now allow various curve types.\n    * Google Analytics plugin restored (events tracking).\n    * Added warning if server result limit has been hit.\n    * Added server information dialog.\n    * Added new horizontal columns chart.\n    * Added two columns mode and hide controls mode.\n    * New icon library and revamped UI.\n    * Added automatic content-based column resize feature.\n    * Added support for negated cuts (inverse filters).\n    * Added support for custom column formatting functions.\n    * Added cube metadata option to set view default params.\n    * Option to show/hide chart legend.\n    * Pie charts are now sorted by size of slice.\n    * Serializing now shows JSON in a modal dialog and is easier to copy.\n\n    * Responsive design.\n    * More printer-friendly CSS.\n    * UI is now refreshed in-place instead of blocking whole UI.\n    * Using templating for HTML views (no more HTML/JavaScript spaguetti code).\n    * Moved from jQGrid to more versatile Angular ui-grid.\n    * Refactored to Angular. Dropped jQueryUI.\n    * Now using Bootstrap embedded (no global CSS selectors) for styling, without\n      impacting page styles and better avoiding being impacted by container page styling.\n    * Introduced Grunt and Bower build toolchain. Also JSDoc.\n    * Separated CubesViewer server and client into two different projects.\n    * License changed to pure MIT (removed extra clause).\n\n[0.0.11]\n\n    * Fixed bug causing datefilter to unnecessarily require 'cv-datefilter: true'.\n    * Moved GUI interface to top sticky menu (warning: could break existing\n      integrations of the interface).\n    * Changed chart resize method to a fixed set of height choices.\n    * Using less technical menu and button labels (cut = filter).\n    * Facts table now includes fact details.\n    * Fixed export facts feature.\n\n[0.0.10]\n\n    * Updated to work with Cubes 1.0 (note: dropped support for Cubes 0.10.x).\n    * Upgraded to Django 1.7.3 (your settings.py may need updating).\n    * Datefilter now uses dimension role \"time\" in Cubes 1.0.\n    * First version using Django migrations.\n    * Use cubes.js official client library (altered).\n    * Modified jQueryUI theme.\n    * Updated to latest jQuery version 1.10.2.\n    * Switched from django-piston to django-rest-framework.\n    * Dropped notes system.\n\n[0.0.9]\n\n    * Last version supporting cubes 0.10.x.\n    * Fix dimensionfilter bug causing wrong values to\n      be selected when updating from the current filter.\n    * Added Google Analityics events plugin.\n\n[0.0.8]\n\n    * Charts now save view configuration (status and disabledseries).\n    * New rangefilter plugin (closes #21).\n    * Added support for a cv-ignore option in the model for dimensions.\n    * Separated datefilter as a plugin (closes #8).\n    * Cutting over a drilled dimension no longer removes the drill.\n    * Added shortcuts (select all) and drilldown from filters.\n    * Menus now open on hover if already open.\n    * Charts now using nvd3.js.\n\n[0.0.7]\n\n    * Always send dimension level for drilldown (solves\n      issue about single-point cut * drilldown combination)\n    * Updated the pure-html examples (embedded views).\n    * Ajax global error handler is no longer used.\n    * More user friendly error handling if server not available.\n    * Fixed table resizing not fitting parent.\n    * Added week information to datepickers.\n    * Added measures to facts view.\n\n[0.0.6]\n\n    * Added facts view (and support for column size saving).\n    * Added dimension filter icons (shortcuts) to info pieces.\n    * Fixed bug causing wrong hierarchy name to be displayed\n    * Added the dimensionfilter plugin, which introduces a\n      more advanced filtering interface.\n    * Sort order in tables is now preserved.\n    * Added column chooser for Explore mode, saved with view.\n    * Column widths saved with view via new plugin.\n    * Added tooltips to table values.\n    * Added wiki plugin for public notes for cubes and views.\n    * Menu buttons now require click to activate.\n    * Fixed a few UI glitches.\n\n[0.0.5]\n\n    * Removed the \"global shared views\" concept.\n    * Experimental Cubes proxy (with ACLs).\n    * Initial version of cache system.\n    * Measure aggregations are now shown in submenus.\n    * Fixed bug causing drilldowns to incorrectly drill to latest level.\n    * Changed \"loading\" approach, now blocks the interface where appropriate.\n    * Changed redraw strategy trying to minimize size changes.\n    * Fixed wrong extra columns in some charts.\n    * Fixed multiple drill dimensions that were ignored in charts.\n\n[0.0.4]\n\n    * Added a locale switcher plugin.\n    * Added documentation and examples for embedding views\n      in other web applications.\n    * Added the serialization plugin.\n\n[0.0.3]\n\n    * Added undo/redo plugin.\n    * Improved export plugin (now exports all pages of tables).\n    * Updated Flotr2 library to support stacked lines.\n    * Date dimensions are now correctly configured at model level.\n    * Added support for dimension hierarchies.\n    * Added some Cubes model javascript support classes.\n    * Added support for labels and label attributes.\n    * Added (draft) examples of local HTML usage.\n    * Added installation documentation.\n    * Application settings now have default values that work out of the box.\n    * Added support for measures with no aggregations.\n\n[0.0.2]\n\n    * Initial import into repository.\n    * Added basic saving/sharing capabilities.\n    * Initial separation of components.\n    * Refactored Javascript code to be more object-oriented.\n    * Finished functional application prototype (exploration, tables and charts).\n\n[0.0.1]\n\n    * Application prototype and proof of concept.\n"
  },
  {
    "path": "Gruntfile.js",
    "content": "module.exports = function(grunt) {\n\n  grunt.initConfig({\n    pkg: grunt.file.readJSON('package.json'),\n\n    concat: {\n      options: {\n        separator: ';'\n      },\n      dist: {\n        src: [\n              'cubesviewer/angular-bootstrap-submenu/angular-bootstrap-submenu.js',\n              'cubesviewer/cubes/cubes.js',\n              'cubesviewer/cubes/cubes-cvextensions.js',\n              'cubesviewer/cubes/cubes-service.js',\n              'cubesviewer/cubes/cache.js',\n              'cubesviewer/core/cubesviewer.js',\n              'cubesviewer/views/views.js',\n              'cubesviewer/dialog/dialog.js',\n              'cubesviewer/views/cube/cube.js',\n              'cubesviewer/views/cube/explore/explore.js',\n              'cubesviewer/views/cube/filter/dimension.js',\n              'cubesviewer/views/cube/filter/datefilter.js',\n              'cubesviewer/views/cube/facts/facts.js',\n              'cubesviewer/views/cube/series/series.js',\n              'cubesviewer/views/cube/series/operations.js',\n              'cubesviewer/views/cube/chart/chart.js',\n              'cubesviewer/views/cube/chart/chart-bars-vertical.js',\n              'cubesviewer/views/cube/chart/chart-bars-horizontal.js',\n              'cubesviewer/views/cube/chart/chart-lines.js',\n              'cubesviewer/views/cube/chart/chart-pie.js',\n              'cubesviewer/views/cube/chart/chart-radar.js',\n              'cubesviewer/views/cube/chart/chart-sunburst.js',\n              //'cubesviewer/cubesviewer.views.cube.rangefilter.js',\n              'cubesviewer/views/cube/export.js',\n              'cubesviewer/views/undo.js',\n              'cubesviewer/studio/studio.js',\n              'cubesviewer/studio/serialize.js',\n\n              'cubesviewer/server/reststore.js',\n              'cubesviewer/ga/googleanalytics.js',\n\n              // The templates file is autogenerated by grunt-angular-templates\n              'cubesviewer/cubesviewer.templates.js'\n        ],\n        dest: 'dist/<%= pkg.name %>.js'\n      }\n    },\n\n    less: {\n    \toptions: {\n    \t},\n    \tdist: {\n\t    \tfiles: {\n\t    \t\t'dist/cubesviewer.css': 'cubesviewer/cubesviewer.less'\n\t    \t}\n    \t}\n    },\n    uglify: {\n      options: {\n        banner: '/*! <%= pkg.name %> <%= grunt.template.today(\"dd-mm-yyyy\") %> */\\n'\n      },\n      dist: {\n        files: {\n          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']\n        }\n      }\n    },\n    copy: {\n      \tdist: {\n    \t\tfiles: [\n    \t\t    { expand: true, cwd: 'dist', src: '*', dest: '../cubesviewer-page/lib/cubesviewer/' },\n    \t\t    { expand: true, cwd: 'dist', src: '*', dest: '../cubesviewer-server/cvapp/cubesviewer/static/lib/cubesviewer/' }\n\t        ]\n    \t}\n    },\n    qunit: {\n      files: ['test/**/*.html']\n    },\n    bower: {\n    \tinstall: {\n    \t\toptions: {\n    \t\t\ttargetDir: 'html/lib/',\n    \t\t\tlayout: 'byComponent',\n    \t\t\tverbose: true\n\t\t    }\n\t    }\n    },\n    /*\n    wiredep: {\n\t  dist: {\n          src: [\n        \t  'html/*.html'\n          ],\n          options: {\n        \t ignorePath: '../bower_components/',\n        \t fileTypes: {\n        \t\t html: {\n        \t\t\t replace: {\n        \t\t\t\t js: '<script src=\"../lib/{{filePath}}\"></script>',\n        \t\t\t\t css: '<link rel=\"stylesheet\" href=\"../lib/{{filePath}}\" />'\n        \t\t\t }\n        \t\t }\n        \t }\n          }\n      }\n\t},\n\t*/\n    jsdoc : {\n        dist : {\n            src: ['cubesviewer/**/*.js'], // 'test/*.js'\n            options: {\n                destination: 'build/doc',\n                configure : 'doc/jsdoc/jsdoc.conf.json'\n            }\n        }\n    },\n    jshint: {\n      files: ['Gruntfile.js', 'bower,json', 'cubesviewer/**/*.js', 'cubesviewer/**/*.less', 'test/**/*.js'],\n      options: {\n        // options here to override JSHint defaults\n        globals: {\n          jQuery: true,\n          console: true,\n          module: true,\n          document: true\n        }\n      }\n    },\n    watch: {\n      files: ['<%= jshint.files %>', 'bower.json', 'cubesviewer/**/**.*'],\n      tasks: ['default']  // 'copy'\n    },\n    ngtemplates:  {\n    \t  app:        {\n    \t    cwd:      'cubesviewer',\n    \t    src:      '**/**.html',\n    \t    dest:     'cubesviewer/cubesviewer.templates.js',\n    \t    options: {\n    \t    \tmodule:\t  \"cv\",\n    \t    }\n    \t  }\n    \t}\n  });\n\n  grunt.loadNpmTasks('grunt-contrib-uglify');\n  grunt.loadNpmTasks('grunt-contrib-jshint');\n  //grunt.loadNpmTasks('grunt-contrib-qunit');\n  grunt.loadNpmTasks('grunt-contrib-watch');\n  grunt.loadNpmTasks('grunt-contrib-copy');\n  grunt.loadNpmTasks('grunt-contrib-concat');\n  grunt.loadNpmTasks('grunt-contrib-less');\n  grunt.loadNpmTasks('grunt-bower-task')\n  //grunt.loadNpmTasks('grunt-wiredep');\n  grunt.loadNpmTasks('grunt-angular-templates');\n  grunt.loadNpmTasks('grunt-jsdoc');\n\n  grunt.registerTask('test', ['jshint']);  // 'qunit'\n\n  grunt.registerTask('default', ['less', 'ngtemplates', 'concat', 'uglify', 'jsdoc']);  // 'bower',\n\n};\n\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "CubesViewer\nCopyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\nAbout\n-----\n\nCubesViewer is a visual, web-based tool for exploring and analyzing\nOLAP databases served by the Cubes OLAP Framework.\n\nCubesViewer can be used for data exploration and auditory,\ngeneration of reports, chart designing and embedding,\nand as a (simple) company-wide analytics application.\n\nCubesViewer is a visual interface for the\nopen source [Cubes server](http://databrewery.org/cubes.html) (an OLAP server in Python).\nPurpose is to keep it simple while leveraging the web services provided by Cubes.\n\nSee it live: [CubesViewer site](http://www.cubesviewer.com/).\n\nFeatures:\n\n* Dimension hierarchies, date filtering\n* Several charts and diagrams can be created\n* Explore, create data series, draw charts, see raw facts\n* Export data and images\n* Responsive design, tablet friendly\n* Undo / redo\n* Views can be embedded in other web sites\n* User Interface allows for multiple views on-screen\n* Optional multi-user server-side backend for saving/sharing views\n\n\nOnline Demos\n------------\n\n* [CubesViewer Site](http://www.cubesviewer.com)\n* [CubesViewer Studio](http://www.cubesviewer.com/studio.html) with the full application\n\n<!---\n* [CubesViewer Embedded Views](http://jjmontesl.github.io/cubesviewer/views.html) showing embedded views\n-->\n\nDownload\n--------\n\nLatest CubesViewer stable release is 2.0.2:\n\n* CubesViewer 2.0.2\n  * [cubesviewer-v2.0.2.zip](https://github.com/jjmontesl/cubesviewer/archive/v2.0.2.zip)\n  * [cubesviewer-server-v2.0.2.zip](https://github.com/jjmontesl/cubesviewer-server/archive/v2.0.2.zip)\n  * [Changelog](http://github.com/jjmontesl/cubesviewer/blob/v2.0.2/CHANGES.txt)\n  * [Release Notes](http://github.com/jjmontesl/cubesviewer/blob/v2.0.2/RELEASE-NOTES.txt)\n  * Works with *Cubes 1.0.x* and *Cubes 1.1.x*\n\nCubesViewer Server already includes the CubesViewer library so you just need that package\nif you plan to deploy the server-side application.\n\nIf you do modifications to the project, cloning both repositories via `git` is encouraged, so you can\neasily contribute your fixes and improvements back.\n\nRequirements\n------------\n\nCubesViewer consists of two parts:\n\n**CubesViewer client** is an HTML5 application that runs on any modern browser.\nIt can run without server side support. **Simply download the package and open**\n`html/studio.html` in your favorite browser. Views can also be embedded in other sites.\n\nCubesViewer also features an optional **server side application**\nwhich provides a full web application and supports features like sharing/saving views.\nThis project lives on a separate repository: [CubesViewer Server](http://github.com/jjmontesl/cubesviewer-server)\n(not to be confused with Cubes Server itself).\n\nYou need a configured and running [Cubes Server](http://databrewery.org/cubes.html) version 1.0.x or later.\nYour Cubes model may use some extra configuration if you wish to use features like date\nfilters and range filters (see Documentation below).\n\nFor CubesViewer clients to connect to Cubes server (\"slicer\"), your Cubes server possibly needs to allow\ncross origin resource sharing (CORS). To enable it, add `allow_cors_origin: *`\n(or a more restrictive setting) under the `[server]` section of the `slicer.ini` file.\n\nFor further information, see the Documentation section below.\n\nDocumentation\n-------------\n\nThis tool allows users to inspect the different dimensions, measures and\naggregated data in different ways, allowing you to build tables and charts\nbased on the analytical data available from the server.\n\n* [CubesViewer Quick Start](http://github.com/jjmontesl/cubesviewer/blob/master/doc/guide/cubesviewer-quickstart.md)\n* [CubesViewer Documentation](http://github.com/jjmontesl/cubesviewer/blob/master/doc/guide/index.md)\n\n* [CubesViewer 2.0 Release Notes](http://github.com/jjmontesl/cubesviewer/blob/master/RELEASE-NOTES.md)\n\n\nScreenshots\n-----------\n\n![CubesViewer Explore Screenshot](https://raw.github.com/jjmontesl/cubesviewer/master/doc/screenshots/view-explore-1.png \"CubesViewer Explore\")\n![CubesViewer Chart Screenshot](https://raw.github.com/jjmontesl/cubesviewer/master/doc/screenshots/view-chart-2.png \"CubesViewer Chart\")\n\nSupport\n=======\n\nYou can use the Cubes discuss group for CubesViewer related questions,\nand report bugs or features via CubesViewer issue tracker:\n\n* User group: http://groups.google.com/group/cubes-discuss\n* Report bugs: http://github.com/jjmontesl/cubesviewer/issues\n\nSource\n======\n\nGithub source repository:\n\n* http://github.com/jjmontesl/cubesviewer\n* http://github.com/jjmontesl/cubesviewer-server\n\nAbout versioning:\n\n* Tagged versions (ie. v2.0.x) are stable releases.\n* The \"master\" branch may be ahead the latest stable version, but is meant to be stable (fixes and documentation improvements).\n* Development and latest changes happen in the \"devel\" branch and others.\n\nCollaborate!\n------------\n\nUsing CubesViewer or interested in data engineering / data visualization? CubesViewer\nis an open source project and could grow up best with the help of fellow coders.\n\nYou can collaborate:\n\n* If you find bugs, please [file an issue](http://github.com/jjmontesl/cubesviewer/issues).\n* If you have a feature request, also file an issue.\n* If you fix bugs, please do send a pull request.\n* If you make reusable changes, please document those and send a pull request.\n* If you wish to take over a larger feature, get in touch through the Cubes discuss group above\n  in order to plan for it collectively. Check the TODO.txt file if you need some inspiration.\n* You can also help improving the documentation or writing about Cubes/CubesViewer, and spreading the love.\n\nIf you are using or trying CubesViewer, we'd love to hear from you (please tweet #cubesviewer !).\n\nDevelopment\n-----------\n\nRun:\n\n    grunt watch\n\nThis is the `grunt` task that watches the cubesviewer directory and generates the built\nlibrary in the `dist` directory.\n\nCan be tested using the `html/studio.html` application.\n\n\nAuthors\n=======\n\nCubesViewer is written and maintained by Jose Juan Montes\nand other contributors.\n\nSee AUTHORS file for more information.\n\nLicense\n=======\n\nCubesViewer is published under MIT license.\n\nFor full license see the LICENSE file.\n\n"
  },
  {
    "path": "RELEASE-NOTES.md",
    "content": "\nCubesViewer 2.0 Release Notes\n=============================\n\nCubesViewer is a visual, web-based tool application for exploring and analyzing\nOLAP databases served by the Cubes OLAP Framework.\n\nCubesViewer can be used for data exploration and data auditory,\ngeneration of reports, chart design and embedding,\nand as a (simple) company-wide analytics application.\n\n* [CubesViewer Official Site](http://www.cubesviewer.com)\n* [CubesViewer at GitHub](https://github.com/jjmontesl/cubesviewer)\n\n\n2.0 Release Notes\n-----------------\n\nThis is a major release of CubesViewer featuring tons of improvements, new\nfeatures, a rebranded look and feel as well as a new code architecture\nthat greatly eases development and paves the way for following versions.\n\nCubesViewer has undergone a major upgrade. The code is now built upon\n*AngularJS*, and the UI framework has been migrated from jQueryUI to\n*Bootstrap* and *Angular Bootstrap* components. HTML has been rewritten\nand separated into easier to handle templates.\n\nThe application is now more *responsive* and *mobile friendly*\nand looks more stylish overall. CSS has been reworked and namespaced,\neasing integration into other web documents.\n\nMigration to AngularJS has involved an comprehensive\nrefactoring and review of every module, and we trust it's been for the better.\nInternally, the build pipeline now uses *Less*, *Grunt* and *Bower*, and a lot\nof dependencies have been removed. All together allow CubesViewer to now be\ndistributed as a single `.js` file (minified version also available) and\naccompanying `.css` file. *JSDoc* has also been introduced.\n\nOther additions feature:\n\n* Printer friendly CSS.\n* Export charts as images.\n* New horizontal bars chart.\n* Line and area charts with curved lines.\n* Improved error reporting and user interface.\n* CubesViewer Server (optional) upgraded to Django 1.9.\n* Plugin for cube usage tracking via Google Analytics.\n* Improved documentation and tutorials.\n\nMake sure you read the [Changelog]() for the full list of changes.\n\nSpecial thanks to Stefan Urbanek, Devin Howard and all the other\ncontributors and users for your support and collaboration.\n\n\nRequirements\n------------\n\nCubesViewer consists of two parts:\n\n**CubesViewer client** is a HTML5 application that runs on any modern browser.\nIt can run without server side support. **Simply download the package and open**\n`html/studio.html` in your favorite browser. Views can also be embedded in other sites.\n\nCubesViewer also features an optional **server side application**\nwhich provides a full web application and supports features like sharing/saving views.\nThis project lives on a separate repository: [CubesViewer Server](https://github.com/jjmontesl/cubesviewer-server)\n(not to be confused with Cubes Server itself).\n\nYou need a configured and running [Cubes Server](http://databrewery.org/cubes.html) version 1.0.x or later.\nYour Cubes model may need some extra configuration if you wish to use features like date filters.\n\n\nUpgrading from 2.0.1\n--------------------\n\n1. A new Javascript dependency (masonry) has been added to the Studio application\n   (this does not apply if you are using CubesViewer Server or embedding CubesViewer\n   views: only if embedding CubesViewer Studio). Check the sample `html/studio.html`\n   for an up to date list of dependencies.\n\n\nUpgrading from 0.10 or 0.11\n---------------------------\n\n1. If you are integrating CubesViewer in your HTML, note that the code needed for\n   initializing CubesViewer has changed slightly. The list of Javascript and CSS\n   dependencies has also changed. Refer to the [Embedding CubesViewer] for detailed\n   instructions on integrating views and the full list of initialization options.\n\n2. View definitions are (partially) backwards compatible, but some of the attributes\n   have changed (ie. column width definition). If you or your users have stored view\n   definitions, either via CubesViewer Server or any other JSON view definition,\n   it is recommended to test drive your existing view definitions to check they\n   show up as expected.\n\n3. The \"Range Filter\" feature hasn't yet been upgraded from previous version and\n   is not available. If you were using \"Range Filter\" these will not show up.\n\n4. Column sorting now follows `order_attribute` from model. Depending on your\n   model definition, you may find that some columns are not ordered as in 0.x.\n   See documentation \"CubesViewer Model options\" for details.\n\n5. For CubesViewer clients to connect to Cubes server (\"slicer\"), your Cubes server\n   possibly needs to allow cross origin resource sharing (CORS). To enable it,\n   add `allow_cors_origin: *` (or a more restrictive setting)\n   under the `[server]` section of the `slicer.ini` file.\n\n6. If you are using CubesViewer Server, you need to upgrade your database after\n   upgrading the application package. As with any Django app,\n   run `python manage.py migrate`.\n\n\nFor complete installation instructions, see the\n[CubesViewer Documentation](http://github.com/jjmontesl/cubesviewer/blob/master/doc/guide/index.md).\n\n\nUpgrading from 0.9 or earlier\n-----------------------------\n\nCubesViewer 0.9 supported older Cubes 0.10.x. This version of Cubes is no longer supported\nby CubesViewer and thus you need to upgrade your Cubes Server installation first and\nreinstall CubesViewer.\n\n"
  },
  {
    "path": "TODO.txt",
    "content": "Consider contributing to CubesViewer! This is a possible roadmap (reverse order).\n\n[ROADMAP]\n\n    * Support multiple servers and multiple versions (use adaptors, and own data dictionary).\n\n    * Translation site / tool / ask for help.\n    * Interface available in English and one more language.\n    * Implement i18n.\n    * Bring back locale support!\n\n    * Support more authentication scenarios for embedded views / IFRAME,\n      via CubesViewer server app (note upcoming Cubes auth framework).\n    * App support for IFRAME embedding.\n    * GUI support for browser back button, correct URL usage, links to GUI.\n\n    * Support dimension attributes, and fact details in fact view etc..\n    * Support better exploration of facts\n\n    * GUI options (and all other plugin options) now as cubesviewer options\n      (with plugin namespace?).\n    * Hide interface mode (also, make these programmable options for the views)\n    * Fix too many series in legend issue (limit? alternate legend?).\n    * Avoid leaving the page inadvertedely (also make back/forward/url_links work?)\n    * Jump to added view when creating a view (also make back/forward/url_links work?)\n\n    * Separate in directives appropriately, restore \"puggability\", move cube \"globals\" to directive scopes.\n\n    * Add anonymous-save service to backend and client (dedup).\n    * Print feature (open tables and charts with appropriate height/width, hide most interface buttons).\n\n    * X/Y/size bubble charts.\n    * 3rd dimension scrollbar and play mode (for charts and series)\n    * Time filter dynamic (zoomable, etc) when is horizontal dimension in appropriate chart mode (nvd3 does this ootb)\n    * Make charts more interactive (allow cut from chart, etc).\n\n    * Series annotation system: markers for annotations in time or other dimension.\n    * Better loading bar (account for pending requests, etc).\n    * Default cube settings (cv-info) feature bug? it should only be applied if the view is not otherwise configured (ie loaded or json). Check.\n\n    * Architecture improvements:\n        * Abstract backend?? Create CV objects for dimensions, levels, etc... Plug cubes as one more adaptor???\n        * Abstract data/grid in cubeview? -> Add own data dictionary (<->CubETL).\n\n        * Make cubesviewer-studio an angular app.\n\n    * Save filters (segments). Info pieces shall be made directives first.\n\n[2.4]\n\n    * Data alerts (server-backed, depending on criteria, with triggers (use cubetl?)).\n    * http://bl.ocks.org/mbostock/4063269 (Bubble chart: categories/sizes)\n    * https://mbostock.github.io/d3/talk/20111018/treemap.html (zoomable treemap)\n    * Scatter charts (allow to use a second measure for one of the axis)\n\n[2.3]\n\n    * Fulltext search (facts, dimension values/info, extra external data (refs), metadata) ?\n\n    * Filter from chart filter / synchronize filter and chart filter (?)\n    * Synchronize view to other view (one way/two way, attributes to synchronize)\n\n[2.2]\n\n    * Info metadata (html/url), etc...\n    * Django views admin -> include CubesViewer\n    * Scroll to recently open view on GUI (also provide function to do it from code for standalone views).\n    * Fact Viewer and fact templates (html/url/angular template?), i.e. including links to documents or etc...\n    * Data formatters (color, decimals, abbreviations, units, etc...). Allow client side changes?\n    * Implement limits to items shown in charts or dimension filters...?\n    * Show filter icon from \"horizontal dimension\". Also show its detail level (and perhaps not the hierarchy).\n    * Abandon page warning?\n    * Datepicker to show only to correct level (year, month, day)\n    * Try reoder columns + pin columns again\n    * Add fullscreen mode for a view (in this case, stretch grid and chart as appropriate?)\n    * Drop notes system 2: use metadata for info and add a comments system\n    * Allow direct link to URL (cubesviewer GUI reading configuration/anonymous-id from URL)\n    * Drill more/drill less. Same for horizontal dimension, and dimension filter (???)\n    * Reviewed and improved doc (JSDoc).\n\n    * Comments system.\n\n[2.1]\n\n    * Site, demos and data:\n        * Update screenshots showing map chart (ie from views.html).\n        * Create views.html page for site, showing a full story w/ source code (\"start with a blank cube\", \"exploration\", \"series\", \"chart\", \"map\"...)\n        * Site (second iteration). Show a couple of charts view, a table, and an enabled-controls view.\n          SAME views to be automatically opened in the explorer sample.\n        * Add product subcategory to demo data. Add some formatters (correctly from dims via CubeETL).\n        * Update & simplify demo views JSON.\n        * Review site and doc links.\n        * Mention Python, jQuery+Angular, database agnostic / systems\n\n\n    * Chart series view/hide selection is serialized using label instead of key. Normalize.\n    * Issue #55 (chart shows measure name, not measure label).\n    * Fix submenu timer hack: is causing issues already. Watch contents and perhaps debounce menu activation?\n\n    * Add \"accumulated\", \"difference\" and other operations to series and charts.\n    * Add \"grouping\", allowing to group drilled down items (custom groups) using an aggregation of choice...\n      Ability to save groups.\n    * Add \"reduce to N items\" operation on series (allows to represent charts adding \"Others\" for the rest),\n      reducing using some criteria -> uses grouping.\n    * Finish calculations: show infos, mark which ones are enabled, order, add series colorize (positive/negative) | move \"invert 2nd serie -> mirror 2nd serie\" as a calculation?\n    * Operations. Design. Possible error: operations shall be applied after series but before flatennign cols for charts. Ensure this is correct.\n\n    * Restore cached content notice (is missing, commented out).\n    * Automatically hide legend if too many results.\n    * Colors get incorrectly drawn when series are deselected from legend, and view changed back/forth.\n\n    * Divide in reusable angular directives (ie. start with fact viewer). JS doc. Make views\n          proper objects.\n        * Move to a more object oriented API, directives for widgets for model and cubeview.\n          Keep drilldown and cuts as objects in API, serialize only as\n          needed (and so introduce the ability optionally include column widths, etc).\n        * (Use controllerAs).\n\n\n    * Range filter.\n    * Flag icons support OOTB.\n    * Map representations from facts, including segments from individual points in facts (plot paths, with metrics and filtering!)\n    * Map charts. Design already available.\n\n[2.0.3]\n\n    * Remove -devel from version, -beta from doc, package.json version cubesviewer version,  generate files, copy to web and server, same on server.\n      Release notes, Tag repo (release), Announcement, Move this todo item to next release top.\n    * Submenu loading issue.\n\n    * Tooltip columns: column=val remove columnTooltipAttr, enable tooltips?\n    * Regression: tooltips (column label = formatted value), and row highlighting. Also row selection odd/even issue.\n\n    * Fix: toggling legend does not redraw chart (just moves legend?). Redrawing the chart (ie switching view mode) actually works.\n      Same for sometimes drilling down or changing a filter, grid doens't get correct size.\n    * Size change when switching views is irritating. Hack that (fix height during changes/reloads?).\n\n    * Fix to grid sort function cache was incorrect? If two grids are loaded, clicking on a column in grid A could affect sorting in grid B (#71).\n    * Error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 45-45 [Í] in expression [entity['SECRETARÍA XERAL TÉCNICA '](CONSELLERÍA DE CULTURA, EDUCACIÓN E ORDENACIÓN UNIVERSITARIA)].\n\n    * Possible repeated data load / events?\n    * Refresh: use watches to trigger invalidation? (also check for repeated events). Example: drilldown with click on item\n      now triggers refresh twice: cut and drilldown. Also causes incorrect Undo/Redo tracking.\n\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"cubesviewer\",\n  \"description\": \"CubesViewer JS client app\",\n  \"main\": \"cubesviewer\",\n  \"authors\": [\n    \"Jose Juan Montes <jjmontes@gmail.com>\"\n  ],\n  \"license\": \"MIT\",\n  \"keywords\": [\n    \"olap\",\n    \"visualization\",\n    \"cubes\"\n  ],\n  \"homepage\": \"https://github.com/jjmontesl/cubesviewer\",\n  \"moduleType\": [\n    \"globals\"\n  ],\n  \"ignore\": [\n    \"**/.*\",\n    \"node_modules\",\n    \"bower_components\",\n    \"test\",\n    \"tests\"\n  ],\n  \"dependencies\": {\n    \"jquery\": \"2.2.3\",\n    \"nvd3\": \"1.8.2\",\n    \"bootstrap\": \"3.3.6\",\n    \"flotr2\": \"*\",\n    \"font-awesome\": \"Font-Awesome#4.6.1\",\n    \"bootstrap-submenu\": \"^2.0.4\",\n    \"angular\": \"^1.5.5\",\n    \"angular-bootstrap\": \"1.3.2\",\n    \"angular-ui-grid\": \"^3.1.1\",\n    \"angular-bootstrap-slider\": \"^0.1.27\",\n    \"angular-cookies\": \"^1.5.5\"\n  },\n  \"exportsOverride\": {\n    \"jquery\": {\n      \"/\": \"dist/**/*.*\"\n    },\n    \"bootstrap\": {\n      \"/\": \"dist/**/*.*\"\n    },\n    \"bootstrap-submenu\": {\n      \"css\": \"dist/css/*.*\",\n      \"js\": \"dist/js/*.*\"\n    },\n    \"font-awesome\": {\n      \"css\": \"css/*.*\",\n      \"fonts\": \"fonts/*.*\"\n    },\n    \"flotr2\": {\n        \"/\": \"*.*\"\n    }\n  }\n}\n"
  },
  {
    "path": "cubesviewer/angular-bootstrap-submenu/angular-bootstrap-submenu.js",
    "content": "/*\n * angular-bootstrap-submenu\n * Copyright (c) 2016 Jose Juan Montes\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n\nangular.module('bootstrapSubmenu', []).directive(\"submenu\", ['$timeout', function($timeout) {\n\treturn {\n\t\trestrict: 'A',\n\t\tlink: function(scope, iElement, iAttrs) {\n\t\t\t// FIXME: This is not a proper way of waiting for the menu to be constructed.\n\t\t\t$timeout(function() {\n\t\t\t\t$(iElement).submenupicker();\n\t\t\t}, 500);\n\t\t}\n\t};\n}]);\n\n"
  },
  {
    "path": "cubesviewer/core/cubesviewer.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n\"use strict\";\n\n/**\n * CubesViewer namespace.\n *\n * @namespace cv\n */\n\n// Main CubesViewer angular module\nangular.module('cv', ['ui.bootstrap', 'bootstrapSubmenu',\n                      'ui.grid', 'ui.grid.resizeColumns', 'ui.grid.selection', 'ui.grid.autoResize',\n                      'ui.grid.pagination', 'ui.grid.pinning', /*'ui.grid.exporter',*/\n                      'ngCookies',\n                      'cv.cubes', 'cv.views']);\n\n// Configure moment.js\n/*\nangular.module('cv').constant('angularMomentConfig', {\n\t// preprocess: 'unix', // optional\n\t// timezone: 'Europe/London' // optional\n});\n*/\n\n/*\n * Configures cv application (cvOptions, log provider...).\n */\nangular.module('cv').config([ '$logProvider', 'cvOptions', /* 'editableOptions', 'editableThemes', */\n                           function($logProvider, cvOptions /*, editableOptions, editableThemes */) {\n\n\t//console.debug(\"Bootstrapping CubesViewer.\");\n\n    var defaultOptions = {\n\n    \t\tcubesUrl : null,\n            //cubesLang : null,\n    \t\tjsonRequestType: \"json\", // \"json | jsonp\"\n\n    \t\tpagingOptions: [15, 30, 100, 250],\n\n            cacheEnabled: true,\n            cacheDuration: 30 * 60,\n            cacheNotice: 10 * 60,\n            cacheSize: 32,\n\n\t\t\tdatepickerShowWeeks: true,\n\t\t    datepickerFirstDay: 1,  // Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday).\n\n            undoEnabled: true,\n            undoSize: 32,\n\n            seriesOperationsEnabled: false,\n\n        \thideControls: false,\n\n            gaTrackEvents: false,\n\n            debug: false\n    };\n\n\t$.extend(defaultOptions, cvOptions);\n\t$.extend(cvOptions, defaultOptions);\n\n\t$logProvider.debugEnabled(cvOptions.debug);\n\n\t// Avoid square brackets in serialized array params\n\t// TODO: Shall be done for $http instead?\n\t/*\n\t$.ajaxSetup({\n\t\ttraditional : true\n\t});\n\t*/\n\n\t// XEditable bootstrap3 theme. Can be also 'bs2', 'default'\n\t/*\n\teditableThemes.bs3.inputClass = 'input-sm';\n\teditableThemes.bs3.buttonsClass = 'btn-sm';\n\teditableOptions.theme = 'bs3';\n\t*/\n\n}]);\n\n/*\n *\n */\nangular.module('cv').run([ '$timeout', '$log', 'cvOptions', 'cubesService', 'cubesCacheService', /* 'editableOptions', 'editableThemes', */\n\t                           function($timeout, $log, cvOptions, cubesService, cubesCacheService /*, editableOptions, editableThemes */) {\n\n\t$log.debug(\"CubesViewer debug mode is enabled.\");\n\n\t// Initialize cache service\n\tcubesCacheService.initialize();\n\n\t// Initialize Cubes service\n\tcubesService.connect();\n\n}]);\n\n\n/**\n * CubesViewer class, used to initialize CubesViewer and\n * create views. Note that the initialization method varies depending\n * on whether your application uses Angular 1.x or not.\n *\n * An instance of this class is available as the global `cubesviewer`\n * variable. This class must not be instantiated.\n *\n * @class\n */\nfunction CubesViewer() {\n\n\t// CubesViewer version\n\tthis.version = \"2.0.3-devel\";\n\n\t/**\n\t * State of a view that has not yet been fully initialized, and cannot be interacted with.\n\t * @const\n\t */\n\tthis.VIEW_STATE_INITIALIZING = 1;\n\n\t/**\n\t * State of a view that has been correctly initialized.\n\t * @const\n\t */\n\tthis.VIEW_STATE_INITIALIZED = 2;\n\n\t/**\n\t * State of a view that has failed initialization, and cannot be used.\n\t * @const\n\t */\n\tthis.VIEW_STATE_ERROR = 3;\n\n\n\tthis._configure = function(options) {\n\t\t$('.cv-version').html(cubesviewer.version);\n\t\tangular.module('cv').constant('cvOptions', options);\n\t};\n\n\t/**\n\t * Initializes CubesViewer system.\n\t *\n\t * If you are using CubesViewer in an Angular application, you don't\n\t * need to call this method. Instead, use your application Angular `config`\n\t * block to initialize the cvOptions constant with your settings,\n\t * and add the 'cv' module as a dependency to your application.\n\t */\n\tthis.init = function(options) {\n\n\t\tthis._configure(options);\n\t\tangular.element(document).ready(function() {\n\t\t\tangular.bootstrap(document, ['cv']);\n\t\t});\n\t};\n\n\t/**\n\t * Creates a CubesViewer view object and interface, and attaches it\n\t * to the specified DOM element.\n\t *\n\t * If you are embedding CubesViewer in an Angular application, you can\n\t * avoid this method and use the {@link viewsService} and the\n\t * {@link cvViewCube} directive instead.\n\t *\n\t * @param container A selector, jQuery object or DOM element where the view will be attached.\n\t * @param type View type (currently only \"cube\" is available).\n\t * @param viewData An object or JSON string with the view parameters.\n\t * @returns The created view object.\n\t */\n\tthis.createView = function(container, type, viewData) {\n\n\t\t//console.debug(\"Creating view: \" + viewData);\n\n\t\tvar $compile = angular.element(document).injector().get('$compile');\n\t\tvar viewsService = angular.element(document).injector().get('viewsService');\n\n\t\tvar view = viewsService.createView(\"cube\", viewData);\n\n\t\tvar viewDirective = '<div class=\"cv-bootstrap\"><div cv-view-cube view=\"view\"></div></div>';\n\t\t$(container).first().html(viewDirective);\n\n\t\tvar scope = angular.element(document).scope().$root;\n\t\tvar templateScope = scope.$new();\n\t\ttemplateScope.view = view;\n\n\t\t//templateCtrl = $controller(\"CubesViewerStudioController\", { $scope: templateScope } );\n\t\t//$(cvOptions.container).children().data('$ngControllerController', templateCtrl);\n\n\t\t$compile($(container).first().contents())(templateScope);\n\n\t\treturn view;\n\n\t};\n\n\t/**\n\t * Performs changes within CubesViewer scope. If are not using CubesViewer from\n\t * Angular, you need to wrap all your CubesViewer client code within this\n\t * method in order for changes to be observed.\n\t *\n\t * @param routine Function that will be executed within CubesViewer Angular context.\n\t */\n\tthis.apply = function(routine) {\n\t\tif (! angular.element(document).scope()) {\n\t\t\tconsole.debug(\"Delaying\");\n\t\t\tsetTimeout(function() { cubesviewer.apply(routine); }, 1000);\n\t\t} else {\n\t\t\tangular.element(document).scope().$apply(routine);\n\t\t}\n\t};\n\n};\n\n/**\n * This is Cubesviewer main entry point. Please see {@link CubesViewer}\n * documentation for further information.\n *\n * @global\n */\nvar cubesviewer = new CubesViewer();\n\n"
  },
  {
    "path": "cubesviewer/cubes/cache.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\nangular.module('cv.cubes').service(\"cubesCacheService\", ['$rootScope', '$log', 'cvOptions', 'cubesService', 'gaService',\n                                                         function ($rootScope, $log, cvOptions, cubesService, gaService) {\n\n\tvar cubesCacheService = this;\n\n\tthis.cache = {};\n\n\tthis._cacheOverridedCubesRequest = null;\n\n\tthis.initialize = function() {\n\t\tif (this._cacheOverridedCubesRequest) {\n\t\t\t$log.warn(\"Error: tried to initialize CubesCacheService but it was already initialized.\")\n\t\t\treturn;\n\t\t}\n\t\tif (cvOptions.cacheEnabled) {\n\t\t\t// Replace request function\n\t\t\t$log.debug(\"Replacing Cubes request method with caching version.\")\n\t\t\tcubesCacheService._cacheOverridedCubesRequest = cubesService.cubesRequest;\n\t\t\tcubesService.cubesRequest = cubesCacheService.cachedCubesRequest;\n\t\t}\n\t};\n\n\tthis.cachedCubesRequest = function(path, params, successCallback, errCallback) {\n\n\t\tcubesCacheService._cacheCleanup();\n\n\t\tvar requestHash = path + \"?\" + $.param(params);\n\t\tvar jqxhr = null;\n\t\tif (requestHash in cubesCacheService.cache && cvOptions.cacheEnabled) {\n\n\t\t\t// Warn that data comes from cache (QTip can do this?)\n\t\t\tvar timediff = Math.round ((new Date().getTime() - cubesCacheService.cache[requestHash].time) / 1000);\n\t\t\tif (timediff > cvOptions.cacheNotice) {\n\t\t\t\t//cubesviewer.showInfoMessage(\"Data loaded from cache<br/>(\" + timediff + \" minutes old)\", 1000);\n\t\t\t\t$log.debug(\"Data loaded from cache (\" + Math.floor(timediff / 60, 2) + \" minutes old)\");\n\t\t\t}\n\n\t\t\tjqxhr = $.Deferred();\n\t\t\tjqxhr.error = function() { };\n\n\t\t\tsetTimeout(function() {\n\t\t\t\t// TODO: What is the correct ordering of success/complete callbacks?\n\t\t\t\tsuccessCallback(cubesCacheService.cache[requestHash].data);\n\t\t\t\tjqxhr.resolve(); //.promise();\n\t\t\t}, 0);\n\n\t\t\tgaService.trackRequest(path);\n\n\t\t} else {\n\t\t\t// Do request\n\t\t\tjqxhr = cubesCacheService._cacheOverridedCubesRequest(path, params, cubesCacheService._cacheCubesRequestSuccess(successCallback, requestHash), errCallback);\n\t\t}\n\n\t\treturn jqxhr;\n\t};\n\n\t/*\n\t * Reviews the cache and removes old elements and oldest if too many\n\t */\n\tthis._cacheCleanup = function() {\n\n\t\tvar cacheDuration = cvOptions.cacheDuration;\n\t\tvar cacheSize = cvOptions.cacheSize;\n\n\t\tvar oldestTime = new Date().getTime() - (1000 * cacheDuration);\n\n\t\tvar elements = [];\n\t\tfor (var element in cubesCacheService.cache) {\n\t\t\tif (cubesCacheService.cache[element].time < oldestTime) {\n\t\t\t\tdelete cubesCacheService.cache[element];\n\t\t\t} else {\n\t\t\t\telements.push (element);\n\t\t\t}\n\t\t}\n\n\t\telements.sort(function(a, b) {\n\t\t\treturn (cubesCacheService.cache[a].time - cubesCacheService.cache[b].time);\n\t\t});\n\t\tif (elements.length >= cacheSize) {\n\t\t\tfor (var i = 0; i < elements.length - cacheSize; i++) {\n\t\t\t\tdelete cubesCacheService.cache[elements[i]];\n\t\t\t}\n\t\t}\n\n\t}\n\n\tthis._cacheCubesRequestSuccess = function(pCallback, pRequestHash) {\n\t\tvar requestHash = pRequestHash;\n\t\tvar callback = pCallback;\n\t\treturn function(data) {\n\t\t\t// TODO: Check if cache is enabled\n\t\t\tcubesCacheService.cache[pRequestHash] = {\n\t\t\t\t\"time\": new Date().getTime(),\n\t\t\t\t\"data\": data\n\t\t\t};\n\t\t\tpCallback(data);\n\t\t};\n\t};\n\n}]);\n\n"
  },
  {
    "path": "cubesviewer/cubes/cubes-cvextensions.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/* Extensions to cubesviewer client lib */\ncubes.Dimension.prototype.hierarchies_count = function()  {\n\n\tvar count = 0;\n\tfor (var hiename in this.hierarchies) {\n\t\tif (this.hierarchies.hasOwnProperty(hiename)) {\n\t\t\tcount++;\n\t\t}\n\t}\n\treturn count;\n};\n\ncubes.Dimension.prototype.default_hierarchy = function()  {\n\treturn this.hierarchies[this.default_hierarchy_name];\n};\n\n/*\n * Extend model prototype to support datefilter dimensions.\n */\ncubes.Dimension.prototype.isDateDimension = function()  {\n\n\t// Inform if a dimension is a date dimension and can be used as a date\n\t// filter (i.e. with date selection tool).\n\treturn ((this.role == \"time\") &&\n\t\t\t((! (\"cv-datefilter\" in this.info)) || (this.info[\"cv-datefilter\"] == true)) );\n\n};\n\n/**\n * List date dimensions.\n *\n * @returns An array with the dimensions that are date dimensions (role: time).\n */\ncubes.Cube.prototype.dateDimensions = function() {\n\tvar result = [];\n\tfor (var index in this.dimensions) {\n\t\tvar dimension = this.dimensions[index];\n\t\tif (dimension.isDateDimension()) result.push(dimension);\n\t}\n\treturn result;\n};\n\n\ncubes.Cube.prototype.cvdim_dim = function(dimensionString) {\n\t// Get a dimension by name. Accepts dimension hierarchy and level in the input string.\n\tvar dimname = dimensionString;\n\tif (dimensionString.indexOf('@') > 0) {\n\t\tdimname = dimensionString.split(\"@\")[0];\n\t} else if (dimensionString.indexOf(':') > 0) {\n\t\tdimname = dimensionString.split(\":\")[0];\n\t}\n\n\treturn this.dimension(dimname);\n};\n\ncubes.Cube.prototype.dimensionPartsFromCut = function(cut) {\n\tvar parts = this.dimensionParts(cut.dimension);\n\tvar depth = (cut.value.split(';')[0].match(/,/g) || []).length + 1;\n\n\tvar dimstring = parts.dimension.name + '@' + parts.hierarchy.name + ':' + parts.hierarchy.levels[depth - 1].name;\n\treturn this.dimensionParts(dimstring);\n};\n\ncubes.Cube.prototype.dimensionParts = function(dimensionString) {\n\t// Get a dimension info by name. Accepts dimension hierarchy and level in the input string.\n\n\tif (!dimensionString) return null;\n\n\tvar dim = this.cvdim_dim(dimensionString);\n\tvar hie = dim.default_hierarchy();\n\n\tif (dimensionString.indexOf(\"@\") > 0) {\n\t\tvar hierarchyName = dimensionString.split(\"@\")[1].split(\":\")[0];\n\t\thie = dim.hierarchy(hierarchyName);\n\t}\n\n\tvar lev = null;\n\tvar levelIndex = 0;\n\tif (dimensionString.indexOf(\":\") > 0) {\n\t\tvar levelname = dimensionString.split(\":\")[1];\n\t\tlev = dim.level(levelname);\n\t\tfor (levelIndex = 0; levelIndex < hie.levels.length && hie.levels[levelIndex] != lev; levelIndex++);\n\t} else {\n\t\tlev = dim.level(hie.levels[0]);\n\t}\n\n\tvar depth = null;\n\tfor (var i = 0; i < hie.levels.length; i++) {\n\t\tif (lev.name == hie.levels[i]) {\n\t\t\tdepth = i + 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn {\n\t\tdimension: dim,\n\t\tlevel: lev,\n\t\tlevelIndex: levelIndex,\n\t\tdepth: depth,\n\t\thierarchy: hie,\n\t\tlabel: dim.label + ( hie.name != \"default\" ? (\" - \" + hie.label) : \"\" ) + ( hie.levels.length > 1 ? (\" / \" + lev.label) : \"\" ),\n\t\tlabelShort: (dim.label +  ( hie.levels.length > 1 ? (\" / \" + lev.label) : \"\" )),\n\t\tlabelNoLevel: dim.label + ( hie.name != \"default\" ? (\" - \" + hie.label) : \"\" ),\n\n\t\tfullDrilldownValue: dim.name + ( hie.name != \"default\" ? (\"@\" + hie.name) : \"\" ) + \":\" + lev.name,\n\t\tdrilldownDimension: dim.name + '@' + hie.name + ':' + lev.name,\n\t\tdrilldownDimensionPlus: (hie.levels.length > 1 && levelIndex < hie.levels.length - 1) ? (dim.name + '@' + hie.name + ':' + hie.levels[levelIndex + 1].name) : null,\n\t\tdrilldownDimensionMinus: (hie.levels.length > 1 && levelIndex > 0) ? (dim.name + '@' + hie.name + ':' + hie.levels[levelIndex - 1].name) : null,\n\n\t\tcutDimension: dim.name + ( hie.name != \"default\" ? \"@\" + hie.name : \"\" )\n\t};\n\n};\n\n/**\n * Returns the aggregates for the given measure, by name.\n * If passed null, returns aggregates with no measure.\n *\n * @returns The list of aggregates of a measure.\n */\ncubes.Cube.prototype.measureAggregates = function(measureName) {\n\tvar aggregates = $.grep(this.aggregates, function(ia) { return measureName ? ia.measure == measureName : !ia.measure; } );\n\treturn aggregates;\n};\n\n\ncubes.Cube.prototype.aggregateFromName = function(aggregateName) {\n\tvar aggregates = $.grep(this.aggregates, function(ia) { return aggregateName ? ia.name == aggregateName : !ia.measure; } );\n\treturn aggregates.length == 1 ? aggregates[0] : null;\n};\n\n\n\n/*\n * Processes a cell and returns an object with consistent information:\n * o.key\n * o.label\n * o.info[]\n */\ncubes.Level.prototype.readCell = function(cell) {\n\n\tif (!(this.key().ref in cell)) return null;\n\n\tvar result = {};\n\tresult.key = cell[this.key().ref];\n\tresult.label = cell[this.label_attribute().ref];\n\tresult.orderValue = cell[this.order_attribute().ref];\n\tresult.info = {};\n\t$(this.attributes).each(function(idx, attribute) {\n\t\tresult.info[attribute.ref] = cell[attribute.ref];\n\t});\n\n\treturn result;\n};\n\ncubes.Hierarchy.prototype.readCell = function(cell, level_limit) {\n\n\tvar result = [];\n\tvar hie = this;\n\n\tfor (var i = 0; i < this.levels.length; i ++) {\n\t\tvar level = this.levels[i];\n\t\tvar info = level.readCell(cell);\n\t\tif (info != null) result.push(info);\n\n\t\t// Stop if we reach level_limit\n\t\tif ((level_limit != undefined) && (level_limit != null)) {\n\t\t\tif (level_limit.name == level.name) break;\n\t\t}\n\t}\n\treturn result;\n};\n\n"
  },
  {
    "path": "cubesviewer/cubes/cubes-service.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/**\n * CubesViewer Cubes module. Provides an interface to the Cubes client.\n *\n * @namespace cv.cubes\n */\nangular.module('cv.cubes', []);\n\n/**\n * This service manages the Cubes client instance and provides methods to\n * connect to and query the Cubes server.\n *\n * @class cubesService\n * @memberof cv.cubes\n */\nangular.module('cv.cubes').service(\"cubesService\", ['$rootScope', '$log', 'cvOptions', 'gaService',\n                                                    function ($rootScope, $log, cvOptions, gaService) {\n\n\tvar cubesService = this;\n\n\tthis.cubesserver = null;\n\n\tthis.state = cubesviewer.VIEW_STATE_INITIALIZING;\n\n\tthis.stateText = \"\";\n\n\n\tthis.initialize = function() {\n\t};\n\n\t/**\n\t * Connects this service to the Cubes server, using the parameters\n\t * defined by the configured {@link cvOptions}.\n\t *\n\t * @memberOf cv.cubes.cubesService\n\t */\n\tthis.connect = function() {\n\t\t// Initialize Cubes client library\n\t\tthis.cubesserver = new cubes.Server(cubesService._cubesAjaxHandler);\n\t\tconsole.debug(\"Cubes client connecting to: \" + cvOptions.cubesUrl);\n\t\tthis.cubesserver.connect (cvOptions.cubesUrl, function() {\n\t\t\t$log.debug('Cubes client initialized (server version: ' + cubesService.cubesserver.server_version + ')');\n\t\t\tcubesService.state = cubesviewer.VIEW_STATE_INITIALIZED;\n\t\t\t$rootScope.$apply();\n\t\t}, function(xhr) {\n\n\t\t\tconsole.debug(xhr);\n\t\t\tconsole.debug('Could not connect to Cubes server [code=' + xhr.status + \"]\");\n\t\t\tcubesService.state = cubesviewer.VIEW_STATE_ERROR;\n\n\t\t\tif (xhr.status == 401) {\n\t\t\t\tcubesService.stateText = \"Unauthorized.\";\n\t\t\t} else if (xhr.status == 403) {\n\t\t\t\tcubesService.stateText = \"Forbidden.\";\n\t\t\t} else if (xhr.status == 400) {\n\t\t\t\tcubesService.stateText = \"Bad request: \" + ($.parseJSON(xhr.responseText).message);\n\t\t\t} else {\n\t\t\t\tcubesService.stateText = \"Unknown error.\";\n\t\t\t}\n\n\n\t\t\t$rootScope.$apply();\n\t\t} );\n\t};\n\n\n\t/*\n\t * Ajax handler for cubes library\n\t */\n\tthis._cubesAjaxHandler = function (settings) {\n\t\treturn cubesService.cubesRequest(settings.url, settings.data || [], settings.success, settings.error);\n\t};\n\n\n\t/**\n\t * Sends a request to the Cubes server.\n\t *\n\t * @memberOf cv.cubes.cubesService\n\t * @returns The jQuery XHR object.\n\t */\n\tthis.cubesRequest = function(path, params, successCallback, errCallback) {\n\n\n\t\t// TODO: normalize how URLs are used (full URL shall come from client code)\n\t\tif (path.charAt(0) == '/') path = cvOptions.cubesUrl + path;\n\n\t\tif (cvOptions.debug) {\n\t\t\t$log.debug(\"Cubes request: \" + path + \" (\" + JSON.stringify(params) + \")\");\n\t\t}\n\n\t\tvar jqxhr = $.get(path, params, cubesService._cubesRequestCallback(successCallback), cvOptions.jsonRequestType);\n\n\t\tjqxhr.fail(errCallback || cubesService.defaultRequestErrorHandler);\n\n\t\ttry {\n\t\t\tgaService.trackRequest(path);\n\t\t} catch(e) {\n\t\t\t$log.error(\"An error happened during CubesViewer event tracking: \" + e)\n\t\t}\n\n\t\treturn jqxhr;\n\n\t}\n\n\tthis._cubesRequestCallback = function(pCallback) {\n\t\tvar callback = pCallback;\n\t\treturn function(data, status) {\n\t\t\tpCallback(data);\n\t\t}\n\t};\n\n\t/*\n\t * Default XHR error handler for CubesRequests\n\t */\n\tthis.defaultRequestErrorHandler = function(xhr, textStatus, errorThrown) {\n\t\t$log.error(\"Cubes request error: \" + xhr)\n\t};\n\n\t/*\n\t * Builds Cubes Server query parameters based on current view values.\n\t */\n\tthis.buildBrowserArgs = function(view, includeXAxis, onlyCuts) {\n\n\t\t// \"lang\": view.cubesviewer.options.cubesLang\n\n\t\t//console.debug(view);\n\n\t\tvar args = {};\n\n\t\tif (!onlyCuts) {\n\n\t\t\tvar drilldowns = view.params.drilldown.slice(0);\n\n\t\t\t// Include X Axis if necessary\n\t\t\tif (includeXAxis) {\n\t\t\t\tdrilldowns.splice(0, 0, view.params.xaxis);\n\t\t\t}\n\n\t\t\t// Preprocess\n\t\t\tfor (var i = 0; i < drilldowns.length; i++) {\n\t\t\t\tdrilldowns[i] = cubes.drilldown_from_string(view.cube, view.cube.dimensionParts(drilldowns[i]).fullDrilldownValue);\n\t\t\t}\n\n\t\t\t// Include drilldown array\n\t\t\tif (drilldowns.length > 0)\n\t\t\t\targs.drilldown = cubes.drilldowns_to_string(drilldowns);\n\t\t}\n\n\t\t// Cuts\n\t\tvar cuts = this.buildQueryCuts(view);\n\t\tif (cuts.length > 0) args.cut = new cubes.Cell(view.cube, cuts);\n\n\t\treturn args;\n\n\t};\n\n\t/*\n\t * Builds Query Cuts\n\t */\n\tthis.buildQueryCutsStrings = function(view) {\n\n\t\tvar cuts = [];\n\n\t\t// Cuts\n\t\t$(view.params.cuts).each(function(idx, e) {\n\t\t\tvar invert = e.invert ? \"!\" : \"\";\n\t\t\tvar dimParts = view.cube.dimensionParts(e.dimension);\n\t\t\tvar cutDim = dimParts.dimension.name + ( dimParts.hierarchy.name != \"default\" ? \"@\" + dimParts.hierarchy.name : \"\" );\n\n\t\t\tcuts.push(invert + cutDim + \":\" + e.value.replace(\"-\", \"\\\\-\"));\n\t\t});\n\n\t\t// Date filters\n\t\t$(view.params.datefilters).each(function(idx, e) {\n\t\t\tvar datefilterval = cubesService.datefilterValue(view, e);\n\t\t\tif (datefilterval != null) {\n\t\t\t\tcuts.push(e.dimension + \":\" + datefilterval);\n\t\t\t}\n\t\t});\n\n\t\treturn cuts;\n\t};\n\n\tthis.buildQueryCuts = function(view) {\n\t\tvar cuts = [];\n\t\tvar cutsStrings = cubesService.buildQueryCutsStrings(view);\n\t\t$(cutsStrings).each(function(idx, e) {\n\t\t\tcuts.push(cubes.cut_from_string(view.cube, e));\n\t\t});\n\t\treturn cuts;\n\t};\n\n\t/*\n\t * Composes a filter with appropriate syntax and time grain from a\n\t * datefilter\n\t */\n\tthis.datefilterValue = function(view, datefilter) {\n\n\t\tvar date_from = null;\n\t\tvar date_to = null;\n\n\t\tif (datefilter.mode.indexOf(\"auto-\") == 0) {\n\t\t\tif (datefilter.mode == \"auto-last1m\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(date_from.getMonth() - 1);\n\t\t\t} else if (datefilter.mode == \"auto-last3m\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(date_from.getMonth() - 3);\n\t\t\t} else if (datefilter.mode == \"auto-last6m\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(date_from.getMonth() - 6);\n\t\t\t} else if (datefilter.mode == \"auto-last12m\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(date_from.getMonth() - 12);\n\t\t\t} else if (datefilter.mode == \"auto-last24m\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(date_from.getMonth() - 24);\n\t\t\t} else if (datefilter.mode == \"auto-january1st\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setMonth(0);\n\t\t\t\tdate_from.setDate(1);\n\t\t\t} else if (datefilter.mode == \"auto-yesterday\") {\n\t\t\t\tdate_from = new Date();\n\t\t\t\tdate_from.setDate(date_from.getDate() - 1);\n\t\t\t\tdate_to = new Date();\n                date_to.setDate(date_from.getDate() - 1);\n\t\t\t}\n\n\t\t} else if (datefilter.mode == \"custom\") {\n\t\t\tif ((datefilter.date_from != null) && (datefilter.date_from != \"\")) {\n\t\t\t\tdate_from = new Date(datefilter.date_from);\n\t\t\t}\n\t\t\tif ((datefilter.date_to != null) && (datefilter.date_to != \"\")) {\n\t\t\t\tdate_to = new Date(datefilter.date_to);\n\t\t\t}\n\t\t}\n\n\t\tif ((date_from != null) || (date_to != null)) {\n\t\t\tvar datefiltervalue = \"\";\n\t\t\tif (date_from != null)\n\t\t\t\tdatefiltervalue = datefiltervalue + cubesService._datefiltercell(view, datefilter, date_from);\n\t\t\tdatefiltervalue = datefiltervalue + \"-\";\n\t\t\tif (date_to != null)\n\t\t\t\tdatefiltervalue = datefiltervalue + cubesService._datefiltercell(view, datefilter, date_to);\n\t\t\treturn datefiltervalue;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\n\t};\n\n\tthis._datefiltercell = function(view, datefilter, tdate) {\n\n\t\tvar values = [];\n\n\t\tvar dimensionparts = view.cube.dimensionParts(datefilter.dimension);\n\t\tfor (var i = 0; i < dimensionparts.hierarchy.levels.length; i++) {\n\t\t\tvar level = dimensionparts.hierarchy.levels[i];\n\n\t\t\tvar field = level.role;\n\t\t\tif (field == \"year\") {\n\t\t\t\tvalues.push(tdate.getFullYear());\n\t\t\t} else if (field == \"month\") {\n\t\t\t\tvalues.push(tdate.getMonth() + 1);\n\t\t\t} else if (field == \"quarter\") {\n\t\t\t\tvalues.push((Math.floor(tdate.getMonth() / 3) + 1));\n\t\t\t} else if (field == \"week\") {\n\t\t\t\tvalues.push(this._weekNumber(tdate));\n\t\t\t} else if (field == \"day\") {\n\t\t\t\tvalues.push(tdate.getDate());\n\t\t\t} else {\n\t\t\t\tdialogService.show(\"Wrong configuration of model: time role of level '\" + level.name + \"' is invalid.\");\n\t\t\t}\n\t\t}\n\n\t\treturn values.join(',');\n\n\t\t/*return tdate.getFullYear() + \",\"\n\t\t\t\t+ (Math.floor(tdate.getMonth() / 3) + 1) + \",\"\n\t\t\t\t+ (tdate.getMonth() + 1); */\n\t};\n\n\tthis._weekNumber = function(d) {\n\t    // Copy date so don't modify original\n\t    d = new Date(d);\n\t    d.setHours(0,0,0);\n\t    // Get first day of year\n\t    var yearStart = new Date(d.getFullYear(),0,1);\n\t    // Calculate full weeks to nearest Thursday\n\t    var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7)\n\t    // Return array of year and week number\n\t    return weekNo;\n\t};\n\n\n\tthis.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/cubes/cubes.js",
    "content": "/* Cubes.js\n *\n * JavaScript library for Cubes OLAP.\n *\n */\n\n(function(){\n\n    // Light-weight \"underscore\" replacements\n\n    var _ = {};\n\n    _.map = function(ary, f) {\n      var ret = [];\n      for (var i = 0; i < ary.length; i++) {\n        ret.push(f(ary[i]));\n      }\n      return ret;\n    };\n\n    _.filter = function(ary, f) {\n      var ret = [];\n      for (var i = 0; i < ary.length; i++) {\n        if ( f(ary[i]) ) ret.push(ary[i]);\n      }\n      return ret;\n    };\n\n    _.find = function(ary, f) {\n      var i;\n      if (Object.prototype.toString.call(ary) === '[object Array]') {\n        for (i = 0; i < ary.length; i++) {\n          if ( f(ary[i]) ) return ary[i];\n        }\n      } else {\n        for (i in ary) {\n          if ( f(ary[i]) ) return ary[i];\n        }\n      }\n      return null;\n    };\n\n    _.indexOf = function(ary, f) {\n      var i;\n      if (Object.prototype.toString.call(ary) === '[object Array]') {\n        for (i = 0; i < ary.length; i++) {\n          if ( f(ary[i]) ) return i;\n        }\n      } else {\n        for (i in ary) {\n          if ( f(ary[i]) ) return i;\n        }\n      }\n      return -1;\n    };\n\n    _.isObject = function(o) {\n      return Object.prototype.toString.call(o) === '[object Object]';\n    };\n\n    _.isString = function(o) {\n      return Object.prototype.toString.call(o) === '[object String]';\n    };\n\n    // Variables and functions go here.\n    var root = this;\n    var cubes = { };\n\n    /*\n     * Server\n     * ======\n     */\n\n    cubes.Server = function(ajaxHandler){\n        // Represents Cubes Slicer Server connection.\n        //\n        // Attributes:\n        //\n        // * `ajaxHandler`: a function accepting jquery-style settings object as in $.ajax(settings)\n        //\n\n        if(ajaxHandler)\n        {\n            this.ajaxRequest = ajaxHandler;\n        }\n        else\n        {\n            this.ajaxRequest = $.ajax;\n        }\n        this._cube_list = [];\n        this._cubes = {}\n    };\n\n    cubes.Server.prototype.cubeinfo = function(cubename) {\n    \tvar cubeinfos = $.grep(this._cube_list, function (ci) { return ci.name == cubename });\n    \tif (cubeinfos.length != 1) throw \"Found \" + cubeinfos.length + \" cubes with name '\" + cubename + \"' in the cube list\";\n    \treturn cubeinfos[0];\n    };\n\n    cubes.Server.prototype.ajaxRequest = function(settings) {\n        throw \"Must implement ajaxRequest for server to process jquery-style $.ajax settings object\";\n    };\n\n    cubes.Server.prototype.query = function(query, cube, args, callback, errCallback, completeCallback) {\n        var params = {dataType : 'json', type : \"GET\"};\n\n        var cube_name = null;\n        if(cube.hasOwnProperty(\"name\"))\n            cube_name = cube.name;\n        else\n            cube_name = cube;\n\n        params.url = this.url + \"cube/\" + cube_name + \"/\" + query;\n        params.data = args;\n\n        if(args && args.cut)\n            params.data.cut = params.data.cut.toString();\n\n        if(args && args.drilldown)\n          params.data.drilldown = params.data.drilldown.toString();\n\n        params.success = function(obj) {\n            callback(obj);\n        };\n        params.error = function(obj) {\n            // FIXME: Some error handler here\n            if (errCallback) errCallback(obj);\n        };\n        params.complete = function(obj) {\n            if (completeCallback) completeCallback(obj);\n        };\n\n        return this.ajaxRequest(params);\n    };\n\n    /**\n     * Connect to the Slicer server.\n     *\n     * @param {url} Slicer server URL\n     * @param {callback} Function called on successfull connect\n     * @param {errCallback} Function called on error\n     *     one line.\n     */\n\n    cubes.Server.prototype.connect = function(url, callback, errCallback) {\n        var self = this;\n\n        self.url = self._normalize_url(url);\n\n        var options = {dataType : 'json', type : \"GET\"};\n\n        options.url = self.url + 'info';\n\n        options.success = function(resp, status, xhr) {\n            self.server_version = resp.cubes_version;\n            self.cubes_version = resp.cubes_version;\n            self.api_version = resp.api_version;\n            self.info = resp;\n            self.load_cube_list(callback, errCallback);\n        };\n\n        options.error = function(resp, status, xhr) {\n            if (errCallback)\n                errCallback(resp);\n        };\n\n        this.ajaxRequest(options);\n    };\n\n    cubes.Server.prototype._normalize_url = function(url) {\n        if(url[url.length-1] != '/')\n            return url + '/';\n        return url;\n    };\n\n    cubes.Server.prototype.load_cube_list = function(callback, errCallback) {\n        var self = this;\n\n        var options = {dataType : 'json', type : \"GET\"};\n\n        options.url = self.url + 'cubes';\n\n        options.success = function(resp, status, xhr) {\n            self._cube_list = resp;\n\n            if (callback)\n                callback(self._cube_list);\n        };\n\n        options.error = function(resp, status, xhr) {\n            if (errCallback)\n                errCallback(resp);\n        };\n\n        return this.ajaxRequest(options);\n    };\n\n    cubes.Server.prototype.get_cube = function(name, callback, errCallback) {\n\n    \tvar self = this;\n\n        // Return the cube if already loaded\n        if((name in this._cubes) && callback){\n        \tvar jqxhr = $.Deferred();\n        \tjqxhr.error = function() { };\n        \tsetTimeout(function() {\n        \t\t// TODO: What is the correct ordering of success/complete callbacks?\n        \t\tcallback(self._cubes[name]);\n        \t\tjqxhr.resolve(); //.promise();\n        \t}, 0);\n        \treturn jqxhr;\n        }\n\n        var options = {dataType : 'json', type : \"GET\"};\n\n        options.url = self.url + 'cube/' + encodeURI(name) + '/model';\n\n        options.success = function(resp, status, xhr) {\n            // must parse dimensions first into a \"fake\" model\n            var cube = new cubes.Cube(resp);\n\n            self._cubes[name] = cube;\n\n            // FIXME: handle model parse failure\n            if (callback)\n                callback(cube);\n        };\n\n        options.error = function(resp, status, xhr) {\n            if (errCallback)\n                errCallback(resp);\n        };\n\n        return this.ajaxRequest(options);\n    };\n\n    /*\n     * The Cube\n     * ========\n     */\n\n    cubes.Cube = function(metadata) {\n        var i, obj;\n\n        this.name = metadata.name;\n        !metadata.label || (this.label = metadata.label);\n        !metadata.description || (this.description = metadata.description);\n        !metadata.key || (this.key = metadata.key);\n        !metadata.info || (this.info = metadata.info);\n        !metadata.category || (this.category = metadata.category);\n        !metadata.features || (this.features = metadata.features);\n\n        this.measures = _.map(metadata.measures || [], function(m) { return new cubes.Measure(m); });\n        this.aggregates = _.map(metadata.aggregates || [], function(m) { return new cubes.MeasureAggregate(m); });\n        this.details = _.map(metadata.details || [], function(m) { return new cubes.Attribute(m); });\n\n        this.dimensions = _.map(metadata.dimensions || [], function(dim) {return new cubes.Dimension(dim);} );\n    };\n\n    cubes.Cube.prototype.dimension = function(name) {\n        if ( _.isObject(name) )\n          return name;\n        // Return a dimension with given name\n        return _.find(this.dimensions, function(obj){return obj.name === name;});\n    };\n\n    /*\n     * Dimension\n     * =========\n     */\n\n    cubes.Dimension = function(md){\n        var dim = this;\n        var i;\n\n        dim.name = md.name;\n        dim.label = md.name;\n        !md.label || (dim.label = md.label);\n        !md.description || (dim.description = md.description);\n        !md.default_hierarchy_name || (dim.default_hierarchy_name = md.default_hierarchy_name);\n        !md.info || (dim.info = md.info);\n        !md.role || (dim.role = md.role);\n        !md.cardinality || (dim.cardinality = md.cardinality);\n        !md.nonadditive || (dim.nonadditive = md.nonadditive);\n\n        dim.levels = [];\n\n        if(md.levels) {\n            for(i in md.levels) {\n                var level = new cubes.Level(dim.name, md.levels[i]);\n                dim.levels.push(level);\n            }\n        }\n\n        this.hierarchies = {};\n\n        if(md.hierarchies) {\n            for(i in md.hierarchies) {\n                var hier = new cubes.Hierarchy(md.hierarchies[i], this);\n                dim.hierarchies[hier.name] = hier;\n            }\n        }\n\n        // if no default_hierarchy_name defined, use first hierarchy's name.\n        if ( ! dim.default_hierarchy_name && md.hierarchies\n                    && md.hierarchies.length > 0 ) {\n          dim.default_hierarchy_name = md.hierarchies[0].name;\n        }\n    };\n\n    cubes.Dimension.prototype.hierarchy = function(name) {\n        if ( _.isObject(name) )\n          return name;\n        if ( ! name ) {\n          return this.hierarchies[this.default_hierarchy_name];\n        }\n        // Return a hierarchy with given name\n        return this.hierarchies[name];\n    }\n\n    cubes.Dimension.prototype.level = function(name) {\n        if ( _.isObject(name) )\n          return name;\n        // Return a level with given name\n        return _.find(this.levels, function(obj) {return obj.name == name;});\n    };\n\n    cubes.Dimension.prototype.toString = function(desc) {\n        return this.name;\n    };\n\n    cubes.Dimension.prototype.display_label = function() {\n        return this.label || this.name;\n    };\n\n    cubes.Dimension.prototype.hierarchy = function(name) {\n        if ( _.isObject(name) )\n          return name;\n        else if(name != null)\n            return this.hierarchies[name];\n        else\n            return this.hierarchies[this.default_hierarchy_name];\n    };\n\n    /*\n     * Hierarchy\n     * ---------\n     */\n\n    cubes.Hierarchy = function(obj, dim) {\n        this.parse(obj, dim);\n    };\n\n    cubes.Hierarchy.prototype.parse = function(desc, dim) {\n        var hier = this;\n        var i;\n\n        hier.name = desc.name;\n        hier.label = hier.name;\n        !desc.label || (hier.label = desc.label)\n        !desc.description || (hier.description = desc.description)\n        !desc.info || (hier.info = desc.info);\n\n        var level_names = desc.levels || [];\n\n        hier.levels = _.map(level_names, function(name) {return dim.level(name);} );\n    };\n\n    cubes.Hierarchy.prototype.toString = function() {\n        return cubes.HIERARCHY_PREFIX_CHAR + this.name;\n    };\n\n    cubes.Hierarchy.prototype.display_label = function() {\n        return this.label || this.name;\n    };\n\n    /*\n     * Level\n     * -----\n     */\n\n    cubes.Level = function(dimension_name, obj){\n        this.parse(dimension_name, obj);\n    };\n\n    cubes.Level.prototype.parse = function(dimension_name, desc) {\n        var level = this;\n        var i;\n\n        level.dimension_name = dimension_name;\n        level.name = desc.name;\n        !desc.label || (level.label = desc.label);\n        !desc.description || (level.description = desc.description);\n        !desc.info || (level.info = desc.info);\n        level._key = desc.key;\n        level._label_attribute = desc.label_attribute;\n        level._order_attribute = desc.order_attribute;\n        !desc.role || (level.role = desc.role);\n        !desc.cardinality || (level.cardinality = desc.cardinality);\n        level.nonadditive = desc.nonadditive;\n\n        level.attributes = [];\n\n        if(desc.attributes) {\n            for(i in desc.attributes) {\n                var attr = new cubes.Attribute(desc.attributes[i]);\n                level.attributes.push(attr);\n            }\n        }\n    };\n\n    cubes.Level.prototype.key = function() {\n        // Key attribute is either explicitly specified or it is first attribute in the list\n        var key = this._key;\n        var the_attr = _.find(this.attributes, function(a) { return a.name === key; });\n        return the_attr || this.attributes[0];\n    };\n\n    cubes.Level.prototype.label_attribute = function() {\n        // Label attribute is either explicitly specified or it is second attribute if there are more\n        // than one, otherwise it is first\n        var the_attr = null;\n        if ( this._label_attribute ) {\n            var label_attribute = this._label_attribute;\n            the_attr = _.find(this.attributes, function(a) { return a.name === label_attribute; });\n        }\n        return the_attr || this.key();\n    };\n\n    cubes.Level.prototype.order_attribute = function() {\n        var the_attr = null;\n        var order_attribute = this._order_attribute;\n        if (order_attribute ) {\n          the_attr = _.find(this.attributes, function(a) { return a.name === order_attribute; });\n        }\n        return the_attr || this.label_attribute();\n    };\n\n    cubes.Level.prototype.toString = function() {\n        return this.name;\n    };\n\n    cubes.Level.prototype.display_name = function() {\n      return this.label || this.name;\n    };\n\n    cubes.Level.prototype.full_name = function() {\n        return this.dimension_name + cubes.ATTRIBUTE_STRING_SEPARATOR_CHAR + this.name;\n    };\n\n    cubes.Level.prototype.full_name_for_drilldown = function() {\n        return this.dimension_name + cubes.DIMENSION_STRING_SEPARATOR_CHAR + this.name;\n    };\n\n\n    /*\n     * Attributes, measures and measure aggregates\n     * -------------------------------------------\n     * */\n\n    cubes.Attribute = function(obj){\n        this.ref = obj.ref;\n        this.name = obj.name;\n        this.label = obj.label;\n        this.order = obj.order;\n        this.info = (obj.info || {});\n        this.description = obj.description;\n        this.format = obj.format;\n        this.missing_value = obj.missing_value;\n        this.locales = obj.locales;\n    };\n\n    cubes.Measure = function(obj){\n        this.ref = obj.ref;\n        this.name = obj.name;\n        this.label = obj.label;\n        this.order = obj.order;\n        this.info = (obj.info || {});\n        this.description = obj.description;\n        this.format = obj.format;\n        this.missing_value = obj.missing_value;\n        this.nonadditive = obj.nonadditive;\n        if (obj.aggregates) {\n            this.aggregates = obj.aggregates;\n        }\n    };\n    cubes.MeasureAggregate = function(obj){\n        this.ref = obj.ref;\n        this.name = obj.name;\n        this.label = obj.label;\n        this.order = obj.order;\n        this.locales = obj.locales;\n        this.info = (obj.info || {});\n        this.description = obj.description;\n        this.format = obj.format;\n        this.missing_value = obj.missing_value;\n        this.nonadditive = obj.nonadditive;\n\n        this[\"function\"] = obj[\"function\"];\n        this.measure = obj.measure;\n    };\n\n\n    /*\n     * Browser\n     * =======\n     * */\n\n    cubes.Browser = function(server, cube){\n        this.cube = cube;\n        this.server = server;\n    };\n\n    cubes.Browser.prototype.full_cube = function() {\n        return new cubes.Cell(this.cube);\n    };\n\n    cubes.Browser.prototype.aggregate = function(args, callback) {\n        if ( ! args )\n          args = {};\n\n        var http_args = {};\n\n        if (args.cut) http_args.cut = args.cut.toString();\n        if (args.measure) http_args.measure = args.measure.toString();\n        if (args.drilldown) http_args.drilldown = args.drilldown.toString();\n        if (args.split) http_args.split = args.split.toString();\n        if (args.order) http_args.order = args.order.toString();\n        if (args.page) http_args.page = args.page;\n        if (args.pagesize) http_args.pagesize = args.pagesize;\n\n        return this.server.query(\"aggregate\", this.cube, args, callback);\n    };\n\n    cubes.Browser.prototype.facts = function(args, callback) {\n        if ( ! args )\n          args = {};\n\n        var http_args = {};\n\n        if (args.cut) http_args.cut = args.cut.toString();\n        if (args.order) http_args.order = args.order.toString();\n        if (args.page) http_args.page = args.page;\n        if (args.pagesize) http_args.pagesize = args.pagesize;\n\n        return this.server.query(\"facts\", this.cube, args, callback);\n    };\n\n    cubes.Drilldown = function(dimension, hierarchy, level) {\n        if ( ! _.isObject(dimension) )\n            throw \"Drilldown requires a Dimension object as first argument\";\n        this.dimension = dimension;\n        this.hierarchy = dimension.hierarchy(hierarchy);\n        this.level = dimension.level(level) || this.hierarchy.levels[0];\n        if ( ! this.hierarchy )\n            throw \"Drilldown cannot recognize hierarchy \" + hierarchy + \" for dimension \" + dimension;\n        if ( ! this.level )\n            throw \"Drilldown cannot recognize level \" + level  + \" for dimension \" + dimension;\n    };\n\n    cubes.Drilldown.prototype.toString = function() {\n        return \"\" + this.dimension + this.hierarchy + cubes.DIMENSION_STRING_SEPARATOR_CHAR + this.level;\n    };\n\n    cubes.Drilldown.prototype.keysInResultCell = function() {\n        var drill = this;\n        var saw_this_level = false;\n        var levels_to_look_for = _.filter(drill.hierarchy.levels, function(lvl) { return ( lvl.key() === drill.level.key() && (saw_this_level = true) ) || ( ! saw_this_level ); });\n        return _.map(levels_to_look_for, function(lvl) { return lvl.key().ref });\n    }\n\n    cubes.Drilldown.prototype.labelsInResultCell = function() {\n        var drill = this;\n        var saw_this_level = false;\n        var levels_to_look_for = _.filter(drill.hierarchy.levels, function(lvl) { return ( lvl.key() === drill.level.key() && (saw_this_level = true) ) || ( ! saw_this_level ); });\n        return _.map(levels_to_look_for, function(lvl) { return lvl.label_attribute().ref });\n    }\n\n    cubes.Cell = function(cube, cuts) {\n        this.cube = cube;\n        this.cuts = _.map((cuts || []), function(i) { return i; });\n    };\n\n    cubes.Cell.prototype.slice = function(new_cut) {\n        var cuts = [];\n        var new_cut_pushed = false;\n        for (var i = 0; i < this.cuts.length; i++) {\n          var c = this.cuts[i];\n          if ( c.dimension == new_cut.dimension ){\n            cuts.push(new_cut);\n            new_cut_pushed = true;\n          }\n          else {\n            cuts.push(c);\n          }\n        }\n        if ( ! new_cut_pushed ) {\n          cuts.push(new_cut);\n        }\n        var cell = new cubes.Cell(this.cube, cuts);\n        return cell;\n    };\n\n    cubes.Cell.prototype.toString = function() {\n        return _.map(this.cuts || [], function(cut) { return cut.toString(); }).join(cubes.CUT_STRING_SEPARATOR_CHAR);\n    };\n\n    cubes.Cell.prototype.cut_for_dimension = function(name) {\n        return _.find(this.cuts, function(cut) {\n            return cut.dimension.name == name;\n        });\n    };\n\n    cubes.PointCut = function(dimension, hierarchy, path, invert) {\n        this.type = 'point';\n        this.dimension = dimension;\n        this.hierarchy = dimension.hierarchy(hierarchy);\n        this.path = path;\n        this.invert = !!invert;\n    };\n\n    cubes.PointCut.prototype.toString = function() {\n        var path_str = cubes.string_from_path(this.path);\n        return (this.invert ? cubes.CUT_INVERSION_CHAR : \"\") +\n            this.dimension +\n            ( this.hierarchy || '' ) +\n            cubes.DIMENSION_STRING_SEPARATOR_CHAR +\n            path_str;\n    };\n\n    cubes.SetCut = function(dimension, hierarchy, paths, invert) {\n        this.type = 'set';\n        this.dimension = dimension;\n        this.hierarchy = dimension.hierarchy(hierarchy);\n        this.paths = paths;\n        this.invert = !!invert;\n    };\n\n    cubes.SetCut.prototype.toString = function() {\n        var path_str = _.map(this.paths, cubes.string_from_path).join(cubes.SET_CUT_SEPARATOR_CHAR);\n        return (this.invert ? cubes.CUT_INVERSION_CHAR : \"\") +\n            this.dimension +\n            ( this.hierarchy || '' ) +\n            cubes.DIMENSION_STRING_SEPARATOR_CHAR +\n            path_str;\n    };\n\n    cubes.RangeCut = function(dimension, hierarchy, from_path, to_path, invert){\n        this.type = 'range';\n        this.dimension = dimension;\n        this.hierarchy = dimension.hierarchy(hierarchy);\n        if ( from_path === null && to_path === null ) {\n            throw \"Either from_path or to_path must be defined for RangeCut\";\n        }\n        this.from_path = from_path;\n        this.to_path = to_path;\n        this.invert = !!invert;\n    };\n\n    cubes.RangeCut.prototype.toString = function() {\n        var path_str = cubes.string_from_path(this.from_path) + cubes.RANGE_CUT_SEPARATOR_CHAR + cubes.string_from_path(this.to_path);\n        return (this.invert ? cubes.CUT_INVERSION_CHAR : \"\") +\n            this.dimension +\n            ( this.hierarchy || '' ) +\n            cubes.DIMENSION_STRING_SEPARATOR_CHAR +\n            path_str;\n    };\n\n    cubes.CUT_INVERSION_CHAR = \"!\";\n    cubes.CUT_STRING_SEPARATOR_CHAR = \"|\";\n    cubes.DIMENSION_STRING_SEPARATOR_CHAR = \":\";\n    cubes.ATTRIBUTE_STRING_SEPARATOR_CHAR = \".\";\n    cubes.HIERARCHY_PREFIX_CHAR = \"@\";\n    cubes.PATH_STRING_SEPARATOR_CHAR = \",\";\n    cubes.RANGE_CUT_SEPARATOR_CHAR = \"-\";\n    cubes.SET_CUT_SEPARATOR_CHAR = \";\";\n\n    cubes.CUT_STRING_SEPARATOR = /\\|/g;\n    cubes.DIMENSION_STRING_SEPARATOR = /:/g;\n    cubes.PATH_STRING_SEPARATOR = /,/g;\n    cubes.RANGE_CUT_SEPARATOR = /-/g;\n    cubes.SET_CUT_SEPARATOR = /;/g;\n\n    cubes.PATH_PART_ESCAPE_PATTERN = /([\\\\!|:;,-])/g;\n    cubes.PATH_PART_UNESCAPE_PATTERN = /\\\\([\\\\!|:;,-])/g;\n\n    cubes.CUT_PARSE_REGEXP = new RegExp(\"^(\" + cubes.CUT_INVERSION_CHAR + \"?)(\\\\w+)(?:\" + cubes.HIERARCHY_PREFIX_CHAR + \"(\\\\w+))?\" + cubes.DIMENSION_STRING_SEPARATOR_CHAR + \"(.*)$\")\n    cubes.DRILLDOWN_PARSE_REGEXP = new RegExp(\"^(\\\\w+)(?:\" + cubes.HIERARCHY_PREFIX_CHAR + \"(\\\\w+))?(?:\" + cubes.DIMENSION_STRING_SEPARATOR_CHAR + \"(\\\\w+))?$\")\n    cubes.NULL_PART_STRING = '__null__';\n    cubes.SPLIT_DIMENSION_STRING = '__within_split__';\n\n    cubes.SPLIT_DIMENSION = new cubes.Dimension({\n      name: cubes.SPLIT_DIMENSION_STRING,\n      label: 'Matches Filters',\n      hierarchies: [ { name: 'default', levels: [ cubes.SPLIT_DIMENSION_STRING ] } ],\n      levels: [ { name: cubes.SPLIT_DIMENSION_STRING, attributes: [{name: cubes.SPLIT_DIMENSION_STRING}], label: 'Matches Filters' } ]\n    });\n\n    cubes._split_with_negative_lookbehind = function(input, regex, lb) {\n      var string = input;\n      var match;\n      var splits = [];\n\n\n      while ((match = regex.exec(string)) != null) {\n          if ( string.substr(match.index - lb.length, lb.length) != lb ) {\n            splits.push(string.substring(0, match.index));\n            string = string.substring(Math.min(match.index + match[0].length, string.length));\n            regex.lastIndex = 0;\n          }\n          else {\n            // match has the lookbehind, must exclude\n        \t// TODO: I suspect an infinite loop on this branch as the string is not modified\n          }\n      }\n      splits.push(string);\n      return splits;\n    }\n\n    cubes._escape_path_part = function(part) {\n        if ( part == null ) {\n          return cubes.NULL_PART_STRING;\n        }\n        return part.toString().replace(cubes.PATH_PART_ESCAPE_PATTERN, function(match, b1) { return \"\\\\\" + b1; });\n    };\n\n    cubes._unescape_path_part = function(part) {\n        if ( part === cubes.NULL_PART_STRING ) {\n          return null;\n        }\n        return part.replace(cubes.PATH_PART_UNESCAPE_PATTERN, function(match, b1) { return b1; });\n    };\n\n    cubes.string_from_path = function(path){\n        var fixed_path = _.map(path || [], function(element) {return cubes._escape_path_part(element);}).join(cubes.PATH_STRING_SEPARATOR_CHAR);\n        return fixed_path;\n    };\n\n    cubes.path_from_string = function(path_string) {\n        var paths = cubes._split_with_negative_lookbehind(path_string, cubes.PATH_STRING_SEPARATOR, '\\\\');\n        var parsed = _.map(paths || [], function(e) { return cubes._unescape_path_part(e); });\n        return parsed;\n    };\n\n    cubes.cut_from_string = function(cube_or_model, cut_string) {\n        // parse out invert, dim_name, hierarchy, and path thingy\n        var match = cubes.CUT_PARSE_REGEXP.exec(cut_string);\n        if (!match) {\n          return null;\n        }\n        var invert = !!(match[1]),\n            dim_name = match[2],\n            hierarchy = match[3] || null,\n            path_thingy = match[4];\n        var dimension = cube_or_model.dimension(dim_name);\n        // if path thingy splits on set separator, make a SetCut.\n        var splits = cubes._split_with_negative_lookbehind(path_thingy, cubes.SET_CUT_SEPARATOR, '\\\\');\n        if ( splits.length > 1 ) {\n          return new cubes.SetCut(dimension, hierarchy, _.map(splits, function(ss) { return cubes.path_from_string(ss); }), invert);\n        }\n        // else if path thingy splits into two on range separator, make a RangeCut.\n        splits = cubes._split_with_negative_lookbehind(path_thingy, cubes.RANGE_CUT_SEPARATOR, '\\\\');\n        if ( splits.length == 2 ) {\n          var from_path = splits[0] ? cubes.path_from_string(splits[0]) : null;\n          var to_path = splits[1] ? cubes.path_from_string(splits[1]) : null;\n          return new cubes.RangeCut(dimension, hierarchy, from_path, to_path, invert);\n        }\n        // else it's a PointCut.\n        return new cubes.PointCut(dimension, hierarchy, cubes.path_from_string(path_thingy), invert);\n    };\n\n    cubes.cuts_from_string = function(cube_or_model, cut_param_value) {\n        var cut_strings = cubes._split_with_negative_lookbehind(cut_param_value, cubes.CUT_STRING_SEPARATOR, '\\\\');\n        return _.map(cut_strings || [], function(e) { return cubes.cut_from_string(cube_or_model, e); });\n    };\n\n    cubes.cell_from_string = function(cube, cut_param_value) {\n        return new cubes.Cell(cube, cubes.cuts_from_string(cube, cut_param_value));\n    };\n\n    cubes.drilldown_from_string = function(cube_or_model, drilldown_string) {\n        var match = cubes.DRILLDOWN_PARSE_REGEXP.exec(drilldown_string);\n        if (!match) {\n          return null;\n        }\n        var dim_name = match[1],\n            hierarchy = match[2] || null,\n            level = match[3] || null;\n        var dimension = cube_or_model.dimension(dim_name);\n        if ( ! dimension )\n          if ( dim_name === cubes.SPLIT_DIMENSION_STRING )\n            dimension = cubes.SPLIT_DIMENSION;\n          else\n            return null;\n        return new cubes.Drilldown(dimension, hierarchy, level);\n    };\n\n    cubes.drilldowns_from_string = function(cube_or_model, drilldown_param_value) {\n        var dd_strings = cubes._split_with_negative_lookbehind(drilldown_param_value, cubes.CUT_STRING_SEPARATOR, '\\\\');\n        return _.map(dd_strings || [], function(e) { return cubes.drilldown_from_string(cube_or_model, e); });\n    };\n\n    cubes.drilldowns_to_string = function(drilldowns) {\n      return _.map(drilldowns, function(d) { return d.toString(); }).join(cubes.CUT_STRING_SEPARATOR_CHAR);\n    };\n\n    root['cubes'] = cubes;\n\n}).call(this);\n"
  },
  {
    "path": "cubesviewer/cubesviewer.less",
    "content": "/*\n * Cubesviewer CSS\n */\n\n.cv-bootstrap {\n\n    @import \"bower_components/bootstrap/less/bootstrap.less\";\n    @import \"bower_components/bootstrap/less/responsive-embed.less\";\n    /*@import \"bower_components/bootstrap-submenu/less/bootstrap-submenu.less\";*/\n\n    @font-family-sans-serif:  Helvetica, Arial, sans-serif;\n    @font-family-serif:       Georgia, \"Times New Roman\", Times, serif;\n    @font-family-monospace:   Menlo, Monaco, Consolas, \"Courier New\", monospace;\n    @font-family-base:        @font-family-sans-serif;\n\n    @font-size-base: 12px;\n    @panel-heading-padding: 5px 5px;\n    @panel-body-padding: 5px;\n\n    @grid-gutter-width: 10px;\n\n    font-size: 12px;\n    font-family: Arial, Helvetica, sans-serif;\n\n    .panel {\n       margin-bottom: 10px;\n    }\n\n    h3 {\n        margin-top: 0px;\n        margin-bottom: 5px;\n    }\n\n    /* UI grid hacks */\n    .ui-grid-pager-panel {\n        margin-bottom: -32px;\n    }\n    .ui-grid-pager-control-input {\n        width: 70px;\n    }\n    .ui-grid-pager-max-pages-number {\n        vertical-align: middle;\n    }\n    .ui-grid-selection-row-header-buttons {\n        margin-left: -2px;\n    }\n    .ui-grid-column-menu-button:focus {\n        outline: none;\n    }\n    .ui-grid-menu-button {\n        height: 24px;\n        width: 13px;\n        top: 0px;\n        right: 0px;\n        text-align: center;\n    }\n    .ui-grid-menu-button i::before {\n        margin: 0px;\n    }\n    .ui-grid-menu-mid {\n        max-height: 200px !important;\n        width: 190px;\n        overflow-x: hidden !important;\n    }\n    .ui-grid-menu .ui-grid-menu-inner ul li button {\n        padding: 6px;\n    }\n    div.ui-grid-pager-panel {\n        height: 32px;\n        white-space: nowrap;\n        overflow: hidden;\n    }\n    .ui-grid-canvas {\n        -webkit-touch-callout: initial;\n        -webkit-user-select: initial;\n        -khtml-user-select: initial;\n        -moz-user-select: initial;\n        -ms-user-select: initial;\n        user-select: initial;\n    }\n    .ui-grid-row:nth-child(even) .ui-grid-cell {\n        background-color: #F1F4FF;\n    }\n    .ui-grid-row .ui-grid-cell.ui-grid-row-header-cell {\n        background-color: #f0f0ee;\n    }\n\n\n    /* Datepicker popup hack */\n    div ul.uib-datepicker-popup.dropdown-menu {\n        display: block;\n        font-size: 12px;\n        padding: 0px 0px 10px 0px;\n    }\n    .cv-infopiece .uib-datepicker-popup.dropdown-menu button {\n        line-height: 1.5;\n        padding: 4px 8px;\n    }\n\n    /* Override glyphicon and use fontawesome */\n    .cv-view-panel .glyphicon {\n        display: inline-block;\n        font: normal normal normal 14px/1 FontAwesome;\n        font-size: inherit;\n        text-rendering: auto;\n        -webkit-font-smoothing: antialiased;\n    }\n    .glyphicon.glyphicon-chevron-left:before {\n        content: \"\\f053\";\n    }\n    .glyphicon.glyphicon-chevron-right:before {\n        content: \"\\f054\";\n    }\n\n}\n\n\n/*\n*/\n\n.cv-view-panel, .cv-gui-viewcontainer {\n\t-webkit-touch-callout: none;\n\t-webkit-user-select: none;\n\t-khtml-user-select: none;\n\t-moz-user-select: none;\n\t-ms-user-select: none;\n\tuser-select: none;\n}\n\n.cv-gui-panel .dropdown-menu li {\n    cursor: pointer;\n}\n\n.cv-view-panel .dropdown-menu li {\n    cursor: pointer;\n}\n\n.cv-gui-title {\n    font-weight: bold;\n}\n\n.cv-alerts {\n    position: fixed;\n    bottom: 10px;\n    right: 10px;\n    z-index: 5000;\n}\n\n/*\n.cv-view-panel a:link {\n\ttext-decoration: none;\n}\n*/\n\n.cv-grid-header-dimension {\n    color: #004400;\n}\n.cv-grid-header-dimensionattribute {\n    color: #666666;\n}\n.cv-grid-header-measure {\n    color: #444477;\n}\n\n\n\n/*\n.ui-slider-range {\n    background-color: red;\n    background-image: none;\n}\n\n.cv-view-panel div {\n\tmargin: 0px;\n\tpadding: 0px;\n}\n*/\n\n/*\n.cv-view-panel td, th {\n    vertical-align: middle;\n    text-align: inherit;\n    padding: 2px 2px 2px 2px;\n}\n\n.cv-view-panel input[type=checkbox] {\n    margin: 0px !important;\n}\n*/\n\n/* Override blueprint highlight */\n/*\n.cv-view-panel .highlight {background: inherit;}\n*/\n\n/*\nCustom Cubesviewer styles\n*/\n\n/*\n.cv-view-panel input {\n    vertical-align: middle;\n}\n\n.cv-view-panel input {\n\tborder: 1px solid #d0d0d0;\n\tpadding: 0px 2px 0px 2px;\n}\n\n.cv-view-panel h1 {\n    font-variant: small-caps;\n    font-weight: bold;\n    margin: 0px 0px 10px 0px;\n    color: #8686BF;\n    font-size: 20pt;\n}\n\n.cv-view-panel h2 {f\n    font-variant: small-caps;\n    font-weight: bold;\n    margin: 0px 0px 10px 0px;\n    color: #8686BF;\n    font-size: 16pt;\n}\n\n.cv-view-panel h3, .nvtooltip h3 {\n    font-variant: small-caps;\n    font-weight: bold;\n    margin: 0px 0px 10px 0px;\n    color: #8686BF;\n    font-size: 12pt;\n}\n\n.cv-view-panel label {\n    font-weight: inherit;\n}\n*/\n\n\n.cv-view-panel th {\n    white-space: nowrap;\n}\n\n\n\n.nobreak {\n    overflow: hidden;\n    white-space: nowrap;\n}\n\n.ui-jqgrid tr.jqgrow td {\n    white-space: nowrap !important;\n    /*overflow: hidden;*/\n}\n\n/* GUI Elements */\n\n.cv-gui-panel {\n    z-index: 9999;\n    margin-bottom: 10px;\n}\n\n.cv-gui-workspace {\n    /*margin-left: 230px;*/\n    min-height: 320px;\n}\n\ndiv.cv-gui-viewcontainer {\n\tmargin-bottom: 10px;\n}\n\ndiv.cv-gui-panelsection {\n\tmargin-bottom: 10px;\n}\n\ndiv.cv-view-viewinfo {\n\tmargin-top: 5px;\n\tmargin-bottom: 10px;\n}\n\ndiv.cv-infopiece {\n    display: inline-block;\n}\ndiv.cv-infopiece>span {\n    vertical-align: middle;\n    display: inline-block;\n    text-overflow: ellipsis;\n    overflow: hidden;\n}\n\ndiv.label.cv-infopiece {\n    font-size: inherit;\n    margin-bottom: 5px;\n    margin-right: 5px;\n    display: inline-block;\n}\n\ndiv.label.cv-infopiece button {\n    line-height: 1.0;\n    padding: 1px;\n}\n\n.fixed {\n   position: fixed;\n}\n\n.nvtooltip table {\n\tmargin: 0px ;\n}\n.nvtooltip table td {\n    border: none;\n}\ndiv.nvtooltip {\n\tbackground-color : rgba(255,255,255,0.9);\n}\n\n/*\n.ui-grid .ui-grid-render-container-body .ui-grid-viewport {\n    overflow-x: auto !important;\n}\n*/\n\n\n/* Loading bar */\n\n.loadingbar-content {\n    width: 100%;\n    /* Full Width */\n    height: 3px;\n    margin: -4px 0px 1px 0px;\n    //position: fixed;\n    position: relative;\n    overflow-x: hidden;\n}\n\n.loadingbar-expand {\n    width: 99%;\n    height: 1px;\n    margin: 1px 0;\n    background: #2187e7;\n    position: absolute;\n    box-shadow: 0px 0px 6px 1px rgba(0,198,255,0.8);\n    -moz-animation: fullexpand 60s ease-out;\n    -webkit-animation: fullexpand 60s ease-out;\n}\n\n@-moz-keyframes fullexpand {\n    0%  { width: 0px; }\n    20%  { width: 50%; }\n    40% { width: 75%; }\n    60% { width: 85%; }\n    80% { width: 95%; }\n    100% { width: 99%; }\n}\n\n@-webkit-keyframes fullexpand {\n    0%  { width: 0px; }\n    20%  { width: 50%; }\n    40% { width: 75%; }\n    60% { width: 90%; }\n    80% { width: 95%; }\n    100% { width: 99%; }\n}\n\n/*\nCV Logo\n*/\n.cv-logo-embedded {\n    background:\n        url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAAeCAYAAACIeIa4AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4AUIAQ8FIfSUygAABKVJREFUWMPtmE9MHFUYwH9vWRYoQiuFoKE1kGBDXzlosbFeuEClakxjTNrYYkyLKaniQaMmcjAeqknFYE1EUiMxNPGgHAwR1IQ0aaE1RY1iUr9tqYm0B638EdYCLt0/42FmYXachV0YDk36JZvd/d68N/Ob9/17H9yR21PUWhcwtPYDXwNPKpEFmx4lgqF1N9ChRL53zEOJJH7XAgeAaqAIyAMiwCzwB/CtEul0zltXOEPrTcAvwH3ANKCVyA1D68TaXwL7rMtrlciQDVoBzwDvAmVp3vJDoF2J/J4OpFoDWAHwl/WWEzID3KtEwobW3wB7HdPqlcgZQ+ty4Fdgwypv/7oSaVuXnTO0vgu4CtzjMjwNXAMecBmLA+8DLwGBRW00CpEI7NoFO3dCYSHE4zA6CoODMD0N+fnOtQaUyKPL7aDKAChhTuXAKJC9Zo+PRqG4GA4dgqNHwe93v254GE6ehJER8PnsIz8BDwNRN0CV4Y4VA+NeBCLTC2uhszP968+cgeZmyMmxa99TIq+5Xe5LZ8es7/uBMU/AwmFobMwMDKCuDvr6nNpXDa33ZGyWNlOsAX70LAHt3g1dXaufPzQETU2QvegZVwHtNE+Vxs5VWZHN5wnY/DxcvAilpUnqyOQk/4yMELt5E+X3s6Gykvzt21Ov09oKvb12TbkSubaiWdpM8TEg6BlYPG4GDztYPM7MhQv8fe4csdlZUAojFmMuGGSyv5/Y3Jz7WgcPQixm17Ss6HM2U3zCqjy8lWPHkv7OBoPcGh9HZWU5nsxHPBJhamAAIxnClOpqyLOnWJ5dEc4Cexz4ynOwjRuhoGDpRUYizAWDoJb3jvD16+4D9fX23StdFs7QGkPrl4F+z8K9XXJzk3LZrakpZ95yT4ehkPvAtm2mqS89f9FyO5cFNKxbmW4YyVbi8/1Pl3ERkLzrsZRwSiSmRPYCPesCFw6bZZYlgZKStOCyi4rcBy5dSoJTIqF0Asp+4DPP4WZmYGLC9jYVhTU1qQENA18gQO7Wre7jg4OwFIh+SzegoEQagY89hfP5oC25mM+rqCC3vNwEtH2MWAx/YSGbGxrcA87wcJIVAKczri0NrTuAFzwDXFgwk++OHckpMBxm7vJloqEQvkCAvMpK02xTSXMznD9v97UtSuTGasqvd4A3PAOsrHRWF5lJdzccPw6BxVPTz8BDSiSeduFsM9FW4E3P4IJBOHzYWWGkJ2fPwokTdjCARifYao48rcDbnkGWlZlVfvKDppb2djh1ynnua1EiHV4dVo8AXWvEMgCFYZjRrr7e9KGqKvdc1t0NPT0wNmaPjgCnlchzqU7jq20zPG9FUrf5bUCT1cVySg/wAdAHbEpK7vPzZnvB3ma4csVsNeTk2I83CflIibzoSZvBBXA/8LlDfUSJfGpoXQL8aVU8CelQIi3W3DzguxR9lhXjLbBHiQytmHlW3fAU+QKos5o+APssMJTIBFABzNtaAS2Jo5QS+VeJPAg8ksHJYwZotrprQ4m11qu1l/DBp4DNSuQTp4kYWhcCryiRt1zG7E3Zu4GngVpgC5ALRIGQ1RftVSI/ZNqUvSO3q/wHjjvb2rWTZoYAAAAASUVORK5CYII=)\n        no-repeat\n        left center;\n    width: 55px;\n    height: 30px;\n    display: inline-block;\n    vertical-align: middle;\n}\n"
  },
  {
    "path": "cubesviewer/cubesviewer.templates.js",
    "content": "angular.module('cv').run(['$templateCache', function($templateCache) {\n  'use strict';\n\n  $templateCache.put('dialog/dialog.html',\n    \"  <div class=\\\"modal-header\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"    <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"fa fa-fw fa-exclamation\\\"></i> CubesViewer</h4>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-body\\\">\\n\" +\n    \"        <p>{{ dialog.text }}</p>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-footer\\\">\\n\" +\n    \"    <!-- <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"btn btn-secondary\\\" data-dismiss=\\\"modal\\\">Cancel</button>  -->\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"btn btn-primary\\\" data-dismiss=\\\"modal\\\">Close</button>\\n\" +\n    \"  </div>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/about.html',\n    \"<div class=\\\"modal fade\\\" id=\\\"cvAboutModal\\\" tabindex=\\\"-1\\\" role=\\\"dialog\\\" aria-labelledby=\\\"\\\">\\n\" +\n    \"  <div class=\\\"modal-dialog\\\" role=\\\"document\\\">\\n\" +\n    \"    <div class=\\\"modal-content\\\">\\n\" +\n    \"      <div class=\\\"modal-header\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"        <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"cv-logo-embedded\\\"></i> CubesViewer</h4>\\n\" +\n    \"      </div>\\n\" +\n    \"      <div class=\\\"modal-body\\\">\\n\" +\n    \"\\n\" +\n    \"            <p><a href=\\\"http://jjmontesl.github.io/cubesviewer/\\\" target=\\\"_blank\\\">CubesViewer</a> is a visual, web-based application for exploring and analyzing\\n\" +\n    \"            OLAP databases served by the <a href=\\\"http://cubes.databrewery.org/\\\" target=\\\"_blank\\\">Cubes OLAP Framework</a>.</p>\\n\" +\n    \"            <hr />\\n\" +\n    \"\\n\" +\n    \"            <p>Version {{ cvVersion }}<br />\\n\" +\n    \"            <a href=\\\"https://github.com/jjmontesl/cubesviewer/\\\" target=\\\"_blank\\\">https://github.com/jjmontesl/cubesviewer/</a></p>\\n\" +\n    \"\\n\" +\n    \"            <p>by José Juan Montes and others (see AUTHORS)<br />\\n\" +\n    \"            2012 - 2016</p>\\n\" +\n    \"\\n\" +\n    \"            <p>\\n\" +\n    \"            <a href=\\\"http://github.com/jjmontesl/cubesviewer/blob/master/LICENSE.txt\\\" target=\\\"_blank\\\">LICENSE</a>\\n\" +\n    \"            </p>\\n\" +\n    \"\\n\" +\n    \"      </div>\\n\" +\n    \"      <div class=\\\"modal-footer\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-default\\\" data-dismiss=\\\"modal\\\"><i class=\\\"fa fa-cube\\\"></i> Close</button>\\n\" +\n    \"      </div>\\n\" +\n    \"    </div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/panel.html',\n    \"<div class=\\\"cv-bootstrap cv-gui-viewcontainer\\\" ng-controller=\\\"CubesViewerStudioViewController\\\">\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"panel panel-primary\\\">\\n\" +\n    \"        <div ng-if=\\\"! cvOptions.hideControls\\\" class=\\\"panel-heading\\\">\\n\" +\n    \"\\n\" +\n    \"            <button type=\\\"button\\\" ng-click=\\\"studioViewsService.closeView(view)\\\" class=\\\"btn btn-danger btn-xs pull-right hidden-print\\\" style=\\\"margin-left: 10px;\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></button>\\n\" +\n    \"            <button type=\\\"button\\\" ng-click=\\\"studioViewsService.toggleCollapseView(view)\\\" class=\\\"btn btn-primary btn-xs pull-right hidden-print\\\" style=\\\"margin-left: 5px;\\\"><i class=\\\"fa fa-fw\\\" ng-class=\\\"{'fa-caret-up': !view.collapsed, 'fa-caret-down': view.collapsed }\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"            <i class=\\\"fa fa-fw fa-file\\\"></i> <span class=\\\"cv-gui-title\\\" style=\\\"cursor: pointer;\\\" ng-dblclick=\\\"studioViewsService.studioScope.showRenameView(view)\\\"><a name=\\\"cvView{{ view.id }}\\\"></a>{{ view.params.name }}</span>\\n\" +\n    \"\\n\" +\n    \"            <span ng-if=\\\"view.savedId > 0 && reststoreService.isViewChanged(view)\\\" class=\\\"badge cv-gui-container-state\\\" style=\\\"margin-left: 15px; font-size: 80%;\\\">Modified</span>\\n\" +\n    \"            <span ng-if=\\\"view.savedId > 0 && !reststoreService.isViewChanged(view)\\\" class=\\\"badge cv-gui-container-state\\\" style=\\\"margin-left: 15px; font-size: 80%;\\\">Saved</span>\\n\" +\n    \"            <span ng-if=\\\"view.shared\\\" class=\\\"badge cv-gui-container-state\\\" style=\\\"margin-left: 5px; font-size: 80%;\\\">Shared</span>\\n\" +\n    \"\\n\" +\n    \"            <button type=\\\"button\\\" class=\\\"btn btn-danger btn-xs\\\" style=\\\"visibility: hidden;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"        <div class=\\\"panel-body\\\" ng-hide=\\\"view.collapsed\\\">\\n\" +\n    \"            <div class=\\\"cv-gui-viewcontent\\\">\\n\" +\n    \"\\n\" +\n    \"                <div cv-view-cube view=\\\"view\\\"></div>\\n\" +\n    \"\\n\" +\n    \"            </div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('studio/rename.html',\n    \"  <div class=\\\"modal-header\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close();\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"    <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"fa fa-pencil\\\"></i> Rename view</h4>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-body\\\">\\n\" +\n    \"\\n\" +\n    \"        <form class=\\\"form\\\" ng-submit=\\\"renameView(viewName);\\\">\\n\" +\n    \"            <div class=\\\"form-group\\\">\\n\" +\n    \"                <label for=\\\"serializedView\\\">Name:</label>\\n\" +\n    \"                <input class=\\\"form-control\\\" ng-model=\\\"viewName\\\" />\\n\" +\n    \"            </div>\\n\" +\n    \"        </form>\\n\" +\n    \"\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-footer\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close();\\\" class=\\\"btn btn-secondary\\\" data-dismiss=\\\"modal\\\">Cancel</button>\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"renameView(viewName);\\\" class=\\\"btn btn-primary\\\" data-dismiss=\\\"modal\\\">Rename</button>\\n\" +\n    \"  </div>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/serialize-add.html',\n    \"  <div class=\\\"modal-header\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"    <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"fa fa-code\\\"></i> Add view from serialized JSON</h4>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-body\\\">\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"form\\\">\\n\" +\n    \"            <label for=\\\"serializedView\\\">Code:</label>\\n\" +\n    \"            <textarea class=\\\"form-control\\\" ng-model=\\\"serializedView\\\" style=\\\"width: 100%; height: 12em;\\\" />\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-footer\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"btn btn-secondary\\\" data-dismiss=\\\"modal\\\">Cancel</button>\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"addSerializedView(serializedView)\\\" class=\\\"btn btn-primary\\\" data-dismiss=\\\"modal\\\">Add View</button>\\n\" +\n    \"  </div>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/serialize-view.html',\n    \"  <div class=\\\"modal-header\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"    <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"fa fa-code\\\"></i> Serialized View</h4>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-body\\\">\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"form\\\">\\n\" +\n    \"            <label for=\\\"serializedView\\\">View definition JSON:</label>\\n\" +\n    \"            <textarea class=\\\"form-control cv-serialized-view\\\" ng-bind=\\\"serializedView\\\" style=\\\"width: 100%; height: 12em;\\\" readonly></textarea>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"  </div>\\n\" +\n    \"  <div class=\\\"modal-footer\\\">\\n\" +\n    \"    <button type=\\\"button\\\" ng-click=\\\"close()\\\" class=\\\"btn btn-default\\\" data-dismiss=\\\"modal\\\">Close</button>\\n\" +\n    \"  </div>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/serverinfo.html',\n    \"<div class=\\\"modal fade\\\" id=\\\"cvServerInfo\\\" tabindex=\\\"-1\\\" role=\\\"dialog\\\" aria-labelledby=\\\"\\\">\\n\" +\n    \"  <div class=\\\"modal-dialog\\\" role=\\\"document\\\">\\n\" +\n    \"    <div class=\\\"modal-content\\\">\\n\" +\n    \"      <div class=\\\"modal-header\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"close\\\" data-dismiss=\\\"modal\\\" aria-label=\\\"Close\\\"><span aria-hidden=\\\"true\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></span></button>\\n\" +\n    \"        <h4 class=\\\"modal-title\\\" id=\\\"myModalLabel\\\"><i class=\\\"fa fa-fw fa-database\\\"></i> Server info</h4>\\n\" +\n    \"      </div>\\n\" +\n    \"      <div class=\\\"modal-body\\\">\\n\" +\n    \"\\n\" +\n    \"            <p>\\n\" +\n    \"                <i>This CubesViewer version supports Cubes Server version 1.0.x and 1.1.x</i><br />\\n\" +\n    \"                <br />\\n\" +\n    \"                <b>Server version:</b> {{ cubesService.cubesserver.server_version }} <br />\\n\" +\n    \"                <b>Cubes version:</b> {{ cubesService.cubesserver.cubes_version }} <br />\\n\" +\n    \"                <b>API version:</b> {{ cubesService.cubesserver.api_version }} <br />\\n\" +\n    \"            </p>\\n\" +\n    \"            <p>\\n\" +\n    \"                <b>Timezone:</b> {{ cubesService.cubesserver.info.timezone }} <br />\\n\" +\n    \"                <b>Week start:</b> {{ cubesService.cubesserver.info.first_weekday }} <br />\\n\" +\n    \"            </p>\\n\" +\n    \"            <p>\\n\" +\n    \"                <b>Result limit:</b> <strong class=\\\"text-warning\\\">{{ cubesService.cubesserver.info.json_record_limit }}</strong> items<br />\\n\" +\n    \"            </p>\\n\" +\n    \"\\n\" +\n    \"      </div>\\n\" +\n    \"      <div class=\\\"modal-footer\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-default\\\" data-dismiss=\\\"modal\\\"> Close</button>\\n\" +\n    \"      </div>\\n\" +\n    \"    </div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('studio/studio.html',\n    \"<div class=\\\"cv-bootstrap\\\" ng-controller=\\\"CubesViewerStudioController\\\">\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"cv-gui-panel hidden-print\\\">\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"dropdown m-b\\\" style=\\\"display: inline-block;\\\">\\n\" +\n    \"          <button class=\\\"btn btn-primary dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"            <i class=\\\"fa fa-fw fa-cube\\\"></i> Cubes <span class=\\\"caret\\\"></span>\\n\" +\n    \"          </button>\\n\" +\n    \"\\n\" +\n    \"          <ul class=\\\"dropdown-menu cv-gui-cubeslist-menu\\\">\\n\" +\n    \"\\n\" +\n    \"            <li ng-show=\\\"cubesService.state === 1\\\" class=\\\"disabled\\\"><a>Loading...</a></li>\\n\" +\n    \"            <li ng-show=\\\"cubesService.state === 2 && cubesService.cubesserver._cube_list.length === 0\\\" class=\\\"disabled\\\"><a>No cubes found</a></li>\\n\" +\n    \"            <li ng-show=\\\"cubesService.state === 3\\\" class=\\\"disabled text-danger\\\"><a>Loading failed</a></li>\\n\" +\n    \"\\n\" +\n    \"            <li ng-repeat=\\\"cube in cubesService.cubesserver._cube_list | orderBy:'label'\\\" ng-click=\\\"studioViewsService.addViewCube(cube.name)\\\"><a>{{ cube.label }}</a></li>\\n\" +\n    \"\\n\" +\n    \"          </ul>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"        <div ng-if=\\\"cvOptions.backendUrl\\\" class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; \\\">\\n\" +\n    \"          <button class=\\\"btn btn-primary dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"            <i class=\\\"fa fa-fw fa-file\\\"></i> Saved views <span class=\\\"caret\\\"></span>\\n\" +\n    \"          </button>\\n\" +\n    \"\\n\" +\n    \"          <ul class=\\\"dropdown-menu cv-gui-catalog-menu\\\">\\n\" +\n    \"\\n\" +\n    \"            <li class=\\\"dropdown-header\\\">Personal views</li>\\n\" +\n    \"\\n\" +\n    \"            <!-- <li ng-show=\\\"true\\\" class=\\\"disabled\\\"><a>Loading...</a></li>  -->\\n\" +\n    \"            <li ng-repeat=\\\"sv in reststoreService.savedViews | orderBy:'sv.name'\\\" ng-if=\\\"sv.owner == cvOptions.user\\\" ng-click=\\\"reststoreService.addSavedView(sv.id)\\\"><a style=\\\"max-width: 360px; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\\\"><i class=\\\"fa fa-fw\\\"></i> {{ sv.name }}</a></li>\\n\" +\n    \"\\n\" +\n    \"            <li class=\\\"dropdown-header\\\">Shared by others</li>\\n\" +\n    \"\\n\" +\n    \"            <!-- <li ng-show=\\\"true\\\" class=\\\"disabled\\\"><a>Loading...</a></li>  -->\\n\" +\n    \"            <li ng-repeat=\\\"sv in reststoreService.savedViews | orderBy:'sv.name'\\\" ng-if=\\\"sv.shared && sv.owner != cvOptions.user\\\" ng-click=\\\"reststoreService.addSavedView(sv.id)\\\"><a style=\\\"max-width: 360px; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\\\"><i class=\\\"fa fa-fw\\\"></i> {{ sv.name }}</a></li>\\n\" +\n    \"\\n\" +\n    \"          </ul>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; margin-left: 5px;\\\">\\n\" +\n    \"          <button class=\\\"btn btn-primary dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"            <i class=\\\"fa fa-fw fa-wrench\\\"></i> Tools <span class=\\\"caret\\\"></span>\\n\" +\n    \"          </button>\\n\" +\n    \"\\n\" +\n    \"          <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"\\n\" +\n    \"                <li ng-click=\\\"showSerializeAdd()\\\"><a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-code\\\"></i> Add view from JSON...</a></li>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <li ng-click=\\\"toggleTwoColumn()\\\" ng-class=\\\"{ 'hidden-xs': ! cvOptions.studioTwoColumn, 'disabled': studioViewsService.views.length == 0 }\\\"><a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-columns\\\"></i> 2 column\\n\" +\n    \"                    <span class=\\\"label label-default\\\" style=\\\"margin-left: 10px;\\\" ng-class=\\\"{ 'label-success': cvOptions.studioTwoColumn }\\\">{{ cvOptions.studioTwoColumn ? \\\"ON\\\" : \\\"OFF\\\" }}</span></a>\\n\" +\n    \"                </li>\\n\" +\n    \"                <li ng-click=\\\"toggleHideControls()\\\" ng-class=\\\"{ 'disabled': studioViewsService.views.length == 0 }\\\"><a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-unlock-alt\\\"></i> Hide controls\\n\" +\n    \"                    <span class=\\\"label label-default\\\" style=\\\"margin-left: 10px;\\\" ng-class=\\\"{ 'label-success': cvOptions.hideControls }\\\">{{ cvOptions.hideControls ? \\\"ON\\\" : \\\"OFF\\\" }}</span></a>\\n\" +\n    \"                </li>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"                <!-- <li class=\\\"\\\"><a data-toggle=\\\"modal\\\" data-target=\\\"#cvServerInfo\\\"><i class=\\\"fa fa-fw fa-server\\\"></i> Data model</a></li> -->\\n\" +\n    \"                <li class=\\\"\\\" ng-class=\\\"{ 'disabled': cubesService.state != 2 }\\\"><a data-toggle=\\\"modal\\\" data-target=\\\"#cvServerInfo\\\" ><i class=\\\"fa fa-fw fa-database\\\"></i> Server info</a></li>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <li class=\\\"\\\"><a href=\\\"http://github.com/jjmontesl/cubesviewer/blob/master/doc/guide/cubesviewer-user-main.md\\\" target=\\\"_blank\\\"><i class=\\\"fa fa-fw fa-question\\\"></i> User guide</a></li>\\n\" +\n    \"                <li class=\\\"\\\"><a data-toggle=\\\"modal\\\" data-target=\\\"#cvAboutModal\\\"><i class=\\\"fa fa-fw fa-info\\\"></i> About CubesViewer...</a></li>\\n\" +\n    \"\\n\" +\n    \"            </ul>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <div style=\\\"display: inline-block; margin-left: 10px; margin-bottom: 0px;\\\">\\n\" +\n    \"\\n\" +\n    \"             <div class=\\\"form-group hidden-xs\\\" style=\\\"display: inline-block; margin-bottom: 0px;\\\">\\n\" +\n    \"                <button class=\\\"btn\\\" type=\\\"button\\\" title=\\\"2 column\\\" ng-disabled=\\\"studioViewsService.views.length == 0\\\" ng-class=\\\"cvOptions.studioTwoColumn ? 'btn-active btn-success' : 'btn-primary'\\\" ng-click=\\\"toggleTwoColumn()\\\"><i class=\\\"fa fa-fw fa-columns\\\"></i></button>\\n\" +\n    \"             </div>\\n\" +\n    \"             <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin-bottom: 0px;\\\">\\n\" +\n    \"                <button class=\\\"btn\\\" type=\\\"button\\\" title=\\\"Hide controls\\\" ng-disabled=\\\"studioViewsService.views.length == 0\\\" ng-class=\\\"cvOptions.hideControls ? 'btn-active btn-success' : 'btn-primary'\\\" ng-click=\\\"toggleHideControls()\\\"><i class=\\\"fa fa-fw fa-unlock-alt\\\"></i></button>\\n\" +\n    \"             </div>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-gui-modals\\\">\\n\" +\n    \"            <div ng-include=\\\"'studio/about.html'\\\"></div>\\n\" +\n    \"            <div ng-include=\\\"'studio/serverinfo.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"cv-gui-workspace\\\">\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"row\\\">\\n\" +\n    \"            <div ng-if=\\\"cubesService.state == 3\\\" class=\\\"col-xs-12\\\" style=\\\"margin-bottom: 10px;\\\">\\n\" +\n    \"                <div class=\\\"alert alert-danger\\\" style=\\\"margin: 0px;\\\">\\n\" +\n    \"                    <p>Could not connect to server: {{ cubesService.stateText }}</p>\\n\" +\n    \"                    <p>Please try again and contact your administrator if the problem persists.</p>\\n\" +\n    \"                </div>\\n\" +\n    \"            </div>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"row cv-views-container\\\" data-masonry='{ \\\"itemSelector\\\": \\\".cv-view-container\\\", \\\"columnWidth\\\": \\\".cv-views-gridsizer\\\", \\\"percentPosition\\\": true }'>\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"col-xs-1 cv-views-gridsizer\\\"></div>\\n\" +\n    \"\\n\" +\n    \"            <div ng-repeat=\\\"studioView in studioViewsService.views\\\" style=\\\"display: none;\\\" class=\\\"col-xs-12 cv-view-container sv{{ studioView.id }}\\\" ng-class=\\\"(cvOptions.studioTwoColumn ? 'col-sm-6' : 'col-sm-12')\\\">\\n\" +\n    \"                <div >\\n\" +\n    \"                    <div cv-studio-view view=\\\"studioView\\\"></div>\\n\" +\n    \"                </div>\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('views/cube/alerts.html',\n    \"<div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.requestFailed\\\" class=\\\"alert alert-dismissable alert-danger\\\" style=\\\"margin-bottom: 5px;\\\">\\n\" +\n    \"        <div style=\\\"display: inline-block;\\\"><i class=\\\"fa fa-exclamation\\\"></i></div>\\n\" +\n    \"        <div style=\\\"display: inline-block; margin-left: 20px;\\\">\\n\" +\n    \"            An error has occurred. Cannot present view.<br />\\n\" +\n    \"            Please try again and contact your administrator if the problem persists.\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.resultLimitHit\\\" class=\\\"alert alert-dismissable alert-warning\\\" style=\\\"margin-bottom: 5px;\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"close\\\" ng-click=\\\"view._resultLimitHit = false;\\\" data-dismiss=\\\"alert\\\" aria-hidden=\\\"true\\\">&times;</button>\\n\" +\n    \"        <div style=\\\"display: inline-block; vertical-align: top;\\\"><i class=\\\"fa fa-exclamation\\\"></i></div>\\n\" +\n    \"        <div style=\\\"display: inline-block; margin-left: 20px;\\\">\\n\" +\n    \"            Limit of {{ cubesService.cubesserver.info.json_record_limit }} items has been hit. <b>Results are incomplete.</b><br />\\n\" +\n    \"            <i>Tip</i>: reduce level of drilldown or filter your selection to reduce the number of items in the result.\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/chart/chart-common.html',\n    \"<div ng-show=\\\"(view.grid.data.length > 0 && view.params.yaxis != null) && (!(view.params.charttype == 'pie' && view.grid.columnDefs.length > 2)) && (!(view.params.charttype == 'radar' && view.grid.columnDefs.length < 4))\\\" style=\\\"width: 99%;\\\">\\n\" +\n    \"    <div>\\n\" +\n    \"        <div class=\\\"cv-chart-container\\\">\\n\" +\n    \"            <svg style=\\\"height: 400px;\\\" />\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-hide=\\\"view.getControlsHidden() || view.params.charttype == 'radar'\\\" style=\\\"font-size: 8px; float: right;\\\">\\n\" +\n    \"            <a href=\\\"\\\" class=\\\"cv-chart-height\\\" ng-click=\\\"chartCtrl.resizeChart(400);\\\">Small</a>\\n\" +\n    \"            <a href=\\\"\\\" class=\\\"cv-chart-height\\\" ng-click=\\\"chartCtrl.resizeChart(550);\\\">Medium</a>\\n\" +\n    \"            <a href=\\\"\\\" class=\\\"cv-chart-height\\\" ng-click=\\\"chartCtrl.resizeChart(700);\\\">Tall</a>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"<div ng-if=\\\"view.params.yaxis == null\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"    <p>\\n\" +\n    \"        Cannot present chart: no <b>measure</b> has been selected.\\n\" +\n    \"    </p>\\n\" +\n    \"    <p>\\n\" +\n    \"        Tip: use the <kbd><i class=\\\"fa fa-fw fa-cogs\\\"></i> View &gt; <i class=\\\"fa fa-fw fa-crosshairs\\\"></i> Measure</kbd> menu.\\n\" +\n    \"    </p>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"<div ng-if=\\\"view.pendingRequests == 0 && view.params.yaxis != null && view.grid.data.length == 0\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"    <p>\\n\" +\n    \"        Cannot present chart: <b>no rows returned</b> by the current filtering, horizontal dimension, and drilldown combination.\\n\" +\n    \"    </p>\\n\" +\n    \"    <p>\\n\" +\n    \"        Tip: use the <kbd><i class=\\\"fa fa-fw fa-cogs\\\"></i> View</kbd> menu to select an horizontal dimension.\\n\" +\n    \"    </p>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"<div ng-if=\\\"view.pendingRequests == 0 && view.params.charttype == 'pie' && view.grid.columnDefs.length > 2\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"    <p>\\n\" +\n    \"        Cannot present a <b>pie chart</b> when <b>more than one column</b> is present.<br />\\n\" +\n    \"    </p>\\n\" +\n    \"    <p>\\n\" +\n    \"        Tip: review chart data and columns in <a href=\\\"\\\" ng-click=\\\"setViewMode('series')\\\" class=\\\"alert-link\\\">series mode</a>,\\n\" +\n    \"        or <a href=\\\"\\\" ng-click=\\\"selectXAxis(null);\\\" class=\\\"alert-link\\\">remove horizontal dimension</a>.\\n\" +\n    \"    </p>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\" +\n    \"<div ng-if=\\\"view.pendingRequests == 0 && view.params.yaxis != null && view.params.charttype == 'radar' && view.grid.columnDefs.length < 4\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"    Cannot present a <b>radar chart</b> when <b>less than 3 columns</b> are present.<br />\\n\" +\n    \"    Tip: review chart data and columns in <a href=\\\"\\\" ng-click=\\\"setViewMode('series')\\\" class=\\\"alert-link\\\">series mode</a>.\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/chart/chart.html',\n    \"<div ng-controller=\\\"CubesViewerViewsCubeChartController as chartCtrl\\\">\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'pie'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-pie-chart\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartPieController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'bars-vertical'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-bar-chart\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartBarsVerticalController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'bars-horizontal'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-bar-chart fa-rotate-270\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartBarsHorizontalController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'lines'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-line-chart\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartLinesController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'lines-stacked'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-area-chart\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartLinesController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'radar'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-bullseye\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartRadarController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.params.charttype == 'sunburst'\\\">\\n\" +\n    \"        <h3><i class=\\\"fa fa-fw fa-sun-o\\\"></i> Chart\\n\" +\n    \"            <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"        </h3>\\n\" +\n    \"        <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"            <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div ng-controller=\\\"CubesViewerViewsCubeChartSunburstController\\\">\\n\" +\n    \"            <div ng-include=\\\"'views/cube/chart/chart-common.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/cube-menu-drilldown.html',\n    \"  <button class=\\\"btn btn-primary btn-sm dropdown-toggle drilldownbutton\\\" ng-disabled=\\\"view.params.mode == 'facts'\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"    <i class=\\\"fa fa-fw fa-arrow-down\\\"></i> <span class=\\\"hidden-xs\\\" ng-class=\\\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\\\">Drilldown</span> <span class=\\\"caret\\\"></span>\\n\" +\n    \"  </button>\\n\" +\n    \"\\n\" +\n    \"  <ul class=\\\"dropdown-menu dropdown-menu-right cv-view-menu-drilldown\\\">\\n\" +\n    \"\\n\" +\n    \"      <!-- if ((grayout_drill) && ((($.grep(view.params.drilldown, function(ed) { return ed == dimension.name; })).length > 0))) { -->\\n\" +\n    \"      <li on-repeat-done ng-repeat-start=\\\"dimension in view.cube.dimensions\\\" ng-if=\\\"dimension.levels.length == 1\\\" ng-click=\\\"selectDrill(dimension.name, true);\\\">\\n\" +\n    \"        <a href=\\\"\\\">{{ dimension.label }}</a>\\n\" +\n    \"      </li>\\n\" +\n    \"      <li ng-repeat-end ng-if=\\\"dimension.levels.length != 1\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\">{{ dimension.label }}</a>\\n\" +\n    \"\\n\" +\n    \"        <ul ng-if=\\\"dimension.hierarchies_count() != 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"            <li ng-repeat=\\\"(hikey,hi) in dimension.hierarchies\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"                <a tabindex=\\\"0\\\" href=\\\"\\\" onclick=\\\"return false;\\\">{{ hi.label }}</a>\\n\" +\n    \"                <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                    <li ng-repeat=\\\"level in hi.levels\\\" ng-click=\\\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"                </ul>\\n\" +\n    \"            </li>\\n\" +\n    \"        </ul>\\n\" +\n    \"\\n\" +\n    \"        <ul ng-if=\\\"dimension.hierarchies_count() == 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"            <li ng-repeat=\\\"level in dimension.default_hierarchy().levels\\\" ng-click=\\\"selectDrill(dimension.name + '@' + dimension.default_hierarchy().name + ':' + level.name, true)\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"        </ul>\\n\" +\n    \"\\n\" +\n    \"      </li>\\n\" +\n    \"\\n\" +\n    \"      <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"      <li ng-class=\\\"{ 'disabled': view.params.drilldown.length == 0 }\\\" ng-click=\\\"selectDrill('')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-close\\\"></i> None</a></li>\\n\" +\n    \"\\n\" +\n    \"  </ul>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('views/cube/cube-menu-filter.html',\n    \"  <button class=\\\"btn btn-primary btn-sm dropdown-toggle cutbutton\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"    <i class=\\\"fa fa-fw fa-filter\\\"></i> <span class=\\\"hidden-xs\\\" ng-class=\\\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\\\">Filter</span> <span class=\\\"caret\\\"></span>\\n\" +\n    \"  </button>\\n\" +\n    \"\\n\" +\n    \"  <ul class=\\\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-cut\\\">\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'explore'\\\" ng-click=\\\"filterSelected()\\\" ng-class=\\\"{ 'disabled': view.params.drilldown.length != 1 }\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-filter\\\"></i> Filter selected rows</a></li>\\n\" +\n    \"    <div ng-show=\\\"view.params.mode == 'explore'\\\" class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    <li class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-bars\\\"></i> Dimension filter</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"\\n\" +\n    \"          <li on-repeat-done ng-repeat-start=\\\"dimension in view.cube.dimensions\\\" ng-if=\\\"dimension.levels.length == 1\\\" ng-click=\\\"showDimensionFilter(dimension.name);\\\">\\n\" +\n    \"            <a href=\\\"\\\">{{ dimension.label }}</a>\\n\" +\n    \"          </li>\\n\" +\n    \"          <li ng-repeat-end ng-if=\\\"dimension.levels.length != 1\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"            <a tabindex=\\\"0\\\">{{ dimension.label }}</a>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() != 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-repeat=\\\"(hikey,hi) in dimension.hierarchies\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"                    <a tabindex=\\\"0\\\" href=\\\"\\\" onclick=\\\"return false;\\\">{{ hi.label }}</a>\\n\" +\n    \"                    <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                        <!-- ng-click=\\\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\\\"  -->\\n\" +\n    \"                        <li ng-repeat=\\\"level in hi.levels\\\" ng-click=\\\"showDimensionFilter(dimension.name + '@' + hi.name + ':' + level.name )\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"                    </ul>\\n\" +\n    \"                </li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() == 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <!--  selectDrill(dimension.name + ':' + level.name, true) -->\\n\" +\n    \"                <li ng-repeat=\\\"level in dimension.default_hierarchy().levels\\\" ng-click=\\\"showDimensionFilter(dimension.name + '@' + dimension.default_hierarchy().name + ':' + level.name);\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <li class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-calendar\\\"></i> Date filter</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"          <li ng-repeat=\\\"dimension in view.cube.dimensions\\\" ng-if=\\\"dimension.isDateDimension()\\\">\\n\" +\n    \"            <a href=\\\"\\\" ng-click=\\\"selectDateFilter(dimension.name + ((dimension.info['cv-datefilter-hierarchy']) ? '@' + dimension.info['cv-datefilter-hierarchy'] : ''), true)\\\">\\n\" +\n    \"                {{ dimension.label + ((dimension.hierarchy(dimension.info[\\\"cv-datefilter-hierarchy\\\"])) ? \\\" / \\\" + dimension.hierarchy(dimension.info[\\\"cv-datefilter-hierarchy\\\"]).label : \\\"\\\") }}\\n\" +\n    \"            </a>\\n\" +\n    \"          </li>\\n\" +\n    \"          <li ng-if=\\\"view.cube.dateDimensions().length == 0\\\" class=\\\"disabled\\\">\\n\" +\n    \"            <a href=\\\"\\\" ng-click=\\\"\\\"><i>No date filters defined for this cube.</i></a>\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <!--\\n\" +\n    \"    <li class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-arrows-h\\\"></i> Range filter</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"\\n\" +\n    \"          <li on-repeat-done ng-repeat-start=\\\"dimension in view.cube.dimensions\\\" ng-if=\\\"dimension.levels.length == 1\\\" ng-click=\\\"showDimensionFilter(dimension.name);\\\">\\n\" +\n    \"            <a href=\\\"\\\">{{ dimension.label }}</a>\\n\" +\n    \"          </li>\\n\" +\n    \"          <li ng-repeat-end ng-if=\\\"dimension.levels.length != 1\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"            <a tabindex=\\\"0\\\">{{ dimension.label }}</a>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() != 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-repeat=\\\"(hikey,hi) in dimension.hierarchies\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"                    <a tabindex=\\\"0\\\" href=\\\"\\\" onclick=\\\"return false;\\\">{{ hi.label }}</a>\\n\" +\n    \"                    <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                        <li ng-repeat=\\\"level in hi.levels\\\" ng-click=\\\"showDimensionFilter(dimension.name + '@' + hi.name + ':' + level.name )\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"                    </ul>\\n\" +\n    \"                </li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() == 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-repeat=\\\"level in dimension.default_hierarchy().levels\\\" ng-click=\\\"showDimensionFilter(level);\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"     -->\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    <li ng-class=\\\"{ 'disabled': view.params.cuts.length == 0 && view.params.datefilters.length == 0 }\\\" ng-click=\\\"clearFilters()\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-trash\\\"></i> Clear filters</a></li>\\n\" +\n    \"\\n\" +\n    \"  </ul>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/cube-menu-panel.html',\n    \"  <button class=\\\"btn btn-primary btn-sm dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"    <i class=\\\"fa fa-fw fa-file\\\"></i> <span class=\\\"hidden-xs\\\" ng-class=\\\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\\\">Panel</span> <span class=\\\"caret\\\"></span>\\n\" +\n    \"  </button>\\n\" +\n    \"\\n\" +\n    \"  <ul class=\\\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-view\\\">\\n\" +\n    \"\\n\" +\n    \"    <li ng-click=\\\"viewsService.studioViewsService.studioScope.showRenameView(view)\\\"><a><i class=\\\"fa fa-fw fa-pencil\\\"></i> Rename...</a></li>\\n\" +\n    \"    <li ng-click=\\\"viewsService.studioViewsService.studioScope.cloneView(view)\\\"><a><i class=\\\"fa fa-fw fa-clone\\\"></i> Clone</a></li>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"cvOptions.backendUrl\\\" class=\\\"divider\\\"></div>\\n\" +\n    \"    <li ng-if=\\\"cvOptions.backendUrl\\\" ng-click=\\\"reststoreService.saveView(view)\\\"><a><i class=\\\"fa fa-fw fa-save\\\"></i> Save</a></li>\\n\" +\n    \"    <li ng-if=\\\"cvOptions.backendUrl\\\" ng-click=\\\"reststoreService.shareView(view, ! view.shared)\\\"><a><i class=\\\"fa fa-fw fa-share\\\"></i> {{ view.shared ? \\\"Unshare\\\" : \\\"Share\\\" }}</a></li>\\n\" +\n    \"    <li ng-if=\\\"cvOptions.backendUrl\\\" ng-click=\\\"reststoreService.deleteView(view)\\\"><a><i class=\\\"fa fa-fw fa-trash-o\\\"></i> Delete...</a></li>\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"divider\\\"></div>\\n\" +\n    \"    <li ng-click=\\\"viewsService.studioViewsService.studioScope.showSerializeView(view)\\\"><a><i class=\\\"fa fa-fw fa-code\\\"></i> Serialize...</a></li>\\n\" +\n    \"    <div class=\\\"divider\\\"></div>\\n\" +\n    \"    <li ng-click=\\\"viewsService.studioViewsService.closeView(view)\\\"><a><i class=\\\"fa fa-fw fa-close\\\"></i> Close</a></li>\\n\" +\n    \"  </ul>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/cube-menu-view.html',\n    \"  <button class=\\\"btn btn-primary btn-sm dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"    <i class=\\\"fa fa-fw fa-cogs\\\"></i> <span class=\\\"hidden-xs\\\" ng-class=\\\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\\\">View</span> <span class=\\\"caret\\\"></span>\\n\" +\n    \"  </button>\\n\" +\n    \"\\n\" +\n    \"  <ul class=\\\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-view\\\">\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'chart'\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\" ><i class=\\\"fa fa-fw fa-area-chart\\\"></i> Chart type</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"          <li ng-click=\\\"selectChartType('pie')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-pie-chart\\\"></i> Pie</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('bars-vertical')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-bar-chart\\\"></i> Bars Vertical</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('bars-horizontal')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-rotate-270 fa-bar-chart\\\"></i> Bars Horizontal</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('lines')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-line-chart\\\"></i> Lines</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('lines-stacked')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-area-chart\\\"></i> Areas</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('radar')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-bullseye\\\"></i> Radar</a></li>\\n\" +\n    \"\\n\" +\n    \"          <!-- <div class=\\\"divider\\\"></div>  -->\\n\" +\n    \"\\n\" +\n    \"          <!--\\n\" +\n    \"          <li><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-dot-circle-o\\\"></i> Bubbles</a></li>\\n\" +\n    \"          <li><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-square\\\"></i> Treemap</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectChartType('sunburst')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-sun-o\\\"></i> Sunburst</a></li>\\n\" +\n    \"          -->\\n\" +\n    \"\\n\" +\n    \"          <!--\\n\" +\n    \"          <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"          <li><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-globe\\\"></i> Map</a></li>\\n\" +\n    \"           -->\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <!--\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'chart' && (view.params.charttype == 'lines-stacked' || view.params.charttype == 'lines' || view.params.charttype == 'bars-horizontal')\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\" ><i class=\\\"fa fa-fw fa-sliders\\\"></i> Chart options</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"    -->\\n\" +\n    \"        <li class=\\\"dropdown-submenu\\\" ng-show=\\\"view.params.mode == 'chart' && (view.params.charttype == 'lines-stacked' || view.params.charttype == 'lines')\\\">\\n\" +\n    \"            <a href=\\\"\\\"><i class=\\\"fa fa-fw fa-angle-up\\\"></i> Curve type</a>\\n\" +\n    \"            <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-class=\\\"{'active': view.params.chartoptions.lineInterpolation == 'linear'}\\\" ng-click=\\\"view.params.chartoptions.lineInterpolation = 'linear'; refreshView();\\\"><a href=\\\"\\\"> Linear</a></li>\\n\" +\n    \"                <li ng-class=\\\"{'active': view.params.chartoptions.lineInterpolation == 'monotone'}\\\" ng-click=\\\"view.params.chartoptions.lineInterpolation = 'monotone'; refreshView();\\\"><a href=\\\"\\\"> Smooth</a></li>\\n\" +\n    \"                <!-- <li ng-class=\\\"{'active': view.params.chartoptions.lineInterpolation == 'cardinal'}\\\" ng-click=\\\"view.params.chartoptions.lineInterpolation = 'cardinal'; refreshView();\\\"><a href=\\\"\\\"> Smooth (Cardinal)</a></li>  -->\\n\" +\n    \"            </ul>\\n\" +\n    \"        </li>\\n\" +\n    \"\\n\" +\n    \"        <li ng-class=\\\"{'disabled': view.grid.data.length != 2 }\\\" ng-show=\\\"view.params.mode == 'chart' && view.params.charttype == 'bars-horizontal'\\\" ng-click=\\\"view.params.chartoptions.mirrorSerie2 = !view.params.chartoptions.mirrorSerie2; refreshView();\\\">\\n\" +\n    \"            <a><i class=\\\"fa fa-fw fa-arrows-h\\\"></i> Invert 2nd series\\n\" +\n    \"                <span style=\\\"margin-left: 5px;\\\" class=\\\"label label-default\\\" ng-class=\\\"{ 'label-success': view.params.chartoptions.mirrorSerie2 }\\\">{{ view.params.chartoptions.mirrorSerie2 ? \\\"ON\\\" : \\\"OFF\\\" }}</span>\\n\" +\n    \"            </a>\\n\" +\n    \"        </li>\\n\" +\n    \"\\n\" +\n    \"    <!--\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"     -->\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'chart'\\\" ng-click=\\\"view.params.chartoptions.showLegend = !view.params.chartoptions.showLegend; refreshView();\\\">\\n\" +\n    \"        <a><i class=\\\"fa fa-fw\\\" ng-class=\\\"{'fa-toggle-on': view.params.chartoptions.showLegend, 'fa-toggle-off': ! view.params.chartoptions.showLegend }\\\"></i> Toggle legend\\n\" +\n    \"            <span style=\\\"margin-left: 5px;\\\" class=\\\"label label-default\\\" ng-class=\\\"{ 'label-success': view.params.chartoptions.showLegend }\\\">{{ view.params.chartoptions.showLegend ? \\\"ON\\\" : \\\"OFF\\\" }}</span>\\n\" +\n    \"        </a>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <div ng-show=\\\"view.params.mode == 'chart'\\\" class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'series' || view.params.mode == 'chart'\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-long-arrow-right\\\"></i> Horizontal dimension</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"\\n\" +\n    \"          <li on-repeat-done ng-repeat-start=\\\"dimension in view.cube.dimensions\\\" ng-if=\\\"dimension.levels.length == 1\\\" ng-click=\\\"selectXAxis(dimension.name)\\\">\\n\" +\n    \"            <a href=\\\"\\\">{{ dimension.label }}</a>\\n\" +\n    \"          </li>\\n\" +\n    \"          <li ng-repeat-end ng-if=\\\"dimension.levels.length != 1\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"            <a tabindex=\\\"0\\\">{{ dimension.label }}</a>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() != 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-repeat=\\\"(hikey,hi) in dimension.hierarchies\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"                    <a tabindex=\\\"0\\\" href=\\\"\\\" onclick=\\\"return false;\\\">{{ hi.label }}</a>\\n\" +\n    \"                    <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                        <!-- ng-click=\\\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\\\"  -->\\n\" +\n    \"                        <li ng-repeat=\\\"level in hi.levels\\\" ng-click=\\\"selectXAxis(dimension.name + '@' + hi.name + ':' + level.name )\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"                    </ul>\\n\" +\n    \"                </li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"            <ul ng-if=\\\"dimension.hierarchies_count() == 1\\\" class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <!--  selectDrill(dimension.name + ':' + level.name, true) -->\\n\" +\n    \"                <li ng-repeat=\\\"level in dimension.default_hierarchy().levels\\\" ng-click=\\\"selectXAxis(dimension.name + ':' + level.name);\\\"><a href=\\\"\\\">{{ level.label }}</a></li>\\n\" +\n    \"            </ul>\\n\" +\n    \"\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"          <div class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"          <li ng-click=\\\"selectXAxis(null);\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-close\\\"></i> None</a></li>\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'series' || view.params.mode == 'chart'\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\"><i class=\\\"fa fa-fw fa-crosshairs\\\"></i> Measure</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"\\n\" +\n    \"          <li ng-repeat=\\\"measure in view.cube.measures\\\" ng-if=\\\"view.cube.measureAggregates(measure.name).length > 0\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"            <a href=\\\"\\\">{{ measure.label }}</a>\\n\" +\n    \"            <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"                <li ng-repeat=\\\"aggregate in view.cube.measureAggregates(measure.name)\\\" >\\n\" +\n    \"                    <a href=\\\"\\\" ng-click=\\\"selectMeasure(aggregate.ref)\\\">{{ aggregate.label }}</a>\\n\" +\n    \"                </li>\\n\" +\n    \"            </ul>\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"          <div class=\\\"divider\\\" ng-if=\\\"view.cube.measureAggregates(null).length > 0\\\"></div>\\n\" +\n    \"          <li ng-repeat=\\\"aggregate in view.cube.measureAggregates(null)\\\" ng-if=\\\"view.cube.measureAggregates(null).length > 0\\\" >\\n\" +\n    \"            <a href=\\\"\\\" ng-click=\\\"selectMeasure(aggregate.ref)\\\">{{ aggregate.label }}</a>\\n\" +\n    \"          </li>\\n\" +\n    \"\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <div ng-show=\\\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\\\" class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\\\" class=\\\"dropdown-submenu\\\">\\n\" +\n    \"        <a tabindex=\\\"0\\\" ><i class=\\\"fa fa-fw fa-calculator\\\"></i> Series operations</a>\\n\" +\n    \"        <ul class=\\\"dropdown-menu\\\">\\n\" +\n    \"          <li ng-click=\\\"selectOperation('difference')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-line-chart\\\"></i> Difference</a></li>\\n\" +\n    \"          <li ng-click=\\\"selectOperation('percentage')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-percent\\\"></i> Change rate</a></li>\\n\" +\n    \"          <!--\\n\" +\n    \"          <li ng-click=\\\"selectOperation('accum')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw\\\">&sum;</i> Accumulated</a></li>\\n\" +\n    \"          <div class=\\\"divider\\\"></div>\\n\" +\n    \"          <li ng-click=\\\"selectOperation('fill-zeros')\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw\\\">0</i> Replace blanks with zeroes</a></li>\\n\" +\n    \"           -->\\n\" +\n    \"          <div class=\\\"divider\\\"></div>\\n\" +\n    \"          <li ng-click=\\\"selectOperation(null)\\\"><a href=\\\"\\\"><i class=\\\"fa fa-fw fa-times\\\"></i> Clear operations</a></li>\\n\" +\n    \"        </ul>\\n\" +\n    \"    </li>\\n\" +\n    \"\\n\" +\n    \"    <div ng-show=\\\"view.params.mode == 'series' || view.params.mode == 'chart'\\\" class=\\\"divider\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    <li ng-show=\\\"view.params.mode != 'chart'\\\" ng-click=\\\"exportService.exportGridAsCsv(view)\\\"><a><i class=\\\"fa fa-fw fa-table\\\"></i> Export table</a></li>\\n\" +\n    \"    <li ng-show=\\\"view.params.mode == 'chart' && view.params.charttype != 'radar' \\\" ng-click=\\\"view.exportChartAsPNG()\\\"><a><i class=\\\"fa fa-fw fa-picture-o\\\"></i> Export figure</a></li>\\n\" +\n    \"    <li ng-click=\\\"exportService.exportFacts(view)\\\"><a><i class=\\\"fa fa-fw fa-th\\\"></i> Export facts</a></li>\\n\" +\n    \"\\n\" +\n    \"  </ul>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('views/cube/cube.html',\n    \"<div class=\\\"cv-view-panel\\\" ng-controller=\\\"CubesViewerViewsCubeController as cubeView\\\" >\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.state == 3\\\">\\n\" +\n    \"        <div class=\\\"alert alert-danger\\\" style=\\\"margin: 0px;\\\">\\n\" +\n    \"            <p>An error occurred. Cannot present view.</p>\\n\" +\n    \"            <p ng-if=\\\"cubesService.state != 3\\\">{{ view.error }}</p>\\n\" +\n    \"            <p ng-if=\\\"cubesService.state == 3\\\">Could not connect to data server: {{ cubesService.stateText }}</p>\\n\" +\n    \"            <p>Please try again and contact your administrator if the problem persists.</p>\\n\" +\n    \"            <p class=\\\"text-right\\\">\\n\" +\n    \"                <a class=\\\"alert-link\\\" href=\\\"http://jjmontesl.github.io/cubesviewer/\\\" target=\\\"_blank\\\">CubesViewer Data Visualizer</a>\\n\" +\n    \"            </p>\\n\" +\n    \"        </div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div>\\n\" +\n    \"        <h2 ng-show=\\\"view.getControlsHidden()\\\" style=\\\"margin-top: 5px;\\\">\\n\" +\n    \"            <i class=\\\"fa fa-fw fa-file-o\\\"></i> {{ view.params.name }}\\n\" +\n    \"        </h2>\\n\" +\n    \"\\n\" +\n    \"        <div ng-include=\\\"'views/cube/alerts.html'\\\"></div>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.state == 2\\\" style=\\\"min-height: 80px;\\\">\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-view-viewmenu hidden-print\\\" ng-hide=\\\"view.getControlsHidden()\\\">\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"panel panel-primary pull-right\\\" style=\\\"padding: 3px; white-space: nowrap; margin-bottom: 6px; margin-left: 6px;\\\">\\n\" +\n    \"\\n\" +\n    \"                <div ng-if=\\\"cvOptions.undoEnabled\\\" class=\\\"btn-group\\\" role=\\\"group\\\" ng-controller=\\\"CubesViewerViewsUndoController\\\">\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"undo()\\\" ng-disabled=\\\"view.undoPos <= 0\\\" class=\\\"btn btn-default btn-sm\\\" title=\\\"Undo\\\"><i class=\\\"fa fa-fw fa-undo\\\"></i></button>\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"redo()\\\" ng-disabled=\\\"view.undoPos >= view.undoList.length - 1\\\" class=\\\"btn btn-default btn-sm\\\" title=\\\"Redo\\\"><i class=\\\"fa fa-fw fa-undo fa-flip-horizontal\\\"></i></button>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"btn-group\\\" role=\\\"group\\\" aria-label=\\\"...\\\" style=\\\"margin-left: 5px;\\\">\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"setViewMode('explore')\\\" ng-class=\\\"{'active': view.params.mode == 'explore'}\\\" class=\\\"btn btn-primary btn-sm explorebutton\\\" title=\\\"Explore\\\"><i class=\\\"fa fa-fw fa-arrow-circle-down\\\"></i></button>\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"setViewMode('facts')\\\" ng-class=\\\"{'active': view.params.mode == 'facts'}\\\" class=\\\"btn btn-primary btn-sm \\\" title=\\\"Facts\\\"><i class=\\\"fa fa-fw fa-th\\\"></i></button>\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"setViewMode('series')\\\" ng-class=\\\"{'active': view.params.mode == 'series'}\\\" class=\\\"btn btn-primary btn-sm \\\" title=\\\"Series\\\"><i class=\\\"fa fa-fw fa-clock-o\\\"></i></button>\\n\" +\n    \"                  <button type=\\\"button\\\" ng-click=\\\"setViewMode('chart')\\\" ng-class=\\\"{'active': view.params.mode == 'chart'}\\\" class=\\\"btn btn-primary btn-sm \\\" title=\\\"Charts\\\"><i class=\\\"fa fa-fw fa-area-chart\\\"></i></button>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"                <div ng-include=\\\"'views/cube/cube-menu-drilldown.html'\\\" class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; margin-left: 5px;\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <div ng-include=\\\"'views/cube/cube-menu-filter.html'\\\" class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; margin-left: 2px;\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <div ng-include=\\\"'views/cube/cube-menu-view.html'\\\" class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; margin-left: 5px;\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <div ng-if=\\\"cvOptions.container\\\" ng-include=\\\"'views/cube/cube-menu-panel.html'\\\" class=\\\"dropdown m-b\\\" style=\\\"display: inline-block; margin-left: 5px;\\\"></div>\\n\" +\n    \"\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"pull-right\\\" style=\\\"white-space: nowrap; padding-top: 4px; padding-bottom: 4px; margin-left: 6px; margin-bottom: 6px;\\\">\\n\" +\n    \"\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-view-viewinfo\\\">\\n\" +\n    \"            <div>\\n\" +\n    \"                <div class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-cubename\\\" style=\\\"color: white; background-color: black;\\\">\\n\" +\n    \"                    <span><i class=\\\"fa fa-fw fa-cube\\\" title=\\\"Cube\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Cube:</b> {{ view.cube.label }}</span>\\n\" +\n    \"                    <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"cv-view-viewinfo-drill\\\">\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"                    <div ng-repeat=\\\"drilldown in view.params.drilldown\\\" ng-init=\\\"parts = view.cube.dimensionParts(drilldown);\\\" ng-if=\\\"view.params.mode != 'facts'\\\" class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-drill\\\" style=\\\"color: black; background-color: #ccffcc;\\\">\\n\" +\n    \"                        <span><i class=\\\"fa fa-fw fa-arrow-down\\\" title=\\\"Drilldown\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Drilldown:</b> <span title=\\\"{{ view.cube.dimensionParts(drilldown).label }}\\\">{{ parts.labelShort }}</span></span>\\n\" +\n    \"                        <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden; margin-left: -20px;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden() || parts.hierarchy.levels.length < 2\\\" ng-disabled=\\\"! parts.drilldownDimensionMinus\\\" type=\\\"button\\\" ng-click=\\\"selectDrill(parts.drilldownDimensionMinus, true)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 3px;\\\"><i class=\\\"fa fa-fw fa-minus\\\"></i></button>\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden() || parts.hierarchy.levels.length < 2\\\" ng-disabled=\\\"! parts.drilldownDimensionPlus\\\" type=\\\"button\\\" ng-click=\\\"selectDrill(parts.drilldownDimensionPlus, true)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 0px;\\\"><i class=\\\"fa fa-fw fa-plus\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden()\\\" type=\\\"button\\\" ng-click=\\\"showDimensionFilter(drilldown)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 3px;\\\"><i class=\\\"fa fa-fw fa-search\\\"></i></button>\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden()\\\" type=\\\"button\\\" ng-click=\\\"selectDrill(drilldown, '')\\\" class=\\\"btn btn-danger btn-xs hidden-print\\\" style=\\\"margin-left: 1px;\\\"><i class=\\\"fa fa-fw fa-trash\\\"></i></button>\\n\" +\n    \"                    </div>\\n\" +\n    \"\\n\" +\n    \"                </div>\\n\" +\n    \"                <div class=\\\"cv-view-viewinfo-cut\\\">\\n\" +\n    \"                    <!--\\n\" +\n    \"                        var dimensionString = $(this).parents('.cv-view-infopiece-cut').first().attr('data-dimension');\\n\" +\n    \"                        var parts = view.cube.dimensionParts(dimensionString);\\n\" +\n    \"                        var depth = $(this).parents('.cv-view-infopiece-cut').first().attr('data-value').split(';')[0].split(\\\",\\\").length;\\n\" +\n    \"                        cubesviewer.views.cube.dimensionfilter.drawDimensionFilter(view, dimensionString + \\\":\\\" + parts.hierarchy.levels[depth - 1] );\\n\" +\n    \"                     -->\\n\" +\n    \"                    <div ng-repeat=\\\"cut in view.params.cuts\\\" ng-init=\\\"equality = cut.invert ? ' &ne; ' : ' = ';\\\" class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-cut\\\" style=\\\"color: black; background-color: #ffcccc;\\\">\\n\" +\n    \"                        <span style=\\\"max-width: 480px;\\\"><i class=\\\"fa fa-fw fa-filter\\\" title=\\\"Filter\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Filter:</b> <span title=\\\"{{ view.cube.dimensionPartsFromCut(cut).label }}\\\">{{ view.cube.dimensionPartsFromCut(cut).labelShort }}</span> <span ng-class=\\\"{ 'text-danger': cut.invert }\\\">{{ equality }}</span> <span title=\\\"{{ cut.value }}\\\">{{ cut.value }}</span></span>\\n\" +\n    \"                        <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden; margin-left: -20px;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden()\\\" type=\\\"button\\\" ng-click=\\\"showDimensionFilter(view.cube.dimensionPartsFromCut(cut).drilldownDimension)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 3px;\\\"><i class=\\\"fa fa-fw fa-search\\\"></i></button>\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden()\\\" type=\\\"button\\\" ng-click=\\\"selectCut(cut.dimension, '', cut.invert)\\\" class=\\\"btn btn-danger btn-xs hidden-print\\\" style=\\\"margin-left: 1px;\\\"><i class=\\\"fa fa-fw fa-trash\\\"></i></button>\\n\" +\n    \"                    </div>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"                <div ng-include=\\\"'views/cube/filter/datefilter.html'\\\"></div>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"cv-view-viewinfo-extra\\\">\\n\" +\n    \"\\n\" +\n    \"                    <div ng-if=\\\"view.params.mode == 'series' || view.params.mode == 'chart'\\\" class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-extra\\\" style=\\\"color: black; background-color: #ccccff;\\\">\\n\" +\n    \"                        <span style=\\\"max-width: 350px;\\\"><i class=\\\"fa fa-fw fa-crosshairs\\\" title=\\\"Measure\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Measure:</b> {{ (view.params.yaxis != null) ? view.cube.aggregateFromName(view.params.yaxis).label : \\\"None\\\" }}</span>\\n\" +\n    \"                        <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden; margin-left: -20px;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"                    </div>\\n\" +\n    \"\\n\" +\n    \"                    <div ng-if=\\\"view.params.mode == 'series' || view.params.mode == 'chart'\\\" class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-extra\\\" style=\\\"color: black; background-color: #ccddff;\\\">\\n\" +\n    \"                        <span style=\\\"max-width: 350px;\\\"><i class=\\\"fa fa-fw fa-long-arrow-right\\\" title=\\\"Horizontal dimension\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Horizontal dimension:</b> {{ (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).labelShort : \\\"None\\\" }}</span>\\n\" +\n    \"                        <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden; margin-left: -20px;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden() || !view.params.xaxis || view.cube.dimensionParts(view.params.xaxis).hierarchy.levels.length < 2\\\" ng-disabled=\\\"! view.cube.dimensionParts(view.params.xaxis).drilldownDimensionMinus\\\" type=\\\"button\\\" ng-click=\\\"selectXAxis(view.cube.dimensionParts(view.params.xaxis).drilldownDimensionMinus, true)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 3px;\\\"><i class=\\\"fa fa-fw fa-minus\\\"></i></button>\\n\" +\n    \"                        <button ng-hide=\\\"view.getControlsHidden() || !view.params.xaxis || view.cube.dimensionParts(view.params.xaxis).hierarchy.levels.length < 2\\\" ng-disabled=\\\"! view.cube.dimensionParts(view.params.xaxis).drilldownDimensionPlus\\\" type=\\\"button\\\" ng-click=\\\"selectXAxis(view.cube.dimensionParts(view.params.xaxis).drilldownDimensionPlus, true)\\\" class=\\\"btn btn-secondary btn-xs hidden-print\\\" style=\\\"margin-left: 0px;\\\"><i class=\\\"fa fa-fw fa-plus\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"                        <!-- <button type=\\\"button\\\" ng-click=\\\"showDimensionFilter(view.params.xaxis)\\\" class=\\\"btn btn-secondary btn-xs\\\" style=\\\"margin-left: 3px;\\\"><i class=\\\"fa fa-fw fa-search\\\"></i></button>  -->\\n\" +\n    \"                        <!-- <button type=\\\"button\\\" ng-click=\\\"selectXAxis(null)\\\" class=\\\"btn btn-danger btn-xs\\\" style=\\\"margin-left: 1px;\\\"><i class=\\\"fa fa-fw fa-trash\\\"></i></button>  -->\\n\" +\n    \"                    </div>\\n\" +\n    \"\\n\" +\n    \"                </div>\\n\" +\n    \"            </div>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div class=\\\"clearfix\\\"></div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-view-viewdialogs\\\">\\n\" +\n    \"            <div ng-if=\\\"view.dimensionFilter\\\" ng-include=\\\"'views/cube/filter/dimension.html'\\\"></div>\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-view-viewdata\\\">\\n\" +\n    \"\\n\" +\n    \"            <div ng-if=\\\"view.params.mode == 'explore'\\\" ng-include=\\\"'views/cube/explore/explore.html'\\\"></div>\\n\" +\n    \"            <div ng-if=\\\"view.params.mode == 'facts'\\\" ng-include=\\\"'views/cube/facts/facts.html'\\\"></div>\\n\" +\n    \"            <div ng-if=\\\"view.params.mode == 'series'\\\" ng-include=\\\"'views/cube/series/series.html'\\\"></div>\\n\" +\n    \"            <div ng-if=\\\"view.params.mode == 'chart'\\\" ng-include=\\\"'views/cube/chart/chart.html'\\\"></div>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"        <div class=\\\"clearfix\\\"></div>\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-view-viewfooter\\\"></div>\\n\" +\n    \"\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/explore/explore.html',\n    \"<div ng-controller=\\\"CubesViewerViewsCubeExploreController\\\">\\n\" +\n    \"\\n\" +\n    \"    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\\n\" +\n    \"    <h3><i class=\\\"fa fa-fw fa-arrow-circle-down\\\"></i> Aggregated data\\n\" +\n    \"        <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"    </h3>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"        <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ui-grid=\\\"view.grid\\\"\\n\" +\n    \"         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\\n\" +\n    \"         ui-grid-pagination ui-grid-pinning\\n\" +\n    \"         style=\\\"width: 100%;\\\" ng-style=\\\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\\\">\\n\" +\n    \"    </div>\\n\" +\n    \"    <div style=\\\"height: 30px;\\\">&nbsp;</div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/facts/facts.html',\n    \"<div ng-controller=\\\"CubesViewerViewsCubeFactsController\\\">\\n\" +\n    \"\\n\" +\n    \"    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\\n\" +\n    \"    <h3><i class=\\\"fa fa-fw fa-th\\\"></i> Facts data\\n\" +\n    \"        <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"    </h3>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"        <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.grid.data.length > 0\\\"\\n\" +\n    \"         ui-grid=\\\"view.grid\\\"\\n\" +\n    \"         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\\n\" +\n    \"         ui-grid-pagination ui-grid-pinning\\n\" +\n    \"         style=\\\"width: 100%;\\\" ng-style=\\\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\\\">\\n\" +\n    \"    </div>\\n\" +\n    \"    <div ng-if=\\\"view.grid.data.length > 0\\\" style=\\\"height: 30px;\\\">&nbsp;</div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"viewController.view.pendingRequests == 0 && view.grid.data.length == 0\\\">No facts are returned by the current filtering combination.</div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/filter/datefilter.html',\n    \"<div class=\\\"cv-view-viewinfo-date\\\">\\n\" +\n    \"    <div ng-repeat=\\\"datefilter in view.params.datefilters\\\" ng-controller=\\\"CubesViewerViewsCubeFilterDateController\\\" ng-init=\\\"dimparts = view.cube.dimensionParts(datefilter.dimension);\\\" class=\\\"label label-secondary cv-infopiece cv-view-viewinfo-cut text-left\\\" style=\\\"color: black; background-color: #ffdddd; text-align: left;\\\">\\n\" +\n    \"        <span style=\\\"max-width: 280px; white-space: nowrap;\\\"><i class=\\\"fa fa-fw fa-filter\\\"></i> <b class=\\\"hidden-xs hidden-sm\\\">Filter:</b> {{ dimparts.labelNoLevel }}:</span>\\n\" +\n    \"\\n\" +\n    \"        <!--\\n\" +\n    \"        <br class=\\\"hidden-sm hidden-md hidden-lg\\\" />\\n\" +\n    \"        <i class=\\\"fa fa-fw hidden-sm hidden-md hidden-lg\\\" />\\n\" +\n    \"         -->\\n\" +\n    \"\\n\" +\n    \"        <div class=\\\"cv-datefilter\\\" style=\\\"overflow: visible; display: inline-block;\\\">\\n\" +\n    \"\\n\" +\n    \"            <form class=\\\"form-inline\\\">\\n\" +\n    \"\\n\" +\n    \"                 <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin: 0px;\\\">\\n\" +\n    \"                    <div class=\\\"dropdown\\\" style=\\\"display: inline-block;\\\">\\n\" +\n    \"                      <button ng-hide=\\\"view.getControlsHidden()\\\" style=\\\"height: 20px;\\\" class=\\\"btn btn-default btn-sm dropdown-toggle\\\" type=\\\"button\\\" data-toggle=\\\"dropdown\\\" data-submenu>\\n\" +\n    \"                        <i class=\\\"fa fa-fw fa-calendar\\\"></i> {{ datefilter.mode | datefilterMode }} <span class=\\\"caret\\\"></span>\\n\" +\n    \"                      </button>\\n\" +\n    \"                      <span ng-show=\\\"view.getControlsHidden()\\\"><i class=\\\"fa fa-fw fa-calendar\\\"></i> {{ datefilter.mode | datefilterMode }}</span>\\n\" +\n    \"\\n\" +\n    \"                      <ul class=\\\"dropdown-menu cv-view-menu cv-view-menu-view\\\">\\n\" +\n    \"                        <li ng-click=\\\"setMode('custom')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Custom</a></li>\\n\" +\n    \"                        <div class=\\\"divider\\\"></div>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-last1m')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Last month</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-last3m')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Last 3 months</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-last6m')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Last 6 months</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-last12m')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Last year</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-last24m')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Last 2 years</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-january1st')\\\"><a><i class=\\\"fa fa-fw\\\"></i> From January 1st</a></li>\\n\" +\n    \"                        <li ng-click=\\\"setMode('auto-yesterday')\\\"><a><i class=\\\"fa fa-fw\\\"></i> Yesterday</a></li>\\n\" +\n    \"                      </ul>\\n\" +\n    \"                  </div>\\n\" +\n    \"                 </div>\\n\" +\n    \"\\n\" +\n    \"            <div ng-show=\\\"datefilter.mode == 'custom'\\\" style=\\\"display: inline-block; margin: 0px;\\\">\\n\" +\n    \"\\n\" +\n    \"                 &rArr;\\n\" +\n    \"\\n\" +\n    \"                 <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin: 0px;\\\">\\n\" +\n    \"                    <p class=\\\"input-group disabled\\\" style=\\\"margin: 0px; display: inline-block;\\\">\\n\" +\n    \"                      <input ng-disabled=\\\"view.getControlsHidden()\\\" autocomplete=\\\"off\\\" type=\\\"text\\\" style=\\\"height: 20px; width: 80px; display: inline-block;\\\" class=\\\"form-control input-sm\\\" uib-datepicker-popup=\\\"yyyy-MM-dd\\\" ng-model=\\\"dateStart.value\\\" is-open=\\\"dateStart.opened\\\" datepicker-options=\\\"dateStart.options\\\" ng-required=\\\"true\\\" close-text=\\\"Close\\\" />\\n\" +\n    \"                      <span ng-hide=\\\"view.getControlsHidden()\\\"  class=\\\"input-group-btn\\\" style=\\\"display: inline-block;\\\">\\n\" +\n    \"                        <button type=\\\"button\\\" style=\\\"height: 20px;\\\" class=\\\"btn btn-default\\\" ng-click=\\\"dateStartOpen()\\\"><i class=\\\"fa fa-fw fa-calendar\\\"></i></button>\\n\" +\n    \"                      </span>\\n\" +\n    \"                    </p>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"                <span ng-hide=\\\"view.getControlsHidden()\\\" style=\\\"margin-left: 17px; margin-right: 0px;\\\">-</span>\\n\" +\n    \"                <span ng-show=\\\"view.getControlsHidden()\\\" style=\\\"margin-left: 0px; margin-right: 0px;\\\">-</span>\\n\" +\n    \"\\n\" +\n    \"                 <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin: 0px;\\\">\\n\" +\n    \"                    <p class=\\\"input-group\\\" style=\\\"margin: 0px; display: inline-block;\\\">\\n\" +\n    \"                      <input ng-disabled=\\\"view.getControlsHidden()\\\" autocomplete=\\\"off\\\" type=\\\"text\\\" style=\\\"height: 20px; width: 80px; display: inline-block;\\\" class=\\\"form-control input-sm\\\" uib-datepicker-popup=\\\"yyyy-MM-dd\\\" ng-model=\\\"dateEnd.value\\\" is-open=\\\"dateEnd.opened\\\" datepicker-options=\\\"dateEnd.options\\\" ng-required=\\\"true\\\" close-text=\\\"Close\\\" />\\n\" +\n    \"                      <span ng-hide=\\\"view.getControlsHidden()\\\" class=\\\"input-group-btn\\\" style=\\\"display: inline-block;\\\">\\n\" +\n    \"                        <button type=\\\"button\\\" style=\\\"height: 20px;\\\" class=\\\"btn btn-default\\\" ng-click=\\\"dateEndOpen()\\\"><i class=\\\"fa fa-fw fa-calendar\\\"></i></button>\\n\" +\n    \"                      </span>\\n\" +\n    \"                    </p>\\n\" +\n    \"                </div>\\n\" +\n    \"\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"        </form>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"\\n\" +\n    \"        <button type=\\\"button\\\" ng-hide=\\\"view.getControlsHidden()\\\" ng-click=\\\"selectDateFilter(datefilter.dimension, false)\\\" class=\\\"btn btn-danger btn-xs\\\" style=\\\"margin-left: 20px;\\\"><i class=\\\"fa fa-fw fa-trash\\\"></i></button>\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-info btn-xs\\\" style=\\\"visibility: hidden; margin-left: -20px;\\\"><i class=\\\"fa fa-fw fa-info\\\"></i></button>\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"    </div>\\n\" +\n    \"</div>\\n\" +\n    \"\\n\"\n  );\n\n\n  $templateCache.put('views/cube/filter/dimension.html',\n    \"<div ng-controller=\\\"CubesViewerViewsCubeFilterDimensionController\\\">\\n\" +\n    \"\\n\" +\n    \"    <div class=\\\"panel panel-default panel-outline hidden-print\\\" ng-hide=\\\"view.getControlsHidden()\\\" style=\\\"border-color: #ffcccc;\\\">\\n\" +\n    \"        <div class=\\\"panel-heading clearfix\\\" style=\\\"border-color: #ffcccc;\\\">\\n\" +\n    \"            <button class=\\\"btn btn-xs btn-danger pull-right\\\" ng-click=\\\"closeDimensionFilter()\\\"><i class=\\\"fa fa-fw fa-close\\\"></i></button>\\n\" +\n    \"            <h4 style=\\\"margin: 2px 0px 0px 0px;\\\"><i class=\\\"fa fa-fw fa-filter\\\"></i> Dimension filter: <b>{{ parts.label }}</b></h4>\\n\" +\n    \"        </div>\\n\" +\n    \"        <div class=\\\"panel-body\\\">\\n\" +\n    \"\\n\" +\n    \"            <div >\\n\" +\n    \"            <form >\\n\" +\n    \"\\n\" +\n    \"              <div class=\\\"form-group has-feedback\\\" style=\\\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\\\">\\n\" +\n    \"                <!-- <label for=\\\"search\\\">Search:</label>  -->\\n\" +\n    \"                <input type=\\\"text\\\" class=\\\"form-control\\\" ng-model=\\\"searchString\\\" ng-model-options=\\\"{ debounce: 300 }\\\" placeholder=\\\"Search...\\\" style=\\\"width: 16em;\\\">\\n\" +\n    \"                <i class=\\\"fa fa-fw fa-times-circle form-control-feedback\\\" ng-click=\\\"searchString = ''\\\" style=\\\"cursor: pointer; pointer-events: inherit;\\\"></i>\\n\" +\n    \"              </div>\\n\" +\n    \"\\n\" +\n    \"              <div class=\\\"btn-group\\\" style=\\\"margin-left: 10px; display: inline-block; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\\\">\\n\" +\n    \"                    <button class=\\\"btn btn-default\\\" ng-click=\\\"selectAll();\\\" type=\\\"button\\\" title=\\\"Select all\\\"><i class=\\\"fa fa-fw fa-check-square-o\\\"></i></button>\\n\" +\n    \"                    <button class=\\\"btn btn-default\\\" ng-click=\\\"selectNone();\\\" type=\\\"button\\\" title=\\\"Select none\\\"><i class=\\\"fa fa-fw fa-square-o\\\"></i></button>\\n\" +\n    \"              </div>\\n\" +\n    \"\\n\" +\n    \"<!--               <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\\\"> -->\\n\" +\n    \"              <div class=\\\"btn-group\\\" style=\\\"display: inline-block; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\\\">\\n\" +\n    \"                    <button ng-hide=\\\"parts.hierarchy.levels.length < 2\\\" ng-disabled=\\\"! parts.drilldownDimensionMinus\\\"  class=\\\"btn btn-default\\\" ng-click=\\\"showDimensionFilter(parts.drilldownDimensionMinus)\\\" type=\\\"button\\\" title=\\\"Drilldown less\\\"><i class=\\\"fa fa-fw fa-minus\\\"></i></button>\\n\" +\n    \"                    <button ng-hide=\\\"parts.hierarchy.levels.length < 2\\\" ng-disabled=\\\"! parts.drilldownDimensionPlus\\\"  class=\\\"btn btn-default\\\" ng-click=\\\"showDimensionFilter(parts.drilldownDimensionPlus)\\\" type=\\\"button\\\" title=\\\"Drilldown more\\\"><i class=\\\"fa fa-fw fa-plus\\\"></i></button>\\n\" +\n    \"                    <button class=\\\"btn btn-default\\\" type=\\\"button\\\" title=\\\"Drilldown this\\\" ng-click=\\\"selectDrill(parts.drilldownDimension, true)\\\"><i class=\\\"fa fa-fw fa-arrow-down\\\"></i></button>\\n\" +\n    \"              </div>\\n\" +\n    \"\\n\" +\n    \"              <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\\\">\\n\" +\n    \"                 <div class=\\\"btn btn-default\\\" ng-click=\\\"filterShowAll = ! filterShowAll\\\" ng-class=\\\"{ 'active': filterShowAll, 'btn-info': filterShowAll }\\\">\\n\" +\n    \"                    <i class=\\\"fa fa-fw fa-filter fa-rotate-180\\\"></i> Show all\\n\" +\n    \"                 </div>\\n\" +\n    \"              </div>\\n\" +\n    \"\\n\" +\n    \"              <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px; \\\">\\n\" +\n    \"\\n\" +\n    \"                  <div class=\\\"btn btn-default\\\" ng-click=\\\"filterInverted = !filterInverted\\\" ng-class=\\\"{ 'active': filterInverted, 'btn-danger': filterInverted }\\\">\\n\" +\n    \"                    <input type=\\\"checkbox\\\" ng-model=\\\"filterInverted\\\" style=\\\"pointer-events: none; margin: 0px; vertical-align: middle;\\\" ></input>\\n\" +\n    \"                    <b>&ne;</b> Invert\\n\" +\n    \"                  </div>\\n\" +\n    \"\\n\" +\n    \"              </div>\\n\" +\n    \"\\n\" +\n    \"                <div class=\\\"form-group\\\" style=\\\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\\\">\\n\" +\n    \"                 <button ng-click=\\\"applyFilter()\\\" class=\\\"btn btn-success\\\" type=\\\"button\\\"><i class=\\\"fa fa-fw fa-filter\\\"></i> Apply</button>\\n\" +\n    \"              </div>\\n\" +\n    \"            </form>\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"clearfix\\\"></div>\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"row\\\">\\n\" +\n    \"                <div class=\\\"col-xs-9 col-sm-6\\\">\\n\" +\n    \"                <div style=\\\"margin-top: 5px;\\\">\\n\" +\n    \"                    <div class=\\\"panel panel-default panel-outline\\\" style=\\\"margin-bottom: 0px; \\\"><div class=\\\"panel-body\\\" style=\\\"max-height: 180px; overflow-y: auto; overflow-x: hidden;\\\">\\n\" +\n    \"                        <div ng-show=\\\"loadingDimensionValues\\\" ><i class=\\\"fa fa-circle-o-notch fa-spin fa-fw\\\"></i> Loading...</div>\\n\" +\n    \"\\n\" +\n    \"                        <div ng-if=\\\"!loadingDimensionValues\\\">\\n\" +\n    \"                            <div ng-repeat=\\\"val in dimensionValues | filter:filterDimensionValue(searchString)\\\" style=\\\"overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\\\">\\n\" +\n    \"                                <label style=\\\"font-weight: normal; margin-bottom: 2px;\\\">\\n\" +\n    \"                                    <input type=\\\"checkbox\\\" name=\\\"selectedValues[]\\\" ng-model=\\\"val.selected\\\" value=\\\"{{ ::val.value }}\\\" style=\\\"vertical-align: bottom;\\\" />\\n\" +\n    \"                                    <span title=\\\"{{ val.label }}\\\">{{ ::val.label }}</span>\\n\" +\n    \"                                </label>\\n\" +\n    \"                            </div>\\n\" +\n    \"                        </div>\\n\" +\n    \"\\n\" +\n    \"                    </div></div>\\n\" +\n    \"\\n\" +\n    \"                    <div ng-if=\\\"!loadingDimensionValues\\\" class=\\\"\\\" style=\\\"margin-bottom: 0px; \\\">\\n\" +\n    \"                        <div class=\\\"text-right\\\">\\n\" +\n    \"                            {{ dimensionValues.length }} items\\n\" +\n    \"                        </div>\\n\" +\n    \"                    </div>\\n\" +\n    \"\\n\" +\n    \"                    <div ng-if=\\\"!loadingDimensionValues && dimensionValues.length >= cubesService.cubesserver.info.json_record_limit\\\" class=\\\"alert alert-warning\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"                        <div style=\\\"display: inline-block;\\\"><i class=\\\"fa fa-exclamation\\\"></i></div>\\n\" +\n    \"                        <div style=\\\"display: inline-block; margin-left: 20px;\\\">\\n\" +\n    \"                            Limit of {{ cubesService.cubesserver.info.json_record_limit }} items has been hit. Dimension value list is <b>incomplete</b>.<br />\\n\" +\n    \"                        </div>\\n\" +\n    \"                    </div>\\n\" +\n    \"\\n\" +\n    \"                </div>\\n\" +\n    \"                </div>\\n\" +\n    \"            </div>\\n\" +\n    \"\\n\" +\n    \"            <div class=\\\"clearfix\\\"></div>\\n\" +\n    \"\\n\" +\n    \"        </div>\\n\" +\n    \"      </div>\\n\" +\n    \"\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n\n  $templateCache.put('views/cube/series/series.html',\n    \"<div ng-controller=\\\"CubesViewerViewsCubeSeriesController\\\">\\n\" +\n    \"\\n\" +\n    \"    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\\n\" +\n    \"    <h3><i class=\\\"fa fa-fw fa-clock-o\\\"></i> Series table\\n\" +\n    \"        <i ng-show=\\\"view.pendingRequests > 0\\\" class=\\\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\\\"></i>\\n\" +\n    \"    </h3>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.pendingRequests > 0\\\" class=\\\"loadingbar-content\\\">\\n\" +\n    \"        <span class=\\\"loadingbar-expand\\\"></span>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.grid.data.length > 0\\\"\\n\" +\n    \"         ui-grid=\\\"view.grid\\\"\\n\" +\n    \"         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\\n\" +\n    \"         ui-grid-pagination ui-grid-pinning\\n\" +\n    \"         style=\\\"width: 100%;\\\" ng-style=\\\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\\\">\\n\" +\n    \"    </div>\\n\" +\n    \"    <div ng-if=\\\"view.grid.data.length > 0\\\" style=\\\"height: 30px;\\\">&nbsp;</div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.pendingRequests == 0 && view.params.yaxis == null\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"        <p>\\n\" +\n    \"            Cannot present series table: no <b>measure</b> has been selected.\\n\" +\n    \"        </p>\\n\" +\n    \"        <p>\\n\" +\n    \"            Tip: use the <kbd><i class=\\\"fa fa-fw fa-cogs\\\"></i> View &gt; <i class=\\\"fa fa-fw fa-crosshairs\\\"></i> Measure</kbd> menu.\\n\" +\n    \"        </p>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"    <div ng-if=\\\"view.pendingRequests == 0 && view.params.yaxis != null && view.grid.data.length == 0\\\" class=\\\"alert alert-info\\\" style=\\\"margin-bottom: 0px;\\\">\\n\" +\n    \"        <p>\\n\" +\n    \"            Cannot present series table: <b>no rows</b> are returned by the current horizontal dimension, drilldown or filtering combination.\\n\" +\n    \"        </p>\\n\" +\n    \"        <p>\\n\" +\n    \"            Tip: use the <kbd><i class=\\\"fa fa-fw fa-cogs\\\"></i> View</kbd> menu to select an horizontal dimension.\\n\" +\n    \"        </p>\\n\" +\n    \"    </div>\\n\" +\n    \"\\n\" +\n    \"</div>\\n\"\n  );\n\n}]);\n"
  },
  {
    "path": "cubesviewer/dialog/dialog.html",
    "content": "  <div class=\"modal-header\">\n    <button type=\"button\" ng-click=\"close()\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n    <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"fa fa-fw fa-exclamation\"></i> CubesViewer</h4>\n  </div>\n  <div class=\"modal-body\">\n        <p>{{ dialog.text }}</p>\n  </div>\n  <div class=\"modal-footer\">\n    <!-- <button type=\"button\" ng-click=\"close()\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Cancel</button>  -->\n    <button type=\"button\" ng-click=\"close()\" class=\"btn btn-primary\" data-dismiss=\"modal\">Close</button>\n  </div>\n\n"
  },
  {
    "path": "cubesviewer/dialog/dialog.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\nangular.module('cv.views').service(\"dialogService\", ['$rootScope', '$uibModal', 'cvOptions', 'cubesService',\n                                                    function ($rootScope, $uibModal, cvOptions, cubesService) {\n\n\tvar dialogService = this;\n\n\tthis.initialize = function() {\n\t\t$(\"body\").append('<div class=\"cv-modals cv-bootstrap\"></div>');\n\t};\n\n\tthis.show = function(text) {\n\n\t    var modalInstance = $uibModal.open({\n\t    \tanimation: true,\n\t    \ttemplateUrl: 'dialog/dialog.html',\n\t    \tcontroller: 'CubesViewerViewsDialogController',\n\t    \tappendTo: angular.element($(\"body\").find('.cv-modals')[0]),\n\t\t    resolve: {\n\t    \t\tdialog: function() { return { 'text': text }; }\n\t\t    },\n\t    \t/*\n\t\t    size: size,\n\t    \t */\n\t    });\n\n\t    modalInstance.result.then(function (selectedItem) {\n\t    \t//$scope.selected = selectedItem;\n\t    }, function () {\n\t        //console.debug('Modal dismissed at: ' + new Date());\n\t    });\n\n\t};\n\n\tthis.initialize();\n\n}]);\n\n\n/**\n */\nangular.module('cv.views').controller(\"CubesViewerViewsDialogController\", ['$rootScope', '$scope', '$timeout', '$uibModalInstance', 'cvOptions', 'cubesService', 'viewsService', 'dialog',\n                                                                           function ($rootScope, $scope, $timeout, $uibModalInstance, cvOptions, cubesService, viewsService, dialog) {\n\n\t$scope.$rootScope = $rootScope;\n\n\t$scope.dialog = dialog;\n\n\t$scope.close = function() {\n\t\t$uibModalInstance.dismiss('cancel');\n\t};\n\n\n}]);\n\n"
  },
  {
    "path": "cubesviewer/ga/googleanalytics.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n/*\n * Google Analytics events tracking service.\n *\n * When enabled, it uses Google Analytics event system to\n * log CubesViewer operations. Model loading, Aggregations, Facts and Dimension queries\n * are registered as non-interactive events (and don't affect bounce rate). Each\n * view refresh is registered as an interactive event.\n *\n */\n\n\n\"use strict\";\n\nangular.module('cv.cubes').service(\"gaService\", ['$rootScope', '$http', '$cookies', '$log', 'cvOptions',\n                                                  function ($rootScope, $http, $cookies, $log, cvOptions) {\n\n\tvar gaService = this;\n\n\tthis.ignorePeriod = 12; // 35\n\n\tthis.initTime = new Date();\n\n\tthis.initialize = function() {\n\t\tif (cvOptions.gaTrackEvents) $log.debug(\"Google Analytics events tracking plugin enabled.\")\n\t};\n\n\tthis.trackRequest = function(path) {\n\n\t\tif (! (cvOptions.gaTrackEvents)) return;\n\t\tif ((((new Date()) - this.initTime) / 1000) < this.ignorePeriod) return;\n\n\t\t// Track request, through Google Analytics events API\n\t\tvar event = null;\n\t\tvar pathParts = path.split(\"/\");\n\t\tvar modelPos = pathParts.indexOf(\"cube\");\n\n\t\tif (modelPos >= 0) {\n\t\t\tpathParts = pathParts.slice(modelPos + 1);\n\n\t\t\tif (pathParts[1] == \"model\") {\n\t\t\t\tevent = ['model', pathParts[0]];\n\t\t\t} else if (pathParts[1] == \"aggregate\") {\n\t\t\t\tevent = ['aggregate', pathParts[0]];\n\t\t\t} else if (pathParts[1] == \"facts\") {\n\t\t\t\tevent = ['facts', pathParts[0]];\n\t\t\t} else if (pathParts[1] == \"members\") {\n\t\t\t\tevent = ['dimension', pathParts[2]];\n\t\t\t}\n\t\t}\n\n\n\t\tif (event) {\n\t\t\tif (typeof ga !== 'undefined') {\n\t\t\t\tga('send', 'event', \"CubesViewer\", event[0], event[1]);\n\t\t\t\t$log.debug(\"Tracking GA event: \" + event[0] + \"/\" + event[1]);\n\t\t\t} else {\n\t\t\t\t$log.debug(\"Cannot track CubesViewer events: GA object 'ga' not available.\")\n\t\t\t}\n\t\t} else {\n\t\t\t$log.warn(\"Unknown cubes operation, cannot be tracked by GA service: \" + path)\n\t\t}\n\n\t};\n\n\tthis.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/server/reststore.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\nangular.module('cv.studio').service(\"reststoreService\", ['$rootScope', '$http', '$cookies', 'cvOptions', 'cubesService', 'viewsService', 'dialogService', 'studioViewsService',\n                                                           function ($rootScope, $http, $cookies, cvOptions, cubesService, viewsService, dialogService, studioViewsService) {\n\n\tvar reststoreService = this;\n\n\treststoreService.savedViews = [];\n\n\treststoreService.initialize = function() {\n\t\tif (! cvOptions.backendUrl) return;\n\t\treststoreService.viewList();\n\t};\n\n    /**\n     * Returns a stored view from memory.\n     */\n\treststoreService.getSavedView = function(savedId) {\n        var view = $.grep(reststoreService.savedViews, function(ed) { return ed.id == savedId; });\n        if (view.length > 0) {\n            return view[0];\n        } else {\n            return null;\n        }\n    };\n\n    /**\n     * Save a view.\n     */\n    reststoreService.saveView = function (view) {\n\n        if (view.owner != cvOptions.user) {\n            dialogService.show('Cannot save a view that belongs to other user (try cloning the view).');\n            return;\n        }\n\n        var data = {\n            \"id\": view.savedId,\n            \"name\": view.params.name,\n            \"shared\": view.shared,\n            \"data\":  viewsService.serializeView(view)\n        };\n\n        $http({\n        \t\"method\": \"POST\",\n        \t\"url\": cvOptions.backendUrl + \"/view/save/\",\n        \t\"data\": JSON.stringify(data),\n        \t\"headers\": {\"X-CSRFToken\": $cookies.get('csrftoken')},\n        }).then(reststoreService._viewSaveCallback(view), cubesService.defaultRequestErrorHandler);\n\n    };\n\n    /**\n     * Save callback\n     */\n    reststoreService._viewSaveCallback = function(view) {\n\n        var view = view;\n\n        return function(data, status) {\n            data = data.data;\n        \tif (view != null) {\n                view.savedId = data.id;\n\n                // Manually update saved list to avoid detecting differences as the list hasn't been reloaded\n                var sview = reststoreService.getSavedView(view.savedId);\n                if (sview != null) {\n                    sview.name = view.params.name;\n                    sview.shared = view.shared;\n                    sview.data = viewsService.serializeView(view)\n                }\n            }\n            reststoreService.viewList();\n\n            dialogService.show(\"View saved.\");\n        }\n\n    };\n\n    /**\n     * Delete a view.\n     */\n    reststoreService.deleteView = function (view) {\n\n        if (view.savedId == 0) {\n        \tdialogService.show(\"Cannot delete this view as it hasn't been saved.\");\n            return;\n        }\n        if (view.owner != cvOptions.user) {\n            dialogService.show('Cannot delete a view that belongs to other user.');\n            return;\n        }\n\n        if (! confirm('Are you sure you want to delete and close this view?')) {\n            return;\n        }\n\n        var data = {\n            \"id\": view.savedId,\n            \"data\": \"\"\n        };\n\n        studioViewsService.closeView(view);\n\n        $http({\n        \t\"method\": \"POST\",\n        \t\"url\": cvOptions.backendUrl + \"/view/save/\",\n        \t\"data\": JSON.stringify(data),\n        \t\"headers\": {\"X-CSRFToken\": $cookies.get('csrftoken')}\n         }).then(reststoreService._viewDeleteCallback, cubesviewer.defaultRequestErrorHandler);\n\n    };\n\n    /*\n     * Delete callback\n     */\n    reststoreService._viewDeleteCallback = function() {\n    \treststoreService.viewList();\n    };\n\n    /*\n     * Get view list.\n     */\n    reststoreService.viewList = function () {\n        $http.get(cvOptions.backendUrl + \"/view/list/\").then(\n        \t\treststoreService._viewListCallback, cubesService.defaultRequestErrorHandler);\n    };\n\n    reststoreService._viewListCallback = function(data, status) {\n    \treststoreService.savedViews = data.data;\n    };\n\n    reststoreService.isViewChanged = function(view) {\n\n        if (view.savedId == 0) return false;\n\n        // Find saved copy\n        var sview = reststoreService.getSavedView(view.savedId);\n\n        // Find differences\n        if (sview != null) {\n            if (view.params.name != sview.name) return true;\n            if (view.shared != sview.shared) return true;\n            if (viewsService.serializeView(view) != sview.data) return true;\n        }\n\n        return false;\n\n\t};\n\n    /**\n     * Change shared mode\n     */\n\treststoreService.shareView = function(view, sharedstate) {\n\n        if (view.owner != cvOptions.user) {\n            dialogService.show('Cannot share/unshare a view that belongs to other user (try cloning the view).');\n            return;\n        }\n\n        view.shared = ( sharedstate == 1 ? true : false );\n        reststoreService.saveView(view);\n\n    };\n\n    /**\n     * Loads a view from the backend.\n     * This is equivalent to other view adding methods in the cubesviewer.gui namespace,\n     * like \"addViewCube\" or \"addViewObject\", but thisloads the view definition from\n     * the storage backend.\n     */\n    reststoreService.addSavedView = function(savedViewId) {\n\n    \t// TODO: Check whether the server model is loaded, etc\n\n        var savedview = reststoreService.getSavedView(savedViewId);\n        var viewobject = $.parseJSON(savedview.data);\n        var view = studioViewsService.addViewObject(viewobject);\n\n        if (savedview.owner == cvOptions.user) {\n        \tview.savedId = savedview.id;\n        \tview.owner = savedview.owner;\n        \tview.shared = savedview.shared;\n        } else {\n        \tview.savedId = 0;\n        \tview.owner = cvOptions.user;\n        \tview.shared = false;\n        }\n\n    };\n\n    reststoreService.initialize();\n\n}]);\n\n"
  },
  {
    "path": "cubesviewer/studio/about.html",
    "content": "<div class=\"modal fade\" id=\"cvAboutModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"\">\n  <div class=\"modal-dialog\" role=\"document\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n        <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"cv-logo-embedded\"></i> CubesViewer</h4>\n      </div>\n      <div class=\"modal-body\">\n\n            <p><a href=\"http://jjmontesl.github.io/cubesviewer/\" target=\"_blank\">CubesViewer</a> is a visual, web-based application for exploring and analyzing\n            OLAP databases served by the <a href=\"http://cubes.databrewery.org/\" target=\"_blank\">Cubes OLAP Framework</a>.</p>\n            <hr />\n\n            <p>Version {{ cvVersion }}<br />\n            <a href=\"https://github.com/jjmontesl/cubesviewer/\" target=\"_blank\">https://github.com/jjmontesl/cubesviewer/</a></p>\n\n            <p>by José Juan Montes and others (see AUTHORS)<br />\n            2012 - 2016</p>\n\n            <p>\n            <a href=\"http://github.com/jjmontesl/cubesviewer/blob/master/LICENSE.txt\" target=\"_blank\">LICENSE</a>\n            </p>\n\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\"><i class=\"fa fa-cube\"></i> Close</button>\n      </div>\n    </div>\n  </div>\n</div>\n\n\n"
  },
  {
    "path": "cubesviewer/studio/localeswitcher.js.old",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Locale switcher button.\n */\nfunction cubesviewerGuiLocaleSwitcher() { \n\n\tthis.cubesviewer = cubesviewer; \n\t\n\t/*\n\t * Draw GUI options \n\t */\n\tthis.onGuiDraw = function(event, gui) {\n\t\t\n\t\t$(gui.options.container).find('.cv-gui-tools').prepend(\n\t\t\t\t'<div style=\"margin-bottom: 4px;\">' +\n\t\t\t\t'Language: ' +\n\t\t\t\t'<select name=\"cv-gui-localeswitcher\">' +\n\t\t\t\t'<option value=\"\">Default</option>' +\n\t\t\t\t'</select>' +\n\t\t\t\t'</div>'\n\t\t    );\n\t\t\n\t\t$('[name=cv-gui-localeswitcher]', $(cubesviewer.gui.options.container)).change(function() {\n\t\t\tcubesviewer.gui.localeswitcher.selectLocale(gui, $(this).val());\n\t\t});\n\t\t\n\t}\t\n\t\n\t/*\n\t * Draw languages from model\n\t */\n\tthis.onCubesviewerRefresh = function(event, data) {\n\t\t\n\t\tvar gui = event.data.gui;\n\t\tvar cubesviewer = gui.cubesviewer;\n\n\t\t// Add locales (clean list first)\n\t\t$('[name=cv-gui-localeswitcher]', $(cubesviewer.gui.options.container)).empty();\n\t\t$('[name=cv-gui-localeswitcher]', $(cubesviewer.gui.options.container)).append(\n\t\t\t\t'<option value=\"\">Default</option>'\n\t\t);\n\t\t$(cubesviewer.model[\"locales\"]).each(\n\t\t\tfunction(idx, locale) {\n\t\t\t\t$('[name=cv-gui-localeswitcher]', $(cubesviewer.gui.options.container)).append(\n\t\t\t\t\t\t'<option value=\"' + locale + '\">' + locale + '</option>'\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\t\n\t\t// Selected language\n\t\t$('[name=cv-gui-localeswitcher]', $(cubesviewer.gui.options.container)).val(gui.cubesviewer.options.cubesLang);\n\t\t\n\t}\n\t\n\n\t/*\n\t * Select cubes locale (at the time just changes .\n\t */\n\tthis.selectLocale = function(gui, locale) {\n\t\t\n\t\tgui.cubesviewer.changeCubesLang (locale);\n\t\t\n\t};\t\n\t\n};\n\n/*\n * Create object.\n */\ncubesviewer.gui.localeswitcher = new cubesviewerGuiLocaleSwitcher();\n\n/*\n * Bind events.\n */\n$(document).bind(\"cubesviewerGuiDraw\", { }, cubesviewer.gui.localeswitcher.onGuiDraw);\n$(document).bind(\"cubesviewerRefresh\", { \"gui\": cubesviewer.gui }, cubesviewer.gui.localeswitcher.onCubesviewerRefresh);\n"
  },
  {
    "path": "cubesviewer/studio/panel.html",
    "content": "<div class=\"cv-bootstrap cv-gui-viewcontainer\" ng-controller=\"CubesViewerStudioViewController\">\n\n    <div class=\"panel panel-primary\">\n        <div ng-if=\"! cvOptions.hideControls\" class=\"panel-heading\">\n\n            <button type=\"button\" ng-click=\"studioViewsService.closeView(view)\" class=\"btn btn-danger btn-xs pull-right hidden-print\" style=\"margin-left: 10px;\"><i class=\"fa fa-fw fa-close\"></i></button>\n            <button type=\"button\" ng-click=\"studioViewsService.toggleCollapseView(view)\" class=\"btn btn-primary btn-xs pull-right hidden-print\" style=\"margin-left: 5px;\"><i class=\"fa fa-fw\" ng-class=\"{'fa-caret-up': !view.collapsed, 'fa-caret-down': view.collapsed }\"></i></button>\n\n            <i class=\"fa fa-fw fa-file\"></i> <span class=\"cv-gui-title\" style=\"cursor: pointer;\" ng-dblclick=\"studioViewsService.studioScope.showRenameView(view)\"><a name=\"cvView{{ view.id }}\"></a>{{ view.params.name }}</span>\n\n            <span ng-if=\"view.savedId > 0 && reststoreService.isViewChanged(view)\" class=\"badge cv-gui-container-state\" style=\"margin-left: 15px; font-size: 80%;\">Modified</span>\n            <span ng-if=\"view.savedId > 0 && !reststoreService.isViewChanged(view)\" class=\"badge cv-gui-container-state\" style=\"margin-left: 15px; font-size: 80%;\">Saved</span>\n            <span ng-if=\"view.shared\" class=\"badge cv-gui-container-state\" style=\"margin-left: 5px; font-size: 80%;\">Shared</span>\n\n            <button type=\"button\" class=\"btn btn-danger btn-xs\" style=\"visibility: hidden;\"><i class=\"fa fa-fw fa-info\"></i></button>\n\n        </div>\n        <div class=\"panel-body\" ng-hide=\"view.collapsed\">\n            <div class=\"cv-gui-viewcontent\">\n\n                <div cv-view-cube view=\"view\"></div>\n\n            </div>\n        </div>\n    </div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/studio/rename.html",
    "content": "  <div class=\"modal-header\">\n    <button type=\"button\" ng-click=\"close();\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n    <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"fa fa-pencil\"></i> Rename view</h4>\n  </div>\n  <div class=\"modal-body\">\n\n        <form class=\"form\" ng-submit=\"renameView(viewName);\">\n            <div class=\"form-group\">\n                <label for=\"serializedView\">Name:</label>\n                <input class=\"form-control\" ng-model=\"viewName\" />\n            </div>\n        </form>\n\n  </div>\n  <div class=\"modal-footer\">\n    <button type=\"button\" ng-click=\"close();\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Cancel</button>\n    <button type=\"button\" ng-click=\"renameView(viewName);\" class=\"btn btn-primary\" data-dismiss=\"modal\">Rename</button>\n  </div>\n\n"
  },
  {
    "path": "cubesviewer/studio/serialize-add.html",
    "content": "  <div class=\"modal-header\">\n    <button type=\"button\" ng-click=\"close()\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n    <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"fa fa-code\"></i> Add view from serialized JSON</h4>\n  </div>\n  <div class=\"modal-body\">\n\n        <div class=\"form\">\n            <label for=\"serializedView\">Code:</label>\n            <textarea class=\"form-control\" ng-model=\"serializedView\" style=\"width: 100%; height: 12em;\" />\n        </div>\n\n  </div>\n  <div class=\"modal-footer\">\n    <button type=\"button\" ng-click=\"close()\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Cancel</button>\n    <button type=\"button\" ng-click=\"addSerializedView(serializedView)\" class=\"btn btn-primary\" data-dismiss=\"modal\">Add View</button>\n  </div>\n\n"
  },
  {
    "path": "cubesviewer/studio/serialize-view.html",
    "content": "  <div class=\"modal-header\">\n    <button type=\"button\" ng-click=\"close()\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n    <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"fa fa-code\"></i> Serialized View</h4>\n  </div>\n  <div class=\"modal-body\">\n\n        <div class=\"form\">\n            <label for=\"serializedView\">View definition JSON:</label>\n            <textarea class=\"form-control cv-serialized-view\" ng-bind=\"serializedView\" style=\"width: 100%; height: 12em;\" readonly></textarea>\n        </div>\n\n  </div>\n  <div class=\"modal-footer\">\n    <button type=\"button\" ng-click=\"close()\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\n  </div>\n\n"
  },
  {
    "path": "cubesviewer/studio/serialize.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/**\n * View serialization inteface. This is an optional component.\n * Provides visual assistance for serializing views and instancing of views from\n * serialized data. Note that only the view parameters are serialized,\n * but not data. The Cubes Server still needs to be available to serve data.\n * This serialized strings can also be used to initialize different views from code,\n * which is handy when these are going to be instantiated from code later on\n * (ie. when embedding views on a web site).\n */\nangular.module('cv.studio').controller(\"CubesViewerSerializeViewController\", ['$rootScope', '$scope', '$timeout', '$uibModalInstance', 'element', 'cvOptions', 'cubesService', 'studioViewsService', 'viewsService', 'view',\n                                                                             function ($rootScope, $scope, $timeout, $uibModalInstance, element, cvOptions, cubesService, studioViewsService, viewsService, view) {\n\n\t$scope.cvVersion = cubesviewer.version;\n\t$scope.cvOptions = cvOptions;\n\t$scope.cubesService = cubesService;\n\t$scope.studioViewsService = studioViewsService;\n\n\t$scope.serializedView = \"\";\n\n\t$scope.initialize = function() {\n\n\t\t$scope.serializedView  = viewsService.serializeView(view);\n\t\tconsole.log(\"Serialized view: \" + $scope.serializedView);\n\n\t\t$timeout(function() {\n\t\t\twindow.getSelection().removeAllRanges();\n\t\t\tvar range = document.createRange();\n\t\t\trange.selectNodeContents($(element).find(\".cv-serialized-view\")[0]);\n\t\t\twindow.getSelection().addRange(range);\n\t\t} , 0);\n\n\t};\n\n\t$scope.close = function() {\n\t\t$uibModalInstance.dismiss('cancel');\n\t};\n\n\t$scope.initialize();\n\n}]);\n\n\nangular.module('cv.studio').controller(\"CubesViewerSerializeAddController\", ['$rootScope', '$scope', '$uibModalInstance', 'cvOptions', 'cubesService', 'studioViewsService',\n                                                                             function ($rootScope, $scope, $uibModalInstance, cvOptions, cubesService, studioViewsService) {\n\n\t$scope.cvVersion = cubesviewer.version;\n\t$scope.cvOptions = cvOptions;\n\t$scope.cubesService = cubesService;\n\t$scope.studioViewsService = studioViewsService;\n\n\t$scope.serializedView = null;\n\n\t/*\n\t * Add a serialized view.\n\t */\n\t$scope.addSerializedView = function (serialized) {\n\t\tif (serialized != null) {\n\t\t\tvar view = studioViewsService.addViewObject(serialized);\n\t\t}\n\t\t$uibModalInstance.close(serialized);\n\t};\n\n\t$scope.close = function() {\n\t\t$uibModalInstance.dismiss('cancel');\n\t};\n\n}]);\n\n\n\n"
  },
  {
    "path": "cubesviewer/studio/serverinfo.html",
    "content": "<div class=\"modal fade\" id=\"cvServerInfo\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"\">\n  <div class=\"modal-dialog\" role=\"document\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\"><i class=\"fa fa-fw fa-close\"></i></span></button>\n        <h4 class=\"modal-title\" id=\"myModalLabel\"><i class=\"fa fa-fw fa-database\"></i> Server info</h4>\n      </div>\n      <div class=\"modal-body\">\n\n            <p>\n                <i>This CubesViewer version supports Cubes Server version 1.0.x and 1.1.x</i><br />\n                <br />\n                <b>Server version:</b> {{ cubesService.cubesserver.server_version }} <br />\n                <b>Cubes version:</b> {{ cubesService.cubesserver.cubes_version }} <br />\n                <b>API version:</b> {{ cubesService.cubesserver.api_version }} <br />\n            </p>\n            <p>\n                <b>Timezone:</b> {{ cubesService.cubesserver.info.timezone }} <br />\n                <b>Week start:</b> {{ cubesService.cubesserver.info.first_weekday }} <br />\n            </p>\n            <p>\n                <b>Result limit:</b> <strong class=\"text-warning\">{{ cubesService.cubesserver.info.json_record_limit }}</strong> items<br />\n            </p>\n\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\"> Close</button>\n      </div>\n    </div>\n  </div>\n</div>\n\n\n"
  },
  {
    "path": "cubesviewer/studio/studio.html",
    "content": "<div class=\"cv-bootstrap\" ng-controller=\"CubesViewerStudioController\">\n\n    <div class=\"cv-gui-panel hidden-print\">\n\n        <div class=\"dropdown m-b\" style=\"display: inline-block;\">\n          <button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n            <i class=\"fa fa-fw fa-cube\"></i> Cubes <span class=\"caret\"></span>\n          </button>\n\n          <ul class=\"dropdown-menu cv-gui-cubeslist-menu\">\n\n            <li ng-show=\"cubesService.state === 1\" class=\"disabled\"><a>Loading...</a></li>\n            <li ng-show=\"cubesService.state === 2 && cubesService.cubesserver._cube_list.length === 0\" class=\"disabled\"><a>No cubes found</a></li>\n            <li ng-show=\"cubesService.state === 3\" class=\"disabled text-danger\"><a>Loading failed</a></li>\n\n            <li ng-repeat=\"cube in cubesService.cubesserver._cube_list | orderBy:'label'\" ng-click=\"studioViewsService.addViewCube(cube.name)\"><a>{{ cube.label }}</a></li>\n\n          </ul>\n        </div>\n\n\n        <div ng-if=\"cvOptions.backendUrl\" class=\"dropdown m-b\" style=\"display: inline-block; \">\n          <button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n            <i class=\"fa fa-fw fa-file\"></i> Saved views <span class=\"caret\"></span>\n          </button>\n\n          <ul class=\"dropdown-menu cv-gui-catalog-menu\">\n\n            <li class=\"dropdown-header\">Personal views</li>\n\n            <!-- <li ng-show=\"true\" class=\"disabled\"><a>Loading...</a></li>  -->\n            <li ng-repeat=\"sv in reststoreService.savedViews | orderBy:'sv.name'\" ng-if=\"sv.owner == cvOptions.user\" ng-click=\"reststoreService.addSavedView(sv.id)\"><a style=\"max-width: 360px; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\"><i class=\"fa fa-fw\"></i> {{ sv.name }}</a></li>\n\n            <li class=\"dropdown-header\">Shared by others</li>\n\n            <!-- <li ng-show=\"true\" class=\"disabled\"><a>Loading...</a></li>  -->\n            <li ng-repeat=\"sv in reststoreService.savedViews | orderBy:'sv.name'\" ng-if=\"sv.shared && sv.owner != cvOptions.user\" ng-click=\"reststoreService.addSavedView(sv.id)\"><a style=\"max-width: 360px; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\"><i class=\"fa fa-fw\"></i> {{ sv.name }}</a></li>\n\n          </ul>\n        </div>\n\n\n        <div class=\"dropdown m-b\" style=\"display: inline-block; margin-left: 5px;\">\n          <button class=\"btn btn-primary dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n            <i class=\"fa fa-fw fa-wrench\"></i> Tools <span class=\"caret\"></span>\n          </button>\n\n          <ul class=\"dropdown-menu\">\n\n                <li ng-click=\"showSerializeAdd()\"><a tabindex=\"0\"><i class=\"fa fa-fw fa-code\"></i> Add view from JSON...</a></li>\n\n                <div class=\"divider\"></div>\n\n                <li ng-click=\"toggleTwoColumn()\" ng-class=\"{ 'hidden-xs': ! cvOptions.studioTwoColumn, 'disabled': studioViewsService.views.length == 0 }\"><a tabindex=\"0\"><i class=\"fa fa-fw fa-columns\"></i> 2 column\n                    <span class=\"label label-default\" style=\"margin-left: 10px;\" ng-class=\"{ 'label-success': cvOptions.studioTwoColumn }\">{{ cvOptions.studioTwoColumn ? \"ON\" : \"OFF\" }}</span></a>\n                </li>\n                <li ng-click=\"toggleHideControls()\" ng-class=\"{ 'disabled': studioViewsService.views.length == 0 }\"><a tabindex=\"0\"><i class=\"fa fa-fw fa-unlock-alt\"></i> Hide controls\n                    <span class=\"label label-default\" style=\"margin-left: 10px;\" ng-class=\"{ 'label-success': cvOptions.hideControls }\">{{ cvOptions.hideControls ? \"ON\" : \"OFF\" }}</span></a>\n                </li>\n\n                <div class=\"divider\"></div>\n\n\n                <!-- <li class=\"\"><a data-toggle=\"modal\" data-target=\"#cvServerInfo\"><i class=\"fa fa-fw fa-server\"></i> Data model</a></li> -->\n                <li class=\"\" ng-class=\"{ 'disabled': cubesService.state != 2 }\"><a data-toggle=\"modal\" data-target=\"#cvServerInfo\" ><i class=\"fa fa-fw fa-database\"></i> Server info</a></li>\n\n                <div class=\"divider\"></div>\n\n                <li class=\"\"><a href=\"http://github.com/jjmontesl/cubesviewer/blob/master/doc/guide/cubesviewer-user-main.md\" target=\"_blank\"><i class=\"fa fa-fw fa-question\"></i> User guide</a></li>\n                <li class=\"\"><a data-toggle=\"modal\" data-target=\"#cvAboutModal\"><i class=\"fa fa-fw fa-info\"></i> About CubesViewer...</a></li>\n\n            </ul>\n        </div>\n\n        <div style=\"display: inline-block; margin-left: 10px; margin-bottom: 0px;\">\n\n             <div class=\"form-group hidden-xs\" style=\"display: inline-block; margin-bottom: 0px;\">\n                <button class=\"btn\" type=\"button\" title=\"2 column\" ng-disabled=\"studioViewsService.views.length == 0\" ng-class=\"cvOptions.studioTwoColumn ? 'btn-active btn-success' : 'btn-primary'\" ng-click=\"toggleTwoColumn()\"><i class=\"fa fa-fw fa-columns\"></i></button>\n             </div>\n             <div class=\"form-group\" style=\"display: inline-block; margin-bottom: 0px;\">\n                <button class=\"btn\" type=\"button\" title=\"Hide controls\" ng-disabled=\"studioViewsService.views.length == 0\" ng-class=\"cvOptions.hideControls ? 'btn-active btn-success' : 'btn-primary'\" ng-click=\"toggleHideControls()\"><i class=\"fa fa-fw fa-unlock-alt\"></i></button>\n             </div>\n\n        </div>\n\n        <div class=\"cv-gui-modals\">\n            <div ng-include=\"'studio/about.html'\"></div>\n            <div ng-include=\"'studio/serverinfo.html'\"></div>\n        </div>\n\n    </div>\n\n    <div class=\"cv-gui-workspace\">\n\n        <div class=\"row\">\n            <div ng-if=\"cubesService.state == 3\" class=\"col-xs-12\" style=\"margin-bottom: 10px;\">\n                <div class=\"alert alert-danger\" style=\"margin: 0px;\">\n                    <p>Could not connect to server: {{ cubesService.stateText }}</p>\n                    <p>Please try again and contact your administrator if the problem persists.</p>\n                </div>\n            </div>\n        </div>\n\n        <div class=\"row cv-views-container\" data-masonry='{ \"itemSelector\": \".cv-view-container\", \"columnWidth\": \".cv-views-gridsizer\", \"percentPosition\": true }'>\n\n            <div class=\"col-xs-1 cv-views-gridsizer\"></div>\n\n            <div ng-repeat=\"studioView in studioViewsService.views\" style=\"display: none;\" class=\"col-xs-12 cv-view-container sv{{ studioView.id }}\" ng-class=\"(cvOptions.studioTwoColumn ? 'col-sm-6' : 'col-sm-12')\">\n                <div >\n                    <div cv-studio-view view=\"studioView\"></div>\n                </div>\n            </div>\n\n        </div>\n\n    </div>\n\n</div>\n\n\n"
  },
  {
    "path": "cubesviewer/studio/studio.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/**\n * CubesViewer Studio module. CubesViewer Studio is the (optional) interface that\n * provides a full visualization environment allowing users to create and\n * interact with cubes and views.\n *\n * See the CubesViewer Studio demo at `html/studio.html` in the package.\n *\n * @namespace cv.studio\n */\nangular.module('cv.studio', ['cv' /*'ui.bootstrap-slider', 'ui.validate', 'ngAnimate', */\n                             /*'angularMoment', 'smart-table', 'angular-confirm', 'debounce', 'xeditable',\n                             'nvd3' */ ]);\n\n/**\n * This service manages the panels and views of the CubesViewer Studio interface.\n * Provides methods to create, remove and collapse view panels which are rendered\n * within the CubesViewer Studio user interface.\n *\n * @class studioViewsService\n * @memberof cv.studio\n */\nangular.module('cv.studio').service(\"studioViewsService\", ['$rootScope', '$anchorScroll', '$timeout', 'cvOptions', 'cubesService', 'viewsService', 'dialogService',\n                                                            function ($rootScope, $anchorScroll, $timeout, cvOptions, cubesService, viewsService, dialogService) {\n\n\tthis.views = [];\n\n\tthis.studioScope = null;\n\n\tviewsService.studioViewsService = this;\n\tcubesviewerStudio.studioViewsService = this;\n\n\t/**\n\t * Adds a new clean view of type \"cube\" given a cube name.\n\t *\n\t * @memberof cv.studio.studioViewsService\n\t * @returns The created view object.\n\t */\n\tthis.addViewCube = function(cubename) {\n\n\t\t// Find cube name\n\t\tvar cubeinfo = cubesService.cubesserver.cubeinfo(cubename);\n\n\t\t//var container = this.createContainer(viewId);\n\t\t//$('.cv-gui-viewcontent', container),\n\n\t\tvar name = cubeinfo.label + \" (\" + (viewsService.lastViewId + 1) + \")\";\n\t\tvar view = viewsService.createView(\"cube\", { \"cubename\": cubename, \"name\": name });\n\t\tthis.views.push(view);\n\n\t\t$timeout(function() {\n\t\t\t$('.cv-views-container').masonry('appended', $('.cv-views-container').find(\".sv\" + view.id).show());\n\t\t\t//$('.cv-views-container').masonry('reloadItems');\n\t\t\t//$('.cv-views-container').masonry('layout');\n\t\t\t$timeout(function() { $anchorScroll(\"cvView\" + view.id); }, 500);\n\t\t}, 0);\n\n\t\treturn view;\n\t};\n\n\t/**\n\t * Adds a view given its parameters descriptor either as an object or as\n\t * a JSON string.\n\t *\n\t * @memberof cv.studio.studioViewsService\n\t * @returns The created view object.\n\t */\n\tthis.addViewObject = function(data) {\n\n\t\t// Check at least JSON is valid to avoid creating an unusable view from Studio\n\t\tif (typeof data == \"string\") {\n\t\t\ttry {\n\t\t\t\t$.parseJSON(data);\n\t\t\t} catch (err) {\n\t\t\t\tdialogService.show('Could not process serialized data: JSON parse error.')\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tvar view = viewsService.createView(\"cube\", data);\n\t\tthis.views.push(view);\n\n\t\t$timeout(function() {\n\t\t\t$('.cv-views-container').masonry('appended', $('.cv-views-container').find(\".sv\" + view.id).show());\n\t\t\t//$('.cv-views-container').masonry('reloadItems');\n\t\t\t//$('.cv-views-container').masonry('layout');\n\t\t\t$timeout(function() { $anchorScroll(\"cvView\" + view.id); }, 500);\n\t\t}, 0);\n\n\t\treturn view;\n\t};\n\n\t/**\n\t * Closes the panel of the given view.\n\t *\n\t * @memberof cv.studio.studioViewsService\n\t */\n\tthis.closeView = function(view) {\n\t\tvar viewIndex = this.views.indexOf(view);\n\t\tif (viewIndex >= 0) {\n\t\t\t$('.cv-views-container').masonry('remove', $('.cv-views-container').find(\".sv\" + view.id));\n\t\t\tthis.views.splice(viewIndex, 1);\n\t\t\t//$('.cv-views-container').masonry('reloadItems');\n\t\t\t$('.cv-views-container').masonry('layout');\n\t\t}\n\n\t};\n\n\t/**\n\t * Collapses the panel of the given view.\n\t *\n\t * @memberof cv.studio.studioViewsService\n\t */\n\tthis.toggleCollapseView = function(view) {\n\t\tview.collapsed = !view.collapsed;\n\t\t$timeout(function() {\n\t\t\t$('.cv-views-container').masonry('layout');\n\t\t}, 100);\n\t};\n\n\n}]);\n\n\n/**\n * cvStudioView directive. Shows a Studio panel containing the corresponding view.\n */\nangular.module('cv.studio').controller(\"CubesViewerStudioViewController\", ['$rootScope', '$scope', 'cvOptions', 'cubesService', 'studioViewsService', 'reststoreService',\n                                                     function ($rootScope, $scope, cvOptions, cubesService, studioViewsService, reststoreService) {\n\n\t$scope.cubesService = cubesService;\n\t$scope.studioViewsService = studioViewsService;\n\t$scope.cvOptions = cvOptions;\n\t$scope.reststoreService = reststoreService;\n\n\t$scope.$watch('__height', function() {\n\t\t$('.cv-views-container').masonry('layout');\n\t});\n\n}]).directive(\"cvStudioView\", function() {\n\treturn {\n\t\trestrict: 'A',\n\t\ttemplateUrl: 'studio/panel.html',\n\t\tscope: {\n\t\t\tview: \"=\"\n\t\t},\n        link: function( scope, elem, attrs ) {\n\n            scope.$watch( function() {\n                scope.__height = elem.height();\n            } );\n\n        }\n\n\t};\n});\n\n\n\nangular.module('cv.studio').controller(\"CubesViewerStudioController\", ['$rootScope', '$scope', '$uibModal', '$element', '$timeout', 'cvOptions', 'cubesService', 'studioViewsService', 'viewsService', 'reststoreService',\n                                                                       function ($rootScope, $scope, $uibModal, $element, $timeout, cvOptions, cubesService, studioViewsService, viewsService, reststoreService) {\n\n\t$scope.cvVersion = cubesviewer.version;\n\t$scope.cvOptions = cvOptions;\n\t$scope.cubesService = cubesService;\n\t$scope.studioViewsService = studioViewsService;\n\t$scope.reststoreService = reststoreService;\n\n\t$scope.studioViewsService.studioScope = $scope;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.showSerializeAdd = function() {\n\n\t    var modalInstance = $uibModal.open({\n\t    \tanimation: true,\n\t    \ttemplateUrl: 'studio/serialize-add.html',\n\t    \tcontroller: 'CubesViewerSerializeAddController',\n\t    \tappendTo: angular.element($($element).find('.cv-gui-modals')[0]),\n\t    \t/*\n\t\t    size: size,\n\t    \t */\n\t    });\n\n\t    modalInstance.result.then(function (selectedItem) {\n\t    \t//$scope.selected = selectedItem;\n\t    }, function () {\n\t        //console.debug('Modal dismissed at: ' + new Date());\n\t    });\n\t};\n\n\t$scope.showSerializeView = function(view) {\n\n\t    var modalInstance = $uibModal.open({\n\t    \tanimation: true,\n\t    \ttemplateUrl: 'studio/serialize-view.html',\n\t    \tcontroller: 'CubesViewerSerializeViewController',\n\t    \tappendTo: angular.element($($element).find('.cv-gui-modals')[0]),\n\t\t    resolve: {\n\t\t        view: function () { return view; },\n\t    \t\telement: function() { return $($element).find('.cv-gui-modals')[0] },\n\t\t    }\n\t    });\n\n\t    modalInstance.result.then(function (selectedItem) {\n\t    \t//$scope.selected = selectedItem;\n\t    }, function () {\n\t        //console.debug('Modal dismissed at: ' + new Date());\n\t    });\n\t};\n\n\t/*\n\t * Renames a view (this is the user-defined label that is shown in the GUI header).\n\t */\n\t$scope.showRenameView = function(view) {\n\n\t\tvar modalInstance = $uibModal.open({\n\t    \tanimation: true,\n\t    \ttemplateUrl: 'studio/rename.html',\n\t    \tcontroller: 'CubesViewerRenameController',\n\t    \tappendTo: angular.element($($element).find('.cv-gui-modals')[0]),\n\t    \tsize: \"md\",\n\t\t    resolve: {\n\t\t        view: function () { return view; },\n\t    \t\telement: function() { return $($element).find('.cv-gui-modals')[0] },\n\t\t    }\n\t    });\n\n\t    modalInstance.result.then(function (selectedItem) {\n\t    \t//$scope.selected = selectedItem;\n\t    }, function () {\n\t        //console.debug('Modal dismissed at: ' + new Date());\n\t    });\n\n\t};\n\n\t/*\n\t * Clones a view.\n\t * This uses the serialization facility.\n\t */\n\t$scope.cloneView = function(view) {\n\n\t\tvar viewObject = $.parseJSON(viewsService.serializeView(view));\n\t\tviewObject.name = \"Clone of \" + viewObject.name;\n\n\t\tvar view = studioViewsService.addViewObject(viewObject);\n\n\t\t// TODO: These belong to plugins\n\t\tview.savedId = 0;\n\t\tview.owner = cvOptions.user;\n\t\tview.shared = false;\n\t};\n\n\t/**\n\t * Toggles two column mode.\n\t */\n\t$scope.toggleTwoColumn = function() {\n\t\tcvOptions.studioTwoColumn = ! cvOptions.studioTwoColumn;\n\t\t$timeout(function() {\n\t\t\t$('.cv-views-container').masonry('layout');\n\t\t}, 100);\n\t};\n\n\t/**\n\t * Toggles two column mode.\n\t */\n\t$scope.toggleHideControls = function() {\n\t\tcvOptions.hideControls = ! cvOptions.hideControls;\n\t\t$timeout(function() {\n\t\t\t$('.cv-views-container').masonry('layout');\n\t\t}, 100);\n\t};\n\n\t$scope.initialize();\n\n}]);\n\n\n\n\nangular.module('cv.studio').controller(\"CubesViewerRenameController\", ['$rootScope', '$scope', '$uibModalInstance', 'cvOptions', 'cubesService', 'studioViewsService', 'view',\n                                                                       function ($rootScope, $scope, $uibModalInstance, cvOptions, cubesService, studioViewsService, view) {\n\n\t$scope.cvVersion = cubesviewer.version;\n\t$scope.cvOptions = cvOptions;\n\t$scope.cubesService = cubesService;\n\t$scope.studioViewsService = studioViewsService;\n\n\t$scope.viewName = view.params.name;\n\n\t/*\n\t * Add a serialized view.\n\t */\n\t$scope.renameView = function(viewName) {\n\n\t\t// TODO: Validate name\n\t\tif ((viewName != null) && (viewName != \"\")) {\n\t\t\tview.params.name = viewName;\n\t\t}\n\n\t\t$uibModalInstance.close(view);\n\t};\n\n\t$scope.close = function() {\n\t\t$uibModalInstance.dismiss('cancel');\n\t};\n\n}]);\n\n\n\n// Disable Debug Info (for production)\nangular.module('cv.studio').config([ '$compileProvider', function($compileProvider) {\n\t// TODO: Enable debug optionally\n\t// $compileProvider.debugInfoEnabled(false);\n} ]);\n\n\nangular.module('cv.studio').run(['$rootScope', '$compile', '$controller', '$http', '$templateCache', 'cvOptions',\n           function($rootScope, $compile, $controller, $http, $templateCache, cvOptions) {\n\n\tconsole.debug(\"Bootstrapping CubesViewer Studio.\");\n\n    // Add default options\n\tvar defaultOptions = {\n        container: null,\n        user: null,\n        studioTwoColumn: false,\n        hideControls: false,\n\n        backendUrl: null\n    };\n\t$.extend(defaultOptions, cvOptions);\n\t$.extend(cvOptions, defaultOptions);;\n\n    // Get main template from template cache and compile it\n\t$http.get(\"studio/studio.html\", { cache: $templateCache } ).then(function(response) {\n\n\t\t//var scope = angular.element(document).scope();\n\t\tvar templateScope = $rootScope.$new();\n\t\t$(cvOptions.container).html(response.data);\n\n\t\t//templateCtrl = $controller(\"CubesViewerStudioController\", { $scope: templateScope } );\n\t\t//$(cvOptions.container).children().data('$ngControllerController', templateCtrl);\n\n\t\t$compile($(cvOptions.container).contents())(templateScope);\n\t});\n\n}]);\n\n\n/**\n * CubesViewer Studio global instance and entry point. Used to initialize\n * CubesViewer Studio.\n *\n * This class is available through the global cubesviewerStudio variable,\n * and must not be instantiated.\n *\n * If you are embedding views in a 3rd party site and you do not need\n * Studio features, use {@link CubesViewer} initialization method instead.\n *\n * Note that the initialization method varies depending\n * on whether your application uses Angular 1.x or not.\n *\n * @class\n */\nfunction CubesViewerStudio() {\n\n\tthis._configure = function(options) {\n\t\tcubesviewer._configure(options);\n\t};\n\n\t/**\n\t * Initializes CubesViewer Studio.\n\t *\n\t * If you wish to embed CubesViewer Studio within an Angular application, you don't\n\t * need to call this method. Instead, use your application Angular `config`\n\t * block to initialize the cvOptions constant with your settings,\n\t * and add the 'cv.studio' module as a dependency to your application.\n\t *\n\t * See the `cv-angular.html` example for further information.\n\t */\n\tthis.init = function(options) {\n\t\tthis._configure(options);\n   \t\tangular.element(document).ready(function() {\n   \t\t\tangular.bootstrap(document, ['cv.studio']);\n   \t\t});\n\t};\n\n}\n\n/**\n * This is Cubesviewer Studio main entry point. Please see {@link CubesViewerStudio}\n * documentation for further information.\n *\n * @global\n */\nvar cubesviewerStudio = new CubesViewerStudio();\n\n"
  },
  {
    "path": "cubesviewer/views/cube/alerts.html",
    "content": "<div>\n\n    <div ng-if=\"view.requestFailed\" class=\"alert alert-dismissable alert-danger\" style=\"margin-bottom: 5px;\">\n        <div style=\"display: inline-block;\"><i class=\"fa fa-exclamation\"></i></div>\n        <div style=\"display: inline-block; margin-left: 20px;\">\n            An error has occurred. Cannot present view.<br />\n            Please try again and contact your administrator if the problem persists.\n        </div>\n    </div>\n\n    <div ng-if=\"view.resultLimitHit\" class=\"alert alert-dismissable alert-warning\" style=\"margin-bottom: 5px;\">\n        <button type=\"button\" class=\"close\" ng-click=\"view._resultLimitHit = false;\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>\n        <div style=\"display: inline-block; vertical-align: top;\"><i class=\"fa fa-exclamation\"></i></div>\n        <div style=\"display: inline-block; margin-left: 20px;\">\n            Limit of {{ cubesService.cubesserver.info.json_record_limit }} items has been hit. <b>Results are incomplete.</b><br />\n            <i>Tip</i>: reduce level of drilldown or filter your selection to reduce the number of items in the result.\n        </div>\n    </div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-bars-horizontal.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartBarsHorizontalController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$scope.chartCtrl.cleanupNvd3();\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartBarsVertical();\n\t\t}, 0);\n\t});\n\n\t/**\n\t * Draws a vertical bars chart.\n\t */\n\t$scope.drawChartBarsVertical = function () {\n\n\t\tvar view = $scope.view;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\"svg\").get(0);\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).label : \"None\")\n\n\t    var d = [];\n\n\t    var numRows = dataRows.length;\n\t    var serieCount = 0;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tvar serie = [];\n\t    \tfor (var i = 1; i < columnDefs.length; i++) {\n\t    \t\tvar value = e[columnDefs[i].name];\n\n\t    \t\t// If second serie is reversed\n\t    \t\tif (dataRows.length == 2 && serieCount == 1 && view.params.chartoptions.mirrorSerie2) value = (value != undefined) ? -value : 0;\n\n\t    \t\tserie.push( { \"x\": columnDefs[i].name, \"y\":  (value != undefined) ? value : 0 } );\n\t    \t}\n\n\t    \t// Reverse horizontal dimension to make series start from the base\n\t    \tserie.reverse();\n\n\t    \tvar series = { \"values\": serie, \"key\": e[\"key\"] != \"\" ? e[\"key\"] : view.params.yaxis };\n\t    \tif (view.params[\"chart-disabledseries\"]) {\n\t    \t\tif (view.params[\"chart-disabledseries\"][\"key\"] == (view.params.drilldown.join(\",\"))) {\n\t    \t\t\tseries.disabled = !! view.params[\"chart-disabledseries\"][\"disabled\"][series.key];\n\t    \t\t}\n\t    \t}\n\t    \td.push(series);\n\t    \tserieCount++;\n\t    });\n\t    d.sort(function(a,b) { return a.key < b.key ? -1 : (a.key > b.key ? +1 : 0) });\n\n\t    /*\n\t    xticks = [];\n\t    for (var i = 1; i < colNames.length; i++) {\n    \t\txticks.push([ i * 10, colNames[i] ]);\n\t    }\n\t    */\n\n\t    var chartOptions = {\n\t    \t  //barColor: d3.scale.category20().range(),\n\t    \t  delay: 1200,\n\t    \t  groupSpacing: 0.1,\n\t    \t  //reduceXTicks: false,\n\t    \t  //staggerLabels: true\n\t    };\n\n\t    var ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];\n\t\tvar colFormatter = $scope.columnFormatFunction(ag);\n\n\t\tnv.addGraph(function() {\n\t        var chart = nv.models.multiBarHorizontalChart()\n\t\t\t      //.x(function(d) { return d.label })\n\t\t\t      //.y(function(d) { return d.value })\n\t\t          .showLegend(!!view.params.chartoptions.showLegend)\n\t\t          .margin({left: 120})\n\t\t\t      //.showValues(true)           //Show bar value next to each bar.\n\t\t          //.tooltips(true)             //Show tooltips on hover.\n\t\t          //.transitionDuration(350)\n\t\t          .showControls(true);        //Allow user to switch between \"Grouped\" and \"Stacked\" mode.\n\n\t    \tif (view.params[\"chart-barsvertical-stacked\"]) {\n\t    \t\tchart.stacked ( view.params[\"chart-barsvertical-stacked\"] );\n\t    \t}\n\n\t        chart.options(chartOptions);\n\n\t        //chart.xAxis.axisLabel(xAxisLabel).showMaxMin(true).tickFormat(d3.format(',0f'));\n\t        //chart.xAxis.axisLabel(xAxisLabel);\n\n\t        //chart.yAxis.tickFormat(d3.format(',.2f'));\n\n\t        chart.yAxis.tickFormat(function(d, i) {\n\t        \tif (dataRows.length == 2 && view.params.chartoptions.mirrorSerie2 && d < 0) d = -d;\n\t        \treturn colFormatter(d);\n\t        });\n\n\t        d3.select(container)\n\t            .datum(d)\n\t            .call(chart);\n\n\t        //nv.utils.windowResize(chart.update);\n\n    \t    // Handler for state change\n            chart.dispatch.on('stateChange', function(newState) {\n            \tview.params[\"chart-barsvertical-stacked\"] = newState.stacked;\n            \tview.params[\"chart-disabledseries\"] = {\n        \t\t\t  \"key\": view.params.drilldown.join(\",\"),\n        \t\t\t  \"disabled\": {}\n            \t};\n            \tfor (var i = 0; i < newState.disabled.length; i++) {\n            \t\tview.params[\"chart-disabledseries\"][\"disabled\"][d[i][\"key\"]] =  newState.disabled[i];\n            \t}\n            \tview.updateUndo();\n            });\n\n\t        //chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });\n\n            $scope.chartCtrl.chart = chart;\n\n\t        return chart;\n\n\t    });\n\n\t}\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-bars-vertical.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartBarsVerticalController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$scope.chartCtrl.cleanupNvd3();\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartBarsVertical();\n\t\t}, 0);\n\t});\n\n\t/**\n\t * Draws a vertical bars chart.\n\t */\n\t$scope.drawChartBarsVertical = function () {\n\n\t\tvar view = $scope.view;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\"svg\").get(0);\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).label : \"None\")\n\n\t    var d = [];\n\n\t    var numRows = dataRows.length;\n\t    var serieCount = 0;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tvar serie = [];\n\t    \tfor (var i = 1; i < columnDefs.length; i++) {\n\t    \t\tvar value = e[columnDefs[i].name];\n\t    \t\tserie.push( { \"x\": columnDefs[i].name, \"y\":  (value != undefined) ? value : 0 } );\n\t    \t}\n\t    \tvar series = { \"values\": serie, \"key\": e[\"key\"] != \"\" ? e[\"key\"] : view.params.yaxis };\n\t    \tif (view.params[\"chart-disabledseries\"]) {\n\t    \t\tif (view.params[\"chart-disabledseries\"][\"key\"] == (view.params.drilldown.join(\",\"))) {\n\t    \t\t\tseries.disabled = !! view.params[\"chart-disabledseries\"][\"disabled\"][series.key];\n\t    \t\t}\n\t    \t}\n\t    \td.push(series);\n\t    \tserieCount++;\n\t    });\n\t    d.sort(function(a,b) { return a.key < b.key ? -1 : (a.key > b.key ? +1 : 0) });\n\n\t    /*\n\t    xticks = [];\n\t    for (var i = 1; i < colNames.length; i++) {\n    \t\txticks.push([ i * 10, colNames[i] ]);\n\t    }\n\t    */\n\n\t    var chartOptions = {\n\t    \t  //barColor: d3.scale.category20().range(),\n\t    \t  delay: 1200,\n\t    \t  groupSpacing: 0.1,\n\t    \t  //reduceXTicks: false,\n\t    \t  //staggerLabels: true\n\t    };\n\n\t    var ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];\n\t\tvar colFormatter = $scope.columnFormatFunction(ag);\n\n\t    nv.addGraph(function() {\n\t        var chart = nv.models.multiBarChart()\n\t\t          //.margin({bottom: 100})\n\t\t          .showLegend(!!view.params.chartoptions.showLegend)\n\t\t          .margin({left: 120});\n\n\t    \tif (view.params[\"chart-barsvertical-stacked\"]) {\n\t    \t\tchart.stacked ( view.params[\"chart-barsvertical-stacked\"] );\n\t    \t}\n\n\t        chart.options(chartOptions);\n\t        chart.multibar.hideable(true);\n\n\t        //chart.xAxis.axisLabel(xAxisLabel).showMaxMin(true).tickFormat(d3.format(',0f'));\n\t        chart.xAxis.axisLabel(xAxisLabel);\n\n\t        //chart.yAxis.tickFormat(d3.format(',.2f'));\n\t        chart.yAxis.tickFormat(function(d,i) {\n\t        \treturn colFormatter(d);\n\t        });\n\n\t        d3.select(container)\n\t            .datum(d)\n\t            .call(chart);\n\n\t        //nv.utils.windowResize(chart.update);\n\n    \t    // Handler for state change\n            chart.dispatch.on('stateChange', function(newState) {\n            \tview.params[\"chart-barsvertical-stacked\"] = newState.stacked;\n            \tview.params[\"chart-disabledseries\"] = {\n        \t\t\t  \"key\": view.params.drilldown.join(\",\"),\n        \t\t\t  \"disabled\": {}\n            \t};\n            \tfor (var i = 0; i < newState.disabled.length; i++) {\n            \t\tview.params[\"chart-disabledseries\"][\"disabled\"][d[i][\"key\"]] =  newState.disabled[i];\n            \t}\n            \tview.updateUndo();\n            });\n\n\t        //chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });\n\n            $scope.chartCtrl.chart = chart;\n\n\t        return chart;\n\n\t    });\n\n\t}\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-common.html",
    "content": "<div ng-show=\"(view.grid.data.length > 0 && view.params.yaxis != null) && (!(view.params.charttype == 'pie' && view.grid.columnDefs.length > 2)) && (!(view.params.charttype == 'radar' && view.grid.columnDefs.length < 4))\" style=\"width: 99%;\">\n    <div>\n        <div class=\"cv-chart-container\">\n            <svg style=\"height: 400px;\" />\n        </div>\n        <div ng-hide=\"view.getControlsHidden() || view.params.charttype == 'radar'\" style=\"font-size: 8px; float: right;\">\n            <a href=\"\" class=\"cv-chart-height\" ng-click=\"chartCtrl.resizeChart(400);\">Small</a>\n            <a href=\"\" class=\"cv-chart-height\" ng-click=\"chartCtrl.resizeChart(550);\">Medium</a>\n            <a href=\"\" class=\"cv-chart-height\" ng-click=\"chartCtrl.resizeChart(700);\">Tall</a>\n        </div>\n    </div>\n</div>\n\n<div ng-if=\"view.params.yaxis == null\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n    <p>\n        Cannot present chart: no <b>measure</b> has been selected.\n    </p>\n    <p>\n        Tip: use the <kbd><i class=\"fa fa-fw fa-cogs\"></i> View &gt; <i class=\"fa fa-fw fa-crosshairs\"></i> Measure</kbd> menu.\n    </p>\n</div>\n\n<div ng-if=\"view.pendingRequests == 0 && view.params.yaxis != null && view.grid.data.length == 0\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n    <p>\n        Cannot present chart: <b>no rows returned</b> by the current filtering, horizontal dimension, and drilldown combination.\n    </p>\n    <p>\n        Tip: use the <kbd><i class=\"fa fa-fw fa-cogs\"></i> View</kbd> menu to select an horizontal dimension.\n    </p>\n</div>\n\n<div ng-if=\"view.pendingRequests == 0 && view.params.charttype == 'pie' && view.grid.columnDefs.length > 2\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n    <p>\n        Cannot present a <b>pie chart</b> when <b>more than one column</b> is present.<br />\n    </p>\n    <p>\n        Tip: review chart data and columns in <a href=\"\" ng-click=\"setViewMode('series')\" class=\"alert-link\">series mode</a>,\n        or <a href=\"\" ng-click=\"selectXAxis(null);\" class=\"alert-link\">remove horizontal dimension</a>.\n    </p>\n</div>\n\n<div ng-if=\"view.pendingRequests == 0 && view.params.yaxis != null && view.params.charttype == 'radar' && view.grid.columnDefs.length < 4\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n    Cannot present a <b>radar chart</b> when <b>less than 3 columns</b> are present.<br />\n    Tip: review chart data and columns in <a href=\"\" ng-click=\"setViewMode('series')\" class=\"alert-link\">series mode</a>.\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-lines.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartLinesController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t\tif (! \"lineInterpolation\" in $scope.view.params.chartoptions) {\n\t\t\t$scope.view.params.chartoptions.lineInterpolation = \"linear\";\n\t\t}\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$scope.chartCtrl.cleanupNvd3();\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartLines();\n\t\t}, 0);\n\t});\n\n\n\t/**\n\t * Draws a vertical bars chart.\n\t */\n\t$scope.drawChartLines = function () {\n\n\t\tvar view = $scope.view;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\"svg\").get(0);\n\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).label : \"None\")\n\n\n\t    // TODO: Check there's only one value column\n\n\t\tvar d = [];\n\t    var numRows = dataRows.length;\n\t    var serieCount = 0;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tvar serie = [];\n\t    \tfor (var i = 1; i < columnDefs.length; i++) {\n\t    \t\tif (columnDefs[i].field in e) {\n\t    \t\t\tvar value = e[columnDefs[i].field];\n\t    \t\t\tserie.push( { \"x\": i, \"y\":  (value != undefined) ? value : 0 } );\n\t    \t\t} else  {\n\t    \t\t\tif (view.params.charttype == \"lines-stacked\") {\n\t    \t\t\t\tserie.push( { \"x\": i, \"y\":  0 } );\n\t    \t\t\t}\n\t    \t\t}\n\t    \t}\n\t    \tvar series = { \"values\": serie, \"key\": e[\"key\"] != \"\" ? e[\"key\"] : view.params.yaxis };\n\t    \tif (view.params[\"chart-disabledseries\"]) {\n\t    \t\tif (view.params[\"chart-disabledseries\"][\"key\"] == (view.params.drilldown.join(\",\"))) {\n\t    \t\t\tseries.disabled = !! view.params[\"chart-disabledseries\"][\"disabled\"][series.key];\n\t    \t\t}\n\t    \t}\n\t    \td.push(series);\n\t    \tserieCount++;\n\t    });\n\t    d.sort(function(a,b) { return a.key < b.key ? -1 : (a.key > b.key ? +1 : 0) });\n\n\t    /*\n\t    xticks = [];\n\t    for (var i = 1; i < colNames.length; i++) {\n    \t\txticks.push([ i, colNames[i] ]);\n\t    }\n\t    */\n\n\t    var ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];\n\t    var colFormatter = $scope.columnFormatFunction(ag);\n\n\t    if (view.params.charttype != \"lines-stacked\") {\n\n\t\t    nv.addGraph(function() {\n\t\t    \tvar chart = nv.models.lineChart()\n\t\t    \t\t.useInteractiveGuideline(true)\n\t\t    \t\t.interpolate($scope.view.params.chartoptions.lineInterpolation)\n\t\t    \t\t.showLegend(!!view.params.chartoptions.showLegend)\n\t\t    \t\t.margin({left: 120});\n\n\t\t    \tchart.xAxis\n\t\t    \t\t.axisLabel(xAxisLabel)\n\t\t    \t\t.tickFormat(function(d,i) {\n\t\t    \t\t\treturn (columnDefs[d].name);\n\t\t\t\t    });\n\n\t    \t\tchart.yAxis.tickFormat(function(d,i) {\n\t\t        \treturn colFormatter(d);\n\t\t        });\n\n\t\t    \td3.select(container)\n\t\t    \t\t.datum(d)\n\t\t    \t\t.call(chart);\n\n\t\t    \t  // Handler for state change\n\t\t          chart.dispatch.on('stateChange', function(newState) {\n\t\t        \t  view.params[\"chart-disabledseries\"] = {\n\t\t        \t\t\t  \"key\": view.params.drilldown.join(\",\"),\n\t\t        \t\t\t  \"disabled\": {}\n\t\t        \t  };\n\t\t        \t  for (var i = 0; i < newState.disabled.length; i++) {\n\t\t        \t\t  view.params[\"chart-disabledseries\"][\"disabled\"][d[i][\"key\"]] =  newState.disabled[i];\n\t\t        \t  }\n\t\t          });\n\n\t\t        $scope.chartCtrl.chart = chart;\n\t\t    \treturn chart;\n\t\t    });\n\n\t    } else {\n\n\t\t    nv.addGraph(function() {\n\t    \t  var chart = nv.models.stackedAreaChart()\n\t    \t                //.x(function(d) { return d[0] })\n\t    \t                //.y(function(d) { return \"y\" in d ? d.y : 0 })\n\t    \t  \t\t\t\t.showLegend(!!view.params.chartoptions.showLegend)\n\t    \t  \t\t\t\t.interpolate($scope.view.params.chartoptions.lineInterpolation)\n\t    \t  \t\t\t\t.margin({left: 130})\n\t    \t                .clipEdge(true)\n\t    \t                .useInteractiveGuideline(true);\n\n\t    \t  if (\tview.params[\"chart-stackedarea-style\"] ) {\n\t    \t\t  chart.style ( view.params[\"chart-stackedarea-style\"] );\n\t    \t  }\n\n\t    \t  chart.xAxis\t        //chart.xAxis.axisLabel(xAxisLabel).showMaxMin(true).tickFormat(d3.format(',0f'));\n\t    \t  \t  .axisLabel(xAxisLabel)\n\t    \t      .showMaxMin(false)\n\t    \t      .tickFormat(function(d, i) {\n\t    \t    \t  return (columnDefs[d].name);\n\t\t\t      });\n\n\t    \t  chart.yAxis.tickFormat(function(d,i) {\n\t    \t\t  return colFormatter(d);\n\t    \t  });\n\n\t    \t  d3.select(container)\n\t    \t  \t  .datum(d)\n\t    \t      .call(chart);\n\n\t    \t  // Handler for state change\n\t          chart.dispatch.on('stateChange', function(newState) {\n\t        \t  view.params[\"chart-stackedarea-style\"] = newState.style;\n\t        \t  view.params[\"chart-disabledseries\"] = {\n\t        \t\t\t  \"key\": view.params.drilldown.join(\",\"),\n\t        \t\t\t  \"disabled\": {}\n\t        \t  };\n\t        \t  for (var i = 0; i < newState.disabled.length; i++) {\n\t        \t\t  view.params[\"chart-disabledseries\"][\"disabled\"][d[i][\"key\"]] =  newState.disabled[i];\n\t        \t  }\n\t        \t  view.updateUndo();\n\t          });\n\n\t          $scope.chartCtrl.chart = chart;\n\t    \t  return chart;\n\t    \t});\n\t    }\n\n\t};\n\n\n\n\t/**\n\t */\n\t/*\n\tthis.drawChartLinesCumulative = function (view, colNames, dataRows, dataTotals) {\n\n\t\tvar container = $('#seriesChart-' + view.id).find(\"svg\").get(0);\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.getDimensionParts(view.params.xaxis).label : \"None\")\n\n\t    var d = [];\n\n\n\t    numRows = dataRows.length;\n\t    var serieCount = 1;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tserie = [];\n\t    \tfor (var i = 1; i < colNames.length; i++) {\n\t    \t\tif ( (colNames[i] in e) && (e[colNames[i]] != null) && (e[colNames[i]]) ) {\n\t    \t\t\tvar value = e[colNames[i]];\n\t    \t\t\tserie.push( { \"x\": i, \"y\": parseFloat(value) } );\n\t    \t\t} else {\n\t    \t\t\tserie.push( { \"x\": i, \"y\": 0 } );\n\t    \t\t}\n\t    \t}\n\t    \td.push({ \"values\": serie, \"key\": e[\"key\"] != \"\" ? e[\"key\"] : view.params.yaxis });\n\t    });\n\t    d.sort(function(a,b) { return a.key < b.key ? -1 : (a.key > b.key ? +1 : 0) });\n\n\t    nv.addGraph(function() {\n\t        var chart = nv.models.cumulativeLineChart()\n                          //.x(function(d) { return d.x })\n\t\t                  //.y(function(d) { return d.y })\n\t\t                  .showLegend(!!view.params.chartoptions.showLegend)\n\t\t                  .color(d3.scale.category20().range())\n\t                      //.color(d3.scale.category10().range())\n\t\t                  .useInteractiveGuideline(true)\n\t                      ;\n\n\t         chart.xAxis\n\t            .axisLabel(xAxisLabel)\n\t\t\t      .tickFormat(function(d,i) {\n\t\t\t                return (colNames[d]);\n\t\t\t       })\t;\n\n\t         chart.yAxis\n\t         .tickFormat(d3.format(',.2f'));\n\n\t        d3.select(container)\n\t            .datum(d)\n\t          .transition().duration(500)\n\t            .call(chart);\n\n    \t  // Handler for state change\n\t          chart.dispatch.on('stateChange', function(newState) {\n\t        \t  view.params[\"chart-stackedarea-style\"] = newState.style;\n\t        \t  view.params[\"chart-disabledseries\"] = {\n\t        \t\t\t  \"key\": view.params.drilldown.join(\",\"),\n\t        \t\t\t  \"disabled\": newState.disabled\n\t        \t  };\n\t          });\n\n\t        //TODO: Figure out a good way to do this automatically\n\t        nv.utils.windowResize(chart.update);\n\n\t        return chart;\n      });\n\n\t};\n\t*/\n\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-pie.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartPieController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$scope.chartCtrl.cleanupNvd3();\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartPie();\n\t\t}, 0);\n\t});\n\n\t/**\n\t */\n\t$scope.drawChartPie = function () {\n\n\t\tvar view = $scope.view;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\"svg\").get(0);\n\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).label : \"None\")\n\n\t    var d = [];\n\n\t    var numRows = dataRows.length;\n\t    var serieCount = 0;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tvar serie = [];\n\t    \tvar value = e[columnDefs[1].field];\n    \t\tif ((value != undefined) && (value > 0)) {\n\n    \t    \tvar series = { \"y\": value, \"key\": e[\"key\"] != \"\" ? e[\"key\"] : columnDefs[0].name };\n    \t    \tif (view.params[\"chart-disabledseries\"]) {\n    \t    \t\tif (view.params[\"chart-disabledseries\"][\"key\"] == (view.params.drilldown.join(\",\"))) {\n    \t    \t\t\tseries.disabled = !! view.params[\"chart-disabledseries\"][\"disabled\"][series.key];\n    \t    \t\t}\n    \t    \t}\n\n    \t    \td.push(series);\n    \t\t\tserieCount++;\n\n    \t\t}\n\n\t    });\n\t    d.sort(function(a,b) { return a.y < b.y ? -1 : (a.y > b.y ? +1 : 0) });\n\n\t    var xticks = [];\n\t    for (var i = 1; i < columnDefs.length; i++) {\n    \t\txticks.push([ i - 1, columnDefs[i].name ]);\n\t    }\n\n\t    var ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];\n\t    var colFormatter = $scope.columnFormatFunction(ag);\n\n\t    nv.addGraph(function() {\n\n\t        var chart = nv.models.pieChart()\n\t            .x(function(d) { return d.key })\n\t            .y(function(d) { return d.y })\n\t            .showLegend(!!view.params.chartoptions.showLegend)\n\t            .margin({bottom: 20, top: 20})\n\t            //.color(d3.scale.category20().range())\n\t            //.width(width)\n\t            //.height(height)\n\t            .labelType(\"percent\");\n\t            //.donut(true);\n\n\t        /*\n\t\t    chart.pie\n\t\t        .startAngle(function(d) { return d.startAngle/2 -Math.PI/2 })\n\t\t        .endAngle(function(d) { return d.endAngle/2 -Math.PI/2 });\n\t\t        */\n\n\t        chart.valueFormat(function(d,i) {\n\t        \treturn colFormatter(d);\n\t        });\n\n\t        d3.select(container)\n\t              .datum(d)\n\t              //.attr('width', width)\n\t              //.attr('height', height)\n\t              .call(chart);\n\n\t        //nv.utils.windowResize(chart.update);\n\n\t    \t// Handler for state change\n\t        chart.dispatch.on('stateChange', function(newState) {\n\t        \tview.params[\"chart-disabledseries\"] = {\n\t        \t\t\t\"key\": view.params.drilldown.join(\",\"),\n\t        \t\t\t\"disabled\": {}\n\t        \t};\n\t        \tfor (var i = 0; i < newState.disabled.length; i++) {\n\t        \t\tview.params[\"chart-disabledseries\"][\"disabled\"][d[i][\"key\"]] =  newState.disabled[i];\n\t        \t}\n\t        \tview.updateUndo();\n\t        });\n\n\t        $scope.chartCtrl.chart = chart;\n\t        return chart;\n\t    });\n\n\t};\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-radar.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartRadarController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartRadar();\n\t\t}, 2000);\n\t});\n\t$scope.$watch('cvOptions.studioTwoColumn', function() {\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartRadar();\n\t\t}, 2000);\n\t});\n\n\t$scope.$on(\"ViewResize\", function (){\n\t\t$scope.$apply(function(){\n\t\t\t$scope.drawChartRadar();\n\t\t});\n\t});\n\n\n\t/**\n\t */\n\t$scope.drawChartRadar = function () {\n\n\t\tvar view = $scope.view;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\".cv-chart-container\")[0];\n\t\t$(container).empty();\n\t\t$(container).height(400);\n\n\t    var d = [];\n\n\t    var numRows = dataRows.length;\n\t    $(dataRows).each(function(idx, e) {\n\t    \tvar serie = [];\n\t    \tfor (var i = 1; i < columnDefs.length; i++) {\n\t    \t\tvar value = e[columnDefs[i].field];\n\t    \t\tif (value != undefined) {\n\t    \t\t\tserie.push( [i-1, value] );\n\t    \t\t} else {\n\t    \t\t\tserie.push( [i-1, 0] );\n\t    \t\t}\n\t    \t}\n\t    \td.push({ data: serie, label: e[\"key\"] != \"\" ? e[\"key\"] : view.params.yaxis });\n\t    });\n\t    d.sort(function(a,b) { return a.label < b.label ? -1 : (a.label > b.label ? +1 : 0) });\n\n\t    var xticks = [];\n\t    for (var i = 1; i < columnDefs.length; i++) {\n    \t\txticks.push([ i - 1, columnDefs[i].name ]);\n\t    }\n\n\t    var flotrOptions = {\n\t    \t//HtmlText: ! view.doExport,\n\t    \tHtmlText: false,\n\t    \tshadowSize: 2,\n\t    \theight: 350,\n\t        radar: {\n\t            show: true,\n\t            fill: numRows < 4,\n\t            fillOpacity: 0.2\n\t        },\n\t        mouse: {\n\t            track: false,\n\t            relative: true\n\t        },\n\t        grid: {\n\t            circular: true,\n\t            minorHorizontalLines: true\n\t        },\n\t        xaxis: {\n\t            ticks: xticks\n\t        },\n\t        yaxis: {\n\t        },\n\t        legend: {\n\t        \tshow: (!!view.params.chartoptions.showLegend),\n\t            position: \"se\",\n\t            backgroundColor: \"#D2E8FF\"\n\t        }\n\t    };\n\t    $scope.flotrDraw = Flotr.draw(container, d, flotrOptions);\n\n\t};\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart-sunburst.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2013 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Sof\ttware, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Series Sunburst object. Contains view functions for the 'sunburst' mode.\n * This is an optional component, part of the cube view. Depends on the series mode.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartSunburstController\", ['$rootScope', '$scope', '$element', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                                                           function ($rootScope, $scope, $element, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.chart = null;\n\n\t$scope.initialize = function() {\n\t};\n\n\t$scope.$on('gridDataUpdated', function() {\n\t\t$timeout(function() {\n\t\t\t$scope.drawChartSunburst();\n\t\t}, 2000);\n\t});\n\n\t/**\n\t * Draws Series Chart.\n\t */\n\t$scope.drawChartSunburst = function() {\n\n\t\tvar view = $scope.view;\n\t\tvar data = $scope.rawData;\n\t\tvar dataRows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\t/*\n\t\t$(view.container).find('.cv-view-viewdata').empty();\n\n\t\tif (data.cells.length == 0) {\n\t\t\t$(view.container).find('.cv-view-viewdata').empty().append(\n\t\t\t\t'<h3>Dynamic Chart</h3>' +\n\t\t\t\t'<div>Cannot present chart as no data is returned by the current filtering and drilldown combination.</div>'\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t$(view.container).find('.cv-view-viewdata').css(\"width\", \"95%\");\n\t\t$(view.container).find('.cv-view-viewdata').append(\n\t\t\t'<div><h3>Dynamic Chart</h3>' +\n\t\t\t'<div id=\"dynamicChart-' + view.id + '\" style=\"height: 480px; width: 480px; float: left; \"></div></div>' +\n\t\t\t'<div id=\"dynamicChart-details-' + view.id + '\" style=\"width: 95%; margin-left: 10px;\" >' +\n\t\t\t'<h3>Selected Segment</h3>' +\n\t\t\t'<h3>Drilldowns</h3>' +\n\t\t\t'</div>'\n\t\t);\n\t\t*/\n\n\t\t// Process and draw cells\n\t\t//$scope._sortData (data.cells, view.params.xaxis != null ? true : false);\n\t\tvar json = $scope.prepareDrilldownTree (data);\n\t\t$scope.draw3DJSSunburst (json);\n\n\t};\n\n\t/*\n\t * Prepares drilldowndata\n\t */\n\t$scope.prepareDrilldownTree = function (data) {\n\n\t\tvar view = $scope.view;\n\n\t\tvar json =  [{\n\t\t\tchildren: [],\n\t\t\tname: \"Current Slice\",\n\t\t}];\n\n\t\tvar current = null;\n\n\t\t$(data.cells).each(function (idx, e) {\n\n\t\t\tcurrent = json[0];\n\n\t\t\t// For the horizontal axis drilldown level, if present\n\t\t\tfor (var i = 0; i < view.params.drilldown.length; i++) {\n\n\t\t\t\t// Get dimension\n\t\t\t\tvar parts = view.cube.dimensionParts(view.params.drilldown[i]);\n\t\t\t\tvar infos = parts.hierarchy.readCell(e);\n\n\t\t\t\t$(infos).each(function(idx, info) {\n\t\t\t\t\tvar child = $.grep(current.children, function(ed) { return ed.name == info.key; });\n\t\t\t\t\tif (child.length > 0) {\n\t\t\t\t\t\tcurrent = child[0];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchild = {\n\t\t\t\t\t\t\tchildren: [],\n\t\t\t\t\t\t\tname: String(info.key),\n\t\t\t\t\t\t\tlabel: info.label,\n\t\t\t\t\t\t\t//color: \"#aabbcc\" ,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcurrent.children.push(child);\n\t\t\t\t\t\tcurrent = child;\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t}\n\n\t\t\tcurrent.measure = (e[view.params.yaxis]);\n\n\t\t});\n\n\n\t\treturn json[0].children;\n\n\t};\n\n\tString.prototype.hashCode = function() {\n\t\t  var hash = 0, i, chr, len;\n\t\t  if (this.length === 0) return hash;\n\t\t  for (i = 0, len = this.length; i < len; i++) {\n\t\t    chr   = this.charCodeAt(i);\n\t\t    hash  = ((hash << 5) - hash) + chr;\n\t\t    hash |= 0; // Convert to 32bit integer\n\t\t  }\n\t\t  return hash;\n\t};\n\n\t$scope.draw3DJSSunburst = function(json) {\n\n\n\n\t\tvar view = $scope.view;\n\t\tvar json = json;\n\n\t\tvar data = $scope.rawData;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\tvar container = $($element).find(\"svg\").parent().empty().get(0);\n\t\tvar xAxisLabel = ( (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).label : \"None\");\n\n\n\t\tvar width = 470;\n\t\tvar height = width;\n\t\tvar radius = width / 2;\n\t\tvar varx = d3.scale.linear().range([ 0.0 * Math.PI, 2.0 * Math.PI ]);\n\t\t//var vary = d3.scale.pow().exponent(1).domain([ 0, 1 ]).range([ 5, radius]);\n\t\tvar vary = d3.scale.linear().domain([ 0, 1 ]).range([ 20, radius]);\n\t\tvar varp = 5;\n\t\tvar duration = 1000;\n\n\t\tvar colorScale = d3.scale.category20b().domain([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);\n\n\t\tvar lastD = null;\n\n\t\tfunction isParentOf(p, c) {\n\t        if (p === c)\n\t            return true;\n\t        if ((p.children) && (p.children.length > 0)) {\n\t            return p.children.some(function(d) {\n\t                return isParentOf(d, c);\n\t            });\n\t        }\n\t        return false;\n\t    }\n\n\t    function colour(d) {\n\n\t    \t// TODO: Color shall be different and consistent for each drilldown dimension, but shades\n\t    \t// of same palette for levels within same dimension. Use the various colourscales.\n\n\n\t    \tif (!d) return \"#ffaaaa\";\n\n\t    \tif (d.color != undefined) {\n\t    \t\treturn d.color;\n\t    \t} else if ((d.parent != null) && (d.parent.parent != null)) {\n\t    \t\td.color = colour(d.parent);\n\t    \t\tvar color2 = colorScale(Math.abs(String(d.name).hashCode()) % 20);\n\t    \t\td.color = d3.scale.linear().domain([0,100]).interpolate(d3.interpolateRgb).range([d.color, color2])(30);\n\t    \t\td.color = color2;\n\t    \t} else {\n\t    \t\tif (! (\"name\" in d)) {\n\t    \t\t\td.color = \"#ffffff\"; // center\n\t    \t\t} else {\n\t    \t\t\td.color = colorScale(Math.abs(String(d.name).hashCode()) % 20);\n\t    \t\t}\n    \t\t\t//console.debug (d.name + \"  hash: \" + (Math.abs(String(d.name).hashCode()) % 20) + \" color: \" + d.color);\n\t    \t}\n\t    \treturn d.color;\n\n\t    }\n\n\t    // Interpolate the scales!\n\t    function arcTween(d) {\n\t        var my = maxY(d),\n\t            xd = d3.interpolate(varx.domain(), [ d.x, d.x + d.dx ]),\n\t            yd = d3.interpolate(vary.domain(), [ d.y, my ]),\n\t            //yr = d3.interpolate(vary.range(), [ d.y ? 20 : 0, radius]);\n\t            yr = d3.interpolate(vary.range(), [ 20, radius]);\n\t        return function(d) {\n\t            return function(t) {\n\t                varx.domain(xd(t));\n\t                vary.domain(yd(t)).range(yr(t));\n\t                return arc(d);\n\t            };\n\t        };\n\n\t    }\n\n\t    function maxY(d) {\n\t    \treturn 1;\n\t    \t//return d.children ? Math.max.apply(Math, d.children.map(maxY)) : d.y + d.dy;\n\t    }\n\n\t    //http://www.w3.org/WAI/ER/WD-AERT/#color-contrast\n\t    function brightness(rgb) {\n\t        return rgb.r * .299 + rgb.g * .587 + rgb.b * .114;\n\t    }\n\n\t    function textPart(text, part) {\n\t    \tvar parts = text.split(\" \");\n\t    \tvar overflow = (parts.length > 8);\n\n\t    \tif (parts.length <= 2) {\n\t    \t\treturn (part == 0) ? text : \"\";\n\t    \t}\n\n\t    \tparts = parts.slice(0, 8);\n\t    \tif (part == 0) {\n\t    \t\tparts = parts.slice(0, Math.floor(parts.length / 2));\n\t    \t} else {\n\t    \t\tparts = parts.slice(Math.floor(parts.length / 2));\n\t    \t}\n\t    \treturn parts.join(\" \") + (overflow && part == 1 ? \"...\" : \"\");\n\t    }\n\n\t    var div = d3.select(container);\n\n\t    var vis = div.append(\"svg\").attr(\"width\", width + varp * 2).attr(\"height\",\n\t            height + varp * 2).append(\"g\").attr(\"transform\",\n\t            \"translate(\" + (radius + varp) + \",\" + (radius + varp) + \")\");\n\n\t    var partition = d3.layout.partition().sort(null).value(function(d) {\n\t        return d.measure;\n\t    });\n\n\t    var arc = d3.svg.arc().startAngle(function(d) {\n\t        return Math.max(0, Math.min(2 * Math.PI, varx(d.x)));\n\t    }).endAngle(function(d) {\n\t        return Math.max(0, Math.min(2 * Math.PI, varx(d.x + d.dx)));\n\t    }).innerRadius(function(d) {\n\t        return Math.max(0, d.y ? vary(d.y) : d.y);\n\t    }).outerRadius(function(d) {\n\t        return Math.max(0, vary(d.y + d.dy));\n\t    });\n\n       var nodes = partition.nodes({\n           children : json\n       });\n\n       var path = vis.selectAll(\"path\").data(nodes);\n\n       path.enter().append(\"path\").attr(\"id\", function(d, i) {\n           return \"path-\" + i;\n       }).attr(\"d\", arc).attr(\"fill-rule\", \"evenodd\").style(\n               \"fill\", colour).on(\"click\", click)\n       .each(function(d, i) {\n    \t   var el = this;\n    \t   $(el).hover(function() {\n    \t\t   d3.select(el)\n    \t\t      //.style(\"fill\", \"#ccccff\")\n    \t\t      .style('stroke', '#ffffff')\n    \t\t      .style('stroke-width', '2')\n    \t\t      .style('stroke-opacity', '1');\n    \t\t   $(el).insertBefore($('text').first());\n    \t   }, function() {\n    \t\t   d3.select(el)\n\t    \t\t   .style('stroke', '#000000')\n\t               .style('stroke-width', '0')\n\t               .style('stroke-opacity', '0');\n    \t   });\n       });\n\n\n       lastD = nodes[0];\n\n       var text = vis.selectAll(\"text\").data(nodes);\n       var textEnter = text\n               .enter()\n               .append(\"text\")\n               .style(\"fill-opacity\", 1)\n               .style(\n                       \"fill\",\n                       function(d) {\n                           return brightness(d3.rgb(colour(d))) < 125 ? \"#eee\"\n                                   : \"#000\";\n                       })\n               .style(\"font-size\", 9)\n               .style(\"-webkit-touch-callout\", \"none\")\n               .style(\"-webkit-user-select\", \"none\")\n    \t\t   .style(\"-khtml-user-select\", \"none\")\n\t\t\t   .style(\"-moz-user-select\", \"none\")\n\t\t\t   .style(\"-ms-user-select\", \"none\")\n\t\t\t   .style(\"user-select\", \"none\")\n\t\t\t   .style(\"pointer-events\", \"none\")\n               .style(\n\t               \"visibility\",\n\t               function(e) {\n\t                   var show = ( Math.abs(varx(e.x + e.dx ) - varx(e.x) ) > Math.PI / 48 );\n\t                   show = true;\n\t                   return show ? null  : \"hidden\";\n\t                   //return isParentOf(d, e) ? null  : d3.select(this).style(\"visibility\");\n\t               })\n               .attr(\n                       \"text-anchor\",\n                       function(d) {\n                           return varx(d.x + d.dx / 2) > Math.PI ? \"end\"\n                                   : \"start\";\n                       })\n               .attr(\"dy\", \".2em\")\n               .attr(\n                       \"transform\",\n                       function(d) {\n                           var multiline = (('label' in d ? String(d.label) : \"\") || \"\").split(\" \").length > 1\n                           var angle = varx(d.x + d.dx / 2)* 180 / Math.PI - 90\n                           var rotate = angle + (multiline ? -.5 : 0);\n                           return \"rotate(\" + rotate + \")translate(\"\n                                   + (vary(d.y) + varp) + \")rotate(\"\n                                   + (angle > 90 ? -180 : 0)\n                                   + \")\";\n                       }).on(\"click\", click);\n       textEnter.append(\"tspan\").attr(\"x\", 0).text(\n               function(d) {\n                   return d.depth ? (textPart(d.label, 0)) : \"\";\n               });\n       textEnter\n               .append(\"tspan\")\n               .attr(\"x\", 0)\n               .attr(\"dy\", \"1em\")\n               .text(function(d) { return d.depth ? textPart(d.label, 1) || \"\" : \"\"; });\n\n       /*\n       d3.select(\"#graphBlocks\").on(\"click\", function() {\n           graphBlocks();\n           return false;\n       });\n       d3.select(\"#graphSize\").on(\"click\", function() {\n           graphSize();\n           return false;\n       });\n       */\n\n       function updateText(d) {\n    \t   // Note the example hacked this as they rely on arcTween updating the scales.\n           text\n                   .style(\n                           \"visibility\",\n                           function(e) {\n                               var show = ( Math.abs(varx(e.x + e.dx ) - varx(e.x) ) > Math.PI / 48 );\n                               return show ? null  : \"hidden\";\n                               //return isParentOf(d, e) ? null  : d3.select(this).style(\"visibility\");\n                           })\n                   .transition()\n                   .duration(duration)\n                   .attrTween(\n                           \"text-anchor\",\n                           function(d) {\n                               return function() {\n                                   return varx(d.x + d.dx / 2) > Math.PI ? \"end\"\n                                           : \"start\";\n                               };\n                           })\n                   .attrTween(\n                           \"transform\",\n                           function(d) {\n                               var multiline = (d.name || \"\").split(\" \").length > 1;\n                               return function() {\n                                   var angle = varx(d.x + d.dx\n                                           / 2)\n                                           * 180\n                                           / Math.PI\n                                           - 90, rotate = angle\n                                           + (multiline ? -.5\n                                                   : 0);\n                                   return \"rotate(\" + rotate + \")translate(\" + (vary(d.y) + varp)\n                                           + \")rotate(\" + (angle > 90 ? -180 : 0) + \")\";\n                               };\n                           }).style(\n                           \"fill-opacity\",\n                           function(e) {\n                               return isParentOf(d, e) ? 1\n                                       : 1e-6;\n                           }).each(\n                           \"end\",\n                           function(e) {\n\n                        \t   var show = ( Math.abs(varx(e.x + e.dx ) - varx(e.x) ) > Math.PI / 48 );\n                        \t   d3.select(this).style(\"visibility\", show ? null  : \"hidden\");\n                        \t   //d3.select(this).style(\"visibility\", && isParentOf(d, e)  ? null  : \"hidden\");\n                           });\n           }\n\n       function click(d) {\n\n    \t   lastD = d;\n\n           path.transition().duration(duration).attrTween(\"d\", arcTween(d));\n\n           updateText(d);\n       }\n\n\t};\n\n\n\n}]);\n\nfunction cubesviewerViewCubeDynamicChart() {\n\n\t/*\n\t * Draw cube view structure.\n\t */\n\tthis.onViewDraw = function(event, view) {\n\t\t// Remove horizontal dimension menu\n\t\t$(\".cv-view-series-horizontal-menu\", $(view.container)).remove();\n\t\t// Remove horizontal dimension info\n\t\t$(\".cv-view-series-horizontal-info\", $(view.container)).parents('.infopiece').remove();\n\t};\n\n\n\t/*\n\t * Load and draw current data\n\t */\n\tthis.loadData = function(view) {\n\n\t\t// Build params (do not include xaxis)\n\t\tvar params = this.cubesviewer.views.cube.buildQueryParams(view, false, false);\n\n\t\t$('#' + view.id).find('.cv-view-viewdata').empty().append('<h3>Dynamic Chart</h3><span class=\"ajaxloader\" title=\"Loading...\">  Loading</span>');\n\n\t\t$.get(view.cubesviewer.options.cubesUrl + \"/cube/\" + view.cube.name + \"/aggregate\", params,\n\t\t\t\tview.cubesviewer.views.cube.dynamicchart._loadDataCallback(view), \"json\");\n\n\t};\n\n};\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart.html",
    "content": "<div ng-controller=\"CubesViewerViewsCubeChartController as chartCtrl\">\n\n    <div ng-if=\"view.params.charttype == 'pie'\">\n        <h3><i class=\"fa fa-fw fa-pie-chart\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartPieController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'bars-vertical'\">\n        <h3><i class=\"fa fa-fw fa-bar-chart\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartBarsVerticalController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'bars-horizontal'\">\n        <h3><i class=\"fa fa-fw fa-bar-chart fa-rotate-270\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartBarsHorizontalController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'lines'\">\n        <h3><i class=\"fa fa-fw fa-line-chart\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartLinesController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'lines-stacked'\">\n        <h3><i class=\"fa fa-fw fa-area-chart\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartLinesController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'radar'\">\n        <h3><i class=\"fa fa-fw fa-bullseye\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartRadarController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n    <div ng-if=\"view.params.charttype == 'sunburst'\">\n        <h3><i class=\"fa fa-fw fa-sun-o\"></i> Chart\n            <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n        </h3>\n        <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n            <span class=\"loadingbar-expand\"></span>\n        </div>\n        <div ng-controller=\"CubesViewerViewsCubeChartSunburstController\">\n            <div ng-include=\"'views/cube/chart/chart-common.html'\"></div>\n        </div>\n    </div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/chart/chart.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/*\n * Series chart object. Contains view functions for the 'chart' mode.\n * This is an optional component, part of the cube view.\n */\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeChartController\", ['$rootScope', '$scope', '$timeout', '$element', 'cvOptions', 'cubesService', 'viewsService', 'seriesOperationsService', 'exportService',\n                                                     function ($rootScope, $scope, $timeout, $element, cvOptions, cubesService, viewsService, seriesOperationsService, exportService) {\n\n\tvar chartCtrl = this;\n\n\tthis.chart = null;\n\n\tthis.initialize = function() {\n\t\t// Add chart view parameters to view definition\n\t\t$scope.view.params = $.extend(\n\t\t\t{},\n\t\t\t{ \"charttype\" : \"bars-vertical\", \"chartoptions\": { showLegend: true } },\n\t\t\t$scope.view.params\n\t\t);\n\t\t//$scope.refreshView();\n\t};\n\n\t$scope.$watch(\"view.params.charttype\", function() {\n\t\tchartCtrl.loadData();\n\t});\n\t$scope.$on(\"ViewRefresh\", function(view) {\n\t\tchartCtrl.loadData();\n\t});\n\n\tthis.loadData = function() {\n\n\t\tvar view = $scope.view;\n\n\t\t// Check if we can produce a table\n\t\tif (view.params.yaxis == null) return;\n\n\t\tvar browser_args = cubesService.buildBrowserArgs($scope.view, $scope.view.params.xaxis != null ? true : false, false);\n\t\tvar browser = new cubes.Browser(cubesService.cubesserver, $scope.view.cube);\n\t\tvar viewStateKey = $scope.newViewStateKey();\n\t\tvar jqxhr = browser.aggregate(browser_args, $scope._loadDataCallback(viewStateKey));\n\n\t\t$scope.view.pendingRequests++;\n\t\tjqxhr.always(function() {\n\t\t\t$scope.view.pendingRequests--;\n\t\t\t$rootScope.$apply();\n\t\t});\n\t\tjqxhr.error($scope.requestErrorHandler);\n\n\t};\n\n\t$scope._loadDataCallback = function(viewStateKey) {\n\t\treturn function(data, status) {\n\t\t\t// Only update if view hasn't changed since data was requested.\n\t\t\tif (viewStateKey == $scope._viewStateKey) {\n\t\t\t\t$scope.validateData(data, status);\n\t\t\t\tchartCtrl.processData(data);\n\t\t\t\t$rootScope.$apply();\n\t\t\t}\n\t\t};\n\t};\n\n\tthis.processData = function(data) {\n\n\t\tif ($scope.view.pendingRequests == 0) {\n\t\t\t$($element).find(\"svg\").empty();\n\t\t\t$($element).find(\"svg\").parent().children().not(\"svg\").remove();\n\t\t}\n\n\t\t$scope.rawData = data;\n\n\t\t$scope.resetGrid();\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t\t$rootScope.$apply();\n\n\t\tvar view = $scope.view;\n\t\tvar rows = $scope.view.grid.data;\n\t\tvar columnDefs = view.grid.columnDefs;\n\n\t\t// Process data\n\t\t//$scope._sortData (data.cells, view.params.xaxis != null ? true : false);\n\t    this._addRows($scope, data);\n\t    seriesOperationsService.applyCalculations($scope.view, $scope.view.grid.data, view.grid.columnDefs);\n\n\t\t// Join keys\n\t\tif (view.params.drilldown.length > 0) {\n\t\t\tcolumnDefs.splice (0, view.params.drilldown.length, {\n\t\t\t\tname: \"key\"\n\t\t\t});\n\n\t\t\t$(rows).each(function(idx, e) {\n\t\t\t\tvar jointkey = [];\n\t\t\t\tfor (var i = 0; i < view.params.drilldown.length; i++) jointkey.push(e[\"key\" + i]);\n\t\t\t\te[\"key\"] = jointkey.join(\" / \");\n\t\t\t});\n\t\t}\n\n\t\t$scope.$broadcast(\"gridDataUpdated\");\n\n\t};\n\n\t/*\n\t * Adds rows.\n\t */\n\tthis._addRows = cubesviewer._seriesAddRows;\n\n\tthis.cleanupNvd3 = function() {\n\n\t\t//$($element).find(\"svg\").empty();\n\t\t$($element).find(\"svg\").parent().children().not(\"svg\").remove();\n\n\t\tif (chartCtrl.chart) {\n\t\t\t$(\"#\" + chartCtrl.chart.tooltip.id()).remove(); // div.nvtooltip\n\t\t}\n\n\t\t//$scope.chart = null;\n\n\t\t/*\n\t\tvar len = nv.graphs.length;\n\t\twhile (len--) {\n\t\t\tif (! ($.contains(document.documentElement, nv.graphs[len].container))) {\n\t\t\t    // Element is detached, destroy graph\n\t\t\t\tnv.graphs.splice (len,1);\n\t\t\t}\n\t\t}\n\t\t*/\n\t};\n\n\t$scope.$watch('cvOptions.studioTwoColumn', function() {\n\t\tif (chartCtrl.chart) {\n\t\t\t$timeout(function() {\n\t\t\t\tchartCtrl.chart.update();\n\t\t\t}, 100);\n\t\t}\n\t});\n\n\tthis.resizeChart = function(size) {\n\t\tvar view = $scope.view;\n\t\t$($element).find('svg').height(size);\n\t\t$($element).find('svg').resize();\n\n\t\tif (chartCtrl.chart) chartCtrl.chart.update();\n\t};\n\n\t$scope.$on(\"ViewResize\", function(view) {\n\t\tif (chartCtrl.chart) chartCtrl.chart.update();\n\t});\n\n\t/**\n\t * FIXME: This shouldn't be defined here.\n\t * Note that `this` refers to the view in this context.\n\t */\n\t$scope.view.exportChartAsPNG = function() {\n\n\t\tvar doctype = '<?xml version=\"1.0\" standalone=\"no\"?>'\n\t\t\t  + '<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">';\n\n\t\t// Get page styles\n\t\tvar styles = exportService.getDocumentStyles();\n\t\tstyles = (styles === undefined) ? \"\" : styles;\n\n\t\t// Serialize our SVG XML to a string.\n\t\tvar svgSel = $($element).find('svg').first();\n\t\tsvgSel.addClass(\"cv-bootstrap\");\n\t\tsvgSel.css(\"font-size\", \"10px\");\n\t\tsvgSel.css(\"font-family\", \"Helvetica, Arial, sans-serif\");\n\t\tsvgSel.css(\"background-color\", \"white\");\n\t\tsvgSel.attr(\"width\", svgSel.width());\n\t\tsvgSel.attr(\"height\", svgSel.height());\n\t\tsvgSel.attr(\"version\", \"1.1\")\n\n\t\tvar defsEl = document.createElement(\"defs\");\n\t    svgSel[0].insertBefore(defsEl, svgSel[0].firstChild);\n\t    //defsEl.setAttribute(\"class\", \"cv-bootstrap\");\n\t    var styleEl = document.createElement(\"style\")\n\t    defsEl.appendChild(styleEl);\n\t    styleEl.setAttribute(\"type\", \"text/css\");\n\n\t\tvar source = (new XMLSerializer()).serializeToString(svgSel.get(0));\n\t\tsource = source.replace('</style>', '<![CDATA[' + styles + ']]></style>')\n\n\t\t// Create a file blob of our SVG.\n\t\tvar blob = new Blob([doctype + source], { type: 'image/svg+xml;charset=utf-8' });\n\n\t\tvar url = window.URL.createObjectURL(blob);\n\n\t\t// Put the svg into an image tag so that the Canvas element can read it in.\n\t\tvar img = d3.select('body').append('img').attr('visibility', 'hidden').attr('width', svgSel.width()).attr('height', svgSel.height()).node();\n\n\t\timg.onload = function() {\n\t\t  // Now that the image has loaded, put the image into a canvas element.\n\t\t  var canvas = d3.select('body').append('canvas').node();\n\t\t  $(canvas).addClass(\"cv-bootstrap\");\n\t\t  $(canvas).attr('visibility', 'hidden');\n\t\t  canvas.width = svgSel.width();\n\t\t  canvas.height = svgSel.height();\n\t\t  var ctx = canvas.getContext('2d');\n\t\t  ctx.drawImage(img, 0, 0, svgSel.width(), svgSel.height());\n\t\t  var canvasUrl = canvas.toDataURL(\"image/png\");\n\n\t\t  $(img).remove();\n\t\t  $(canvas).remove();\n\n\t\t  // As per issue #93 and https://stackoverflow.com/questions/17332071/trying-to-save-canvas-png-data-url-to-disk-with-html5-filesystem-but-when-i-ret\n\t\t  var data = atob( canvasUrl.substring( \"data:image/png;base64,\".length ) ), asArray = new Uint8Array(data.length);\n\t\t  for( var i = 0, len = data.length; i < len; ++i ) {asArray[i] = data.charCodeAt(i);}\n\t\t  var blob = new Blob( [ asArray.buffer ], {type: \"image/png\"} );\n\n\t\t  exportService.saveAs(blob, \"image/png\", $scope.view.cube.name + \"-\" + $scope.view.params.charttype + \".png\");\n\t\t}\n\t\t// start loading the image.\n\t\timg.src = url;\n\t};\n\n\n\t$scope.$on(\"$destroy\", function() {\n\t\tchartCtrl.cleanupNvd3();\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t});\n\n\tthis.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/cube-menu-drilldown.html",
    "content": "  <button class=\"btn btn-primary btn-sm dropdown-toggle drilldownbutton\" ng-disabled=\"view.params.mode == 'facts'\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n    <i class=\"fa fa-fw fa-arrow-down\"></i> <span class=\"hidden-xs\" ng-class=\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\">Drilldown</span> <span class=\"caret\"></span>\n  </button>\n\n  <ul class=\"dropdown-menu dropdown-menu-right cv-view-menu-drilldown\">\n\n      <!-- if ((grayout_drill) && ((($.grep(view.params.drilldown, function(ed) { return ed == dimension.name; })).length > 0))) { -->\n      <li on-repeat-done ng-repeat-start=\"dimension in view.cube.dimensions\" ng-if=\"dimension.levels.length == 1\" ng-click=\"selectDrill(dimension.name, true);\">\n        <a href=\"\">{{ dimension.label }}</a>\n      </li>\n      <li ng-repeat-end ng-if=\"dimension.levels.length != 1\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\">{{ dimension.label }}</a>\n\n        <ul ng-if=\"dimension.hierarchies_count() != 1\" class=\"dropdown-menu\">\n            <li ng-repeat=\"(hikey,hi) in dimension.hierarchies\" class=\"dropdown-submenu\">\n                <a tabindex=\"0\" href=\"\" onclick=\"return false;\">{{ hi.label }}</a>\n                <ul class=\"dropdown-menu\">\n                    <li ng-repeat=\"level in hi.levels\" ng-click=\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\"><a href=\"\">{{ level.label }}</a></li>\n                </ul>\n            </li>\n        </ul>\n\n        <ul ng-if=\"dimension.hierarchies_count() == 1\" class=\"dropdown-menu\">\n            <li ng-repeat=\"level in dimension.default_hierarchy().levels\" ng-click=\"selectDrill(dimension.name + '@' + dimension.default_hierarchy().name + ':' + level.name, true)\"><a href=\"\">{{ level.label }}</a></li>\n        </ul>\n\n      </li>\n\n      <div class=\"divider\"></div>\n\n      <li ng-class=\"{ 'disabled': view.params.drilldown.length == 0 }\" ng-click=\"selectDrill('')\"><a href=\"\"><i class=\"fa fa-fw fa-close\"></i> None</a></li>\n\n  </ul>\n\n"
  },
  {
    "path": "cubesviewer/views/cube/cube-menu-filter.html",
    "content": "  <button class=\"btn btn-primary btn-sm dropdown-toggle cutbutton\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n    <i class=\"fa fa-fw fa-filter\"></i> <span class=\"hidden-xs\" ng-class=\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\">Filter</span> <span class=\"caret\"></span>\n  </button>\n\n  <ul class=\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-cut\">\n\n    <li ng-show=\"view.params.mode == 'explore'\" ng-click=\"filterSelected()\" ng-class=\"{ 'disabled': view.params.drilldown.length != 1 }\"><a href=\"\"><i class=\"fa fa-fw fa-filter\"></i> Filter selected rows</a></li>\n    <div ng-show=\"view.params.mode == 'explore'\" class=\"divider\"></div>\n\n    <li class=\"dropdown-submenu\">\n        <a tabindex=\"0\"><i class=\"fa fa-fw fa-bars\"></i> Dimension filter</a>\n        <ul class=\"dropdown-menu\">\n\n          <li on-repeat-done ng-repeat-start=\"dimension in view.cube.dimensions\" ng-if=\"dimension.levels.length == 1\" ng-click=\"showDimensionFilter(dimension.name);\">\n            <a href=\"\">{{ dimension.label }}</a>\n          </li>\n          <li ng-repeat-end ng-if=\"dimension.levels.length != 1\" class=\"dropdown-submenu\">\n            <a tabindex=\"0\">{{ dimension.label }}</a>\n\n            <ul ng-if=\"dimension.hierarchies_count() != 1\" class=\"dropdown-menu\">\n                <li ng-repeat=\"(hikey,hi) in dimension.hierarchies\" class=\"dropdown-submenu\">\n                    <a tabindex=\"0\" href=\"\" onclick=\"return false;\">{{ hi.label }}</a>\n                    <ul class=\"dropdown-menu\">\n                        <!-- ng-click=\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\"  -->\n                        <li ng-repeat=\"level in hi.levels\" ng-click=\"showDimensionFilter(dimension.name + '@' + hi.name + ':' + level.name )\"><a href=\"\">{{ level.label }}</a></li>\n                    </ul>\n                </li>\n            </ul>\n\n            <ul ng-if=\"dimension.hierarchies_count() == 1\" class=\"dropdown-menu\">\n                <!--  selectDrill(dimension.name + ':' + level.name, true) -->\n                <li ng-repeat=\"level in dimension.default_hierarchy().levels\" ng-click=\"showDimensionFilter(dimension.name + '@' + dimension.default_hierarchy().name + ':' + level.name);\"><a href=\"\">{{ level.label }}</a></li>\n            </ul>\n\n          </li>\n\n        </ul>\n    </li>\n\n    <li class=\"dropdown-submenu\">\n        <a tabindex=\"0\"><i class=\"fa fa-fw fa-calendar\"></i> Date filter</a>\n        <ul class=\"dropdown-menu\">\n          <li ng-repeat=\"dimension in view.cube.dimensions\" ng-if=\"dimension.isDateDimension()\">\n            <a href=\"\" ng-click=\"selectDateFilter(dimension.name + ((dimension.info['cv-datefilter-hierarchy']) ? '@' + dimension.info['cv-datefilter-hierarchy'] : ''), true)\">\n                {{ dimension.label + ((dimension.hierarchy(dimension.info[\"cv-datefilter-hierarchy\"])) ? \" / \" + dimension.hierarchy(dimension.info[\"cv-datefilter-hierarchy\"]).label : \"\") }}\n            </a>\n          </li>\n          <li ng-if=\"view.cube.dateDimensions().length == 0\" class=\"disabled\">\n            <a href=\"\" ng-click=\"\"><i>No date filters defined for this cube.</i></a>\n          </li>\n\n        </ul>\n    </li>\n\n    <!--\n    <li class=\"dropdown-submenu\">\n        <a tabindex=\"0\"><i class=\"fa fa-fw fa-arrows-h\"></i> Range filter</a>\n        <ul class=\"dropdown-menu\">\n\n          <li on-repeat-done ng-repeat-start=\"dimension in view.cube.dimensions\" ng-if=\"dimension.levels.length == 1\" ng-click=\"showDimensionFilter(dimension.name);\">\n            <a href=\"\">{{ dimension.label }}</a>\n          </li>\n          <li ng-repeat-end ng-if=\"dimension.levels.length != 1\" class=\"dropdown-submenu\">\n            <a tabindex=\"0\">{{ dimension.label }}</a>\n\n            <ul ng-if=\"dimension.hierarchies_count() != 1\" class=\"dropdown-menu\">\n                <li ng-repeat=\"(hikey,hi) in dimension.hierarchies\" class=\"dropdown-submenu\">\n                    <a tabindex=\"0\" href=\"\" onclick=\"return false;\">{{ hi.label }}</a>\n                    <ul class=\"dropdown-menu\">\n                        <li ng-repeat=\"level in hi.levels\" ng-click=\"showDimensionFilter(dimension.name + '@' + hi.name + ':' + level.name )\"><a href=\"\">{{ level.label }}</a></li>\n                    </ul>\n                </li>\n            </ul>\n\n            <ul ng-if=\"dimension.hierarchies_count() == 1\" class=\"dropdown-menu\">\n                <li ng-repeat=\"level in dimension.default_hierarchy().levels\" ng-click=\"showDimensionFilter(level);\"><a href=\"\">{{ level.label }}</a></li>\n            </ul>\n\n          </li>\n\n        </ul>\n    </li>\n     -->\n\n    <div class=\"divider\"></div>\n\n    <li ng-class=\"{ 'disabled': view.params.cuts.length == 0 && view.params.datefilters.length == 0 }\" ng-click=\"clearFilters()\"><a href=\"\"><i class=\"fa fa-fw fa-trash\"></i> Clear filters</a></li>\n\n  </ul>\n"
  },
  {
    "path": "cubesviewer/views/cube/cube-menu-panel.html",
    "content": "  <button class=\"btn btn-primary btn-sm dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n    <i class=\"fa fa-fw fa-file\"></i> <span class=\"hidden-xs\" ng-class=\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\">Panel</span> <span class=\"caret\"></span>\n  </button>\n\n  <ul class=\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-view\">\n\n    <li ng-click=\"viewsService.studioViewsService.studioScope.showRenameView(view)\"><a><i class=\"fa fa-fw fa-pencil\"></i> Rename...</a></li>\n    <li ng-click=\"viewsService.studioViewsService.studioScope.cloneView(view)\"><a><i class=\"fa fa-fw fa-clone\"></i> Clone</a></li>\n\n    <div ng-if=\"cvOptions.backendUrl\" class=\"divider\"></div>\n    <li ng-if=\"cvOptions.backendUrl\" ng-click=\"reststoreService.saveView(view)\"><a><i class=\"fa fa-fw fa-save\"></i> Save</a></li>\n    <li ng-if=\"cvOptions.backendUrl\" ng-click=\"reststoreService.shareView(view, ! view.shared)\"><a><i class=\"fa fa-fw fa-share\"></i> {{ view.shared ? \"Unshare\" : \"Share\" }}</a></li>\n    <li ng-if=\"cvOptions.backendUrl\" ng-click=\"reststoreService.deleteView(view)\"><a><i class=\"fa fa-fw fa-trash-o\"></i> Delete...</a></li>\n\n    <div class=\"divider\"></div>\n    <li ng-click=\"viewsService.studioViewsService.studioScope.showSerializeView(view)\"><a><i class=\"fa fa-fw fa-code\"></i> Serialize...</a></li>\n    <div class=\"divider\"></div>\n    <li ng-click=\"viewsService.studioViewsService.closeView(view)\"><a><i class=\"fa fa-fw fa-close\"></i> Close</a></li>\n  </ul>\n"
  },
  {
    "path": "cubesviewer/views/cube/cube-menu-view.html",
    "content": "  <button class=\"btn btn-primary btn-sm dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n    <i class=\"fa fa-fw fa-cogs\"></i> <span class=\"hidden-xs\" ng-class=\"{ 'hidden-sm hidden-md': cvOptions.studioTwoColumn }\">View</span> <span class=\"caret\"></span>\n  </button>\n\n  <ul class=\"dropdown-menu dropdown-menu-right cv-view-menu cv-view-menu-view\">\n\n    <li ng-show=\"view.params.mode == 'chart'\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\" ><i class=\"fa fa-fw fa-area-chart\"></i> Chart type</a>\n        <ul class=\"dropdown-menu\">\n          <li ng-click=\"selectChartType('pie')\"><a href=\"\"><i class=\"fa fa-fw fa-pie-chart\"></i> Pie</a></li>\n          <li ng-click=\"selectChartType('bars-vertical')\"><a href=\"\"><i class=\"fa fa-fw fa-bar-chart\"></i> Bars Vertical</a></li>\n          <li ng-click=\"selectChartType('bars-horizontal')\"><a href=\"\"><i class=\"fa fa-fw fa-rotate-270 fa-bar-chart\"></i> Bars Horizontal</a></li>\n          <li ng-click=\"selectChartType('lines')\"><a href=\"\"><i class=\"fa fa-fw fa-line-chart\"></i> Lines</a></li>\n          <li ng-click=\"selectChartType('lines-stacked')\"><a href=\"\"><i class=\"fa fa-fw fa-area-chart\"></i> Areas</a></li>\n          <li ng-click=\"selectChartType('radar')\"><a href=\"\"><i class=\"fa fa-fw fa-bullseye\"></i> Radar</a></li>\n\n          <!-- <div class=\"divider\"></div>  -->\n\n          <!--\n          <li><a href=\"\"><i class=\"fa fa-fw fa-dot-circle-o\"></i> Bubbles</a></li>\n          <li><a href=\"\"><i class=\"fa fa-fw fa-square\"></i> Treemap</a></li>\n          <li ng-click=\"selectChartType('sunburst')\"><a href=\"\"><i class=\"fa fa-fw fa-sun-o\"></i> Sunburst</a></li>\n          -->\n\n          <!--\n          <div class=\"divider\"></div>\n\n          <li><a href=\"\"><i class=\"fa fa-fw fa-globe\"></i> Map</a></li>\n           -->\n\n        </ul>\n    </li>\n\n    <!--\n    <li ng-show=\"view.params.mode == 'chart' && (view.params.charttype == 'lines-stacked' || view.params.charttype == 'lines' || view.params.charttype == 'bars-horizontal')\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\" ><i class=\"fa fa-fw fa-sliders\"></i> Chart options</a>\n        <ul class=\"dropdown-menu\">\n    -->\n        <li class=\"dropdown-submenu\" ng-show=\"view.params.mode == 'chart' && (view.params.charttype == 'lines-stacked' || view.params.charttype == 'lines')\">\n            <a href=\"\"><i class=\"fa fa-fw fa-angle-up\"></i> Curve type</a>\n            <ul class=\"dropdown-menu\">\n                <li ng-class=\"{'active': view.params.chartoptions.lineInterpolation == 'linear'}\" ng-click=\"view.params.chartoptions.lineInterpolation = 'linear'; refreshView();\"><a href=\"\"> Linear</a></li>\n                <li ng-class=\"{'active': view.params.chartoptions.lineInterpolation == 'monotone'}\" ng-click=\"view.params.chartoptions.lineInterpolation = 'monotone'; refreshView();\"><a href=\"\"> Smooth</a></li>\n                <!-- <li ng-class=\"{'active': view.params.chartoptions.lineInterpolation == 'cardinal'}\" ng-click=\"view.params.chartoptions.lineInterpolation = 'cardinal'; refreshView();\"><a href=\"\"> Smooth (Cardinal)</a></li>  -->\n            </ul>\n        </li>\n\n        <li ng-class=\"{'disabled': view.grid.data.length != 2 }\" ng-show=\"view.params.mode == 'chart' && view.params.charttype == 'bars-horizontal'\" ng-click=\"view.params.chartoptions.mirrorSerie2 = !view.params.chartoptions.mirrorSerie2; refreshView();\">\n            <a><i class=\"fa fa-fw fa-arrows-h\"></i> Invert 2nd series\n                <span style=\"margin-left: 5px;\" class=\"label label-default\" ng-class=\"{ 'label-success': view.params.chartoptions.mirrorSerie2 }\">{{ view.params.chartoptions.mirrorSerie2 ? \"ON\" : \"OFF\" }}</span>\n            </a>\n        </li>\n\n    <!--\n        </ul>\n    </li>\n     -->\n\n    <li ng-show=\"view.params.mode == 'chart'\" ng-click=\"view.params.chartoptions.showLegend = !view.params.chartoptions.showLegend; refreshView();\">\n        <a><i class=\"fa fa-fw\" ng-class=\"{'fa-toggle-on': view.params.chartoptions.showLegend, 'fa-toggle-off': ! view.params.chartoptions.showLegend }\"></i> Toggle legend\n            <span style=\"margin-left: 5px;\" class=\"label label-default\" ng-class=\"{ 'label-success': view.params.chartoptions.showLegend }\">{{ view.params.chartoptions.showLegend ? \"ON\" : \"OFF\" }}</span>\n        </a>\n    </li>\n\n    <div ng-show=\"view.params.mode == 'chart'\" class=\"divider\"></div>\n\n    <li ng-show=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\"><i class=\"fa fa-fw fa-long-arrow-right\"></i> Horizontal dimension</a>\n        <ul class=\"dropdown-menu\">\n\n          <li on-repeat-done ng-repeat-start=\"dimension in view.cube.dimensions\" ng-if=\"dimension.levels.length == 1\" ng-click=\"selectXAxis(dimension.name)\">\n            <a href=\"\">{{ dimension.label }}</a>\n          </li>\n          <li ng-repeat-end ng-if=\"dimension.levels.length != 1\" class=\"dropdown-submenu\">\n            <a tabindex=\"0\">{{ dimension.label }}</a>\n\n            <ul ng-if=\"dimension.hierarchies_count() != 1\" class=\"dropdown-menu\">\n                <li ng-repeat=\"(hikey,hi) in dimension.hierarchies\" class=\"dropdown-submenu\">\n                    <a tabindex=\"0\" href=\"\" onclick=\"return false;\">{{ hi.label }}</a>\n                    <ul class=\"dropdown-menu\">\n                        <!-- ng-click=\"selectDrill(dimension.name + '@' + hi.name + ':' + level.name, true)\"  -->\n                        <li ng-repeat=\"level in hi.levels\" ng-click=\"selectXAxis(dimension.name + '@' + hi.name + ':' + level.name )\"><a href=\"\">{{ level.label }}</a></li>\n                    </ul>\n                </li>\n            </ul>\n\n            <ul ng-if=\"dimension.hierarchies_count() == 1\" class=\"dropdown-menu\">\n                <!--  selectDrill(dimension.name + ':' + level.name, true) -->\n                <li ng-repeat=\"level in dimension.default_hierarchy().levels\" ng-click=\"selectXAxis(dimension.name + ':' + level.name);\"><a href=\"\">{{ level.label }}</a></li>\n            </ul>\n\n          </li>\n\n          <div class=\"divider\"></div>\n\n          <li ng-click=\"selectXAxis(null);\"><a href=\"\"><i class=\"fa fa-fw fa-close\"></i> None</a></li>\n\n        </ul>\n    </li>\n\n    <li ng-show=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\"><i class=\"fa fa-fw fa-crosshairs\"></i> Measure</a>\n        <ul class=\"dropdown-menu\">\n\n          <li ng-repeat=\"measure in view.cube.measures\" ng-if=\"view.cube.measureAggregates(measure.name).length > 0\" class=\"dropdown-submenu\">\n            <a href=\"\">{{ measure.label }}</a>\n            <ul class=\"dropdown-menu\">\n                <li ng-repeat=\"aggregate in view.cube.measureAggregates(measure.name)\" >\n                    <a href=\"\" ng-click=\"selectMeasure(aggregate.ref)\">{{ aggregate.label }}</a>\n                </li>\n            </ul>\n          </li>\n\n          <div class=\"divider\" ng-if=\"view.cube.measureAggregates(null).length > 0\"></div>\n          <li ng-repeat=\"aggregate in view.cube.measureAggregates(null)\" ng-if=\"view.cube.measureAggregates(null).length > 0\" >\n            <a href=\"\" ng-click=\"selectMeasure(aggregate.ref)\">{{ aggregate.label }}</a>\n          </li>\n\n        </ul>\n    </li>\n\n    <div ng-show=\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\" class=\"divider\"></div>\n\n    <li ng-show=\"cvOptions.seriesOperationsEnabled && (view.params.mode == 'series' || view.params.mode == 'chart')\" class=\"dropdown-submenu\">\n        <a tabindex=\"0\" ><i class=\"fa fa-fw fa-calculator\"></i> Series operations</a>\n        <ul class=\"dropdown-menu\">\n          <li ng-click=\"selectOperation('difference')\"><a href=\"\"><i class=\"fa fa-fw fa-line-chart\"></i> Difference</a></li>\n          <li ng-click=\"selectOperation('percentage')\"><a href=\"\"><i class=\"fa fa-fw fa-percent\"></i> Change rate</a></li>\n          <!--\n          <li ng-click=\"selectOperation('accum')\"><a href=\"\"><i class=\"fa fa-fw\">&sum;</i> Accumulated</a></li>\n          <div class=\"divider\"></div>\n          <li ng-click=\"selectOperation('fill-zeros')\"><a href=\"\"><i class=\"fa fa-fw\">0</i> Replace blanks with zeroes</a></li>\n           -->\n          <div class=\"divider\"></div>\n          <li ng-click=\"selectOperation(null)\"><a href=\"\"><i class=\"fa fa-fw fa-times\"></i> Clear operations</a></li>\n        </ul>\n    </li>\n\n    <div ng-show=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"divider\"></div>\n\n    <li ng-show=\"view.params.mode != 'chart'\" ng-click=\"exportService.exportGridAsCsv(view)\"><a><i class=\"fa fa-fw fa-table\"></i> Export table</a></li>\n    <li ng-show=\"view.params.mode == 'chart' && view.params.charttype != 'radar' \" ng-click=\"view.exportChartAsPNG()\"><a><i class=\"fa fa-fw fa-picture-o\"></i> Export figure</a></li>\n    <li ng-click=\"exportService.exportFacts(view)\"><a><i class=\"fa fa-fw fa-th\"></i> Export facts</a></li>\n\n  </ul>\n\n"
  },
  {
    "path": "cubesviewer/views/cube/cube.html",
    "content": "<div class=\"cv-view-panel\" ng-controller=\"CubesViewerViewsCubeController as cubeView\" >\n\n    <div ng-if=\"view.state == 3\">\n        <div class=\"alert alert-danger\" style=\"margin: 0px;\">\n            <p>An error occurred. Cannot present view.</p>\n            <p ng-if=\"cubesService.state != 3\">{{ view.error }}</p>\n            <p ng-if=\"cubesService.state == 3\">Could not connect to data server: {{ cubesService.stateText }}</p>\n            <p>Please try again and contact your administrator if the problem persists.</p>\n            <p class=\"text-right\">\n                <a class=\"alert-link\" href=\"http://jjmontesl.github.io/cubesviewer/\" target=\"_blank\">CubesViewer Data Visualizer</a>\n            </p>\n        </div>\n    </div>\n\n    <div>\n        <h2 ng-show=\"view.getControlsHidden()\" style=\"margin-top: 5px;\">\n            <i class=\"fa fa-fw fa-file-o\"></i> {{ view.params.name }}\n        </h2>\n\n        <div ng-include=\"'views/cube/alerts.html'\"></div>\n    </div>\n\n    <div ng-if=\"view.state == 2\" style=\"min-height: 80px;\">\n\n        <div class=\"cv-view-viewmenu hidden-print\" ng-hide=\"view.getControlsHidden()\">\n\n            <div class=\"panel panel-primary pull-right\" style=\"padding: 3px; white-space: nowrap; margin-bottom: 6px; margin-left: 6px;\">\n\n                <div ng-if=\"cvOptions.undoEnabled\" class=\"btn-group\" role=\"group\" ng-controller=\"CubesViewerViewsUndoController\">\n                  <button type=\"button\" ng-click=\"undo()\" ng-disabled=\"view.undoPos <= 0\" class=\"btn btn-default btn-sm\" title=\"Undo\"><i class=\"fa fa-fw fa-undo\"></i></button>\n                  <button type=\"button\" ng-click=\"redo()\" ng-disabled=\"view.undoPos >= view.undoList.length - 1\" class=\"btn btn-default btn-sm\" title=\"Redo\"><i class=\"fa fa-fw fa-undo fa-flip-horizontal\"></i></button>\n                </div>\n\n                <div class=\"btn-group\" role=\"group\" aria-label=\"...\" style=\"margin-left: 5px;\">\n                  <button type=\"button\" ng-click=\"setViewMode('explore')\" ng-class=\"{'active': view.params.mode == 'explore'}\" class=\"btn btn-primary btn-sm explorebutton\" title=\"Explore\"><i class=\"fa fa-fw fa-arrow-circle-down\"></i></button>\n                  <button type=\"button\" ng-click=\"setViewMode('facts')\" ng-class=\"{'active': view.params.mode == 'facts'}\" class=\"btn btn-primary btn-sm \" title=\"Facts\"><i class=\"fa fa-fw fa-th\"></i></button>\n                  <button type=\"button\" ng-click=\"setViewMode('series')\" ng-class=\"{'active': view.params.mode == 'series'}\" class=\"btn btn-primary btn-sm \" title=\"Series\"><i class=\"fa fa-fw fa-clock-o\"></i></button>\n                  <button type=\"button\" ng-click=\"setViewMode('chart')\" ng-class=\"{'active': view.params.mode == 'chart'}\" class=\"btn btn-primary btn-sm \" title=\"Charts\"><i class=\"fa fa-fw fa-area-chart\"></i></button>\n                </div>\n\n                <div ng-include=\"'views/cube/cube-menu-drilldown.html'\" class=\"dropdown m-b\" style=\"display: inline-block; margin-left: 5px;\"></div>\n\n                <div ng-include=\"'views/cube/cube-menu-filter.html'\" class=\"dropdown m-b\" style=\"display: inline-block; margin-left: 2px;\"></div>\n\n                <div ng-include=\"'views/cube/cube-menu-view.html'\" class=\"dropdown m-b\" style=\"display: inline-block; margin-left: 5px;\"></div>\n\n                <div ng-if=\"cvOptions.container\" ng-include=\"'views/cube/cube-menu-panel.html'\" class=\"dropdown m-b\" style=\"display: inline-block; margin-left: 5px;\"></div>\n\n            </div>\n\n            <div class=\"pull-right\" style=\"white-space: nowrap; padding-top: 4px; padding-bottom: 4px; margin-left: 6px; margin-bottom: 6px;\">\n\n            </div>\n\n        </div>\n\n        <div class=\"cv-view-viewinfo\">\n            <div>\n                <div class=\"label label-secondary cv-infopiece cv-view-viewinfo-cubename\" style=\"color: white; background-color: black;\">\n                    <span><i class=\"fa fa-fw fa-cube\" title=\"Cube\"></i> <b class=\"hidden-xs hidden-sm\">Cube:</b> {{ view.cube.label }}</span>\n                    <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden;\"><i class=\"fa fa-fw fa-info\"></i></button>\n                </div>\n\n                <div class=\"cv-view-viewinfo-drill\">\n\n\n                    <div ng-repeat=\"drilldown in view.params.drilldown\" ng-init=\"parts = view.cube.dimensionParts(drilldown);\" ng-if=\"view.params.mode != 'facts'\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-drill\" style=\"color: black; background-color: #ccffcc;\">\n                        <span><i class=\"fa fa-fw fa-arrow-down\" title=\"Drilldown\"></i> <b class=\"hidden-xs hidden-sm\">Drilldown:</b> <span title=\"{{ view.cube.dimensionParts(drilldown).label }}\">{{ parts.labelShort }}</span></span>\n                        <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n\n                        <button ng-hide=\"view.getControlsHidden() || parts.hierarchy.levels.length < 2\" ng-disabled=\"! parts.drilldownDimensionMinus\" type=\"button\" ng-click=\"selectDrill(parts.drilldownDimensionMinus, true)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 3px;\"><i class=\"fa fa-fw fa-minus\"></i></button>\n                        <button ng-hide=\"view.getControlsHidden() || parts.hierarchy.levels.length < 2\" ng-disabled=\"! parts.drilldownDimensionPlus\" type=\"button\" ng-click=\"selectDrill(parts.drilldownDimensionPlus, true)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 0px;\"><i class=\"fa fa-fw fa-plus\"></i></button>\n\n                        <button ng-hide=\"view.getControlsHidden()\" type=\"button\" ng-click=\"showDimensionFilter(drilldown)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 3px;\"><i class=\"fa fa-fw fa-search\"></i></button>\n                        <button ng-hide=\"view.getControlsHidden()\" type=\"button\" ng-click=\"selectDrill(drilldown, '')\" class=\"btn btn-danger btn-xs hidden-print\" style=\"margin-left: 1px;\"><i class=\"fa fa-fw fa-trash\"></i></button>\n                    </div>\n\n                </div>\n                <div class=\"cv-view-viewinfo-cut\">\n                    <!--\n                        var dimensionString = $(this).parents('.cv-view-infopiece-cut').first().attr('data-dimension');\n                        var parts = view.cube.dimensionParts(dimensionString);\n                        var depth = $(this).parents('.cv-view-infopiece-cut').first().attr('data-value').split(';')[0].split(\",\").length;\n                        cubesviewer.views.cube.dimensionfilter.drawDimensionFilter(view, dimensionString + \":\" + parts.hierarchy.levels[depth - 1] );\n                     -->\n                    <div ng-repeat=\"cut in view.params.cuts\" ng-init=\"equality = cut.invert ? ' &ne; ' : ' = ';\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-cut\" style=\"color: black; background-color: #ffcccc;\">\n                        <span style=\"max-width: 480px;\"><i class=\"fa fa-fw fa-filter\" title=\"Filter\"></i> <b class=\"hidden-xs hidden-sm\">Filter:</b> <span title=\"{{ view.cube.dimensionPartsFromCut(cut).label }}\">{{ view.cube.dimensionPartsFromCut(cut).labelShort }}</span> <span ng-class=\"{ 'text-danger': cut.invert }\">{{ equality }}</span> <span title=\"{{ cut.value }}\">{{ cut.value }}</span></span>\n                        <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n                        <button ng-hide=\"view.getControlsHidden()\" type=\"button\" ng-click=\"showDimensionFilter(view.cube.dimensionPartsFromCut(cut).drilldownDimension)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 3px;\"><i class=\"fa fa-fw fa-search\"></i></button>\n                        <button ng-hide=\"view.getControlsHidden()\" type=\"button\" ng-click=\"selectCut(cut.dimension, '', cut.invert)\" class=\"btn btn-danger btn-xs hidden-print\" style=\"margin-left: 1px;\"><i class=\"fa fa-fw fa-trash\"></i></button>\n                    </div>\n                </div>\n\n                <div ng-include=\"'views/cube/filter/datefilter.html'\"></div>\n\n                <div class=\"cv-view-viewinfo-extra\">\n\n                    <div ng-if=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-extra\" style=\"color: black; background-color: #ccccff;\">\n                        <span style=\"max-width: 350px;\"><i class=\"fa fa-fw fa-crosshairs\" title=\"Measure\"></i> <b class=\"hidden-xs hidden-sm\">Measure:</b> {{ (view.params.yaxis != null) ? view.cube.aggregateFromName(view.params.yaxis).label : \"None\" }}</span>\n                        <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n                    </div>\n\n                    <div ng-if=\"view.params.mode == 'series' || view.params.mode == 'chart'\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-extra\" style=\"color: black; background-color: #ccddff;\">\n                        <span style=\"max-width: 350px;\"><i class=\"fa fa-fw fa-long-arrow-right\" title=\"Horizontal dimension\"></i> <b class=\"hidden-xs hidden-sm\">Horizontal dimension:</b> {{ (view.params.xaxis != null) ? view.cube.dimensionParts(view.params.xaxis).labelShort : \"None\" }}</span>\n                        <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n\n                        <button ng-hide=\"view.getControlsHidden() || !view.params.xaxis || view.cube.dimensionParts(view.params.xaxis).hierarchy.levels.length < 2\" ng-disabled=\"! view.cube.dimensionParts(view.params.xaxis).drilldownDimensionMinus\" type=\"button\" ng-click=\"selectXAxis(view.cube.dimensionParts(view.params.xaxis).drilldownDimensionMinus, true)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 3px;\"><i class=\"fa fa-fw fa-minus\"></i></button>\n                        <button ng-hide=\"view.getControlsHidden() || !view.params.xaxis || view.cube.dimensionParts(view.params.xaxis).hierarchy.levels.length < 2\" ng-disabled=\"! view.cube.dimensionParts(view.params.xaxis).drilldownDimensionPlus\" type=\"button\" ng-click=\"selectXAxis(view.cube.dimensionParts(view.params.xaxis).drilldownDimensionPlus, true)\" class=\"btn btn-secondary btn-xs hidden-print\" style=\"margin-left: 0px;\"><i class=\"fa fa-fw fa-plus\"></i></button>\n\n                        <!-- <button type=\"button\" ng-click=\"showDimensionFilter(view.params.xaxis)\" class=\"btn btn-secondary btn-xs\" style=\"margin-left: 3px;\"><i class=\"fa fa-fw fa-search\"></i></button>  -->\n                        <!-- <button type=\"button\" ng-click=\"selectXAxis(null)\" class=\"btn btn-danger btn-xs\" style=\"margin-left: 1px;\"><i class=\"fa fa-fw fa-trash\"></i></button>  -->\n                    </div>\n\n                </div>\n            </div>\n        </div>\n        <div class=\"clearfix\"></div>\n\n        <div class=\"cv-view-viewdialogs\">\n            <div ng-if=\"view.dimensionFilter\" ng-include=\"'views/cube/filter/dimension.html'\"></div>\n        </div>\n\n        <div class=\"cv-view-viewdata\">\n\n            <div ng-if=\"view.params.mode == 'explore'\" ng-include=\"'views/cube/explore/explore.html'\"></div>\n            <div ng-if=\"view.params.mode == 'facts'\" ng-include=\"'views/cube/facts/facts.html'\"></div>\n            <div ng-if=\"view.params.mode == 'series'\" ng-include=\"'views/cube/series/series.html'\"></div>\n            <div ng-if=\"view.params.mode == 'chart'\" ng-include=\"'views/cube/chart/chart.html'\"></div>\n\n        </div>\n        <div class=\"clearfix\"></div>\n\n        <div class=\"cv-view-viewfooter\"></div>\n\n    </div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/cube.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\"use strict\";\n\n/**\n * The CubeView class represents a view of type `cube`.\n *\n * @param cvOptions The cv options object.\n * @param id The numeric id of the view to be created.\n * @param type The view type (ie. 'cube').\n * @returns The new view object.\n *\n * @namespace cubesviewer\n */\ncubesviewer.CubeView = function(cvOptions, id, type) {\n\n\tvar view = cubesviewer.View(cvOptions, id, type);\n\n\tview.resultLimitHit = false;\n\tview.requestFailed = false;\n\tview.pendingRequests = 0;\n\tview.dimensionFilter = null;\n\n\tview._invalidatedData = true;\n\tview._invalidatedDefs = true;\n\n\tview.grid = {\n\t\tapi: null,\n\t\tdata: [],\n\t\tcolumnDefs: []\n\t};\n\n\tview.invalidateData = function() {\n\t\tview._invalidatedData = true;\n\t};\n\n\tview.invalidateDefs = function() {\n\t\tview._invalidatedData = true;\n\t\tview._invalidatedDefs = true;\n\t};\n\n\tview.setViewMode = function(mode) {\n\t\tview.params.mode = mode;\n\t\tview.invalidateDefs();\n\t};\n\n\treturn view;\n\n};\n\n\n/**\n * CubesViewer view module.\n *\n * @namespace cv.views.cube\n */\nangular.module('cv.views.cube', []);\n\n\n/**\n * cvViewCube directive and controller.\n *\n * FIXME: Some of this code shall be on a parent generic \"view\" directive.\n */\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeController\", ['$rootScope', '$log', '$window','$injector', '$scope', '$timeout', 'cvOptions', 'cubesService', 'viewsService', 'exportService', 'rowSorter', 'dialogService',\n                                                                               function ($rootScope, $log, $window, $injector, $scope, $timeout, cvOptions, cubesService, viewsService, exportService, rowSorter, dialogService) {\n\n\t// TODO: Functions shall be here?\n\t$scope.viewController = {};\n\n\t$scope.$rootScope = $rootScope;\n\t$scope.viewsService = viewsService;\n\t$scope.cvOptions = cvOptions;\n\t$scope.cubesService = cubesService;\n\t$scope.exportService = exportService;\n\n\t$scope.reststoreService = null;\n\n    if ($injector.has('reststoreService')) {\n        $scope.reststoreService = $injector.get('reststoreService');\n    }\n\n\n    $scope.refreshView = function() {\n    \tif ($scope.view && $scope.view.cube) {\n\t\t\t//$scope.view.grid.data = [];\n\t\t\t//$scope.view.grid.columnDefs = [];\n\t\t\t$scope.$broadcast(\"ViewRefresh\", $scope.view);\n\t\t}\n\t};\n\n\t$scope.setViewMode = function(mode) {\n\t\tconsole.debug(\"Remove setViewMode call on the controller?\")\n\t\t$scope.view.setViewMode(mode);\n\t};\n\n\n\t$scope.initCube = function() {\n\n\t\t$scope.view.cube = null;\n\n\t\t// Apply default cube view parameters\n\t\tvar cubeViewDefaultParams = {\n\t\t\t\"mode\" : \"explore\",\n\t\t\t\"drilldown\" : [],\n\t\t\t\"cuts\" : [],\n\n\t\t\t\"datefilters\": [],\n\n\t\t\t\"columnHide\": {},\n\t\t\t\"columnWidths\": {},\n\t\t\t\"columnSort\": {},\n\t\t};\n\n\t\tvar jqxhr = cubesService.cubesserver.get_cube($scope.view.params.cubename, function(cube) {\n\n\t\t\t$scope.view.cube = cube;\n\n\t\t\t$log.debug($scope.view.cube);\n\n\t\t\t// Apply parameters if cube metadata contains specific cv-view-params\n\t\t\t// TODO: Don't do this if this was a saved or pre-initialized view, only for new views\n\t\t\tif ('cv-view-params' in $scope.view.cube.info) {\n\t\t\t\t$scope.view.params = $.extend({}, cubeViewDefaultParams, $scope.view.cube.info['cv-view-params'], $scope.view.params);\n\t\t\t} else {\n\t\t\t\t$scope.view.params = $.extend({}, cubeViewDefaultParams, $scope.view.params);\n\t\t\t}\n\n\t\t\t$scope.view.state = cubesviewer.VIEW_STATE_INITIALIZED;\n\t\t\t$scope.view.error = \"\";\n\n\t\t\t$rootScope.$apply();\n\n\t\t});\n\t\tjqxhr.fail(function(req) {\n\t\t\tvar data = req.responseJSON;\n\t\t\t$scope.view.state = cubesviewer.VIEW_STATE_ERROR;\n\t\t\t$scope.view.error = \"Error loading model: \" + data.message + \" (\" + data.error + \")\";\n\t\t\tconsole.debug(data);\n\t\t\t$rootScope.$apply();\n\t\t});\n\t};\n\n\t$scope.requestErrorHandler = function() {\n\t\t$scope.view.requestFailed = true;\n\t};\n\n\n\t$scope.resetGrid = function() {\n\t\trowSorter.colSortFnCache = {};\n\t\t//$scope.view.grid.api.core.notifyDataChange(uiGridConstants.dataChange.ALL);\n\t};\n\n\n\t// TODO: Move to explore view or grid component as cube view shall be split into directives\n    $scope.onGridRegisterApi = function(gridApi) {\n    \t//console.debug(\"Grid Register Api: Explore\");\n        $scope.view.grid.api = gridApi;\n        gridApi.selection.on.rowSelectionChanged($scope, function(row){\n          //console.debug(row.entity);\n        });\n        gridApi.selection.on.rowSelectionChangedBatch($scope, function(rows){\n          //console.debug(rows);\n        });\n        gridApi.core.on.columnVisibilityChanged($scope, function (column) {\n        \tif (column.visible) {\n        \t\tdelete ($scope.view.params.columnHide[column.field]);\n        \t} else {\n        \t\t$scope.view.params.columnHide[column.field] = true;\n        \t\tdelete ($scope.view.params.columnWidths[column.field]);\n        \t}\n        \t$scope.view.updateUndo();\n        });\n        gridApi.core.on.sortChanged($scope, function(grid, sortColumns){\n            // do something\n        \t$scope.view.params.columnSort[$scope.view.params.mode] = {};\n        \t$(sortColumns).each(function (idx, col) {\n        \t\t$scope.view.params.columnSort[$scope.view.params.mode][col.field] = { direction: col.sort.direction, priority: col.sort.priority };\n        \t});\n        \t$scope.view.updateUndo();\n        });\n        gridApi.colResizable.on.columnSizeChanged($scope, function(colDef, deltaChange) {\n        \tvar colIndex = -1;\n        \t$(gridApi.grid.columns).each(function(idx, e) {\n        \t\tif (e.field == colDef.field) colIndex = idx;\n        \t});\n        \tif (colIndex >= 0) {\n        \t\t$scope.view.params.columnWidths[colDef.field] = gridApi.grid.columns[colIndex].width;\n        \t}\n        \t$scope.view.updateUndo();\n        });\n    };\n\n\t$scope.view.grid.onRegisterApi = $scope.onGridRegisterApi;\n\n\t$scope.validateData = function(data, status) {\n\t\t//console.debug(data);\n\t\t$scope.view.requestFailed = false;\n\t\t$scope.view.resultLimitHit = false;\n\t\tif ( (\"cells\" in data && data.cells.length >= cubesService.cubesserver.info.json_record_limit) ||\n\t\t     (data.length && data.length >= cubesService.cubesserver.info.json_record_limit) ) {\n\t\t\t$scope.view.resultLimitHit = true;\n\t\t}\n\t};\n\n\t$scope.newViewStateKey = function() {\n\t\t$scope._viewStateKey = Math.floor(Math.random() * 999999999999);\n\t\treturn $scope._viewStateKey;\n\t};\n\n\t/**\n\t * Adds a drilldown level.\n\t * Dimension is encoded using Cubes notation: dimension[@hierarchy][:level]\n\t */\n\t$scope.selectDrill = function(dimension, value) {\n\n\t\tvar cube = $scope.view.cube;\n\n\t\t// view.params.drilldown = (drilldown == \"\" ? null : drilldown);\n\t\tif (! dimension) {\n\t\t\t$scope.view.params.drilldown = [];\n\t\t} else {\n\t\t\t$scope.removeDrill(dimension);\n\t\t\tif (value == true) {\n\t\t\t\t$scope.view.params.drilldown.push(dimension);\n\t\t\t}\n\t\t}\n\n\t\t$scope.refreshView();\n\t};\n\n\t/**\n\t * Removes a level from the view.\n\t */\n\t$scope.removeDrill = function(drilldown) {\n\n\t\t$scope.view.params.drilldown = $.grep($scope.view.params.drilldown, function(e) {\n\t\t\treturn $scope.view.cube.dimensionParts(e).dimension.name == $scope.view.cube.dimensionParts(drilldown).dimension.name;\n\t\t}, true);\n\n\t\t$scope.refreshView();\n\t};\n\n\n\t/**\n\t * Accepts an aggregation or a measure and returns the formatter function.\n\t *\n\t * @param agmes Aggregation or measure object.\n\t * @returns A formatter function that takes an argument with the metric value to be formatted.\n\t */\n\t$scope.columnFormatFunction = function(agmes) {\n\n\t\tvar view = $scope.view;\n\n\t\tvar measure = agmes;\n\n\t\tif (!measure) {\n\t\t\treturn function(value) {\n\t\t\t\treturn value;\n\t\t\t};\n\t\t}\n\n\t\tif ('measure' in agmes) {\n\t\t\tmeasure = $.grep(view.cube.measures, function(item, idx) { return item.ref == agmes.measure; })[0];\n\t\t}\n\n\t\tvar formatterFunction = null;\n\t\tif (measure && ('cv-formatter' in measure.info)) {\n\t\t\tformatterFunction = function(value, row) {\n\t\t\t\treturn eval(measure.info['cv-formatter']);\n\t\t\t};\n\t\t} else {\n\t\t\tformatterFunction = function(value) {\n\t\t\t\treturn Math.formatnumber(value, (agmes.ref==\"record_count\" ? 0 : 2));\n\t\t\t};\n\t\t}\n\n\t\treturn formatterFunction;\n\t};\n\n\t// Select a cut\n\t$scope.selectCut = function(dimension, value, invert) {\n\n\t\tvar view = $scope.view;\n\n\t\tif (dimension) {\n\t\t\tif (value) {\n\t\t\t\t/*\n\t\t\t\tvar existing_cut = $.grep(view.params.cuts, function(e) {\n\t\t\t\t\treturn e.dimension == dimension;\n\t\t\t\t});\n\t\t\t\tif (existing_cut.length > 0) {\n\t\t\t\t\t//dialogService.show(\"Cannot cut dataset. Dimension '\" + dimension + \"' is already filtered.\");\n\t\t\t\t\t//return;\n\t\t\t\t} else {*/\n\t\t\t\t\tview.params.cuts = $.grep(view.params.cuts, function(e) {\n\t\t\t\t\t\treturn view.cube.dimensionParts(e.dimension).cutDimension == view.cube.dimensionParts(dimension).cutDimension;\n\t\t\t\t\t}, true);\n\t\t\t\t\tview.params.cuts.push({\n\t\t\t\t\t\t\"dimension\" : view.cube.dimensionParts(dimension).cutDimension,\n\t\t\t\t\t\t\"value\" : value,\n\t\t\t\t\t\t\"invert\" : invert\n\t\t\t\t\t});\n\t\t\t\t/*}*/\n\t\t\t} else {\n\t\t\t\tview.params.cuts = $.grep(view.params.cuts, function(e) {\n\t\t\t\t\treturn view.cube.dimensionParts(e.dimension).cutDimension == view.cube.dimensionParts(dimension).cutDimension;\n\t\t\t\t}, true);\n\t\t\t}\n\t\t} else {\n\t\t\tview.params.cuts = [];\n\t\t}\n\n\t\t$scope.refreshView();\n\n\t};\n\n\n\t/*\n\t * Filters current selection\n\t */\n\t$scope.filterSelected = function() {\n\n\t\tvar view = $scope.view;\n\n\t\tif (view.params.drilldown.length != 1) {\n\t\t\tdialogService.show('Can only filter multiple values in a view with one level of drilldown.');\n\t\t\treturn;\n\t\t}\n\n\t\tif (view.grid.api.selection.getSelectedCount() <= 0) {\n\t\t\tdialogService.show('Cannot filter. No rows are selected.');\n\t\t\treturn;\n\t\t}\n\n\t\tvar filterValues = [];\n\t\tvar selectedRows = view.grid.api.selection.getSelectedRows();\n\t\t$(selectedRows).each( function(idx, gd) {\n\t\t\tfilterValues.push(gd[\"key0\"].cutValue);\n\t\t});\n\n\t\tvar invert = false;\n\t\t$scope.selectCut(view.grid.columnDefs[0].cutDimension, filterValues.join(\";\"), invert);\n\n\t};\n\n\n\t$scope.showDimensionFilter = function(dimension) {\n\t\tvar parts = $scope.view.cube.dimensionParts(dimension);\n\t\tif ($scope.view.dimensionFilter && $scope.view.dimensionFilter == parts.drilldownDimension) {\n\t\t\t$scope.view.dimensionFilter = null;\n\t\t} else {\n\t\t\t$scope.view.dimensionFilter = parts.drilldownDimension;\n\t\t}\n\t};\n\n\t/*\n\t * Selects measure axis\n\t */\n\t$scope.selectMeasure = function(measure) {\n\t\t$scope.view.params.yaxis = measure;\n\t\t$scope.refreshView();\n\t};\n\n\t/*\n\t * Selects horizontal axis\n\t */\n\t$scope.selectXAxis = function(dimension) {\n\t\t$scope.view.params.xaxis = (dimension == \"\" ? null : dimension);\n\t\t$scope.refreshView();\n\t};\n\n\t/*\n\t * Selects chart type\n\t */\n\t$scope.selectChartType = function(charttype) {\n\t\t$scope.view.params.charttype = charttype;\n\t\t$scope.refreshView();\n\t};\n\n\t/*\n\t * Selects chart type\n\t */\n\t$scope.selectCalculation = function(calculation) {\n\t\t$scope.view.params.calculation = calculation;\n\t\t$scope.refreshView();  // TODO: This depends on the calculation\n\t};\n\n\n\t/*\n\t * Serialize view dialog\n\t */\n\t$scope.showSerializeView = function(view) {\n\t\tstudioViewsService.studioScope.showSerializeView(view);\n\t};\n\n\t/**\n\t * Adds a date filter.\n\t */\n\t$scope.selectDateFilter = function(dimension, enabled) {\n\n\t\tvar view = $scope.view;\n\t\tvar cube = view.cube;\n\n\t\t// TODO: Show a notice if the dimension already has a date filter (? and cut filter)\n\n\t\tif (dimension != \"\") {\n\t\t\tif (enabled == \"1\") {\n\t\t\t\tview.params.datefilters.push({\n\t\t\t\t\t\"dimension\" : dimension,\n\t\t\t\t\t\"mode\" : \"auto-last3m\",\n\t\t\t\t\t\"date_from\" : null,\n\t\t\t\t\t\"date_to\" : null\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tfor ( var i = 0; i < view.params.datefilters.length; i++) {\n\t\t\t\t\tif (view.params.datefilters[i].dimension.split(':')[0] == dimension) {\n\t\t\t\t\t\tview.params.datefilters.splice(i, 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tview.params.datefilters = [];\n\t\t}\n\n\t\t$scope.refreshView();\n\n\t};\n\n\t$scope.clearFilters = function() {\n\t\t$scope.view.params.cuts = [];\n\t\t$scope.view.params.datefilters = [];\n\t\t$scope.refreshView();\n\t};\n\n\t$scope.defineColumnWidth = function(column, vdefault) {\n\t\tif (column in $scope.view.params.columnWidths) {\n\t\t\treturn $scope.view.params.columnWidths[column];\n\t\t} else {\n\t\t\treturn vdefault;\n\t\t}\n\t};\n\n\t$scope.defineColumnSort = function(column) {\n\t\tvar columnSort = null;\n\t\tif ($scope.view.params.columnSort[$scope.view.params.mode] && $scope.view.params.columnSort[$scope.view.params.mode][column]) {\n\t\t\tcolumnSort = {\n\t\t\t\t\"direction\": $scope.view.params.columnSort[$scope.view.params.mode][column].direction,\n\t\t\t\t\"priority\": $scope.view.params.columnSort[$scope.view.params.mode][column].priority\n\t\t\t};\n\t\t}\n\t\treturn columnSort;\n\t};\n\n\t/**\n\t * Function to compare two values by guessing the\n\t * data type.\n\t *\n\t * @return An integer, negative or positive depending on relative inputs ordering.\n\t */\n\t$scope.sortValues = function(a, b) {\n\t\tif (typeof a == \"number\" && typeof b == \"number\") {\n\t\t\treturn a - b;\n\t\t} else if (typeof a == \"string\" && typeof b == \"string\") {\n\t\t\tif ($.isNumeric(a) && $.isNumeric(b)) {\n\t\t\t\treturn parseFloat(a) - parseFloat(b);\n\t\t\t} else {\n\t\t\t\treturn a.localeCompare(b);\n\t\t\t}\n\t\t} else if (a == null && b == null) {\n\t\t\treturn 0;\n\t\t} else if (a == null) {\n\t\t\treturn 1;\n\t\t} else if (b == null) {\n\t\t\treturn -1;\n\t\t} else {\n\t\t\treturn a - b;\n\t\t}\n\t};\n\n\t/**\n\t * Called to sort a column which is a dimension drilled down to a particular level.\n\t * This is called by UIGrid, since this method is used as `compareAlgorithm` for it.\n\t *\n\t * @returns A compare function.\n\t */\n\t$scope.sortDimensionParts = function(tdimparts) {\n\n\t\tvar dimparts = tdimparts;\n\n\t\tvar cmpFunction = function(a, b, rowA, rowB, direction) {\n\t\t\tvar result = 0;\n\n\t\t\tfor (var j = 0; result == 0 && j < dimparts.hierarchy.levels.length; j++) {\n\t\t\t\tvar level = dimparts.hierarchy.levels[j];\n\t\t\t\tvar order_attribute = level.order_attribute();\n\t\t\t\tvar fieldname = order_attribute.ref;\n\t\t\t\tif ((fieldname in rowA.entity._cell) && (fieldname in rowB.entity._cell)) {\n\t\t\t\t\tresult = $scope.sortValues(rowA.entity._cell[fieldname], rowB.entity._cell[fieldname]);\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t};\n\n\t\treturn cmpFunction;\n\t};\n\n\t/**\n\t * Called to sort a column which is a level of a dimension, without a hierarchy\n\t * context. This is ie. used from the Facts view (where levels are sorted independently).\n\t *\n\t * This is called by UIGrid, since this method is used as `compareAlgorithm` for it.\n\t *\n\t * @returns A compare function.\n\t */\n\t$scope.sortDimensionLevel = function(level) {\n\t\tvar cmpFunction = function(a, b, rowA, rowB, direction) {\n\t\t\tvar result = 0;\n\t\t\tvar order_attribute = level.order_attribute();\n\t\t\tvar fieldname = order_attribute.ref;\n\t\t\tif ((fieldname in rowA.entity._cell) && (fieldname in rowB.entity._cell)) {\n\t\t\t\tresult = $scope.sortValues(rowA.entity._cell[fieldname], rowB.entity._cell[fieldname]);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\treturn cmpFunction;\n\t};\n\n\t$scope.onResize = function() {\n\t\t$rootScope.$broadcast('ViewResize');\n\t};\n\n\tangular.element($window).on('resize', $scope.onResize);\n\n\t$scope.$on(\"$destroy\", function() {\n\t\tangular.element($window).off('resize', $scope.onResize);\n\t});\n\n\n}]).directive(\"cvViewCube\", function() {\n\treturn {\n\t\trestrict: 'A',\n\t\ttemplateUrl: 'views/cube/cube.html',\n\t\tscope: {\n\t\t\tview: \"=\"\n\t\t},\n\t\tcontroller: \"CubesViewerViewsCubeController\",\n\t\tlink: function(scope, iElement, iAttrs) {\n\t\t\t//console.debug(scope);\n\t\t\tscope.initCube();\n\t\t}\n\t};\n});\n\n\nMath.formatnumber = function(value, decimalPlaces, decimalSeparator, thousandsSeparator) {\n\n\tif (value === undefined) return \"\";\n\n\tif (decimalPlaces === undefined) decimalPlaces = 2;\n\tif (decimalSeparator === undefined) decimalSeparator = \".\";\n\tif (thousandsSeparator === undefined) thousandsSeparator = \" \";\n\n\tvar result = \"\";\n\n\n\tvar avalue = Math.abs(value);\n\n\tvar intString = Math.floor(avalue).toString();\n\tfor (var i = 0; i < intString.length; i++) {\n\t\tresult = result + intString[i];\n\t\tvar invPos = (intString.length - i - 1);\n\t\tif (invPos > 0 && invPos % 3 == 0) result = result + thousandsSeparator;\n\t}\n\tif (decimalPlaces > 0) {\n\t\tresult = result + parseFloat(avalue - Math.floor(avalue)).toFixed(decimalPlaces).toString().replace(\".\", decimalSeparator).substring(1);\n\t}\n\n\tif (value < 0) result = \"-\" + result;\n\n\treturn result;\n};\n\n"
  },
  {
    "path": "cubesviewer/views/cube/explore/explore.html",
    "content": "<div ng-controller=\"CubesViewerViewsCubeExploreController\">\n\n    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\n    <h3><i class=\"fa fa-fw fa-arrow-circle-down\"></i> Aggregated data\n        <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n    </h3>\n\n    <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n        <span class=\"loadingbar-expand\"></span>\n    </div>\n\n    <div ui-grid=\"view.grid\"\n         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\n         ui-grid-pagination ui-grid-pinning\n         style=\"width: 100%;\" ng-style=\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\">\n    </div>\n    <div style=\"height: 30px;\">&nbsp;</div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/explore/explore.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n/**\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeExploreController\", ['$rootScope', '$scope', '$timeout', 'cvOptions', 'cubesService', 'viewsService', 'dialogService', 'uiGridConstants',\n                                                     function ($rootScope, $scope, $timeout, cvOptions, cubesService, viewsService, dialogService, uiGridConstants) {\n\n\t$scope.view.grid.enableRowSelection = true;\n\t$scope.view.grid.enableRowHeaderSelection = true;\n\n\t$scope.initialize = function() {\n\t\t$scope.refreshView();\n\t};\n\n\t$scope.$on(\"ViewRefresh\", function(view) {\n\t\t$scope.loadData();\n\t});\n\n\t$scope.loadData = function() {\n\n\t\t//$scope.view.cubesviewer.views.blockViewLoading(view);\n\t\tvar browser_args = cubesService.buildBrowserArgs($scope.view, false, false);\n\t\tvar browser = new cubes.Browser(cubesService.cubesserver, $scope.view.cube);\n\t\tvar viewStateKey = $scope.newViewStateKey();\n\t\tvar jqxhr = browser.aggregate(browser_args, $scope._loadDataCallback(viewStateKey));\n\n\t\t$scope.view.pendingRequests++;\n\t\tjqxhr.always(function() {\n\t\t\t$scope.view.pendingRequests--;\n\t\t\t$rootScope.$apply();\n\t\t});\n\t\tjqxhr.error($scope.requestErrorHandler);\n\n\t};\n\n\t$scope._loadDataCallback = function(viewStateKey) {\n\t\treturn function(data, status) {\n\t\t\t// Only update if view hasn't changed since data was requested.\n\t\t\tif (viewStateKey == $scope._viewStateKey) {\n\t\t\t\t$scope.validateData(data, status);\n\t\t\t\t$scope.processData(data);\n\t\t\t\t//$scope.view.grid.api.core.notifyDataChange(uiGridConstants.dataChange.ALL);\n\t\t\t\t$rootScope.$apply();\n\t\t\t}\n\t\t};\n\t};\n\n\t$scope.exploreCut = function(dimension, value, invert) {\n\t\t$scope.selectCut(dimension, value, invert);\n\t\tif ($scope.view.params.drilldown.length == 1) {\n\t\t\t// A single item has been selected, so automatically drill one more level\n\t\t\tvar dimparts = $scope.view.cube.dimensionParts($scope.view.params.drilldown[0]);\n\t\t\tif (dimparts.levelIndex < dimparts.hierarchy.levels.length - 1) {\n\t\t\t\tvar drilldown = dimparts.dimension.name + ( dimparts.hierarchy.name != \"default\" ? (\"@\" + dimparts.hierarchy.name) : \"\" ) + \":\" + dimparts.hierarchy.levels[dimparts.levelIndex + 1].name;\n\t\t\t\t$scope.selectDrill(drilldown, true);\n\t\t\t}\n\t\t}\n\t};\n\n\t$scope.processData = function(data) {\n\n\t\tvar view = $scope.view;\n\n\t\t$scope.resetGrid();\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t\t$rootScope.$apply();\n\n\t    // Configure grid\n\t    angular.extend(view.grid, {\n\t    \tdata: [],\n    \t\t//minRowsToShow: 3,\n    \t\trowHeight: 24,\n    \t\tonRegisterApi: $scope.onGridRegisterApi,\n    \t\tenableColumnResizing: true,\n    \t\tshowColumnFooter: true,\n    \t\tenableGridMenu: true,\n    \t\t//showGridFooter: true,\n    \t    paginationPageSizes: cvOptions.pagingOptions,\n    \t    paginationPageSize: cvOptions.pagingOptions[0],\n    \t\t//enableHorizontalScrollbar: 0,\n    \t\t//enableVerticalScrollbar: 0,\n    \t\tenableRowSelection: view.params.drilldown.length > 0,\n    \t\t//enableRowHeaderSelection: false,\n    \t\t//enableSelectAll: false,\n    \t\tenablePinning: false,\n    \t\tmultiSelect: true,\n    \t\tselectionRowHeaderWidth: 20,\n    \t\t//rowHeight: 50,\n    \t\tcolumnDefs: []\n\t    });\n\n\t\t$(view.cube.aggregates).each(function(idx, ag) {\n\t\t\tvar col = {\n\t\t\t\tname: ag.label,\n\t\t\t\tfield: ag.ref,\n\t\t\t\tindex : ag.ref,\n\t\t\t\tcellClass : \"text-right\",\n\t\t\t\ttype : \"number\",\n\t\t\t\theaderCellClass: \"cv-grid-header-measure\",\n\t\t\t\twidth : $scope.defineColumnWidth(ag.ref, 115),\n\t\t\t\tvisible: ! view.params.columnHide[ag.ref],\n\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t\tformatter: $scope.columnFormatFunction(ag),\n\t\t\t\tsort: $scope.defineColumnSort(ag.ref)\n\t\t\t\t//formatoptions: {},\n\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t};\n\t\t\tcol.footerValue = $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col);\n\t\t\tcol.footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>';\n\t\t\tview.grid.columnDefs.push(col);\n\n\t\t\t//if (data.summary) dataTotals[ag.ref] = data.summary[ag.ref];\n\t\t});\n\n\t\t// If there are cells, show them\n\t\t//$scope._sortData(data.cells, false);\n\t\t$scope._addRows(data);\n\n\t\t/*\n\t\tcolNames.sort();\n\t\tcolModel.sort(function(a, b) {\n\t\t\treturn (a.name < b.name ? -1 : (a.name == b.name ? 0 : 1));\n\t\t});\n\t\t*/\n\n\t\tvar label = [];\n\t\t$(view.params.drilldown).each(function(idx, e) {\n\t\t\tlabel.push(view.cube.cvdim_dim(e).label);\n\t\t});\n\t\tfor (var i = 0; i < view.params.drilldown.length; i++) {\n\n\t\t\t// Get dimension\n\t\t\tvar dim = view.cube.cvdim_dim(view.params.drilldown[i]);\n\t\t\tvar parts = view.cube.dimensionParts(view.params.drilldown[i]);\n\t\t\t//var cutDimension = parts.dimension.name + ( parts.hierarchy.name != \"default\" ? \"@\" + parts.hierarchy.name : \"\" );\n\t\t\tvar cutDimension = view.params.drilldown[i];\n\n\t\t\t//nid.push(drilldownLevelValues.join(\"-\"));\n\n\t\t\tvar footer = \"\";\n\t\t\tif (i == 0) footer = (cubesService.buildQueryCuts(view).length == 0) ? \"<b>Summary</b>\" : '<b>Summary <i style=\"color: #ddaaaa;\">(Filtered)</i></b>';\n\n\t\t\tview.grid.columnDefs.splice(i, 0, {\n\t\t\t\tname: label[i],\n\t\t\t\tfield: \"key\" + i,\n\t\t\t\tindex: \"key\" + i,\n\t\t\t\theaderCellClass: \"cv-grid-header-dimension\",\n\t\t\t\tenableHiding: false,\n\t\t\t\tcutDimension: cutDimension,\n\t\t\t\twidth : $scope.defineColumnWidth(\"key\" + i, 190),\n\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\"><a href=\"\" ng-click=\"grid.appScope.exploreCut(col.colDef.cutDimension, COL_FIELD.cutValue, false)\">{{ COL_FIELD.title }}</a></div>',\n\t\t\t\tfooterCellTemplate: '<div class=\"ui-grid-cell-contents\">' + footer + '</div>',\n\t\t\t\tsort: $scope.defineColumnSort(\"key\" + i),\n\t\t\t\tsortingAlgorithm: $scope.sortDimensionParts(parts)\n\t\t\t});\n\t\t}\n\n\t\tif (view.params.drilldown.length == 0) {\n\t\t\tview.grid.columnDefs.splice(0, 0, {\n\t\t\t\tname: view.cube.label,\n\t\t\t\tfield: \"key\" + 0,\n\t\t\t\tindex: \"key\" + 0,\n\t\t\t\tenableHiding: false,\n\t\t\t\talign: \"left\",\n\t\t\t\twidth : $scope.defineColumnWidth(\"key\" + 0, 190),\n\t\t\t\tsort: $scope.defineColumnSort(\"key\" + 0),\n\t\t\t\t//type: \"string\"\n\t\t\t});\n\t\t}\n\n\n\t};\n\n\n\t$scope._addRows = function(data) {\n\n\t\tvar view = $scope.view;\n\t\tvar rows = view.grid.data;\n\n\t\t$(data.cells).each( function(idx, e) {\n\n\t\t\tvar nid = [];\n\t\t\tvar row = {};\n\t\t\tvar key = [];\n\n\t\t\t// For each drilldown level\n\t\t\tfor ( var i = 0; i < view.params.drilldown.length; i++) {\n\n\t\t\t\t// Get dimension\n\t\t\t\tvar dim = view.cube.cvdim_dim(view.params.drilldown[i]);\n\n\t\t\t\tvar parts = view.cube.dimensionParts(view.params.drilldown[i]);\n\t\t\t\tvar infos = parts.hierarchy.readCell(e, parts.level);\n\n\t\t\t\t// Values and Labels\n\t\t\t\tvar drilldownLevelValues = [];\n\t\t\t\tvar drilldownLevelLabels = [];\n\n\t\t\t\t$(infos).each(function(idx, info) {\n\t\t\t\t\tdrilldownLevelValues.push (info.key);\n\t\t\t\t\tdrilldownLevelLabels.push (info.label);\n\t\t\t\t});\n\n\t\t\t\tnid.push(drilldownLevelValues.join(\"-\"));\n\n\t\t\t\tvar cutDimension = parts.dimension.name + ( parts.hierarchy.name != \"default\" ? \"@\" + parts.hierarchy.name : \"\" );\n\t\t\t\tkey.push({ cutValue: drilldownLevelValues.join(\",\"), title: drilldownLevelLabels.join(\" / \") });\n\t\t\t}\n\n\t\t\t// Set key\n\t\t\trow[\"key\"] = key.join (\" / \");\n\t\t\tfor (var i = 0; i < key.length; i++) {\n\t\t\t\trow[\"key\" + i] = key[i];\n\t\t\t}\n\t\t\t//row[\"key\"] = key.join(' / ');\n\n\t\t\t// Add columns\n\t\t\t$(view.cube.aggregates).each(function(idx, ag) {\n\t\t\t\trow[ag.ref] = e[ag.ref];\n\t\t\t});\n\n\t\t\trow[\"id\"] = nid.join('-');\n\t\t\trow[\"_cell\"] = e;\n\t\t\trows.push(row);\n\t\t});\n\n\t\t// Copy summary if there's no data\n\t\t// This allows a scrollbar to appear in jqGrid when only the summary row is shown.\n\t\tif ((rows.length == 0) && (data.summary)) {\n\t\t\tvar row = {};\n\t\t\tvar summary = (cubesService.buildQueryCuts(view).length == 0) ? \"Summary\" : \"Summary (Filtered)\";\n\t\t\trow[\"key0\"] = summary;\n\n\t\t\t$(view.cube.aggregates).each(function(idx, ag) {\n\t\t\t\trow[ag.ref] = data.summary[ag.ref];\n\t\t\t});\n\n\t\t\trows.push(row);\n\t\t}\n\n\t};\n\n\t// Sort data according to current view\n\t$scope._sortData = function(data, includeXAxis) {\n\t\t//data.sort(cubesviewer._drilldownSortFunction(view.id, includeXAxis));\n\t};\n\n\n\t$scope.$on(\"$destroy\", function() {\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t});\n\n\t$scope.initialize();\n\n}]);\n\n\n\n\nfunction cubesviewerViewCubeExplore() {\n\n\n\t/*\n\t *\n\t */\n\tthis._drilldownSortFunction = function(view, includeXAxis) {\n\n\t\tvar drilldown = view.params.drilldown.slice(0);\n\n\t\t// Include X Axis if necessary\n\t\tif (includeXAxis) {\n\t\t\tdrilldown.splice(0, 0, view.params.xaxis);\n\t\t}\n\n\t\treturn function(a, b) {\n\n\t\t\t// For the horizontal axis drilldown level, if present\n\t\t\tfor ( var i = 0; i < drilldown.length; i++) {\n\n\t\t\t\t// Get dimension\n\t\t\t\tvar dimension = view.cube.cvdim_dim(drilldown[i]);\n\n\t\t\t\t// row[\"key\"] = ((e[view.params.drilldown_field] != null) &&\n\t\t\t\t// (e[view.params.drilldown] != \"\")) ? e[view.params.drilldown] : \"Undefined\";\n\t\t\t\tif (dimension.is_flat == true) {\n\t\t\t\t\tif (a[dimension.name] < b[dimension.name])\n\t\t\t\t\t\treturn -1;\n\t\t\t\t\tif (a[dimension.name] > b[dimension.name])\n\t\t\t\t\t\treturn 1;\n\t\t\t\t} else {\n\t\t\t\t\tvar drilldown_level_value = [];\n\t\t\t\t\tfor ( var j = 0; j < dimension.levels.length; j++) {\n\t\t\t\t\t\tvar fieldname = dimension.name + \".\"\n\t\t\t\t\t\t\t\t+ dimension.levels[j].name;\n\t\t\t\t\t\tif ((fieldname in a) && (fieldname in b)) {\n\t\t\t\t\t\t\tif (a[fieldname] < b[fieldname])\n\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\tif (a[fieldname] > b[fieldname])\n\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t};\n\t},\n\n\tthis.columnTooltipAttr = function(column) {\n\t\treturn function (rowId, val, rawObject) {\n\t\t\treturn 'title=\"' + column + ' = ' + val + '\"';\n\t\t};\n\t};\n\n\n};\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/export.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * This addon adds export to CSV capability to CubesViewer cube view.\n * It offers an \"export facts\" menu option for all cube view modes,\n * and a \"export table\" option in Explore and Series mode.\n */\n\n\"use strict\";\n\n/**\n * Provides methods to export data from \"cube\" views.\n *\n * @class exportService\n * @memberof cv.views.cube\n */\nangular.module('cv.views.cube').service(\"exportService\", ['$rootScope', '$timeout', 'cvOptions', 'cubesService', 'viewsService', 'seriesOperationsService',\n                                                         function ($rootScope, $timeout, cvOptions, cubesService, viewsService, seriesOperationsService) {\n\n\t/**\n\t * Download facts in CSV format from Cubes Server\n\t *\n\t * @memberof cv.views.cube.exportService\n\t */\n\tthis.exportFacts = function(view) {\n\n\t\tvar args = cubesService.buildBrowserArgs(view, false, true);\n\n        var http_args = {};\n        http_args[\"format\"] = \"csv\";\n\n        if (args.cut) http_args.cut = args.cut.toString();\n        if (args.order) http_args.order = args.order.toString();\n\n\n\t\tvar url = cvOptions.cubesUrl + \"/cube/\" + view.cube.name + \"/facts?\" + $.param(http_args);\n\t\twindow.open(url, '_blank');\n\t\twindow.focus();\n\n\t};\n\n\t/**\n\t * Export a view (either in \"explore\" or \"series\" mode) in CSV format.\n\t *\n\t * @memberof cv.views.cube.exportService\n\t */\n\tthis.exportGridAsCsv = function (view) {\n\n\t\tif (!view.grid) {\n\t\t\tconsole.debug(\"View has no grid that can be exported.\");\n\t\t\treturn;\n\t\t}\n\n\t\tvar gridOptions = view.grid;\n\t\tvar dataRows = view.grid.data;\n\n\t\tvar content = \"\";\n\t\tvar values = [];\n\n\t\t$(view.grid.columnDefs).each(function(idx, e) {\n\t\t\tvalues.push ('\"' + e.name + '\"');\n\t\t});\n\t\tcontent = content + (values.join(\",\")) + \"\\n\";\n\n\t\t$(dataRows).each(function(idxr, r) {\n\t\t\tvalues = [];\n\t\t\t$(view.grid.columnDefs).each(function(idx, e) {\n\t\t\t\tif (r[e.field] && r[e.field].title) {\n\t\t\t\t\t// Explore view uses objects as values, where \"title\" is the label\n\t\t\t\t\tvalues.push('\"' + r[e.field].title + '\"');\n\t\t\t\t} else {\n\t\t\t\t\t//\n\t\t\t\t\tvalues.push('\"' + r[e.field] + '\"');\n\t\t\t\t}\n\t\t\t});\n\t\t\tcontent = content + (values.join(\",\")) + \"\\n\";\n\t\t});\n\n\n\t\t//window.open (url, \"_blank\");\n\t\tthis.saveAs(content, \"text/csv\", view.cube.name + \"-summary.csv\")\n\t};\n\n\t/**\n\t * Delivers a data URI to the client with a given filename.\n\t *\n\t * @memberof cv.views.cube.exportService\n\t */\n\tthis.saveAs = function(content, mime, filename) {\n\n\t\t// Method 1\n\t\t//var uri = \"data:\" + mime + \";charset=utf-8,\" + encodeURIComponent(content);\n\n\t\t// Method 2\n\t\tvar csvData = new Blob([content], { type: mime });\n\t\tvar uri = URL.createObjectURL(csvData);\n\n\t\tvar link = document.createElement('a');\n\t    if (typeof link.download === 'string') {\n\t        document.body.appendChild(link); // Firefox requires the link to be in the body\n\t        link.download = filename;\n\t        link.href = uri;\n\t        link.click();\n        \tdocument.body.removeChild(link); // remove the link when done\n\t    } else {\n\t        location.replace(uri);\n\t    }\n\t};\n\n\t/**\n\t * Grab page styles as a string to embed them into the SVG source\n\t * From: https://github.com/NYTimes/svg-crowbar/blob/gh-pages/svg-crowbar.js\n\t */\n\tthis.getDocumentStyles = function() {\n\n\t\tvar doc = window.document;\n\n\t\tvar styles = \"\", styleSheets = doc.styleSheets;\n\n\t\tif (styleSheets) {\n\t\t\tfor ( var i = 0; i < styleSheets.length; i++) {\n\t\t\t\tprocessStyleSheet(styleSheets[i]);\n\t\t\t}\n\t\t}\n\n\t    function processStyleSheet(ss) {\n\t    \ttry {\n\t\t    \tif (ss.cssRules) {\n\t\t    \t\tconsole.debug(ss);\n\t\t\t\t\tfor ( var i = 0; i < ss.cssRules.length; i++) {\n\t\t\t\t\t\tvar rule = ss.cssRules[i];\n\t\t\t\t\t\tif (rule.type === 3) {\n\t\t\t\t\t\t\t// Import Rule\n\t\t\t\t\t\t\tprocessStyleSheet(rule.styleSheet);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// hack for illustrator crashing\n\t\t\t\t\t\t\t// on descendent selectors\n\t\t\t\t\t\t\tif (rule.selectorText) {\n\t\t\t\t\t\t\t\tif (rule.selectorText\n\t\t\t\t\t\t\t\t\t\t.indexOf(\">\") === -1) {\n\t\t\t\t\t\t\t\t\tstyles += \"\\n\"\n\t\t\t\t\t\t\t\t\t\t\t+ rule.cssText;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t    \t} catch (err) {\n\t    \t\tconsole.debug(\"Could not access document stylesheet.\")\n\t    \t}\n\t\t}\n\n\t\treturn styles;\n\t}\n\n}]);\n\n"
  },
  {
    "path": "cubesviewer/views/cube/facts/facts.html",
    "content": "<div ng-controller=\"CubesViewerViewsCubeFactsController\">\n\n    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\n    <h3><i class=\"fa fa-fw fa-th\"></i> Facts data\n        <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n    </h3>\n\n    <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n        <span class=\"loadingbar-expand\"></span>\n    </div>\n\n    <div ng-if=\"view.grid.data.length > 0\"\n         ui-grid=\"view.grid\"\n         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\n         ui-grid-pagination ui-grid-pinning\n         style=\"width: 100%;\" ng-style=\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\">\n    </div>\n    <div ng-if=\"view.grid.data.length > 0\" style=\"height: 30px;\">&nbsp;</div>\n\n    <div ng-if=\"viewController.view.pendingRequests == 0 && view.grid.data.length == 0\">No facts are returned by the current filtering combination.</div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/facts/facts.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Sof\ttware, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n/**\n * Facts table. Allows users to see the facts associated to current cut.\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeFactsController\", ['$rootScope', '$scope', '$timeout', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $timeout, cvOptions, cubesService, viewsService) {\n\n\t$scope.view.grid.enableRowSelection = false;\n\t$scope.view.grid.enableRowHeaderSelection = false;\n\n\t$scope.initialize = function() {\n\t\t$scope.refreshView();\n\t};\n\n\t$scope.$on(\"ViewRefresh\", function(view) {\n\t\t$scope.loadData();\n\t});\n\n\t$scope.loadData = function() {\n\n\t\tvar browser_args = cubesService.buildBrowserArgs($scope.view, false, false);\n\t\tvar browser = new cubes.Browser(cubesService.cubesserver, $scope.view.cube);\n\t\tvar viewStateKey = $scope.newViewStateKey();\n\t\tvar jqxhr = browser.facts(browser_args, $scope._loadDataCallback(viewStateKey));\n\n\t\t$scope.view.pendingRequests++;\n\t\tjqxhr.always(function() {\n\t\t\t$scope.view.pendingRequests--;\n\t\t\t$rootScope.$apply();\n\t\t});\n\t\tjqxhr.error($scope.requestErrorHandler);\n\n\t};\n\n\t$scope._loadDataCallback = function(viewStateKey) {\n\t\treturn function(data, status) {\n\t\t\t// Only update if view hasn't changed since data was requested.\n\t\t\tif (viewStateKey == $scope._viewStateKey) {\n\t\t\t\t$scope.validateData(data, status);\n\t\t\t\t$scope.processData(data);\n\t\t\t\t$rootScope.$apply();\n\t\t\t}\n\t\t};\n\t};\n\n\t$scope.processData = function(data) {\n\n\t\tvar view = $scope.view;\n\n\t\t$scope.resetGrid();\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t\t$rootScope.$apply();\n\n\t\tvar dimensions = view.cube.dimensions;\n\t\tvar measures = view.cube.measures;\n        var details = view.cube.details;\n\n\t    // Configure grid\n\t    angular.extend($scope.view.grid, {\n    \t\tdata: [],\n    \t\t//minRowsToShow: 3,\n    \t\trowHeight: 24,\n    \t\tonRegisterApi: $scope.onGridRegisterApi,\n    \t\tenableColumnResizing: true,\n    \t\tshowColumnFooter: false,\n    \t\tenableGridMenu: true,\n    \t\t//showGridFooter: false,\n    \t    paginationPageSizes: cvOptions.pagingOptions,\n    \t    paginationPageSize: cvOptions.pagingOptions[0],\n    \t\t//enableHorizontalScrollbar: 0,\n    \t\t//enableVerticalScrollbar: 0,\n    \t\tenableRowSelection: false,\n    \t\tenableRowHeaderSelection: false,\n    \t\t//enableSelectAll: false,\n    \t\tenablePinning: false,\n    \t\tmultiSelect: false,\n    \t\t//selectionRowHeaderWidth: 20,\n    \t\t//rowHeight: 50,\n    \t\tcolumnDefs: []\n\t    });\n\n\t\tview.grid.columnDefs.push({\n\t\t\tname: \"id\",\n\t\t\tfield: \"id\",\n\t\t\tindex: \"id\",\n\t\t\tenableHiding: false,\n\t\t\twidth: 80, //cubesviewer.views.cube.explore.defineColumnWidth(view, \"id\", 65),\n\t\t});\n\n\t\tfor (var dimensionIndex in dimensions) {\n\n\t\t\tvar dimension = dimensions[dimensionIndex];\n\n\t\t\tfor (var i = 0; i < dimension.levels.length; i++) {\n\t\t\t\tvar level = dimension.levels[i];\n\t\t\t\tvar col = {\n\t\t\t\t\tname: level.label,\n\t\t\t\t\tfield: level.key().ref,\n\t\t\t\t\tindex : level.key().ref,\n\t\t\t\t\theaderCellClass: \"cv-grid-header-dimension\",\n\t\t\t\t\t//cellClass : \"text-right\",\n\t\t\t\t\t//sorttype : \"number\",\n\t\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ row.entity[col.colDef.field] }}</div>',\n\t\t\t\t\t//formatter: $scope.columnFormatFunction(ag),\n\t\t\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t\t\t//formatoptions: {},\n\t\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>'\n\t\t\t\t\tvisible: ! view.params.columnHide[level.key().ref],\n\t\t\t\t\twidth : $scope.defineColumnWidth(level.key().ref, 95),\n\t\t\t\t\tsort: $scope.defineColumnSort(level.key().ref),\n\t\t\t\t\tsortingAlgorithm: $scope.sortDimensionLevel(level)\n\t\t\t\t};\n\t\t\t\tview.grid.columnDefs.push(col);\n\n\t\t\t\t// Additional dimension attributes\n\t\t\t\t$(level.attributes).each(function(idx, e) {\n\t\t\t\t\tif (e.ref != level.key().ref && e.ref != level.label_attribute().ref) {\n\t\t\t\t\t\tvar col = {\n\t\t\t\t\t\t\tname: e.name,\n\t\t\t\t\t\t\tfield: e.ref,\n\t\t\t\t\t\t\tindex : e.ref,\n\t\t\t\t\t\t\theaderCellClass: \"cv-grid-header-dimensionattribute\",\n\t\t\t\t\t\t\t//cellClass : \"text-right\",\n\t\t\t\t\t\t\t//sorttype : \"number\",\n\t\t\t\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ row.entity[col.colDef.field] }}</div>',\n\t\t\t\t\t\t\t//formatter: $scope.columnFormatFunction(ag),\n\t\t\t\t\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t\t\t\t\t//formatoptions: {},\n\t\t\t\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t\t\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>'\n\t\t\t\t\t\t\tvisible: ! view.params.columnHide[e.ref],\n\t\t\t\t\t\t\twidth : $scope.defineColumnWidth(e.ref, 85),\n\t\t\t\t\t\t\tsort: $scope.defineColumnSort(e.ref),\n\t\t\t\t\t\t\t//sortingAlgorithm: $scope.sortDimensionLevel(level)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tview.grid.columnDefs.push(col);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t}\n\t\t}\n\n\t\tfor (var measureIndex in measures) {\n\t\t\tvar measure = measures[measureIndex];\n\n\t\t\tvar col = {\n\t\t\t\tname: measure.label,\n\t\t\t\tfield: measure.ref,\n\t\t\t\tindex : measure.ref,\n\t\t\t\tcellClass : \"text-right\",\n\t\t\t\theaderCellClass: \"cv-grid-header-measure\",\n\t\t\t\t//type : \"number\",\n\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t\tformatter: $scope.columnFormatFunction(measure),\n\t\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t\t//formatoptions: {},\n\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>';\n\t\t\t\tvisible: ! view.params.columnHide[measure.ref],\n\t\t\t\twidth : $scope.defineColumnWidth(measure.ref, 75),\n\t\t\t\tsort: $scope.defineColumnSort(measure.ref),\n\t\t\t};\n\t\t\tview.grid.columnDefs.push(col);\n\t\t}\n\n        for (var detailIndex in details) {\n            var detail = details[detailIndex];\n\n            var col = {\n\t\t\t\tname: detail.name,\n\t\t\t\tfield: detail.ref,\n\t\t\t\tindex : detail.ref,\n\t\t\t\t//cellClass : \"text-right\",\n\t\t\t\t//sorttype : \"number\",\n\t\t\t\t//cellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t\t//formatter: $scope.columnFormatFunction(ag),\n\t\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t\t//formatoptions: {},\n\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>'\n\t\t\t\tvisible: ! view.params.columnHide[detail.ref],\n\t\t\t\twidth: $scope.defineColumnWidth(detail.ref, 95),\n\t\t\t\tsort: $scope.defineColumnSort(detail.ref),\n\t\t\t\tsortingAlgorithm: $scope.sortValues\n\t\t\t};\n            view.grid.columnDefs.push(col);\n        }\n\n\t\t// If there are cells, show them\n\t\t$scope._addRows(data);\n\n\t};\n\n\n\t/*\n\t * Adds rows.\n\t */\n\t$scope._addRows = function(data) {\n\n\t\tvar view = $scope.view;\n\t\tvar rows = view.grid.data;\n\n\t\tvar counter = 0;\n\t\tvar dimensions = view.cube.dimensions;\n\t\tvar measures = view.cube.measures;\n        var details = view.cube.details;\n\n\t\t$(data).each( function(idx, e) {\n\n\t\t\tvar nid = [];\n\t\t\tvar row = [];\n\t\t\tvar key = [];\n\n\t\t\tfor ( var dimensionIndex in dimensions) {\n\t\t\t\t// Get dimension\n\t\t\t\tvar dimension = dimensions[dimensionIndex];\n\n\t\t\t\tfor (var i = 0; i < dimension.levels.length; i++) {\n\n\t\t\t\t\tvar level = dimension.levels[i];\n\t\t\t\t\tvar levelData = level.readCell(e);\n\n\t\t\t\t\trow[level.key().ref] = levelData.label;\n\n\t\t\t\t\t$(level.attributes).each(function(aidx, ae) {\n\t\t\t\t\t\tif (ae.ref != level.key().ref && ae.ref != level.label_attribute().ref) {\n\t\t\t\t\t\t\trow[ae.ref] = levelData.info[ae.ref];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var measureIndex in measures) {\n\t\t\t\tvar measure = measures[measureIndex];\n\t\t\t\trow[measure.ref] = e[measure.ref];\n\t\t\t}\n\n            for (var detailIndex in details) {\n\t\t\t\tvar detail = details[detailIndex];\n\t\t\t\trow[detail.ref] = e[detail.ref];\n\t\t\t}\n\n\t\t\t// Set key\n            row[\"id\"] = counter++;\n\t\t\tif (\"id\" in e) row[\"id\"] = e[\"id\"];\n\t\t\trow[\"key\"] = row[\"id\"];\n\n\t\t\trow[\"_cell\"] = e;\n\n\t\t\trows.push(row);\n\t\t});\n\n\t};\n\n\t$scope.$on(\"$destroy\", function() {\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t});\n\n\t$scope.initialize();\n\n}]);\n\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/filter/datefilter.html",
    "content": "<div class=\"cv-view-viewinfo-date\">\n    <div ng-repeat=\"datefilter in view.params.datefilters\" ng-controller=\"CubesViewerViewsCubeFilterDateController\" ng-init=\"dimparts = view.cube.dimensionParts(datefilter.dimension);\" class=\"label label-secondary cv-infopiece cv-view-viewinfo-cut text-left\" style=\"color: black; background-color: #ffdddd; text-align: left;\">\n        <span style=\"max-width: 280px; white-space: nowrap;\"><i class=\"fa fa-fw fa-filter\"></i> <b class=\"hidden-xs hidden-sm\">Filter:</b> {{ dimparts.labelNoLevel }}:</span>\n\n        <!--\n        <br class=\"hidden-sm hidden-md hidden-lg\" />\n        <i class=\"fa fa-fw hidden-sm hidden-md hidden-lg\" />\n         -->\n\n        <div class=\"cv-datefilter\" style=\"overflow: visible; display: inline-block;\">\n\n            <form class=\"form-inline\">\n\n                 <div class=\"form-group\" style=\"display: inline-block; margin: 0px;\">\n                    <div class=\"dropdown\" style=\"display: inline-block;\">\n                      <button ng-hide=\"view.getControlsHidden()\" style=\"height: 20px;\" class=\"btn btn-default btn-sm dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" data-submenu>\n                        <i class=\"fa fa-fw fa-calendar\"></i> {{ datefilter.mode | datefilterMode }} <span class=\"caret\"></span>\n                      </button>\n                      <span ng-show=\"view.getControlsHidden()\"><i class=\"fa fa-fw fa-calendar\"></i> {{ datefilter.mode | datefilterMode }}</span>\n\n                      <ul class=\"dropdown-menu cv-view-menu cv-view-menu-view\">\n                        <li ng-click=\"setMode('custom')\"><a><i class=\"fa fa-fw\"></i> Custom</a></li>\n                        <div class=\"divider\"></div>\n                        <li ng-click=\"setMode('auto-last1m')\"><a><i class=\"fa fa-fw\"></i> Last month</a></li>\n                        <li ng-click=\"setMode('auto-last3m')\"><a><i class=\"fa fa-fw\"></i> Last 3 months</a></li>\n                        <li ng-click=\"setMode('auto-last6m')\"><a><i class=\"fa fa-fw\"></i> Last 6 months</a></li>\n                        <li ng-click=\"setMode('auto-last12m')\"><a><i class=\"fa fa-fw\"></i> Last year</a></li>\n                        <li ng-click=\"setMode('auto-last24m')\"><a><i class=\"fa fa-fw\"></i> Last 2 years</a></li>\n                        <li ng-click=\"setMode('auto-january1st')\"><a><i class=\"fa fa-fw\"></i> From January 1st</a></li>\n                        <li ng-click=\"setMode('auto-yesterday')\"><a><i class=\"fa fa-fw\"></i> Yesterday</a></li>\n                      </ul>\n                  </div>\n                 </div>\n\n            <div ng-show=\"datefilter.mode == 'custom'\" style=\"display: inline-block; margin: 0px;\">\n\n                 &rArr;\n\n                 <div class=\"form-group\" style=\"display: inline-block; margin: 0px;\">\n                    <p class=\"input-group disabled\" style=\"margin: 0px; display: inline-block;\">\n                      <input ng-disabled=\"view.getControlsHidden()\" autocomplete=\"off\" type=\"text\" style=\"height: 20px; width: 80px; display: inline-block;\" class=\"form-control input-sm\" uib-datepicker-popup=\"yyyy-MM-dd\" ng-model=\"dateStart.value\" is-open=\"dateStart.opened\" datepicker-options=\"dateStart.options\" ng-required=\"true\" close-text=\"Close\" />\n                      <span ng-hide=\"view.getControlsHidden()\"  class=\"input-group-btn\" style=\"display: inline-block;\">\n                        <button type=\"button\" style=\"height: 20px;\" class=\"btn btn-default\" ng-click=\"dateStartOpen()\"><i class=\"fa fa-fw fa-calendar\"></i></button>\n                      </span>\n                    </p>\n                </div>\n\n                <span ng-hide=\"view.getControlsHidden()\" style=\"margin-left: 17px; margin-right: 0px;\">-</span>\n                <span ng-show=\"view.getControlsHidden()\" style=\"margin-left: 0px; margin-right: 0px;\">-</span>\n\n                 <div class=\"form-group\" style=\"display: inline-block; margin: 0px;\">\n                    <p class=\"input-group\" style=\"margin: 0px; display: inline-block;\">\n                      <input ng-disabled=\"view.getControlsHidden()\" autocomplete=\"off\" type=\"text\" style=\"height: 20px; width: 80px; display: inline-block;\" class=\"form-control input-sm\" uib-datepicker-popup=\"yyyy-MM-dd\" ng-model=\"dateEnd.value\" is-open=\"dateEnd.opened\" datepicker-options=\"dateEnd.options\" ng-required=\"true\" close-text=\"Close\" />\n                      <span ng-hide=\"view.getControlsHidden()\" class=\"input-group-btn\" style=\"display: inline-block;\">\n                        <button type=\"button\" style=\"height: 20px;\" class=\"btn btn-default\" ng-click=\"dateEndOpen()\"><i class=\"fa fa-fw fa-calendar\"></i></button>\n                      </span>\n                    </p>\n                </div>\n\n            </div>\n\n        </form>\n\n        </div>\n\n        <button type=\"button\" ng-hide=\"view.getControlsHidden()\" ng-click=\"selectDateFilter(datefilter.dimension, false)\" class=\"btn btn-danger btn-xs\" style=\"margin-left: 20px;\"><i class=\"fa fa-fw fa-trash\"></i></button>\n        <button type=\"button\" class=\"btn btn-info btn-xs\" style=\"visibility: hidden; margin-left: -20px;\"><i class=\"fa fa-fw fa-info\"></i></button>\n\n\n    </div>\n</div>\n\n"
  },
  {
    "path": "cubesviewer/views/cube/filter/datefilter.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Adds support for datefilters.\n *\n * This module requires that the model is configured\n * to declare which dimensions may use a datefilter,\n * and which fields of the dimension correspond to\n * calendar fields (year, quarter, month, day, week...).\n * (see integrator documentation for more information).\n *\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').filter(\"datefilterMode\", ['$rootScope', 'cvOptions',\n                                                          function ($rootScope, cvOptions) {\n\treturn function(val) {\n\t\tvar text = \"None\";\n\t\tswitch (val) {\n\t\t\tcase \"custom\": text = \"Custom\"; break;\n\t\t\tcase \"auto-last1m\": text = \"Last month\"; break;\n\t\t\tcase \"auto-last3m\": text = \"Last 3 months\"; break;\n\t\t\tcase \"auto-last6m\": text = \"Last 6 months\"; break;\n\t\t\tcase \"auto-last12m\": text = \"Last year\"; break;\n\t\t\tcase \"auto-last24m\": text = \"Last 2 years\"; break;\n\t\t\tcase \"auto-january1st\": text = \"From January 1st\"; break;\n\t\t\tcase \"auto-yesterday\": text = \"Yesterday\"; break;\n\t\t}\n\t\treturn text;\n\t};\n}]);\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeFilterDateController\", ['$rootScope', '$scope', '$filter', 'cvOptions', 'cubesService', 'viewsService',\n                                                                                        function ($rootScope, $scope, $filter, cvOptions, cubesService, viewsService) {\n\t$scope.initialize = function() {\n\t\t$scope.dateStart.value = $scope.datefilter.date_from ? new Date($scope.datefilter.date_from) : null;\n\t\t$scope.dateEnd.value = $scope.datefilter.date_to ? new Date($scope.datefilter.date_to) : null;\n\t};\n\n\t$scope.dateStart = {\n\t\topened: false,\n\t\tvalue: null,\n\t\toptions: {\n\t\t\t//dateDisabled: disabled,\n\t    \tformatYear: 'yyyy',\n\t    \t//maxDate: new Date(2020, 12, 31),\n\t    \t//minDate: new Date(1970, 1, 1),\n\t    \tstartingDay: cvOptions.datepickerFirstDay,\n\t    \tshowWeeks: cvOptions.datepickerShowWeeks\n\t    }\n\t};\n\t$scope.dateEnd = {\n\t\topened: false,\n\t\tvalue: null,\n\t\toptions: {\n\t\t\t//dateDisabled: disabled,\n\t    \tformatYear: 'yyyy',\n\t    \t//maxDate: new Date(2020, 12, 31),\n\t    \t//minDate: new Date(1970, 1, 1),\n\t    \tstartingDay: cvOptions.datepickerFirstDay,\n\t    \tshowWeeks: cvOptions.datepickerShowWeeks\n\t    }\n\t};\n\n\t$scope.dateStartOpen = function() {\n\t\t$scope.dateStart.opened = true;\n\t}\n\t$scope.dateEndOpen = function() {\n\t\t$scope.dateEnd.opened = true;\n\t}\n\n\t$scope.setMode = function(mode) {\n\t\t$scope.datefilter.mode = mode;\n\t};\n\n\t$scope.updateDateFilter = function() {\n\t\t$scope.datefilter.date_from = $scope.dateStart.value ? $filter('date')($scope.dateStart.value, \"yyyy-MM-dd\") : null;\n\t\t$scope.datefilter.date_to = $scope.dateEnd.value? $filter('date')($scope.dateEnd.value, \"yyyy-MM-dd\") : null;\n\t\t$scope.refreshView();\n\t}\n\n\t$scope.$watch(\"dateStart.value\", $scope.updateDateFilter);\n\t$scope.$watch(\"dateEnd.value\", $scope.updateDateFilter);\n\t$scope.$watch(\"datefilter.mode\", $scope.updateDateFilter);\n\n\t$scope.initialize();\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/filter/dimension.html",
    "content": "<div ng-controller=\"CubesViewerViewsCubeFilterDimensionController\">\n\n    <div class=\"panel panel-default panel-outline hidden-print\" ng-hide=\"view.getControlsHidden()\" style=\"border-color: #ffcccc;\">\n        <div class=\"panel-heading clearfix\" style=\"border-color: #ffcccc;\">\n            <button class=\"btn btn-xs btn-danger pull-right\" ng-click=\"closeDimensionFilter()\"><i class=\"fa fa-fw fa-close\"></i></button>\n            <h4 style=\"margin: 2px 0px 0px 0px;\"><i class=\"fa fa-fw fa-filter\"></i> Dimension filter: <b>{{ parts.label }}</b></h4>\n        </div>\n        <div class=\"panel-body\">\n\n            <div >\n            <form >\n\n              <div class=\"form-group has-feedback\" style=\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\">\n                <!-- <label for=\"search\">Search:</label>  -->\n                <input type=\"text\" class=\"form-control\" ng-model=\"searchString\" ng-model-options=\"{ debounce: 300 }\" placeholder=\"Search...\" style=\"width: 16em;\">\n                <i class=\"fa fa-fw fa-times-circle form-control-feedback\" ng-click=\"searchString = ''\" style=\"cursor: pointer; pointer-events: inherit;\"></i>\n              </div>\n\n              <div class=\"btn-group\" style=\"margin-left: 10px; display: inline-block; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\">\n                    <button class=\"btn btn-default\" ng-click=\"selectAll();\" type=\"button\" title=\"Select all\"><i class=\"fa fa-fw fa-check-square-o\"></i></button>\n                    <button class=\"btn btn-default\" ng-click=\"selectNone();\" type=\"button\" title=\"Select none\"><i class=\"fa fa-fw fa-square-o\"></i></button>\n              </div>\n\n<!--               <div class=\"form-group\" style=\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\"> -->\n              <div class=\"btn-group\" style=\"display: inline-block; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\">\n                    <button ng-hide=\"parts.hierarchy.levels.length < 2\" ng-disabled=\"! parts.drilldownDimensionMinus\"  class=\"btn btn-default\" ng-click=\"showDimensionFilter(parts.drilldownDimensionMinus)\" type=\"button\" title=\"Drilldown less\"><i class=\"fa fa-fw fa-minus\"></i></button>\n                    <button ng-hide=\"parts.hierarchy.levels.length < 2\" ng-disabled=\"! parts.drilldownDimensionPlus\"  class=\"btn btn-default\" ng-click=\"showDimensionFilter(parts.drilldownDimensionPlus)\" type=\"button\" title=\"Drilldown more\"><i class=\"fa fa-fw fa-plus\"></i></button>\n                    <button class=\"btn btn-default\" type=\"button\" title=\"Drilldown this\" ng-click=\"selectDrill(parts.drilldownDimension, true)\"><i class=\"fa fa-fw fa-arrow-down\"></i></button>\n              </div>\n\n              <div class=\"form-group\" style=\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px; margin-right: 5px;\">\n                 <div class=\"btn btn-default\" ng-click=\"filterShowAll = ! filterShowAll\" ng-class=\"{ 'active': filterShowAll, 'btn-info': filterShowAll }\">\n                    <i class=\"fa fa-fw fa-filter fa-rotate-180\"></i> Show all\n                 </div>\n              </div>\n\n              <div class=\"form-group\" style=\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px; \">\n\n                  <div class=\"btn btn-default\" ng-click=\"filterInverted = !filterInverted\" ng-class=\"{ 'active': filterInverted, 'btn-danger': filterInverted }\">\n                    <input type=\"checkbox\" ng-model=\"filterInverted\" style=\"pointer-events: none; margin: 0px; vertical-align: middle;\" ></input>\n                    <b>&ne;</b> Invert\n                  </div>\n\n              </div>\n\n                <div class=\"form-group\" style=\"display: inline-block; margin-bottom: 0; vertical-align: middle; margin-bottom: 2px;\">\n                 <button ng-click=\"applyFilter()\" class=\"btn btn-success\" type=\"button\"><i class=\"fa fa-fw fa-filter\"></i> Apply</button>\n              </div>\n            </form>\n            </div>\n\n            <div class=\"clearfix\"></div>\n\n            <div class=\"row\">\n                <div class=\"col-xs-9 col-sm-6\">\n                <div style=\"margin-top: 5px;\">\n                    <div class=\"panel panel-default panel-outline\" style=\"margin-bottom: 0px; \"><div class=\"panel-body\" style=\"max-height: 180px; overflow-y: auto; overflow-x: hidden;\">\n                        <div ng-show=\"loadingDimensionValues\" ><i class=\"fa fa-circle-o-notch fa-spin fa-fw\"></i> Loading...</div>\n\n                        <div ng-if=\"!loadingDimensionValues\">\n                            <div ng-repeat=\"val in dimensionValues | filter:filterDimensionValue(searchString)\" style=\"overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap;\">\n                                <label style=\"font-weight: normal; margin-bottom: 2px;\">\n                                    <input type=\"checkbox\" name=\"selectedValues[]\" ng-model=\"val.selected\" value=\"{{ ::val.value }}\" style=\"vertical-align: bottom;\" />\n                                    <span title=\"{{ val.label }}\">{{ ::val.label }}</span>\n                                </label>\n                            </div>\n                        </div>\n\n                    </div></div>\n\n                    <div ng-if=\"!loadingDimensionValues\" class=\"\" style=\"margin-bottom: 0px; \">\n                        <div class=\"text-right\">\n                            {{ dimensionValues.length }} items\n                        </div>\n                    </div>\n\n                    <div ng-if=\"!loadingDimensionValues && dimensionValues.length >= cubesService.cubesserver.info.json_record_limit\" class=\"alert alert-warning\" style=\"margin-bottom: 0px;\">\n                        <div style=\"display: inline-block;\"><i class=\"fa fa-exclamation\"></i></div>\n                        <div style=\"display: inline-block; margin-left: 20px;\">\n                            Limit of {{ cubesService.cubesserver.info.json_record_limit }} items has been hit. Dimension value list is <b>incomplete</b>.<br />\n                        </div>\n                    </div>\n\n                </div>\n                </div>\n            </div>\n\n            <div class=\"clearfix\"></div>\n\n        </div>\n      </div>\n\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/filter/dimension.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n\n/**\n */\n\n\"use strict\";\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeFilterDimensionController\", ['$rootScope', '$scope', '$filter', 'cvOptions', 'cubesService', 'viewsService',\n                                                     function ($rootScope, $scope, $filter, cvOptions, cubesService, viewsService) {\n\n\t$scope.parts = null;\n\t$scope.dimensionValues = null;\n\t$scope.loadingDimensionValues = false;\n\n\t$scope.searchString = \"\";\n\t$scope.selectedValues = null;\n\t$scope.filterInverted = null;\n\t$scope.filterShowAll = true;\n\n\t$scope.currentDataId = null;\n\n\t$scope.initialize = function() {\n\n\t\t// Check if current filter is inverted\n\t\tvar view = $scope.view;\n\t\tvar parts = view.cube.dimensionParts($scope.view.dimensionFilter);\n\t\tfor (var i = 0; i < view.params.cuts.length ; i++) {\n\t\t\tif (view.params.cuts[i].dimension == parts.cutDimension) {\n\t\t\t\t$scope.filterInverted = view.params.cuts[i].invert;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t$scope.$watch(\"view.dimensionFilter\", function() {\n\t\t$scope.parts = $scope.view.cube.dimensionParts($scope.view.dimensionFilter);\n\t\t$scope.loadDimensionValues();\n\t});\n\n\t$scope.$on(\"ViewRefresh\", function(view) {\n\t\t// FIXME: Update checkboxes, but do not reload.\n\t\t$scope.loadDimensionValues();\n\t});\n\t$scope.$watch(\"filterShowAll\", function(view) {\n\t\t$scope.loadDimensionValues();\n\t});\n\n\n\t$scope.closeDimensionFilter = function() {\n\t\t$scope.view.dimensionFilter = null;\n\t};\n\n\t/*\n\t * Load dimension values.\n\t */\n\t$scope.loadDimensionValues = function() {\n\n\t\tvar params = {\n\t\t\t\"hierarchy\": $scope.parts.hierarchy.name,\n\t\t\t\"depth\": $scope.parts.depth\n\t\t};\n\n\t\t//view.cubesviewer.views.blockViewLoading(view);\n\n\t\tif (! $scope.filterShowAll) {\n\n\t\t\tvar parts = $scope.view.cube.dimensionParts($scope.view.dimensionFilter);\n\t\t\tvar buildQueryCutsStrings = cubesService.buildQueryCutsStrings($scope.view);\n\n\t\t\tif (buildQueryCutsStrings.length > 0) {\n\t\t\t\t// Remove current dimension\n\t\t\t\tbuildQueryCutsStrings = $.grep(buildQueryCutsStrings, function(cs) {\n\t\t\t\t\treturn ((cs.indexOf(parts.dimension.name) != 0) && (cs.indexOf(\"!\" + parts.dimension.name) != 0));\n\t\t\t\t});\n\n\t\t\t\tparams[\"cut\"] = buildQueryCutsStrings.join(cubes.CUT_STRING_SEPARATOR_CHAR);\n\t\t\t}\n\n\t\t};\n\n\t\tvar path = \"/cube/\" + $scope.view.cube.name + \"/members/\" + $scope.parts.dimension.name;\n\t\tvar dataId = path + \"?\" + $.param(params);\n\t\tif ($scope.currentDataId == dataId) { return; }\n\t\t$scope.currentDataId = dataId;\n\n\t\tvar tdimension = $scope.view.dimensionFilter;\n\t\t$scope.loadingDimensionValues = true;\n\t\tvar jqxhr = cubesService.cubesRequest(\n                // Doc says it's dimension, not members\n\t\t\t\tpath,\n\t\t\t\tparams,\n\t\t\t\t$scope._loadDimensionValuesCallback(tdimension));\n\t\tjqxhr.always(function() {\n\t\t\t//unblockView\n\t\t\t$scope.loadingDimensionValues = false;\n\t\t\t$scope.$apply();\n\t\t});\n\n\t};\n\n\t/*\n\t * Updates info after loading data.\n\t */\n\t$scope._loadDimensionValuesCallback = function(dimension) {\n\t\tvar dimension = dimension;\n\t\treturn function(data, status) {\n\t\t\tif ($scope.view.dimensionFilter == dimension) $scope._processDimensionValuesData(data);\n\t\t};\n\t};\n\n\t$scope.filterDimensionValue = function(searchString) {\n\t\treturn function(item) {\n\t\t\tvar lowerCaseSearch = searchString.toLowerCase();\n\t\t\treturn ((searchString == \"\") || (item.label.toLowerCase().indexOf(lowerCaseSearch) >= 0));\n\t\t};\n\t};\n\n\t$scope.selectAll = function() {\n\t\tvar filter = $scope.filterDimensionValue($scope.searchString);\n\t\t$($scope.dimensionValues).each(function(idx, val) {\n\t\t\tif (filter(val)) val.selected = true;\n\t\t});\n\t};\n\n\t$scope.selectNone = function() {\n\t\tvar filter = $scope.filterDimensionValue($scope.searchString);\n\t\t$($scope.dimensionValues).each(function(idx, val) {\n\t\t\tif (filter(val)) val.selected = false;\n\t\t});\n\t};\n\n\t$scope._processDimensionValuesData = function(data) {\n\n\t\t// Get dimension\n\t\tvar view = $scope.view;\n\t\tvar dimension = $scope.view.cube.cvdim_dim($scope.view.dimensionFilter);\n\t\tvar dimensionValues = [];\n\n\t\tvar parts = view.cube.dimensionParts($scope.view.dimensionFilter);\n\t\t//var cutDimension = parts.dimension.name + ( parts.hierarchy.name != \"default\" ? \"@\" + parts.hierarchy.name : \"\" );\n\n\t\tvar filterValues = [];\n\t\tfor (var i = 0; i < view.params.cuts.length ; i++) {\n\t\t\tif (view.params.cuts[i].dimension == view.cube.dimensionParts($scope.view.dimensionFilter).cutDimension) {\n\t\t\t\t$scope.filterInverted = view.params.cuts[i].invert;\n\t\t\t\tfilterValues = view.params.cuts[i].value.split(\";\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t$(data.data).each( function(idx, e) {\n\n\t\t\t// Get dimension\n\t\t\tvar parts = $scope.view.cube.dimensionParts($scope.view.dimensionFilter);\n\t\t\tvar infos = parts.hierarchy.readCell(e, parts.level);\n\n\t\t\t// Values and Labels\n\t\t\tvar drilldownLevelValues = [];\n\t\t\tvar drilldownLevelLabels = [];\n\n\t\t\t$(infos).each(function(idx, info) {\n\t\t\t\tdrilldownLevelValues.push(info.key);\n\t\t\t\tdrilldownLevelLabels.push(info.label);\n\t\t\t});\n\n\t\t\tdimensionValues.push({\n\t\t\t\t'label': drilldownLevelLabels.join(' / '),\n\t\t\t\t'value': drilldownLevelValues.join (','),\n\t\t\t\t'selected': filterValues.indexOf(drilldownLevelValues.join (',')) >= 0\n\t\t\t});\n\n\t\t});\n\n\t\t$scope.dimensionValues = dimensionValues;\n\t\t$scope.$apply();\n\t};\n\n\t/*\n\t * Updates info after loading data.\n\t */\n\t$scope.applyFilter = function() {\n\n\t\tvar view = $scope.view;\n\n\t\tvar filterValues = [];\n\t\t$($scope.dimensionValues).each(function(idx, val) {\n\t\t\tif (val.selected) filterValues.push(val.value);\n\t\t});\n\n\t\t// If all values are selected, the filter is empty and therefore removed by selectCut\n\t\tif (filterValues.length >= $scope.dimensionValues.length) filterValues = [];\n\n\t\t// Cut dimension\n\t\tvar cutDimension = $scope.parts.dimension.name + ( $scope.parts.hierarchy.name != \"default\" ? \"@\" + $scope.parts.hierarchy.name : \"\" ) + ':' + $scope.parts.level.name;\n\t\t$scope.selectCut(cutDimension, filterValues.join(\";\"), $scope.filterInverted);\n\n\t};\n\n\n\t$scope.initialize();\n\n}]);\n\n"
  },
  {
    "path": "cubesviewer/views/cube/filter/rangefilter.js.old",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Adds support for rangefilters.\n *\n * This plugin requires that the model is configured\n * to declare which dimensions may use a rangefilter\n * (see integrator documentation for more information).\n *\n * This is an optional plugin.\n * Depends on the cube.explore plugin.\n */\nfunction cubesviewerViewCubeRangeFilter () {\n\n\tthis.cubesviewer = cubesviewer;\n\n\tthis._overridedbuildQueryCuts = null;\n\n\tthis.onViewCreate = function(event, view) {\n\n\t\t$.extend(view.params, {\n\n\t\t\t\"rangefilters\" : [],\n\n\t\t});\n\n\t}\n\n\n\t/*\n\t * Draw cube view structure.\n\t */\n\tthis.onViewDraw = function(event, view) {\n\n\t\tif (view.cube == null) return;\n\t\tvar cube = view.cube;\n\n\t\t// Draw menu options (depending on mode)\n\t\tview.cubesviewer.views.cube.rangefilter.drawFilterMenu(view);\n\n\t\t// Draw info boxes\n\t\tview.cubesviewer.views.cube.rangefilter.drawInfo(view);\n\n\t};\n\n\n\n\t/*\n\t * Draw rangefilter options in the cut menu.\n\t */\n\tthis.drawFilterMenu = function(view) {\n\n\t\tvar cube = view.cube;\n\t\tvar menu = $(\".cv-view-menu-cut\", $(view.container));\n\n\t\tvar rangeFilterElements = \"\";\n\t\t$(cube.dimensions).each( function(idx, dimension) {\n\n\t\t\tif (dimension.isRangeDimension()) {\n\n\t\t\t\tvar disabled = \"\";\n\t\t\t\trangeFilterElements = rangeFilterElements + '<li><a href=\"#\" class=\"selectRangeFilter '  + disabled +\n\t\t\t\t\t'\" data-dimension=\"' + dimension.name + '\" data-value=\"1\">' + dimension.label +\n\t\t\t\t\t'</a></li>';\n\t\t\t}\n\n\t\t});\n\t\tif (rangeFilterElements == \"\") {\n\t\t\trangeFilterElements = rangeFilterElements + '<li><a href=\"#\" onclick=\"return false;\"><i>No range filters defined</i></a></li>';\n\t\t}\n\n\t\t$(\".ui-explore-cut-clearsep\", menu).before(\n\t\t\t\t'<li><a href=\"#\" onclick=\"return false;\"><span class=\"ui-icon ui-icon-zoomin\"></span>Range filter</a><ul class=\"rangeFilterList\" style=\"width: 180px;\">' +\n\t\t\t\trangeFilterElements +\n\t\t\t\t'</ul></li>'\n\t\t);\n\n\t\t$(menu).menu(\"refresh\");\n\t\t$(menu).addClass(\"ui-menu-icons\");\n\n\t\t$(view.container).find('.selectRangeFilter').click( function() {\n\t\t\tcubesviewer.views.cube.rangefilter.selectRangeFilter(view, $(this).attr('data-dimension'), $(this).attr('data-value'));\n\t\t\treturn false;\n\t\t});\n\n\t};\n\n\n\t// Draw information bubbles\n\tthis.drawInfo = function(view, readonly) {\n\n\t\t$(view.container).find('.cv-view-viewinfo-cut').after(\n\t\t\t\t'<div class=\"cv-view-viewinfo-range\"></div>'\n\t\t);\n\n\t\t$(view.params.rangefilters).each( function(idx, e) {\n\t\t\tvar dimparts = view.cube.dimensionParts(e.dimension);\n\t\t\tvar piece = cubesviewer.views.cube.explore.drawInfoPiece(\n\t\t\t\t\t$(view.container).find('.cv-view-viewinfo-range'), \"#ffe8dd\", null, readonly,\n\t\t\t\t\t'<span class=\"ui-icon ui-icon-zoomin\"></span> <span><b>Filter: </b> ' +\n\t\t\t\t\tdimparts.labelNoLevel +\n\t\t\t\t\t': </span><span class=\"rangefilter\"></span>')\n\t\t\tvar container = $('.rangefilter', piece);\n\t\t\tview.cubesviewer.views.cube.rangefilter.drawRangeFilter(view, e, container);\n\n\t\t\tpiece.find('.cv-view-infopiece-close').click(function() {\n\t\t\t\tview.cubesviewer.views.cube.rangefilter.selectRangeFilter(view, e.dimension, \"0\");\n\t\t\t});\n\t\t});\n\n\t\tif (readonly) {\n\t\t\t$(view.container).find('.infopiece').find('.ui-icon-close')\n\t\t\t\t\t.parent().remove();\n\t\t}\n\n\t};\n\n\n\tthis.drawRangeFilter = function(view, rangefilter, container) {\n\n\t\tvar dimparts = view.cube.dimensionParts(rangefilter.dimension);\n\n\t\t$(container).append(\n\t\t\t'<input name=\"range_start\" /> - '\n\t\t\t+ '<input name=\"range_end\" /> '\n\t\t);\n\n\t\tvar slider = dimparts.dimension.info[\"cv-rangefilter-slider\"];\n\t\tif (slider != null) {\n\t\t\t$(container).append(\n\t\t\t\t'<div style=\"display: inline-block; margin-left: 8px; margin-right: 8px; vertical-align: middle;\">' +\n\t\t\t\t'<span style=\"font-size: 70%;\">' + slider.min + '</span>' +\n\t\t\t\t'<span class=\"slider-range\" style=\"width: 180px; display: inline-block; margin-left: 6px; margin-right: 6px; vertical-align: middle;\"></span>' +\n\t\t\t\t'<span style=\"font-size: 70%;\">' + slider.max + '</span></div>'\n\t\t\t);\n\t\t}\n\n\t\t//$(\"[name='range_start']\", container).attr('autocomplete', 'off');\n\t\t//$(\"[name='range_end']\", container).attr('autocomplete', 'off');\n\n\t\t// Functionality\n\t\t$(\"input\", container).change(function() {\n\t\t\tview.cubesviewer.views.cube.rangefilter._updateRangeFilter(view, rangefilter);\n\t\t});\n\n\t\t// Set initial values\n\t\t$(\"[name='range_start']\", container).val(rangefilter.range_from);\n\t\t$(\"[name='range_end']\", container).val(rangefilter.range_to);\n\n\t\t// Slider\n\t\tif (slider) {\n\t\t\t$(\".slider-range\", container).slider({\n\t\t\t\trange: true,\n\t\t\t\tmin: slider.min ,\n\t\t\t\tmax: slider.max ,\n\t\t\t\tstep: slider.step ? slider.step : 1,\n\t\t\t\tvalues: [ rangefilter.range_from ? rangefilter.range_from : slider.min, rangefilter.range_to ? rangefilter.range_to : slider.max ],\n\t\t\t\tslide: function( event, ui ) {\n\t\t\t\t\t$(\"[name='range_start']\", container).val(ui.values[ 0 ]);\n\t\t\t\t\t$(\"[name='range_end']\", container).val(ui.values[ 1 ]);\n\t\t\t\t},\n\t\t\t\tstop: function(event, ui) {\n\t\t\t\t\tview.cubesviewer.views.cube.rangefilter._updateRangeFilter(view, rangefilter);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t};\n\n\tthis._updateRangeFilter = function (view, rangefilter) {\n\t\tvar changed = false;\n\t\tvar container = view.container;\n\t\tif (rangefilter.range_from != $(\"[name='range_start']\", container).val()) {\n\t\t\trangefilter.range_from = $(\"[name='range_start']\", container).val();\n\t\t\tchanged = true;\n\t\t}\n\t\tif (rangefilter.range_to != $(\"[name='range_end']\", container).val()) {\n\t\t\trangefilter.range_to = $(\"[name='range_end']\", container).val();\n\t\t\tchanged = true;\n\t\t}\n\t\tif (changed) view.cubesviewer.views.redrawView (view);\n\t};\n\n\t// Adds a date filter\n\tthis.selectRangeFilter = function(view, dimension, enabled) {\n\n\t\tvar cube = view.cube;\n\n\t\t// TODO: Show a notice if the dimension already has a date filter (? and cut filter)\n\n\t\tif (dimension != \"\") {\n\t\t\tif (enabled == \"1\") {\n\t\t\t\tview.params.rangefilters.push({\n\t\t\t\t\t\"dimension\" : dimension,\n\t\t\t\t\t\"range_from\" : null,\n\t\t\t\t\t\"range_to\" : null\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tfor ( var i = 0; i < view.params.rangefilters.length; i++) {\n\t\t\t\t\tif (view.params.rangefilters[i].dimension.split(':')[0] == dimension) {\n\t\t\t\t\t\tview.params.rangefilters.splice(i, 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tview.params.rangefilters = [];\n\t\t}\n\n\t\tview.cubesviewer.views.redrawView(view);\n\n\t};\n\n\t/*\n\t * Composes a filter with appropriate syntax and time grain from a\n\t * rangefilter\n\t */\n\tthis.rangefilterValue = function(rangefilter) {\n\n\t\tvar range_from = rangefilter.range_from;\n\t\tvar range_to = rangefilter.range_to;\n\n\t\tif ((range_from != null) || (range_to != null)) {\n\t\t\tvar rangefiltervalue = \"\";\n\t\t\tif (range_from != null)\n\t\t\t\trangefiltervalue = rangefiltervalue + range_from;\n\t\t\trangefiltervalue = rangefiltervalue + \"-\";\n\t\t\tif (range_to != null)\n\t\t\t\trangefiltervalue = rangefiltervalue + range_to;\n\t\t\treturn rangefiltervalue;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\n\t};\n\n\n\t/*\n\t * Builds Query Cuts (overrides default cube cut build function).\n\t */\n\tthis.buildQueryCuts = function(view) {\n\n\t\t// Include cuts and rangefilters\n\t\tvar cuts = cubesviewer.views.cube.rangefilter._overridedbuildQueryCuts(view);\n\n\t\t$(view.params.rangefilters).each(function(idx, e) {\n\t\t\tvar rangefiltervalue = view.cubesviewer.views.cube.rangefilter.rangefilterValue(e);\n\t\t\tif (rangefiltervalue != null) {\n\t\t\t\tcuts.push(e.dimension + \":\" + rangefiltervalue);\n\t\t\t}\n\t\t});\n\n\t\treturn cuts;\n\n\t};\n\n}\n\n/*\n * Extend model prototype to support rangefilter dimensions.\n */\ncubes.Dimension.prototype.isRangeDimension = function() {\n\n\treturn (\"cv-rangefilter\" in this.info && this.info[\"cv-rangefilter\"] == true);\n\n};\n\n/*\n * Create object.\n */\ncubesviewer.views.cube.rangefilter = new cubesviewerViewCubeRangeFilter();\n\n/*\n * Override original Cut generation function to add support for rangefilters\n */\ncubesviewer.views.cube.rangefilter._overridedbuildQueryCuts = cubesviewer.views.cube.buildQueryCuts;\ncubesviewer.views.cube.buildQueryCuts = cubesviewer.views.cube.rangefilter.buildQueryCuts;\n\n/*\n * Bind events.\n */\n$(document).bind(\"cubesviewerViewCreate\", { }, cubesviewer.views.cube.rangefilter.onViewCreate);\n$(document).bind(\"cubesviewerViewDraw\", { }, cubesviewer.views.cube.rangefilter.onViewDraw);\n\n"
  },
  {
    "path": "cubesviewer/views/cube/series/operations.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Sof\ttware, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n\n/**\n * Manipulates series.\n */\n\n\"use strict\";\n\nangular.module('cv.views').service(\"seriesOperationsService\", ['$rootScope', 'cvOptions', 'cubesService',\n                                                               function ($rootScope, cvOptions, cubesService) {\n\n\tthis.calculateDifferentials = function(view, rows, columnDefs) {\n\n\t\tconsole.debug(\"FIXME: Differentials are ignoring drilldown.length columns, but fails in some cases.\");\n\n\t\t$(rows).each(function(idx, e) {\n\t\t\tvar lastValue = null;\n\t\t\tfor (var i = view.params.drilldown.length; i < columnDefs.length; i++) {\n\t    \t\tvar value = e[columnDefs[i].field];\n\t    \t\tvar diff = null;\n\t    \t\tif ((lastValue != null) && (value != null)) {\n\t    \t\t\tvar diff = value - lastValue;\n\t    \t\t\te[columnDefs[i].field] = diff;\n\t    \t\t} else {\n\t    \t\t\tdelete e[columnDefs[i].field];\n\t    \t\t\t//e[columnDefs[i].field] = null;\n\t    \t\t}\n\t    \t\tlastValue = value;\n\t    \t}\n\t\t});\n\n\t};\n\n\tthis.calculateDifferentialsPercent = function(view, rows, columnDefs) {\n\n\t\tconsole.debug(\"FIXME: Differentials are ignoring drilldown.length columns, but fails in some cases.\");\n\n\t\t$(rows).each(function(idx, e) {\n\t\t\tvar lastValue = null;\n\t\t\tfor (var i = view.params.drilldown.length; i < columnDefs.length; i++) {\n\t    \t\tvar value = e[columnDefs[i].field];\n\t    \t\tvar diff = null;\n\t    \t\tif ((lastValue != null) && (value != null)) {\n\t    \t\t\tvar diff = (value - lastValue) / lastValue;\n\t    \t\t\te[columnDefs[i].field] = diff;\n\t    \t\t} else {\n\t    \t\t\tdelete e[columnDefs[i].field];\n\t    \t\t\t//e[columnDefs[i].field] = null;\n\t    \t\t}\n\t    \t\tlastValue = value;\n\t    \t}\n\t\t});\n\n\t};\n\n\tthis.calculateAccum = function(view, rows, columnDefs) {\n\n\t};\n\n\tthis.applyCalculations = function(view, rows, columnDefs) {\n\t\tif (view.params.calculation == \"difference\") {\n\t\t\tthis.calculateDifferentials(view, rows, columnDefs);\n\t\t}\n\t\tif (view.params.calculation == \"percentage\") {\n\t\t\tthis.calculateDifferentialsPercent(view, rows, columnDefs);\n\t\t}\n\t};\n\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/cube/series/series.html",
    "content": "<div ng-controller=\"CubesViewerViewsCubeSeriesController\">\n\n    <!-- ($(view.container).find('.cv-view-viewdata').children().size() == 0)  -->\n    <h3><i class=\"fa fa-fw fa-clock-o\"></i> Series table\n        <i ng-show=\"view.pendingRequests > 0\" class=\"fa fa-circle-o-notch fa-spin fa-fw margin-bottom text-info pull-right\"></i>\n    </h3>\n\n    <div ng-if=\"view.pendingRequests > 0\" class=\"loadingbar-content\">\n        <span class=\"loadingbar-expand\"></span>\n    </div>\n\n    <div ng-if=\"view.grid.data.length > 0\"\n         ui-grid=\"view.grid\"\n         ui-grid-resize-columns ui-grid-move-columns ui-grid-selection ui-grid-auto-resize\n         ui-grid-pagination ui-grid-pinning\n         style=\"width: 100%;\" ng-style=\"{height: ((view.grid.data.length < 15 ? view.grid.data.length : 15) * 24) + 44 + 30 + 'px'}\">\n    </div>\n    <div ng-if=\"view.grid.data.length > 0\" style=\"height: 30px;\">&nbsp;</div>\n\n    <div ng-if=\"view.pendingRequests == 0 && view.params.yaxis == null\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n        <p>\n            Cannot present series table: no <b>measure</b> has been selected.\n        </p>\n        <p>\n            Tip: use the <kbd><i class=\"fa fa-fw fa-cogs\"></i> View &gt; <i class=\"fa fa-fw fa-crosshairs\"></i> Measure</kbd> menu.\n        </p>\n    </div>\n\n    <div ng-if=\"view.pendingRequests == 0 && view.params.yaxis != null && view.grid.data.length == 0\" class=\"alert alert-info\" style=\"margin-bottom: 0px;\">\n        <p>\n            Cannot present series table: <b>no rows</b> are returned by the current horizontal dimension, drilldown or filtering combination.\n        </p>\n        <p>\n            Tip: use the <kbd><i class=\"fa fa-fw fa-cogs\"></i> View</kbd> menu to select an horizontal dimension.\n        </p>\n    </div>\n\n</div>\n"
  },
  {
    "path": "cubesviewer/views/cube/series/series.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Sof\ttware, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n\n/**\n * Manipulates series.\n */\n\n\"use strict\";\n\n\n/**\n * SeriesTable object. This is part of the \"cube\" view. Allows the user to select\n * a dimension to use as horizontal axis of a table. This is later used to generate\n * charts.\n */\nangular.module('cv.views.cube').controller(\"CubesViewerViewsCubeSeriesController\", ['$rootScope', '$scope', '$timeout', 'cvOptions', 'cubesService', 'viewsService', 'seriesOperationsService',\n                                                     function ($rootScope, $scope, $timeout, cvOptions, cubesService, viewsService, seriesOperationsService) {\n\n\t$scope.view.grid.enableRowSelection = false;\n\t$scope.view.grid.enableRowHeaderSelection = false;\n\n\t$scope.initialize = function() {\n\t\t$scope.view.params = $.extend(\n\t\t\t{},\n\t\t\t{ \"xaxis\" : null, \"yaxis\" : null },\n\t\t\t$scope.view.params\n\t\t);\n\t\t$scope.refreshView();\n\t};\n\n\t$scope.$on(\"ViewRefresh\", function(view) {\n\t\t$scope.loadData();\n\t});\n\n\t$scope.loadData = function() {\n\n\t\tvar view = $scope.view;\n\n\t\t// Check if we can produce a table\n\t\tif (view.params.yaxis == null) return;\n\n\t\tvar browser_args = cubesService.buildBrowserArgs($scope.view, $scope.view.params.xaxis != null ? true : false, false);\n\t\tvar browser = new cubes.Browser(cubesService.cubesserver, $scope.view.cube);\n\t\tvar viewStateKey = $scope.newViewStateKey();\n\t\tvar jqxhr = browser.aggregate(browser_args, $scope._loadDataCallback(viewStateKey));\n\n\t\t$scope.view.pendingRequests++;\n\t\tjqxhr.always(function() {\n\t\t\t$scope.view.pendingRequests--;\n\t\t\t$rootScope.$apply();\n\t\t});\n\t\tjqxhr.error($scope.requestErrorHandler);\n\n\t};\n\n\t$scope._loadDataCallback = function(viewStateKey) {\n\t\treturn function(data, status) {\n\t\t\t// Only update if view hasn't changed since data was requested.\n\t\t\tif (viewStateKey == $scope._viewStateKey) {\n\t\t\t\t$scope.validateData(data, status);\n\t\t\t\t$scope.processData(data);\n\t\t\t\t$rootScope.$apply();\n\t\t\t}\n\t\t};\n\t};\n\n\t$scope.processData = function(data) {\n\n\t\tvar view = $scope.view;\n\n\t\t//$scope.rawData = data;\n\n\t\t$scope.resetGrid();\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t\t$rootScope.$apply();\n\n\t\t// Configure grid\n\t\tangular.extend($scope.view.grid, {\n\t\t\tdata: [],\n    \t\t//minRowsToShow: 3,\n    \t\trowHeight: 24,\n    \t\tonRegisterApi: $scope.onGridRegisterApi,\n    \t\tenableColumnResizing: true,\n    \t\tshowColumnFooter: false,\n    \t\tenableGridMenu: true,\n    \t\t//showGridFooter: false,\n    \t    paginationPageSizes: cvOptions.pagingOptions,\n    \t    paginationPageSize: cvOptions.pagingOptions[0],\n    \t\t//enableHorizontalScrollbar: 0,\n    \t\t//enableVerticalScrollbar: 0,\n    \t\tenableRowSelection: false,\n    \t\tenableRowHeaderSelection: false,\n    \t\t//enableSelectAll: false,\n    \t\tenablePinning: false,\n    \t\tmultiSelect: false,\n    \t\tselectionRowHeaderWidth: 20,\n    \t\t//rowHeight: 50,\n    \t\tcolumnDefs: []\n\t    });\n\n\t\t// Process data\n\t\t//$scope._sortData (data.cells, view.params.xaxis != null ? true : false);\n\t    $scope._addRows($scope, data);\n\t    seriesOperationsService.applyCalculations($scope.view, $scope.view.grid.data, view.grid.columnDefs);\n\n\t    /*\n\t    // TODO: Is this needed?\n\n\t\tcolNames.forEach(function (e) {\n\t\t\tvar colLabel = null;\n\t\t\t$(view.cube.aggregates).each(function (idx, ag) {\n\t\t\t\tif (ag.name == e) {\n\t\t\t\t\tcolLabel = ag.label||ag.name;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!colLabel) {\n\t\t\t\t$(view.cube.measures).each(function (idx, me) {\n\t\t\t\t\tif (me.name == e) {\n\t\t\t\t\t\tcolLabel = me.label||ag.name;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\t//colLabel = view.cube.getDimension(e).label\n\t\t\tcolLabels.push(colLabel||e);\n\t\t});\n\t\t*/\n\n\t};\n\n\n\t/*\n\t * Adds rows.\n\t */\n\t$scope._addRows = cubesviewer._seriesAddRows;\n\n\t$scope.$on(\"$destroy\", function() {\n\t\t$scope.view.grid.data = [];\n\t\t$scope.view.grid.columnDefs = [];\n\t});\n\n\t$scope.initialize();\n\n}]);\n\ncubesviewer._seriesAddRows = function($scope, data) {\n\n\tvar view = $scope.view;\n\tvar rows = view.grid.data;\n\n\tvar counter = 0;\n\tvar dimensions = view.cube.dimensions;\n\tvar measures = view.cube.measures;\n    var details = view.cube.details;\n\n\t// Copy drilldown as we'll modify it\n\tvar drilldown = view.params.drilldown.slice(0);\n\n\t// Include X Axis if necessary\n\tif (view.params.xaxis != null) {\n\t\tdrilldown.splice(0,0, view.params.xaxis);\n\t}\n\tvar baseidx = ((view.params.xaxis == null) ? 0 : 1);\n\n\tvar addedCols = [];\n\t$(data.cells).each(function (idx, e) {\n\n\t\tvar row = [];\n\t\tvar key = [];\n\t\tvar nid = [];\n\n\t\t// For the drilldown level, if present\n\t\tfor (var i = 0; i < drilldown.length; i++) {\n\n\t\t\t// Get dimension\n\t\t\tvar parts = view.cube.dimensionParts(drilldown[i]);\n\t\t\tvar infos = parts.hierarchy.readCell(e, parts.level);\n\n\t\t\t// Values and Labels\n\t\t\tvar drilldownLevelValues = [];\n\t\t\tvar drilldownLevelLabels = [];\n\n\t\t\t$(infos).each(function(idx, info) {\n\t\t\t\tdrilldownLevelValues.push(info.key);\n\t\t\t\tdrilldownLevelLabels.push(info.label);\n\t\t\t});\n\n\t\t\tkey.push (drilldownLevelLabels.join(\" / \"));\n\t\t\tnid.push(drilldownLevelValues.join('-'));\n\t\t}\n\n\t\t// Set key\n\t\tvar colKey = (view.params.xaxis == null) ? view.params.yaxis : key[0];\n\t\tvar value = (e[view.params.yaxis]);\n\t\tvar rowKey = (view.params.xaxis == null) ? nid.join ('-') : nid.slice(1).join ('-');\n\n\t\t// Search or introduce\n\t\tvar row = $.grep(rows, function(ed) { return ed[\"key\"] == rowKey; });\n\t\tif (row.length > 0) {\n\t\t\trow[0][colKey] = value;\n\t\t\trow[0][\"_cell\"] = e;\n\t\t} else {\n\t\t\tvar newrow = {};\n\t\t\tnewrow[\"key\"] = rowKey;\n\t\t\tnewrow[colKey] = value;\n\n\t\t\tfor (var i = baseidx ; i < key.length; i++) {\n\t\t\t\tnewrow[\"key\" + (i - baseidx)] = key[i];\n\t\t\t}\n\n\t\t\tnewrow[\"_cell\"] = e;\n\t\t\trows.push ( newrow );\n\t\t}\n\n\n\t\t// Add column definition if the column hasn't been added yet\n\t\tif (addedCols.indexOf(colKey) < 0) {\n\t\t\taddedCols.push(colKey);\n\n\t\t\tvar ag = $.grep(view.cube.aggregates, function(ag) { return ag.ref == view.params.yaxis })[0];\n\n\t\t\tvar col = {\n\t\t\t\tname: colKey,\n\t\t\t\tfield: colKey,\n\t\t\t\tindex : colKey,\n\t\t\t\tcellClass : \"text-right\",\n\t\t\t\t//sorttype : \"number\",\n\t\t\t\tcellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t\tformatter: $scope.columnFormatFunction(ag),\n\t\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t\t//formatoptions: {},\n\t\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>';\n\t\t\t\tenableHiding: false,\n\t\t\t\twidth: $scope.defineColumnWidth(colKey, 90),\n\t\t\t\tsort: $scope.defineColumnSort(colKey),\n\t\t\t};\n\t\t\tview.grid.columnDefs.push(col);\n\t\t}\n\t});\n\n\t//var label = [];\n\t$(view.params.drilldown).each (function (idx, e) {\n\t\tvar col = {\n\t\t\tname: view.cube.cvdim_dim(e).label,\n\t\t\tfield: \"key\" + idx,\n\t\t\tindex : \"key\" + idx,\n\t\t\theaderCellClass: \"cv-grid-header-dimension\",\n\t\t\tenableHiding: false,\n\t\t\t//cellClass : \"text-right\",\n\t\t\t//sorttype : \"number\",\n\t\t\t//cellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t//formatter: $scope.columnFormatFunction(ag),\n\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t//formatoptions: {},\n\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>';\n\t\t\twidth : $scope.defineColumnWidth(\"key\" + idx, 190),\n\t\t\tsort: $scope.defineColumnSort(\"key\" + idx),\n\t\t\tsortingAlgorithm: $scope.sortDimensionParts(view.cube.dimensionParts(e))\n\t\t};\n\t\tview.grid.columnDefs.splice(idx, 0, col);\n\t});\n\n\tif (view.params.drilldown.length == 0 && rows.length > 0) {\n\t\trows[0][\"key0\"] = view.cube.aggregateFromName(view.params.yaxis).label;\n\n\t\tvar col = {\n\t\t\tname: \"Measure\",\n\t\t\tfield: \"key0\",\n\t\t\tindex : \"key0\",\n\t\t\theaderCellClass: \"cv-grid-header-measure\",\n\t\t\tenableHiding: false,\n\t\t\t//cellClass : \"text-right\",\n\t\t\t//sorttype : \"number\",\n\t\t\t//cellTemplate: '<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{ col.colDef.formatter(COL_FIELD, row, col) }}</div>',\n\t\t\t//formatter: $scope.columnFormatFunction(ag),\n\t\t\t//footerValue: $scope.columnFormatFunction(ag)(data.summary[ag.ref], null, col)\n\t\t\t//formatoptions: {},\n\t\t\t//cellattr: cubesviewer.views.cube.explore.columnTooltipAttr(ag.ref),\n\t\t\t//footerCellTemplate = '<div class=\"ui-grid-cell-contents text-right\">{{ col.colDef.footerValue }}</div>';\n\t\t\twidth : $scope.defineColumnWidth(\"key0\", 190),\n\t\t\tsort: $scope.defineColumnSort(\"key0\")\n\t\t};\n\t\tview.grid.columnDefs.splice(0, 0, col);\n\t}\n\n};\n\n"
  },
  {
    "path": "cubesviewer/views/undo.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/*\n * Undo/Redo plugin.\n */\n\n\"use strict\";\n\n\nangular.module('cv.views.cube').controller(\"CubesViewerViewsUndoController\", ['$rootScope', '$scope', '$timeout', '$element', 'cvOptions', 'cubesService', 'viewsService',\n                                                                                   function ($rootScope, $scope, $timeout, $element, cvOptions, cubesService, viewsService) {\n\n  \t$scope.initialize = function() {\n  \t\t// Add chart view parameters to view definition\n  \t\t$scope.view.undoList = [];\n  \t\t$scope.view.undoPos = -1;\n  \t};\n\n  \t$scope.initialize();\n\n  \t$scope.$on('ViewRefresh', function(view) { $scope._processState(view); });\n\n\t$scope._processState = function() {\n\n\t\tvar drawn = viewsService.serializeView($scope.view);\n\t\tvar current = $scope.getCurrentUndoState();\n\n\t\tif (drawn != current) {\n\t\t\t$scope.pushUndo(drawn);\n\t\t}\n\n\t}\n\n\t$scope.pushUndo = function (state) {\n\n\t\tvar view = $scope.view;\n\n\t\tview.undoPos = view.undoPos + 1;\n\t\tif (view.undoPos + 1 <= view.undoList.length) {\n\t\t\tview.undoList.splice(view.undoPos, view.undoList.length - view.undoPos);\n\t\t}\n\t\tview.undoList.push(state);\n\n\t\tif (view.undoList.length > cvOptions.undoSize) {\n\t\t\tview.undoList.splice(0, view.undoList.length - cvOptions.undoSize);\n\t\t\tview.undoPos = view.undoList.length - 1;\n\t\t}\n\t};\n\n\t$scope.view.updateUndo = function() {\n\t\tvar view = $scope.view;\n\t\tvar state = viewsService.serializeView(view);\n\n\t\tif (view.undoList[view.undoPos]) {\n\t\t\tview.undoList[view.undoPos] = state;\n\t\t}\n\t};\n\n\t$scope.getCurrentUndoState = function () {\n\t\tif ($scope.view.undoList.length == 0) return \"{}\";\n\t\treturn $scope.view.undoList[$scope.view.undoPos];\n\t};\n\n\t$scope.undo = function () {\n\t\t$scope.view.undoPos = $scope.view.undoPos - 1;\n\t\tif ($scope.view.undoPos < 0) $scope.view.undoPos = 0;\n\t\t$scope.applyCurrentUndoState();\n\t};\n\n\t$scope.redo = function () {\n\t\t$scope.view.undoPos = $scope.view.undoPos + 1;\n\t\t$scope.applyCurrentUndoState ();\n\t};\n\n\t$scope.applyCurrentUndoState = function() {\n\t\tvar current = $scope.getCurrentUndoState();\n\t\t$scope.view.params = $.parseJSON(current);\n\t\t$scope.refreshView();\n\t};\n\n\n}]);\n\n\n"
  },
  {
    "path": "cubesviewer/views/views.js",
    "content": "/*\n * CubesViewer\n * Copyright (c) 2012-2016 Jose Juan Montes, see AUTHORS for more details\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n\n\"use strict\";\n\n\n/**\n * View class, which contains view definition (params), view state,\n * and provides the view API.\n *\n * This is the generic base View class definition.\n * Specific views (ie. CubeView) enrich this model.\n *\n * @param cvOptions The cv options object.\n * @param id The numeric id of the view to be created.\n * @param type The view type (ie. 'cube').\n * @returns The new view object.\n *\n * @namespace cubesviewer\n */\ncubesviewer.View = function(cvOptions, id, type) {\n\n\tvar view = {};\n\n\tview.id = \"_cv-view-\" + id;\n\tview.type = type;\n\tview.cvOptions = cvOptions;\n\n\tview.state = cubesviewer.VIEW_STATE_INITIALIZING;\n\tview.error = \"\";\n\n\tview.params = {};\n\n\tview.savedId = 0;\n\tview.owner = cvOptions.user;\n\tview.shared = false;\n\n\n\t/**\n\t * Returns a boolean indicating whether controls are hidden for this view.\n\t *\n\t * @returns boolean indicating whether controls are hidden for this view.\n\t */\n\tview.getControlsHidden = function() {\n\t\treturn !!view.params.controlsHidden || !!view.cvOptions.hideControls;\n\t};\n\n\tview.setControlsHidden = function(controlsHidden) {\n\t\tview.params.controlsHidden = controlsHidden;\n\t};\n\n\treturn view;\n\n};\n\n\n\n/**\n * The views module manages different views in CubesViewer.\n *\n * @namespace cv.views\n */\nangular.module('cv.views', ['cv.views.cube']);\n\n\n/**\n * This service manages CubesViewer views in the application.\n *\n * @class viewsService\n * @memberof cv.views\n */\nangular.module('cv.views').service(\"viewsService\", ['$rootScope', '$window', 'cvOptions', 'cubesService', 'dialogService',\n                                                    function ($rootScope, $window, cvOptions, cubesService, dialogService) {\n\n\tthis.views = [];\n\n\tthis.lastViewId = 0;\n\n\tthis.studioViewsService = null;\n\n\t/**\n\t * Adds a new clean view for a cube.\n\t *\n\t * @param type Type of view to create. Currently only \"cube\" is available.\n\t * @param data View parameters, as an object or as a serialized JSON string.\n\t * @returns CubesViewer view object.\n\t *\n\t * @memberOf cv.views.viewsService\n\t */\n\tthis.createView = function(type, data) {\n\n\t\t// Create view\n\n\t\tthis.lastViewId++;\n\n\t\tvar params = {};\n\n\t\tif (typeof data == \"string\") {\n\t\t\ttry {\n\t\t\t\tparams = $.parseJSON(data);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.debug('Error: could not process serialized data (JSON parse error)');\n\t\t\t\tdialogService.show('Error: could not process serialized data (JSON parse error).')\n\t\t\t\tparams[\"name\"] = \"Undefined view\";\n\t\t\t}\n\t\t} else {\n\t\t\tparams = data;\n\t\t}\n\n\t\t// FIXME: cvOptions shall not be passed, and getControlsHidden() shall possibly be part of this view service\n\t\tvar view = cubesviewer.CubeView(cvOptions, this.lastViewId, type);\n\t\t$.extend(view.params, params);\n\n\t\treturn view;\n\t};\n\n\t/**\n\t * Serialize view data.\n\t *\n\t * @param view The view object for which definition will be serialized.\n\t * @returns A string with the definition of the view (view.params) serialized in JSON.\n\t */\n\tthis.serializeView = function(view) {\n\t\t//return JSON.stringify(view.params);\n\t\treturn angular.toJson(view.params);  // Ignores $$ attributes\n\t};\n\n\n}]);\n\n\n"
  },
  {
    "path": "doc/guide/cubesviewer-embed.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\nEmbedding CubesViewer views\n---------------------------\n\nAs CubesViewer is mainly a Javascript library, views (or the full GUI) can easily be embedded in other\napplications.\n\nViews are designed using CubesViewer Studio. Then, using the `View > Serialize to JSON` option,\nyou can export your view definitions as JSON, and use the serialized JSON to initialize views in\nyour application.\n\nNote that you still need a running Cubes server. CubesViewer views don't store any data, and when\nthey are initialized they need to access Cubes server to retrieve the necessary data for the view.\n\n\nEmbedded views examples\n-----------------------\n\nExamples of integration of views can be found in the\n[html](https://github.com/jjmontesl/cubesviewer/tree/master/html) directory.\n\nThis includes a local HTML file (studio.html) that features a complete static version of\nCubesViewer Studio interface, great for quickly testing the app on your\n favourite Cubes server. Just open the file on your web browser.\n\nThe directory includes an example of a view embedded into a web page (`views.html`),\nand the same example integration under Angular (`views-angular.html`).\n\n\nFiles\n---------------------\n\nYou need to include CubesViewer CSS and Javascript in the `dist` directory.\n\nYou can get dependencies using your favourite dependency manager, but all the needed libraries\nare available in the `html/lib` directory for convenience.\n\n\nIncluding CubesViewer\n---------------------\n\nIn order to run CubesViewer, you need to include a number Javascript and CSS dependencies, listed below.\n\nNote that the paths may vary in your application, depending on where you copy libraries. Also,\nnote that **the order of inclusion of Javascript and CSS files is critical**.\n\n```\n    <link rel=\"stylesheet\" href=\"lib/angular-ui-grid/ui-grid.css\" />\n    <link rel=\"stylesheet\" href=\"lib/font-awesome/css/font-awesome.css\" />\n    <link rel=\"stylesheet\" href=\"lib/nvd3/nv.d3.css\" />\n    <link rel=\"stylesheet\" href=\"lib/cubesviewer/cubesviewer.css\" />\n    <link rel=\"stylesheet\" href=\"lib/bootstrap-submenu/css/bootstrap-submenu.css\" /> <!-- after cubesviewer.css! -->\n\n    <script src=\"lib/jquery/jquery.js\"></script>\n    <script src=\"lib/bootstrap/bootstrap.js\"></script>\n    <script src=\"lib/bootstrap-submenu/js/bootstrap-submenu.js\"></script>\n    <script src=\"lib/angular/angular.js\"></script>\n    <script src=\"lib/angular-cookies/angular-cookies.js\"></script>\n    <script src=\"lib/angular-bootstrap/ui-bootstrap-tpls.js\"></script>\n    <script src=\"lib/angular-ui-grid/ui-grid.js\"></script>\n    <script src=\"lib/d3/d3.js\"></script>\n    <script src=\"lib/nvd3/nv.d3.js\"></script>\n    <script src=\"lib/flotr2/flotr2.min.js\"></script>\n    <script src=\"lib/cubesviewer/cubesviewer.js\"></script>\n```\n\nCheck if your project is using any of the included Javascript and CSS dependencies,\nas including them twice may cause errors, or there may be version conflicts (jQuery, AngularJS, D3.js, NVD3...).\n\n(Note: the most up to date list of JS and CSS files, and examples of HTML/CSS integration of CubesViewer\nis best shown by the examples in the `/html` directory of the package).\n\n\nContainer\n---------\n\nIn your page, reserve a space for your embedded view or views:\n\n```\n<div id=\"cv-view-1\" style=\"width: 100%; min-height: 120px;\">Loading CubesViewer...</div>\n```\n\n\nInitializing CubesViewer\n------------------------\n\nCubesviewer needs to be instantiated after the document has been loaded. We use the jQuery library to\nhandle the `$(document).ready()` event.\n\nInside this method:\n\n* Initialize CubesViewer (the URL of the Cubes server needs to be passed)\n* Use `cubesviewer.createView()` to create a view in your container (options\n  can be defined with a JSON string or a Javascript array).\n* You need to wrap your calls to CubesViewer in a `cubesviewer.apply()`\n  (note: if you are using CubesViewer from an Angular application, you don't\n  need to do this, instead you should be using CubesViewer directives directly).\n\n\n```\n    // Reference to the created view\n    var view1 = null;\n\n    // Initialize CubesViewer when document is ready\n    $(document).ready(function() {\n\n        // Get user Cubes information for the example\n        var cubesUrl = prompt (\"Enter your Cubes Server URL\", \"http://localhost:5000\");\n\n        // Initialize CubesViewer system\n        cubesviewer.init({\n            cubesUrl: cubesUrl\n        });\n\n        // Sample serialized view (based on cubes-examples project data)\n        var serializedView = '{\"cubename\":\"webshop_sales\",\"name\":\"Cube Webshop / Sales\",\"mode\":\"chart\",\"drilldown\":[\"country:continent\"],\"cuts\":[],\"datefilters\":[{\"dimension\":\"date_sale@daily\",\"mode\":\"auto-last24m\",\"date_from\":\"\",\"date_to\":\"\"}],\"rangefilters\":[],\"xaxis\":\"date_sale@daily:month\",\"yaxis\":\"price_total_sum\",\"charttype\":\"lines-stacked\",\"columnHide\":{},\"columnWidths\":{},\"columnSort\":{},\"chart-barsvertical-stacked\":true,\"chart-disabledseries\":{\"key\":\"product@product:product_category\",\"disabled\":{\"Books\":false,\"Sports\":false,\"Various\":false,\"Videos\":false}}}';\n\n        // Using a JSON string for view parameters:\n        cubesviewer.apply(function() {\n            view1 = cubesviewer.createView(\"#cv-view-1\", \"cube\", serializedView);\n        });\n\n    });\n```\n\nUse CubesViewer Studio to design views\n--------------------------------------\n\nCubesViewer Studio includes a menu option for serializing a view as JSON, which can be used to initialize views,\nas shown above. It also includes an option to load views from serialized JSON strings.\n\nIf you plan to embed the full CubesViewer Studio, you will need a slightly different\ninitialization procedure. Check the `/html` examples for further details.\n\nFurther information\n-------------------\n\n* [Configuring your Cubes model](cubesviewer-model.md)\n* [Documentation index](index.md)\n\n"
  },
  {
    "path": "doc/guide/cubesviewer-model.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\nCubesViewer model options\n-------------------------\n\nSome of CubesViewer features rely on your model being correctly configured. This is required, for example,\nin order to identify date dimensions so CubesViewer knows which dimensions can be used by date filters.\n\nRemember to **restart your Cubes server after changing cube metadata** in order for the changes to be picked up.\n\n\nLabels\n------\n\nCubes supports the `label` attribute on every object. If available, CubesViewer will show this attribute\nwhen referring to Cubes, Dimensions, Hierarchies, Levels and other Cubes objects.\n\n\nOrdering\n--------\n\nWhen sorting data, CubesViewer will follow the `order_attribute` in your model definition if available.\nCubes default order_attribute is the key, which is often not desired, therefore setting this parameter\nin your model is recommended.\n\nYou can control ordering by setting the `order_attribute` for dimension levels in the model:\n\n```\n    \"levels\": [\n           {\n               \"name\":\"month\",\n               \"label\":\"Month\"\n               \"role\": \"month\",\n               'attributes': ['month', 'month_name']\n               \"label_attribute\": \"month_name,\n               \"order_attribute\": \"month\",\n           },\n           ...\n```\n\n\nDate Filtering\n--------------\n\nCubesViewer has a \"Date Filter\" option that shows a special cut filter for date dimensions. In order for it\nto work, you need to add information to your model, using also the \"role\" attribute of dimension and levels.\n\n1. For each date dimension, add an \"role\" attribute with \"time\" value.\n2. Optionally, also add an \"info\" dictionary, with a \"cv-datefilter-hierarchy\" attribute pointing to\n   your desired date filtering hierarchy, if it is not \"default\".\n3. For each *level* involved in your date filtering, add a \"role\" attribute\n   identifying the unit of date value (one of \"year\", \"quarter\", \"month\", \"week\" or \"day\").\n\nMore information about roles at https://pythonhosted.org/cubes/model.html#roles\n\nThis is an example dimension \"date_created\" showing this configuration:\n\n```\n    \"dimensions\": [\n        {\n            \"name\": \"date_created\",\n            \"label\": \"Date Created\",\n            \"role\": \"time\",\n            \"info\": {\n                \"cv-datefilter-hierarchy\": \"weekly\"\n            },\n            \"levels\": [\n                   {\n                       \"name\":\"year\",\n                       \"label\":\"Year\",\n                       \"role\": \"year\"\n                   },\n                   {\n                       \"name\":\"quarter\",\n                       \"label\":\"Quarter\",\n                       \"role\": \"quarter\"\n                   },\n                   {\n                       \"name\":\"month\",\n                       \"label\":\"Month\"\n                       \"role\": \"month\",\n                       \"order_attribute\": \"month\",\n                       \"label_attribute\": \"month_name,\n                       'attributes': ['month', 'month_name']\n                   },\n                   {\n                       \"name\":\"week\",\n                       \"label\":\"Week\",\n                       \"role\": \"week\"\n                   }\n               ],\n            \"hierarchies\": [\n                {\n                    \"name\": \"weekly\",\n                    \"label\": \"Weekly\",\n                    \"levels\": [ \"year\", \"week\"]\n                },\n                {\n                    \"name\": \"monthly\",\n                    \"label\": \"Monthly\",\n                    \"levels\": [ \"year\", \"quarter\", \"month\"]\n\n                }\n            ]\n        },\n        {\n            \"name\": \"date_updated_last\",\n            \"label\": \"Last Update\",\n            \"template\": \"date_created\"\n        },\n        ...\n```\n\n\nRange Filtering\n---------------\n\n**Note:** This feature is temporarily not available, but will be brought back soon.\n\nCubesViewer has a \"Range Filter\" option that shows a special cut filter for ranges. This can be applied\nto simple dimensions which *keys* are sortable.\n\nIn order for this to work, you need to add information to your model.\n\n1. For each range dimension, add an \"info\" attribute called \"cv-rangefilter\" with \"true\" value.\n2. Optionally, also add an \"info\" attribute \"cv-rangefilter-slider\" if you wish the filter\n   to include a slider. This attribute must be a dictionary with \"min\", \"max\" and \"step\" keys, as shown\n   in the example below:\n\nThis is an example dimension \"year\" showing this configuration:\n\n```\n    \"dimensions\": [\n        {\n            \"name\": \"date_year\",\n            \"label\": \"Year\",\n            \"info\": {\n                \"cv-rangefilter\": true,\n                \"cv-rangefilter-slider\": {\n                    \"min\": 2006,\n                    \"max\": 2012,\n                    \"step\": 1\n                }\n            }\n        },\n        ...\n```\n\n\nPer-cube default configuration from Cubes model\n-----------------------------------------------\n\nSometimes you may wish to define an initial default configuration for each cube.\nYou can do so by adding a \"cv-view-params\" dictionary to the cube \"info\". This way\nyou can, for example, hide some columns, apply a datefilter or show a chart view as\na default for a given cube:\n\n```\n        \"name\": \"cube_name\",\n        \"info\": {\n            \"cv-view-params\": {\n                \"mode\": \"chart\",\n                \"xaxis\": \"date:quarter\",\n                \"yaxis\": \"record_count\"\n            }\n        }\n        ...\n```\n\n\nNote that this settings won't apply if you are creating a view passing configuration\nparameters as JSON. This option impacts cube views created with no options (as you'd\ndo when working from CubesViewer Studio, or when using the `viewService.createView()`\nAPI call with empty options).\n\n\nMeasure Formatting\n------------------\n\nYou can apply a formatting expression to your measures like shown in the\nexample below.\n\n```\n    \"measures\": [\n        {\n            \"label\": \"expense_total\",\n            \"name\": \"expense_total\",\n            \"info\": {\n              \"cv-formatter\": \"Math.formatnumber(value, 2) + (value != undefined ? ' €' : '')\"\n            }\n        },\n        ...\n```\n\nThe `cv-formatter` value is a Javascript expression that returns a formatted\nstring.\n\nYou can use the `Math.formatnumber` function (added by CubesViewer) which\nformats a number the given number of decimal places and optional thousands\nseparator.\n\nRemember to restart your Cubes server when changing cube metadata in order\nfor the changes to be picked up.\n\nFurther information\n-------------------\n\n* [Documentation index](index.md)\n\n"
  },
  {
    "path": "doc/guide/cubesviewer-quickstart.md",
    "content": "CubesViewer - Quickstart\n========================\n\nHello Cubes!\n------------\n\nCubesViewer is a client-side HTML5 application. You can test it by simply downloading\nthe package and opening the HTML file in your browser.\n\n1. Download the latest cubesviewer:\n\n   `git clone https://github.com/jjmontesl/cubesviewer.git`\n\n   (You can also download a zipped package).\n\n2. Open `html/views.html` in your browser. When prompted,\n   accept the default server URL (`http://cubesdemo.cubesviewer.com/`).\n\n3. Done! You are running your own copy of CubesViewer connecting to data\n   from CubesViewer public demo server.\n\n\nCubesViewer family\n------------------\n\n* *Cubes* is the OLAP Cubes Server by DataBrewery.\n* *CubesViewer* is the client-side HTML5 viewer library for Cubes.\n* *CubesViewer Studio* is the client-side HTML5 exploring solution for Cubes.\n* *CubesViewer Server* is the server-side backend for CubesViewer Studio (optional).\n\n\nSetting up Cubes and CubesViewer example data\n---------------------------------------------\n\nThe example above uses data from CubesViewer public demo server. But in order to serve your\nown data, you need to run your own Cubes installation.\n\nWe'll download the example data and install it locally along with Cubes. This example\nneeds *Python*, *PIP* and *virtualenv* installed:\n\n1. Clone the CubesViewer cubes-examples repository which contains this example:\n\n   `git clone https://github.com/jjmontesl/cubes-examples`\n\n2. Enter the directory. Create a virtual environment and activate it (this is optional,\n   but helps keeping your Python installation clean):\n\n   ```\n   cd cubes-examples\n   virtualenv env\n   . env/bin/activate\n   ```\n\n3. Install Cubes package via PIP:\n\n   `pip install -r requirements.txt`\n\n   This will install dependencies: Cubes, Flask and SQLAlchemy.\n\n4. Enter the \"webshop\" dir and run Cubes OLAP server (the tool is called `slicer`):\n\n   ```\n   cd webshop\n   slicer serve slicer.ini\n   ```\n\n   This will use the `slicer.ini` file and `model.json` config files to\n   initialize Cubes server. The database is a SQLite database included in\n   the same directory.\n\n5. Visit `http://localhost:5000` and check the server response. Cubes should reply\n   with a short web page describing its configuration.\n\n\nRefer to [Cubes](https://pythonhosted.org/cubes/index.html) site for download\nand installation instructions.\n\nNote: If you are on Windows and you get an error (_Your platform does not support forking_),\nyou may need to remove or comment the `processes: 6` line from the `slicer.ini` file.\n\nPut it all together\n-------------------\n\n1. Make sure your Cubes *slicer* service is running (from the section above).\n\n2. Use your browser to load `html/studio.html` in the `cubesviewer` package.\n\n3. When prompted, accept the default Cubes location: `http://localhost:5000`.\n\n4. Done! You are now using your copy of CubesViewer to access your local\n   Cubes server.\n\n\nCubesViewer Studio and Server\n-----------------------------\n\nIf you wish to install the full CubesViewer Studio Server environment, which\nallows several users to save / share views, check the\n[Installing CubesViewer Server](cubesviewer-server-installation.md) section.\n\nYou can also embed the CubesViewer views you design into other web applications.\nCheck [Integrating CubesViewer views in other web applications](cubesviewer-embed.md)\nfor further information.\n\n\nFurther information\n-------------------\n\n* [Configuring your Cubes model](cubesviewer-model.md)\n* [Documentation index](index.md)\n\n"
  },
  {
    "path": "doc/guide/cubesviewer-server-installation.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\nInstalling the full CubesViewer application\n-------------------------------------------\n\nCubesViewer Studio Server includes the complete set of user interface features to explore and navigate\na Cubes Server.\n\nThis full CubesViewer application adds a server-side Python/Django application which serves as backend for\nsome of the operations (ie. saving / sharing).\n\nThe CubesViewer Studio Server application is a web application and as such it must be served by an HTTP server.\nIt can be run using Python Django local webserver, but for more serious/production environments, it should\nbe fronted by a real web server like Apache.\n\nAs a side note, it should be pointed that CubesViewer is, however, mainly a client-side Javascript application,\nwhich means that although the full application is a Python Django Server-Side app, you can use a subset\nof the GUI features running the tool directly from your browser (as long as the Cubes server is accessible).\n\nThe installation steps are:\n\n\n## 1 - Python Cubes Requisite\n\nIn order to use CubesViewer, you need to have a working installation and configuration of the latest version of\n[Cubes Framework](http://databrewery.org/cubes.html) version.\n\nCubes includes an HTTP server called \"slicer\", which provides a REST-like API interface to one or more data cubes. This\nserver needs to be running for CubesViewer. Follow [Cubes Framework](http://databrewery.org/cubes.html) instructions\nin order to install and set up a cubes server if you haven't done so yet.\n\nIt is not required that the *Cubes Server* runs on the same host as the *CubesViewer Server* application.\n\nFor CubesViewer clients to connect to Cubes server (*slicer*), your Cubes server possibly needs to allow\ncross origin resource sharing (CORS). To enable it, add `allow_cors_origin: *`\n(or a more restrictive setting) under the `[server]` section of the `slicer.ini` file.\n\n\n## 2 - Dependencies\n\nCubesViewer application runs on Python/Django. You need to have the following packages available in your system:\n\n* Python 2.7\n* Django 1.9\n\nYou will also need Python packages \"requests\" and \"django-rest-framework\". Check the requirements.txt file for\nthe full list of dependencies (you can also use this file to install all dependencies via\n`pip install -r requirements.txt`).\n\nDjango applications can run on local SQLite files, but if you plan to run on a different database system, you may\nneed to install also the Python connectors for the appropriate database backend.\n\n\n## 3 - Download and install CubesViewer\n\nDownload **cubesviewer-server** project from GitHub (https://github.com/jjmontesl/cubesviewer-server).\nYou can use 'git' or get a zipped package from the project page.\n\n```\ngit clone https://github.com/jjmontesl/cubesviewer-server.git\n```\n\n\n## 4 - Configure the application.\n\nThere are a few parameters that need to be configured.\n\nBesides of the OLAP database served by Cubes, the CubesViewer application requires access to a database in order\nto support save/load operations. You can use a local SQLite file or any other database system supported by Django.\n\nBy default, CubesViewer uses a SQLite database located in the same directory as the `settings.py` file (`cvapp/cvapp/`).\nSee [Django Database configuration](https://docs.djangoproject.com/en/dev/ref/settings/#databases) documents for\nmore information on the database configuration.\n\n**Edit the web/cvapp/cvapp/settings.py file**, and review the following sections according to your\nCubes URL, database config and installation path.\n\n```python\n##\n# 1. Configuration of application database for storing reports\n##\n\n# Note: Default database uses sqlite and places the database file in the same\n# directory as this configuration file. Change the database connection to\n# match your needs.\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.\n        'NAME': os.path.join(CURRENT_DIR, 'cubesviewer.sqlite'),  # Or path to database file if using sqlite3.\n        'USER': '',                      # Not used with sqlite3.\n        'PASSWORD': '',                  # Not used with sqlite3.\n        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.\n        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.\n    },\n}\n```\n\n```python\n##\n# 2. Configuration of CubesViewer Server\n##\n\n# Base Cubes Server URL.\n# Your Cubes Server needs to be running and listening on this URL, and it needs\n# to be accessible to clients of the application.\nCUBESVIEWER_CUBES_URL = \"http://localhost:5000\"\n\n# CubesViewer Store backend URL. It should point to this application.\n# Note that this must match the URL that you use to access the application,\n# otherwise you may hit security issues. If you access your server\n# via http://localhost:8000, use the same here. Note that 127.0.0.1 and\n# 'localhost' are different strings for this purpose. (If you wish to accept\n# requests from different URLs, you may need to add CORS support).\nCUBESVIEWER_BACKEND_URL = \"http://localhost:8000/cubesviewer\"\n\n# Optional user and password tuple to access the backend, or False\n# (only applies when CubesViewer Cubes proxy is used)\n#CUBESVIEWER_CUBES_PROXY_USER = ('user', 'password')\nCUBESVIEWER_CUBES_PROXY_USER = None\n\n# CubesViewer Proxy ACL\n# (only applies when CubesViewer Cubes proxy is used)\n# ie. CUBESVIEWER_PROXY_ACL = [ { \"cube\": \"my_cube\", \"group\": \"my_group\" } ]\nCUBESVIEWER_PROXY_ACL = [ ]\n```\n\n```python\n##\n# 3. Other Django application settings\n##\n\n# Uncomment this if you need to allow access to CubesViewer resources\n# from a different origin (schema, domain or port) from which CubesViewer\n# is served to users.\n#CORS_ORIGIN_ALLOW_ALL = True\n\n# Path to static files\nSTATIC_DIR = ( os.path.join(BASE_DIR, os.path.pardir, 'static'), )\nTEMPLATE_DIR = ( os.path.join(BASE_DIR, os.path.pardir, 'templates'), )\n\n# Local time zone for this installation. Choices can be found here:\n# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name\n# although not all choices may be available on all operating systems.\n# On Unix systems, a value of None will cause Django to use the same\n# timezone as the operating system.\n# If running in a Windows environment this must be set to the same as your\n# system time zone.\nTIME_ZONE = 'Europe/Madrid'\n\n# Language code for this installation. All choices can be found here:\n# http://www.i18nguy.com/unicode/language-identifiers.html\nLANGUAGE_CODE = 'en-us'\n```\n\n\n## 5 - Initializing the database\n\nOnce the application is configured, we need to initialize the backend database.\nDjango applications are initialized using the `manage.py` script.\n\nMove into your `cubesviewer-server/cvapp` directory and run the manage script with the `syncdb` option:\n\n```\npython manage.py syncdb\n```\n\nYou will be prompted for an \"admin\" user and password. This is the user that will have access\nto the administration section.\n\n\n## 6 - Running with Django WebServer\n\nFinally, let's run the application. Django provides a convenient way to spawn a server\nfor testing purposes. Run the manage script with the following parameters:\n\n```\npython manage.py runserver 0.0.0.0:8000\n```\n\nNow, the application should be available from your browser using `http://localhost:8000/`.\n\nIf the data model can be loaded from Cubes server and contains any cube definitions, you should be able to see them and inspect\nthem using CubesViewer.\n\n\n## 7 - Configure your model for CubesViewer\n\nNote that you can benefit from extra features if you configure your Cubes model. Check the\n[Configuring your Cubes data model](cubesviewer-model.md) section of the documentation.\n\n\nIf you are using CubesViewer, please share and tweet #cubesviewer !\n\n\nFurther information\n-------------------\n\n* [Documentation index](index.md)\n"
  },
  {
    "path": "doc/guide/cubesviewer-user-main.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\nUser Guide\n----------\n\nCubesViewer is a data exploration and visualization tool. It helps you exploring and understanding\ndata and to present it in a way that is meaningful.\n\nCall for help\n-------------\n\nThis section of CubesViewer documentation has not yet been created. Please consider collaborating with\nthe project by writing it! Get in touch with jjmontes@gmail.com if you wish to take over this task:\n\n* Introduction\n* Facts and dimensions\n* Explore view\n  * Drilldown\n  * Filtering\n* Series view\n  * Operations on series\n* Facts view\n* Charts view\n* Exporting data\n* Saving and sharing\n\n\n* [Documentation index](index.md)\n\n\n![CubesViewer Explore Screenshot](https://raw.github.com/jjmontesl/cubesviewer/master/doc/screenshots/view-explore-1.png \"CubesViewer Explore\")\n\n"
  },
  {
    "path": "doc/guide/index.md",
    "content": "CubesViewer - OLAP Visual Viewer and Explore Tool\n=================================================\n\n[CubesViewer](https://github.com/jjmontesl/cubesviewer) is a visual, web-based tool application\nfor exploring and analyzing OLAP databases served by the Cubes OLAP Framework.\n\n\nCubesViewer Documentation\n-------------------------\n\n**For developers and integrators**:\n\n* [Quick Start](cubesviewer-quickstart.md)\n* [Configuring your Cubes data model](cubesviewer-model.md)\n* [Installing CubesViewer Server](cubesviewer-server-installation.md)\n* [Integrating CubesViewer views in other web applications](cubesviewer-embed.md)\n\n**For end users**:\n\n* [CubesViewer User Guide](cubesviewer-user-main.md) - Work in progress\n\n**Links**:\n\n* [CubesViewer Demo](http://jjmontesl.github.io/cubesviewer/)\n* [CubesViewer](https://github.com/jjmontesl/cubesviewer) at Github\n* [CubesViewer Server](https://github.com/jjmontesl/cubesviewer-server) at Github\n\n\nPlease see the README.md file for information on collaborating with CubesViewer project!\n\n![CubesViewer Chart Screenshot](https://raw.github.com/jjmontesl/cubesviewer/master/doc/screenshots/view-chart-1.png \"CubesViewer Chart\")\n\n"
  },
  {
    "path": "doc/images/icon/browserconfig.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<browserconfig>\r\n  <msapplication>\r\n    <tile>\r\n      <square70x70logo src=\"/mstile-70x70.png\"/>\r\n      <square150x150logo src=\"/mstile-150x150.png\"/>\r\n      <square310x310logo src=\"/mstile-310x310.png\"/>\r\n      <wide310x150logo src=\"/mstile-310x150.png\"/>\r\n      <TileColor>#da532c</TileColor>\r\n    </tile>\r\n  </msapplication>\r\n</browserconfig>\r\n"
  },
  {
    "path": "doc/images/icon/manifest.json",
    "content": "{\n\t\"name\": \"CubesViewer\",\n\t\"icons\": [\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-36x36.png\",\n\t\t\t\"sizes\": \"36x36\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 0.75\n\t\t},\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-48x48.png\",\n\t\t\t\"sizes\": \"48x48\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 1\n\t\t},\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-72x72.png\",\n\t\t\t\"sizes\": \"72x72\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 1.5\n\t\t},\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-96x96.png\",\n\t\t\t\"sizes\": \"96x96\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 2\n\t\t},\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-144x144.png\",\n\t\t\t\"sizes\": \"144x144\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 3\n\t\t},\n\t\t{\n\t\t\t\"src\": \"\\/android-chrome-192x192.png\",\n\t\t\t\"sizes\": \"192x192\",\n\t\t\t\"type\": \"image\\/png\",\n\t\t\t\"density\": 4\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "doc/jsdoc/jsdoc.conf.json",
    "content": "{\n  \"templates\": {\n    \"default\": {\n      \"outputSourceFiles\": true,\n      \"includeDate\": false,\n      \"layoutFile\": \"doc/jsdoc/layout.tmpl\",\n      \"staticFiles\": {\n        \"include\": [ ]\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "doc/jsdoc/layout.tmpl",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n    <title>CubesViewer Doc: <?js= title ?></title>\n\n    <script src=\"scripts/prettify/prettify.js\"> </script>\n    <script src=\"scripts/prettify/lang-css.js\"> </script>\n    <!--[if lt IE 9]>\n      <script src=\"//html5shiv.googlecode.com/svn/trunk/html5.js\"></script>\n    <![endif]-->\n    <link type=\"text/css\" rel=\"stylesheet\" href=\"styles/prettify-tomorrow.css\">\n    <link type=\"text/css\" rel=\"stylesheet\" href=\"styles/jsdoc-default.css\">\n</head>\n\n<body>\n\n<div id=\"main\">\n\n    <h1 class=\"page-title\"><?js= title ?></h1>\n\n    <?js= content ?>\n</div>\n\n<nav>\n    <?js= this.nav ?>\n</nav>\n\n<br class=\"clear\">\n\n<footer>\n    Documentation generated by <a href=\"https://github.com/jsdoc3/jsdoc\">JSDoc <?js= env.version.number ?></a><?js if(env.conf.templates && env.conf.templates.default && env.conf.templates.default.includeDate !== false) { ?> on <?js= (new Date()) ?><?js } ?>\n</footer>\n\n<script> prettyPrint(); </script>\n<script src=\"scripts/linenumber.js\"> </script>\n</body>\n</html>\n"
  },
  {
    "path": "html/cvapp.css",
    "content": "/*\n * Cubesviewer sites CSS\n * This file must not be included needed if you are embedding cubesviewer in your site, as it\n * contains global CSS selectors.\n */\n\nhtml {\n    font-size: 13px;\n    font-family: Helvetica, Arial, sans-serif;\n}\n\nimg.cv-logo {\n\tmargin: 0px;\n\theight: 40px;\n\twidth: 85px;\n}\n\n.header h1 {\n\tmargin-bottom: 5px;\n}\n\n#cubesviewer {\n    margin-top: 10px;\n}\n\n.cv-gui-panel {\n    /*\n    position: fixed;\n    border-bottom: 2px solid black;\n    background-color: #ffffff;\n    left: 0px;\n    right: 0px;\n    padding: 3px 5px 3px 5px;\n    margin-bottom: 10px;\n    */\n\n}\n"
  },
  {
    "path": "html/lib/angular/angular.js",
    "content": "/**\n * @license AngularJS v1.5.5\n * (c) 2010-2016 Google, Inc. http://angularjs.org\n * License: MIT\n */\n(function(window) {'use strict';\n\n/**\n * @description\n *\n * This object provides a utility for producing rich Error messages within\n * Angular. It can be called as follows:\n *\n * var exampleMinErr = minErr('example');\n * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);\n *\n * The above creates an instance of minErr in the example namespace. The\n * resulting error will have a namespaced error code of example.one.  The\n * resulting error will replace {0} with the value of foo, and {1} with the\n * value of bar. The object is not restricted in the number of arguments it can\n * take.\n *\n * If fewer arguments are specified than necessary for interpolation, the extra\n * interpolation markers will be preserved in the final string.\n *\n * Since data will be parsed statically during a build step, some restrictions\n * are applied with respect to how minErr instances are created and called.\n * Instances should have names of the form namespaceMinErr for a minErr created\n * using minErr('namespace') . Error codes, namespaces and template strings\n * should all be static strings, not variables or general expressions.\n *\n * @param {string} module The namespace to use for the new minErr instance.\n * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning\n *   error from returned function, for cases when a particular type of error is useful.\n * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance\n */\n\nfunction minErr(module, ErrorConstructor) {\n  ErrorConstructor = ErrorConstructor || Error;\n  return function() {\n    var SKIP_INDEXES = 2;\n\n    var templateArgs = arguments,\n      code = templateArgs[0],\n      message = '[' + (module ? module + ':' : '') + code + '] ',\n      template = templateArgs[1],\n      paramPrefix, i;\n\n    message += template.replace(/\\{\\d+\\}/g, function(match) {\n      var index = +match.slice(1, -1),\n        shiftedIndex = index + SKIP_INDEXES;\n\n      if (shiftedIndex < templateArgs.length) {\n        return toDebugString(templateArgs[shiftedIndex]);\n      }\n\n      return match;\n    });\n\n    message += '\\nhttp://errors.angularjs.org/1.5.5/' +\n      (module ? module + '/' : '') + code;\n\n    for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {\n      message += paramPrefix + 'p' + (i - SKIP_INDEXES) + '=' +\n        encodeURIComponent(toDebugString(templateArgs[i]));\n    }\n\n    return new ErrorConstructor(message);\n  };\n}\n\n/* We need to tell jshint what variables are being exported */\n/* global angular: true,\n  msie: true,\n  jqLite: true,\n  jQuery: true,\n  slice: true,\n  splice: true,\n  push: true,\n  toString: true,\n  ngMinErr: true,\n  angularModule: true,\n  uid: true,\n  REGEX_STRING_REGEXP: true,\n  VALIDITY_STATE_PROPERTY: true,\n\n  lowercase: true,\n  uppercase: true,\n  manualLowercase: true,\n  manualUppercase: true,\n  nodeName_: true,\n  isArrayLike: true,\n  forEach: true,\n  forEachSorted: true,\n  reverseParams: true,\n  nextUid: true,\n  setHashKey: true,\n  extend: true,\n  toInt: true,\n  inherit: true,\n  merge: true,\n  noop: true,\n  identity: true,\n  valueFn: true,\n  isUndefined: true,\n  isDefined: true,\n  isObject: true,\n  isBlankObject: true,\n  isString: true,\n  isNumber: true,\n  isDate: true,\n  isArray: true,\n  isFunction: true,\n  isRegExp: true,\n  isWindow: true,\n  isScope: true,\n  isFile: true,\n  isFormData: true,\n  isBlob: true,\n  isBoolean: true,\n  isPromiseLike: true,\n  trim: true,\n  escapeForRegexp: true,\n  isElement: true,\n  makeMap: true,\n  includes: true,\n  arrayRemove: true,\n  copy: true,\n  shallowCopy: true,\n  equals: true,\n  csp: true,\n  jq: true,\n  concat: true,\n  sliceArgs: true,\n  bind: true,\n  toJsonReplacer: true,\n  toJson: true,\n  fromJson: true,\n  convertTimezoneToLocal: true,\n  timezoneToOffset: true,\n  startingTag: true,\n  tryDecodeURIComponent: true,\n  parseKeyValue: true,\n  toKeyValue: true,\n  encodeUriSegment: true,\n  encodeUriQuery: true,\n  angularInit: true,\n  bootstrap: true,\n  getTestability: true,\n  snake_case: true,\n  bindJQuery: true,\n  assertArg: true,\n  assertArgFn: true,\n  assertNotHasOwnProperty: true,\n  getter: true,\n  getBlockNodes: true,\n  hasOwnProperty: true,\n  createMap: true,\n\n  NODE_TYPE_ELEMENT: true,\n  NODE_TYPE_ATTRIBUTE: true,\n  NODE_TYPE_TEXT: true,\n  NODE_TYPE_COMMENT: true,\n  NODE_TYPE_DOCUMENT: true,\n  NODE_TYPE_DOCUMENT_FRAGMENT: true,\n*/\n\n////////////////////////////////////\n\n/**\n * @ngdoc module\n * @name ng\n * @module ng\n * @installation\n * @description\n *\n * # ng (core module)\n * The ng module is loaded by default when an AngularJS application is started. The module itself\n * contains the essential components for an AngularJS application to function. The table below\n * lists a high level breakdown of each of the services/factories, filters, directives and testing\n * components available within this core module.\n *\n * <div doc-module-components=\"ng\"></div>\n */\n\nvar REGEX_STRING_REGEXP = /^\\/(.+)\\/([a-z]*)$/;\n\n// The name of a form control's ValidityState property.\n// This is used so that it's possible for internal tests to create mock ValidityStates.\nvar VALIDITY_STATE_PROPERTY = 'validity';\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};\nvar uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};\n\n\nvar manualLowercase = function(s) {\n  /* jshint bitwise: false */\n  return isString(s)\n      ? s.replace(/[A-Z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) | 32);})\n      : s;\n};\nvar manualUppercase = function(s) {\n  /* jshint bitwise: false */\n  return isString(s)\n      ? s.replace(/[a-z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) & ~32);})\n      : s;\n};\n\n\n// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish\n// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods\n// with correct but slower alternatives. See https://github.com/angular/angular.js/issues/11387\nif ('i' !== 'I'.toLowerCase()) {\n  lowercase = manualLowercase;\n  uppercase = manualUppercase;\n}\n\n\nvar\n    msie,             // holds major version number for IE, or NaN if UA is not IE.\n    jqLite,           // delay binding since jQuery could be loaded after us.\n    jQuery,           // delay binding\n    slice             = [].slice,\n    splice            = [].splice,\n    push              = [].push,\n    toString          = Object.prototype.toString,\n    getPrototypeOf    = Object.getPrototypeOf,\n    ngMinErr          = minErr('ng'),\n\n    /** @name angular */\n    angular           = window.angular || (window.angular = {}),\n    angularModule,\n    uid               = 0;\n\n/**\n * documentMode is an IE-only property\n * http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx\n */\nmsie = window.document.documentMode;\n\n\n/**\n * @private\n * @param {*} obj\n * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments,\n *                   String ...)\n */\nfunction isArrayLike(obj) {\n\n  // `null`, `undefined` and `window` are not array-like\n  if (obj == null || isWindow(obj)) return false;\n\n  // arrays, strings and jQuery/jqLite objects are array like\n  // * jqLite is either the jQuery or jqLite constructor function\n  // * we have to check the existence of jqLite first as this method is called\n  //   via the forEach method when constructing the jqLite object in the first place\n  if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true;\n\n  // Support: iOS 8.2 (not reproducible in simulator)\n  // \"length\" in obj used to prevent JIT error (gh-11508)\n  var length = \"length\" in Object(obj) && obj.length;\n\n  // NodeList objects (with `item` method) and\n  // other objects with suitable length characteristics are array-like\n  return isNumber(length) &&\n    (length >= 0 && ((length - 1) in obj || obj instanceof Array) || typeof obj.item == 'function');\n\n}\n\n/**\n * @ngdoc function\n * @name angular.forEach\n * @module ng\n * @kind function\n *\n * @description\n * Invokes the `iterator` function once for each item in `obj` collection, which can be either an\n * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value`\n * is the value of an object property or an array element, `key` is the object property key or\n * array element index and obj is the `obj` itself. Specifying a `context` for the function is optional.\n *\n * It is worth noting that `.forEach` does not iterate over inherited properties because it filters\n * using the `hasOwnProperty` method.\n *\n * Unlike ES262's\n * [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18),\n * providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just\n * return the value provided.\n *\n   ```js\n     var values = {name: 'misko', gender: 'male'};\n     var log = [];\n     angular.forEach(values, function(value, key) {\n       this.push(key + ': ' + value);\n     }, log);\n     expect(log).toEqual(['name: misko', 'gender: male']);\n   ```\n *\n * @param {Object|Array} obj Object to iterate over.\n * @param {Function} iterator Iterator function.\n * @param {Object=} context Object to become context (`this`) for the iterator function.\n * @returns {Object|Array} Reference to `obj`.\n */\n\nfunction forEach(obj, iterator, context) {\n  var key, length;\n  if (obj) {\n    if (isFunction(obj)) {\n      for (key in obj) {\n        // Need to check if hasOwnProperty exists,\n        // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function\n        if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {\n          iterator.call(context, obj[key], key, obj);\n        }\n      }\n    } else if (isArray(obj) || isArrayLike(obj)) {\n      var isPrimitive = typeof obj !== 'object';\n      for (key = 0, length = obj.length; key < length; key++) {\n        if (isPrimitive || key in obj) {\n          iterator.call(context, obj[key], key, obj);\n        }\n      }\n    } else if (obj.forEach && obj.forEach !== forEach) {\n        obj.forEach(iterator, context, obj);\n    } else if (isBlankObject(obj)) {\n      // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty\n      for (key in obj) {\n        iterator.call(context, obj[key], key, obj);\n      }\n    } else if (typeof obj.hasOwnProperty === 'function') {\n      // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed\n      for (key in obj) {\n        if (obj.hasOwnProperty(key)) {\n          iterator.call(context, obj[key], key, obj);\n        }\n      }\n    } else {\n      // Slow path for objects which do not have a method `hasOwnProperty`\n      for (key in obj) {\n        if (hasOwnProperty.call(obj, key)) {\n          iterator.call(context, obj[key], key, obj);\n        }\n      }\n    }\n  }\n  return obj;\n}\n\nfunction forEachSorted(obj, iterator, context) {\n  var keys = Object.keys(obj).sort();\n  for (var i = 0; i < keys.length; i++) {\n    iterator.call(context, obj[keys[i]], keys[i]);\n  }\n  return keys;\n}\n\n\n/**\n * when using forEach the params are value, key, but it is often useful to have key, value.\n * @param {function(string, *)} iteratorFn\n * @returns {function(*, string)}\n */\nfunction reverseParams(iteratorFn) {\n  return function(value, key) {iteratorFn(key, value);};\n}\n\n/**\n * A consistent way of creating unique IDs in angular.\n *\n * Using simple numbers allows us to generate 28.6 million unique ids per second for 10 years before\n * we hit number precision issues in JavaScript.\n *\n * Math.pow(2,53) / 60 / 60 / 24 / 365 / 10 = 28.6M\n *\n * @returns {number} an unique alpha-numeric string\n */\nfunction nextUid() {\n  return ++uid;\n}\n\n\n/**\n * Set or clear the hashkey for an object.\n * @param obj object\n * @param h the hashkey (!truthy to delete the hashkey)\n */\nfunction setHashKey(obj, h) {\n  if (h) {\n    obj.$$hashKey = h;\n  } else {\n    delete obj.$$hashKey;\n  }\n}\n\n\nfunction baseExtend(dst, objs, deep) {\n  var h = dst.$$hashKey;\n\n  for (var i = 0, ii = objs.length; i < ii; ++i) {\n    var obj = objs[i];\n    if (!isObject(obj) && !isFunction(obj)) continue;\n    var keys = Object.keys(obj);\n    for (var j = 0, jj = keys.length; j < jj; j++) {\n      var key = keys[j];\n      var src = obj[key];\n\n      if (deep && isObject(src)) {\n        if (isDate(src)) {\n          dst[key] = new Date(src.valueOf());\n        } else if (isRegExp(src)) {\n          dst[key] = new RegExp(src);\n        } else if (src.nodeName) {\n          dst[key] = src.cloneNode(true);\n        } else if (isElement(src)) {\n          dst[key] = src.clone();\n        } else {\n          if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};\n          baseExtend(dst[key], [src], true);\n        }\n      } else {\n        dst[key] = src;\n      }\n    }\n  }\n\n  setHashKey(dst, h);\n  return dst;\n}\n\n/**\n * @ngdoc function\n * @name angular.extend\n * @module ng\n * @kind function\n *\n * @description\n * Extends the destination object `dst` by copying own enumerable properties from the `src` object(s)\n * to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so\n * by passing an empty object as the target: `var object = angular.extend({}, object1, object2)`.\n *\n * **Note:** Keep in mind that `angular.extend` does not support recursive merge (deep copy). Use\n * {@link angular.merge} for this.\n *\n * @param {Object} dst Destination object.\n * @param {...Object} src Source object(s).\n * @returns {Object} Reference to `dst`.\n */\nfunction extend(dst) {\n  return baseExtend(dst, slice.call(arguments, 1), false);\n}\n\n\n/**\n* @ngdoc function\n* @name angular.merge\n* @module ng\n* @kind function\n*\n* @description\n* Deeply extends the destination object `dst` by copying own enumerable properties from the `src` object(s)\n* to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so\n* by passing an empty object as the target: `var object = angular.merge({}, object1, object2)`.\n*\n* Unlike {@link angular.extend extend()}, `merge()` recursively descends into object properties of source\n* objects, performing a deep copy.\n*\n* @param {Object} dst Destination object.\n* @param {...Object} src Source object(s).\n* @returns {Object} Reference to `dst`.\n*/\nfunction merge(dst) {\n  return baseExtend(dst, slice.call(arguments, 1), true);\n}\n\n\n\nfunction toInt(str) {\n  return parseInt(str, 10);\n}\n\n\nfunction inherit(parent, extra) {\n  return extend(Object.create(parent), extra);\n}\n\n/**\n * @ngdoc function\n * @name angular.noop\n * @module ng\n * @kind function\n *\n * @description\n * A function that performs no operations. This function can be useful when writing code in the\n * functional style.\n   ```js\n     function foo(callback) {\n       var result = calculateResult();\n       (callback || angular.noop)(result);\n     }\n   ```\n */\nfunction noop() {}\nnoop.$inject = [];\n\n\n/**\n * @ngdoc function\n * @name angular.identity\n * @module ng\n * @kind function\n *\n * @description\n * A function that returns its first argument. This function is useful when writing code in the\n * functional style.\n *\n   ```js\n     function transformer(transformationFn, value) {\n       return (transformationFn || angular.identity)(value);\n     };\n   ```\n  * @param {*} value to be returned.\n  * @returns {*} the value passed in.\n */\nfunction identity($) {return $;}\nidentity.$inject = [];\n\n\nfunction valueFn(value) {return function valueRef() {return value;};}\n\nfunction hasCustomToString(obj) {\n  return isFunction(obj.toString) && obj.toString !== toString;\n}\n\n\n/**\n * @ngdoc function\n * @name angular.isUndefined\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is undefined.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is undefined.\n */\nfunction isUndefined(value) {return typeof value === 'undefined';}\n\n\n/**\n * @ngdoc function\n * @name angular.isDefined\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is defined.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is defined.\n */\nfunction isDefined(value) {return typeof value !== 'undefined';}\n\n\n/**\n * @ngdoc function\n * @name angular.isObject\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not\n * considered to be objects. Note that JavaScript arrays are objects.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is an `Object` but not `null`.\n */\nfunction isObject(value) {\n  // http://jsperf.com/isobject4\n  return value !== null && typeof value === 'object';\n}\n\n\n/**\n * Determine if a value is an object with a null prototype\n *\n * @returns {boolean} True if `value` is an `Object` with a null prototype\n */\nfunction isBlankObject(value) {\n  return value !== null && typeof value === 'object' && !getPrototypeOf(value);\n}\n\n\n/**\n * @ngdoc function\n * @name angular.isString\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is a `String`.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a `String`.\n */\nfunction isString(value) {return typeof value === 'string';}\n\n\n/**\n * @ngdoc function\n * @name angular.isNumber\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is a `Number`.\n *\n * This includes the \"special\" numbers `NaN`, `+Infinity` and `-Infinity`.\n *\n * If you wish to exclude these then you can use the native\n * [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)\n * method.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a `Number`.\n */\nfunction isNumber(value) {return typeof value === 'number';}\n\n\n/**\n * @ngdoc function\n * @name angular.isDate\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a value is a date.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a `Date`.\n */\nfunction isDate(value) {\n  return toString.call(value) === '[object Date]';\n}\n\n\n/**\n * @ngdoc function\n * @name angular.isArray\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is an `Array`.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is an `Array`.\n */\nvar isArray = Array.isArray;\n\n/**\n * @ngdoc function\n * @name angular.isFunction\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is a `Function`.\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a `Function`.\n */\nfunction isFunction(value) {return typeof value === 'function';}\n\n\n/**\n * Determines if a value is a regular expression object.\n *\n * @private\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a `RegExp`.\n */\nfunction isRegExp(value) {\n  return toString.call(value) === '[object RegExp]';\n}\n\n\n/**\n * Checks if `obj` is a window object.\n *\n * @private\n * @param {*} obj Object to check\n * @returns {boolean} True if `obj` is a window obj.\n */\nfunction isWindow(obj) {\n  return obj && obj.window === obj;\n}\n\n\nfunction isScope(obj) {\n  return obj && obj.$evalAsync && obj.$watch;\n}\n\n\nfunction isFile(obj) {\n  return toString.call(obj) === '[object File]';\n}\n\n\nfunction isFormData(obj) {\n  return toString.call(obj) === '[object FormData]';\n}\n\n\nfunction isBlob(obj) {\n  return toString.call(obj) === '[object Blob]';\n}\n\n\nfunction isBoolean(value) {\n  return typeof value === 'boolean';\n}\n\n\nfunction isPromiseLike(obj) {\n  return obj && isFunction(obj.then);\n}\n\n\nvar TYPED_ARRAY_REGEXP = /^\\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\\]$/;\nfunction isTypedArray(value) {\n  return value && isNumber(value.length) && TYPED_ARRAY_REGEXP.test(toString.call(value));\n}\n\nfunction isArrayBuffer(obj) {\n  return toString.call(obj) === '[object ArrayBuffer]';\n}\n\n\nvar trim = function(value) {\n  return isString(value) ? value.trim() : value;\n};\n\n// Copied from:\n// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021\n// Prereq: s is a string.\nvar escapeForRegexp = function(s) {\n  return s.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1').\n           replace(/\\x08/g, '\\\\x08');\n};\n\n\n/**\n * @ngdoc function\n * @name angular.isElement\n * @module ng\n * @kind function\n *\n * @description\n * Determines if a reference is a DOM element (or wrapped jQuery element).\n *\n * @param {*} value Reference to check.\n * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element).\n */\nfunction isElement(node) {\n  return !!(node &&\n    (node.nodeName  // we are a direct element\n    || (node.prop && node.attr && node.find)));  // we have an on and find method part of jQuery API\n}\n\n/**\n * @param str 'key1,key2,...'\n * @returns {object} in the form of {key1:true, key2:true, ...}\n */\nfunction makeMap(str) {\n  var obj = {}, items = str.split(','), i;\n  for (i = 0; i < items.length; i++) {\n    obj[items[i]] = true;\n  }\n  return obj;\n}\n\n\nfunction nodeName_(element) {\n  return lowercase(element.nodeName || (element[0] && element[0].nodeName));\n}\n\nfunction includes(array, obj) {\n  return Array.prototype.indexOf.call(array, obj) != -1;\n}\n\nfunction arrayRemove(array, value) {\n  var index = array.indexOf(value);\n  if (index >= 0) {\n    array.splice(index, 1);\n  }\n  return index;\n}\n\n/**\n * @ngdoc function\n * @name angular.copy\n * @module ng\n * @kind function\n *\n * @description\n * Creates a deep copy of `source`, which should be an object or an array.\n *\n * * If no destination is supplied, a copy of the object or array is created.\n * * If a destination is provided, all of its elements (for arrays) or properties (for objects)\n *   are deleted and then all elements/properties from the source are copied to it.\n * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.\n * * If `source` is identical to 'destination' an exception will be thrown.\n *\n * @param {*} source The source that will be used to make a copy.\n *                   Can be any type, including primitives, `null`, and `undefined`.\n * @param {(Object|Array)=} destination Destination into which the source is copied. If\n *     provided, must be of the same type as `source`.\n * @returns {*} The copy or updated `destination`, if `destination` was specified.\n *\n * @example\n <example module=\"copyExample\">\n <file name=\"index.html\">\n <div ng-controller=\"ExampleController\">\n <form novalidate class=\"simple-form\">\n Name: <input type=\"text\" ng-model=\"user.name\" /><br />\n E-mail: <input type=\"email\" ng-model=\"user.email\" /><br />\n Gender: <input type=\"radio\" ng-model=\"user.gender\" value=\"male\" />male\n <input type=\"radio\" ng-model=\"user.gender\" value=\"female\" />female<br />\n <button ng-click=\"reset()\">RESET</button>\n <button ng-click=\"update(user)\">SAVE</button>\n </form>\n <pre>form = {{user | json}}</pre>\n <pre>master = {{master | json}}</pre>\n </div>\n\n <script>\n  angular.module('copyExample', [])\n    .controller('ExampleController', ['$scope', function($scope) {\n      $scope.master= {};\n\n      $scope.update = function(user) {\n        // Example with 1 argument\n        $scope.master= angular.copy(user);\n      };\n\n      $scope.reset = function() {\n        // Example with 2 arguments\n        angular.copy($scope.master, $scope.user);\n      };\n\n      $scope.reset();\n    }]);\n </script>\n </file>\n </example>\n */\nfunction copy(source, destination) {\n  var stackSource = [];\n  var stackDest = [];\n\n  if (destination) {\n    if (isTypedArray(destination) || isArrayBuffer(destination)) {\n      throw ngMinErr('cpta', \"Can't copy! TypedArray destination cannot be mutated.\");\n    }\n    if (source === destination) {\n      throw ngMinErr('cpi', \"Can't copy! Source and destination are identical.\");\n    }\n\n    // Empty the destination object\n    if (isArray(destination)) {\n      destination.length = 0;\n    } else {\n      forEach(destination, function(value, key) {\n        if (key !== '$$hashKey') {\n          delete destination[key];\n        }\n      });\n    }\n\n    stackSource.push(source);\n    stackDest.push(destination);\n    return copyRecurse(source, destination);\n  }\n\n  return copyElement(source);\n\n  function copyRecurse(source, destination) {\n    var h = destination.$$hashKey;\n    var key;\n    if (isArray(source)) {\n      for (var i = 0, ii = source.length; i < ii; i++) {\n        destination.push(copyElement(source[i]));\n      }\n    } else if (isBlankObject(source)) {\n      // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty\n      for (key in source) {\n        destination[key] = copyElement(source[key]);\n      }\n    } else if (source && typeof source.hasOwnProperty === 'function') {\n      // Slow path, which must rely on hasOwnProperty\n      for (key in source) {\n        if (source.hasOwnProperty(key)) {\n          destination[key] = copyElement(source[key]);\n        }\n      }\n    } else {\n      // Slowest path --- hasOwnProperty can't be called as a method\n      for (key in source) {\n        if (hasOwnProperty.call(source, key)) {\n          destination[key] = copyElement(source[key]);\n        }\n      }\n    }\n    setHashKey(destination, h);\n    return destination;\n  }\n\n  function copyElement(source) {\n    // Simple values\n    if (!isObject(source)) {\n      return source;\n    }\n\n    // Already copied values\n    var index = stackSource.indexOf(source);\n    if (index !== -1) {\n      return stackDest[index];\n    }\n\n    if (isWindow(source) || isScope(source)) {\n      throw ngMinErr('cpws',\n        \"Can't copy! Making copies of Window or Scope instances is not supported.\");\n    }\n\n    var needsRecurse = false;\n    var destination = copyType(source);\n\n    if (destination === undefined) {\n      destination = isArray(source) ? [] : Object.create(getPrototypeOf(source));\n      needsRecurse = true;\n    }\n\n    stackSource.push(source);\n    stackDest.push(destination);\n\n    return needsRecurse\n      ? copyRecurse(source, destination)\n      : destination;\n  }\n\n  function copyType(source) {\n    switch (toString.call(source)) {\n      case '[object Int8Array]':\n      case '[object Int16Array]':\n      case '[object Int32Array]':\n      case '[object Float32Array]':\n      case '[object Float64Array]':\n      case '[object Uint8Array]':\n      case '[object Uint8ClampedArray]':\n      case '[object Uint16Array]':\n      case '[object Uint32Array]':\n        return new source.constructor(copyElement(source.buffer));\n\n      case '[object ArrayBuffer]':\n        //Support: IE10\n        if (!source.slice) {\n          var copied = new ArrayBuffer(source.byteLength);\n          new Uint8Array(copied).set(new Uint8Array(source));\n          return copied;\n        }\n        return source.slice(0);\n\n      case '[object Boolean]':\n      case '[object Number]':\n      case '[object String]':\n      case '[object Date]':\n        return new source.constructor(source.valueOf());\n\n      case '[object RegExp]':\n        var re = new RegExp(source.source, source.toString().match(/[^\\/]*$/)[0]);\n        re.lastIndex = source.lastIndex;\n        return re;\n\n      case '[object Blob]':\n        return new source.constructor([source], {type: source.type});\n    }\n\n    if (isFunction(source.cloneNode)) {\n      return source.cloneNode(true);\n    }\n  }\n}\n\n/**\n * Creates a shallow copy of an object, an array or a primitive.\n *\n * Assumes that there are no proto properties for objects.\n */\nfunction shallowCopy(src, dst) {\n  if (isArray(src)) {\n    dst = dst || [];\n\n    for (var i = 0, ii = src.length; i < ii; i++) {\n      dst[i] = src[i];\n    }\n  } else if (isObject(src)) {\n    dst = dst || {};\n\n    for (var key in src) {\n      if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) {\n        dst[key] = src[key];\n      }\n    }\n  }\n\n  return dst || src;\n}\n\n\n/**\n * @ngdoc function\n * @name angular.equals\n * @module ng\n * @kind function\n *\n * @description\n * Determines if two objects or two values are equivalent. Supports value types, regular\n * expressions, arrays and objects.\n *\n * Two objects or values are considered equivalent if at least one of the following is true:\n *\n * * Both objects or values pass `===` comparison.\n * * Both objects or values are of the same type and all of their properties are equal by\n *   comparing them with `angular.equals`.\n * * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal)\n * * Both values represent the same regular expression (In JavaScript,\n *   /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual\n *   representation matches).\n *\n * During a property comparison, properties of `function` type and properties with names\n * that begin with `$` are ignored.\n *\n * Scope and DOMWindow objects are being compared only by identify (`===`).\n *\n * @param {*} o1 Object or value to compare.\n * @param {*} o2 Object or value to compare.\n * @returns {boolean} True if arguments are equal.\n *\n * @example\n   <example module=\"equalsExample\" name=\"equalsExample\">\n     <file name=\"index.html\">\n      <div ng-controller=\"ExampleController\">\n        <form novalidate>\n          <h3>User 1</h3>\n          Name: <input type=\"text\" ng-model=\"user1.name\">\n          Age: <input type=\"number\" ng-model=\"user1.age\">\n\n          <h3>User 2</h3>\n          Name: <input type=\"text\" ng-model=\"user2.name\">\n          Age: <input type=\"number\" ng-model=\"user2.age\">\n\n          <div>\n            <br/>\n            <input type=\"button\" value=\"Compare\" ng-click=\"compare()\">\n          </div>\n          User 1: <pre>{{user1 | json}}</pre>\n          User 2: <pre>{{user2 | json}}</pre>\n          Equal: <pre>{{result}}</pre>\n        </form>\n      </div>\n    </file>\n    <file name=\"script.js\">\n        angular.module('equalsExample', []).controller('ExampleController', ['$scope', function($scope) {\n          $scope.user1 = {};\n          $scope.user2 = {};\n          $scope.result;\n          $scope.compare = function() {\n            $scope.result = angular.equals($scope.user1, $scope.user2);\n          };\n        }]);\n    </file>\n  </example>\n */\nfunction equals(o1, o2) {\n  if (o1 === o2) return true;\n  if (o1 === null || o2 === null) return false;\n  if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN\n  var t1 = typeof o1, t2 = typeof o2, length, key, keySet;\n  if (t1 == t2 && t1 == 'object') {\n    if (isArray(o1)) {\n      if (!isArray(o2)) return false;\n      if ((length = o1.length) == o2.length) {\n        for (key = 0; key < length; key++) {\n          if (!equals(o1[key], o2[key])) return false;\n        }\n        return true;\n      }\n    } else if (isDate(o1)) {\n      if (!isDate(o2)) return false;\n      return equals(o1.getTime(), o2.getTime());\n    } else if (isRegExp(o1)) {\n      if (!isRegExp(o2)) return false;\n      return o1.toString() == o2.toString();\n    } else {\n      if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||\n        isArray(o2) || isDate(o2) || isRegExp(o2)) return false;\n      keySet = createMap();\n      for (key in o1) {\n        if (key.charAt(0) === '$' || isFunction(o1[key])) continue;\n        if (!equals(o1[key], o2[key])) return false;\n        keySet[key] = true;\n      }\n      for (key in o2) {\n        if (!(key in keySet) &&\n            key.charAt(0) !== '$' &&\n            isDefined(o2[key]) &&\n            !isFunction(o2[key])) return false;\n      }\n      return true;\n    }\n  }\n  return false;\n}\n\nvar csp = function() {\n  if (!isDefined(csp.rules)) {\n\n\n    var ngCspElement = (window.document.querySelector('[ng-csp]') ||\n                    window.document.querySelector('[data-ng-csp]'));\n\n    if (ngCspElement) {\n      var ngCspAttribute = ngCspElement.getAttribute('ng-csp') ||\n                    ngCspElement.getAttribute('data-ng-csp');\n      csp.rules = {\n        noUnsafeEval: !ngCspAttribute || (ngCspAttribute.indexOf('no-unsafe-eval') !== -1),\n        noInlineStyle: !ngCspAttribute || (ngCspAttribute.indexOf('no-inline-style') !== -1)\n      };\n    } else {\n      csp.rules = {\n        noUnsafeEval: noUnsafeEval(),\n        noInlineStyle: false\n      };\n    }\n  }\n\n  return csp.rules;\n\n  function noUnsafeEval() {\n    try {\n      /* jshint -W031, -W054 */\n      new Function('');\n      /* jshint +W031, +W054 */\n      return false;\n    } catch (e) {\n      return true;\n    }\n  }\n};\n\n/**\n * @ngdoc directive\n * @module ng\n * @name ngJq\n *\n * @element ANY\n * @param {string=} ngJq the name of the library available under `window`\n * to be used for angular.element\n * @description\n * Use this directive to force the angular.element library.  This should be\n * used to force either jqLite by leaving ng-jq blank or setting the name of\n * the jquery variable under window (eg. jQuery).\n *\n * Since angular looks for this directive when it is loaded (doesn't wait for the\n * DOMContentLoaded event), it must be placed on an element that comes before the script\n * which loads angular. Also, only the first instance of `ng-jq` will be used and all\n * others ignored.\n *\n * @example\n * This example shows how to force jqLite using the `ngJq` directive to the `html` tag.\n ```html\n <!doctype html>\n <html ng-app ng-jq>\n ...\n ...\n </html>\n ```\n * @example\n * This example shows how to use a jQuery based library of a different name.\n * The library name must be available at the top most 'window'.\n ```html\n <!doctype html>\n <html ng-app ng-jq=\"jQueryLib\">\n ...\n ...\n </html>\n ```\n */\nvar jq = function() {\n  if (isDefined(jq.name_)) return jq.name_;\n  var el;\n  var i, ii = ngAttrPrefixes.length, prefix, name;\n  for (i = 0; i < ii; ++i) {\n    prefix = ngAttrPrefixes[i];\n    if (el = window.document.querySelector('[' + prefix.replace(':', '\\\\:') + 'jq]')) {\n      name = el.getAttribute(prefix + 'jq');\n      break;\n    }\n  }\n\n  return (jq.name_ = name);\n};\n\nfunction concat(array1, array2, index) {\n  return array1.concat(slice.call(array2, index));\n}\n\nfunction sliceArgs(args, startIndex) {\n  return slice.call(args, startIndex || 0);\n}\n\n\n/* jshint -W101 */\n/**\n * @ngdoc function\n * @name angular.bind\n * @module ng\n * @kind function\n *\n * @description\n * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for\n * `fn`). You can supply optional `args` that are prebound to the function. This feature is also\n * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as\n * distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).\n *\n * @param {Object} self Context which `fn` should be evaluated in.\n * @param {function()} fn Function to be bound.\n * @param {...*} args Optional arguments to be prebound to the `fn` function call.\n * @returns {function()} Function that wraps the `fn` with all the specified bindings.\n */\n/* jshint +W101 */\nfunction bind(self, fn) {\n  var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];\n  if (isFunction(fn) && !(fn instanceof RegExp)) {\n    return curryArgs.length\n      ? function() {\n          return arguments.length\n            ? fn.apply(self, concat(curryArgs, arguments, 0))\n            : fn.apply(self, curryArgs);\n        }\n      : function() {\n          return arguments.length\n            ? fn.apply(self, arguments)\n            : fn.call(self);\n        };\n  } else {\n    // in IE, native methods are not functions so they cannot be bound (note: they don't need to be)\n    return fn;\n  }\n}\n\n\nfunction toJsonReplacer(key, value) {\n  var val = value;\n\n  if (typeof key === 'string' && key.charAt(0) === '$' && key.charAt(1) === '$') {\n    val = undefined;\n  } else if (isWindow(value)) {\n    val = '$WINDOW';\n  } else if (value &&  window.document === value) {\n    val = '$DOCUMENT';\n  } else if (isScope(value)) {\n    val = '$SCOPE';\n  }\n\n  return val;\n}\n\n\n/**\n * @ngdoc function\n * @name angular.toJson\n * @module ng\n * @kind function\n *\n * @description\n * Serializes input into a JSON-formatted string. Properties with leading $$ characters will be\n * stripped since angular uses this notation internally.\n *\n * @param {Object|Array|Date|string|number} obj Input to be serialized into JSON.\n * @param {boolean|number} [pretty=2] If set to true, the JSON output will contain newlines and whitespace.\n *    If set to an integer, the JSON output will contain that many spaces per indentation.\n * @returns {string|undefined} JSON-ified string representing `obj`.\n */\nfunction toJson(obj, pretty) {\n  if (isUndefined(obj)) return undefined;\n  if (!isNumber(pretty)) {\n    pretty = pretty ? 2 : null;\n  }\n  return JSON.stringify(obj, toJsonReplacer, pretty);\n}\n\n\n/**\n * @ngdoc function\n * @name angular.fromJson\n * @module ng\n * @kind function\n *\n * @description\n * Deserializes a JSON string.\n *\n * @param {string} json JSON string to deserialize.\n * @returns {Object|Array|string|number} Deserialized JSON string.\n */\nfunction fromJson(json) {\n  return isString(json)\n      ? JSON.parse(json)\n      : json;\n}\n\n\nvar ALL_COLONS = /:/g;\nfunction timezoneToOffset(timezone, fallback) {\n  // IE/Edge do not \"understand\" colon (`:`) in timezone\n  timezone = timezone.replace(ALL_COLONS, '');\n  var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;\n  return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;\n}\n\n\nfunction addDateMinutes(date, minutes) {\n  date = new Date(date.getTime());\n  date.setMinutes(date.getMinutes() + minutes);\n  return date;\n}\n\n\nfunction convertTimezoneToLocal(date, timezone, reverse) {\n  reverse = reverse ? -1 : 1;\n  var dateTimezoneOffset = date.getTimezoneOffset();\n  var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n  return addDateMinutes(date, reverse * (timezoneOffset - dateTimezoneOffset));\n}\n\n\n/**\n * @returns {string} Returns the string representation of the element.\n */\nfunction startingTag(element) {\n  element = jqLite(element).clone();\n  try {\n    // turns out IE does not let you set .html() on elements which\n    // are not allowed to have children. So we just ignore it.\n    element.empty();\n  } catch (e) {}\n  var elemHtml = jqLite('<div>').append(element).html();\n  try {\n    return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) :\n        elemHtml.\n          match(/^(<[^>]+>)/)[1].\n          replace(/^<([\\w\\-]+)/, function(match, nodeName) {return '<' + lowercase(nodeName);});\n  } catch (e) {\n    return lowercase(elemHtml);\n  }\n\n}\n\n\n/////////////////////////////////////////////////\n\n/**\n * Tries to decode the URI component without throwing an exception.\n *\n * @private\n * @param str value potential URI component to check.\n * @returns {boolean} True if `value` can be decoded\n * with the decodeURIComponent function.\n */\nfunction tryDecodeURIComponent(value) {\n  try {\n    return decodeURIComponent(value);\n  } catch (e) {\n    // Ignore any invalid uri component\n  }\n}\n\n\n/**\n * Parses an escaped url query string into key-value pairs.\n * @returns {Object.<string,boolean|Array>}\n */\nfunction parseKeyValue(/**string*/keyValue) {\n  var obj = {};\n  forEach((keyValue || \"\").split('&'), function(keyValue) {\n    var splitPoint, key, val;\n    if (keyValue) {\n      key = keyValue = keyValue.replace(/\\+/g,'%20');\n      splitPoint = keyValue.indexOf('=');\n      if (splitPoint !== -1) {\n        key = keyValue.substring(0, splitPoint);\n        val = keyValue.substring(splitPoint + 1);\n      }\n      key = tryDecodeURIComponent(key);\n      if (isDefined(key)) {\n        val = isDefined(val) ? tryDecodeURIComponent(val) : true;\n        if (!hasOwnProperty.call(obj, key)) {\n          obj[key] = val;\n        } else if (isArray(obj[key])) {\n          obj[key].push(val);\n        } else {\n          obj[key] = [obj[key],val];\n        }\n      }\n    }\n  });\n  return obj;\n}\n\nfunction toKeyValue(obj) {\n  var parts = [];\n  forEach(obj, function(value, key) {\n    if (isArray(value)) {\n      forEach(value, function(arrayValue) {\n        parts.push(encodeUriQuery(key, true) +\n                   (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));\n      });\n    } else {\n    parts.push(encodeUriQuery(key, true) +\n               (value === true ? '' : '=' + encodeUriQuery(value, true)));\n    }\n  });\n  return parts.length ? parts.join('&') : '';\n}\n\n\n/**\n * We need our custom method because encodeURIComponent is too aggressive and doesn't follow\n * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path\n * segments:\n *    segment       = *pchar\n *    pchar         = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n *    pct-encoded   = \"%\" HEXDIG HEXDIG\n *    unreserved    = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n *    sub-delims    = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\"\n *                     / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n */\nfunction encodeUriSegment(val) {\n  return encodeUriQuery(val, true).\n             replace(/%26/gi, '&').\n             replace(/%3D/gi, '=').\n             replace(/%2B/gi, '+');\n}\n\n\n/**\n * This method is intended for encoding *key* or *value* parts of query component. We need a custom\n * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be\n * encoded per http://tools.ietf.org/html/rfc3986:\n *    query       = *( pchar / \"/\" / \"?\" )\n *    pchar         = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n *    unreserved    = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n *    pct-encoded   = \"%\" HEXDIG HEXDIG\n *    sub-delims    = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\"\n *                     / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n */\nfunction encodeUriQuery(val, pctEncodeSpaces) {\n  return encodeURIComponent(val).\n             replace(/%40/gi, '@').\n             replace(/%3A/gi, ':').\n             replace(/%24/g, '$').\n             replace(/%2C/gi, ',').\n             replace(/%3B/gi, ';').\n             replace(/%20/g, (pctEncodeSpaces ? '%20' : '+'));\n}\n\nvar ngAttrPrefixes = ['ng-', 'data-ng-', 'ng:', 'x-ng-'];\n\nfunction getNgAttribute(element, ngAttr) {\n  var attr, i, ii = ngAttrPrefixes.length;\n  for (i = 0; i < ii; ++i) {\n    attr = ngAttrPrefixes[i] + ngAttr;\n    if (isString(attr = element.getAttribute(attr))) {\n      return attr;\n    }\n  }\n  return null;\n}\n\n/**\n * @ngdoc directive\n * @name ngApp\n * @module ng\n *\n * @element ANY\n * @param {angular.Module} ngApp an optional application\n *   {@link angular.module module} name to load.\n * @param {boolean=} ngStrictDi if this attribute is present on the app element, the injector will be\n *   created in \"strict-di\" mode. This means that the application will fail to invoke functions which\n *   do not use explicit function annotation (and are thus unsuitable for minification), as described\n *   in {@link guide/di the Dependency Injection guide}, and useful debugging info will assist in\n *   tracking down the root of these bugs.\n *\n * @description\n *\n * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive\n * designates the **root element** of the application and is typically placed near the root element\n * of the page - e.g. on the `<body>` or `<html>` tags.\n *\n * There are a few things to keep in mind when using `ngApp`:\n * - only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`\n *   found in the document will be used to define the root element to auto-bootstrap as an\n *   application. To run multiple applications in an HTML document you must manually bootstrap them using\n *   {@link angular.bootstrap} instead.\n * - AngularJS applications cannot be nested within each other.\n * - Do not use a directive that uses {@link ng.$compile#transclusion transclusion} on the same element as `ngApp`.\n *   This includes directives such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and\n *   {@link ngRoute.ngView `ngView`}.\n *   Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},\n *   causing animations to stop working and making the injector inaccessible from outside the app.\n *\n * You can specify an **AngularJS module** to be used as the root module for the application.  This\n * module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It\n * should contain the application code needed or have dependencies on other modules that will\n * contain the code. See {@link angular.module} for more information.\n *\n * In the example below if the `ngApp` directive were not placed on the `html` element then the\n * document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`\n * would not be resolved to `3`.\n *\n * `ngApp` is the easiest, and most common way to bootstrap an application.\n *\n <example module=\"ngAppDemo\">\n   <file name=\"index.html\">\n   <div ng-controller=\"ngAppDemoController\">\n     I can add: {{a}} + {{b}} =  {{ a+b }}\n   </div>\n   </file>\n   <file name=\"script.js\">\n   angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {\n     $scope.a = 1;\n     $scope.b = 2;\n   });\n   </file>\n </example>\n *\n * Using `ngStrictDi`, you would see something like this:\n *\n <example ng-app-included=\"true\">\n   <file name=\"index.html\">\n   <div ng-app=\"ngAppStrictDemo\" ng-strict-di>\n       <div ng-controller=\"GoodController1\">\n           I can add: {{a}} + {{b}} =  {{ a+b }}\n\n           <p>This renders because the controller does not fail to\n              instantiate, by using explicit annotation style (see\n              script.js for details)\n           </p>\n       </div>\n\n       <div ng-controller=\"GoodController2\">\n           Name: <input ng-model=\"name\"><br />\n           Hello, {{name}}!\n\n           <p>This renders because the controller does not fail to\n              instantiate, by using explicit annotation style\n              (see script.js for details)\n           </p>\n       </div>\n\n       <div ng-controller=\"BadController\">\n           I can add: {{a}} + {{b}} =  {{ a+b }}\n\n           <p>The controller could not be instantiated, due to relying\n              on automatic function annotations (which are disabled in\n              strict mode). As such, the content of this section is not\n              interpolated, and there should be an error in your web console.\n           </p>\n       </div>\n   </div>\n   </file>\n   <file name=\"script.js\">\n   angular.module('ngAppStrictDemo', [])\n     // BadController will fail to instantiate, due to relying on automatic function annotation,\n     // rather than an explicit annotation\n     .controller('BadController', function($scope) {\n       $scope.a = 1;\n       $scope.b = 2;\n     })\n     // Unlike BadController, GoodController1 and GoodController2 will not fail to be instantiated,\n     // due to using explicit annotations using the array style and $inject property, respectively.\n     .controller('GoodController1', ['$scope', function($scope) {\n       $scope.a = 1;\n       $scope.b = 2;\n     }])\n     .controller('GoodController2', GoodController2);\n     function GoodController2($scope) {\n       $scope.name = \"World\";\n     }\n     GoodController2.$inject = ['$scope'];\n   </file>\n   <file name=\"style.css\">\n   div[ng-controller] {\n       margin-bottom: 1em;\n       -webkit-border-radius: 4px;\n       border-radius: 4px;\n       border: 1px solid;\n       padding: .5em;\n   }\n   div[ng-controller^=Good] {\n       border-color: #d6e9c6;\n       background-color: #dff0d8;\n       color: #3c763d;\n   }\n   div[ng-controller^=Bad] {\n       border-color: #ebccd1;\n       background-color: #f2dede;\n       color: #a94442;\n       margin-bottom: 0;\n   }\n   </file>\n </example>\n */\nfunction angularInit(element, bootstrap) {\n  var appElement,\n      module,\n      config = {};\n\n  // The element `element` has priority over any other element\n  forEach(ngAttrPrefixes, function(prefix) {\n    var name = prefix + 'app';\n\n    if (!appElement && element.hasAttribute && element.hasAttribute(name)) {\n      appElement = element;\n      module = element.getAttribute(name);\n    }\n  });\n  forEach(ngAttrPrefixes, function(prefix) {\n    var name = prefix + 'app';\n    var candidate;\n\n    if (!appElement && (candidate = element.querySelector('[' + name.replace(':', '\\\\:') + ']'))) {\n      appElement = candidate;\n      module = candidate.getAttribute(name);\n    }\n  });\n  if (appElement) {\n    config.strictDi = getNgAttribute(appElement, \"strict-di\") !== null;\n    bootstrap(appElement, module ? [module] : [], config);\n  }\n}\n\n/**\n * @ngdoc function\n * @name angular.bootstrap\n * @module ng\n * @description\n * Use this function to manually start up angular application.\n *\n * For more information, see the {@link guide/bootstrap Bootstrap guide}.\n *\n * Angular will detect if it has been loaded into the browser more than once and only allow the\n * first loaded script to be bootstrapped and will report a warning to the browser console for\n * each of the subsequent scripts. This prevents strange results in applications, where otherwise\n * multiple instances of Angular try to work on the DOM.\n *\n * <div class=\"alert alert-warning\">\n * **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.\n * They must use {@link ng.directive:ngApp ngApp}.\n * </div>\n *\n * <div class=\"alert alert-warning\">\n * **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},\n * such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.\n * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},\n * causing animations to stop working and making the injector inaccessible from outside the app.\n * </div>\n *\n * ```html\n * <!doctype html>\n * <html>\n * <body>\n * <div ng-controller=\"WelcomeController\">\n *   {{greeting}}\n * </div>\n *\n * <script src=\"angular.js\"></script>\n * <script>\n *   var app = angular.module('demo', [])\n *   .controller('WelcomeController', function($scope) {\n *       $scope.greeting = 'Welcome!';\n *   });\n *   angular.bootstrap(document, ['demo']);\n * </script>\n * </body>\n * </html>\n * ```\n *\n * @param {DOMElement} element DOM element which is the root of angular application.\n * @param {Array<String|Function|Array>=} modules an array of modules to load into the application.\n *     Each item in the array should be the name of a predefined module or a (DI annotated)\n *     function that will be invoked by the injector as a `config` block.\n *     See: {@link angular.module modules}\n * @param {Object=} config an object for defining configuration options for the application. The\n *     following keys are supported:\n *\n * * `strictDi` - disable automatic function annotation for the application. This is meant to\n *   assist in finding bugs which break minified code. Defaults to `false`.\n *\n * @returns {auto.$injector} Returns the newly created injector for this app.\n */\nfunction bootstrap(element, modules, config) {\n  if (!isObject(config)) config = {};\n  var defaultConfig = {\n    strictDi: false\n  };\n  config = extend(defaultConfig, config);\n  var doBootstrap = function() {\n    element = jqLite(element);\n\n    if (element.injector()) {\n      var tag = (element[0] === window.document) ? 'document' : startingTag(element);\n      //Encode angle brackets to prevent input from being sanitized to empty string #8683\n      throw ngMinErr(\n          'btstrpd',\n          \"App already bootstrapped with this element '{0}'\",\n          tag.replace(/</,'&lt;').replace(/>/,'&gt;'));\n    }\n\n    modules = modules || [];\n    modules.unshift(['$provide', function($provide) {\n      $provide.value('$rootElement', element);\n    }]);\n\n    if (config.debugInfoEnabled) {\n      // Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.\n      modules.push(['$compileProvider', function($compileProvider) {\n        $compileProvider.debugInfoEnabled(true);\n      }]);\n    }\n\n    modules.unshift('ng');\n    var injector = createInjector(modules, config.strictDi);\n    injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',\n       function bootstrapApply(scope, element, compile, injector) {\n        scope.$apply(function() {\n          element.data('$injector', injector);\n          compile(element)(scope);\n        });\n      }]\n    );\n    return injector;\n  };\n\n  var NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;\n  var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;\n\n  if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {\n    config.debugInfoEnabled = true;\n    window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, '');\n  }\n\n  if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {\n    return doBootstrap();\n  }\n\n  window.name = window.name.replace(NG_DEFER_BOOTSTRAP, '');\n  angular.resumeBootstrap = function(extraModules) {\n    forEach(extraModules, function(module) {\n      modules.push(module);\n    });\n    return doBootstrap();\n  };\n\n  if (isFunction(angular.resumeDeferredBootstrap)) {\n    angular.resumeDeferredBootstrap();\n  }\n}\n\n/**\n * @ngdoc function\n * @name angular.reloadWithDebugInfo\n * @module ng\n * @description\n * Use this function to reload the current application with debug information turned on.\n * This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`.\n *\n * See {@link ng.$compileProvider#debugInfoEnabled} for more.\n */\nfunction reloadWithDebugInfo() {\n  window.name = 'NG_ENABLE_DEBUG_INFO!' + window.name;\n  window.location.reload();\n}\n\n/**\n * @name angular.getTestability\n * @module ng\n * @description\n * Get the testability service for the instance of Angular on the given\n * element.\n * @param {DOMElement} element DOM element which is the root of angular application.\n */\nfunction getTestability(rootElement) {\n  var injector = angular.element(rootElement).injector();\n  if (!injector) {\n    throw ngMinErr('test',\n      'no injector found for element argument to getTestability');\n  }\n  return injector.get('$$testability');\n}\n\nvar SNAKE_CASE_REGEXP = /[A-Z]/g;\nfunction snake_case(name, separator) {\n  separator = separator || '_';\n  return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) {\n    return (pos ? separator : '') + letter.toLowerCase();\n  });\n}\n\nvar bindJQueryFired = false;\nfunction bindJQuery() {\n  var originalCleanData;\n\n  if (bindJQueryFired) {\n    return;\n  }\n\n  // bind to jQuery if present;\n  var jqName = jq();\n  jQuery = isUndefined(jqName) ? window.jQuery :   // use jQuery (if present)\n           !jqName             ? undefined     :   // use jqLite\n                                 window[jqName];   // use jQuery specified by `ngJq`\n\n  // Use jQuery if it exists with proper functionality, otherwise default to us.\n  // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.\n  // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older\n  // versions. It will not work for sure with jQuery <1.7, though.\n  if (jQuery && jQuery.fn.on) {\n    jqLite = jQuery;\n    extend(jQuery.fn, {\n      scope: JQLitePrototype.scope,\n      isolateScope: JQLitePrototype.isolateScope,\n      controller: JQLitePrototype.controller,\n      injector: JQLitePrototype.injector,\n      inheritedData: JQLitePrototype.inheritedData\n    });\n\n    // All nodes removed from the DOM via various jQuery APIs like .remove()\n    // are passed through jQuery.cleanData. Monkey-patch this method to fire\n    // the $destroy event on all removed nodes.\n    originalCleanData = jQuery.cleanData;\n    jQuery.cleanData = function(elems) {\n      var events;\n      for (var i = 0, elem; (elem = elems[i]) != null; i++) {\n        events = jQuery._data(elem, \"events\");\n        if (events && events.$destroy) {\n          jQuery(elem).triggerHandler('$destroy');\n        }\n      }\n      originalCleanData(elems);\n    };\n  } else {\n    jqLite = JQLite;\n  }\n\n  angular.element = jqLite;\n\n  // Prevent double-proxying.\n  bindJQueryFired = true;\n}\n\n/**\n * throw error if the argument is falsy.\n */\nfunction assertArg(arg, name, reason) {\n  if (!arg) {\n    throw ngMinErr('areq', \"Argument '{0}' is {1}\", (name || '?'), (reason || \"required\"));\n  }\n  return arg;\n}\n\nfunction assertArgFn(arg, name, acceptArrayAnnotation) {\n  if (acceptArrayAnnotation && isArray(arg)) {\n      arg = arg[arg.length - 1];\n  }\n\n  assertArg(isFunction(arg), name, 'not a function, got ' +\n      (arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg));\n  return arg;\n}\n\n/**\n * throw error if the name given is hasOwnProperty\n * @param  {String} name    the name to test\n * @param  {String} context the context in which the name is used, such as module or directive\n */\nfunction assertNotHasOwnProperty(name, context) {\n  if (name === 'hasOwnProperty') {\n    throw ngMinErr('badname', \"hasOwnProperty is not a valid {0} name\", context);\n  }\n}\n\n/**\n * Return the value accessible from the object by path. Any undefined traversals are ignored\n * @param {Object} obj starting object\n * @param {String} path path to traverse\n * @param {boolean} [bindFnToScope=true]\n * @returns {Object} value as accessible by path\n */\n//TODO(misko): this function needs to be removed\nfunction getter(obj, path, bindFnToScope) {\n  if (!path) return obj;\n  var keys = path.split('.');\n  var key;\n  var lastInstance = obj;\n  var len = keys.length;\n\n  for (var i = 0; i < len; i++) {\n    key = keys[i];\n    if (obj) {\n      obj = (lastInstance = obj)[key];\n    }\n  }\n  if (!bindFnToScope && isFunction(obj)) {\n    return bind(lastInstance, obj);\n  }\n  return obj;\n}\n\n/**\n * Return the DOM siblings between the first and last node in the given array.\n * @param {Array} array like object\n * @returns {Array} the inputted object or a jqLite collection containing the nodes\n */\nfunction getBlockNodes(nodes) {\n  // TODO(perf): update `nodes` instead of creating a new object?\n  var node = nodes[0];\n  var endNode = nodes[nodes.length - 1];\n  var blockNodes;\n\n  for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {\n    if (blockNodes || nodes[i] !== node) {\n      if (!blockNodes) {\n        blockNodes = jqLite(slice.call(nodes, 0, i));\n      }\n      blockNodes.push(node);\n    }\n  }\n\n  return blockNodes || nodes;\n}\n\n\n/**\n * Creates a new object without a prototype. This object is useful for lookup without having to\n * guard against prototypically inherited properties via hasOwnProperty.\n *\n * Related micro-benchmarks:\n * - http://jsperf.com/object-create2\n * - http://jsperf.com/proto-map-lookup/2\n * - http://jsperf.com/for-in-vs-object-keys2\n *\n * @returns {Object}\n */\nfunction createMap() {\n  return Object.create(null);\n}\n\nvar NODE_TYPE_ELEMENT = 1;\nvar NODE_TYPE_ATTRIBUTE = 2;\nvar NODE_TYPE_TEXT = 3;\nvar NODE_TYPE_COMMENT = 8;\nvar NODE_TYPE_DOCUMENT = 9;\nvar NODE_TYPE_DOCUMENT_FRAGMENT = 11;\n\n/**\n * @ngdoc type\n * @name angular.Module\n * @module ng\n * @description\n *\n * Interface for configuring angular {@link angular.module modules}.\n */\n\nfunction setupModuleLoader(window) {\n\n  var $injectorMinErr = minErr('$injector');\n  var ngMinErr = minErr('ng');\n\n  function ensure(obj, name, factory) {\n    return obj[name] || (obj[name] = factory());\n  }\n\n  var angular = ensure(window, 'angular', Object);\n\n  // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap\n  angular.$$minErr = angular.$$minErr || minErr;\n\n  return ensure(angular, 'module', function() {\n    /** @type {Object.<string, angular.Module>} */\n    var modules = {};\n\n    /**\n     * @ngdoc function\n     * @name angular.module\n     * @module ng\n     * @description\n     *\n     * The `angular.module` is a global place for creating, registering and retrieving Angular\n     * modules.\n     * All modules (angular core or 3rd party) that should be available to an application must be\n     * registered using this mechanism.\n     *\n     * Passing one argument retrieves an existing {@link angular.Module},\n     * whereas passing more than one argument creates a new {@link angular.Module}\n     *\n     *\n     * # Module\n     *\n     * A module is a collection of services, directives, controllers, filters, and configuration information.\n     * `angular.module` is used to configure the {@link auto.$injector $injector}.\n     *\n     * ```js\n     * // Create a new module\n     * var myModule = angular.module('myModule', []);\n     *\n     * // register a new service\n     * myModule.value('appName', 'MyCoolApp');\n     *\n     * // configure existing services inside initialization blocks.\n     * myModule.config(['$locationProvider', function($locationProvider) {\n     *   // Configure existing providers\n     *   $locationProvider.hashPrefix('!');\n     * }]);\n     * ```\n     *\n     * Then you can create an injector and load your modules like this:\n     *\n     * ```js\n     * var injector = angular.injector(['ng', 'myModule'])\n     * ```\n     *\n     * However it's more likely that you'll just use\n     * {@link ng.directive:ngApp ngApp} or\n     * {@link angular.bootstrap} to simplify this process for you.\n     *\n     * @param {!string} name The name of the module to create or retrieve.\n     * @param {!Array.<string>=} requires If specified then new module is being created. If\n     *        unspecified then the module is being retrieved for further configuration.\n     * @param {Function=} configFn Optional configuration function for the module. Same as\n     *        {@link angular.Module#config Module#config()}.\n     * @returns {angular.Module} new module with the {@link angular.Module} api.\n     */\n    return function module(name, requires, configFn) {\n      var assertNotHasOwnProperty = function(name, context) {\n        if (name === 'hasOwnProperty') {\n          throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);\n        }\n      };\n\n      assertNotHasOwnProperty(name, 'module');\n      if (requires && modules.hasOwnProperty(name)) {\n        modules[name] = null;\n      }\n      return ensure(modules, name, function() {\n        if (!requires) {\n          throw $injectorMinErr('nomod', \"Module '{0}' is not available! You either misspelled \" +\n             \"the module name or forgot to load it. If registering a module ensure that you \" +\n             \"specify the dependencies as the second argument.\", name);\n        }\n\n        /** @type {!Array.<Array.<*>>} */\n        var invokeQueue = [];\n\n        /** @type {!Array.<Function>} */\n        var configBlocks = [];\n\n        /** @type {!Array.<Function>} */\n        var runBlocks = [];\n\n        var config = invokeLater('$injector', 'invoke', 'push', configBlocks);\n\n        /** @type {angular.Module} */\n        var moduleInstance = {\n          // Private state\n          _invokeQueue: invokeQueue,\n          _configBlocks: configBlocks,\n          _runBlocks: runBlocks,\n\n          /**\n           * @ngdoc property\n           * @name angular.Module#requires\n           * @module ng\n           *\n           * @description\n           * Holds the list of modules which the injector will load before the current module is\n           * loaded.\n           */\n          requires: requires,\n\n          /**\n           * @ngdoc property\n           * @name angular.Module#name\n           * @module ng\n           *\n           * @description\n           * Name of the module.\n           */\n          name: name,\n\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#provider\n           * @module ng\n           * @param {string} name service name\n           * @param {Function} providerType Construction function for creating new instance of the\n           *                                service.\n           * @description\n           * See {@link auto.$provide#provider $provide.provider()}.\n           */\n          provider: invokeLaterAndSetModuleName('$provide', 'provider'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#factory\n           * @module ng\n           * @param {string} name service name\n           * @param {Function} providerFunction Function for creating new instance of the service.\n           * @description\n           * See {@link auto.$provide#factory $provide.factory()}.\n           */\n          factory: invokeLaterAndSetModuleName('$provide', 'factory'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#service\n           * @module ng\n           * @param {string} name service name\n           * @param {Function} constructor A constructor function that will be instantiated.\n           * @description\n           * See {@link auto.$provide#service $provide.service()}.\n           */\n          service: invokeLaterAndSetModuleName('$provide', 'service'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#value\n           * @module ng\n           * @param {string} name service name\n           * @param {*} object Service instance object.\n           * @description\n           * See {@link auto.$provide#value $provide.value()}.\n           */\n          value: invokeLater('$provide', 'value'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#constant\n           * @module ng\n           * @param {string} name constant name\n           * @param {*} object Constant value.\n           * @description\n           * Because the constants are fixed, they get applied before other provide methods.\n           * See {@link auto.$provide#constant $provide.constant()}.\n           */\n          constant: invokeLater('$provide', 'constant', 'unshift'),\n\n           /**\n           * @ngdoc method\n           * @name angular.Module#decorator\n           * @module ng\n           * @param {string} name The name of the service to decorate.\n           * @param {Function} decorFn This function will be invoked when the service needs to be\n           *                           instantiated and should return the decorated service instance.\n           * @description\n           * See {@link auto.$provide#decorator $provide.decorator()}.\n           */\n          decorator: invokeLaterAndSetModuleName('$provide', 'decorator'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#animation\n           * @module ng\n           * @param {string} name animation name\n           * @param {Function} animationFactory Factory function for creating new instance of an\n           *                                    animation.\n           * @description\n           *\n           * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.\n           *\n           *\n           * Defines an animation hook that can be later used with\n           * {@link $animate $animate} service and directives that use this service.\n           *\n           * ```js\n           * module.animation('.animation-name', function($inject1, $inject2) {\n           *   return {\n           *     eventName : function(element, done) {\n           *       //code to run the animation\n           *       //once complete, then run done()\n           *       return function cancellationFunction(element) {\n           *         //code to cancel the animation\n           *       }\n           *     }\n           *   }\n           * })\n           * ```\n           *\n           * See {@link ng.$animateProvider#register $animateProvider.register()} and\n           * {@link ngAnimate ngAnimate module} for more information.\n           */\n          animation: invokeLaterAndSetModuleName('$animateProvider', 'register'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#filter\n           * @module ng\n           * @param {string} name Filter name - this must be a valid angular expression identifier\n           * @param {Function} filterFactory Factory function for creating new instance of filter.\n           * @description\n           * See {@link ng.$filterProvider#register $filterProvider.register()}.\n           *\n           * <div class=\"alert alert-warning\">\n           * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.\n           * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace\n           * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores\n           * (`myapp_subsection_filterx`).\n           * </div>\n           */\n          filter: invokeLaterAndSetModuleName('$filterProvider', 'register'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#controller\n           * @module ng\n           * @param {string|Object} name Controller name, or an object map of controllers where the\n           *    keys are the names and the values are the constructors.\n           * @param {Function} constructor Controller constructor function.\n           * @description\n           * See {@link ng.$controllerProvider#register $controllerProvider.register()}.\n           */\n          controller: invokeLaterAndSetModuleName('$controllerProvider', 'register'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#directive\n           * @module ng\n           * @param {string|Object} name Directive name, or an object map of directives where the\n           *    keys are the names and the values are the factories.\n           * @param {Function} directiveFactory Factory function for creating new instance of\n           * directives.\n           * @description\n           * See {@link ng.$compileProvider#directive $compileProvider.directive()}.\n           */\n          directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#component\n           * @module ng\n           * @param {string} name Name of the component in camel-case (i.e. myComp which will match as my-comp)\n           * @param {Object} options Component definition object (a simplified\n           *    {@link ng.$compile#directive-definition-object directive definition object})\n           *\n           * @description\n           * See {@link ng.$compileProvider#component $compileProvider.component()}.\n           */\n          component: invokeLaterAndSetModuleName('$compileProvider', 'component'),\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#config\n           * @module ng\n           * @param {Function} configFn Execute this function on module load. Useful for service\n           *    configuration.\n           * @description\n           * Use this method to register work which needs to be performed on module loading.\n           * For more about how to configure services, see\n           * {@link providers#provider-recipe Provider Recipe}.\n           */\n          config: config,\n\n          /**\n           * @ngdoc method\n           * @name angular.Module#run\n           * @module ng\n           * @param {Function} initializationFn Execute this function after injector creation.\n           *    Useful for application initialization.\n           * @description\n           * Use this method to register work which should be performed when the injector is done\n           * loading all modules.\n           */\n          run: function(block) {\n            runBlocks.push(block);\n            return this;\n          }\n        };\n\n        if (configFn) {\n          config(configFn);\n        }\n\n        return moduleInstance;\n\n        /**\n         * @param {string} provider\n         * @param {string} method\n         * @param {String=} insertMethod\n         * @returns {angular.Module}\n         */\n        function invokeLater(provider, method, insertMethod, queue) {\n          if (!queue) queue = invokeQueue;\n          return function() {\n            queue[insertMethod || 'push']([provider, method, arguments]);\n            return moduleInstance;\n          };\n        }\n\n        /**\n         * @param {string} provider\n         * @param {string} method\n         * @returns {angular.Module}\n         */\n        function invokeLaterAndSetModuleName(provider, method) {\n          return function(recipeName, factoryFunction) {\n            if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name;\n            invokeQueue.push([provider, method, arguments]);\n            return moduleInstance;\n          };\n        }\n      });\n    };\n  });\n\n}\n\n/* global: toDebugString: true */\n\nfunction serializeObject(obj) {\n  var seen = [];\n\n  return JSON.stringify(obj, function(key, val) {\n    val = toJsonReplacer(key, val);\n    if (isObject(val)) {\n\n      if (seen.indexOf(val) >= 0) return '...';\n\n      seen.push(val);\n    }\n    return val;\n  });\n}\n\nfunction toDebugString(obj) {\n  if (typeof obj === 'function') {\n    return obj.toString().replace(/ \\{[\\s\\S]*$/, '');\n  } else if (isUndefined(obj)) {\n    return 'undefined';\n  } else if (typeof obj !== 'string') {\n    return serializeObject(obj);\n  }\n  return obj;\n}\n\n/* global angularModule: true,\n  version: true,\n\n  $CompileProvider,\n\n  htmlAnchorDirective,\n  inputDirective,\n  inputDirective,\n  formDirective,\n  scriptDirective,\n  selectDirective,\n  styleDirective,\n  optionDirective,\n  ngBindDirective,\n  ngBindHtmlDirective,\n  ngBindTemplateDirective,\n  ngClassDirective,\n  ngClassEvenDirective,\n  ngClassOddDirective,\n  ngCloakDirective,\n  ngControllerDirective,\n  ngFormDirective,\n  ngHideDirective,\n  ngIfDirective,\n  ngIncludeDirective,\n  ngIncludeFillContentDirective,\n  ngInitDirective,\n  ngNonBindableDirective,\n  ngPluralizeDirective,\n  ngRepeatDirective,\n  ngShowDirective,\n  ngStyleDirective,\n  ngSwitchDirective,\n  ngSwitchWhenDirective,\n  ngSwitchDefaultDirective,\n  ngOptionsDirective,\n  ngTranscludeDirective,\n  ngModelDirective,\n  ngListDirective,\n  ngChangeDirective,\n  patternDirective,\n  patternDirective,\n  requiredDirective,\n  requiredDirective,\n  minlengthDirective,\n  minlengthDirective,\n  maxlengthDirective,\n  maxlengthDirective,\n  ngValueDirective,\n  ngModelOptionsDirective,\n  ngAttributeAliasDirectives,\n  ngEventDirectives,\n\n  $AnchorScrollProvider,\n  $AnimateProvider,\n  $CoreAnimateCssProvider,\n  $$CoreAnimateJsProvider,\n  $$CoreAnimateQueueProvider,\n  $$AnimateRunnerFactoryProvider,\n  $$AnimateAsyncRunFactoryProvider,\n  $BrowserProvider,\n  $CacheFactoryProvider,\n  $ControllerProvider,\n  $DateProvider,\n  $DocumentProvider,\n  $ExceptionHandlerProvider,\n  $FilterProvider,\n  $$ForceReflowProvider,\n  $InterpolateProvider,\n  $IntervalProvider,\n  $$HashMapProvider,\n  $HttpProvider,\n  $HttpParamSerializerProvider,\n  $HttpParamSerializerJQLikeProvider,\n  $HttpBackendProvider,\n  $xhrFactoryProvider,\n  $LocationProvider,\n  $LogProvider,\n  $ParseProvider,\n  $RootScopeProvider,\n  $QProvider,\n  $$QProvider,\n  $$SanitizeUriProvider,\n  $SceProvider,\n  $SceDelegateProvider,\n  $SnifferProvider,\n  $TemplateCacheProvider,\n  $TemplateRequestProvider,\n  $$TestabilityProvider,\n  $TimeoutProvider,\n  $$RAFProvider,\n  $WindowProvider,\n  $$jqLiteProvider,\n  $$CookieReaderProvider\n*/\n\n\n/**\n * @ngdoc object\n * @name angular.version\n * @module ng\n * @description\n * An object that contains information about the current AngularJS version.\n *\n * This object has the following properties:\n *\n * - `full` – `{string}` – Full version string, such as \"0.9.18\".\n * - `major` – `{number}` – Major version number, such as \"0\".\n * - `minor` – `{number}` – Minor version number, such as \"9\".\n * - `dot` – `{number}` – Dot version number, such as \"18\".\n * - `codeName` – `{string}` – Code name of the release, such as \"jiggling-armfat\".\n */\nvar version = {\n  full: '1.5.5',    // all of these placeholder strings will be replaced by grunt's\n  major: 1,    // package task\n  minor: 5,\n  dot: 5,\n  codeName: 'material-conspiration'\n};\n\n\nfunction publishExternalAPI(angular) {\n  extend(angular, {\n    'bootstrap': bootstrap,\n    'copy': copy,\n    'extend': extend,\n    'merge': merge,\n    'equals': equals,\n    'element': jqLite,\n    'forEach': forEach,\n    'injector': createInjector,\n    'noop': noop,\n    'bind': bind,\n    'toJson': toJson,\n    'fromJson': fromJson,\n    'identity': identity,\n    'isUndefined': isUndefined,\n    'isDefined': isDefined,\n    'isString': isString,\n    'isFunction': isFunction,\n    'isObject': isObject,\n    'isNumber': isNumber,\n    'isElement': isElement,\n    'isArray': isArray,\n    'version': version,\n    'isDate': isDate,\n    'lowercase': lowercase,\n    'uppercase': uppercase,\n    'callbacks': {counter: 0},\n    'getTestability': getTestability,\n    '$$minErr': minErr,\n    '$$csp': csp,\n    'reloadWithDebugInfo': reloadWithDebugInfo\n  });\n\n  angularModule = setupModuleLoader(window);\n\n  angularModule('ng', ['ngLocale'], ['$provide',\n    function ngModule($provide) {\n      // $$sanitizeUriProvider needs to be before $compileProvider as it is used by it.\n      $provide.provider({\n        $$sanitizeUri: $$SanitizeUriProvider\n      });\n      $provide.provider('$compile', $CompileProvider).\n        directive({\n            a: htmlAnchorDirective,\n            input: inputDirective,\n            textarea: inputDirective,\n            form: formDirective,\n            script: scriptDirective,\n            select: selectDirective,\n            style: styleDirective,\n            option: optionDirective,\n            ngBind: ngBindDirective,\n            ngBindHtml: ngBindHtmlDirective,\n            ngBindTemplate: ngBindTemplateDirective,\n            ngClass: ngClassDirective,\n            ngClassEven: ngClassEvenDirective,\n            ngClassOdd: ngClassOddDirective,\n            ngCloak: ngCloakDirective,\n            ngController: ngControllerDirective,\n            ngForm: ngFormDirective,\n            ngHide: ngHideDirective,\n            ngIf: ngIfDirective,\n            ngInclude: ngIncludeDirective,\n            ngInit: ngInitDirective,\n            ngNonBindable: ngNonBindableDirective,\n            ngPluralize: ngPluralizeDirective,\n            ngRepeat: ngRepeatDirective,\n            ngShow: ngShowDirective,\n            ngStyle: ngStyleDirective,\n            ngSwitch: ngSwitchDirective,\n            ngSwitchWhen: ngSwitchWhenDirective,\n            ngSwitchDefault: ngSwitchDefaultDirective,\n            ngOptions: ngOptionsDirective,\n            ngTransclude: ngTranscludeDirective,\n            ngModel: ngModelDirective,\n            ngList: ngListDirective,\n            ngChange: ngChangeDirective,\n            pattern: patternDirective,\n            ngPattern: patternDirective,\n            required: requiredDirective,\n            ngRequired: requiredDirective,\n            minlength: minlengthDirective,\n            ngMinlength: minlengthDirective,\n            maxlength: maxlengthDirective,\n            ngMaxlength: maxlengthDirective,\n            ngValue: ngValueDirective,\n            ngModelOptions: ngModelOptionsDirective\n        }).\n        directive({\n          ngInclude: ngIncludeFillContentDirective\n        }).\n        directive(ngAttributeAliasDirectives).\n        directive(ngEventDirectives);\n      $provide.provider({\n        $anchorScroll: $AnchorScrollProvider,\n        $animate: $AnimateProvider,\n        $animateCss: $CoreAnimateCssProvider,\n        $$animateJs: $$CoreAnimateJsProvider,\n        $$animateQueue: $$CoreAnimateQueueProvider,\n        $$AnimateRunner: $$AnimateRunnerFactoryProvider,\n        $$animateAsyncRun: $$AnimateAsyncRunFactoryProvider,\n        $browser: $BrowserProvider,\n        $cacheFactory: $CacheFactoryProvider,\n        $controller: $ControllerProvider,\n        $document: $DocumentProvider,\n        $exceptionHandler: $ExceptionHandlerProvider,\n        $filter: $FilterProvider,\n        $$forceReflow: $$ForceReflowProvider,\n        $interpolate: $InterpolateProvider,\n        $interval: $IntervalProvider,\n        $http: $HttpProvider,\n        $httpParamSerializer: $HttpParamSerializerProvider,\n        $httpParamSerializerJQLike: $HttpParamSerializerJQLikeProvider,\n        $httpBackend: $HttpBackendProvider,\n        $xhrFactory: $xhrFactoryProvider,\n        $location: $LocationProvider,\n        $log: $LogProvider,\n        $parse: $ParseProvider,\n        $rootScope: $RootScopeProvider,\n        $q: $QProvider,\n        $$q: $$QProvider,\n        $sce: $SceProvider,\n        $sceDelegate: $SceDelegateProvider,\n        $sniffer: $SnifferProvider,\n        $templateCache: $TemplateCacheProvider,\n        $templateRequest: $TemplateRequestProvider,\n        $$testability: $$TestabilityProvider,\n        $timeout: $TimeoutProvider,\n        $window: $WindowProvider,\n        $$rAF: $$RAFProvider,\n        $$jqLite: $$jqLiteProvider,\n        $$HashMap: $$HashMapProvider,\n        $$cookieReader: $$CookieReaderProvider\n      });\n    }\n  ]);\n}\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *     Any commits to this file should be reviewed with security in mind.  *\n *   Changes to this file can potentially create security vulnerabilities. *\n *          An approval from 2 Core members with history of modifying      *\n *                         this file is required.                          *\n *                                                                         *\n *  Does the change somehow allow for arbitrary javascript to be executed? *\n *    Or allows for someone to change the prototype of built-in objects?   *\n *     Or gives undesired access to variables likes document or window?    *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n/* global JQLitePrototype: true,\n  addEventListenerFn: true,\n  removeEventListenerFn: true,\n  BOOLEAN_ATTR: true,\n  ALIASED_ATTR: true,\n*/\n\n//////////////////////////////////\n//JQLite\n//////////////////////////////////\n\n/**\n * @ngdoc function\n * @name angular.element\n * @module ng\n * @kind function\n *\n * @description\n * Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element.\n *\n * If jQuery is available, `angular.element` is an alias for the\n * [jQuery](http://api.jquery.com/jQuery/) function. If jQuery is not available, `angular.element`\n * delegates to Angular's built-in subset of jQuery, called \"jQuery lite\" or **jqLite**.\n *\n * jqLite is a tiny, API-compatible subset of jQuery that allows\n * Angular to manipulate the DOM in a cross-browser compatible way. jqLite implements only the most\n * commonly needed functionality with the goal of having a very small footprint.\n *\n * To use `jQuery`, simply ensure it is loaded before the `angular.js` file. You can also use the\n * {@link ngJq `ngJq`} directive to specify that jqlite should be used over jQuery, or to use a\n * specific version of jQuery if multiple versions exist on the page.\n *\n * <div class=\"alert alert-info\">**Note:** All element references in Angular are always wrapped with jQuery or\n * jqLite (such as the element argument in a directive's compile / link function). They are never raw DOM references.</div>\n *\n * <div class=\"alert alert-warning\">**Note:** Keep in mind that this function will not find elements\n * by tag name / CSS selector. For lookups by tag name, try instead `angular.element(document).find(...)`\n * or `$document.find()`, or use the standard DOM APIs, e.g. `document.querySelectorAll()`.</div>\n *\n * ## Angular's jqLite\n * jqLite provides only the following jQuery methods:\n *\n * - [`addClass()`](http://api.jquery.com/addClass/)\n * - [`after()`](http://api.jquery.com/after/)\n * - [`append()`](http://api.jquery.com/append/)\n * - [`attr()`](http://api.jquery.com/attr/) - Does not support functions as parameters\n * - [`bind()`](http://api.jquery.com/bind/) - Does not support namespaces, selectors or eventData\n * - [`children()`](http://api.jquery.com/children/) - Does not support selectors\n * - [`clone()`](http://api.jquery.com/clone/)\n * - [`contents()`](http://api.jquery.com/contents/)\n * - [`css()`](http://api.jquery.com/css/) - Only retrieves inline-styles, does not call `getComputedStyle()`.\n *   As a setter, does not convert numbers to strings or append 'px', and also does not have automatic property prefixing.\n * - [`data()`](http://api.jquery.com/data/)\n * - [`detach()`](http://api.jquery.com/detach/)\n * - [`empty()`](http://api.jquery.com/empty/)\n * - [`eq()`](http://api.jquery.com/eq/)\n * - [`find()`](http://api.jquery.com/find/) - Limited to lookups by tag name\n * - [`hasClass()`](http://api.jquery.com/hasClass/)\n * - [`html()`](http://api.jquery.com/html/)\n * - [`next()`](http://api.jquery.com/next/) - Does not support selectors\n * - [`on()`](http://api.jquery.com/on/) - Does not support namespaces, selectors or eventData\n * - [`off()`](http://api.jquery.com/off/) - Does not support namespaces, selectors or event object as parameter\n * - [`one()`](http://api.jquery.com/one/) - Does not support namespaces or selectors\n * - [`parent()`](http://api.jquery.com/parent/) - Does not support selectors\n * - [`prepend()`](http://api.jquery.com/prepend/)\n * - [`prop()`](http://api.jquery.com/prop/)\n * - [`ready()`](http://api.jquery.com/ready/)\n * - [`remove()`](http://api.jquery.com/remove/)\n * - [`removeAttr()`](http://api.jquery.com/removeAttr/)\n * - [`removeClass()`](http://api.jquery.com/removeClass/)\n * - [`removeData()`](http://api.jquery.com/removeData/)\n * - [`replaceWith()`](http://api.jquery.com/replaceWith/)\n * - [`text()`](http://api.jquery.com/text/)\n * - [`toggleClass()`](http://api.jquery.com/toggleClass/)\n * - [`triggerHandler()`](http://api.jquery.com/triggerHandler/) - Passes a dummy event object to handlers.\n * - [`unbind()`](http://api.jquery.com/unbind/) - Does not support namespaces or event object as parameter\n * - [`val()`](http://api.jquery.com/val/)\n * - [`wrap()`](http://api.jquery.com/wrap/)\n *\n * ## jQuery/jqLite Extras\n * Angular also provides the following additional methods and events to both jQuery and jqLite:\n *\n * ### Events\n * - `$destroy` - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event\n *    on all DOM nodes being removed.  This can be used to clean up any 3rd party bindings to the DOM\n *    element before it is removed.\n *\n * ### Methods\n * - `controller(name)` - retrieves the controller of the current element or its parent. By default\n *   retrieves controller associated with the `ngController` directive. If `name` is provided as\n *   camelCase directive name, then the controller for this directive will be retrieved (e.g.\n *   `'ngModel'`).\n * - `injector()` - retrieves the injector of the current element or its parent.\n * - `scope()` - retrieves the {@link ng.$rootScope.Scope scope} of the current\n *   element or its parent. Requires {@link guide/production#disabling-debug-data Debug Data} to\n *   be enabled.\n * - `isolateScope()` - retrieves an isolate {@link ng.$rootScope.Scope scope} if one is attached directly to the\n *   current element. This getter should be used only on elements that contain a directive which starts a new isolate\n *   scope. Calling `scope()` on this element always returns the original non-isolate scope.\n *   Requires {@link guide/production#disabling-debug-data Debug Data} to be enabled.\n * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top\n *   parent element is reached.\n *\n * @knownIssue You cannot spy on `angular.element` if you are using Jasmine version 1.x. See\n * https://github.com/angular/angular.js/issues/14251 for more information.\n *\n * @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery.\n * @returns {Object} jQuery object.\n */\n\nJQLite.expando = 'ng339';\n\nvar jqCache = JQLite.cache = {},\n    jqId = 1,\n    addEventListenerFn = function(element, type, fn) {\n      element.addEventListener(type, fn, false);\n    },\n    removeEventListenerFn = function(element, type, fn) {\n      element.removeEventListener(type, fn, false);\n    };\n\n/*\n * !!! This is an undocumented \"private\" function !!!\n */\nJQLite._data = function(node) {\n  //jQuery always returns an object on cache miss\n  return this.cache[node[this.expando]] || {};\n};\n\nfunction jqNextId() { return ++jqId; }\n\n\nvar SPECIAL_CHARS_REGEXP = /([\\:\\-\\_]+(.))/g;\nvar MOZ_HACK_REGEXP = /^moz([A-Z])/;\nvar MOUSE_EVENT_MAP= { mouseleave: \"mouseout\", mouseenter: \"mouseover\"};\nvar jqLiteMinErr = minErr('jqLite');\n\n/**\n * Converts snake_case to camelCase.\n * Also there is special case for Moz prefix starting with upper case letter.\n * @param name Name to normalize\n */\nfunction camelCase(name) {\n  return name.\n    replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {\n      return offset ? letter.toUpperCase() : letter;\n    }).\n    replace(MOZ_HACK_REGEXP, 'Moz$1');\n}\n\nvar SINGLE_TAG_REGEXP = /^<([\\w-]+)\\s*\\/?>(?:<\\/\\1>|)$/;\nvar HTML_REGEXP = /<|&#?\\w+;/;\nvar TAG_NAME_REGEXP = /<([\\w:-]+)/;\nvar XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\\w:-]+)[^>]*)\\/>/gi;\n\nvar wrapMap = {\n  'option': [1, '<select multiple=\"multiple\">', '</select>'],\n\n  'thead': [1, '<table>', '</table>'],\n  'col': [2, '<table><colgroup>', '</colgroup></table>'],\n  'tr': [2, '<table><tbody>', '</tbody></table>'],\n  'td': [3, '<table><tbody><tr>', '</tr></tbody></table>'],\n  '_default': [0, \"\", \"\"]\n};\n\nwrapMap.optgroup = wrapMap.option;\nwrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;\nwrapMap.th = wrapMap.td;\n\n\nfunction jqLiteIsTextNode(html) {\n  return !HTML_REGEXP.test(html);\n}\n\nfunction jqLiteAcceptsData(node) {\n  // The window object can accept data but has no nodeType\n  // Otherwise we are only interested in elements (1) and documents (9)\n  var nodeType = node.nodeType;\n  return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_DOCUMENT;\n}\n\nfunction jqLiteHasData(node) {\n  for (var key in jqCache[node.ng339]) {\n    return true;\n  }\n  return false;\n}\n\nfunction jqLiteCleanData(nodes) {\n  for (var i = 0, ii = nodes.length; i < ii; i++) {\n    jqLiteRemoveData(nodes[i]);\n  }\n}\n\nfunction jqLiteBuildFragment(html, context) {\n  var tmp, tag, wrap,\n      fragment = context.createDocumentFragment(),\n      nodes = [], i;\n\n  if (jqLiteIsTextNode(html)) {\n    // Convert non-html into a text node\n    nodes.push(context.createTextNode(html));\n  } else {\n    // Convert html into DOM nodes\n    tmp = tmp || fragment.appendChild(context.createElement(\"div\"));\n    tag = (TAG_NAME_REGEXP.exec(html) || [\"\", \"\"])[1].toLowerCase();\n    wrap = wrapMap[tag] || wrapMap._default;\n    tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, \"<$1></$2>\") + wrap[2];\n\n    // Descend through wrappers to the right content\n    i = wrap[0];\n    while (i--) {\n      tmp = tmp.lastChild;\n    }\n\n    nodes = concat(nodes, tmp.childNodes);\n\n    tmp = fragment.firstChild;\n    tmp.textContent = \"\";\n  }\n\n  // Remove wrapper from fragment\n  fragment.textContent = \"\";\n  fragment.innerHTML = \"\"; // Clear inner HTML\n  forEach(nodes, function(node) {\n    fragment.appendChild(node);\n  });\n\n  return fragment;\n}\n\nfunction jqLiteParseHTML(html, context) {\n  context = context || window.document;\n  var parsed;\n\n  if ((parsed = SINGLE_TAG_REGEXP.exec(html))) {\n    return [context.createElement(parsed[1])];\n  }\n\n  if ((parsed = jqLiteBuildFragment(html, context))) {\n    return parsed.childNodes;\n  }\n\n  return [];\n}\n\nfunction jqLiteWrapNode(node, wrapper) {\n  var parent = node.parentNode;\n\n  if (parent) {\n    parent.replaceChild(wrapper, node);\n  }\n\n  wrapper.appendChild(node);\n}\n\n\n// IE9-11 has no method \"contains\" in SVG element and in Node.prototype. Bug #10259.\nvar jqLiteContains = window.Node.prototype.contains || function(arg) {\n  // jshint bitwise: false\n  return !!(this.compareDocumentPosition(arg) & 16);\n  // jshint bitwise: true\n};\n\n/////////////////////////////////////////////\nfunction JQLite(element) {\n  if (element instanceof JQLite) {\n    return element;\n  }\n\n  var argIsString;\n\n  if (isString(element)) {\n    element = trim(element);\n    argIsString = true;\n  }\n  if (!(this instanceof JQLite)) {\n    if (argIsString && element.charAt(0) != '<') {\n      throw jqLiteMinErr('nosel', 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element');\n    }\n    return new JQLite(element);\n  }\n\n  if (argIsString) {\n    jqLiteAddNodes(this, jqLiteParseHTML(element));\n  } else {\n    jqLiteAddNodes(this, element);\n  }\n}\n\nfunction jqLiteClone(element) {\n  return element.cloneNode(true);\n}\n\nfunction jqLiteDealoc(element, onlyDescendants) {\n  if (!onlyDescendants) jqLiteRemoveData(element);\n\n  if (element.querySelectorAll) {\n    var descendants = element.querySelectorAll('*');\n    for (var i = 0, l = descendants.length; i < l; i++) {\n      jqLiteRemoveData(descendants[i]);\n    }\n  }\n}\n\nfunction jqLiteOff(element, type, fn, unsupported) {\n  if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument');\n\n  var expandoStore = jqLiteExpandoStore(element);\n  var events = expandoStore && expandoStore.events;\n  var handle = expandoStore && expandoStore.handle;\n\n  if (!handle) return; //no listeners registered\n\n  if (!type) {\n    for (type in events) {\n      if (type !== '$destroy') {\n        removeEventListenerFn(element, type, handle);\n      }\n      delete events[type];\n    }\n  } else {\n\n    var removeHandler = function(type) {\n      var listenerFns = events[type];\n      if (isDefined(fn)) {\n        arrayRemove(listenerFns || [], fn);\n      }\n      if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {\n        removeEventListenerFn(element, type, handle);\n        delete events[type];\n      }\n    };\n\n    forEach(type.split(' '), function(type) {\n      removeHandler(type);\n      if (MOUSE_EVENT_MAP[type]) {\n        removeHandler(MOUSE_EVENT_MAP[type]);\n      }\n    });\n  }\n}\n\nfunction jqLiteRemoveData(element, name) {\n  var expandoId = element.ng339;\n  var expandoStore = expandoId && jqCache[expandoId];\n\n  if (expandoStore) {\n    if (name) {\n      delete expandoStore.data[name];\n      return;\n    }\n\n    if (expandoStore.handle) {\n      if (expandoStore.events.$destroy) {\n        expandoStore.handle({}, '$destroy');\n      }\n      jqLiteOff(element);\n    }\n    delete jqCache[expandoId];\n    element.ng339 = undefined; // don't delete DOM expandos. IE and Chrome don't like it\n  }\n}\n\n\nfunction jqLiteExpandoStore(element, createIfNecessary) {\n  var expandoId = element.ng339,\n      expandoStore = expandoId && jqCache[expandoId];\n\n  if (createIfNecessary && !expandoStore) {\n    element.ng339 = expandoId = jqNextId();\n    expandoStore = jqCache[expandoId] = {events: {}, data: {}, handle: undefined};\n  }\n\n  return expandoStore;\n}\n\n\nfunction jqLiteData(element, key, value) {\n  if (jqLiteAcceptsData(element)) {\n\n    var isSimpleSetter = isDefined(value);\n    var isSimpleGetter = !isSimpleSetter && key && !isObject(key);\n    var massGetter = !key;\n    var expandoStore = jqLiteExpandoStore(element, !isSimpleGetter);\n    var data = expandoStore && expandoStore.data;\n\n    if (isSimpleSetter) { // data('key', value)\n      data[key] = value;\n    } else {\n      if (massGetter) {  // data()\n        return data;\n      } else {\n        if (isSimpleGetter) { // data('key')\n          // don't force creation of expandoStore if it doesn't exist yet\n          return data && data[key];\n        } else { // mass-setter: data({key1: val1, key2: val2})\n          extend(data, key);\n        }\n      }\n    }\n  }\n}\n\nfunction jqLiteHasClass(element, selector) {\n  if (!element.getAttribute) return false;\n  return ((\" \" + (element.getAttribute('class') || '') + \" \").replace(/[\\n\\t]/g, \" \").\n      indexOf(\" \" + selector + \" \") > -1);\n}\n\nfunction jqLiteRemoveClass(element, cssClasses) {\n  if (cssClasses && element.setAttribute) {\n    forEach(cssClasses.split(' '), function(cssClass) {\n      element.setAttribute('class', trim(\n          (\" \" + (element.getAttribute('class') || '') + \" \")\n          .replace(/[\\n\\t]/g, \" \")\n          .replace(\" \" + trim(cssClass) + \" \", \" \"))\n      );\n    });\n  }\n}\n\nfunction jqLiteAddClass(element, cssClasses) {\n  if (cssClasses && element.setAttribute) {\n    var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')\n                            .replace(/[\\n\\t]/g, \" \");\n\n    forEach(cssClasses.split(' '), function(cssClass) {\n      cssClass = trim(cssClass);\n      if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) {\n        existingClasses += cssClass + ' ';\n      }\n    });\n\n    element.setAttribute('class', trim(existingClasses));\n  }\n}\n\n\nfunction jqLiteAddNodes(root, elements) {\n  // THIS CODE IS VERY HOT. Don't make changes without benchmarking.\n\n  if (elements) {\n\n    // if a Node (the most common case)\n    if (elements.nodeType) {\n      root[root.length++] = elements;\n    } else {\n      var length = elements.length;\n\n      // if an Array or NodeList and not a Window\n      if (typeof length === 'number' && elements.window !== elements) {\n        if (length) {\n          for (var i = 0; i < length; i++) {\n            root[root.length++] = elements[i];\n          }\n        }\n      } else {\n        root[root.length++] = elements;\n      }\n    }\n  }\n}\n\n\nfunction jqLiteController(element, name) {\n  return jqLiteInheritedData(element, '$' + (name || 'ngController') + 'Controller');\n}\n\nfunction jqLiteInheritedData(element, name, value) {\n  // if element is the document object work with the html element instead\n  // this makes $(document).scope() possible\n  if (element.nodeType == NODE_TYPE_DOCUMENT) {\n    element = element.documentElement;\n  }\n  var names = isArray(name) ? name : [name];\n\n  while (element) {\n    for (var i = 0, ii = names.length; i < ii; i++) {\n      if (isDefined(value = jqLite.data(element, names[i]))) return value;\n    }\n\n    // If dealing with a document fragment node with a host element, and no parent, use the host\n    // element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM\n    // to lookup parent controllers.\n    element = element.parentNode || (element.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && element.host);\n  }\n}\n\nfunction jqLiteEmpty(element) {\n  jqLiteDealoc(element, true);\n  while (element.firstChild) {\n    element.removeChild(element.firstChild);\n  }\n}\n\nfunction jqLiteRemove(element, keepData) {\n  if (!keepData) jqLiteDealoc(element);\n  var parent = element.parentNode;\n  if (parent) parent.removeChild(element);\n}\n\n\nfunction jqLiteDocumentLoaded(action, win) {\n  win = win || window;\n  if (win.document.readyState === 'complete') {\n    // Force the action to be run async for consistent behavior\n    // from the action's point of view\n    // i.e. it will definitely not be in a $apply\n    win.setTimeout(action);\n  } else {\n    // No need to unbind this handler as load is only ever called once\n    jqLite(win).on('load', action);\n  }\n}\n\n//////////////////////////////////////////\n// Functions which are declared directly.\n//////////////////////////////////////////\nvar JQLitePrototype = JQLite.prototype = {\n  ready: function(fn) {\n    var fired = false;\n\n    function trigger() {\n      if (fired) return;\n      fired = true;\n      fn();\n    }\n\n    // check if document is already loaded\n    if (window.document.readyState === 'complete') {\n      window.setTimeout(trigger);\n    } else {\n      this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9\n      // we can not use jqLite since we are not done loading and jQuery could be loaded later.\n      // jshint -W064\n      JQLite(window).on('load', trigger); // fallback to window.onload for others\n      // jshint +W064\n    }\n  },\n  toString: function() {\n    var value = [];\n    forEach(this, function(e) { value.push('' + e);});\n    return '[' + value.join(', ') + ']';\n  },\n\n  eq: function(index) {\n      return (index >= 0) ? jqLite(this[index]) : jqLite(this[this.length + index]);\n  },\n\n  length: 0,\n  push: push,\n  sort: [].sort,\n  splice: [].splice\n};\n\n//////////////////////////////////////////\n// Functions iterating getter/setters.\n// these functions return self on setter and\n// value on get.\n//////////////////////////////////////////\nvar BOOLEAN_ATTR = {};\nforEach('multiple,selected,checked,disabled,readOnly,required,open'.split(','), function(value) {\n  BOOLEAN_ATTR[lowercase(value)] = value;\n});\nvar BOOLEAN_ELEMENTS = {};\nforEach('input,select,option,textarea,button,form,details'.split(','), function(value) {\n  BOOLEAN_ELEMENTS[value] = true;\n});\nvar ALIASED_ATTR = {\n  'ngMinlength': 'minlength',\n  'ngMaxlength': 'maxlength',\n  'ngMin': 'min',\n  'ngMax': 'max',\n  'ngPattern': 'pattern'\n};\n\nfunction getBooleanAttrName(element, name) {\n  // check dom last since we will most likely fail on name\n  var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()];\n\n  // booleanAttr is here twice to minimize DOM access\n  return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr;\n}\n\nfunction getAliasedAttrName(name) {\n  return ALIASED_ATTR[name];\n}\n\nforEach({\n  data: jqLiteData,\n  removeData: jqLiteRemoveData,\n  hasData: jqLiteHasData,\n  cleanData: jqLiteCleanData\n}, function(fn, name) {\n  JQLite[name] = fn;\n});\n\nforEach({\n  data: jqLiteData,\n  inheritedData: jqLiteInheritedData,\n\n  scope: function(element) {\n    // Can't use jqLiteData here directly so we stay compatible with jQuery!\n    return jqLite.data(element, '$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']);\n  },\n\n  isolateScope: function(element) {\n    // Can't use jqLiteData here directly so we stay compatible with jQuery!\n    return jqLite.data(element, '$isolateScope') || jqLite.data(element, '$isolateScopeNoTemplate');\n  },\n\n  controller: jqLiteController,\n\n  injector: function(element) {\n    return jqLiteInheritedData(element, '$injector');\n  },\n\n  removeAttr: function(element, name) {\n    element.removeAttribute(name);\n  },\n\n  hasClass: jqLiteHasClass,\n\n  css: function(element, name, value) {\n    name = camelCase(name);\n\n    if (isDefined(value)) {\n      element.style[name] = value;\n    } else {\n      return element.style[name];\n    }\n  },\n\n  attr: function(element, name, value) {\n    var nodeType = element.nodeType;\n    if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT) {\n      return;\n    }\n    var lowercasedName = lowercase(name);\n    if (BOOLEAN_ATTR[lowercasedName]) {\n      if (isDefined(value)) {\n        if (!!value) {\n          element[name] = true;\n          element.setAttribute(name, lowercasedName);\n        } else {\n          element[name] = false;\n          element.removeAttribute(lowercasedName);\n        }\n      } else {\n        return (element[name] ||\n                 (element.attributes.getNamedItem(name) || noop).specified)\n               ? lowercasedName\n               : undefined;\n      }\n    } else if (isDefined(value)) {\n      element.setAttribute(name, value);\n    } else if (element.getAttribute) {\n      // the extra argument \"2\" is to get the right thing for a.href in IE, see jQuery code\n      // some elements (e.g. Document) don't have get attribute, so return undefined\n      var ret = element.getAttribute(name, 2);\n      // normalize non-existing attributes to undefined (as jQuery)\n      return ret === null ? undefined : ret;\n    }\n  },\n\n  prop: function(element, name, value) {\n    if (isDefined(value)) {\n      element[name] = value;\n    } else {\n      return element[name];\n    }\n  },\n\n  text: (function() {\n    getText.$dv = '';\n    return getText;\n\n    function getText(element, value) {\n      if (isUndefined(value)) {\n        var nodeType = element.nodeType;\n        return (nodeType === NODE_TYPE_ELEMENT || nodeType === NODE_TYPE_TEXT) ? element.textContent : '';\n      }\n      element.textContent = value;\n    }\n  })(),\n\n  val: function(element, value) {\n    if (isUndefined(value)) {\n      if (element.multiple && nodeName_(element) === 'select') {\n        var result = [];\n        forEach(element.options, function(option) {\n          if (option.selected) {\n            result.push(option.value || option.text);\n          }\n        });\n        return result.length === 0 ? null : result;\n      }\n      return element.value;\n    }\n    element.value = value;\n  },\n\n  html: function(element, value) {\n    if (isUndefined(value)) {\n      return element.innerHTML;\n    }\n    jqLiteDealoc(element, true);\n    element.innerHTML = value;\n  },\n\n  empty: jqLiteEmpty\n}, function(fn, name) {\n  /**\n   * Properties: writes return selection, reads return first value\n   */\n  JQLite.prototype[name] = function(arg1, arg2) {\n    var i, key;\n    var nodeCount = this.length;\n\n    // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it\n    // in a way that survives minification.\n    // jqLiteEmpty takes no arguments but is a setter.\n    if (fn !== jqLiteEmpty &&\n        (isUndefined((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2))) {\n      if (isObject(arg1)) {\n\n        // we are a write, but the object properties are the key/values\n        for (i = 0; i < nodeCount; i++) {\n          if (fn === jqLiteData) {\n            // data() takes the whole object in jQuery\n            fn(this[i], arg1);\n          } else {\n            for (key in arg1) {\n              fn(this[i], key, arg1[key]);\n            }\n          }\n        }\n        // return self for chaining\n        return this;\n      } else {\n        // we are a read, so read the first child.\n        // TODO: do we still need this?\n        var value = fn.$dv;\n        // Only if we have $dv do we iterate over all, otherwise it is just the first element.\n        var jj = (isUndefined(value)) ? Math.min(nodeCount, 1) : nodeCount;\n        for (var j = 0; j < jj; j++) {\n          var nodeValue = fn(this[j], arg1, arg2);\n          value = value ? value + nodeValue : nodeValue;\n        }\n        return value;\n      }\n    } else {\n      // we are a write, so apply to all children\n      for (i = 0; i < nodeCount; i++) {\n        fn(this[i], arg1, arg2);\n      }\n      // return self for chaining\n      return this;\n    }\n  };\n});\n\nfunction createEventHandler(element, events) {\n  var eventHandler = function(event, type) {\n    // jQuery specific api\n    event.isDefaultPrevented = function() {\n      return event.defaultPrevented;\n    };\n\n    var eventFns = events[type || event.type];\n    var eventFnsLength = eventFns ? eventFns.length : 0;\n\n    if (!eventFnsLength) return;\n\n    if (isUndefined(event.immediatePropagationStopped)) {\n      var originalStopImmediatePropagation = event.stopImmediatePropagation;\n      event.stopImmediatePropagation = function() {\n        event.immediatePropagationStopped = true;\n\n        if (event.stopPropagation) {\n          event.stopPropagation();\n        }\n\n        if (originalStopImmediatePropagation) {\n          originalStopImmediatePropagation.call(event);\n        }\n      };\n    }\n\n    event.isImmediatePropagationStopped = function() {\n      return event.immediatePropagationStopped === true;\n    };\n\n    // Some events have special handlers that wrap the real handler\n    var handlerWrapper = eventFns.specialHandlerWrapper || defaultHandlerWrapper;\n\n    // Copy event handlers in case event handlers array is modified during execution.\n    if ((eventFnsLength > 1)) {\n      eventFns = shallowCopy(eventFns);\n    }\n\n    for (var i = 0; i < eventFnsLength; i++) {\n      if (!event.isImmediatePropagationStopped()) {\n        handlerWrapper(element, event, eventFns[i]);\n      }\n    }\n  };\n\n  // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all\n  //       events on `element`\n  eventHandler.elem = element;\n  return eventHandler;\n}\n\nfunction defaultHandlerWrapper(element, event, handler) {\n  handler.call(element, event);\n}\n\nfunction specialMouseHandlerWrapper(target, event, handler) {\n  // Refer to jQuery's implementation of mouseenter & mouseleave\n  // Read about mouseenter and mouseleave:\n  // http://www.quirksmode.org/js/events_mouse.html#link8\n  var related = event.relatedTarget;\n  // For mousenter/leave call the handler if related is outside the target.\n  // NB: No relatedTarget if the mouse left/entered the browser window\n  if (!related || (related !== target && !jqLiteContains.call(target, related))) {\n    handler.call(target, event);\n  }\n}\n\n//////////////////////////////////////////\n// Functions iterating traversal.\n// These functions chain results into a single\n// selector.\n//////////////////////////////////////////\nforEach({\n  removeData: jqLiteRemoveData,\n\n  on: function jqLiteOn(element, type, fn, unsupported) {\n    if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');\n\n    // Do not add event handlers to non-elements because they will not be cleaned up.\n    if (!jqLiteAcceptsData(element)) {\n      return;\n    }\n\n    var expandoStore = jqLiteExpandoStore(element, true);\n    var events = expandoStore.events;\n    var handle = expandoStore.handle;\n\n    if (!handle) {\n      handle = expandoStore.handle = createEventHandler(element, events);\n    }\n\n    // http://jsperf.com/string-indexof-vs-split\n    var types = type.indexOf(' ') >= 0 ? type.split(' ') : [type];\n    var i = types.length;\n\n    var addHandler = function(type, specialHandlerWrapper, noEventListener) {\n      var eventFns = events[type];\n\n      if (!eventFns) {\n        eventFns = events[type] = [];\n        eventFns.specialHandlerWrapper = specialHandlerWrapper;\n        if (type !== '$destroy' && !noEventListener) {\n          addEventListenerFn(element, type, handle);\n        }\n      }\n\n      eventFns.push(fn);\n    };\n\n    while (i--) {\n      type = types[i];\n      if (MOUSE_EVENT_MAP[type]) {\n        addHandler(MOUSE_EVENT_MAP[type], specialMouseHandlerWrapper);\n        addHandler(type, undefined, true);\n      } else {\n        addHandler(type);\n      }\n    }\n  },\n\n  off: jqLiteOff,\n\n  one: function(element, type, fn) {\n    element = jqLite(element);\n\n    //add the listener twice so that when it is called\n    //you can remove the original function and still be\n    //able to call element.off(ev, fn) normally\n    element.on(type, function onFn() {\n      element.off(type, fn);\n      element.off(type, onFn);\n    });\n    element.on(type, fn);\n  },\n\n  replaceWith: function(element, replaceNode) {\n    var index, parent = element.parentNode;\n    jqLiteDealoc(element);\n    forEach(new JQLite(replaceNode), function(node) {\n      if (index) {\n        parent.insertBefore(node, index.nextSibling);\n      } else {\n        parent.replaceChild(node, element);\n      }\n      index = node;\n    });\n  },\n\n  children: function(element) {\n    var children = [];\n    forEach(element.childNodes, function(element) {\n      if (element.nodeType === NODE_TYPE_ELEMENT) {\n        children.push(element);\n      }\n    });\n    return children;\n  },\n\n  contents: function(element) {\n    return element.contentDocument || element.childNodes || [];\n  },\n\n  append: function(element, node) {\n    var nodeType = element.nodeType;\n    if (nodeType !== NODE_TYPE_ELEMENT && nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT) return;\n\n    node = new JQLite(node);\n\n    for (var i = 0, ii = node.length; i < ii; i++) {\n      var child = node[i];\n      element.appendChild(child);\n    }\n  },\n\n  prepend: function(element, node) {\n    if (element.nodeType === NODE_TYPE_ELEMENT) {\n      var index = element.firstChild;\n      forEach(new JQLite(node), function(child) {\n        element.insertBefore(child, index);\n      });\n    }\n  },\n\n  wrap: function(element, wrapNode) {\n    jqLiteWrapNode(element, jqLite(wrapNode).eq(0).clone()[0]);\n  },\n\n  remove: jqLiteRemove,\n\n  detach: function(element) {\n    jqLiteRemove(element, true);\n  },\n\n  after: function(element, newElement) {\n    var index = element, parent = element.parentNode;\n    newElement = new JQLite(newElement);\n\n    for (var i = 0, ii = newElement.length; i < ii; i++) {\n      var node = newElement[i];\n      parent.insertBefore(node, index.nextSibling);\n      index = node;\n    }\n  },\n\n  addClass: jqLiteAddClass,\n  removeClass: jqLiteRemoveClass,\n\n  toggleClass: function(element, selector, condition) {\n    if (selector) {\n      forEach(selector.split(' '), function(className) {\n        var classCondition = condition;\n        if (isUndefined(classCondition)) {\n          classCondition = !jqLiteHasClass(element, className);\n        }\n        (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className);\n      });\n    }\n  },\n\n  parent: function(element) {\n    var parent = element.parentNode;\n    return parent && parent.nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT ? parent : null;\n  },\n\n  next: function(element) {\n    return element.nextElementSibling;\n  },\n\n  find: function(element, selector) {\n    if (element.getElementsByTagName) {\n      return element.getElementsByTagName(selector);\n    } else {\n      return [];\n    }\n  },\n\n  clone: jqLiteClone,\n\n  triggerHandler: function(element, event, extraParameters) {\n\n    var dummyEvent, eventFnsCopy, handlerArgs;\n    var eventName = event.type || event;\n    var expandoStore = jqLiteExpandoStore(element);\n    var events = expandoStore && expandoStore.events;\n    var eventFns = events && events[eventName];\n\n    if (eventFns) {\n      // Create a dummy event to pass to the handlers\n      dummyEvent = {\n        preventDefault: function() { this.defaultPrevented = true; },\n        isDefaultPrevented: function() { return this.defaultPrevented === true; },\n        stopImmediatePropagation: function() { this.immediatePropagationStopped = true; },\n        isImmediatePropagationStopped: function() { return this.immediatePropagationStopped === true; },\n        stopPropagation: noop,\n        type: eventName,\n        target: element\n      };\n\n      // If a custom event was provided then extend our dummy event with it\n      if (event.type) {\n        dummyEvent = extend(dummyEvent, event);\n      }\n\n      // Copy event handlers in case event handlers array is modified during execution.\n      eventFnsCopy = shallowCopy(eventFns);\n      handlerArgs = extraParameters ? [dummyEvent].concat(extraParameters) : [dummyEvent];\n\n      forEach(eventFnsCopy, function(fn) {\n        if (!dummyEvent.isImmediatePropagationStopped()) {\n          fn.apply(element, handlerArgs);\n        }\n      });\n    }\n  }\n}, function(fn, name) {\n  /**\n   * chaining functions\n   */\n  JQLite.prototype[name] = function(arg1, arg2, arg3) {\n    var value;\n\n    for (var i = 0, ii = this.length; i < ii; i++) {\n      if (isUndefined(value)) {\n        value = fn(this[i], arg1, arg2, arg3);\n        if (isDefined(value)) {\n          // any function which returns a value needs to be wrapped\n          value = jqLite(value);\n        }\n      } else {\n        jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3));\n      }\n    }\n    return isDefined(value) ? value : this;\n  };\n\n  // bind legacy bind/unbind to on/off\n  JQLite.prototype.bind = JQLite.prototype.on;\n  JQLite.prototype.unbind = JQLite.prototype.off;\n});\n\n\n// Provider for private $$jqLite service\nfunction $$jqLiteProvider() {\n  this.$get = function $$jqLite() {\n    return extend(JQLite, {\n      hasClass: function(node, classes) {\n        if (node.attr) node = node[0];\n        return jqLiteHasClass(node, classes);\n      },\n      addClass: function(node, classes) {\n        if (node.attr) node = node[0];\n        return jqLiteAddClass(node, classes);\n      },\n      removeClass: function(node, classes) {\n        if (node.attr) node = node[0];\n        return jqLiteRemoveClass(node, classes);\n      }\n    });\n  };\n}\n\n/**\n * Computes a hash of an 'obj'.\n * Hash of a:\n *  string is string\n *  number is number as string\n *  object is either result of calling $$hashKey function on the object or uniquely generated id,\n *         that is also assigned to the $$hashKey property of the object.\n *\n * @param obj\n * @returns {string} hash string such that the same input will have the same hash string.\n *         The resulting string key is in 'type:hashKey' format.\n */\nfunction hashKey(obj, nextUidFn) {\n  var key = obj && obj.$$hashKey;\n\n  if (key) {\n    if (typeof key === 'function') {\n      key = obj.$$hashKey();\n    }\n    return key;\n  }\n\n  var objType = typeof obj;\n  if (objType == 'function' || (objType == 'object' && obj !== null)) {\n    key = obj.$$hashKey = objType + ':' + (nextUidFn || nextUid)();\n  } else {\n    key = objType + ':' + obj;\n  }\n\n  return key;\n}\n\n/**\n * HashMap which can use objects as keys\n */\nfunction HashMap(array, isolatedUid) {\n  if (isolatedUid) {\n    var uid = 0;\n    this.nextUid = function() {\n      return ++uid;\n    };\n  }\n  forEach(array, this.put, this);\n}\nHashMap.prototype = {\n  /**\n   * Store key value pair\n   * @param key key to store can be any type\n   * @param value value to store can be any type\n   */\n  put: function(key, value) {\n    this[hashKey(key, this.nextUid)] = value;\n  },\n\n  /**\n   * @param key\n   * @returns {Object} the value for the key\n   */\n  get: function(key) {\n    return this[hashKey(key, this.nextUid)];\n  },\n\n  /**\n   * Remove the key/value pair\n   * @param key\n   */\n  remove: function(key) {\n    var value = this[key = hashKey(key, this.nextUid)];\n    delete this[key];\n    return value;\n  }\n};\n\nvar $$HashMapProvider = [function() {\n  this.$get = [function() {\n    return HashMap;\n  }];\n}];\n\n/**\n * @ngdoc function\n * @module ng\n * @name angular.injector\n * @kind function\n *\n * @description\n * Creates an injector object that can be used for retrieving services as well as for\n * dependency injection (see {@link guide/di dependency injection}).\n *\n * @param {Array.<string|Function>} modules A list of module functions or their aliases. See\n *     {@link angular.module}. The `ng` module must be explicitly added.\n * @param {boolean=} [strictDi=false] Whether the injector should be in strict mode, which\n *     disallows argument name annotation inference.\n * @returns {injector} Injector object. See {@link auto.$injector $injector}.\n *\n * @example\n * Typical usage\n * ```js\n *   // create an injector\n *   var $injector = angular.injector(['ng']);\n *\n *   // use the injector to kick off your application\n *   // use the type inference to auto inject arguments, or use implicit injection\n *   $injector.invoke(function($rootScope, $compile, $document) {\n *     $compile($document)($rootScope);\n *     $rootScope.$digest();\n *   });\n * ```\n *\n * Sometimes you want to get access to the injector of a currently running Angular app\n * from outside Angular. Perhaps, you want to inject and compile some markup after the\n * application has been bootstrapped. You can do this using the extra `injector()` added\n * to JQuery/jqLite elements. See {@link angular.element}.\n *\n * *This is fairly rare but could be the case if a third party library is injecting the\n * markup.*\n *\n * In the following example a new block of HTML containing a `ng-controller`\n * directive is added to the end of the document body by JQuery. We then compile and link\n * it into the current AngularJS scope.\n *\n * ```js\n * var $div = $('<div ng-controller=\"MyCtrl\">{{content.label}}</div>');\n * $(document.body).append($div);\n *\n * angular.element(document).injector().invoke(function($compile) {\n *   var scope = angular.element($div).scope();\n *   $compile($div)(scope);\n * });\n * ```\n */\n\n\n/**\n * @ngdoc module\n * @name auto\n * @installation\n * @description\n *\n * Implicit module which gets automatically added to each {@link auto.$injector $injector}.\n */\n\nvar ARROW_ARG = /^([^\\(]+?)=>/;\nvar FN_ARGS = /^[^\\(]*\\(\\s*([^\\)]*)\\)/m;\nvar FN_ARG_SPLIT = /,/;\nvar FN_ARG = /^\\s*(_?)(\\S+?)\\1\\s*$/;\nvar STRIP_COMMENTS = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\nvar $injectorMinErr = minErr('$injector');\n\nfunction extractArgs(fn) {\n  var fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ''),\n      args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);\n  return args;\n}\n\nfunction anonFn(fn) {\n  // For anonymous functions, showing at the very least the function signature can help in\n  // debugging.\n  var args = extractArgs(fn);\n  if (args) {\n    return 'function(' + (args[1] || '').replace(/[\\s\\r\\n]+/, ' ') + ')';\n  }\n  return 'fn';\n}\n\nfunction annotate(fn, strictDi, name) {\n  var $inject,\n      argDecl,\n      last;\n\n  if (typeof fn === 'function') {\n    if (!($inject = fn.$inject)) {\n      $inject = [];\n      if (fn.length) {\n        if (strictDi) {\n          if (!isString(name) || !name) {\n            name = fn.name || anonFn(fn);\n          }\n          throw $injectorMinErr('strictdi',\n            '{0} is not using explicit annotation and cannot be invoked in strict mode', name);\n        }\n        argDecl = extractArgs(fn);\n        forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {\n          arg.replace(FN_ARG, function(all, underscore, name) {\n            $inject.push(name);\n          });\n        });\n      }\n      fn.$inject = $inject;\n    }\n  } else if (isArray(fn)) {\n    last = fn.length - 1;\n    assertArgFn(fn[last], 'fn');\n    $inject = fn.slice(0, last);\n  } else {\n    assertArgFn(fn, 'fn', true);\n  }\n  return $inject;\n}\n\n///////////////////////////////////////\n\n/**\n * @ngdoc service\n * @name $injector\n *\n * @description\n *\n * `$injector` is used to retrieve object instances as defined by\n * {@link auto.$provide provider}, instantiate types, invoke methods,\n * and load modules.\n *\n * The following always holds true:\n *\n * ```js\n *   var $injector = angular.injector();\n *   expect($injector.get('$injector')).toBe($injector);\n *   expect($injector.invoke(function($injector) {\n *     return $injector;\n *   })).toBe($injector);\n * ```\n *\n * # Injection Function Annotation\n *\n * JavaScript does not have annotations, and annotations are needed for dependency injection. The\n * following are all valid ways of annotating function with injection arguments and are equivalent.\n *\n * ```js\n *   // inferred (only works if code not minified/obfuscated)\n *   $injector.invoke(function(serviceA){});\n *\n *   // annotated\n *   function explicit(serviceA) {};\n *   explicit.$inject = ['serviceA'];\n *   $injector.invoke(explicit);\n *\n *   // inline\n *   $injector.invoke(['serviceA', function(serviceA){}]);\n * ```\n *\n * ## Inference\n *\n * In JavaScript calling `toString()` on a function returns the function definition. The definition\n * can then be parsed and the function arguments can be extracted. This method of discovering\n * annotations is disallowed when the injector is in strict mode.\n * *NOTE:* This does not work with minification, and obfuscation tools since these tools change the\n * argument names.\n *\n * ## `$inject` Annotation\n * By adding an `$inject` property onto a function the injection parameters can be specified.\n *\n * ## Inline\n * As an array of injection names, where the last item in the array is the function to call.\n */\n\n/**\n * @ngdoc method\n * @name $injector#get\n *\n * @description\n * Return an instance of the service.\n *\n * @param {string} name The name of the instance to retrieve.\n * @param {string=} caller An optional string to provide the origin of the function call for error messages.\n * @return {*} The instance.\n */\n\n/**\n * @ngdoc method\n * @name $injector#invoke\n *\n * @description\n * Invoke the method and supply the method arguments from the `$injector`.\n *\n * @param {Function|Array.<string|Function>} fn The injectable function to invoke. Function parameters are\n *   injected according to the {@link guide/di $inject Annotation} rules.\n * @param {Object=} self The `this` for the invoked method.\n * @param {Object=} locals Optional object. If preset then any argument names are read from this\n *                         object first, before the `$injector` is consulted.\n * @returns {*} the value returned by the invoked `fn` function.\n */\n\n/**\n * @ngdoc method\n * @name $injector#has\n *\n * @description\n * Allows the user to query if the particular service exists.\n *\n * @param {string} name Name of the service to query.\n * @returns {boolean} `true` if injector has given service.\n */\n\n/**\n * @ngdoc method\n * @name $injector#instantiate\n * @description\n * Create a new instance of JS type. The method takes a constructor function, invokes the new\n * operator, and supplies all of the arguments to the constructor function as specified by the\n * constructor annotation.\n *\n * @param {Function} Type Annotated constructor function.\n * @param {Object=} locals Optional object. If preset then any argument names are read from this\n * object first, before the `$injector` is consulted.\n * @returns {Object} new instance of `Type`.\n */\n\n/**\n * @ngdoc method\n * @name $injector#annotate\n *\n * @description\n * Returns an array of service names which the function is requesting for injection. This API is\n * used by the injector to determine which services need to be injected into the function when the\n * function is invoked. There are three ways in which the function can be annotated with the needed\n * dependencies.\n *\n * # Argument names\n *\n * The simplest form is to extract the dependencies from the arguments of the function. This is done\n * by converting the function into a string using `toString()` method and extracting the argument\n * names.\n * ```js\n *   // Given\n *   function MyController($scope, $route) {\n *     // ...\n *   }\n *\n *   // Then\n *   expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);\n * ```\n *\n * You can disallow this method by using strict injection mode.\n *\n * This method does not work with code minification / obfuscation. For this reason the following\n * annotation strategies are supported.\n *\n * # The `$inject` property\n *\n * If a function has an `$inject` property and its value is an array of strings, then the strings\n * represent names of services to be injected into the function.\n * ```js\n *   // Given\n *   var MyController = function(obfuscatedScope, obfuscatedRoute) {\n *     // ...\n *   }\n *   // Define function dependencies\n *   MyController['$inject'] = ['$scope', '$route'];\n *\n *   // Then\n *   expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);\n * ```\n *\n * # The array notation\n *\n * It is often desirable to inline Injected functions and that's when setting the `$inject` property\n * is very inconvenient. In these situations using the array notation to specify the dependencies in\n * a way that survives minification is a better choice:\n *\n * ```js\n *   // We wish to write this (not minification / obfuscation safe)\n *   injector.invoke(function($compile, $rootScope) {\n *     // ...\n *   });\n *\n *   // We are forced to write break inlining\n *   var tmpFn = function(obfuscatedCompile, obfuscatedRootScope) {\n *     // ...\n *   };\n *   tmpFn.$inject = ['$compile', '$rootScope'];\n *   injector.invoke(tmpFn);\n *\n *   // To better support inline function the inline annotation is supported\n *   injector.invoke(['$compile', '$rootScope', function(obfCompile, obfRootScope) {\n *     // ...\n *   }]);\n *\n *   // Therefore\n *   expect(injector.annotate(\n *      ['$compile', '$rootScope', function(obfus_$compile, obfus_$rootScope) {}])\n *    ).toEqual(['$compile', '$rootScope']);\n * ```\n *\n * @param {Function|Array.<string|Function>} fn Function for which dependent service names need to\n * be retrieved as described above.\n *\n * @param {boolean=} [strictDi=false] Disallow argument name annotation inference.\n *\n * @returns {Array.<string>} The names of the services which the function requires.\n */\n\n\n\n\n/**\n * @ngdoc service\n * @name $provide\n *\n * @description\n *\n * The {@link auto.$provide $provide} service has a number of methods for registering components\n * with the {@link auto.$injector $injector}. Many of these functions are also exposed on\n * {@link angular.Module}.\n *\n * An Angular **service** is a singleton object created by a **service factory**.  These **service\n * factories** are functions which, in turn, are created by a **service provider**.\n * The **service providers** are constructor functions. When instantiated they must contain a\n * property called `$get`, which holds the **service factory** function.\n *\n * When you request a service, the {@link auto.$injector $injector} is responsible for finding the\n * correct **service provider**, instantiating it and then calling its `$get` **service factory**\n * function to get the instance of the **service**.\n *\n * Often services have no configuration options and there is no need to add methods to the service\n * provider.  The provider will be no more than a constructor function with a `$get` property. For\n * these cases the {@link auto.$provide $provide} service has additional helper methods to register\n * services without specifying a provider.\n *\n * * {@link auto.$provide#provider provider(provider)} - registers a **service provider** with the\n *     {@link auto.$injector $injector}\n * * {@link auto.$provide#constant constant(obj)} - registers a value/object that can be accessed by\n *     providers and services.\n * * {@link auto.$provide#value value(obj)} - registers a value/object that can only be accessed by\n *     services, not providers.\n * * {@link auto.$provide#factory factory(fn)} - registers a service **factory function**, `fn`,\n *     that will be wrapped in a **service provider** object, whose `$get` property will contain the\n *     given factory function.\n * * {@link auto.$provide#service service(class)} - registers a **constructor function**, `class`\n *     that will be wrapped in a **service provider** object, whose `$get` property will instantiate\n *      a new object using the given constructor function.\n *\n * See the individual methods for more information and examples.\n */\n\n/**\n * @ngdoc method\n * @name $provide#provider\n * @description\n *\n * Register a **provider function** with the {@link auto.$injector $injector}. Provider functions\n * are constructor functions, whose instances are responsible for \"providing\" a factory for a\n * service.\n *\n * Service provider names start with the name of the service they provide followed by `Provider`.\n * For example, the {@link ng.$log $log} service has a provider called\n * {@link ng.$logProvider $logProvider}.\n *\n * Service provider objects can have additional methods which allow configuration of the provider\n * and its service. Importantly, you can configure what kind of service is created by the `$get`\n * method, or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a\n * method {@link ng.$logProvider#debugEnabled debugEnabled}\n * which lets you specify whether the {@link ng.$log $log} service will log debug messages to the\n * console or not.\n *\n * @param {string} name The name of the instance. NOTE: the provider will be available under `name +\n                        'Provider'` key.\n * @param {(Object|function())} provider If the provider is:\n *\n *   - `Object`: then it should have a `$get` method. The `$get` method will be invoked using\n *     {@link auto.$injector#invoke $injector.invoke()} when an instance needs to be created.\n *   - `Constructor`: a new instance of the provider will be created using\n *     {@link auto.$injector#instantiate $injector.instantiate()}, then treated as `object`.\n *\n * @returns {Object} registered provider instance\n\n * @example\n *\n * The following example shows how to create a simple event tracking service and register it using\n * {@link auto.$provide#provider $provide.provider()}.\n *\n * ```js\n *  // Define the eventTracker provider\n *  function EventTrackerProvider() {\n *    var trackingUrl = '/track';\n *\n *    // A provider method for configuring where the tracked events should been saved\n *    this.setTrackingUrl = function(url) {\n *      trackingUrl = url;\n *    };\n *\n *    // The service factory function\n *    this.$get = ['$http', function($http) {\n *      var trackedEvents = {};\n *      return {\n *        // Call this to track an event\n *        event: function(event) {\n *          var count = trackedEvents[event] || 0;\n *          count += 1;\n *          trackedEvents[event] = count;\n *          return count;\n *        },\n *        // Call this to save the tracked events to the trackingUrl\n *        save: function() {\n *          $http.post(trackingUrl, trackedEvents);\n *        }\n *      };\n *    }];\n *  }\n *\n *  describe('eventTracker', function() {\n *    var postSpy;\n *\n *    beforeEach(module(function($provide) {\n *      // Register the eventTracker provider\n *      $provide.provider('eventTracker', EventTrackerProvider);\n *    }));\n *\n *    beforeEach(module(function(eventTrackerProvider) {\n *      // Configure eventTracker provider\n *      eventTrackerProvider.setTrackingUrl('/custom-track');\n *    }));\n *\n *    it('tracks events', inject(function(eventTracker) {\n *      expect(eventTracker.event('login')).toEqual(1);\n *      expect(eventTracker.event('login')).toEqual(2);\n *    }));\n *\n *    it('saves to the tracking url', inject(function(eventTracker, $http) {\n *      postSpy = spyOn($http, 'post');\n *      eventTracker.event('login');\n *      eventTracker.save();\n *      expect(postSpy).toHaveBeenCalled();\n *      expect(postSpy.mostRecentCall.args[0]).not.toEqual('/track');\n *      expect(postSpy.mostRecentCall.args[0]).toEqual('/custom-track');\n *      expect(postSpy.mostRecentCall.args[1]).toEqual({ 'login': 1 });\n *    }));\n *  });\n * ```\n */\n\n/**\n * @ngdoc method\n * @name $provide#factory\n * @description\n *\n * Register a **service factory**, which will be called to return the service instance.\n * This is short for registering a service where its provider consists of only a `$get` property,\n * which is the given service factory function.\n * You should use {@link auto.$provide#factory $provide.factory(getFn)} if you do not need to\n * configure your service in a provider.\n *\n * @param {string} name The name of the instance.\n * @param {Function|Array.<string|Function>} $getFn The injectable $getFn for the instance creation.\n *                      Internally this is a short hand for `$provide.provider(name, {$get: $getFn})`.\n * @returns {Object} registered provider instance\n *\n * @example\n * Here is an example of registering a service\n * ```js\n *   $provide.factory('ping', ['$http', function($http) {\n *     return function ping() {\n *       return $http.send('/ping');\n *     };\n *   }]);\n * ```\n * You would then inject and use this service like this:\n * ```js\n *   someModule.controller('Ctrl', ['ping', function(ping) {\n *     ping();\n *   }]);\n * ```\n */\n\n\n/**\n * @ngdoc method\n * @name $provide#service\n * @description\n *\n * Register a **service constructor**, which will be invoked with `new` to create the service\n * instance.\n * This is short for registering a service where its provider's `$get` property is a factory\n * function that returns an instance instantiated by the injector from the service constructor\n * function.\n *\n * Internally it looks a bit like this:\n *\n * ```\n * {\n *   $get: function() {\n *     return $injector.instantiate(constructor);\n *   }\n * }\n * ```\n *\n *\n * You should use {@link auto.$provide#service $provide.service(class)} if you define your service\n * as a type/class.\n *\n * @param {string} name The name of the instance.\n * @param {Function|Array.<string|Function>} constructor An injectable class (constructor function)\n *     that will be instantiated.\n * @returns {Object} registered provider instance\n *\n * @example\n * Here is an example of registering a service using\n * {@link auto.$provide#service $provide.service(class)}.\n * ```js\n *   var Ping = function($http) {\n *     this.$http = $http;\n *   };\n *\n *   Ping.$inject = ['$http'];\n *\n *   Ping.prototype.send = function() {\n *     return this.$http.get('/ping');\n *   };\n *   $provide.service('ping', Ping);\n * ```\n * You would then inject and use this service like this:\n * ```js\n *   someModule.controller('Ctrl', ['ping', function(ping) {\n *     ping.send();\n *   }]);\n * ```\n */\n\n\n/**\n * @ngdoc method\n * @name $provide#value\n * @description\n *\n * Register a **value service** with the {@link auto.$injector $injector}, such as a string, a\n * number, an array, an object or a function. This is short for registering a service where its\n * provider's `$get` property is a factory function that takes no arguments and returns the **value\n * service**. That also means it is not possible to inject other services into a value service.\n *\n * Value services are similar to constant services, except that they cannot be injected into a\n * module configuration function (see {@link angular.Module#config}) but they can be overridden by\n * an Angular {@link auto.$provide#decorator decorator}.\n *\n * @param {string} name The name of the instance.\n * @param {*} value The value.\n * @returns {Object} registered provider instance\n *\n * @example\n * Here are some examples of creating value services.\n * ```js\n *   $provide.value('ADMIN_USER', 'admin');\n *\n *   $provide.value('RoleLookup', { admin: 0, writer: 1, reader: 2 });\n *\n *   $provide.value('halfOf', function(value) {\n *     return value / 2;\n *   });\n * ```\n */\n\n\n/**\n * @ngdoc method\n * @name $provide#constant\n * @description\n *\n * Register a **constant service** with the {@link auto.$injector $injector}, such as a string,\n * a number, an array, an object or a function. Like the {@link auto.$provide#value value}, it is not\n * possible to inject other services into a constant.\n *\n * But unlike {@link auto.$provide#value value}, a constant can be\n * injected into a module configuration function (see {@link angular.Module#config}) and it cannot\n * be overridden by an Angular {@link auto.$provide#decorator decorator}.\n *\n * @param {string} name The name of the constant.\n * @param {*} value The constant value.\n * @returns {Object} registered instance\n *\n * @example\n * Here a some examples of creating constants:\n * ```js\n *   $provide.constant('SHARD_HEIGHT', 306);\n *\n *   $provide.constant('MY_COLOURS', ['red', 'blue', 'grey']);\n *\n *   $provide.constant('double', function(value) {\n *     return value * 2;\n *   });\n * ```\n */\n\n\n/**\n * @ngdoc method\n * @name $provide#decorator\n * @description\n *\n * Register a **service decorator** with the {@link auto.$injector $injector}. A service decorator\n * intercepts the creation of a service, allowing it to override or modify the behavior of the\n * service. The object returned by the decorator may be the original service, or a new service\n * object which replaces or wraps and delegates to the original service.\n *\n * @param {string} name The name of the service to decorate.\n * @param {Function|Array.<string|Function>} decorator This function will be invoked when the service needs to be\n *    instantiated and should return the decorated service instance. The function is called using\n *    the {@link auto.$injector#invoke injector.invoke} method and is therefore fully injectable.\n *    Local injection arguments:\n *\n *    * `$delegate` - The original service instance, which can be monkey patched, configured,\n *      decorated or delegated to.\n *\n * @example\n * Here we decorate the {@link ng.$log $log} service to convert warnings to errors by intercepting\n * calls to {@link ng.$log#error $log.warn()}.\n * ```js\n *   $provide.decorator('$log', ['$delegate', function($delegate) {\n *     $delegate.warn = $delegate.error;\n *     return $delegate;\n *   }]);\n * ```\n */\n\n\nfunction createInjector(modulesToLoad, strictDi) {\n  strictDi = (strictDi === true);\n  var INSTANTIATING = {},\n      providerSuffix = 'Provider',\n      path = [],\n      loadedModules = new HashMap([], true),\n      providerCache = {\n        $provide: {\n            provider: supportObject(provider),\n            factory: supportObject(factory),\n            service: supportObject(service),\n            value: supportObject(value),\n            constant: supportObject(constant),\n            decorator: decorator\n          }\n      },\n      providerInjector = (providerCache.$injector =\n          createInternalInjector(providerCache, function(serviceName, caller) {\n            if (angular.isString(caller)) {\n              path.push(caller);\n            }\n            throw $injectorMinErr('unpr', \"Unknown provider: {0}\", path.join(' <- '));\n          })),\n      instanceCache = {},\n      protoInstanceInjector =\n          createInternalInjector(instanceCache, function(serviceName, caller) {\n            var provider = providerInjector.get(serviceName + providerSuffix, caller);\n            return instanceInjector.invoke(\n                provider.$get, provider, undefined, serviceName);\n          }),\n      instanceInjector = protoInstanceInjector;\n\n  providerCache['$injector' + providerSuffix] = { $get: valueFn(protoInstanceInjector) };\n  var runBlocks = loadModules(modulesToLoad);\n  instanceInjector = protoInstanceInjector.get('$injector');\n  instanceInjector.strictDi = strictDi;\n  forEach(runBlocks, function(fn) { if (fn) instanceInjector.invoke(fn); });\n\n  return instanceInjector;\n\n  ////////////////////////////////////\n  // $provider\n  ////////////////////////////////////\n\n  function supportObject(delegate) {\n    return function(key, value) {\n      if (isObject(key)) {\n        forEach(key, reverseParams(delegate));\n      } else {\n        return delegate(key, value);\n      }\n    };\n  }\n\n  function provider(name, provider_) {\n    assertNotHasOwnProperty(name, 'service');\n    if (isFunction(provider_) || isArray(provider_)) {\n      provider_ = providerInjector.instantiate(provider_);\n    }\n    if (!provider_.$get) {\n      throw $injectorMinErr('pget', \"Provider '{0}' must define $get factory method.\", name);\n    }\n    return providerCache[name + providerSuffix] = provider_;\n  }\n\n  function enforceReturnValue(name, factory) {\n    return function enforcedReturnValue() {\n      var result = instanceInjector.invoke(factory, this);\n      if (isUndefined(result)) {\n        throw $injectorMinErr('undef', \"Provider '{0}' must return a value from $get factory method.\", name);\n      }\n      return result;\n    };\n  }\n\n  function factory(name, factoryFn, enforce) {\n    return provider(name, {\n      $get: enforce !== false ? enforceReturnValue(name, factoryFn) : factoryFn\n    });\n  }\n\n  function service(name, constructor) {\n    return factory(name, ['$injector', function($injector) {\n      return $injector.instantiate(constructor);\n    }]);\n  }\n\n  function value(name, val) { return factory(name, valueFn(val), false); }\n\n  function constant(name, value) {\n    assertNotHasOwnProperty(name, 'constant');\n    providerCache[name] = value;\n    instanceCache[name] = value;\n  }\n\n  function decorator(serviceName, decorFn) {\n    var origProvider = providerInjector.get(serviceName + providerSuffix),\n        orig$get = origProvider.$get;\n\n    origProvider.$get = function() {\n      var origInstance = instanceInjector.invoke(orig$get, origProvider);\n      return instanceInjector.invoke(decorFn, null, {$delegate: origInstance});\n    };\n  }\n\n  ////////////////////////////////////\n  // Module Loading\n  ////////////////////////////////////\n  function loadModules(modulesToLoad) {\n    assertArg(isUndefined(modulesToLoad) || isArray(modulesToLoad), 'modulesToLoad', 'not an array');\n    var runBlocks = [], moduleFn;\n    forEach(modulesToLoad, function(module) {\n      if (loadedModules.get(module)) return;\n      loadedModules.put(module, true);\n\n      function runInvokeQueue(queue) {\n        var i, ii;\n        for (i = 0, ii = queue.length; i < ii; i++) {\n          var invokeArgs = queue[i],\n              provider = providerInjector.get(invokeArgs[0]);\n\n          provider[invokeArgs[1]].apply(provider, invokeArgs[2]);\n        }\n      }\n\n      try {\n        if (isString(module)) {\n          moduleFn = angularModule(module);\n          runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);\n          runInvokeQueue(moduleFn._invokeQueue);\n          runInvokeQueue(moduleFn._configBlocks);\n        } else if (isFunction(module)) {\n            runBlocks.push(providerInjector.invoke(module));\n        } else if (isArray(module)) {\n            runBlocks.push(providerInjector.invoke(module));\n        } else {\n          assertArgFn(module, 'module');\n        }\n      } catch (e) {\n        if (isArray(module)) {\n          module = module[module.length - 1];\n        }\n        if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {\n          // Safari & FF's stack traces don't contain error.message content\n          // unlike those of Chrome and IE\n          // So if stack doesn't contain message, we create a new string that contains both.\n          // Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.\n          /* jshint -W022 */\n          e = e.message + '\\n' + e.stack;\n        }\n        throw $injectorMinErr('modulerr', \"Failed to instantiate module {0} due to:\\n{1}\",\n                  module, e.stack || e.message || e);\n      }\n    });\n    return runBlocks;\n  }\n\n  ////////////////////////////////////\n  // internal Injector\n  ////////////////////////////////////\n\n  function createInternalInjector(cache, factory) {\n\n    function getService(serviceName, caller) {\n      if (cache.hasOwnProperty(serviceName)) {\n        if (cache[serviceName] === INSTANTIATING) {\n          throw $injectorMinErr('cdep', 'Circular dependency found: {0}',\n                    serviceName + ' <- ' + path.join(' <- '));\n        }\n        return cache[serviceName];\n      } else {\n        try {\n          path.unshift(serviceName);\n          cache[serviceName] = INSTANTIATING;\n          return cache[serviceName] = factory(serviceName, caller);\n        } catch (err) {\n          if (cache[serviceName] === INSTANTIATING) {\n            delete cache[serviceName];\n          }\n          throw err;\n        } finally {\n          path.shift();\n        }\n      }\n    }\n\n\n    function injectionArgs(fn, locals, serviceName) {\n      var args = [],\n          $inject = createInjector.$$annotate(fn, strictDi, serviceName);\n\n      for (var i = 0, length = $inject.length; i < length; i++) {\n        var key = $inject[i];\n        if (typeof key !== 'string') {\n          throw $injectorMinErr('itkn',\n                  'Incorrect injection token! Expected service name as string, got {0}', key);\n        }\n        args.push(locals && locals.hasOwnProperty(key) ? locals[key] :\n                                                         getService(key, serviceName));\n      }\n      return args;\n    }\n\n    function isClass(func) {\n      // IE 9-11 do not support classes and IE9 leaks with the code below.\n      if (msie <= 11) {\n        return false;\n      }\n      // Workaround for MS Edge.\n      // Check https://connect.microsoft.com/IE/Feedback/Details/2211653\n      return typeof func === 'function'\n        && /^(?:class\\s|constructor\\()/.test(Function.prototype.toString.call(func));\n    }\n\n    function invoke(fn, self, locals, serviceName) {\n      if (typeof locals === 'string') {\n        serviceName = locals;\n        locals = null;\n      }\n\n      var args = injectionArgs(fn, locals, serviceName);\n      if (isArray(fn)) {\n        fn = fn[fn.length - 1];\n      }\n\n      if (!isClass(fn)) {\n        // http://jsperf.com/angularjs-invoke-apply-vs-switch\n        // #5388\n        return fn.apply(self, args);\n      } else {\n        args.unshift(null);\n        return new (Function.prototype.bind.apply(fn, args))();\n      }\n    }\n\n\n    function instantiate(Type, locals, serviceName) {\n      // Check if Type is annotated and use just the given function at n-1 as parameter\n      // e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);\n      var ctor = (isArray(Type) ? Type[Type.length - 1] : Type);\n      var args = injectionArgs(Type, locals, serviceName);\n      // Empty object at position 0 is ignored for invocation with `new`, but required.\n      args.unshift(null);\n      return new (Function.prototype.bind.apply(ctor, args))();\n    }\n\n\n    return {\n      invoke: invoke,\n      instantiate: instantiate,\n      get: getService,\n      annotate: createInjector.$$annotate,\n      has: function(name) {\n        return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name);\n      }\n    };\n  }\n}\n\ncreateInjector.$$annotate = annotate;\n\n/**\n * @ngdoc provider\n * @name $anchorScrollProvider\n *\n * @description\n * Use `$anchorScrollProvider` to disable automatic scrolling whenever\n * {@link ng.$location#hash $location.hash()} changes.\n */\nfunction $AnchorScrollProvider() {\n\n  var autoScrollingEnabled = true;\n\n  /**\n   * @ngdoc method\n   * @name $anchorScrollProvider#disableAutoScrolling\n   *\n   * @description\n   * By default, {@link ng.$anchorScroll $anchorScroll()} will automatically detect changes to\n   * {@link ng.$location#hash $location.hash()} and scroll to the element matching the new hash.<br />\n   * Use this method to disable automatic scrolling.\n   *\n   * If automatic scrolling is disabled, one must explicitly call\n   * {@link ng.$anchorScroll $anchorScroll()} in order to scroll to the element related to the\n   * current hash.\n   */\n  this.disableAutoScrolling = function() {\n    autoScrollingEnabled = false;\n  };\n\n  /**\n   * @ngdoc service\n   * @name $anchorScroll\n   * @kind function\n   * @requires $window\n   * @requires $location\n   * @requires $rootScope\n   *\n   * @description\n   * When called, it scrolls to the element related to the specified `hash` or (if omitted) to the\n   * current value of {@link ng.$location#hash $location.hash()}, according to the rules specified\n   * in the\n   * [HTML5 spec](http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-indicated-part-of-the-document).\n   *\n   * It also watches the {@link ng.$location#hash $location.hash()} and automatically scrolls to\n   * match any anchor whenever it changes. This can be disabled by calling\n   * {@link ng.$anchorScrollProvider#disableAutoScrolling $anchorScrollProvider.disableAutoScrolling()}.\n   *\n   * Additionally, you can use its {@link ng.$anchorScroll#yOffset yOffset} property to specify a\n   * vertical scroll-offset (either fixed or dynamic).\n   *\n   * @param {string=} hash The hash specifying the element to scroll to. If omitted, the value of\n   *                       {@link ng.$location#hash $location.hash()} will be used.\n   *\n   * @property {(number|function|jqLite)} yOffset\n   * If set, specifies a vertical scroll-offset. This is often useful when there are fixed\n   * positioned elements at the top of the page, such as navbars, headers etc.\n   *\n   * `yOffset` can be specified in various ways:\n   * - **number**: A fixed number of pixels to be used as offset.<br /><br />\n   * - **function**: A getter function called everytime `$anchorScroll()` is executed. Must return\n   *   a number representing the offset (in pixels).<br /><br />\n   * - **jqLite**: A jqLite/jQuery element to be used for specifying the offset. The distance from\n   *   the top of the page to the element's bottom will be used as offset.<br />\n   *   **Note**: The element will be taken into account only as long as its `position` is set to\n   *   `fixed`. This option is useful, when dealing with responsive navbars/headers that adjust\n   *   their height and/or positioning according to the viewport's size.\n   *\n   * <br />\n   * <div class=\"alert alert-warning\">\n   * In order for `yOffset` to work properly, scrolling should take place on the document's root and\n   * not some child element.\n   * </div>\n   *\n   * @example\n     <example module=\"anchorScrollExample\">\n       <file name=\"index.html\">\n         <div id=\"scrollArea\" ng-controller=\"ScrollController\">\n           <a ng-click=\"gotoBottom()\">Go to bottom</a>\n           <a id=\"bottom\"></a> You're at the bottom!\n         </div>\n       </file>\n       <file name=\"script.js\">\n         angular.module('anchorScrollExample', [])\n           .controller('ScrollController', ['$scope', '$location', '$anchorScroll',\n             function ($scope, $location, $anchorScroll) {\n               $scope.gotoBottom = function() {\n                 // set the location.hash to the id of\n                 // the element you wish to scroll to.\n                 $location.hash('bottom');\n\n                 // call $anchorScroll()\n                 $anchorScroll();\n               };\n             }]);\n       </file>\n       <file name=\"style.css\">\n         #scrollArea {\n           height: 280px;\n           overflow: auto;\n         }\n\n         #bottom {\n           display: block;\n           margin-top: 2000px;\n         }\n       </file>\n     </example>\n   *\n   * <hr />\n   * The example below illustrates the use of a vertical scroll-offset (specified as a fixed value).\n   * See {@link ng.$anchorScroll#yOffset $anchorScroll.yOffset} for more details.\n   *\n   * @example\n     <example module=\"anchorScrollOffsetExample\">\n       <file name=\"index.html\">\n         <div class=\"fixed-header\" ng-controller=\"headerCtrl\">\n           <a href=\"\" ng-click=\"gotoAnchor(x)\" ng-repeat=\"x in [1,2,3,4,5]\">\n             Go to anchor {{x}}\n           </a>\n         </div>\n         <div id=\"anchor{{x}}\" class=\"anchor\" ng-repeat=\"x in [1,2,3,4,5]\">\n           Anchor {{x}} of 5\n         </div>\n       </file>\n       <file name=\"script.js\">\n         angular.module('anchorScrollOffsetExample', [])\n           .run(['$anchorScroll', function($anchorScroll) {\n             $anchorScroll.yOffset = 50;   // always scroll by 50 extra pixels\n           }])\n           .controller('headerCtrl', ['$anchorScroll', '$location', '$scope',\n             function ($anchorScroll, $location, $scope) {\n               $scope.gotoAnchor = function(x) {\n                 var newHash = 'anchor' + x;\n                 if ($location.hash() !== newHash) {\n                   // set the $location.hash to `newHash` and\n                   // $anchorScroll will automatically scroll to it\n                   $location.hash('anchor' + x);\n                 } else {\n                   // call $anchorScroll() explicitly,\n                   // since $location.hash hasn't changed\n                   $anchorScroll();\n                 }\n               };\n             }\n           ]);\n       </file>\n       <file name=\"style.css\">\n         body {\n           padding-top: 50px;\n         }\n\n         .anchor {\n           border: 2px dashed DarkOrchid;\n           padding: 10px 10px 200px 10px;\n         }\n\n         .fixed-header {\n           background-color: rgba(0, 0, 0, 0.2);\n           height: 50px;\n           position: fixed;\n           top: 0; left: 0; right: 0;\n         }\n\n         .fixed-header > a {\n           display: inline-block;\n           margin: 5px 15px;\n         }\n       </file>\n     </example>\n   */\n  this.$get = ['$window', '$location', '$rootScope', function($window, $location, $rootScope) {\n    var document = $window.document;\n\n    // Helper function to get first anchor from a NodeList\n    // (using `Array#some()` instead of `angular#forEach()` since it's more performant\n    //  and working in all supported browsers.)\n    function getFirstAnchor(list) {\n      var result = null;\n      Array.prototype.some.call(list, function(element) {\n        if (nodeName_(element) === 'a') {\n          result = element;\n          return true;\n        }\n      });\n      return result;\n    }\n\n    function getYOffset() {\n\n      var offset = scroll.yOffset;\n\n      if (isFunction(offset)) {\n        offset = offset();\n      } else if (isElement(offset)) {\n        var elem = offset[0];\n        var style = $window.getComputedStyle(elem);\n        if (style.position !== 'fixed') {\n          offset = 0;\n        } else {\n          offset = elem.getBoundingClientRect().bottom;\n        }\n      } else if (!isNumber(offset)) {\n        offset = 0;\n      }\n\n      return offset;\n    }\n\n    function scrollTo(elem) {\n      if (elem) {\n        elem.scrollIntoView();\n\n        var offset = getYOffset();\n\n        if (offset) {\n          // `offset` is the number of pixels we should scroll UP in order to align `elem` properly.\n          // This is true ONLY if the call to `elem.scrollIntoView()` initially aligns `elem` at the\n          // top of the viewport.\n          //\n          // IF the number of pixels from the top of `elem` to the end of the page's content is less\n          // than the height of the viewport, then `elem.scrollIntoView()` will align the `elem` some\n          // way down the page.\n          //\n          // This is often the case for elements near the bottom of the page.\n          //\n          // In such cases we do not need to scroll the whole `offset` up, just the difference between\n          // the top of the element and the offset, which is enough to align the top of `elem` at the\n          // desired position.\n          var elemTop = elem.getBoundingClientRect().top;\n          $window.scrollBy(0, elemTop - offset);\n        }\n      } else {\n        $window.scrollTo(0, 0);\n      }\n    }\n\n    function scroll(hash) {\n      hash = isString(hash) ? hash : $location.hash();\n      var elm;\n\n      // empty hash, scroll to the top of the page\n      if (!hash) scrollTo(null);\n\n      // element with given id\n      else if ((elm = document.getElementById(hash))) scrollTo(elm);\n\n      // first anchor with given name :-D\n      else if ((elm = getFirstAnchor(document.getElementsByName(hash)))) scrollTo(elm);\n\n      // no element and hash == 'top', scroll to the top of the page\n      else if (hash === 'top') scrollTo(null);\n    }\n\n    // does not scroll when user clicks on anchor link that is currently on\n    // (no url change, no $location.hash() change), browser native does scroll\n    if (autoScrollingEnabled) {\n      $rootScope.$watch(function autoScrollWatch() {return $location.hash();},\n        function autoScrollWatchAction(newVal, oldVal) {\n          // skip the initial scroll if $location.hash is empty\n          if (newVal === oldVal && newVal === '') return;\n\n          jqLiteDocumentLoaded(function() {\n            $rootScope.$evalAsync(scroll);\n          });\n        });\n    }\n\n    return scroll;\n  }];\n}\n\nvar $animateMinErr = minErr('$animate');\nvar ELEMENT_NODE = 1;\nvar NG_ANIMATE_CLASSNAME = 'ng-animate';\n\nfunction mergeClasses(a,b) {\n  if (!a && !b) return '';\n  if (!a) return b;\n  if (!b) return a;\n  if (isArray(a)) a = a.join(' ');\n  if (isArray(b)) b = b.join(' ');\n  return a + ' ' + b;\n}\n\nfunction extractElementNode(element) {\n  for (var i = 0; i < element.length; i++) {\n    var elm = element[i];\n    if (elm.nodeType === ELEMENT_NODE) {\n      return elm;\n    }\n  }\n}\n\nfunction splitClasses(classes) {\n  if (isString(classes)) {\n    classes = classes.split(' ');\n  }\n\n  // Use createMap() to prevent class assumptions involving property names in\n  // Object.prototype\n  var obj = createMap();\n  forEach(classes, function(klass) {\n    // sometimes the split leaves empty string values\n    // incase extra spaces were applied to the options\n    if (klass.length) {\n      obj[klass] = true;\n    }\n  });\n  return obj;\n}\n\n// if any other type of options value besides an Object value is\n// passed into the $animate.method() animation then this helper code\n// will be run which will ignore it. While this patch is not the\n// greatest solution to this, a lot of existing plugins depend on\n// $animate to either call the callback (< 1.2) or return a promise\n// that can be changed. This helper function ensures that the options\n// are wiped clean incase a callback function is provided.\nfunction prepareAnimateOptions(options) {\n  return isObject(options)\n      ? options\n      : {};\n}\n\nvar $$CoreAnimateJsProvider = function() {\n  this.$get = noop;\n};\n\n// this is prefixed with Core since it conflicts with\n// the animateQueueProvider defined in ngAnimate/animateQueue.js\nvar $$CoreAnimateQueueProvider = function() {\n  var postDigestQueue = new HashMap();\n  var postDigestElements = [];\n\n  this.$get = ['$$AnimateRunner', '$rootScope',\n       function($$AnimateRunner,   $rootScope) {\n    return {\n      enabled: noop,\n      on: noop,\n      off: noop,\n      pin: noop,\n\n      push: function(element, event, options, domOperation) {\n        domOperation        && domOperation();\n\n        options = options || {};\n        options.from        && element.css(options.from);\n        options.to          && element.css(options.to);\n\n        if (options.addClass || options.removeClass) {\n          addRemoveClassesPostDigest(element, options.addClass, options.removeClass);\n        }\n\n        var runner = new $$AnimateRunner(); // jshint ignore:line\n\n        // since there are no animations to run the runner needs to be\n        // notified that the animation call is complete.\n        runner.complete();\n        return runner;\n      }\n    };\n\n\n    function updateData(data, classes, value) {\n      var changed = false;\n      if (classes) {\n        classes = isString(classes) ? classes.split(' ') :\n                  isArray(classes) ? classes : [];\n        forEach(classes, function(className) {\n          if (className) {\n            changed = true;\n            data[className] = value;\n          }\n        });\n      }\n      return changed;\n    }\n\n    function handleCSSClassChanges() {\n      forEach(postDigestElements, function(element) {\n        var data = postDigestQueue.get(element);\n        if (data) {\n          var existing = splitClasses(element.attr('class'));\n          var toAdd = '';\n          var toRemove = '';\n          forEach(data, function(status, className) {\n            var hasClass = !!existing[className];\n            if (status !== hasClass) {\n              if (status) {\n                toAdd += (toAdd.length ? ' ' : '') + className;\n              } else {\n                toRemove += (toRemove.length ? ' ' : '') + className;\n              }\n            }\n          });\n\n          forEach(element, function(elm) {\n            toAdd    && jqLiteAddClass(elm, toAdd);\n            toRemove && jqLiteRemoveClass(elm, toRemove);\n          });\n          postDigestQueue.remove(element);\n        }\n      });\n      postDigestElements.length = 0;\n    }\n\n\n    function addRemoveClassesPostDigest(element, add, remove) {\n      var data = postDigestQueue.get(element) || {};\n\n      var classesAdded = updateData(data, add, true);\n      var classesRemoved = updateData(data, remove, false);\n\n      if (classesAdded || classesRemoved) {\n\n        postDigestQueue.put(element, data);\n        postDigestElements.push(element);\n\n        if (postDigestElements.length === 1) {\n          $rootScope.$$postDigest(handleCSSClassChanges);\n        }\n      }\n    }\n  }];\n};\n\n/**\n * @ngdoc provider\n * @name $animateProvider\n *\n * @description\n * Default implementation of $animate that doesn't perform any animations, instead just\n * synchronously performs DOM updates and resolves the returned runner promise.\n *\n * In order to enable animations the `ngAnimate` module has to be loaded.\n *\n * To see the functional implementation check out `src/ngAnimate/animate.js`.\n */\nvar $AnimateProvider = ['$provide', function($provide) {\n  var provider = this;\n\n  this.$$registeredAnimations = Object.create(null);\n\n   /**\n   * @ngdoc method\n   * @name $animateProvider#register\n   *\n   * @description\n   * Registers a new injectable animation factory function. The factory function produces the\n   * animation object which contains callback functions for each event that is expected to be\n   * animated.\n   *\n   *   * `eventFn`: `function(element, ... , doneFunction, options)`\n   *   The element to animate, the `doneFunction` and the options fed into the animation. Depending\n   *   on the type of animation additional arguments will be injected into the animation function. The\n   *   list below explains the function signatures for the different animation methods:\n   *\n   *   - setClass: function(element, addedClasses, removedClasses, doneFunction, options)\n   *   - addClass: function(element, addedClasses, doneFunction, options)\n   *   - removeClass: function(element, removedClasses, doneFunction, options)\n   *   - enter, leave, move: function(element, doneFunction, options)\n   *   - animate: function(element, fromStyles, toStyles, doneFunction, options)\n   *\n   *   Make sure to trigger the `doneFunction` once the animation is fully complete.\n   *\n   * ```js\n   *   return {\n   *     //enter, leave, move signature\n   *     eventFn : function(element, done, options) {\n   *       //code to run the animation\n   *       //once complete, then run done()\n   *       return function endFunction(wasCancelled) {\n   *         //code to cancel the animation\n   *       }\n   *     }\n   *   }\n   * ```\n   *\n   * @param {string} name The name of the animation (this is what the class-based CSS value will be compared to).\n   * @param {Function} factory The factory function that will be executed to return the animation\n   *                           object.\n   */\n  this.register = function(name, factory) {\n    if (name && name.charAt(0) !== '.') {\n      throw $animateMinErr('notcsel', \"Expecting class selector starting with '.' got '{0}'.\", name);\n    }\n\n    var key = name + '-animation';\n    provider.$$registeredAnimations[name.substr(1)] = key;\n    $provide.factory(key, factory);\n  };\n\n  /**\n   * @ngdoc method\n   * @name $animateProvider#classNameFilter\n   *\n   * @description\n   * Sets and/or returns the CSS class regular expression that is checked when performing\n   * an animation. Upon bootstrap the classNameFilter value is not set at all and will\n   * therefore enable $animate to attempt to perform an animation on any element that is triggered.\n   * When setting the `classNameFilter` value, animations will only be performed on elements\n   * that successfully match the filter expression. This in turn can boost performance\n   * for low-powered devices as well as applications containing a lot of structural operations.\n   * @param {RegExp=} expression The className expression which will be checked against all animations\n   * @return {RegExp} The current CSS className expression value. If null then there is no expression value\n   */\n  this.classNameFilter = function(expression) {\n    if (arguments.length === 1) {\n      this.$$classNameFilter = (expression instanceof RegExp) ? expression : null;\n      if (this.$$classNameFilter) {\n        var reservedRegex = new RegExp(\"(\\\\s+|\\\\/)\" + NG_ANIMATE_CLASSNAME + \"(\\\\s+|\\\\/)\");\n        if (reservedRegex.test(this.$$classNameFilter.toString())) {\n          throw $animateMinErr('nongcls','$animateProvider.classNameFilter(regex) prohibits accepting a regex value which matches/contains the \"{0}\" CSS class.', NG_ANIMATE_CLASSNAME);\n\n        }\n      }\n    }\n    return this.$$classNameFilter;\n  };\n\n  this.$get = ['$$animateQueue', function($$animateQueue) {\n    function domInsert(element, parentElement, afterElement) {\n      // if for some reason the previous element was removed\n      // from the dom sometime before this code runs then let's\n      // just stick to using the parent element as the anchor\n      if (afterElement) {\n        var afterNode = extractElementNode(afterElement);\n        if (afterNode && !afterNode.parentNode && !afterNode.previousElementSibling) {\n          afterElement = null;\n        }\n      }\n      afterElement ? afterElement.after(element) : parentElement.prepend(element);\n    }\n\n    /**\n     * @ngdoc service\n     * @name $animate\n     * @description The $animate service exposes a series of DOM utility methods that provide support\n     * for animation hooks. The default behavior is the application of DOM operations, however,\n     * when an animation is detected (and animations are enabled), $animate will do the heavy lifting\n     * to ensure that animation runs with the triggered DOM operation.\n     *\n     * By default $animate doesn't trigger any animations. This is because the `ngAnimate` module isn't\n     * included and only when it is active then the animation hooks that `$animate` triggers will be\n     * functional. Once active then all structural `ng-` directives will trigger animations as they perform\n     * their DOM-related operations (enter, leave and move). Other directives such as `ngClass`,\n     * `ngShow`, `ngHide` and `ngMessages` also provide support for animations.\n     *\n     * It is recommended that the`$animate` service is always used when executing DOM-related procedures within directives.\n     *\n     * To learn more about enabling animation support, click here to visit the\n     * {@link ngAnimate ngAnimate module page}.\n     */\n    return {\n      // we don't call it directly since non-existant arguments may\n      // be interpreted as null within the sub enabled function\n\n      /**\n       *\n       * @ngdoc method\n       * @name $animate#on\n       * @kind function\n       * @description Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...)\n       *    has fired on the given element or among any of its children. Once the listener is fired, the provided callback\n       *    is fired with the following params:\n       *\n       * ```js\n       * $animate.on('enter', container,\n       *    function callback(element, phase) {\n       *      // cool we detected an enter animation within the container\n       *    }\n       * );\n       * ```\n       *\n       * @param {string} event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)\n       * @param {DOMElement} container the container element that will capture each of the animation events that are fired on itself\n       *     as well as among its children\n       * @param {Function} callback the callback function that will be fired when the listener is triggered\n       *\n       * The arguments present in the callback function are:\n       * * `element` - The captured DOM element that the animation was fired on.\n       * * `phase` - The phase of the animation. The two possible phases are **start** (when the animation starts) and **close** (when it ends).\n       */\n      on: $$animateQueue.on,\n\n      /**\n       *\n       * @ngdoc method\n       * @name $animate#off\n       * @kind function\n       * @description Deregisters an event listener based on the event which has been associated with the provided element. This method\n       * can be used in three different ways depending on the arguments:\n       *\n       * ```js\n       * // remove all the animation event listeners listening for `enter`\n       * $animate.off('enter');\n       *\n       * // remove listeners for all animation events from the container element\n       * $animate.off(container);\n       *\n       * // remove all the animation event listeners listening for `enter` on the given element and its children\n       * $animate.off('enter', container);\n       *\n       * // remove the event listener function provided by `callback` that is set\n       * // to listen for `enter` on the given `container` as well as its children\n       * $animate.off('enter', container, callback);\n       * ```\n       *\n       * @param {string|DOMElement} event|container the animation event (e.g. enter, leave, move,\n       * addClass, removeClass, etc...), or the container element. If it is the element, all other\n       * arguments are ignored.\n       * @param {DOMElement=} container the container element the event listener was placed on\n       * @param {Function=} callback the callback function that was registered as the listener\n       */\n      off: $$animateQueue.off,\n\n      /**\n       * @ngdoc method\n       * @name $animate#pin\n       * @kind function\n       * @description Associates the provided element with a host parent element to allow the element to be animated even if it exists\n       *    outside of the DOM structure of the Angular application. By doing so, any animation triggered via `$animate` can be issued on the\n       *    element despite being outside the realm of the application or within another application. Say for example if the application\n       *    was bootstrapped on an element that is somewhere inside of the `<body>` tag, but we wanted to allow for an element to be situated\n       *    as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind\n       *    that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association.\n       *\n       *    Note that this feature is only active when the `ngAnimate` module is used.\n       *\n       * @param {DOMElement} element the external element that will be pinned\n       * @param {DOMElement} parentElement the host parent element that will be associated with the external element\n       */\n      pin: $$animateQueue.pin,\n\n      /**\n       *\n       * @ngdoc method\n       * @name $animate#enabled\n       * @kind function\n       * @description Used to get and set whether animations are enabled or not on the entire application or on an element and its children. This\n       * function can be called in four ways:\n       *\n       * ```js\n       * // returns true or false\n       * $animate.enabled();\n       *\n       * // changes the enabled state for all animations\n       * $animate.enabled(false);\n       * $animate.enabled(true);\n       *\n       * // returns true or false if animations are enabled for an element\n       * $animate.enabled(element);\n       *\n       * // changes the enabled state for an element and its children\n       * $animate.enabled(element, true);\n       * $animate.enabled(element, false);\n       * ```\n       *\n       * @param {DOMElement=} element the element that will be considered for checking/setting the enabled state\n       * @param {boolean=} enabled whether or not the animations will be enabled for the element\n       *\n       * @return {boolean} whether or not animations are enabled\n       */\n      enabled: $$animateQueue.enabled,\n\n      /**\n       * @ngdoc method\n       * @name $animate#cancel\n       * @kind function\n       * @description Cancels the provided animation.\n       *\n       * @param {Promise} animationPromise The animation promise that is returned when an animation is started.\n       */\n      cancel: function(runner) {\n        runner.end && runner.end();\n      },\n\n      /**\n       *\n       * @ngdoc method\n       * @name $animate#enter\n       * @kind function\n       * @description Inserts the element into the DOM either after the `after` element (if provided) or\n       *   as the first child within the `parent` element and then triggers an animation.\n       *   A promise is returned that will be resolved during the next digest once the animation\n       *   has completed.\n       *\n       * @param {DOMElement} element the element which will be inserted into the DOM\n       * @param {DOMElement} parent the parent element which will append the element as\n       *   a child (so long as the after element is not present)\n       * @param {DOMElement=} after the sibling element after which the element will be appended\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      enter: function(element, parent, after, options) {\n        parent = parent && jqLite(parent);\n        after = after && jqLite(after);\n        parent = parent || after.parent();\n        domInsert(element, parent, after);\n        return $$animateQueue.push(element, 'enter', prepareAnimateOptions(options));\n      },\n\n      /**\n       *\n       * @ngdoc method\n       * @name $animate#move\n       * @kind function\n       * @description Inserts (moves) the element into its new position in the DOM either after\n       *   the `after` element (if provided) or as the first child within the `parent` element\n       *   and then triggers an animation. A promise is returned that will be resolved\n       *   during the next digest once the animation has completed.\n       *\n       * @param {DOMElement} element the element which will be moved into the new DOM position\n       * @param {DOMElement} parent the parent element which will append the element as\n       *   a child (so long as the after element is not present)\n       * @param {DOMElement=} after the sibling element after which the element will be appended\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      move: function(element, parent, after, options) {\n        parent = parent && jqLite(parent);\n        after = after && jqLite(after);\n        parent = parent || after.parent();\n        domInsert(element, parent, after);\n        return $$animateQueue.push(element, 'move', prepareAnimateOptions(options));\n      },\n\n      /**\n       * @ngdoc method\n       * @name $animate#leave\n       * @kind function\n       * @description Triggers an animation and then removes the element from the DOM.\n       * When the function is called a promise is returned that will be resolved during the next\n       * digest once the animation has completed.\n       *\n       * @param {DOMElement} element the element which will be removed from the DOM\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      leave: function(element, options) {\n        return $$animateQueue.push(element, 'leave', prepareAnimateOptions(options), function() {\n          element.remove();\n        });\n      },\n\n      /**\n       * @ngdoc method\n       * @name $animate#addClass\n       * @kind function\n       *\n       * @description Triggers an addClass animation surrounding the addition of the provided CSS class(es). Upon\n       *   execution, the addClass operation will only be handled after the next digest and it will not trigger an\n       *   animation if element already contains the CSS class or if the class is removed at a later step.\n       *   Note that class-based animations are treated differently compared to structural animations\n       *   (like enter, move and leave) since the CSS classes may be added/removed at different points\n       *   depending if CSS or JavaScript animations are used.\n       *\n       * @param {DOMElement} element the element which the CSS classes will be applied to\n       * @param {string} className the CSS class(es) that will be added (multiple classes are separated via spaces)\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      addClass: function(element, className, options) {\n        options = prepareAnimateOptions(options);\n        options.addClass = mergeClasses(options.addclass, className);\n        return $$animateQueue.push(element, 'addClass', options);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $animate#removeClass\n       * @kind function\n       *\n       * @description Triggers a removeClass animation surrounding the removal of the provided CSS class(es). Upon\n       *   execution, the removeClass operation will only be handled after the next digest and it will not trigger an\n       *   animation if element does not contain the CSS class or if the class is added at a later step.\n       *   Note that class-based animations are treated differently compared to structural animations\n       *   (like enter, move and leave) since the CSS classes may be added/removed at different points\n       *   depending if CSS or JavaScript animations are used.\n       *\n       * @param {DOMElement} element the element which the CSS classes will be applied to\n       * @param {string} className the CSS class(es) that will be removed (multiple classes are separated via spaces)\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      removeClass: function(element, className, options) {\n        options = prepareAnimateOptions(options);\n        options.removeClass = mergeClasses(options.removeClass, className);\n        return $$animateQueue.push(element, 'removeClass', options);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $animate#setClass\n       * @kind function\n       *\n       * @description Performs both the addition and removal of a CSS classes on an element and (during the process)\n       *    triggers an animation surrounding the class addition/removal. Much like `$animate.addClass` and\n       *    `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has\n       *    passed. Note that class-based animations are treated differently compared to structural animations\n       *    (like enter, move and leave) since the CSS classes may be added/removed at different points\n       *    depending if CSS or JavaScript animations are used.\n       *\n       * @param {DOMElement} element the element which the CSS classes will be applied to\n       * @param {string} add the CSS class(es) that will be added (multiple classes are separated via spaces)\n       * @param {string} remove the CSS class(es) that will be removed (multiple classes are separated via spaces)\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      setClass: function(element, add, remove, options) {\n        options = prepareAnimateOptions(options);\n        options.addClass = mergeClasses(options.addClass, add);\n        options.removeClass = mergeClasses(options.removeClass, remove);\n        return $$animateQueue.push(element, 'setClass', options);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $animate#animate\n       * @kind function\n       *\n       * @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element.\n       * If any detected CSS transition, keyframe or JavaScript matches the provided className value, then the animation will take\n       * on the provided styles. For example, if a transition animation is set for the given classNamem, then the provided `from` and\n       * `to` styles will be applied alongside the given transition. If the CSS style provided in `from` does not have a corresponding\n       * style in `to`, the style in `from` is applied immediately, and no animation is run.\n       * If a JavaScript animation is detected then the provided styles will be given in as function parameters into the `animate`\n       * method (or as part of the `options` parameter):\n       *\n       * ```js\n       * ngModule.animation('.my-inline-animation', function() {\n       *   return {\n       *     animate : function(element, from, to, done, options) {\n       *       //animation\n       *       done();\n       *     }\n       *   }\n       * });\n       * ```\n       *\n       * @param {DOMElement} element the element which the CSS styles will be applied to\n       * @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation.\n       * @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation.\n       * @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If\n       *    this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element.\n       *    (Note that if no animation is detected then this value will not be applied to the element.)\n       * @param {object=} options an optional collection of options/styles that will be applied to the element\n       *\n       * @return {Promise} the animation callback promise\n       */\n      animate: function(element, from, to, className, options) {\n        options = prepareAnimateOptions(options);\n        options.from = options.from ? extend(options.from, from) : from;\n        options.to   = options.to   ? extend(options.to, to)     : to;\n\n        className = className || 'ng-inline-animate';\n        options.tempClasses = mergeClasses(options.tempClasses, className);\n        return $$animateQueue.push(element, 'animate', options);\n      }\n    };\n  }];\n}];\n\nvar $$AnimateAsyncRunFactoryProvider = function() {\n  this.$get = ['$$rAF', function($$rAF) {\n    var waitQueue = [];\n\n    function waitForTick(fn) {\n      waitQueue.push(fn);\n      if (waitQueue.length > 1) return;\n      $$rAF(function() {\n        for (var i = 0; i < waitQueue.length; i++) {\n          waitQueue[i]();\n        }\n        waitQueue = [];\n      });\n    }\n\n    return function() {\n      var passed = false;\n      waitForTick(function() {\n        passed = true;\n      });\n      return function(callback) {\n        passed ? callback() : waitForTick(callback);\n      };\n    };\n  }];\n};\n\nvar $$AnimateRunnerFactoryProvider = function() {\n  this.$get = ['$q', '$sniffer', '$$animateAsyncRun', '$document', '$timeout',\n       function($q,   $sniffer,   $$animateAsyncRun,   $document,   $timeout) {\n\n    var INITIAL_STATE = 0;\n    var DONE_PENDING_STATE = 1;\n    var DONE_COMPLETE_STATE = 2;\n\n    AnimateRunner.chain = function(chain, callback) {\n      var index = 0;\n\n      next();\n      function next() {\n        if (index === chain.length) {\n          callback(true);\n          return;\n        }\n\n        chain[index](function(response) {\n          if (response === false) {\n            callback(false);\n            return;\n          }\n          index++;\n          next();\n        });\n      }\n    };\n\n    AnimateRunner.all = function(runners, callback) {\n      var count = 0;\n      var status = true;\n      forEach(runners, function(runner) {\n        runner.done(onProgress);\n      });\n\n      function onProgress(response) {\n        status = status && response;\n        if (++count === runners.length) {\n          callback(status);\n        }\n      }\n    };\n\n    function AnimateRunner(host) {\n      this.setHost(host);\n\n      var rafTick = $$animateAsyncRun();\n      var timeoutTick = function(fn) {\n        $timeout(fn, 0, false);\n      };\n\n      this._doneCallbacks = [];\n      this._tick = function(fn) {\n        var doc = $document[0];\n\n        // the document may not be ready or attached\n        // to the module for some internal tests\n        if (doc && doc.hidden) {\n          timeoutTick(fn);\n        } else {\n          rafTick(fn);\n        }\n      };\n      this._state = 0;\n    }\n\n    AnimateRunner.prototype = {\n      setHost: function(host) {\n        this.host = host || {};\n      },\n\n      done: function(fn) {\n        if (this._state === DONE_COMPLETE_STATE) {\n          fn();\n        } else {\n          this._doneCallbacks.push(fn);\n        }\n      },\n\n      progress: noop,\n\n      getPromise: function() {\n        if (!this.promise) {\n          var self = this;\n          this.promise = $q(function(resolve, reject) {\n            self.done(function(status) {\n              status === false ? reject() : resolve();\n            });\n          });\n        }\n        return this.promise;\n      },\n\n      then: function(resolveHandler, rejectHandler) {\n        return this.getPromise().then(resolveHandler, rejectHandler);\n      },\n\n      'catch': function(handler) {\n        return this.getPromise()['catch'](handler);\n      },\n\n      'finally': function(handler) {\n        return this.getPromise()['finally'](handler);\n      },\n\n      pause: function() {\n        if (this.host.pause) {\n          this.host.pause();\n        }\n      },\n\n      resume: function() {\n        if (this.host.resume) {\n          this.host.resume();\n        }\n      },\n\n      end: function() {\n        if (this.host.end) {\n          this.host.end();\n        }\n        this._resolve(true);\n      },\n\n      cancel: function() {\n        if (this.host.cancel) {\n          this.host.cancel();\n        }\n        this._resolve(false);\n      },\n\n      complete: function(response) {\n        var self = this;\n        if (self._state === INITIAL_STATE) {\n          self._state = DONE_PENDING_STATE;\n          self._tick(function() {\n            self._resolve(response);\n          });\n        }\n      },\n\n      _resolve: function(response) {\n        if (this._state !== DONE_COMPLETE_STATE) {\n          forEach(this._doneCallbacks, function(fn) {\n            fn(response);\n          });\n          this._doneCallbacks.length = 0;\n          this._state = DONE_COMPLETE_STATE;\n        }\n      }\n    };\n\n    return AnimateRunner;\n  }];\n};\n\n/**\n * @ngdoc service\n * @name $animateCss\n * @kind object\n *\n * @description\n * This is the core version of `$animateCss`. By default, only when the `ngAnimate` is included,\n * then the `$animateCss` service will actually perform animations.\n *\n * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}.\n */\nvar $CoreAnimateCssProvider = function() {\n  this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) {\n\n    return function(element, initialOptions) {\n      // all of the animation functions should create\n      // a copy of the options data, however, if a\n      // parent service has already created a copy then\n      // we should stick to using that\n      var options = initialOptions || {};\n      if (!options.$$prepared) {\n        options = copy(options);\n      }\n\n      // there is no point in applying the styles since\n      // there is no animation that goes on at all in\n      // this version of $animateCss.\n      if (options.cleanupStyles) {\n        options.from = options.to = null;\n      }\n\n      if (options.from) {\n        element.css(options.from);\n        options.from = null;\n      }\n\n      /* jshint newcap: false */\n      var closed, runner = new $$AnimateRunner();\n      return {\n        start: run,\n        end: run\n      };\n\n      function run() {\n        $$rAF(function() {\n          applyAnimationContents();\n          if (!closed) {\n            runner.complete();\n          }\n          closed = true;\n        });\n        return runner;\n      }\n\n      function applyAnimationContents() {\n        if (options.addClass) {\n          element.addClass(options.addClass);\n          options.addClass = null;\n        }\n        if (options.removeClass) {\n          element.removeClass(options.removeClass);\n          options.removeClass = null;\n        }\n        if (options.to) {\n          element.css(options.to);\n          options.to = null;\n        }\n      }\n    };\n  }];\n};\n\n/* global stripHash: true */\n\n/**\n * ! This is a private undocumented service !\n *\n * @name $browser\n * @requires $log\n * @description\n * This object has two goals:\n *\n * - hide all the global state in the browser caused by the window object\n * - abstract away all the browser specific features and inconsistencies\n *\n * For tests we provide {@link ngMock.$browser mock implementation} of the `$browser`\n * service, which can be used for convenient testing of the application without the interaction with\n * the real browser apis.\n */\n/**\n * @param {object} window The global window object.\n * @param {object} document jQuery wrapped document.\n * @param {object} $log window.console or an object with the same interface.\n * @param {object} $sniffer $sniffer service\n */\nfunction Browser(window, document, $log, $sniffer) {\n  var self = this,\n      location = window.location,\n      history = window.history,\n      setTimeout = window.setTimeout,\n      clearTimeout = window.clearTimeout,\n      pendingDeferIds = {};\n\n  self.isMock = false;\n\n  var outstandingRequestCount = 0;\n  var outstandingRequestCallbacks = [];\n\n  // TODO(vojta): remove this temporary api\n  self.$$completeOutstandingRequest = completeOutstandingRequest;\n  self.$$incOutstandingRequestCount = function() { outstandingRequestCount++; };\n\n  /**\n   * Executes the `fn` function(supports currying) and decrements the `outstandingRequestCallbacks`\n   * counter. If the counter reaches 0, all the `outstandingRequestCallbacks` are executed.\n   */\n  function completeOutstandingRequest(fn) {\n    try {\n      fn.apply(null, sliceArgs(arguments, 1));\n    } finally {\n      outstandingRequestCount--;\n      if (outstandingRequestCount === 0) {\n        while (outstandingRequestCallbacks.length) {\n          try {\n            outstandingRequestCallbacks.pop()();\n          } catch (e) {\n            $log.error(e);\n          }\n        }\n      }\n    }\n  }\n\n  function getHash(url) {\n    var index = url.indexOf('#');\n    return index === -1 ? '' : url.substr(index);\n  }\n\n  /**\n   * @private\n   * Note: this method is used only by scenario runner\n   * TODO(vojta): prefix this method with $$ ?\n   * @param {function()} callback Function that will be called when no outstanding request\n   */\n  self.notifyWhenNoOutstandingRequests = function(callback) {\n    if (outstandingRequestCount === 0) {\n      callback();\n    } else {\n      outstandingRequestCallbacks.push(callback);\n    }\n  };\n\n  //////////////////////////////////////////////////////////////\n  // URL API\n  //////////////////////////////////////////////////////////////\n\n  var cachedState, lastHistoryState,\n      lastBrowserUrl = location.href,\n      baseElement = document.find('base'),\n      pendingLocation = null,\n      getCurrentState = !$sniffer.history ? noop : function getCurrentState() {\n        try {\n          return history.state;\n        } catch (e) {\n          // MSIE can reportedly throw when there is no state (UNCONFIRMED).\n        }\n      };\n\n  cacheState();\n  lastHistoryState = cachedState;\n\n  /**\n   * @name $browser#url\n   *\n   * @description\n   * GETTER:\n   * Without any argument, this method just returns current value of location.href.\n   *\n   * SETTER:\n   * With at least one argument, this method sets url to new value.\n   * If html5 history api supported, pushState/replaceState is used, otherwise\n   * location.href/location.replace is used.\n   * Returns its own instance to allow chaining\n   *\n   * NOTE: this api is intended for use only by the $location service. Please use the\n   * {@link ng.$location $location service} to change url.\n   *\n   * @param {string} url New url (when used as setter)\n   * @param {boolean=} replace Should new url replace current history record?\n   * @param {object=} state object to use with pushState/replaceState\n   */\n  self.url = function(url, replace, state) {\n    // In modern browsers `history.state` is `null` by default; treating it separately\n    // from `undefined` would cause `$browser.url('/foo')` to change `history.state`\n    // to undefined via `pushState`. Instead, let's change `undefined` to `null` here.\n    if (isUndefined(state)) {\n      state = null;\n    }\n\n    // Android Browser BFCache causes location, history reference to become stale.\n    if (location !== window.location) location = window.location;\n    if (history !== window.history) history = window.history;\n\n    // setter\n    if (url) {\n      var sameState = lastHistoryState === state;\n\n      // Don't change anything if previous and current URLs and states match. This also prevents\n      // IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode.\n      // See https://github.com/angular/angular.js/commit/ffb2701\n      if (lastBrowserUrl === url && (!$sniffer.history || sameState)) {\n        return self;\n      }\n      var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url);\n      lastBrowserUrl = url;\n      lastHistoryState = state;\n      // Don't use history API if only the hash changed\n      // due to a bug in IE10/IE11 which leads\n      // to not firing a `hashchange` nor `popstate` event\n      // in some cases (see #9143).\n      if ($sniffer.history && (!sameBase || !sameState)) {\n        history[replace ? 'replaceState' : 'pushState'](state, '', url);\n        cacheState();\n        // Do the assignment again so that those two variables are referentially identical.\n        lastHistoryState = cachedState;\n      } else {\n        if (!sameBase || pendingLocation) {\n          pendingLocation = url;\n        }\n        if (replace) {\n          location.replace(url);\n        } else if (!sameBase) {\n          location.href = url;\n        } else {\n          location.hash = getHash(url);\n        }\n        if (location.href !== url) {\n          pendingLocation = url;\n        }\n      }\n      return self;\n    // getter\n    } else {\n      // - pendingLocation is needed as browsers don't allow to read out\n      //   the new location.href if a reload happened or if there is a bug like in iOS 9 (see\n      //   https://openradar.appspot.com/22186109).\n      // - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172\n      return pendingLocation || location.href.replace(/%27/g,\"'\");\n    }\n  };\n\n  /**\n   * @name $browser#state\n   *\n   * @description\n   * This method is a getter.\n   *\n   * Return history.state or null if history.state is undefined.\n   *\n   * @returns {object} state\n   */\n  self.state = function() {\n    return cachedState;\n  };\n\n  var urlChangeListeners = [],\n      urlChangeInit = false;\n\n  function cacheStateAndFireUrlChange() {\n    pendingLocation = null;\n    cacheState();\n    fireUrlChange();\n  }\n\n  // This variable should be used *only* inside the cacheState function.\n  var lastCachedState = null;\n  function cacheState() {\n    // This should be the only place in $browser where `history.state` is read.\n    cachedState = getCurrentState();\n    cachedState = isUndefined(cachedState) ? null : cachedState;\n\n    // Prevent callbacks fo fire twice if both hashchange & popstate were fired.\n    if (equals(cachedState, lastCachedState)) {\n      cachedState = lastCachedState;\n    }\n    lastCachedState = cachedState;\n  }\n\n  function fireUrlChange() {\n    if (lastBrowserUrl === self.url() && lastHistoryState === cachedState) {\n      return;\n    }\n\n    lastBrowserUrl = self.url();\n    lastHistoryState = cachedState;\n    forEach(urlChangeListeners, function(listener) {\n      listener(self.url(), cachedState);\n    });\n  }\n\n  /**\n   * @name $browser#onUrlChange\n   *\n   * @description\n   * Register callback function that will be called, when url changes.\n   *\n   * It's only called when the url is changed from outside of angular:\n   * - user types different url into address bar\n   * - user clicks on history (forward/back) button\n   * - user clicks on a link\n   *\n   * It's not called when url is changed by $browser.url() method\n   *\n   * The listener gets called with new url as parameter.\n   *\n   * NOTE: this api is intended for use only by the $location service. Please use the\n   * {@link ng.$location $location service} to monitor url changes in angular apps.\n   *\n   * @param {function(string)} listener Listener function to be called when url changes.\n   * @return {function(string)} Returns the registered listener fn - handy if the fn is anonymous.\n   */\n  self.onUrlChange = function(callback) {\n    // TODO(vojta): refactor to use node's syntax for events\n    if (!urlChangeInit) {\n      // We listen on both (hashchange/popstate) when available, as some browsers (e.g. Opera)\n      // don't fire popstate when user change the address bar and don't fire hashchange when url\n      // changed by push/replaceState\n\n      // html5 history api - popstate event\n      if ($sniffer.history) jqLite(window).on('popstate', cacheStateAndFireUrlChange);\n      // hashchange event\n      jqLite(window).on('hashchange', cacheStateAndFireUrlChange);\n\n      urlChangeInit = true;\n    }\n\n    urlChangeListeners.push(callback);\n    return callback;\n  };\n\n  /**\n   * @private\n   * Remove popstate and hashchange handler from window.\n   *\n   * NOTE: this api is intended for use only by $rootScope.\n   */\n  self.$$applicationDestroyed = function() {\n    jqLite(window).off('hashchange popstate', cacheStateAndFireUrlChange);\n  };\n\n  /**\n   * Checks whether the url has changed outside of Angular.\n   * Needs to be exported to be able to check for changes that have been done in sync,\n   * as hashchange/popstate events fire in async.\n   */\n  self.$$checkUrlChange = fireUrlChange;\n\n  //////////////////////////////////////////////////////////////\n  // Misc API\n  //////////////////////////////////////////////////////////////\n\n  /**\n   * @name $browser#baseHref\n   *\n   * @description\n   * Returns current <base href>\n   * (always relative - without domain)\n   *\n   * @returns {string} The current base href\n   */\n  self.baseHref = function() {\n    var href = baseElement.attr('href');\n    return href ? href.replace(/^(https?\\:)?\\/\\/[^\\/]*/, '') : '';\n  };\n\n  /**\n   * @name $browser#defer\n   * @param {function()} fn A function, who's execution should be deferred.\n   * @param {number=} [delay=0] of milliseconds to defer the function execution.\n   * @returns {*} DeferId that can be used to cancel the task via `$browser.defer.cancel()`.\n   *\n   * @description\n   * Executes a fn asynchronously via `setTimeout(fn, delay)`.\n   *\n   * Unlike when calling `setTimeout` directly, in test this function is mocked and instead of using\n   * `setTimeout` in tests, the fns are queued in an array, which can be programmatically flushed\n   * via `$browser.defer.flush()`.\n   *\n   */\n  self.defer = function(fn, delay) {\n    var timeoutId;\n    outstandingRequestCount++;\n    timeoutId = setTimeout(function() {\n      delete pendingDeferIds[timeoutId];\n      completeOutstandingRequest(fn);\n    }, delay || 0);\n    pendingDeferIds[timeoutId] = true;\n    return timeoutId;\n  };\n\n\n  /**\n   * @name $browser#defer.cancel\n   *\n   * @description\n   * Cancels a deferred task identified with `deferId`.\n   *\n   * @param {*} deferId Token returned by the `$browser.defer` function.\n   * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully\n   *                    canceled.\n   */\n  self.defer.cancel = function(deferId) {\n    if (pendingDeferIds[deferId]) {\n      delete pendingDeferIds[deferId];\n      clearTimeout(deferId);\n      completeOutstandingRequest(noop);\n      return true;\n    }\n    return false;\n  };\n\n}\n\nfunction $BrowserProvider() {\n  this.$get = ['$window', '$log', '$sniffer', '$document',\n      function($window, $log, $sniffer, $document) {\n        return new Browser($window, $document, $log, $sniffer);\n      }];\n}\n\n/**\n * @ngdoc service\n * @name $cacheFactory\n *\n * @description\n * Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to\n * them.\n *\n * ```js\n *\n *  var cache = $cacheFactory('cacheId');\n *  expect($cacheFactory.get('cacheId')).toBe(cache);\n *  expect($cacheFactory.get('noSuchCacheId')).not.toBeDefined();\n *\n *  cache.put(\"key\", \"value\");\n *  cache.put(\"another key\", \"another value\");\n *\n *  // We've specified no options on creation\n *  expect(cache.info()).toEqual({id: 'cacheId', size: 2});\n *\n * ```\n *\n *\n * @param {string} cacheId Name or id of the newly created cache.\n * @param {object=} options Options object that specifies the cache behavior. Properties:\n *\n *   - `{number=}` `capacity` — turns the cache into LRU cache.\n *\n * @returns {object} Newly created cache object with the following set of methods:\n *\n * - `{object}` `info()` — Returns id, size, and options of cache.\n * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns\n *   it.\n * - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss.\n * - `{void}` `remove({string} key)` — Removes a key-value pair from the cache.\n * - `{void}` `removeAll()` — Removes all cached values.\n * - `{void}` `destroy()` — Removes references to this cache from $cacheFactory.\n *\n * @example\n   <example module=\"cacheExampleApp\">\n     <file name=\"index.html\">\n       <div ng-controller=\"CacheController\">\n         <input ng-model=\"newCacheKey\" placeholder=\"Key\">\n         <input ng-model=\"newCacheValue\" placeholder=\"Value\">\n         <button ng-click=\"put(newCacheKey, newCacheValue)\">Cache</button>\n\n         <p ng-if=\"keys.length\">Cached Values</p>\n         <div ng-repeat=\"key in keys\">\n           <span ng-bind=\"key\"></span>\n           <span>: </span>\n           <b ng-bind=\"cache.get(key)\"></b>\n         </div>\n\n         <p>Cache Info</p>\n         <div ng-repeat=\"(key, value) in cache.info()\">\n           <span ng-bind=\"key\"></span>\n           <span>: </span>\n           <b ng-bind=\"value\"></b>\n         </div>\n       </div>\n     </file>\n     <file name=\"script.js\">\n       angular.module('cacheExampleApp', []).\n         controller('CacheController', ['$scope', '$cacheFactory', function($scope, $cacheFactory) {\n           $scope.keys = [];\n           $scope.cache = $cacheFactory('cacheId');\n           $scope.put = function(key, value) {\n             if (angular.isUndefined($scope.cache.get(key))) {\n               $scope.keys.push(key);\n             }\n             $scope.cache.put(key, angular.isUndefined(value) ? null : value);\n           };\n         }]);\n     </file>\n     <file name=\"style.css\">\n       p {\n         margin: 10px 0 3px;\n       }\n     </file>\n   </example>\n */\nfunction $CacheFactoryProvider() {\n\n  this.$get = function() {\n    var caches = {};\n\n    function cacheFactory(cacheId, options) {\n      if (cacheId in caches) {\n        throw minErr('$cacheFactory')('iid', \"CacheId '{0}' is already taken!\", cacheId);\n      }\n\n      var size = 0,\n          stats = extend({}, options, {id: cacheId}),\n          data = createMap(),\n          capacity = (options && options.capacity) || Number.MAX_VALUE,\n          lruHash = createMap(),\n          freshEnd = null,\n          staleEnd = null;\n\n      /**\n       * @ngdoc type\n       * @name $cacheFactory.Cache\n       *\n       * @description\n       * A cache object used to store and retrieve data, primarily used by\n       * {@link $http $http} and the {@link ng.directive:script script} directive to cache\n       * templates and other data.\n       *\n       * ```js\n       *  angular.module('superCache')\n       *    .factory('superCache', ['$cacheFactory', function($cacheFactory) {\n       *      return $cacheFactory('super-cache');\n       *    }]);\n       * ```\n       *\n       * Example test:\n       *\n       * ```js\n       *  it('should behave like a cache', inject(function(superCache) {\n       *    superCache.put('key', 'value');\n       *    superCache.put('another key', 'another value');\n       *\n       *    expect(superCache.info()).toEqual({\n       *      id: 'super-cache',\n       *      size: 2\n       *    });\n       *\n       *    superCache.remove('another key');\n       *    expect(superCache.get('another key')).toBeUndefined();\n       *\n       *    superCache.removeAll();\n       *    expect(superCache.info()).toEqual({\n       *      id: 'super-cache',\n       *      size: 0\n       *    });\n       *  }));\n       * ```\n       */\n      return caches[cacheId] = {\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#put\n         * @kind function\n         *\n         * @description\n         * Inserts a named entry into the {@link $cacheFactory.Cache Cache} object to be\n         * retrieved later, and incrementing the size of the cache if the key was not already\n         * present in the cache. If behaving like an LRU cache, it will also remove stale\n         * entries from the set.\n         *\n         * It will not insert undefined values into the cache.\n         *\n         * @param {string} key the key under which the cached data is stored.\n         * @param {*} value the value to store alongside the key. If it is undefined, the key\n         *    will not be stored.\n         * @returns {*} the value stored.\n         */\n        put: function(key, value) {\n          if (isUndefined(value)) return;\n          if (capacity < Number.MAX_VALUE) {\n            var lruEntry = lruHash[key] || (lruHash[key] = {key: key});\n\n            refresh(lruEntry);\n          }\n\n          if (!(key in data)) size++;\n          data[key] = value;\n\n          if (size > capacity) {\n            this.remove(staleEnd.key);\n          }\n\n          return value;\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#get\n         * @kind function\n         *\n         * @description\n         * Retrieves named data stored in the {@link $cacheFactory.Cache Cache} object.\n         *\n         * @param {string} key the key of the data to be retrieved\n         * @returns {*} the value stored.\n         */\n        get: function(key) {\n          if (capacity < Number.MAX_VALUE) {\n            var lruEntry = lruHash[key];\n\n            if (!lruEntry) return;\n\n            refresh(lruEntry);\n          }\n\n          return data[key];\n        },\n\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#remove\n         * @kind function\n         *\n         * @description\n         * Removes an entry from the {@link $cacheFactory.Cache Cache} object.\n         *\n         * @param {string} key the key of the entry to be removed\n         */\n        remove: function(key) {\n          if (capacity < Number.MAX_VALUE) {\n            var lruEntry = lruHash[key];\n\n            if (!lruEntry) return;\n\n            if (lruEntry == freshEnd) freshEnd = lruEntry.p;\n            if (lruEntry == staleEnd) staleEnd = lruEntry.n;\n            link(lruEntry.n,lruEntry.p);\n\n            delete lruHash[key];\n          }\n\n          if (!(key in data)) return;\n\n          delete data[key];\n          size--;\n        },\n\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#removeAll\n         * @kind function\n         *\n         * @description\n         * Clears the cache object of any entries.\n         */\n        removeAll: function() {\n          data = createMap();\n          size = 0;\n          lruHash = createMap();\n          freshEnd = staleEnd = null;\n        },\n\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#destroy\n         * @kind function\n         *\n         * @description\n         * Destroys the {@link $cacheFactory.Cache Cache} object entirely,\n         * removing it from the {@link $cacheFactory $cacheFactory} set.\n         */\n        destroy: function() {\n          data = null;\n          stats = null;\n          lruHash = null;\n          delete caches[cacheId];\n        },\n\n\n        /**\n         * @ngdoc method\n         * @name $cacheFactory.Cache#info\n         * @kind function\n         *\n         * @description\n         * Retrieve information regarding a particular {@link $cacheFactory.Cache Cache}.\n         *\n         * @returns {object} an object with the following properties:\n         *   <ul>\n         *     <li>**id**: the id of the cache instance</li>\n         *     <li>**size**: the number of entries kept in the cache instance</li>\n         *     <li>**...**: any additional properties from the options object when creating the\n         *       cache.</li>\n         *   </ul>\n         */\n        info: function() {\n          return extend({}, stats, {size: size});\n        }\n      };\n\n\n      /**\n       * makes the `entry` the freshEnd of the LRU linked list\n       */\n      function refresh(entry) {\n        if (entry != freshEnd) {\n          if (!staleEnd) {\n            staleEnd = entry;\n          } else if (staleEnd == entry) {\n            staleEnd = entry.n;\n          }\n\n          link(entry.n, entry.p);\n          link(entry, freshEnd);\n          freshEnd = entry;\n          freshEnd.n = null;\n        }\n      }\n\n\n      /**\n       * bidirectionally links two entries of the LRU linked list\n       */\n      function link(nextEntry, prevEntry) {\n        if (nextEntry != prevEntry) {\n          if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify\n          if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify\n        }\n      }\n    }\n\n\n  /**\n   * @ngdoc method\n   * @name $cacheFactory#info\n   *\n   * @description\n   * Get information about all the caches that have been created\n   *\n   * @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info`\n   */\n    cacheFactory.info = function() {\n      var info = {};\n      forEach(caches, function(cache, cacheId) {\n        info[cacheId] = cache.info();\n      });\n      return info;\n    };\n\n\n  /**\n   * @ngdoc method\n   * @name $cacheFactory#get\n   *\n   * @description\n   * Get access to a cache object by the `cacheId` used when it was created.\n   *\n   * @param {string} cacheId Name or id of a cache to access.\n   * @returns {object} Cache object identified by the cacheId or undefined if no such cache.\n   */\n    cacheFactory.get = function(cacheId) {\n      return caches[cacheId];\n    };\n\n\n    return cacheFactory;\n  };\n}\n\n/**\n * @ngdoc service\n * @name $templateCache\n *\n * @description\n * The first time a template is used, it is loaded in the template cache for quick retrieval. You\n * can load templates directly into the cache in a `script` tag, or by consuming the\n * `$templateCache` service directly.\n *\n * Adding via the `script` tag:\n *\n * ```html\n *   <script type=\"text/ng-template\" id=\"templateId.html\">\n *     <p>This is the content of the template</p>\n *   </script>\n * ```\n *\n * **Note:** the `script` tag containing the template does not need to be included in the `head` of\n * the document, but it must be a descendent of the {@link ng.$rootElement $rootElement} (IE,\n * element with ng-app attribute), otherwise the template will be ignored.\n *\n * Adding via the `$templateCache` service:\n *\n * ```js\n * var myApp = angular.module('myApp', []);\n * myApp.run(function($templateCache) {\n *   $templateCache.put('templateId.html', 'This is the content of the template');\n * });\n * ```\n *\n * To retrieve the template later, simply use it in your HTML:\n * ```html\n * <div ng-include=\" 'templateId.html' \"></div>\n * ```\n *\n * or get it via Javascript:\n * ```js\n * $templateCache.get('templateId.html')\n * ```\n *\n * See {@link ng.$cacheFactory $cacheFactory}.\n *\n */\nfunction $TemplateCacheProvider() {\n  this.$get = ['$cacheFactory', function($cacheFactory) {\n    return $cacheFactory('templates');\n  }];\n}\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *     Any commits to this file should be reviewed with security in mind.  *\n *   Changes to this file can potentially create security vulnerabilities. *\n *          An approval from 2 Core members with history of modifying      *\n *                         this file is required.                          *\n *                                                                         *\n *  Does the change somehow allow for arbitrary javascript to be executed? *\n *    Or allows for someone to change the prototype of built-in objects?   *\n *     Or gives undesired access to variables likes document or window?    *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\n/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE!\n *\n * DOM-related variables:\n *\n * - \"node\" - DOM Node\n * - \"element\" - DOM Element or Node\n * - \"$node\" or \"$element\" - jqLite-wrapped node or element\n *\n *\n * Compiler related stuff:\n *\n * - \"linkFn\" - linking fn of a single directive\n * - \"nodeLinkFn\" - function that aggregates all linking fns for a particular node\n * - \"childLinkFn\" -  function that aggregates all linking fns for child nodes of a particular node\n * - \"compositeLinkFn\" - function that aggregates all linking fns for a compilation root (nodeList)\n */\n\n\n/**\n * @ngdoc service\n * @name $compile\n * @kind function\n *\n * @description\n * Compiles an HTML string or DOM into a template and produces a template function, which\n * can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together.\n *\n * The compilation is a process of walking the DOM tree and matching DOM elements to\n * {@link ng.$compileProvider#directive directives}.\n *\n * <div class=\"alert alert-warning\">\n * **Note:** This document is an in-depth reference of all directive options.\n * For a gentle introduction to directives with examples of common use cases,\n * see the {@link guide/directive directive guide}.\n * </div>\n *\n * ## Comprehensive Directive API\n *\n * There are many different options for a directive.\n *\n * The difference resides in the return value of the factory function.\n * You can either return a \"Directive Definition Object\" (see below) that defines the directive properties,\n * or just the `postLink` function (all other properties will have the default values).\n *\n * <div class=\"alert alert-success\">\n * **Best Practice:** It's recommended to use the \"directive definition object\" form.\n * </div>\n *\n * Here's an example directive declared with a Directive Definition Object:\n *\n * ```js\n *   var myModule = angular.module(...);\n *\n *   myModule.directive('directiveName', function factory(injectables) {\n *     var directiveDefinitionObject = {\n *       priority: 0,\n *       template: '<div></div>', // or // function(tElement, tAttrs) { ... },\n *       // or\n *       // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },\n *       transclude: false,\n *       restrict: 'A',\n *       templateNamespace: 'html',\n *       scope: false,\n *       controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },\n *       controllerAs: 'stringIdentifier',\n *       bindToController: false,\n *       require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'],\n *       compile: function compile(tElement, tAttrs, transclude) {\n *         return {\n *           pre: function preLink(scope, iElement, iAttrs, controller) { ... },\n *           post: function postLink(scope, iElement, iAttrs, controller) { ... }\n *         }\n *         // or\n *         // return function postLink( ... ) { ... }\n *       },\n *       // or\n *       // link: {\n *       //  pre: function preLink(scope, iElement, iAttrs, controller) { ... },\n *       //  post: function postLink(scope, iElement, iAttrs, controller) { ... }\n *       // }\n *       // or\n *       // link: function postLink( ... ) { ... }\n *     };\n *     return directiveDefinitionObject;\n *   });\n * ```\n *\n * <div class=\"alert alert-warning\">\n * **Note:** Any unspecified options will use the default value. You can see the default values below.\n * </div>\n *\n * Therefore the above can be simplified as:\n *\n * ```js\n *   var myModule = angular.module(...);\n *\n *   myModule.directive('directiveName', function factory(injectables) {\n *     var directiveDefinitionObject = {\n *       link: function postLink(scope, iElement, iAttrs) { ... }\n *     };\n *     return directiveDefinitionObject;\n *     // or\n *     // return function postLink(scope, iElement, iAttrs) { ... }\n *   });\n * ```\n *\n *\n *\n * ### Directive Definition Object\n *\n * The directive definition object provides instructions to the {@link ng.$compile\n * compiler}. The attributes are:\n *\n * #### `multiElement`\n * When this property is set to true, the HTML compiler will collect DOM nodes between\n * nodes with the attributes `directive-name-start` and `directive-name-end`, and group them\n * together as the directive elements. It is recommended that this feature be used on directives\n * which are not strictly behavioral (such as {@link ngClick}), and which\n * do not manipulate or replace child nodes (such as {@link ngInclude}).\n *\n * #### `priority`\n * When there are multiple directives defined on a single DOM element, sometimes it\n * is necessary to specify the order in which the directives are applied. The `priority` is used\n * to sort the directives before their `compile` functions get called. Priority is defined as a\n * number. Directives with greater numerical `priority` are compiled first. Pre-link functions\n * are also run in priority order, but post-link functions are run in reverse order. The order\n * of directives with the same priority is undefined. The default priority is `0`.\n *\n * #### `terminal`\n * If set to true then the current `priority` will be the last set of directives\n * which will execute (any directives at the current priority will still execute\n * as the order of execution on same `priority` is undefined). Note that expressions\n * and other directives used in the directive's template will also be excluded from execution.\n *\n * #### `scope`\n * The scope property can be `true`, an object or a falsy value:\n *\n * * **falsy:** No scope will be created for the directive. The directive will use its parent's scope.\n *\n * * **`true`:** A new child scope that prototypically inherits from its parent will be created for\n * the directive's element. If multiple directives on the same element request a new scope,\n * only one new scope is created. The new scope rule does not apply for the root of the template\n * since the root of the template always gets a new scope.\n *\n * * **`{...}` (an object hash):** A new \"isolate\" scope is created for the directive's element. The\n * 'isolate' scope differs from normal scope in that it does not prototypically inherit from its parent\n * scope. This is useful when creating reusable components, which should not accidentally read or modify\n * data in the parent scope.\n *\n * The 'isolate' scope object hash defines a set of local scope properties derived from attributes on the\n * directive's element. These local properties are useful for aliasing values for templates. The keys in\n * the object hash map to the name of the property on the isolate scope; the values define how the property\n * is bound to the parent scope, via matching attributes on the directive's element:\n *\n * * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is\n *   always a string since DOM attributes are strings. If no `attr` name is specified then the\n *   attribute name is assumed to be the same as the local name. Given `<my-component\n *   my-attr=\"hello {{name}}\">` and the isolate scope definition `scope: { localName:'@myAttr' }`,\n *   the directive's scope property `localName` will reflect the interpolated value of `hello\n *   {{name}}`. As the `name` attribute changes so will the `localName` property on the directive's\n *   scope. The `name` is read from the parent scope (not the directive's scope).\n *\n * * `=` or `=attr` - set up a bidirectional binding between a local scope property and an expression\n *   passed via the attribute `attr`. The expression is evaluated in the context of the parent scope.\n *   If no `attr` name is specified then the attribute name is assumed to be the same as the local\n *   name. Given `<my-component my-attr=\"parentModel\">` and the isolate scope definition `scope: {\n *   localModel: '=myAttr' }`, the property `localModel` on the directive's scope will reflect the\n *   value of `parentModel` on the parent scope. Changes to `parentModel` will be reflected in\n *   `localModel` and vice versa. Optional attributes should be marked as such with a question mark:\n *   `=?` or `=?attr`. If the binding expression is non-assignable, or if the attribute isn't\n *   optional and doesn't exist, an exception ({@link error/$compile/nonassign `$compile:nonassign`})\n *   will be thrown upon discovering changes to the local value, since it will be impossible to sync\n *   them back to the parent scope. By default, the {@link ng.$rootScope.Scope#$watch `$watch`}\n *   method is used for tracking changes, and the equality check is based on object identity.\n *   However, if an object literal or an array literal is passed as the binding expression, the\n *   equality check is done by value (using the {@link angular.equals} function). It's also possible\n *   to watch the evaluated value shallowly with {@link ng.$rootScope.Scope#$watchCollection\n *   `$watchCollection`}: use `=*` or `=*attr` (`=*?` or `=*?attr` if the attribute is optional).\n *\n  * * `<` or `<attr` - set up a one-way (one-directional) binding between a local scope property and an\n *   expression passed via the attribute `attr`. The expression is evaluated in the context of the\n *   parent scope. If no `attr` name is specified then the attribute name is assumed to be the same as the\n *   local name. You can also make the binding optional by adding `?`: `<?` or `<?attr`.\n *\n *   For example, given `<my-component my-attr=\"parentModel\">` and directive definition of\n *   `scope: { localModel:'<myAttr' }`, then the isolated scope property `localModel` will reflect the\n *   value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected\n *   in `localModel`, but changes in `localModel` will not reflect in `parentModel`. There are however\n *   two caveats:\n *     1. one-way binding does not copy the value from the parent to the isolate scope, it simply\n *     sets the same value. That means if your bound value is an object, changes to its properties\n *     in the isolated scope will be reflected in the parent scope (because both reference the same object).\n *     2. one-way binding watches changes to the **identity** of the parent value. That means the\n *     {@link ng.$rootScope.Scope#$watch `$watch`} on the parent value only fires if the reference\n *     to the value has changed. In most cases, this should not be of concern, but can be important\n *     to know if you one-way bind to an object, and then replace that object in the isolated scope.\n *     If you now change a property of the object in your parent scope, the change will not be\n *     propagated to the isolated scope, because the identity of the object on the parent scope\n *     has not changed. Instead you must assign a new object.\n *\n *   One-way binding is useful if you do not plan to propagate changes to your isolated scope bindings\n *   back to the parent. However, it does not make this completely impossible.\n *\n * * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. If\n *   no `attr` name is specified then the attribute name is assumed to be the same as the local name.\n *   Given `<my-component my-attr=\"count = count + value\">` and the isolate scope definition `scope: {\n *   localFn:'&myAttr' }`, the isolate scope property `localFn` will point to a function wrapper for\n *   the `count = count + value` expression. Often it's desirable to pass data from the isolated scope\n *   via an expression to the parent scope. This can be done by passing a map of local variable names\n *   and values into the expression wrapper fn. For example, if the expression is `increment(amount)`\n *   then we can specify the amount value by calling the `localFn` as `localFn({amount: 22})`.\n *\n * In general it's possible to apply more than one directive to one element, but there might be limitations\n * depending on the type of scope required by the directives. The following points will help explain these limitations.\n * For simplicity only two directives are taken into account, but it is also applicable for several directives:\n *\n * * **no scope** + **no scope** => Two directives which don't require their own scope will use their parent's scope\n * * **child scope** + **no scope** =>  Both directives will share one single child scope\n * * **child scope** + **child scope** =>  Both directives will share one single child scope\n * * **isolated scope** + **no scope** =>  The isolated directive will use it's own created isolated scope. The other directive will use\n * its parent's scope\n * * **isolated scope** + **child scope** =>  **Won't work!** Only one scope can be related to one element. Therefore these directives cannot\n * be applied to the same element.\n * * **isolated scope** + **isolated scope**  =>  **Won't work!** Only one scope can be related to one element. Therefore these directives\n * cannot be applied to the same element.\n *\n *\n * #### `bindToController`\n * This property is used to bind scope properties directly to the controller. It can be either\n * `true` or an object hash with the same format as the `scope` property. Additionally, a controller\n * alias must be set, either by using `controllerAs: 'myAlias'` or by specifying the alias in the controller\n * definition: `controller: 'myCtrl as myAlias'`.\n *\n * When an isolate scope is used for a directive (see above), `bindToController: true` will\n * allow a component to have its properties bound to the controller, rather than to scope.\n *\n * After the controller is instantiated, the initial values of the isolate scope bindings will be bound to the controller\n * properties. You can access these bindings once they have been initialized by providing a controller method called\n * `$onInit`, which is called after all the controllers on an element have been constructed and had their bindings\n * initialized.\n *\n * <div class=\"alert alert-warning\">\n * **Deprecation warning:** although bindings for non-ES6 class controllers are currently\n * bound to `this` before the controller constructor is called, this use is now deprecated. Please place initialization\n * code that relies upon bindings inside a `$onInit` method on the controller, instead.\n * </div>\n *\n * It is also possible to set `bindToController` to an object hash with the same format as the `scope` property.\n * This will set up the scope bindings to the controller directly. Note that `scope` can still be used\n * to define which kind of scope is created. By default, no scope is created. Use `scope: {}` to create an isolate\n * scope (useful for component directives).\n *\n * If both `bindToController` and `scope` are defined and have object hashes, `bindToController` overrides `scope`.\n *\n *\n * #### `controller`\n * Controller constructor function. The controller is instantiated before the\n * pre-linking phase and can be accessed by other directives (see\n * `require` attribute). This allows the directives to communicate with each other and augment\n * each other's behavior. The controller is injectable (and supports bracket notation) with the following locals:\n *\n * * `$scope` - Current scope associated with the element\n * * `$element` - Current element\n * * `$attrs` - Current attributes object for the element\n * * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope:\n *   `function([scope], cloneLinkingFn, futureParentElement, slotName)`:\n *    * `scope`: (optional) override the scope.\n *    * `cloneLinkingFn`: (optional) argument to create clones of the original transcluded content.\n *    * `futureParentElement` (optional):\n *        * defines the parent to which the `cloneLinkingFn` will add the cloned elements.\n *        * default: `$element.parent()` resp. `$element` for `transclude:'element'` resp. `transclude:true`.\n *        * only needed for transcludes that are allowed to contain non html elements (e.g. SVG elements)\n *          and when the `cloneLinkinFn` is passed,\n *          as those elements need to created and cloned in a special way when they are defined outside their\n *          usual containers (e.g. like `<svg>`).\n *        * See also the `directive.templateNamespace` property.\n *    * `slotName`: (optional) the name of the slot to transclude. If falsy (e.g. `null`, `undefined` or `''`)\n *      then the default translusion is provided.\n *    The `$transclude` function also has a method on it, `$transclude.isSlotFilled(slotName)`, which returns\n *    `true` if the specified slot contains content (i.e. one or more DOM nodes).\n *\n * The controller can provide the following methods that act as life-cycle hooks:\n * * `$onInit()` - Called on each controller after all the controllers on an element have been constructed and\n *   had their bindings initialized (and before the pre &amp; post linking functions for the directives on\n *   this element). This is a good place to put initialization code for your controller.\n * * `$onChanges(changesObj)` - Called whenever one-way (`<`) or interpolation (`@`) bindings are updated. The\n *   `changesObj` is a hash whose keys are the names of the bound properties that have changed, and the values are an\n *   object of the form `{ currentValue, previousValue, isFirstChange() }`. Use this hook to trigger updates within a\n *   component such as cloning the bound value to prevent accidental mutation of the outer value.\n * * `$onDestroy()` - Called on a controller when its containing scope is destroyed. Use this hook for releasing\n *   external resources, watches and event handlers. Note that components have their `$onDestroy()` hooks called in\n *   the same order as the `$scope.$broadcast` events are triggered, which is top down. This means that parent\n *   components will have their `$onDestroy()` hook called before child components.\n * * `$postLink()` - Called after this controller's element and its children have been linked. Similar to the post-link\n *   function this hook can be used to set up DOM event handlers and do direct DOM manipulation.\n *   Note that child elements that contain `templateUrl` directives will not have been compiled and linked since\n *   they are waiting for their template to load asynchronously and their own compilation and linking has been\n *   suspended until that occurs.\n *\n *\n * #### `require`\n * Require another directive and inject its controller as the fourth argument to the linking function. The\n * `require` property can be a string, an array or an object:\n * * a **string** containing the name of the directive to pass to the linking function\n * * an **array** containing the names of directives to pass to the linking function. The argument passed to the\n * linking function will be an array of controllers in the same order as the names in the `require` property\n * * an **object** whose property values are the names of the directives to pass to the linking function. The argument\n * passed to the linking function will also be an object with matching keys, whose values will hold the corresponding\n * controllers.\n *\n * If the `require` property is an object and `bindToController` is truthy, then the required controllers are\n * bound to the controller using the keys of the `require` property. This binding occurs after all the controllers\n * have been constructed but before `$onInit` is called.\n * See the {@link $compileProvider#component} helper for an example of how this can be used.\n *\n * If no such required directive(s) can be found, or if the directive does not have a controller, then an error is\n * raised (unless no link function is specified and the required controllers are not being bound to the directive\n * controller, in which case error checking is skipped). The name can be prefixed with:\n *\n * * (no prefix) - Locate the required controller on the current element. Throw an error if not found.\n * * `?` - Attempt to locate the required controller or pass `null` to the `link` fn if not found.\n * * `^` - Locate the required controller by searching the element and its parents. Throw an error if not found.\n * * `^^` - Locate the required controller by searching the element's parents. Throw an error if not found.\n * * `?^` - Attempt to locate the required controller by searching the element and its parents or pass\n *   `null` to the `link` fn if not found.\n * * `?^^` - Attempt to locate the required controller by searching the element's parents, or pass\n *   `null` to the `link` fn if not found.\n *\n *\n * #### `controllerAs`\n * Identifier name for a reference to the controller in the directive's scope.\n * This allows the controller to be referenced from the directive template. This is especially\n * useful when a directive is used as component, i.e. with an `isolate` scope. It's also possible\n * to use it in a directive without an `isolate` / `new` scope, but you need to be aware that the\n * `controllerAs` reference might overwrite a property that already exists on the parent scope.\n *\n *\n * #### `restrict`\n * String of subset of `EACM` which restricts the directive to a specific directive\n * declaration style. If omitted, the defaults (elements and attributes) are used.\n *\n * * `E` - Element name (default): `<my-directive></my-directive>`\n * * `A` - Attribute (default): `<div my-directive=\"exp\"></div>`\n * * `C` - Class: `<div class=\"my-directive: exp;\"></div>`\n * * `M` - Comment: `<!-- directive: my-directive exp -->`\n *\n *\n * #### `templateNamespace`\n * String representing the document type used by the markup in the template.\n * AngularJS needs this information as those elements need to be created and cloned\n * in a special way when they are defined outside their usual containers like `<svg>` and `<math>`.\n *\n * * `html` - All root nodes in the template are HTML. Root nodes may also be\n *   top-level elements such as `<svg>` or `<math>`.\n * * `svg` - The root nodes in the template are SVG elements (excluding `<math>`).\n * * `math` - The root nodes in the template are MathML elements (excluding `<svg>`).\n *\n * If no `templateNamespace` is specified, then the namespace is considered to be `html`.\n *\n * #### `template`\n * HTML markup that may:\n * * Replace the contents of the directive's element (default).\n * * Replace the directive's element itself (if `replace` is true - DEPRECATED).\n * * Wrap the contents of the directive's element (if `transclude` is true).\n *\n * Value may be:\n *\n * * A string. For example `<div red-on-hover>{{delete_str}}</div>`.\n * * A function which takes two arguments `tElement` and `tAttrs` (described in the `compile`\n *   function api below) and returns a string value.\n *\n *\n * #### `templateUrl`\n * This is similar to `template` but the template is loaded from the specified URL, asynchronously.\n *\n * Because template loading is asynchronous the compiler will suspend compilation of directives on that element\n * for later when the template has been resolved.  In the meantime it will continue to compile and link\n * sibling and parent elements as though this element had not contained any directives.\n *\n * The compiler does not suspend the entire compilation to wait for templates to be loaded because this\n * would result in the whole app \"stalling\" until all templates are loaded asynchronously - even in the\n * case when only one deeply nested directive has `templateUrl`.\n *\n * Template loading is asynchronous even if the template has been preloaded into the {@link $templateCache}\n *\n * You can specify `templateUrl` as a string representing the URL or as a function which takes two\n * arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns\n * a string value representing the url.  In either case, the template URL is passed through {@link\n * $sce#getTrustedResourceUrl $sce.getTrustedResourceUrl}.\n *\n *\n * #### `replace` ([*DEPRECATED*!], will be removed in next major release - i.e. v2.0)\n * specify what the template should replace. Defaults to `false`.\n *\n * * `true` - the template will replace the directive's element.\n * * `false` - the template will replace the contents of the directive's element.\n *\n * The replacement process migrates all of the attributes / classes from the old element to the new\n * one. See the {@link guide/directive#template-expanding-directive\n * Directives Guide} for an example.\n *\n * There are very few scenarios where element replacement is required for the application function,\n * the main one being reusable custom components that are used within SVG contexts\n * (because SVG doesn't work with custom elements in the DOM tree).\n *\n * #### `transclude`\n * Extract the contents of the element where the directive appears and make it available to the directive.\n * The contents are compiled and provided to the directive as a **transclusion function**. See the\n * {@link $compile#transclusion Transclusion} section below.\n *\n *\n * #### `compile`\n *\n * ```js\n *   function compile(tElement, tAttrs, transclude) { ... }\n * ```\n *\n * The compile function deals with transforming the template DOM. Since most directives do not do\n * template transformation, it is not used often. The compile function takes the following arguments:\n *\n *   * `tElement` - template element - The element where the directive has been declared. It is\n *     safe to do template transformation on the element and child elements only.\n *\n *   * `tAttrs` - template attributes - Normalized list of attributes declared on this element shared\n *     between all directive compile functions.\n *\n *   * `transclude` -  [*DEPRECATED*!] A transclude linking function: `function(scope, cloneLinkingFn)`\n *\n * <div class=\"alert alert-warning\">\n * **Note:** The template instance and the link instance may be different objects if the template has\n * been cloned. For this reason it is **not** safe to do anything other than DOM transformations that\n * apply to all cloned DOM nodes within the compile function. Specifically, DOM listener registration\n * should be done in a linking function rather than in a compile function.\n * </div>\n\n * <div class=\"alert alert-warning\">\n * **Note:** The compile function cannot handle directives that recursively use themselves in their\n * own templates or compile functions. Compiling these directives results in an infinite loop and\n * stack overflow errors.\n *\n * This can be avoided by manually using $compile in the postLink function to imperatively compile\n * a directive's template instead of relying on automatic template compilation via `template` or\n * `templateUrl` declaration or manual compilation inside the compile function.\n * </div>\n *\n * <div class=\"alert alert-danger\">\n * **Note:** The `transclude` function that is passed to the compile function is deprecated, as it\n *   e.g. does not know about the right outer scope. Please use the transclude function that is passed\n *   to the link function instead.\n * </div>\n\n * A compile function can have a return value which can be either a function or an object.\n *\n * * returning a (post-link) function - is equivalent to registering the linking function via the\n *   `link` property of the config object when the compile function is empty.\n *\n * * returning an object with function(s) registered via `pre` and `post` properties - allows you to\n *   control when a linking function should be called during the linking phase. See info about\n *   pre-linking and post-linking functions below.\n *\n *\n * #### `link`\n * This property is used only if the `compile` property is not defined.\n *\n * ```js\n *   function link(scope, iElement, iAttrs, controller, transcludeFn) { ... }\n * ```\n *\n * The link function is responsible for registering DOM listeners as well as updating the DOM. It is\n * executed after the template has been cloned. This is where most of the directive logic will be\n * put.\n *\n *   * `scope` - {@link ng.$rootScope.Scope Scope} - The scope to be used by the\n *     directive for registering {@link ng.$rootScope.Scope#$watch watches}.\n *\n *   * `iElement` - instance element - The element where the directive is to be used. It is safe to\n *     manipulate the children of the element only in `postLink` function since the children have\n *     already been linked.\n *\n *   * `iAttrs` - instance attributes - Normalized list of attributes declared on this element shared\n *     between all directive linking functions.\n *\n *   * `controller` - the directive's required controller instance(s) - Instances are shared\n *     among all directives, which allows the directives to use the controllers as a communication\n *     channel. The exact value depends on the directive's `require` property:\n *       * no controller(s) required: the directive's own controller, or `undefined` if it doesn't have one\n *       * `string`: the controller instance\n *       * `array`: array of controller instances\n *\n *     If a required controller cannot be found, and it is optional, the instance is `null`,\n *     otherwise the {@link error:$compile:ctreq Missing Required Controller} error is thrown.\n *\n *     Note that you can also require the directive's own controller - it will be made available like\n *     any other controller.\n *\n *   * `transcludeFn` - A transclude linking function pre-bound to the correct transclusion scope.\n *     This is the same as the `$transclude`\n *     parameter of directive controllers, see there for details.\n *     `function([scope], cloneLinkingFn, futureParentElement)`.\n *\n * #### Pre-linking function\n *\n * Executed before the child elements are linked. Not safe to do DOM transformation since the\n * compiler linking function will fail to locate the correct elements for linking.\n *\n * #### Post-linking function\n *\n * Executed after the child elements are linked.\n *\n * Note that child elements that contain `templateUrl` directives will not have been compiled\n * and linked since they are waiting for their template to load asynchronously and their own\n * compilation and linking has been suspended until that occurs.\n *\n * It is safe to do DOM transformation in the post-linking function on elements that are not waiting\n * for their async templates to be resolved.\n *\n *\n * ### Transclusion\n *\n * Transclusion is the process of extracting a collection of DOM elements from one part of the DOM and\n * copying them to another part of the DOM, while maintaining their connection to the original AngularJS\n * scope from where they were taken.\n *\n * Transclusion is used (often with {@link ngTransclude}) to insert the\n * original contents of a directive's element into a specified place in the template of the directive.\n * The benefit of transclusion, over simply moving the DOM elements manually, is that the transcluded\n * content has access to the properties on the scope from which it was taken, even if the directive\n * has isolated scope.\n * See the {@link guide/directive#creating-a-directive-that-wraps-other-elements Directives Guide}.\n *\n * This makes it possible for the widget to have private state for its template, while the transcluded\n * content has access to its originating scope.\n *\n * <div class=\"alert alert-warning\">\n * **Note:** When testing an element transclude directive you must not place the directive at the root of the\n * DOM fragment that is being compiled. See {@link guide/unit-testing#testing-transclusion-directives\n * Testing Transclusion Directives}.\n * </div>\n *\n * There are three kinds of transclusion depending upon whether you want to transclude just the contents of the\n * directive's element, the entire element or multiple parts of the element contents:\n *\n * * `true` - transclude the content (i.e. the child nodes) of the directive's element.\n * * `'element'` - transclude the whole of the directive's element including any directives on this\n *   element that defined at a lower priority than this directive. When used, the `template`\n *   property is ignored.\n * * **`{...}` (an object hash):** - map elements of the content onto transclusion \"slots\" in the template.\n *\n * **Mult-slot transclusion** is declared by providing an object for the `transclude` property.\n *\n * This object is a map where the keys are the name of the slot to fill and the value is an element selector\n * used to match the HTML to the slot. The element selector should be in normalized form (e.g. `myElement`)\n * and will match the standard element variants (e.g. `my-element`, `my:element`, `data-my-element`, etc).\n *\n * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}\n *\n * If the element selector is prefixed with a `?` then that slot is optional.\n *\n * For example, the transclude object `{ slotA: '?myCustomElement' }` maps `<my-custom-element>` elements to\n * the `slotA` slot, which can be accessed via the `$transclude` function or via the {@link ngTransclude} directive.\n *\n * Slots that are not marked as optional (`?`) will trigger a compile time error if there are no matching elements\n * in the transclude content. If you wish to know if an optional slot was filled with content, then you can call\n * `$transclude.isSlotFilled(slotName)` on the transclude function passed to the directive's link function and\n * injectable into the directive's controller.\n *\n *\n * #### Transclusion Functions\n *\n * When a directive requests transclusion, the compiler extracts its contents and provides a **transclusion\n * function** to the directive's `link` function and `controller`. This transclusion function is a special\n * **linking function** that will return the compiled contents linked to a new transclusion scope.\n *\n * <div class=\"alert alert-info\">\n * If you are just using {@link ngTransclude} then you don't need to worry about this function, since\n * ngTransclude will deal with it for us.\n * </div>\n *\n * If you want to manually control the insertion and removal of the transcluded content in your directive\n * then you must use this transclude function. When you call a transclude function it returns a a jqLite/JQuery\n * object that contains the compiled DOM, which is linked to the correct transclusion scope.\n *\n * When you call a transclusion function you can pass in a **clone attach function**. This function accepts\n * two parameters, `function(clone, scope) { ... }`, where the `clone` is a fresh compiled copy of your transcluded\n * content and the `scope` is the newly created transclusion scope, to which the clone is bound.\n *\n * <div class=\"alert alert-info\">\n * **Best Practice**: Always provide a `cloneFn` (clone attach function) when you call a transclude function\n * since you then get a fresh clone of the original DOM and also have access to the new transclusion scope.\n * </div>\n *\n * It is normal practice to attach your transcluded content (`clone`) to the DOM inside your **clone\n * attach function**:\n *\n * ```js\n * var transcludedContent, transclusionScope;\n *\n * $transclude(function(clone, scope) {\n *   element.append(clone);\n *   transcludedContent = clone;\n *   transclusionScope = scope;\n * });\n * ```\n *\n * Later, if you want to remove the transcluded content from your DOM then you should also destroy the\n * associated transclusion scope:\n *\n * ```js\n * transcludedContent.remove();\n * transclusionScope.$destroy();\n * ```\n *\n * <div class=\"alert alert-info\">\n * **Best Practice**: if you intend to add and remove transcluded content manually in your directive\n * (by calling the transclude function to get the DOM and calling `element.remove()` to remove it),\n * then you are also responsible for calling `$destroy` on the transclusion scope.\n * </div>\n *\n * The built-in DOM manipulation directives, such as {@link ngIf}, {@link ngSwitch} and {@link ngRepeat}\n * automatically destroy their transcluded clones as necessary so you do not need to worry about this if\n * you are simply using {@link ngTransclude} to inject the transclusion into your directive.\n *\n *\n * #### Transclusion Scopes\n *\n * When you call a transclude function it returns a DOM fragment that is pre-bound to a **transclusion\n * scope**. This scope is special, in that it is a child of the directive's scope (and so gets destroyed\n * when the directive's scope gets destroyed) but it inherits the properties of the scope from which it\n * was taken.\n *\n * For example consider a directive that uses transclusion and isolated scope. The DOM hierarchy might look\n * like this:\n *\n * ```html\n * <div ng-app>\n *   <div isolate>\n *     <div transclusion>\n *     </div>\n *   </div>\n * </div>\n * ```\n *\n * The `$parent` scope hierarchy will look like this:\n *\n   ```\n   - $rootScope\n     - isolate\n       - transclusion\n   ```\n *\n * but the scopes will inherit prototypically from different scopes to their `$parent`.\n *\n   ```\n   - $rootScope\n     - transclusion\n   - isolate\n   ```\n *\n *\n * ### Attributes\n *\n * The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the\n * `link()` or `compile()` functions. It has a variety of uses.\n *\n * * *Accessing normalized attribute names:* Directives like 'ngBind' can be expressed in many ways:\n *   'ng:bind', `data-ng-bind`, or 'x-ng-bind'. The attributes object allows for normalized access\n *   to the attributes.\n *\n * * *Directive inter-communication:* All directives share the same instance of the attributes\n *   object which allows the directives to use the attributes object as inter directive\n *   communication.\n *\n * * *Supports interpolation:* Interpolation attributes are assigned to the attribute object\n *   allowing other directives to read the interpolated value.\n *\n * * *Observing interpolated attributes:* Use `$observe` to observe the value changes of attributes\n *   that contain interpolation (e.g. `src=\"{{bar}}\"`). Not only is this very efficient but it's also\n *   the only way to easily get the actual value because during the linking phase the interpolation\n *   hasn't been evaluated yet and so the value is at this time set to `undefined`.\n *\n * ```js\n * function linkingFn(scope, elm, attrs, ctrl) {\n *   // get the attribute value\n *   console.log(attrs.ngModel);\n *\n *   // change the attribute\n *   attrs.$set('ngModel', 'new value');\n *\n *   // observe changes to interpolated attribute\n *   attrs.$observe('ngModel', function(value) {\n *     console.log('ngModel has changed value to ' + value);\n *   });\n * }\n * ```\n *\n * ## Example\n *\n * <div class=\"alert alert-warning\">\n * **Note**: Typically directives are registered with `module.directive`. The example below is\n * to illustrate how `$compile` works.\n * </div>\n *\n <example module=\"compileExample\">\n   <file name=\"index.html\">\n    <script>\n      angular.module('compileExample', [], function($compileProvider) {\n        // configure new 'compile' directive by passing a directive\n        // factory function. The factory function injects the '$compile'\n        $compileProvider.directive('compile', function($compile) {\n          // directive factory creates a link function\n          return function(scope, element, attrs) {\n            scope.$watch(\n              function(scope) {\n                 // watch the 'compile' expression for changes\n                return scope.$eval(attrs.compile);\n              },\n              function(value) {\n                // when the 'compile' expression changes\n                // assign it into the current DOM\n                element.html(value);\n\n                // compile the new DOM and link it to the current\n                // scope.\n                // NOTE: we only compile .childNodes so that\n                // we don't get into infinite loop compiling ourselves\n                $compile(element.contents())(scope);\n              }\n            );\n          };\n        });\n      })\n      .controller('GreeterController', ['$scope', function($scope) {\n        $scope.name = 'Angular';\n        $scope.html = 'Hello {{name}}';\n      }]);\n    </script>\n    <div ng-controller=\"GreeterController\">\n      <input ng-model=\"name\"> <br/>\n      <textarea ng-model=\"html\"></textarea> <br/>\n      <div compile=\"html\"></div>\n    </div>\n   </file>\n   <file name=\"protractor.js\" type=\"protractor\">\n     it('should auto compile', function() {\n       var textarea = $('textarea');\n       var output = $('div[compile]');\n       // The initial state reads 'Hello Angular'.\n       expect(output.getText()).toBe('Hello Angular');\n       textarea.clear();\n       textarea.sendKeys('{{name}}!');\n       expect(output.getText()).toBe('Angular!');\n     });\n   </file>\n </example>\n\n *\n *\n * @param {string|DOMElement} element Element or HTML string to compile into a template function.\n * @param {function(angular.Scope, cloneAttachFn=)} transclude function available to directives - DEPRECATED.\n *\n * <div class=\"alert alert-danger\">\n * **Note:** Passing a `transclude` function to the $compile function is deprecated, as it\n *   e.g. will not use the right outer scope. Please pass the transclude function as a\n *   `parentBoundTranscludeFn` to the link function instead.\n * </div>\n *\n * @param {number} maxPriority only apply directives lower than given priority (Only effects the\n *                 root element(s), not their children)\n * @returns {function(scope, cloneAttachFn=, options=)} a link function which is used to bind template\n * (a DOM element/tree) to a scope. Where:\n *\n *  * `scope` - A {@link ng.$rootScope.Scope Scope} to bind to.\n *  * `cloneAttachFn` - If `cloneAttachFn` is provided, then the link function will clone the\n *  `template` and call the `cloneAttachFn` function allowing the caller to attach the\n *  cloned elements to the DOM document at the appropriate place. The `cloneAttachFn` is\n *  called as: <br/> `cloneAttachFn(clonedElement, scope)` where:\n *\n *      * `clonedElement` - is a clone of the original `element` passed into the compiler.\n *      * `scope` - is the current scope with which the linking function is working with.\n *\n *  * `options` - An optional object hash with linking options. If `options` is provided, then the following\n *  keys may be used to control linking behavior:\n *\n *      * `parentBoundTranscludeFn` - the transclude function made available to\n *        directives; if given, it will be passed through to the link functions of\n *        directives found in `element` during compilation.\n *      * `transcludeControllers` - an object hash with keys that map controller names\n *        to a hash with the key `instance`, which maps to the controller instance;\n *        if given, it will make the controllers available to directives on the compileNode:\n *        ```\n *        {\n *          parent: {\n *            instance: parentControllerInstance\n *          }\n *        }\n *        ```\n *      * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add\n *        the cloned elements; only needed for transcludes that are allowed to contain non html\n *        elements (e.g. SVG elements). See also the directive.controller property.\n *\n * Calling the linking function returns the element of the template. It is either the original\n * element passed in, or the clone of the element if the `cloneAttachFn` is provided.\n *\n * After linking the view is not updated until after a call to $digest which typically is done by\n * Angular automatically.\n *\n * If you need access to the bound view, there are two ways to do it:\n *\n * - If you are not asking the linking function to clone the template, create the DOM element(s)\n *   before you send them to the compiler and keep this reference around.\n *   ```js\n *     var element = $compile('<p>{{total}}</p>')(scope);\n *   ```\n *\n * - if on the other hand, you need the element to be cloned, the view reference from the original\n *   example would not point to the clone, but rather to the original template that was cloned. In\n *   this case, you can access the clone via the cloneAttachFn:\n *   ```js\n *     var templateElement = angular.element('<p>{{total}}</p>'),\n *         scope = ....;\n *\n *     var clonedElement = $compile(templateElement)(scope, function(clonedElement, scope) {\n *       //attach the clone to DOM document at the right place\n *     });\n *\n *     //now we have reference to the cloned DOM via `clonedElement`\n *   ```\n *\n *\n * For information on how the compiler works, see the\n * {@link guide/compiler Angular HTML Compiler} section of the Developer Guide.\n */\n\nvar $compileMinErr = minErr('$compile');\n\nfunction UNINITIALIZED_VALUE() {}\nvar _UNINITIALIZED_VALUE = new UNINITIALIZED_VALUE();\n\n/**\n * @ngdoc provider\n * @name $compileProvider\n *\n * @description\n */\n$CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider'];\nfunction $CompileProvider($provide, $$sanitizeUriProvider) {\n  var hasDirectives = {},\n      Suffix = 'Directive',\n      COMMENT_DIRECTIVE_REGEXP = /^\\s*directive\\:\\s*([\\w\\-]+)\\s+(.*)$/,\n      CLASS_DIRECTIVE_REGEXP = /(([\\w\\-]+)(?:\\:([^;]+))?;?)/,\n      ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'),\n      REQUIRE_PREFIX_REGEXP = /^(?:(\\^\\^?)?(\\?)?(\\^\\^?)?)?/;\n\n  // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes\n  // The assumption is that future DOM event attribute names will begin with\n  // 'on' and be composed of only English letters.\n  var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/;\n  var bindingCache = createMap();\n\n  function parseIsolateBindings(scope, directiveName, isController) {\n    var LOCAL_REGEXP = /^\\s*([@&<]|=(\\*?))(\\??)\\s*(\\w*)\\s*$/;\n\n    var bindings = createMap();\n\n    forEach(scope, function(definition, scopeName) {\n      if (definition in bindingCache) {\n        bindings[scopeName] = bindingCache[definition];\n        return;\n      }\n      var match = definition.match(LOCAL_REGEXP);\n\n      if (!match) {\n        throw $compileMinErr('iscp',\n            \"Invalid {3} for directive '{0}'.\" +\n            \" Definition: {... {1}: '{2}' ...}\",\n            directiveName, scopeName, definition,\n            (isController ? \"controller bindings definition\" :\n            \"isolate scope definition\"));\n      }\n\n      bindings[scopeName] = {\n        mode: match[1][0],\n        collection: match[2] === '*',\n        optional: match[3] === '?',\n        attrName: match[4] || scopeName\n      };\n      if (match[4]) {\n        bindingCache[definition] = bindings[scopeName];\n      }\n    });\n\n    return bindings;\n  }\n\n  function parseDirectiveBindings(directive, directiveName) {\n    var bindings = {\n      isolateScope: null,\n      bindToController: null\n    };\n    if (isObject(directive.scope)) {\n      if (directive.bindToController === true) {\n        bindings.bindToController = parseIsolateBindings(directive.scope,\n                                                         directiveName, true);\n        bindings.isolateScope = {};\n      } else {\n        bindings.isolateScope = parseIsolateBindings(directive.scope,\n                                                     directiveName, false);\n      }\n    }\n    if (isObject(directive.bindToController)) {\n      bindings.bindToController =\n          parseIsolateBindings(directive.bindToController, directiveName, true);\n    }\n    if (isObject(bindings.bindToController)) {\n      var controller = directive.controller;\n      var controllerAs = directive.controllerAs;\n      if (!controller) {\n        // There is no controller, there may or may not be a controllerAs property\n        throw $compileMinErr('noctrl',\n              \"Cannot bind to controller without directive '{0}'s controller.\",\n              directiveName);\n      } else if (!identifierForController(controller, controllerAs)) {\n        // There is a controller, but no identifier or controllerAs property\n        throw $compileMinErr('noident',\n              \"Cannot bind to controller without identifier for directive '{0}'.\",\n              directiveName);\n      }\n    }\n    return bindings;\n  }\n\n  function assertValidDirectiveName(name) {\n    var letter = name.charAt(0);\n    if (!letter || letter !== lowercase(letter)) {\n      throw $compileMinErr('baddir', \"Directive/Component name '{0}' is invalid. The first character must be a lowercase letter\", name);\n    }\n    if (name !== name.trim()) {\n      throw $compileMinErr('baddir',\n            \"Directive/Component name '{0}' is invalid. The name should not contain leading or trailing whitespaces\",\n            name);\n    }\n  }\n\n  /**\n   * @ngdoc method\n   * @name $compileProvider#directive\n   * @kind function\n   *\n   * @description\n   * Register a new directive with the compiler.\n   *\n   * @param {string|Object} name Name of the directive in camel-case (i.e. <code>ngBind</code> which\n   *    will match as <code>ng-bind</code>), or an object map of directives where the keys are the\n   *    names and the values are the factories.\n   * @param {Function|Array} directiveFactory An injectable directive factory function. See the\n   *    {@link guide/directive directive guide} and the {@link $compile compile API} for more info.\n   * @returns {ng.$compileProvider} Self for chaining.\n   */\n  this.directive = function registerDirective(name, directiveFactory) {\n    assertNotHasOwnProperty(name, 'directive');\n    if (isString(name)) {\n      assertValidDirectiveName(name);\n      assertArg(directiveFactory, 'directiveFactory');\n      if (!hasDirectives.hasOwnProperty(name)) {\n        hasDirectives[name] = [];\n        $provide.factory(name + Suffix, ['$injector', '$exceptionHandler',\n          function($injector, $exceptionHandler) {\n            var directives = [];\n            forEach(hasDirectives[name], function(directiveFactory, index) {\n              try {\n                var directive = $injector.invoke(directiveFactory);\n                if (isFunction(directive)) {\n                  directive = { compile: valueFn(directive) };\n                } else if (!directive.compile && directive.link) {\n                  directive.compile = valueFn(directive.link);\n                }\n                directive.priority = directive.priority || 0;\n                directive.index = index;\n                directive.name = directive.name || name;\n                directive.require = directive.require || (directive.controller && directive.name);\n                directive.restrict = directive.restrict || 'EA';\n                directive.$$moduleName = directiveFactory.$$moduleName;\n                directives.push(directive);\n              } catch (e) {\n                $exceptionHandler(e);\n              }\n            });\n            return directives;\n          }]);\n      }\n      hasDirectives[name].push(directiveFactory);\n    } else {\n      forEach(name, reverseParams(registerDirective));\n    }\n    return this;\n  };\n\n  /**\n   * @ngdoc method\n   * @name $compileProvider#component\n   * @module ng\n   * @param {string} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`)\n   * @param {Object} options Component definition object (a simplified\n   *    {@link ng.$compile#directive-definition-object directive definition object}),\n   *    with the following properties (all optional):\n   *\n   *    - `controller` – `{(string|function()=}` – controller constructor function that should be\n   *      associated with newly created scope or the name of a {@link ng.$compile#-controller-\n   *      registered controller} if passed as a string. An empty `noop` function by default.\n   *    - `controllerAs` – `{string=}` – identifier name for to reference the controller in the component's scope.\n   *      If present, the controller will be published to scope under the `controllerAs` name.\n   *      If not present, this will default to be `$ctrl`.\n   *    - `template` – `{string=|function()=}` – html template as a string or a function that\n   *      returns an html template as a string which should be used as the contents of this component.\n   *      Empty string by default.\n   *\n   *      If `template` is a function, then it is {@link auto.$injector#invoke injected} with\n   *      the following locals:\n   *\n   *      - `$element` - Current element\n   *      - `$attrs` - Current attributes object for the element\n   *\n   *    - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html\n   *      template that should be used  as the contents of this component.\n   *\n   *      If `templateUrl` is a function, then it is {@link auto.$injector#invoke injected} with\n   *      the following locals:\n   *\n   *      - `$element` - Current element\n   *      - `$attrs` - Current attributes object for the element\n   *\n   *    - `bindings` – `{object=}` – defines bindings between DOM attributes and component properties.\n   *      Component properties are always bound to the component controller and not to the scope.\n   *      See {@link ng.$compile#-bindtocontroller- `bindToController`}.\n   *    - `transclude` – `{boolean=}` – whether {@link $compile#transclusion content transclusion} is enabled.\n   *      Disabled by default.\n   *    - `require` - `{Object<string, string>=}` - requires the controllers of other directives and binds them to\n   *      this component's controller. The object keys specify the property names under which the required\n   *      controllers (object values) will be bound. See {@link ng.$compile#-require- `require`}.\n   *    - `$...` – additional properties to attach to the directive factory function and the controller\n   *      constructor function. (This is used by the component router to annotate)\n   *\n   * @returns {ng.$compileProvider} the compile provider itself, for chaining of function calls.\n   * @description\n   * Register a **component definition** with the compiler. This is a shorthand for registering a special\n   * type of directive, which represents a self-contained UI component in your application. Such components\n   * are always isolated (i.e. `scope: {}`) and are always restricted to elements (i.e. `restrict: 'E'`).\n   *\n   * Component definitions are very simple and do not require as much configuration as defining general\n   * directives. Component definitions usually consist only of a template and a controller backing it.\n   *\n   * In order to make the definition easier, components enforce best practices like use of `controllerAs`,\n   * `bindToController`. They always have **isolate scope** and are restricted to elements.\n   *\n   * Here are a few examples of how you would usually define components:\n   *\n   * ```js\n   *   var myMod = angular.module(...);\n   *   myMod.component('myComp', {\n   *     template: '<div>My name is {{$ctrl.name}}</div>',\n   *     controller: function() {\n   *       this.name = 'shahar';\n   *     }\n   *   });\n   *\n   *   myMod.component('myComp', {\n   *     template: '<div>My name is {{$ctrl.name}}</div>',\n   *     bindings: {name: '@'}\n   *   });\n   *\n   *   myMod.component('myComp', {\n   *     templateUrl: 'views/my-comp.html',\n   *     controller: 'MyCtrl',\n   *     controllerAs: 'ctrl',\n   *     bindings: {name: '@'}\n   *   });\n   *\n   * ```\n   * For more examples, and an in-depth guide, see the {@link guide/component component guide}.\n   *\n   * <br />\n   * See also {@link ng.$compileProvider#directive $compileProvider.directive()}.\n   */\n  this.component = function registerComponent(name, options) {\n    var controller = options.controller || function() {};\n\n    function factory($injector) {\n      function makeInjectable(fn) {\n        if (isFunction(fn) || isArray(fn)) {\n          return function(tElement, tAttrs) {\n            return $injector.invoke(fn, this, {$element: tElement, $attrs: tAttrs});\n          };\n        } else {\n          return fn;\n        }\n      }\n\n      var template = (!options.template && !options.templateUrl ? '' : options.template);\n      var ddo = {\n        controller: controller,\n        controllerAs: identifierForController(options.controller) || options.controllerAs || '$ctrl',\n        template: makeInjectable(template),\n        templateUrl: makeInjectable(options.templateUrl),\n        transclude: options.transclude,\n        scope: {},\n        bindToController: options.bindings || {},\n        restrict: 'E',\n        require: options.require\n      };\n\n      // Copy annotations (starting with $) over to the DDO\n      forEach(options, function(val, key) {\n        if (key.charAt(0) === '$') ddo[key] = val;\n      });\n\n      return ddo;\n    }\n\n    // TODO(pete) remove the following `forEach` before we release 1.6.0\n    // The component-router@0.2.0 looks for the annotations on the controller constructor\n    // Nothing in Angular looks for annotations on the factory function but we can't remove\n    // it from 1.5.x yet.\n\n    // Copy any annotation properties (starting with $) over to the factory and controller constructor functions\n    // These could be used by libraries such as the new component router\n    forEach(options, function(val, key) {\n      if (key.charAt(0) === '$') {\n        factory[key] = val;\n        // Don't try to copy over annotations to named controller\n        if (isFunction(controller)) controller[key] = val;\n      }\n    });\n\n    factory.$inject = ['$injector'];\n\n    return this.directive(name, factory);\n  };\n\n\n  /**\n   * @ngdoc method\n   * @name $compileProvider#aHrefSanitizationWhitelist\n   * @kind function\n   *\n   * @description\n   * Retrieves or overrides the default regular expression that is used for whitelisting of safe\n   * urls during a[href] sanitization.\n   *\n   * The sanitization is a security measure aimed at preventing XSS attacks via html links.\n   *\n   * Any url about to be assigned to a[href] via data-binding is first normalized and turned into\n   * an absolute url. Afterwards, the url is matched against the `aHrefSanitizationWhitelist`\n   * regular expression. If a match is found, the original url is written into the dom. Otherwise,\n   * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.\n   *\n   * @param {RegExp=} regexp New regexp to whitelist urls with.\n   * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for\n   *    chaining otherwise.\n   */\n  this.aHrefSanitizationWhitelist = function(regexp) {\n    if (isDefined(regexp)) {\n      $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp);\n      return this;\n    } else {\n      return $$sanitizeUriProvider.aHrefSanitizationWhitelist();\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @name $compileProvider#imgSrcSanitizationWhitelist\n   * @kind function\n   *\n   * @description\n   * Retrieves or overrides the default regular expression that is used for whitelisting of safe\n   * urls during img[src] sanitization.\n   *\n   * The sanitization is a security measure aimed at prevent XSS attacks via html links.\n   *\n   * Any url about to be assigned to img[src] via data-binding is first normalized and turned into\n   * an absolute url. Afterwards, the url is matched against the `imgSrcSanitizationWhitelist`\n   * regular expression. If a match is found, the original url is written into the dom. Otherwise,\n   * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.\n   *\n   * @param {RegExp=} regexp New regexp to whitelist urls with.\n   * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for\n   *    chaining otherwise.\n   */\n  this.imgSrcSanitizationWhitelist = function(regexp) {\n    if (isDefined(regexp)) {\n      $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp);\n      return this;\n    } else {\n      return $$sanitizeUriProvider.imgSrcSanitizationWhitelist();\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name  $compileProvider#debugInfoEnabled\n   *\n   * @param {boolean=} enabled update the debugInfoEnabled state if provided, otherwise just return the\n   * current debugInfoEnabled state\n   * @returns {*} current value if used as getter or itself (chaining) if used as setter\n   *\n   * @kind function\n   *\n   * @description\n   * Call this method to enable/disable various debug runtime information in the compiler such as adding\n   * binding information and a reference to the current scope on to DOM elements.\n   * If enabled, the compiler will add the following to DOM elements that have been bound to the scope\n   * * `ng-binding` CSS class\n   * * `$binding` data property containing an array of the binding expressions\n   *\n   * You may want to disable this in production for a significant performance boost. See\n   * {@link guide/production#disabling-debug-data Disabling Debug Data} for more.\n   *\n   * The default value is true.\n   */\n  var debugInfoEnabled = true;\n  this.debugInfoEnabled = function(enabled) {\n    if (isDefined(enabled)) {\n      debugInfoEnabled = enabled;\n      return this;\n    }\n    return debugInfoEnabled;\n  };\n\n\n  var TTL = 10;\n  /**\n   * @ngdoc method\n   * @name $compileProvider#onChangesTtl\n   * @description\n   *\n   * Sets the number of times `$onChanges` hooks can trigger new changes before giving up and\n   * assuming that the model is unstable.\n   *\n   * The current default is 10 iterations.\n   *\n   * In complex applications it's possible that dependencies between `$onChanges` hooks and bindings will result\n   * in several iterations of calls to these hooks. However if an application needs more than the default 10\n   * iterations to stabilize then you should investigate what is causing the model to continuously change during\n   * the `$onChanges` hook execution.\n   *\n   * Increasing the TTL could have performance implications, so you should not change it without proper justification.\n   *\n   * @param {number} limit The number of `$onChanges` hook iterations.\n   * @returns {number|object} the current limit (or `this` if called as a setter for chaining)\n   */\n  this.onChangesTtl = function(value) {\n    if (arguments.length) {\n      TTL = value;\n      return this;\n    }\n    return TTL;\n  };\n\n  this.$get = [\n            '$injector', '$interpolate', '$exceptionHandler', '$templateRequest', '$parse',\n            '$controller', '$rootScope', '$sce', '$animate', '$$sanitizeUri',\n    function($injector,   $interpolate,   $exceptionHandler,   $templateRequest,   $parse,\n             $controller,   $rootScope,   $sce,   $animate,   $$sanitizeUri) {\n\n    var SIMPLE_ATTR_NAME = /^\\w/;\n    var specialAttrHolder = window.document.createElement('div');\n\n\n\n    var onChangesTtl = TTL;\n    // The onChanges hooks should all be run together in a single digest\n    // When changes occur, the call to trigger their hooks will be added to this queue\n    var onChangesQueue;\n\n    // This function is called in a $$postDigest to trigger all the onChanges hooks in a single digest\n    function flushOnChangesQueue() {\n      try {\n        if (!(--onChangesTtl)) {\n          // We have hit the TTL limit so reset everything\n          onChangesQueue = undefined;\n          throw $compileMinErr('infchng', '{0} $onChanges() iterations reached. Aborting!\\n', TTL);\n        }\n        // We must run this hook in an apply since the $$postDigest runs outside apply\n        $rootScope.$apply(function() {\n          for (var i = 0, ii = onChangesQueue.length; i < ii; ++i) {\n            onChangesQueue[i]();\n          }\n          // Reset the queue to trigger a new schedule next time there is a change\n          onChangesQueue = undefined;\n        });\n      } finally {\n        onChangesTtl++;\n      }\n    }\n\n\n    function Attributes(element, attributesToCopy) {\n      if (attributesToCopy) {\n        var keys = Object.keys(attributesToCopy);\n        var i, l, key;\n\n        for (i = 0, l = keys.length; i < l; i++) {\n          key = keys[i];\n          this[key] = attributesToCopy[key];\n        }\n      } else {\n        this.$attr = {};\n      }\n\n      this.$$element = element;\n    }\n\n    Attributes.prototype = {\n      /**\n       * @ngdoc method\n       * @name $compile.directive.Attributes#$normalize\n       * @kind function\n       *\n       * @description\n       * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or\n       * `data-`) to its normalized, camelCase form.\n       *\n       * Also there is special case for Moz prefix starting with upper case letter.\n       *\n       * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}\n       *\n       * @param {string} name Name to normalize\n       */\n      $normalize: directiveNormalize,\n\n\n      /**\n       * @ngdoc method\n       * @name $compile.directive.Attributes#$addClass\n       * @kind function\n       *\n       * @description\n       * Adds the CSS class value specified by the classVal parameter to the element. If animations\n       * are enabled then an animation will be triggered for the class addition.\n       *\n       * @param {string} classVal The className value that will be added to the element\n       */\n      $addClass: function(classVal) {\n        if (classVal && classVal.length > 0) {\n          $animate.addClass(this.$$element, classVal);\n        }\n      },\n\n      /**\n       * @ngdoc method\n       * @name $compile.directive.Attributes#$removeClass\n       * @kind function\n       *\n       * @description\n       * Removes the CSS class value specified by the classVal parameter from the element. If\n       * animations are enabled then an animation will be triggered for the class removal.\n       *\n       * @param {string} classVal The className value that will be removed from the element\n       */\n      $removeClass: function(classVal) {\n        if (classVal && classVal.length > 0) {\n          $animate.removeClass(this.$$element, classVal);\n        }\n      },\n\n      /**\n       * @ngdoc method\n       * @name $compile.directive.Attributes#$updateClass\n       * @kind function\n       *\n       * @description\n       * Adds and removes the appropriate CSS class values to the element based on the difference\n       * between the new and old CSS class values (specified as newClasses and oldClasses).\n       *\n       * @param {string} newClasses The current CSS className value\n       * @param {string} oldClasses The former CSS className value\n       */\n      $updateClass: function(newClasses, oldClasses) {\n        var toAdd = tokenDifference(newClasses, oldClasses);\n        if (toAdd && toAdd.length) {\n          $animate.addClass(this.$$element, toAdd);\n        }\n\n        var toRemove = tokenDifference(oldClasses, newClasses);\n        if (toRemove && toRemove.length) {\n          $animate.removeClass(this.$$element, toRemove);\n        }\n      },\n\n      /**\n       * Set a normalized attribute on the element in a way such that all directives\n       * can share the attribute. This function properly handles boolean attributes.\n       * @param {string} key Normalized key. (ie ngAttribute)\n       * @param {string|boolean} value The value to set. If `null` attribute will be deleted.\n       * @param {boolean=} writeAttr If false, does not write the value to DOM element attribute.\n       *     Defaults to true.\n       * @param {string=} attrName Optional none normalized name. Defaults to key.\n       */\n      $set: function(key, value, writeAttr, attrName) {\n        // TODO: decide whether or not to throw an error if \"class\"\n        //is set through this function since it may cause $updateClass to\n        //become unstable.\n\n        var node = this.$$element[0],\n            booleanKey = getBooleanAttrName(node, key),\n            aliasedKey = getAliasedAttrName(key),\n            observer = key,\n            nodeName;\n\n        if (booleanKey) {\n          this.$$element.prop(key, value);\n          attrName = booleanKey;\n        } else if (aliasedKey) {\n          this[aliasedKey] = value;\n          observer = aliasedKey;\n        }\n\n        this[key] = value;\n\n        // translate normalized key to actual key\n        if (attrName) {\n          this.$attr[key] = attrName;\n        } else {\n          attrName = this.$attr[key];\n          if (!attrName) {\n            this.$attr[key] = attrName = snake_case(key, '-');\n          }\n        }\n\n        nodeName = nodeName_(this.$$element);\n\n        if ((nodeName === 'a' && (key === 'href' || key === 'xlinkHref')) ||\n            (nodeName === 'img' && key === 'src')) {\n          // sanitize a[href] and img[src] values\n          this[key] = value = $$sanitizeUri(value, key === 'src');\n        } else if (nodeName === 'img' && key === 'srcset') {\n          // sanitize img[srcset] values\n          var result = \"\";\n\n          // first check if there are spaces because it's not the same pattern\n          var trimmedSrcset = trim(value);\n          //                (   999x   ,|   999w   ,|   ,|,   )\n          var srcPattern = /(\\s+\\d+x\\s*,|\\s+\\d+w\\s*,|\\s+,|,\\s+)/;\n          var pattern = /\\s/.test(trimmedSrcset) ? srcPattern : /(,)/;\n\n          // split srcset into tuple of uri and descriptor except for the last item\n          var rawUris = trimmedSrcset.split(pattern);\n\n          // for each tuples\n          var nbrUrisWith2parts = Math.floor(rawUris.length / 2);\n          for (var i = 0; i < nbrUrisWith2parts; i++) {\n            var innerIdx = i * 2;\n            // sanitize the uri\n            result += $$sanitizeUri(trim(rawUris[innerIdx]), true);\n            // add the descriptor\n            result += (\" \" + trim(rawUris[innerIdx + 1]));\n          }\n\n          // split the last item into uri and descriptor\n          var lastTuple = trim(rawUris[i * 2]).split(/\\s/);\n\n          // sanitize the last uri\n          result += $$sanitizeUri(trim(lastTuple[0]), true);\n\n          // and add the last descriptor if any\n          if (lastTuple.length === 2) {\n            result += (\" \" + trim(lastTuple[1]));\n          }\n          this[key] = value = result;\n        }\n\n        if (writeAttr !== false) {\n          if (value === null || isUndefined(value)) {\n            this.$$element.removeAttr(attrName);\n          } else {\n            if (SIMPLE_ATTR_NAME.test(attrName)) {\n              this.$$element.attr(attrName, value);\n            } else {\n              setSpecialAttr(this.$$element[0], attrName, value);\n            }\n          }\n        }\n\n        // fire observers\n        var $$observers = this.$$observers;\n        $$observers && forEach($$observers[observer], function(fn) {\n          try {\n            fn(value);\n          } catch (e) {\n            $exceptionHandler(e);\n          }\n        });\n      },\n\n\n      /**\n       * @ngdoc method\n       * @name $compile.directive.Attributes#$observe\n       * @kind function\n       *\n       * @description\n       * Observes an interpolated attribute.\n       *\n       * The observer function will be invoked once during the next `$digest` following\n       * compilation. The observer is then invoked whenever the interpolated value\n       * changes.\n       *\n       * @param {string} key Normalized key. (ie ngAttribute) .\n       * @param {function(interpolatedValue)} fn Function that will be called whenever\n                the interpolated value of the attribute changes.\n       *        See the {@link guide/interpolation#how-text-and-attribute-bindings-work Interpolation\n       *        guide} for more info.\n       * @returns {function()} Returns a deregistration function for this observer.\n       */\n      $observe: function(key, fn) {\n        var attrs = this,\n            $$observers = (attrs.$$observers || (attrs.$$observers = createMap())),\n            listeners = ($$observers[key] || ($$observers[key] = []));\n\n        listeners.push(fn);\n        $rootScope.$evalAsync(function() {\n          if (!listeners.$$inter && attrs.hasOwnProperty(key) && !isUndefined(attrs[key])) {\n            // no one registered attribute interpolation function, so lets call it manually\n            fn(attrs[key]);\n          }\n        });\n\n        return function() {\n          arrayRemove(listeners, fn);\n        };\n      }\n    };\n\n    function setSpecialAttr(element, attrName, value) {\n      // Attributes names that do not start with letters (such as `(click)`) cannot be set using `setAttribute`\n      // so we have to jump through some hoops to get such an attribute\n      // https://github.com/angular/angular.js/pull/13318\n      specialAttrHolder.innerHTML = \"<span \" + attrName + \">\";\n      var attributes = specialAttrHolder.firstChild.attributes;\n      var attribute = attributes[0];\n      // We have to remove the attribute from its container element before we can add it to the destination element\n      attributes.removeNamedItem(attribute.name);\n      attribute.value = value;\n      element.attributes.setNamedItem(attribute);\n    }\n\n    function safeAddClass($element, className) {\n      try {\n        $element.addClass(className);\n      } catch (e) {\n        // ignore, since it means that we are trying to set class on\n        // SVG element, where class name is read-only.\n      }\n    }\n\n\n    var startSymbol = $interpolate.startSymbol(),\n        endSymbol = $interpolate.endSymbol(),\n        denormalizeTemplate = (startSymbol == '{{' && endSymbol  == '}}')\n            ? identity\n            : function denormalizeTemplate(template) {\n              return template.replace(/\\{\\{/g, startSymbol).replace(/}}/g, endSymbol);\n        },\n        NG_ATTR_BINDING = /^ngAttr[A-Z]/;\n    var MULTI_ELEMENT_DIR_RE = /^(.+)Start$/;\n\n    compile.$$addBindingInfo = debugInfoEnabled ? function $$addBindingInfo($element, binding) {\n      var bindings = $element.data('$binding') || [];\n\n      if (isArray(binding)) {\n        bindings = bindings.concat(binding);\n      } else {\n        bindings.push(binding);\n      }\n\n      $element.data('$binding', bindings);\n    } : noop;\n\n    compile.$$addBindingClass = debugInfoEnabled ? function $$addBindingClass($element) {\n      safeAddClass($element, 'ng-binding');\n    } : noop;\n\n    compile.$$addScopeInfo = debugInfoEnabled ? function $$addScopeInfo($element, scope, isolated, noTemplate) {\n      var dataName = isolated ? (noTemplate ? '$isolateScopeNoTemplate' : '$isolateScope') : '$scope';\n      $element.data(dataName, scope);\n    } : noop;\n\n    compile.$$addScopeClass = debugInfoEnabled ? function $$addScopeClass($element, isolated) {\n      safeAddClass($element, isolated ? 'ng-isolate-scope' : 'ng-scope');\n    } : noop;\n\n    compile.$$createComment = function(directiveName, comment) {\n      var content = '';\n      if (debugInfoEnabled) {\n        content = ' ' + (directiveName || '') + ': ' + (comment || '') + ' ';\n      }\n      return window.document.createComment(content);\n    };\n\n    return compile;\n\n    //================================\n\n    function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective,\n                        previousCompileContext) {\n      if (!($compileNodes instanceof jqLite)) {\n        // jquery always rewraps, whereas we need to preserve the original selector so that we can\n        // modify it.\n        $compileNodes = jqLite($compileNodes);\n      }\n\n      var NOT_EMPTY = /\\S+/;\n\n      // We can not compile top level text elements since text nodes can be merged and we will\n      // not be able to attach scope data to them, so we will wrap them in <span>\n      for (var i = 0, len = $compileNodes.length; i < len; i++) {\n        var domNode = $compileNodes[i];\n\n        if (domNode.nodeType === NODE_TYPE_TEXT && domNode.nodeValue.match(NOT_EMPTY) /* non-empty */) {\n          jqLiteWrapNode(domNode, $compileNodes[i] = window.document.createElement('span'));\n        }\n      }\n\n      var compositeLinkFn =\n              compileNodes($compileNodes, transcludeFn, $compileNodes,\n                           maxPriority, ignoreDirective, previousCompileContext);\n      compile.$$addScopeClass($compileNodes);\n      var namespace = null;\n      return function publicLinkFn(scope, cloneConnectFn, options) {\n        assertArg(scope, 'scope');\n\n        if (previousCompileContext && previousCompileContext.needsNewScope) {\n          // A parent directive did a replace and a directive on this element asked\n          // for transclusion, which caused us to lose a layer of element on which\n          // we could hold the new transclusion scope, so we will create it manually\n          // here.\n          scope = scope.$parent.$new();\n        }\n\n        options = options || {};\n        var parentBoundTranscludeFn = options.parentBoundTranscludeFn,\n          transcludeControllers = options.transcludeControllers,\n          futureParentElement = options.futureParentElement;\n\n        // When `parentBoundTranscludeFn` is passed, it is a\n        // `controllersBoundTransclude` function (it was previously passed\n        // as `transclude` to directive.link) so we must unwrap it to get\n        // its `boundTranscludeFn`\n        if (parentBoundTranscludeFn && parentBoundTranscludeFn.$$boundTransclude) {\n          parentBoundTranscludeFn = parentBoundTranscludeFn.$$boundTransclude;\n        }\n\n        if (!namespace) {\n          namespace = detectNamespaceForChildElements(futureParentElement);\n        }\n        var $linkNode;\n        if (namespace !== 'html') {\n          // When using a directive with replace:true and templateUrl the $compileNodes\n          // (or a child element inside of them)\n          // might change, so we need to recreate the namespace adapted compileNodes\n          // for call to the link function.\n          // Note: This will already clone the nodes...\n          $linkNode = jqLite(\n            wrapTemplate(namespace, jqLite('<div>').append($compileNodes).html())\n          );\n        } else if (cloneConnectFn) {\n          // important!!: we must call our jqLite.clone() since the jQuery one is trying to be smart\n          // and sometimes changes the structure of the DOM.\n          $linkNode = JQLitePrototype.clone.call($compileNodes);\n        } else {\n          $linkNode = $compileNodes;\n        }\n\n        if (transcludeControllers) {\n          for (var controllerName in transcludeControllers) {\n            $linkNode.data('$' + controllerName + 'Controller', transcludeControllers[controllerName].instance);\n          }\n        }\n\n        compile.$$addScopeInfo($linkNode, scope);\n\n        if (cloneConnectFn) cloneConnectFn($linkNode, scope);\n        if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn);\n        return $linkNode;\n      };\n    }\n\n    function detectNamespaceForChildElements(parentElement) {\n      // TODO: Make this detect MathML as well...\n      var node = parentElement && parentElement[0];\n      if (!node) {\n        return 'html';\n      } else {\n        return nodeName_(node) !== 'foreignobject' && toString.call(node).match(/SVG/) ? 'svg' : 'html';\n      }\n    }\n\n    /**\n     * Compile function matches each node in nodeList against the directives. Once all directives\n     * for a particular node are collected their compile functions are executed. The compile\n     * functions return values - the linking functions - are combined into a composite linking\n     * function, which is the a linking function for the node.\n     *\n     * @param {NodeList} nodeList an array of nodes or NodeList to compile\n     * @param {function(angular.Scope, cloneAttachFn=)} transcludeFn A linking function, where the\n     *        scope argument is auto-generated to the new child of the transcluded parent scope.\n     * @param {DOMElement=} $rootElement If the nodeList is the root of the compilation tree then\n     *        the rootElement must be set the jqLite collection of the compile root. This is\n     *        needed so that the jqLite collection items can be replaced with widgets.\n     * @param {number=} maxPriority Max directive priority.\n     * @returns {Function} A composite linking function of all of the matched directives or null.\n     */\n    function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective,\n                            previousCompileContext) {\n      var linkFns = [],\n          attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound, nodeLinkFnFound;\n\n      for (var i = 0; i < nodeList.length; i++) {\n        attrs = new Attributes();\n\n        // we must always refer to nodeList[i] since the nodes can be replaced underneath us.\n        directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined,\n                                        ignoreDirective);\n\n        nodeLinkFn = (directives.length)\n            ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement,\n                                      null, [], [], previousCompileContext)\n            : null;\n\n        if (nodeLinkFn && nodeLinkFn.scope) {\n          compile.$$addScopeClass(attrs.$$element);\n        }\n\n        childLinkFn = (nodeLinkFn && nodeLinkFn.terminal ||\n                      !(childNodes = nodeList[i].childNodes) ||\n                      !childNodes.length)\n            ? null\n            : compileNodes(childNodes,\n                 nodeLinkFn ? (\n                  (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement)\n                     && nodeLinkFn.transclude) : transcludeFn);\n\n        if (nodeLinkFn || childLinkFn) {\n          linkFns.push(i, nodeLinkFn, childLinkFn);\n          linkFnFound = true;\n          nodeLinkFnFound = nodeLinkFnFound || nodeLinkFn;\n        }\n\n        //use the previous context only for the first element in the virtual group\n        previousCompileContext = null;\n      }\n\n      // return a linking function if we have found anything, null otherwise\n      return linkFnFound ? compositeLinkFn : null;\n\n      function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) {\n        var nodeLinkFn, childLinkFn, node, childScope, i, ii, idx, childBoundTranscludeFn;\n        var stableNodeList;\n\n\n        if (nodeLinkFnFound) {\n          // copy nodeList so that if a nodeLinkFn removes or adds an element at this DOM level our\n          // offsets don't get screwed up\n          var nodeListLength = nodeList.length;\n          stableNodeList = new Array(nodeListLength);\n\n          // create a sparse array by only copying the elements which have a linkFn\n          for (i = 0; i < linkFns.length; i+=3) {\n            idx = linkFns[i];\n            stableNodeList[idx] = nodeList[idx];\n          }\n        } else {\n          stableNodeList = nodeList;\n        }\n\n        for (i = 0, ii = linkFns.length; i < ii;) {\n          node = stableNodeList[linkFns[i++]];\n          nodeLinkFn = linkFns[i++];\n          childLinkFn = linkFns[i++];\n\n          if (nodeLinkFn) {\n            if (nodeLinkFn.scope) {\n              childScope = scope.$new();\n              compile.$$addScopeInfo(jqLite(node), childScope);\n            } else {\n              childScope = scope;\n            }\n\n            if (nodeLinkFn.transcludeOnThisElement) {\n              childBoundTranscludeFn = createBoundTranscludeFn(\n                  scope, nodeLinkFn.transclude, parentBoundTranscludeFn);\n\n            } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) {\n              childBoundTranscludeFn = parentBoundTranscludeFn;\n\n            } else if (!parentBoundTranscludeFn && transcludeFn) {\n              childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn);\n\n            } else {\n              childBoundTranscludeFn = null;\n            }\n\n            nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn);\n\n          } else if (childLinkFn) {\n            childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn);\n          }\n        }\n      }\n    }\n\n    function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) {\n      function boundTranscludeFn(transcludedScope, cloneFn, controllers, futureParentElement, containingScope) {\n\n        if (!transcludedScope) {\n          transcludedScope = scope.$new(false, containingScope);\n          transcludedScope.$$transcluded = true;\n        }\n\n        return transcludeFn(transcludedScope, cloneFn, {\n          parentBoundTranscludeFn: previousBoundTranscludeFn,\n          transcludeControllers: controllers,\n          futureParentElement: futureParentElement\n        });\n      }\n\n      // We need  to attach the transclusion slots onto the `boundTranscludeFn`\n      // so that they are available inside the `controllersBoundTransclude` function\n      var boundSlots = boundTranscludeFn.$$slots = createMap();\n      for (var slotName in transcludeFn.$$slots) {\n        if (transcludeFn.$$slots[slotName]) {\n          boundSlots[slotName] = createBoundTranscludeFn(scope, transcludeFn.$$slots[slotName], previousBoundTranscludeFn);\n        } else {\n          boundSlots[slotName] = null;\n        }\n      }\n\n      return boundTranscludeFn;\n    }\n\n    /**\n     * Looks for directives on the given node and adds them to the directive collection which is\n     * sorted.\n     *\n     * @param node Node to search.\n     * @param directives An array to which the directives are added to. This array is sorted before\n     *        the function returns.\n     * @param attrs The shared attrs object which is used to populate the normalized attributes.\n     * @param {number=} maxPriority Max directive priority.\n     */\n    function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) {\n      var nodeType = node.nodeType,\n          attrsMap = attrs.$attr,\n          match,\n          className;\n\n      switch (nodeType) {\n        case NODE_TYPE_ELEMENT: /* Element */\n          // use the node name: <directive>\n          addDirective(directives,\n              directiveNormalize(nodeName_(node)), 'E', maxPriority, ignoreDirective);\n\n          // iterate over the attributes\n          for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes,\n                   j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) {\n            var attrStartName = false;\n            var attrEndName = false;\n\n            attr = nAttrs[j];\n            name = attr.name;\n            value = trim(attr.value);\n\n            // support ngAttr attribute binding\n            ngAttrName = directiveNormalize(name);\n            if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) {\n              name = name.replace(PREFIX_REGEXP, '')\n                .substr(8).replace(/_(.)/g, function(match, letter) {\n                  return letter.toUpperCase();\n                });\n            }\n\n            var multiElementMatch = ngAttrName.match(MULTI_ELEMENT_DIR_RE);\n            if (multiElementMatch && directiveIsMultiElement(multiElementMatch[1])) {\n              attrStartName = name;\n              attrEndName = name.substr(0, name.length - 5) + 'end';\n              name = name.substr(0, name.length - 6);\n            }\n\n            nName = directiveNormalize(name.toLowerCase());\n            attrsMap[nName] = name;\n            if (isNgAttr || !attrs.hasOwnProperty(nName)) {\n                attrs[nName] = value;\n                if (getBooleanAttrName(node, nName)) {\n                  attrs[nName] = true; // presence means true\n                }\n            }\n            addAttrInterpolateDirective(node, directives, value, nName, isNgAttr);\n            addDirective(directives, nName, 'A', maxPriority, ignoreDirective, attrStartName,\n                          attrEndName);\n          }\n\n          // use class as directive\n          className = node.className;\n          if (isObject(className)) {\n              // Maybe SVGAnimatedString\n              className = className.animVal;\n          }\n          if (isString(className) && className !== '') {\n            while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) {\n              nName = directiveNormalize(match[2]);\n              if (addDirective(directives, nName, 'C', maxPriority, ignoreDirective)) {\n                attrs[nName] = trim(match[3]);\n              }\n              className = className.substr(match.index + match[0].length);\n            }\n          }\n          break;\n        case NODE_TYPE_TEXT: /* Text Node */\n          if (msie === 11) {\n            // Workaround for #11781\n            while (node.parentNode && node.nextSibling && node.nextSibling.nodeType === NODE_TYPE_TEXT) {\n              node.nodeValue = node.nodeValue + node.nextSibling.nodeValue;\n              node.parentNode.removeChild(node.nextSibling);\n            }\n          }\n          addTextInterpolateDirective(directives, node.nodeValue);\n          break;\n        case NODE_TYPE_COMMENT: /* Comment */\n          try {\n            match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue);\n            if (match) {\n              nName = directiveNormalize(match[1]);\n              if (addDirective(directives, nName, 'M', maxPriority, ignoreDirective)) {\n                attrs[nName] = trim(match[2]);\n              }\n            }\n          } catch (e) {\n            // turns out that under some circumstances IE9 throws errors when one attempts to read\n            // comment's node value.\n            // Just ignore it and continue. (Can't seem to reproduce in test case.)\n          }\n          break;\n      }\n\n      directives.sort(byPriority);\n      return directives;\n    }\n\n    /**\n     * Given a node with an directive-start it collects all of the siblings until it finds\n     * directive-end.\n     * @param node\n     * @param attrStart\n     * @param attrEnd\n     * @returns {*}\n     */\n    function groupScan(node, attrStart, attrEnd) {\n      var nodes = [];\n      var depth = 0;\n      if (attrStart && node.hasAttribute && node.hasAttribute(attrStart)) {\n        do {\n          if (!node) {\n            throw $compileMinErr('uterdir',\n                      \"Unterminated attribute, found '{0}' but no matching '{1}' found.\",\n                      attrStart, attrEnd);\n          }\n          if (node.nodeType == NODE_TYPE_ELEMENT) {\n            if (node.hasAttribute(attrStart)) depth++;\n            if (node.hasAttribute(attrEnd)) depth--;\n          }\n          nodes.push(node);\n          node = node.nextSibling;\n        } while (depth > 0);\n      } else {\n        nodes.push(node);\n      }\n\n      return jqLite(nodes);\n    }\n\n    /**\n     * Wrapper for linking function which converts normal linking function into a grouped\n     * linking function.\n     * @param linkFn\n     * @param attrStart\n     * @param attrEnd\n     * @returns {Function}\n     */\n    function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) {\n      return function groupedElementsLink(scope, element, attrs, controllers, transcludeFn) {\n        element = groupScan(element[0], attrStart, attrEnd);\n        return linkFn(scope, element, attrs, controllers, transcludeFn);\n      };\n    }\n\n    /**\n     * A function generator that is used to support both eager and lazy compilation\n     * linking function.\n     * @param eager\n     * @param $compileNodes\n     * @param transcludeFn\n     * @param maxPriority\n     * @param ignoreDirective\n     * @param previousCompileContext\n     * @returns {Function}\n     */\n    function compilationGenerator(eager, $compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) {\n      var compiled;\n\n      if (eager) {\n        return compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext);\n      }\n      return function lazyCompilation() {\n        if (!compiled) {\n          compiled = compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext);\n\n          // Null out all of these references in order to make them eligible for garbage collection\n          // since this is a potentially long lived closure\n          $compileNodes = transcludeFn = previousCompileContext = null;\n        }\n        return compiled.apply(this, arguments);\n      };\n    }\n\n    /**\n     * Once the directives have been collected, their compile functions are executed. This method\n     * is responsible for inlining directive templates as well as terminating the application\n     * of the directives if the terminal directive has been reached.\n     *\n     * @param {Array} directives Array of collected directives to execute their compile function.\n     *        this needs to be pre-sorted by priority order.\n     * @param {Node} compileNode The raw DOM node to apply the compile functions to\n     * @param {Object} templateAttrs The shared attribute function\n     * @param {function(angular.Scope, cloneAttachFn=)} transcludeFn A linking function, where the\n     *                                                  scope argument is auto-generated to the new\n     *                                                  child of the transcluded parent scope.\n     * @param {JQLite} jqCollection If we are working on the root of the compile tree then this\n     *                              argument has the root jqLite array so that we can replace nodes\n     *                              on it.\n     * @param {Object=} originalReplaceDirective An optional directive that will be ignored when\n     *                                           compiling the transclusion.\n     * @param {Array.<Function>} preLinkFns\n     * @param {Array.<Function>} postLinkFns\n     * @param {Object} previousCompileContext Context used for previous compilation of the current\n     *                                        node\n     * @returns {Function} linkFn\n     */\n    function applyDirectivesToNode(directives, compileNode, templateAttrs, transcludeFn,\n                                   jqCollection, originalReplaceDirective, preLinkFns, postLinkFns,\n                                   previousCompileContext) {\n      previousCompileContext = previousCompileContext || {};\n\n      var terminalPriority = -Number.MAX_VALUE,\n          newScopeDirective = previousCompileContext.newScopeDirective,\n          controllerDirectives = previousCompileContext.controllerDirectives,\n          newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective,\n          templateDirective = previousCompileContext.templateDirective,\n          nonTlbTranscludeDirective = previousCompileContext.nonTlbTranscludeDirective,\n          hasTranscludeDirective = false,\n          hasTemplate = false,\n          hasElementTranscludeDirective = previousCompileContext.hasElementTranscludeDirective,\n          $compileNode = templateAttrs.$$element = jqLite(compileNode),\n          directive,\n          directiveName,\n          $template,\n          replaceDirective = originalReplaceDirective,\n          childTranscludeFn = transcludeFn,\n          linkFn,\n          didScanForMultipleTransclusion = false,\n          mightHaveMultipleTransclusionError = false,\n          directiveValue;\n\n      // executes all directives on the current element\n      for (var i = 0, ii = directives.length; i < ii; i++) {\n        directive = directives[i];\n        var attrStart = directive.$$start;\n        var attrEnd = directive.$$end;\n\n        // collect multiblock sections\n        if (attrStart) {\n          $compileNode = groupScan(compileNode, attrStart, attrEnd);\n        }\n        $template = undefined;\n\n        if (terminalPriority > directive.priority) {\n          break; // prevent further processing of directives\n        }\n\n        if (directiveValue = directive.scope) {\n\n          // skip the check for directives with async templates, we'll check the derived sync\n          // directive when the template arrives\n          if (!directive.templateUrl) {\n            if (isObject(directiveValue)) {\n              // This directive is trying to add an isolated scope.\n              // Check that there is no scope of any kind already\n              assertNoDuplicate('new/isolated scope', newIsolateScopeDirective || newScopeDirective,\n                                directive, $compileNode);\n              newIsolateScopeDirective = directive;\n            } else {\n              // This directive is trying to add a child scope.\n              // Check that there is no isolated scope already\n              assertNoDuplicate('new/isolated scope', newIsolateScopeDirective, directive,\n                                $compileNode);\n            }\n          }\n\n          newScopeDirective = newScopeDirective || directive;\n        }\n\n        directiveName = directive.name;\n\n        // If we encounter a condition that can result in transclusion on the directive,\n        // then scan ahead in the remaining directives for others that may cause a multiple\n        // transclusion error to be thrown during the compilation process.  If a matching directive\n        // is found, then we know that when we encounter a transcluded directive, we need to eagerly\n        // compile the `transclude` function rather than doing it lazily in order to throw\n        // exceptions at the correct time\n        if (!didScanForMultipleTransclusion && ((directive.replace && (directive.templateUrl || directive.template))\n            || (directive.transclude && !directive.$$tlb))) {\n                var candidateDirective;\n\n                for (var scanningIndex = i + 1; candidateDirective = directives[scanningIndex++];) {\n                    if ((candidateDirective.transclude && !candidateDirective.$$tlb)\n                        || (candidateDirective.replace && (candidateDirective.templateUrl || candidateDirective.template))) {\n                        mightHaveMultipleTransclusionError = true;\n                        break;\n                    }\n                }\n\n                didScanForMultipleTransclusion = true;\n        }\n\n        if (!directive.templateUrl && directive.controller) {\n          directiveValue = directive.controller;\n          controllerDirectives = controllerDirectives || createMap();\n          assertNoDuplicate(\"'\" + directiveName + \"' controller\",\n              controllerDirectives[directiveName], directive, $compileNode);\n          controllerDirectives[directiveName] = directive;\n        }\n\n        if (directiveValue = directive.transclude) {\n          hasTranscludeDirective = true;\n\n          // Special case ngIf and ngRepeat so that we don't complain about duplicate transclusion.\n          // This option should only be used by directives that know how to safely handle element transclusion,\n          // where the transcluded nodes are added or replaced after linking.\n          if (!directive.$$tlb) {\n            assertNoDuplicate('transclusion', nonTlbTranscludeDirective, directive, $compileNode);\n            nonTlbTranscludeDirective = directive;\n          }\n\n          if (directiveValue == 'element') {\n            hasElementTranscludeDirective = true;\n            terminalPriority = directive.priority;\n            $template = $compileNode;\n            $compileNode = templateAttrs.$$element =\n                jqLite(compile.$$createComment(directiveName, templateAttrs[directiveName]));\n            compileNode = $compileNode[0];\n            replaceWith(jqCollection, sliceArgs($template), compileNode);\n\n            // Support: Chrome < 50\n            // https://github.com/angular/angular.js/issues/14041\n\n            // In the versions of V8 prior to Chrome 50, the document fragment that is created\n            // in the `replaceWith` function is improperly garbage collected despite still\n            // being referenced by the `parentNode` property of all of the child nodes.  By adding\n            // a reference to the fragment via a different property, we can avoid that incorrect\n            // behavior.\n            // TODO: remove this line after Chrome 50 has been released\n            $template[0].$$parentNode = $template[0].parentNode;\n\n            childTranscludeFn = compilationGenerator(mightHaveMultipleTransclusionError, $template, transcludeFn, terminalPriority,\n                                        replaceDirective && replaceDirective.name, {\n                                          // Don't pass in:\n                                          // - controllerDirectives - otherwise we'll create duplicates controllers\n                                          // - newIsolateScopeDirective or templateDirective - combining templates with\n                                          //   element transclusion doesn't make sense.\n                                          //\n                                          // We need only nonTlbTranscludeDirective so that we prevent putting transclusion\n                                          // on the same element more than once.\n                                          nonTlbTranscludeDirective: nonTlbTranscludeDirective\n                                        });\n          } else {\n\n            var slots = createMap();\n\n            $template = jqLite(jqLiteClone(compileNode)).contents();\n\n            if (isObject(directiveValue)) {\n\n              // We have transclusion slots,\n              // collect them up, compile them and store their transclusion functions\n              $template = [];\n\n              var slotMap = createMap();\n              var filledSlots = createMap();\n\n              // Parse the element selectors\n              forEach(directiveValue, function(elementSelector, slotName) {\n                // If an element selector starts with a ? then it is optional\n                var optional = (elementSelector.charAt(0) === '?');\n                elementSelector = optional ? elementSelector.substring(1) : elementSelector;\n\n                slotMap[elementSelector] = slotName;\n\n                // We explicitly assign `null` since this implies that a slot was defined but not filled.\n                // Later when calling boundTransclusion functions with a slot name we only error if the\n                // slot is `undefined`\n                slots[slotName] = null;\n\n                // filledSlots contains `true` for all slots that are either optional or have been\n                // filled. This is used to check that we have not missed any required slots\n                filledSlots[slotName] = optional;\n              });\n\n              // Add the matching elements into their slot\n              forEach($compileNode.contents(), function(node) {\n                var slotName = slotMap[directiveNormalize(nodeName_(node))];\n                if (slotName) {\n                  filledSlots[slotName] = true;\n                  slots[slotName] = slots[slotName] || [];\n                  slots[slotName].push(node);\n                } else {\n                  $template.push(node);\n                }\n              });\n\n              // Check for required slots that were not filled\n              forEach(filledSlots, function(filled, slotName) {\n                if (!filled) {\n                  throw $compileMinErr('reqslot', 'Required transclusion slot `{0}` was not filled.', slotName);\n                }\n              });\n\n              for (var slotName in slots) {\n                if (slots[slotName]) {\n                  // Only define a transclusion function if the slot was filled\n                  slots[slotName] = compilationGenerator(mightHaveMultipleTransclusionError, slots[slotName], transcludeFn);\n                }\n              }\n            }\n\n            $compileNode.empty(); // clear contents\n            childTranscludeFn = compilationGenerator(mightHaveMultipleTransclusionError, $template, transcludeFn, undefined,\n                undefined, { needsNewScope: directive.$$isolateScope || directive.$$newScope});\n            childTranscludeFn.$$slots = slots;\n          }\n        }\n\n        if (directive.template) {\n          hasTemplate = true;\n          assertNoDuplicate('template', templateDirective, directive, $compileNode);\n          templateDirective = directive;\n\n          directiveValue = (isFunction(directive.template))\n              ? directive.template($compileNode, templateAttrs)\n              : directive.template;\n\n          directiveValue = denormalizeTemplate(directiveValue);\n\n          if (directive.replace) {\n            replaceDirective = directive;\n            if (jqLiteIsTextNode(directiveValue)) {\n              $template = [];\n            } else {\n              $template = removeComments(wrapTemplate(directive.templateNamespace, trim(directiveValue)));\n            }\n            compileNode = $template[0];\n\n            if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {\n              throw $compileMinErr('tplrt',\n                  \"Template for directive '{0}' must have exactly one root element. {1}\",\n                  directiveName, '');\n            }\n\n            replaceWith(jqCollection, $compileNode, compileNode);\n\n            var newTemplateAttrs = {$attr: {}};\n\n            // combine directives from the original node and from the template:\n            // - take the array of directives for this element\n            // - split it into two parts, those that already applied (processed) and those that weren't (unprocessed)\n            // - collect directives from the template and sort them by priority\n            // - combine directives as: processed + template + unprocessed\n            var templateDirectives = collectDirectives(compileNode, [], newTemplateAttrs);\n            var unprocessedDirectives = directives.splice(i + 1, directives.length - (i + 1));\n\n            if (newIsolateScopeDirective || newScopeDirective) {\n              // The original directive caused the current element to be replaced but this element\n              // also needs to have a new scope, so we need to tell the template directives\n              // that they would need to get their scope from further up, if they require transclusion\n              markDirectiveScope(templateDirectives, newIsolateScopeDirective, newScopeDirective);\n            }\n            directives = directives.concat(templateDirectives).concat(unprocessedDirectives);\n            mergeTemplateAttributes(templateAttrs, newTemplateAttrs);\n\n            ii = directives.length;\n          } else {\n            $compileNode.html(directiveValue);\n          }\n        }\n\n        if (directive.templateUrl) {\n          hasTemplate = true;\n          assertNoDuplicate('template', templateDirective, directive, $compileNode);\n          templateDirective = directive;\n\n          if (directive.replace) {\n            replaceDirective = directive;\n          }\n\n          /* jshint -W021 */\n          nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode,\n          /* jshint +W021 */\n              templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, {\n                controllerDirectives: controllerDirectives,\n                newScopeDirective: (newScopeDirective !== directive) && newScopeDirective,\n                newIsolateScopeDirective: newIsolateScopeDirective,\n                templateDirective: templateDirective,\n                nonTlbTranscludeDirective: nonTlbTranscludeDirective\n              });\n          ii = directives.length;\n        } else if (directive.compile) {\n          try {\n            linkFn = directive.compile($compileNode, templateAttrs, childTranscludeFn);\n            if (isFunction(linkFn)) {\n              addLinkFns(null, linkFn, attrStart, attrEnd);\n            } else if (linkFn) {\n              addLinkFns(linkFn.pre, linkFn.post, attrStart, attrEnd);\n            }\n          } catch (e) {\n            $exceptionHandler(e, startingTag($compileNode));\n          }\n        }\n\n        if (directive.terminal) {\n          nodeLinkFn.terminal = true;\n          terminalPriority = Math.max(terminalPriority, directive.priority);\n        }\n\n      }\n\n      nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true;\n      nodeLinkFn.transcludeOnThisElement = hasTranscludeDirective;\n      nodeLinkFn.templateOnThisElement = hasTemplate;\n      nodeLinkFn.transclude = childTranscludeFn;\n\n      previousCompileContext.hasElementTranscludeDirective = hasElementTranscludeDirective;\n\n      // might be normal or delayed nodeLinkFn depending on if templateUrl is present\n      return nodeLinkFn;\n\n      ////////////////////\n\n      function addLinkFns(pre, post, attrStart, attrEnd) {\n        if (pre) {\n          if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd);\n          pre.require = directive.require;\n          pre.directiveName = directiveName;\n          if (newIsolateScopeDirective === directive || directive.$$isolateScope) {\n            pre = cloneAndAnnotateFn(pre, {isolateScope: true});\n          }\n          preLinkFns.push(pre);\n        }\n        if (post) {\n          if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd);\n          post.require = directive.require;\n          post.directiveName = directiveName;\n          if (newIsolateScopeDirective === directive || directive.$$isolateScope) {\n            post = cloneAndAnnotateFn(post, {isolateScope: true});\n          }\n          postLinkFns.push(post);\n        }\n      }\n\n      function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) {\n        var i, ii, linkFn, isolateScope, controllerScope, elementControllers, transcludeFn, $element,\n            attrs, scopeBindingInfo;\n\n        if (compileNode === linkNode) {\n          attrs = templateAttrs;\n          $element = templateAttrs.$$element;\n        } else {\n          $element = jqLite(linkNode);\n          attrs = new Attributes($element, templateAttrs);\n        }\n\n        controllerScope = scope;\n        if (newIsolateScopeDirective) {\n          isolateScope = scope.$new(true);\n        } else if (newScopeDirective) {\n          controllerScope = scope.$parent;\n        }\n\n        if (boundTranscludeFn) {\n          // track `boundTranscludeFn` so it can be unwrapped if `transcludeFn`\n          // is later passed as `parentBoundTranscludeFn` to `publicLinkFn`\n          transcludeFn = controllersBoundTransclude;\n          transcludeFn.$$boundTransclude = boundTranscludeFn;\n          // expose the slots on the `$transclude` function\n          transcludeFn.isSlotFilled = function(slotName) {\n            return !!boundTranscludeFn.$$slots[slotName];\n          };\n        }\n\n        if (controllerDirectives) {\n          elementControllers = setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective);\n        }\n\n        if (newIsolateScopeDirective) {\n          // Initialize isolate scope bindings for new isolate scope directive.\n          compile.$$addScopeInfo($element, isolateScope, true, !(templateDirective && (templateDirective === newIsolateScopeDirective ||\n              templateDirective === newIsolateScopeDirective.$$originalDirective)));\n          compile.$$addScopeClass($element, true);\n          isolateScope.$$isolateBindings =\n              newIsolateScopeDirective.$$isolateBindings;\n          scopeBindingInfo = initializeDirectiveBindings(scope, attrs, isolateScope,\n                                        isolateScope.$$isolateBindings,\n                                        newIsolateScopeDirective);\n          if (scopeBindingInfo.removeWatches) {\n            isolateScope.$on('$destroy', scopeBindingInfo.removeWatches);\n          }\n        }\n\n        // Initialize bindToController bindings\n        for (var name in elementControllers) {\n          var controllerDirective = controllerDirectives[name];\n          var controller = elementControllers[name];\n          var bindings = controllerDirective.$$bindings.bindToController;\n\n          if (controller.identifier && bindings) {\n            controller.bindingInfo =\n              initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);\n          } else {\n            controller.bindingInfo = {};\n          }\n\n          var controllerResult = controller();\n          if (controllerResult !== controller.instance) {\n            // If the controller constructor has a return value, overwrite the instance\n            // from setupControllers\n            controller.instance = controllerResult;\n            $element.data('$' + controllerDirective.name + 'Controller', controllerResult);\n            controller.bindingInfo.removeWatches && controller.bindingInfo.removeWatches();\n            controller.bindingInfo =\n              initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);\n          }\n        }\n\n        // Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy\n        forEach(controllerDirectives, function(controllerDirective, name) {\n          var require = controllerDirective.require;\n          if (controllerDirective.bindToController && !isArray(require) && isObject(require)) {\n            extend(elementControllers[name].instance, getControllers(name, require, $element, elementControllers));\n          }\n        });\n\n        // Handle the init and destroy lifecycle hooks on all controllers that have them\n        forEach(elementControllers, function(controller) {\n          var controllerInstance = controller.instance;\n          if (isFunction(controllerInstance.$onChanges)) {\n            controllerInstance.$onChanges(controller.bindingInfo.initialChanges);\n          }\n          if (isFunction(controllerInstance.$onInit)) {\n            controllerInstance.$onInit();\n          }\n          if (isFunction(controllerInstance.$onDestroy)) {\n            controllerScope.$on('$destroy', function callOnDestroyHook() {\n              controllerInstance.$onDestroy();\n            });\n          }\n        });\n\n        // PRELINKING\n        for (i = 0, ii = preLinkFns.length; i < ii; i++) {\n          linkFn = preLinkFns[i];\n          invokeLinkFn(linkFn,\n              linkFn.isolateScope ? isolateScope : scope,\n              $element,\n              attrs,\n              linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers),\n              transcludeFn\n          );\n        }\n\n        // RECURSION\n        // We only pass the isolate scope, if the isolate directive has a template,\n        // otherwise the child elements do not belong to the isolate directive.\n        var scopeToChild = scope;\n        if (newIsolateScopeDirective && (newIsolateScopeDirective.template || newIsolateScopeDirective.templateUrl === null)) {\n          scopeToChild = isolateScope;\n        }\n        childLinkFn && childLinkFn(scopeToChild, linkNode.childNodes, undefined, boundTranscludeFn);\n\n        // POSTLINKING\n        for (i = postLinkFns.length - 1; i >= 0; i--) {\n          linkFn = postLinkFns[i];\n          invokeLinkFn(linkFn,\n              linkFn.isolateScope ? isolateScope : scope,\n              $element,\n              attrs,\n              linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers),\n              transcludeFn\n          );\n        }\n\n        // Trigger $postLink lifecycle hooks\n        forEach(elementControllers, function(controller) {\n          var controllerInstance = controller.instance;\n          if (isFunction(controllerInstance.$postLink)) {\n            controllerInstance.$postLink();\n          }\n        });\n\n        // This is the function that is injected as `$transclude`.\n        // Note: all arguments are optional!\n        function controllersBoundTransclude(scope, cloneAttachFn, futureParentElement, slotName) {\n          var transcludeControllers;\n          // No scope passed in:\n          if (!isScope(scope)) {\n            slotName = futureParentElement;\n            futureParentElement = cloneAttachFn;\n            cloneAttachFn = scope;\n            scope = undefined;\n          }\n\n          if (hasElementTranscludeDirective) {\n            transcludeControllers = elementControllers;\n          }\n          if (!futureParentElement) {\n            futureParentElement = hasElementTranscludeDirective ? $element.parent() : $element;\n          }\n          if (slotName) {\n            // slotTranscludeFn can be one of three things:\n            //  * a transclude function - a filled slot\n            //  * `null` - an optional slot that was not filled\n            //  * `undefined` - a slot that was not declared (i.e. invalid)\n            var slotTranscludeFn = boundTranscludeFn.$$slots[slotName];\n            if (slotTranscludeFn) {\n              return slotTranscludeFn(scope, cloneAttachFn, transcludeControllers, futureParentElement, scopeToChild);\n            } else if (isUndefined(slotTranscludeFn)) {\n              throw $compileMinErr('noslot',\n               'No parent directive that requires a transclusion with slot name \"{0}\". ' +\n               'Element: {1}',\n               slotName, startingTag($element));\n            }\n          } else {\n            return boundTranscludeFn(scope, cloneAttachFn, transcludeControllers, futureParentElement, scopeToChild);\n          }\n        }\n      }\n    }\n\n    function getControllers(directiveName, require, $element, elementControllers) {\n      var value;\n\n      if (isString(require)) {\n        var match = require.match(REQUIRE_PREFIX_REGEXP);\n        var name = require.substring(match[0].length);\n        var inheritType = match[1] || match[3];\n        var optional = match[2] === '?';\n\n        //If only parents then start at the parent element\n        if (inheritType === '^^') {\n          $element = $element.parent();\n        //Otherwise attempt getting the controller from elementControllers in case\n        //the element is transcluded (and has no data) and to avoid .data if possible\n        } else {\n          value = elementControllers && elementControllers[name];\n          value = value && value.instance;\n        }\n\n        if (!value) {\n          var dataName = '$' + name + 'Controller';\n          value = inheritType ? $element.inheritedData(dataName) : $element.data(dataName);\n        }\n\n        if (!value && !optional) {\n          throw $compileMinErr('ctreq',\n              \"Controller '{0}', required by directive '{1}', can't be found!\",\n              name, directiveName);\n        }\n      } else if (isArray(require)) {\n        value = [];\n        for (var i = 0, ii = require.length; i < ii; i++) {\n          value[i] = getControllers(directiveName, require[i], $element, elementControllers);\n        }\n      } else if (isObject(require)) {\n        value = {};\n        forEach(require, function(controller, property) {\n          value[property] = getControllers(directiveName, controller, $element, elementControllers);\n        });\n      }\n\n      return value || null;\n    }\n\n    function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {\n      var elementControllers = createMap();\n      for (var controllerKey in controllerDirectives) {\n        var directive = controllerDirectives[controllerKey];\n        var locals = {\n          $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,\n          $element: $element,\n          $attrs: attrs,\n          $transclude: transcludeFn\n        };\n\n        var controller = directive.controller;\n        if (controller == '@') {\n          controller = attrs[directive.name];\n        }\n\n        var controllerInstance = $controller(controller, locals, true, directive.controllerAs);\n\n        // For directives with element transclusion the element is a comment.\n        // In this case .data will not attach any data.\n        // Instead, we save the controllers for the element in a local hash and attach to .data\n        // later, once we have the actual element.\n        elementControllers[directive.name] = controllerInstance;\n        $element.data('$' + directive.name + 'Controller', controllerInstance.instance);\n      }\n      return elementControllers;\n    }\n\n    // Depending upon the context in which a directive finds itself it might need to have a new isolated\n    // or child scope created. For instance:\n    // * if the directive has been pulled into a template because another directive with a higher priority\n    // asked for element transclusion\n    // * if the directive itself asks for transclusion but it is at the root of a template and the original\n    // element was replaced. See https://github.com/angular/angular.js/issues/12936\n    function markDirectiveScope(directives, isolateScope, newScope) {\n      for (var j = 0, jj = directives.length; j < jj; j++) {\n        directives[j] = inherit(directives[j], {$$isolateScope: isolateScope, $$newScope: newScope});\n      }\n    }\n\n    /**\n     * looks up the directive and decorates it with exception handling and proper parameters. We\n     * call this the boundDirective.\n     *\n     * @param {string} name name of the directive to look up.\n     * @param {string} location The directive must be found in specific format.\n     *   String containing any of theses characters:\n     *\n     *   * `E`: element name\n     *   * `A': attribute\n     *   * `C`: class\n     *   * `M`: comment\n     * @returns {boolean} true if directive was added.\n     */\n    function addDirective(tDirectives, name, location, maxPriority, ignoreDirective, startAttrName,\n                          endAttrName) {\n      if (name === ignoreDirective) return null;\n      var match = null;\n      if (hasDirectives.hasOwnProperty(name)) {\n        for (var directive, directives = $injector.get(name + Suffix),\n            i = 0, ii = directives.length; i < ii; i++) {\n          try {\n            directive = directives[i];\n            if ((isUndefined(maxPriority) || maxPriority > directive.priority) &&\n                 directive.restrict.indexOf(location) != -1) {\n              if (startAttrName) {\n                directive = inherit(directive, {$$start: startAttrName, $$end: endAttrName});\n              }\n              if (!directive.$$bindings) {\n                var bindings = directive.$$bindings =\n                    parseDirectiveBindings(directive, directive.name);\n                if (isObject(bindings.isolateScope)) {\n                  directive.$$isolateBindings = bindings.isolateScope;\n                }\n              }\n              tDirectives.push(directive);\n              match = directive;\n            }\n          } catch (e) { $exceptionHandler(e); }\n        }\n      }\n      return match;\n    }\n\n\n    /**\n     * looks up the directive and returns true if it is a multi-element directive,\n     * and therefore requires DOM nodes between -start and -end markers to be grouped\n     * together.\n     *\n     * @param {string} name name of the directive to look up.\n     * @returns true if directive was registered as multi-element.\n     */\n    function directiveIsMultiElement(name) {\n      if (hasDirectives.hasOwnProperty(name)) {\n        for (var directive, directives = $injector.get(name + Suffix),\n            i = 0, ii = directives.length; i < ii; i++) {\n          directive = directives[i];\n          if (directive.multiElement) {\n            return true;\n          }\n        }\n      }\n      return false;\n    }\n\n    /**\n     * When the element is replaced with HTML template then the new attributes\n     * on the template need to be merged with the existing attributes in the DOM.\n     * The desired effect is to have both of the attributes present.\n     *\n     * @param {object} dst destination attributes (original DOM)\n     * @param {object} src source attributes (from the directive template)\n     */\n    function mergeTemplateAttributes(dst, src) {\n      var srcAttr = src.$attr,\n          dstAttr = dst.$attr,\n          $element = dst.$$element;\n\n      // reapply the old attributes to the new element\n      forEach(dst, function(value, key) {\n        if (key.charAt(0) != '$') {\n          if (src[key] && src[key] !== value) {\n            value += (key === 'style' ? ';' : ' ') + src[key];\n          }\n          dst.$set(key, value, true, srcAttr[key]);\n        }\n      });\n\n      // copy the new attributes on the old attrs object\n      forEach(src, function(value, key) {\n        if (key == 'class') {\n          safeAddClass($element, value);\n          dst['class'] = (dst['class'] ? dst['class'] + ' ' : '') + value;\n        } else if (key == 'style') {\n          $element.attr('style', $element.attr('style') + ';' + value);\n          dst['style'] = (dst['style'] ? dst['style'] + ';' : '') + value;\n          // `dst` will never contain hasOwnProperty as DOM parser won't let it.\n          // You will get an \"InvalidCharacterError: DOM Exception 5\" error if you\n          // have an attribute like \"has-own-property\" or \"data-has-own-property\", etc.\n        } else if (key.charAt(0) != '$' && !dst.hasOwnProperty(key)) {\n          dst[key] = value;\n          dstAttr[key] = srcAttr[key];\n        }\n      });\n    }\n\n\n    function compileTemplateUrl(directives, $compileNode, tAttrs,\n        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {\n      var linkQueue = [],\n          afterTemplateNodeLinkFn,\n          afterTemplateChildLinkFn,\n          beforeTemplateCompileNode = $compileNode[0],\n          origAsyncDirective = directives.shift(),\n          derivedSyncDirective = inherit(origAsyncDirective, {\n            templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective\n          }),\n          templateUrl = (isFunction(origAsyncDirective.templateUrl))\n              ? origAsyncDirective.templateUrl($compileNode, tAttrs)\n              : origAsyncDirective.templateUrl,\n          templateNamespace = origAsyncDirective.templateNamespace;\n\n      $compileNode.empty();\n\n      $templateRequest(templateUrl)\n        .then(function(content) {\n          var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;\n\n          content = denormalizeTemplate(content);\n\n          if (origAsyncDirective.replace) {\n            if (jqLiteIsTextNode(content)) {\n              $template = [];\n            } else {\n              $template = removeComments(wrapTemplate(templateNamespace, trim(content)));\n            }\n            compileNode = $template[0];\n\n            if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {\n              throw $compileMinErr('tplrt',\n                  \"Template for directive '{0}' must have exactly one root element. {1}\",\n                  origAsyncDirective.name, templateUrl);\n            }\n\n            tempTemplateAttrs = {$attr: {}};\n            replaceWith($rootElement, $compileNode, compileNode);\n            var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);\n\n            if (isObject(origAsyncDirective.scope)) {\n              // the original directive that caused the template to be loaded async required\n              // an isolate scope\n              markDirectiveScope(templateDirectives, true);\n            }\n            directives = templateDirectives.concat(directives);\n            mergeTemplateAttributes(tAttrs, tempTemplateAttrs);\n          } else {\n            compileNode = beforeTemplateCompileNode;\n            $compileNode.html(content);\n          }\n\n          directives.unshift(derivedSyncDirective);\n\n          afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,\n              childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,\n              previousCompileContext);\n          forEach($rootElement, function(node, i) {\n            if (node == compileNode) {\n              $rootElement[i] = $compileNode[0];\n            }\n          });\n          afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn);\n\n          while (linkQueue.length) {\n            var scope = linkQueue.shift(),\n                beforeTemplateLinkNode = linkQueue.shift(),\n                linkRootElement = linkQueue.shift(),\n                boundTranscludeFn = linkQueue.shift(),\n                linkNode = $compileNode[0];\n\n            if (scope.$$destroyed) continue;\n\n            if (beforeTemplateLinkNode !== beforeTemplateCompileNode) {\n              var oldClasses = beforeTemplateLinkNode.className;\n\n              if (!(previousCompileContext.hasElementTranscludeDirective &&\n                  origAsyncDirective.replace)) {\n                // it was cloned therefore we have to clone as well.\n                linkNode = jqLiteClone(compileNode);\n              }\n              replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode);\n\n              // Copy in CSS classes from original node\n              safeAddClass(jqLite(linkNode), oldClasses);\n            }\n            if (afterTemplateNodeLinkFn.transcludeOnThisElement) {\n              childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn);\n            } else {\n              childBoundTranscludeFn = boundTranscludeFn;\n            }\n            afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement,\n              childBoundTranscludeFn);\n          }\n          linkQueue = null;\n        });\n\n      return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, boundTranscludeFn) {\n        var childBoundTranscludeFn = boundTranscludeFn;\n        if (scope.$$destroyed) return;\n        if (linkQueue) {\n          linkQueue.push(scope,\n                         node,\n                         rootElement,\n                         childBoundTranscludeFn);\n        } else {\n          if (afterTemplateNodeLinkFn.transcludeOnThisElement) {\n            childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn);\n          }\n          afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, childBoundTranscludeFn);\n        }\n      };\n    }\n\n\n    /**\n     * Sorting function for bound directives.\n     */\n    function byPriority(a, b) {\n      var diff = b.priority - a.priority;\n      if (diff !== 0) return diff;\n      if (a.name !== b.name) return (a.name < b.name) ? -1 : 1;\n      return a.index - b.index;\n    }\n\n    function assertNoDuplicate(what, previousDirective, directive, element) {\n\n      function wrapModuleNameIfDefined(moduleName) {\n        return moduleName ?\n          (' (module: ' + moduleName + ')') :\n          '';\n      }\n\n      if (previousDirective) {\n        throw $compileMinErr('multidir', 'Multiple directives [{0}{1}, {2}{3}] asking for {4} on: {5}',\n            previousDirective.name, wrapModuleNameIfDefined(previousDirective.$$moduleName),\n            directive.name, wrapModuleNameIfDefined(directive.$$moduleName), what, startingTag(element));\n      }\n    }\n\n\n    function addTextInterpolateDirective(directives, text) {\n      var interpolateFn = $interpolate(text, true);\n      if (interpolateFn) {\n        directives.push({\n          priority: 0,\n          compile: function textInterpolateCompileFn(templateNode) {\n            var templateNodeParent = templateNode.parent(),\n                hasCompileParent = !!templateNodeParent.length;\n\n            // When transcluding a template that has bindings in the root\n            // we don't have a parent and thus need to add the class during linking fn.\n            if (hasCompileParent) compile.$$addBindingClass(templateNodeParent);\n\n            return function textInterpolateLinkFn(scope, node) {\n              var parent = node.parent();\n              if (!hasCompileParent) compile.$$addBindingClass(parent);\n              compile.$$addBindingInfo(parent, interpolateFn.expressions);\n              scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {\n                node[0].nodeValue = value;\n              });\n            };\n          }\n        });\n      }\n    }\n\n\n    function wrapTemplate(type, template) {\n      type = lowercase(type || 'html');\n      switch (type) {\n      case 'svg':\n      case 'math':\n        var wrapper = window.document.createElement('div');\n        wrapper.innerHTML = '<' + type + '>' + template + '</' + type + '>';\n        return wrapper.childNodes[0].childNodes;\n      default:\n        return template;\n      }\n    }\n\n\n    function getTrustedContext(node, attrNormalizedName) {\n      if (attrNormalizedName == \"srcdoc\") {\n        return $sce.HTML;\n      }\n      var tag = nodeName_(node);\n      // maction[xlink:href] can source SVG.  It's not limited to <maction>.\n      if (attrNormalizedName == \"xlinkHref\" ||\n          (tag == \"form\" && attrNormalizedName == \"action\") ||\n          (tag != \"img\" && (attrNormalizedName == \"src\" ||\n                            attrNormalizedName == \"ngSrc\"))) {\n        return $sce.RESOURCE_URL;\n      }\n    }\n\n\n    function addAttrInterpolateDirective(node, directives, value, name, allOrNothing) {\n      var trustedContext = getTrustedContext(node, name);\n      allOrNothing = ALL_OR_NOTHING_ATTRS[name] || allOrNothing;\n\n      var interpolateFn = $interpolate(value, true, trustedContext, allOrNothing);\n\n      // no interpolation found -> ignore\n      if (!interpolateFn) return;\n\n\n      if (name === \"multiple\" && nodeName_(node) === \"select\") {\n        throw $compileMinErr(\"selmulti\",\n            \"Binding to the 'multiple' attribute is not supported. Element: {0}\",\n            startingTag(node));\n      }\n\n      directives.push({\n        priority: 100,\n        compile: function() {\n            return {\n              pre: function attrInterpolatePreLinkFn(scope, element, attr) {\n                var $$observers = (attr.$$observers || (attr.$$observers = createMap()));\n\n                if (EVENT_HANDLER_ATTR_REGEXP.test(name)) {\n                  throw $compileMinErr('nodomevents',\n                      \"Interpolations for HTML DOM event attributes are disallowed.  Please use the \" +\n                          \"ng- versions (such as ng-click instead of onclick) instead.\");\n                }\n\n                // If the attribute has changed since last $interpolate()ed\n                var newValue = attr[name];\n                if (newValue !== value) {\n                  // we need to interpolate again since the attribute value has been updated\n                  // (e.g. by another directive's compile function)\n                  // ensure unset/empty values make interpolateFn falsy\n                  interpolateFn = newValue && $interpolate(newValue, true, trustedContext, allOrNothing);\n                  value = newValue;\n                }\n\n                // if attribute was updated so that there is no interpolation going on we don't want to\n                // register any observers\n                if (!interpolateFn) return;\n\n                // initialize attr object so that it's ready in case we need the value for isolate\n                // scope initialization, otherwise the value would not be available from isolate\n                // directive's linking fn during linking phase\n                attr[name] = interpolateFn(scope);\n\n                ($$observers[name] || ($$observers[name] = [])).$$inter = true;\n                (attr.$$observers && attr.$$observers[name].$$scope || scope).\n                  $watch(interpolateFn, function interpolateFnWatchAction(newValue, oldValue) {\n                    //special case for class attribute addition + removal\n                    //so that class changes can tap into the animation\n                    //hooks provided by the $animate service. Be sure to\n                    //skip animations when the first digest occurs (when\n                    //both the new and the old values are the same) since\n                    //the CSS classes are the non-interpolated values\n                    if (name === 'class' && newValue != oldValue) {\n                      attr.$updateClass(newValue, oldValue);\n                    } else {\n                      attr.$set(name, newValue);\n                    }\n                  });\n              }\n            };\n          }\n      });\n    }\n\n\n    /**\n     * This is a special jqLite.replaceWith, which can replace items which\n     * have no parents, provided that the containing jqLite collection is provided.\n     *\n     * @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes\n     *                               in the root of the tree.\n     * @param {JqLite} elementsToRemove The jqLite element which we are going to replace. We keep\n     *                                  the shell, but replace its DOM node reference.\n     * @param {Node} newNode The new DOM node.\n     */\n    function replaceWith($rootElement, elementsToRemove, newNode) {\n      var firstElementToRemove = elementsToRemove[0],\n          removeCount = elementsToRemove.length,\n          parent = firstElementToRemove.parentNode,\n          i, ii;\n\n      if ($rootElement) {\n        for (i = 0, ii = $rootElement.length; i < ii; i++) {\n          if ($rootElement[i] == firstElementToRemove) {\n            $rootElement[i++] = newNode;\n            for (var j = i, j2 = j + removeCount - 1,\n                     jj = $rootElement.length;\n                 j < jj; j++, j2++) {\n              if (j2 < jj) {\n                $rootElement[j] = $rootElement[j2];\n              } else {\n                delete $rootElement[j];\n              }\n            }\n            $rootElement.length -= removeCount - 1;\n\n            // If the replaced element is also the jQuery .context then replace it\n            // .context is a deprecated jQuery api, so we should set it only when jQuery set it\n            // http://api.jquery.com/context/\n            if ($rootElement.context === firstElementToRemove) {\n              $rootElement.context = newNode;\n            }\n            break;\n          }\n        }\n      }\n\n      if (parent) {\n        parent.replaceChild(newNode, firstElementToRemove);\n      }\n\n      // Append all the `elementsToRemove` to a fragment. This will...\n      // - remove them from the DOM\n      // - allow them to still be traversed with .nextSibling\n      // - allow a single fragment.qSA to fetch all elements being removed\n      var fragment = window.document.createDocumentFragment();\n      for (i = 0; i < removeCount; i++) {\n        fragment.appendChild(elementsToRemove[i]);\n      }\n\n      if (jqLite.hasData(firstElementToRemove)) {\n        // Copy over user data (that includes Angular's $scope etc.). Don't copy private\n        // data here because there's no public interface in jQuery to do that and copying over\n        // event listeners (which is the main use of private data) wouldn't work anyway.\n        jqLite.data(newNode, jqLite.data(firstElementToRemove));\n\n        // Remove $destroy event listeners from `firstElementToRemove`\n        jqLite(firstElementToRemove).off('$destroy');\n      }\n\n      // Cleanup any data/listeners on the elements and children.\n      // This includes invoking the $destroy event on any elements with listeners.\n      jqLite.cleanData(fragment.querySelectorAll('*'));\n\n      // Update the jqLite collection to only contain the `newNode`\n      for (i = 1; i < removeCount; i++) {\n        delete elementsToRemove[i];\n      }\n      elementsToRemove[0] = newNode;\n      elementsToRemove.length = 1;\n    }\n\n\n    function cloneAndAnnotateFn(fn, annotation) {\n      return extend(function() { return fn.apply(null, arguments); }, fn, annotation);\n    }\n\n\n    function invokeLinkFn(linkFn, scope, $element, attrs, controllers, transcludeFn) {\n      try {\n        linkFn(scope, $element, attrs, controllers, transcludeFn);\n      } catch (e) {\n        $exceptionHandler(e, startingTag($element));\n      }\n    }\n\n\n    // Set up $watches for isolate scope and controller bindings. This process\n    // only occurs for isolate scopes and new scopes with controllerAs.\n    function initializeDirectiveBindings(scope, attrs, destination, bindings, directive) {\n      var removeWatchCollection = [];\n      var initialChanges = {};\n      var changes;\n      forEach(bindings, function initializeBinding(definition, scopeName) {\n        var attrName = definition.attrName,\n        optional = definition.optional,\n        mode = definition.mode, // @, =, or &\n        lastValue,\n        parentGet, parentSet, compare, removeWatch;\n\n        switch (mode) {\n\n          case '@':\n            if (!optional && !hasOwnProperty.call(attrs, attrName)) {\n              destination[scopeName] = attrs[attrName] = void 0;\n            }\n            attrs.$observe(attrName, function(value) {\n              if (isString(value) || isBoolean(value)) {\n                var oldValue = destination[scopeName];\n                recordChanges(scopeName, value, oldValue);\n                destination[scopeName] = value;\n              }\n            });\n            attrs.$$observers[attrName].$$scope = scope;\n            lastValue = attrs[attrName];\n            if (isString(lastValue)) {\n              // If the attribute has been provided then we trigger an interpolation to ensure\n              // the value is there for use in the link fn\n              destination[scopeName] = $interpolate(lastValue)(scope);\n            } else if (isBoolean(lastValue)) {\n              // If the attributes is one of the BOOLEAN_ATTR then Angular will have converted\n              // the value to boolean rather than a string, so we special case this situation\n              destination[scopeName] = lastValue;\n            }\n            initialChanges[scopeName] = new SimpleChange(_UNINITIALIZED_VALUE, destination[scopeName]);\n            break;\n\n          case '=':\n            if (!hasOwnProperty.call(attrs, attrName)) {\n              if (optional) break;\n              attrs[attrName] = void 0;\n            }\n            if (optional && !attrs[attrName]) break;\n\n            parentGet = $parse(attrs[attrName]);\n            if (parentGet.literal) {\n              compare = equals;\n            } else {\n              compare = function simpleCompare(a, b) { return a === b || (a !== a && b !== b); };\n            }\n            parentSet = parentGet.assign || function() {\n              // reset the change, or we will throw this exception on every $digest\n              lastValue = destination[scopeName] = parentGet(scope);\n              throw $compileMinErr('nonassign',\n                  \"Expression '{0}' in attribute '{1}' used with directive '{2}' is non-assignable!\",\n                  attrs[attrName], attrName, directive.name);\n            };\n            lastValue = destination[scopeName] = parentGet(scope);\n            var parentValueWatch = function parentValueWatch(parentValue) {\n              if (!compare(parentValue, destination[scopeName])) {\n                // we are out of sync and need to copy\n                if (!compare(parentValue, lastValue)) {\n                  // parent changed and it has precedence\n                  destination[scopeName] = parentValue;\n                } else {\n                  // if the parent can be assigned then do so\n                  parentSet(scope, parentValue = destination[scopeName]);\n                }\n              }\n              return lastValue = parentValue;\n            };\n            parentValueWatch.$stateful = true;\n            if (definition.collection) {\n              removeWatch = scope.$watchCollection(attrs[attrName], parentValueWatch);\n            } else {\n              removeWatch = scope.$watch($parse(attrs[attrName], parentValueWatch), null, parentGet.literal);\n            }\n            removeWatchCollection.push(removeWatch);\n            break;\n\n          case '<':\n            if (!hasOwnProperty.call(attrs, attrName)) {\n              if (optional) break;\n              attrs[attrName] = void 0;\n            }\n            if (optional && !attrs[attrName]) break;\n\n            parentGet = $parse(attrs[attrName]);\n\n            destination[scopeName] = parentGet(scope);\n            initialChanges[scopeName] = new SimpleChange(_UNINITIALIZED_VALUE, destination[scopeName]);\n\n            removeWatch = scope.$watch(parentGet, function parentValueWatchAction(newValue, oldValue) {\n              if (newValue === oldValue) {\n                // If the new and old values are identical then this is the first time the watch has been triggered\n                // So instead we use the current value on the destination as the old value\n                oldValue = destination[scopeName];\n              }\n              recordChanges(scopeName, newValue, oldValue);\n              destination[scopeName] = newValue;\n            }, parentGet.literal);\n\n            removeWatchCollection.push(removeWatch);\n            break;\n\n          case '&':\n            // Don't assign Object.prototype method to scope\n            parentGet = attrs.hasOwnProperty(attrName) ? $parse(attrs[attrName]) : noop;\n\n            // Don't assign noop to destination if expression is not valid\n            if (parentGet === noop && optional) break;\n\n            destination[scopeName] = function(locals) {\n              return parentGet(scope, locals);\n            };\n            break;\n        }\n      });\n\n      function recordChanges(key, currentValue, previousValue) {\n        if (isFunction(destination.$onChanges) && currentValue !== previousValue) {\n          // If we have not already scheduled the top level onChangesQueue handler then do so now\n          if (!onChangesQueue) {\n            scope.$$postDigest(flushOnChangesQueue);\n            onChangesQueue = [];\n          }\n          // If we have not already queued a trigger of onChanges for this controller then do so now\n          if (!changes) {\n            changes = {};\n            onChangesQueue.push(triggerOnChangesHook);\n          }\n          // If the has been a change on this property already then we need to reuse the previous value\n          if (changes[key]) {\n            previousValue = changes[key].previousValue;\n          }\n          // Store this change\n          changes[key] = new SimpleChange(previousValue, currentValue);\n        }\n      }\n\n      function triggerOnChangesHook() {\n        destination.$onChanges(changes);\n        // Now clear the changes so that we schedule onChanges when more changes arrive\n        changes = undefined;\n      }\n\n      return {\n        initialChanges: initialChanges,\n        removeWatches: removeWatchCollection.length && function removeWatches() {\n          for (var i = 0, ii = removeWatchCollection.length; i < ii; ++i) {\n            removeWatchCollection[i]();\n          }\n        }\n      };\n    }\n  }];\n}\n\nfunction SimpleChange(previous, current) {\n  this.previousValue = previous;\n  this.currentValue = current;\n}\nSimpleChange.prototype.isFirstChange = function() { return this.previousValue === _UNINITIALIZED_VALUE; };\n\n\nvar PREFIX_REGEXP = /^((?:x|data)[\\:\\-_])/i;\n/**\n * Converts all accepted directives format into proper directive name.\n * @param name Name to normalize\n */\nfunction directiveNormalize(name) {\n  return camelCase(name.replace(PREFIX_REGEXP, ''));\n}\n\n/**\n * @ngdoc type\n * @name $compile.directive.Attributes\n *\n * @description\n * A shared object between directive compile / linking functions which contains normalized DOM\n * element attributes. The values reflect current binding state `{{ }}`. The normalization is\n * needed since all of these are treated as equivalent in Angular:\n *\n * ```\n *    <span ng:bind=\"a\" ng-bind=\"a\" data-ng-bind=\"a\" x-ng-bind=\"a\">\n * ```\n */\n\n/**\n * @ngdoc property\n * @name $compile.directive.Attributes#$attr\n *\n * @description\n * A map of DOM element attribute names to the normalized name. This is\n * needed to do reverse lookup from normalized name back to actual name.\n */\n\n\n/**\n * @ngdoc method\n * @name $compile.directive.Attributes#$set\n * @kind function\n *\n * @description\n * Set DOM element attribute value.\n *\n *\n * @param {string} name Normalized element attribute name of the property to modify. The name is\n *          reverse-translated using the {@link ng.$compile.directive.Attributes#$attr $attr}\n *          property to the original name.\n * @param {string} value Value to set the attribute to. The value can be an interpolated string.\n */\n\n\n\n/**\n * Closure compiler type information\n */\n\nfunction nodesetLinkingFn(\n  /* angular.Scope */ scope,\n  /* NodeList */ nodeList,\n  /* Element */ rootElement,\n  /* function(Function) */ boundTranscludeFn\n) {}\n\nfunction directiveLinkingFn(\n  /* nodesetLinkingFn */ nodesetLinkingFn,\n  /* angular.Scope */ scope,\n  /* Node */ node,\n  /* Element */ rootElement,\n  /* function(Function) */ boundTranscludeFn\n) {}\n\nfunction tokenDifference(str1, str2) {\n  var values = '',\n      tokens1 = str1.split(/\\s+/),\n      tokens2 = str2.split(/\\s+/);\n\n  outer:\n  for (var i = 0; i < tokens1.length; i++) {\n    var token = tokens1[i];\n    for (var j = 0; j < tokens2.length; j++) {\n      if (token == tokens2[j]) continue outer;\n    }\n    values += (values.length > 0 ? ' ' : '') + token;\n  }\n  return values;\n}\n\nfunction removeComments(jqNodes) {\n  jqNodes = jqLite(jqNodes);\n  var i = jqNodes.length;\n\n  if (i <= 1) {\n    return jqNodes;\n  }\n\n  while (i--) {\n    var node = jqNodes[i];\n    if (node.nodeType === NODE_TYPE_COMMENT) {\n      splice.call(jqNodes, i, 1);\n    }\n  }\n  return jqNodes;\n}\n\nvar $controllerMinErr = minErr('$controller');\n\n\nvar CNTRL_REG = /^(\\S+)(\\s+as\\s+([\\w$]+))?$/;\nfunction identifierForController(controller, ident) {\n  if (ident && isString(ident)) return ident;\n  if (isString(controller)) {\n    var match = CNTRL_REG.exec(controller);\n    if (match) return match[3];\n  }\n}\n\n\n/**\n * @ngdoc provider\n * @name $controllerProvider\n * @description\n * The {@link ng.$controller $controller service} is used by Angular to create new\n * controllers.\n *\n * This provider allows controller registration via the\n * {@link ng.$controllerProvider#register register} method.\n */\nfunction $ControllerProvider() {\n  var controllers = {},\n      globals = false;\n\n  /**\n   * @ngdoc method\n   * @name $controllerProvider#has\n   * @param {string} name Controller name to check.\n   */\n  this.has = function(name) {\n    return controllers.hasOwnProperty(name);\n  };\n\n  /**\n   * @ngdoc method\n   * @name $controllerProvider#register\n   * @param {string|Object} name Controller name, or an object map of controllers where the keys are\n   *    the names and the values are the constructors.\n   * @param {Function|Array} constructor Controller constructor fn (optionally decorated with DI\n   *    annotations in the array notation).\n   */\n  this.register = function(name, constructor) {\n    assertNotHasOwnProperty(name, 'controller');\n    if (isObject(name)) {\n      extend(controllers, name);\n    } else {\n      controllers[name] = constructor;\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name $controllerProvider#allowGlobals\n   * @description If called, allows `$controller` to find controller constructors on `window`\n   */\n  this.allowGlobals = function() {\n    globals = true;\n  };\n\n\n  this.$get = ['$injector', '$window', function($injector, $window) {\n\n    /**\n     * @ngdoc service\n     * @name $controller\n     * @requires $injector\n     *\n     * @param {Function|string} constructor If called with a function then it's considered to be the\n     *    controller constructor function. Otherwise it's considered to be a string which is used\n     *    to retrieve the controller constructor using the following steps:\n     *\n     *    * check if a controller with given name is registered via `$controllerProvider`\n     *    * check if evaluating the string on the current scope returns a constructor\n     *    * if $controllerProvider#allowGlobals, check `window[constructor]` on the global\n     *      `window` object (not recommended)\n     *\n     *    The string can use the `controller as property` syntax, where the controller instance is published\n     *    as the specified property on the `scope`; the `scope` must be injected into `locals` param for this\n     *    to work correctly.\n     *\n     * @param {Object} locals Injection locals for Controller.\n     * @return {Object} Instance of given controller.\n     *\n     * @description\n     * `$controller` service is responsible for instantiating controllers.\n     *\n     * It's just a simple call to {@link auto.$injector $injector}, but extracted into\n     * a service, so that one can override this service with [BC version](https://gist.github.com/1649788).\n     */\n    return function $controller(expression, locals, later, ident) {\n      // PRIVATE API:\n      //   param `later` --- indicates that the controller's constructor is invoked at a later time.\n      //                     If true, $controller will allocate the object with the correct\n      //                     prototype chain, but will not invoke the controller until a returned\n      //                     callback is invoked.\n      //   param `ident` --- An optional label which overrides the label parsed from the controller\n      //                     expression, if any.\n      var instance, match, constructor, identifier;\n      later = later === true;\n      if (ident && isString(ident)) {\n        identifier = ident;\n      }\n\n      if (isString(expression)) {\n        match = expression.match(CNTRL_REG);\n        if (!match) {\n          throw $controllerMinErr('ctrlfmt',\n            \"Badly formed controller string '{0}'. \" +\n            \"Must match `__name__ as __id__` or `__name__`.\", expression);\n        }\n        constructor = match[1],\n        identifier = identifier || match[3];\n        expression = controllers.hasOwnProperty(constructor)\n            ? controllers[constructor]\n            : getter(locals.$scope, constructor, true) ||\n                (globals ? getter($window, constructor, true) : undefined);\n\n        assertArgFn(expression, constructor, true);\n      }\n\n      if (later) {\n        // Instantiate controller later:\n        // This machinery is used to create an instance of the object before calling the\n        // controller's constructor itself.\n        //\n        // This allows properties to be added to the controller before the constructor is\n        // invoked. Primarily, this is used for isolate scope bindings in $compile.\n        //\n        // This feature is not intended for use by applications, and is thus not documented\n        // publicly.\n        // Object creation: http://jsperf.com/create-constructor/2\n        var controllerPrototype = (isArray(expression) ?\n          expression[expression.length - 1] : expression).prototype;\n        instance = Object.create(controllerPrototype || null);\n\n        if (identifier) {\n          addIdentifier(locals, identifier, instance, constructor || expression.name);\n        }\n\n        var instantiate;\n        return instantiate = extend(function $controllerInit() {\n          var result = $injector.invoke(expression, instance, locals, constructor);\n          if (result !== instance && (isObject(result) || isFunction(result))) {\n            instance = result;\n            if (identifier) {\n              // If result changed, re-assign controllerAs value to scope.\n              addIdentifier(locals, identifier, instance, constructor || expression.name);\n            }\n          }\n          return instance;\n        }, {\n          instance: instance,\n          identifier: identifier\n        });\n      }\n\n      instance = $injector.instantiate(expression, locals, constructor);\n\n      if (identifier) {\n        addIdentifier(locals, identifier, instance, constructor || expression.name);\n      }\n\n      return instance;\n    };\n\n    function addIdentifier(locals, identifier, instance, name) {\n      if (!(locals && isObject(locals.$scope))) {\n        throw minErr('$controller')('noscp',\n          \"Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.\",\n          name, identifier);\n      }\n\n      locals.$scope[identifier] = instance;\n    }\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $document\n * @requires $window\n *\n * @description\n * A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object.\n *\n * @example\n   <example module=\"documentExample\">\n     <file name=\"index.html\">\n       <div ng-controller=\"ExampleController\">\n         <p>$document title: <b ng-bind=\"title\"></b></p>\n         <p>window.document title: <b ng-bind=\"windowTitle\"></b></p>\n       </div>\n     </file>\n     <file name=\"script.js\">\n       angular.module('documentExample', [])\n         .controller('ExampleController', ['$scope', '$document', function($scope, $document) {\n           $scope.title = $document[0].title;\n           $scope.windowTitle = angular.element(window.document)[0].title;\n         }]);\n     </file>\n   </example>\n */\nfunction $DocumentProvider() {\n  this.$get = ['$window', function(window) {\n    return jqLite(window.document);\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $exceptionHandler\n * @requires ng.$log\n *\n * @description\n * Any uncaught exception in angular expressions is delegated to this service.\n * The default implementation simply delegates to `$log.error` which logs it into\n * the browser console.\n *\n * In unit tests, if `angular-mocks.js` is loaded, this service is overridden by\n * {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.\n *\n * ## Example:\n *\n * ```js\n *   angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {\n *     return function(exception, cause) {\n *       exception.message += ' (caused by \"' + cause + '\")';\n *       throw exception;\n *     };\n *   });\n * ```\n *\n * This example will override the normal action of `$exceptionHandler`, to make angular\n * exceptions fail hard when they happen, instead of just logging to the console.\n *\n * <hr />\n * Note, that code executed in event-listeners (even those registered using jqLite's `on`/`bind`\n * methods) does not delegate exceptions to the {@link ng.$exceptionHandler $exceptionHandler}\n * (unless executed during a digest).\n *\n * If you wish, you can manually delegate exceptions, e.g.\n * `try { ... } catch(e) { $exceptionHandler(e); }`\n *\n * @param {Error} exception Exception associated with the error.\n * @param {string=} cause optional information about the context in which\n *       the error was thrown.\n *\n */\nfunction $ExceptionHandlerProvider() {\n  this.$get = ['$log', function($log) {\n    return function(exception, cause) {\n      $log.error.apply($log, arguments);\n    };\n  }];\n}\n\nvar $$ForceReflowProvider = function() {\n  this.$get = ['$document', function($document) {\n    return function(domNode) {\n      //the line below will force the browser to perform a repaint so\n      //that all the animated elements within the animation frame will\n      //be properly updated and drawn on screen. This is required to\n      //ensure that the preparation animation is properly flushed so that\n      //the active state picks up from there. DO NOT REMOVE THIS LINE.\n      //DO NOT OPTIMIZE THIS LINE. THE MINIFIER WILL REMOVE IT OTHERWISE WHICH\n      //WILL RESULT IN AN UNPREDICTABLE BUG THAT IS VERY HARD TO TRACK DOWN AND\n      //WILL TAKE YEARS AWAY FROM YOUR LIFE.\n      if (domNode) {\n        if (!domNode.nodeType && domNode instanceof jqLite) {\n          domNode = domNode[0];\n        }\n      } else {\n        domNode = $document[0].body;\n      }\n      return domNode.offsetWidth + 1;\n    };\n  }];\n};\n\nvar APPLICATION_JSON = 'application/json';\nvar CONTENT_TYPE_APPLICATION_JSON = {'Content-Type': APPLICATION_JSON + ';charset=utf-8'};\nvar JSON_START = /^\\[|^\\{(?!\\{)/;\nvar JSON_ENDS = {\n  '[': /]$/,\n  '{': /}$/\n};\nvar JSON_PROTECTION_PREFIX = /^\\)\\]\\}',?\\n/;\nvar $httpMinErr = minErr('$http');\nvar $httpMinErrLegacyFn = function(method) {\n  return function() {\n    throw $httpMinErr('legacy', 'The method `{0}` on the promise returned from `$http` has been disabled.', method);\n  };\n};\n\nfunction serializeValue(v) {\n  if (isObject(v)) {\n    return isDate(v) ? v.toISOString() : toJson(v);\n  }\n  return v;\n}\n\n\nfunction $HttpParamSerializerProvider() {\n  /**\n   * @ngdoc service\n   * @name $httpParamSerializer\n   * @description\n   *\n   * Default {@link $http `$http`} params serializer that converts objects to strings\n   * according to the following rules:\n   *\n   * * `{'foo': 'bar'}` results in `foo=bar`\n   * * `{'foo': Date.now()}` results in `foo=2015-04-01T09%3A50%3A49.262Z` (`toISOString()` and encoded representation of a Date object)\n   * * `{'foo': ['bar', 'baz']}` results in `foo=bar&foo=baz` (repeated key for each array element)\n   * * `{'foo': {'bar':'baz'}}` results in `foo=%7B%22bar%22%3A%22baz%22%7D\"` (stringified and encoded representation of an object)\n   *\n   * Note that serializer will sort the request parameters alphabetically.\n   * */\n\n  this.$get = function() {\n    return function ngParamSerializer(params) {\n      if (!params) return '';\n      var parts = [];\n      forEachSorted(params, function(value, key) {\n        if (value === null || isUndefined(value)) return;\n        if (isArray(value)) {\n          forEach(value, function(v) {\n            parts.push(encodeUriQuery(key)  + '=' + encodeUriQuery(serializeValue(v)));\n          });\n        } else {\n          parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(value)));\n        }\n      });\n\n      return parts.join('&');\n    };\n  };\n}\n\nfunction $HttpParamSerializerJQLikeProvider() {\n  /**\n   * @ngdoc service\n   * @name $httpParamSerializerJQLike\n   * @description\n   *\n   * Alternative {@link $http `$http`} params serializer that follows\n   * jQuery's [`param()`](http://api.jquery.com/jquery.param/) method logic.\n   * The serializer will also sort the params alphabetically.\n   *\n   * To use it for serializing `$http` request parameters, set it as the `paramSerializer` property:\n   *\n   * ```js\n   * $http({\n   *   url: myUrl,\n   *   method: 'GET',\n   *   params: myParams,\n   *   paramSerializer: '$httpParamSerializerJQLike'\n   * });\n   * ```\n   *\n   * It is also possible to set it as the default `paramSerializer` in the\n   * {@link $httpProvider#defaults `$httpProvider`}.\n   *\n   * Additionally, you can inject the serializer and use it explicitly, for example to serialize\n   * form data for submission:\n   *\n   * ```js\n   * .controller(function($http, $httpParamSerializerJQLike) {\n   *   //...\n   *\n   *   $http({\n   *     url: myUrl,\n   *     method: 'POST',\n   *     data: $httpParamSerializerJQLike(myData),\n   *     headers: {\n   *       'Content-Type': 'application/x-www-form-urlencoded'\n   *     }\n   *   });\n   *\n   * });\n   * ```\n   *\n   * */\n  this.$get = function() {\n    return function jQueryLikeParamSerializer(params) {\n      if (!params) return '';\n      var parts = [];\n      serialize(params, '', true);\n      return parts.join('&');\n\n      function serialize(toSerialize, prefix, topLevel) {\n        if (toSerialize === null || isUndefined(toSerialize)) return;\n        if (isArray(toSerialize)) {\n          forEach(toSerialize, function(value, index) {\n            serialize(value, prefix + '[' + (isObject(value) ? index : '') + ']');\n          });\n        } else if (isObject(toSerialize) && !isDate(toSerialize)) {\n          forEachSorted(toSerialize, function(value, key) {\n            serialize(value, prefix +\n                (topLevel ? '' : '[') +\n                key +\n                (topLevel ? '' : ']'));\n          });\n        } else {\n          parts.push(encodeUriQuery(prefix) + '=' + encodeUriQuery(serializeValue(toSerialize)));\n        }\n      }\n    };\n  };\n}\n\nfunction defaultHttpResponseTransform(data, headers) {\n  if (isString(data)) {\n    // Strip json vulnerability protection prefix and trim whitespace\n    var tempData = data.replace(JSON_PROTECTION_PREFIX, '').trim();\n\n    if (tempData) {\n      var contentType = headers('Content-Type');\n      if ((contentType && (contentType.indexOf(APPLICATION_JSON) === 0)) || isJsonLike(tempData)) {\n        data = fromJson(tempData);\n      }\n    }\n  }\n\n  return data;\n}\n\nfunction isJsonLike(str) {\n    var jsonStart = str.match(JSON_START);\n    return jsonStart && JSON_ENDS[jsonStart[0]].test(str);\n}\n\n/**\n * Parse headers into key value object\n *\n * @param {string} headers Raw headers as a string\n * @returns {Object} Parsed headers as key value object\n */\nfunction parseHeaders(headers) {\n  var parsed = createMap(), i;\n\n  function fillInParsed(key, val) {\n    if (key) {\n      parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n    }\n  }\n\n  if (isString(headers)) {\n    forEach(headers.split('\\n'), function(line) {\n      i = line.indexOf(':');\n      fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));\n    });\n  } else if (isObject(headers)) {\n    forEach(headers, function(headerVal, headerKey) {\n      fillInParsed(lowercase(headerKey), trim(headerVal));\n    });\n  }\n\n  return parsed;\n}\n\n\n/**\n * Returns a function that provides access to parsed headers.\n *\n * Headers are lazy parsed when first requested.\n * @see parseHeaders\n *\n * @param {(string|Object)} headers Headers to provide access to.\n * @returns {function(string=)} Returns a getter function which if called with:\n *\n *   - if called with single an argument returns a single header value or null\n *   - if called with no arguments returns an object containing all headers.\n */\nfunction headersGetter(headers) {\n  var headersObj;\n\n  return function(name) {\n    if (!headersObj) headersObj =  parseHeaders(headers);\n\n    if (name) {\n      var value = headersObj[lowercase(name)];\n      if (value === void 0) {\n        value = null;\n      }\n      return value;\n    }\n\n    return headersObj;\n  };\n}\n\n\n/**\n * Chain all given functions\n *\n * This function is used for both request and response transforming\n *\n * @param {*} data Data to transform.\n * @param {function(string=)} headers HTTP headers getter fn.\n * @param {number} status HTTP status code of the response.\n * @param {(Function|Array.<Function>)} fns Function or an array of functions.\n * @returns {*} Transformed data.\n */\nfunction transformData(data, headers, status, fns) {\n  if (isFunction(fns)) {\n    return fns(data, headers, status);\n  }\n\n  forEach(fns, function(fn) {\n    data = fn(data, headers, status);\n  });\n\n  return data;\n}\n\n\nfunction isSuccess(status) {\n  return 200 <= status && status < 300;\n}\n\n\n/**\n * @ngdoc provider\n * @name $httpProvider\n * @description\n * Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service.\n * */\nfunction $HttpProvider() {\n  /**\n   * @ngdoc property\n   * @name $httpProvider#defaults\n   * @description\n   *\n   * Object containing default values for all {@link ng.$http $http} requests.\n   *\n   * - **`defaults.cache`** - {boolean|Object} - A boolean value or object created with\n   * {@link ng.$cacheFactory `$cacheFactory`} to enable or disable caching of HTTP responses\n   * by default. See {@link $http#caching $http Caching} for more information.\n   *\n   * - **`defaults.xsrfCookieName`** - {string} - Name of cookie containing the XSRF token.\n   * Defaults value is `'XSRF-TOKEN'`.\n   *\n   * - **`defaults.xsrfHeaderName`** - {string} - Name of HTTP header to populate with the\n   * XSRF token. Defaults value is `'X-XSRF-TOKEN'`.\n   *\n   * - **`defaults.headers`** - {Object} - Default headers for all $http requests.\n   * Refer to {@link ng.$http#setting-http-headers $http} for documentation on\n   * setting default headers.\n   *     - **`defaults.headers.common`**\n   *     - **`defaults.headers.post`**\n   *     - **`defaults.headers.put`**\n   *     - **`defaults.headers.patch`**\n   *\n   *\n   * - **`defaults.paramSerializer`** - `{string|function(Object<string,string>):string}` - A function\n   *  used to the prepare string representation of request parameters (specified as an object).\n   *  If specified as string, it is interpreted as a function registered with the {@link auto.$injector $injector}.\n   *  Defaults to {@link ng.$httpParamSerializer $httpParamSerializer}.\n   *\n   **/\n  var defaults = this.defaults = {\n    // transform incoming response data\n    transformResponse: [defaultHttpResponseTransform],\n\n    // transform outgoing request data\n    transformRequest: [function(d) {\n      return isObject(d) && !isFile(d) && !isBlob(d) && !isFormData(d) ? toJson(d) : d;\n    }],\n\n    // default headers\n    headers: {\n      common: {\n        'Accept': 'application/json, text/plain, */*'\n      },\n      post:   shallowCopy(CONTENT_TYPE_APPLICATION_JSON),\n      put:    shallowCopy(CONTENT_TYPE_APPLICATION_JSON),\n      patch:  shallowCopy(CONTENT_TYPE_APPLICATION_JSON)\n    },\n\n    xsrfCookieName: 'XSRF-TOKEN',\n    xsrfHeaderName: 'X-XSRF-TOKEN',\n\n    paramSerializer: '$httpParamSerializer'\n  };\n\n  var useApplyAsync = false;\n  /**\n   * @ngdoc method\n   * @name $httpProvider#useApplyAsync\n   * @description\n   *\n   * Configure $http service to combine processing of multiple http responses received at around\n   * the same time via {@link ng.$rootScope.Scope#$applyAsync $rootScope.$applyAsync}. This can result in\n   * significant performance improvement for bigger applications that make many HTTP requests\n   * concurrently (common during application bootstrap).\n   *\n   * Defaults to false. If no value is specified, returns the current configured value.\n   *\n   * @param {boolean=} value If true, when requests are loaded, they will schedule a deferred\n   *    \"apply\" on the next tick, giving time for subsequent requests in a roughly ~10ms window\n   *    to load and share the same digest cycle.\n   *\n   * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining.\n   *    otherwise, returns the current configured value.\n   **/\n  this.useApplyAsync = function(value) {\n    if (isDefined(value)) {\n      useApplyAsync = !!value;\n      return this;\n    }\n    return useApplyAsync;\n  };\n\n  var useLegacyPromise = true;\n  /**\n   * @ngdoc method\n   * @name $httpProvider#useLegacyPromiseExtensions\n   * @description\n   *\n   * Configure `$http` service to return promises without the shorthand methods `success` and `error`.\n   * This should be used to make sure that applications work without these methods.\n   *\n   * Defaults to true. If no value is specified, returns the current configured value.\n   *\n   * @param {boolean=} value If true, `$http` will return a promise with the deprecated legacy `success` and `error` methods.\n   *\n   * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining.\n   *    otherwise, returns the current configured value.\n   **/\n  this.useLegacyPromiseExtensions = function(value) {\n    if (isDefined(value)) {\n      useLegacyPromise = !!value;\n      return this;\n    }\n    return useLegacyPromise;\n  };\n\n  /**\n   * @ngdoc property\n   * @name $httpProvider#interceptors\n   * @description\n   *\n   * Array containing service factories for all synchronous or asynchronous {@link ng.$http $http}\n   * pre-processing of request or postprocessing of responses.\n   *\n   * These service factories are ordered by request, i.e. they are applied in the same order as the\n   * array, on request, but reverse order, on response.\n   *\n   * {@link ng.$http#interceptors Interceptors detailed info}\n   **/\n  var interceptorFactories = this.interceptors = [];\n\n  this.$get = ['$httpBackend', '$$cookieReader', '$cacheFactory', '$rootScope', '$q', '$injector',\n      function($httpBackend, $$cookieReader, $cacheFactory, $rootScope, $q, $injector) {\n\n    var defaultCache = $cacheFactory('$http');\n\n    /**\n     * Make sure that default param serializer is exposed as a function\n     */\n    defaults.paramSerializer = isString(defaults.paramSerializer) ?\n      $injector.get(defaults.paramSerializer) : defaults.paramSerializer;\n\n    /**\n     * Interceptors stored in reverse order. Inner interceptors before outer interceptors.\n     * The reversal is needed so that we can build up the interception chain around the\n     * server request.\n     */\n    var reversedInterceptors = [];\n\n    forEach(interceptorFactories, function(interceptorFactory) {\n      reversedInterceptors.unshift(isString(interceptorFactory)\n          ? $injector.get(interceptorFactory) : $injector.invoke(interceptorFactory));\n    });\n\n    /**\n     * @ngdoc service\n     * @kind function\n     * @name $http\n     * @requires ng.$httpBackend\n     * @requires $cacheFactory\n     * @requires $rootScope\n     * @requires $q\n     * @requires $injector\n     *\n     * @description\n     * The `$http` service is a core Angular service that facilitates communication with the remote\n     * HTTP servers via the browser's [XMLHttpRequest](https://developer.mozilla.org/en/xmlhttprequest)\n     * object or via [JSONP](http://en.wikipedia.org/wiki/JSONP).\n     *\n     * For unit testing applications that use `$http` service, see\n     * {@link ngMock.$httpBackend $httpBackend mock}.\n     *\n     * For a higher level of abstraction, please check out the {@link ngResource.$resource\n     * $resource} service.\n     *\n     * The $http API is based on the {@link ng.$q deferred/promise APIs} exposed by\n     * the $q service. While for simple usage patterns this doesn't matter much, for advanced usage\n     * it is important to familiarize yourself with these APIs and the guarantees they provide.\n     *\n     *\n     * ## General usage\n     * The `$http` service is a function which takes a single argument — a {@link $http#usage configuration object} —\n     * that is used to generate an HTTP request and returns  a {@link ng.$q promise}.\n     *\n     * ```js\n     *   // Simple GET request example:\n     *   $http({\n     *     method: 'GET',\n     *     url: '/someUrl'\n     *   }).then(function successCallback(response) {\n     *       // this callback will be called asynchronously\n     *       // when the response is available\n     *     }, function errorCallback(response) {\n     *       // called asynchronously if an error occurs\n     *       // or server returns response with an error status.\n     *     });\n     * ```\n     *\n     * The response object has these properties:\n     *\n     *   - **data** – `{string|Object}` – The response body transformed with the transform\n     *     functions.\n     *   - **status** – `{number}` – HTTP status code of the response.\n     *   - **headers** – `{function([headerName])}` – Header getter function.\n     *   - **config** – `{Object}` – The configuration object that was used to generate the request.\n     *   - **statusText** – `{string}` – HTTP status text of the response.\n     *\n     * A response status code between 200 and 299 is considered a success status and\n     * will result in the success callback being called. Note that if the response is a redirect,\n     * XMLHttpRequest will transparently follow it, meaning that the error callback will not be\n     * called for such responses.\n     *\n     *\n     * ## Shortcut methods\n     *\n     * Shortcut methods are also available. All shortcut methods require passing in the URL, and\n     * request data must be passed in for POST/PUT requests. An optional config can be passed as the\n     * last argument.\n     *\n     * ```js\n     *   $http.get('/someUrl', config).then(successCallback, errorCallback);\n     *   $http.post('/someUrl', data, config).then(successCallback, errorCallback);\n     * ```\n     *\n     * Complete list of shortcut methods:\n     *\n     * - {@link ng.$http#get $http.get}\n     * - {@link ng.$http#head $http.head}\n     * - {@link ng.$http#post $http.post}\n     * - {@link ng.$http#put $http.put}\n     * - {@link ng.$http#delete $http.delete}\n     * - {@link ng.$http#jsonp $http.jsonp}\n     * - {@link ng.$http#patch $http.patch}\n     *\n     *\n     * ## Writing Unit Tests that use $http\n     * When unit testing (using {@link ngMock ngMock}), it is necessary to call\n     * {@link ngMock.$httpBackend#flush $httpBackend.flush()} to flush each pending\n     * request using trained responses.\n     *\n     * ```\n     * $httpBackend.expectGET(...);\n     * $http.get(...);\n     * $httpBackend.flush();\n     * ```\n     *\n     * ## Deprecation Notice\n     * <div class=\"alert alert-danger\">\n     *   The `$http` legacy promise methods `success` and `error` have been deprecated.\n     *   Use the standard `then` method instead.\n     *   If {@link $httpProvider#useLegacyPromiseExtensions `$httpProvider.useLegacyPromiseExtensions`} is set to\n     *   `false` then these methods will throw {@link $http:legacy `$http/legacy`} error.\n     * </div>\n     *\n     * ## Setting HTTP Headers\n     *\n     * The $http service will automatically add certain HTTP headers to all requests. These defaults\n     * can be fully configured by accessing the `$httpProvider.defaults.headers` configuration\n     * object, which currently contains this default configuration:\n     *\n     * - `$httpProvider.defaults.headers.common` (headers that are common for all requests):\n     *   - `Accept: application/json, text/plain, * / *`\n     * - `$httpProvider.defaults.headers.post`: (header defaults for POST requests)\n     *   - `Content-Type: application/json`\n     * - `$httpProvider.defaults.headers.put` (header defaults for PUT requests)\n     *   - `Content-Type: application/json`\n     *\n     * To add or overwrite these defaults, simply add or remove a property from these configuration\n     * objects. To add headers for an HTTP method other than POST or PUT, simply add a new object\n     * with the lowercased HTTP method name as the key, e.g.\n     * `$httpProvider.defaults.headers.get = { 'My-Header' : 'value' }`.\n     *\n     * The defaults can also be set at runtime via the `$http.defaults` object in the same\n     * fashion. For example:\n     *\n     * ```\n     * module.run(function($http) {\n     *   $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w';\n     * });\n     * ```\n     *\n     * In addition, you can supply a `headers` property in the config object passed when\n     * calling `$http(config)`, which overrides the defaults without changing them globally.\n     *\n     * To explicitly remove a header automatically added via $httpProvider.defaults.headers on a per request basis,\n     * Use the `headers` property, setting the desired header to `undefined`. For example:\n     *\n     * ```js\n     * var req = {\n     *  method: 'POST',\n     *  url: 'http://example.com',\n     *  headers: {\n     *    'Content-Type': undefined\n     *  },\n     *  data: { test: 'test' }\n     * }\n     *\n     * $http(req).then(function(){...}, function(){...});\n     * ```\n     *\n     * ## Transforming Requests and Responses\n     *\n     * Both requests and responses can be transformed using transformation functions: `transformRequest`\n     * and `transformResponse`. These properties can be a single function that returns\n     * the transformed value (`function(data, headersGetter, status)`) or an array of such transformation functions,\n     * which allows you to `push` or `unshift` a new transformation function into the transformation chain.\n     *\n     * <div class=\"alert alert-warning\">\n     * **Note:** Angular does not make a copy of the `data` parameter before it is passed into the `transformRequest` pipeline.\n     * That means changes to the properties of `data` are not local to the transform function (since Javascript passes objects by reference).\n     * For example, when calling `$http.get(url, $scope.myObject)`, modifications to the object's properties in a transformRequest\n     * function will be reflected on the scope and in any templates where the object is data-bound.\n     * To prevent this, transform functions should have no side-effects.\n     * If you need to modify properties, it is recommended to make a copy of the data, or create new object to return.\n     * </div>\n     *\n     * ### Default Transformations\n     *\n     * The `$httpProvider` provider and `$http` service expose `defaults.transformRequest` and\n     * `defaults.transformResponse` properties. If a request does not provide its own transformations\n     * then these will be applied.\n     *\n     * You can augment or replace the default transformations by modifying these properties by adding to or\n     * replacing the array.\n     *\n     * Angular provides the following default transformations:\n     *\n     * Request transformations (`$httpProvider.defaults.transformRequest` and `$http.defaults.transformRequest`):\n     *\n     * - If the `data` property of the request configuration object contains an object, serialize it\n     *   into JSON format.\n     *\n     * Response transformations (`$httpProvider.defaults.transformResponse` and `$http.defaults.transformResponse`):\n     *\n     *  - If XSRF prefix is detected, strip it (see Security Considerations section below).\n     *  - If JSON response is detected, deserialize it using a JSON parser.\n     *\n     *\n     * ### Overriding the Default Transformations Per Request\n     *\n     * If you wish override the request/response transformations only for a single request then provide\n     * `transformRequest` and/or `transformResponse` properties on the configuration object passed\n     * into `$http`.\n     *\n     * Note that if you provide these properties on the config object the default transformations will be\n     * overwritten. If you wish to augment the default transformations then you must include them in your\n     * local transformation array.\n     *\n     * The following code demonstrates adding a new response transformation to be run after the default response\n     * transformations have been run.\n     *\n     * ```js\n     * function appendTransform(defaults, transform) {\n     *\n     *   // We can't guarantee that the default transformation is an array\n     *   defaults = angular.isArray(defaults) ? defaults : [defaults];\n     *\n     *   // Append the new transformation to the defaults\n     *   return defaults.concat(transform);\n     * }\n     *\n     * $http({\n     *   url: '...',\n     *   method: 'GET',\n     *   transformResponse: appendTransform($http.defaults.transformResponse, function(value) {\n     *     return doTransform(value);\n     *   })\n     * });\n     * ```\n     *\n     *\n     * ## Caching\n     *\n     * {@link ng.$http `$http`} responses are not cached by default. To enable caching, you must\n     * set the config.cache value or the default cache value to TRUE or to a cache object (created\n     * with {@link ng.$cacheFactory `$cacheFactory`}). If defined, the value of config.cache takes\n     * precedence over the default cache value.\n     *\n     * In order to:\n     *   * cache all responses - set the default cache value to TRUE or to a cache object\n     *   * cache a specific response - set config.cache value to TRUE or to a cache object\n     *\n     * If caching is enabled, but neither the default cache nor config.cache are set to a cache object,\n     * then the default `$cacheFactory($http)` object is used.\n     *\n     * The default cache value can be set by updating the\n     * {@link ng.$http#defaults `$http.defaults.cache`} property or the\n     * {@link $httpProvider#defaults `$httpProvider.defaults.cache`} property.\n     *\n     * When caching is enabled, {@link ng.$http `$http`} stores the response from the server using\n     * the relevant cache object. The next time the same request is made, the response is returned\n     * from the cache without sending a request to the server.\n     *\n     * Take note that:\n     *\n     *   * Only GET and JSONP requests are cached.\n     *   * The cache key is the request URL including search parameters; headers are not considered.\n     *   * Cached responses are returned asynchronously, in the same way as responses from the server.\n     *   * If multiple identical requests are made using the same cache, which is not yet populated,\n     *     one request will be made to the server and remaining requests will return the same response.\n     *   * A cache-control header on the response does not affect if or how responses are cached.\n     *\n     *\n     * ## Interceptors\n     *\n     * Before you start creating interceptors, be sure to understand the\n     * {@link ng.$q $q and deferred/promise APIs}.\n     *\n     * For purposes of global error handling, authentication, or any kind of synchronous or\n     * asynchronous pre-processing of request or postprocessing of responses, it is desirable to be\n     * able to intercept requests before they are handed to the server and\n     * responses before they are handed over to the application code that\n     * initiated these requests. The interceptors leverage the {@link ng.$q\n     * promise APIs} to fulfill this need for both synchronous and asynchronous pre-processing.\n     *\n     * The interceptors are service factories that are registered with the `$httpProvider` by\n     * adding them to the `$httpProvider.interceptors` array. The factory is called and\n     * injected with dependencies (if specified) and returns the interceptor.\n     *\n     * There are two kinds of interceptors (and two kinds of rejection interceptors):\n     *\n     *   * `request`: interceptors get called with a http {@link $http#usage config} object. The function is free to\n     *     modify the `config` object or create a new one. The function needs to return the `config`\n     *     object directly, or a promise containing the `config` or a new `config` object.\n     *   * `requestError`: interceptor gets called when a previous interceptor threw an error or\n     *     resolved with a rejection.\n     *   * `response`: interceptors get called with http `response` object. The function is free to\n     *     modify the `response` object or create a new one. The function needs to return the `response`\n     *     object directly, or as a promise containing the `response` or a new `response` object.\n     *   * `responseError`: interceptor gets called when a previous interceptor threw an error or\n     *     resolved with a rejection.\n     *\n     *\n     * ```js\n     *   // register the interceptor as a service\n     *   $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) {\n     *     return {\n     *       // optional method\n     *       'request': function(config) {\n     *         // do something on success\n     *         return config;\n     *       },\n     *\n     *       // optional method\n     *      'requestError': function(rejection) {\n     *         // do something on error\n     *         if (canRecover(rejection)) {\n     *           return responseOrNewPromise\n     *         }\n     *         return $q.reject(rejection);\n     *       },\n     *\n     *\n     *\n     *       // optional method\n     *       'response': function(response) {\n     *         // do something on success\n     *         return response;\n     *       },\n     *\n     *       // optional method\n     *      'responseError': function(rejection) {\n     *         // do something on error\n     *         if (canRecover(rejection)) {\n     *           return responseOrNewPromise\n     *         }\n     *         return $q.reject(rejection);\n     *       }\n     *     };\n     *   });\n     *\n     *   $httpProvider.interceptors.push('myHttpInterceptor');\n     *\n     *\n     *   // alternatively, register the interceptor via an anonymous factory\n     *   $httpProvider.interceptors.push(function($q, dependency1, dependency2) {\n     *     return {\n     *      'request': function(config) {\n     *          // same as above\n     *       },\n     *\n     *       'response': function(response) {\n     *          // same as above\n     *       }\n     *     };\n     *   });\n     * ```\n     *\n     * ## Security Considerations\n     *\n     * When designing web applications, consider security threats from:\n     *\n     * - [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx)\n     * - [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery)\n     *\n     * Both server and the client must cooperate in order to eliminate these threats. Angular comes\n     * pre-configured with strategies that address these issues, but for this to work backend server\n     * cooperation is required.\n     *\n     * ### JSON Vulnerability Protection\n     *\n     * A [JSON vulnerability](http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx)\n     * allows third party website to turn your JSON resource URL into\n     * [JSONP](http://en.wikipedia.org/wiki/JSONP) request under some conditions. To\n     * counter this your server can prefix all JSON requests with following string `\")]}',\\n\"`.\n     * Angular will automatically strip the prefix before processing it as JSON.\n     *\n     * For example if your server needs to return:\n     * ```js\n     * ['one','two']\n     * ```\n     *\n     * which is vulnerable to attack, your server can return:\n     * ```js\n     * )]}',\n     * ['one','two']\n     * ```\n     *\n     * Angular will strip the prefix, before processing the JSON.\n     *\n     *\n     * ### Cross Site Request Forgery (XSRF) Protection\n     *\n     * [XSRF](http://en.wikipedia.org/wiki/Cross-site_request_forgery) is an attack technique by\n     * which the attacker can trick an authenticated user into unknowingly executing actions on your\n     * website. Angular provides a mechanism to counter XSRF. When performing XHR requests, the\n     * $http service reads a token from a cookie (by default, `XSRF-TOKEN`) and sets it as an HTTP\n     * header (`X-XSRF-TOKEN`). Since only JavaScript that runs on your domain could read the\n     * cookie, your server can be assured that the XHR came from JavaScript running on your domain.\n     * The header will not be set for cross-domain requests.\n     *\n     * To take advantage of this, your server needs to set a token in a JavaScript readable session\n     * cookie called `XSRF-TOKEN` on the first HTTP GET request. On subsequent XHR requests the\n     * server can verify that the cookie matches `X-XSRF-TOKEN` HTTP header, and therefore be sure\n     * that only JavaScript running on your domain could have sent the request. The token must be\n     * unique for each user and must be verifiable by the server (to prevent the JavaScript from\n     * making up its own tokens). We recommend that the token is a digest of your site's\n     * authentication cookie with a [salt](https://en.wikipedia.org/wiki/Salt_(cryptography&#41;)\n     * for added security.\n     *\n     * The name of the headers can be specified using the xsrfHeaderName and xsrfCookieName\n     * properties of either $httpProvider.defaults at config-time, $http.defaults at run-time,\n     * or the per-request config object.\n     *\n     * In order to prevent collisions in environments where multiple Angular apps share the\n     * same domain or subdomain, we recommend that each application uses unique cookie name.\n     *\n     * @param {object} config Object describing the request to be made and how it should be\n     *    processed. The object has following properties:\n     *\n     *    - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc)\n     *    - **url** – `{string}` – Absolute or relative URL of the resource that is being requested.\n     *    - **params** – `{Object.<string|Object>}` – Map of strings or objects which will be serialized\n     *      with the `paramSerializer` and appended as GET parameters.\n     *    - **data** – `{string|Object}` – Data to be sent as the request message data.\n     *    - **headers** – `{Object}` – Map of strings or functions which return strings representing\n     *      HTTP headers to send to the server. If the return value of a function is null, the\n     *      header will not be sent. Functions accept a config object as an argument.\n     *    - **eventHandlers** - `{Object}` - Event listeners to be bound to the XMLHttpRequest object.\n     *      To bind events to the XMLHttpRequest upload object, use `uploadEventHandlers`.\n     *      The handler will be called in the context of a `$apply` block.\n     *    - **uploadEventHandlers** - `{Object}` - Event listeners to be bound to the XMLHttpRequest upload\n     *      object. To bind events to the XMLHttpRequest object, use `eventHandlers`.\n     *      The handler will be called in the context of a `$apply` block.\n     *    - **xsrfHeaderName** – `{string}` – Name of HTTP header to populate with the XSRF token.\n     *    - **xsrfCookieName** – `{string}` – Name of cookie containing the XSRF token.\n     *    - **transformRequest** –\n     *      `{function(data, headersGetter)|Array.<function(data, headersGetter)>}` –\n     *      transform function or an array of such functions. The transform function takes the http\n     *      request body and headers and returns its transformed (typically serialized) version.\n     *      See {@link ng.$http#overriding-the-default-transformations-per-request\n     *      Overriding the Default Transformations}\n     *    - **transformResponse** –\n     *      `{function(data, headersGetter, status)|Array.<function(data, headersGetter, status)>}` –\n     *      transform function or an array of such functions. The transform function takes the http\n     *      response body, headers and status and returns its transformed (typically deserialized) version.\n     *      See {@link ng.$http#overriding-the-default-transformations-per-request\n     *      Overriding the Default Transformations}\n     *    - **paramSerializer** - `{string|function(Object<string,string>):string}` - A function used to\n     *      prepare the string representation of request parameters (specified as an object).\n     *      If specified as string, it is interpreted as function registered with the\n     *      {@link $injector $injector}, which means you can create your own serializer\n     *      by registering it as a {@link auto.$provide#service service}.\n     *      The default serializer is the {@link $httpParamSerializer $httpParamSerializer};\n     *      alternatively, you can use the {@link $httpParamSerializerJQLike $httpParamSerializerJQLike}\n     *    - **cache** – `{boolean|Object}` – A boolean value or object created with\n     *      {@link ng.$cacheFactory `$cacheFactory`} to enable or disable caching of the HTTP response.\n     *      See {@link $http#caching $http Caching} for more information.\n     *    - **timeout** – `{number|Promise}` – timeout in milliseconds, or {@link ng.$q promise}\n     *      that should abort the request when resolved.\n     *    - **withCredentials** - `{boolean}` - whether to set the `withCredentials` flag on the\n     *      XHR object. See [requests with credentials](https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS#Requests_with_credentials)\n     *      for more information.\n     *    - **responseType** - `{string}` - see\n     *      [XMLHttpRequest.responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype).\n     *\n     * @returns {HttpPromise} Returns a {@link ng.$q `Promise}` that will be resolved to a response object\n     *                        when the request succeeds or fails.\n     *\n     *\n     * @property {Array.<Object>} pendingRequests Array of config objects for currently pending\n     *   requests. This is primarily meant to be used for debugging purposes.\n     *\n     *\n     * @example\n<example module=\"httpExample\">\n<file name=\"index.html\">\n  <div ng-controller=\"FetchController\">\n    <select ng-model=\"method\" aria-label=\"Request method\">\n      <option>GET</option>\n      <option>JSONP</option>\n    </select>\n    <input type=\"text\" ng-model=\"url\" size=\"80\" aria-label=\"URL\" />\n    <button id=\"fetchbtn\" ng-click=\"fetch()\">fetch</button><br>\n    <button id=\"samplegetbtn\" ng-click=\"updateModel('GET', 'http-hello.html')\">Sample GET</button>\n    <button id=\"samplejsonpbtn\"\n      ng-click=\"updateModel('JSONP',\n                    'https://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero')\">\n      Sample JSONP\n    </button>\n    <button id=\"invalidjsonpbtn\"\n      ng-click=\"updateModel('JSONP', 'https://angularjs.org/doesntexist&callback=JSON_CALLBACK')\">\n        Invalid JSONP\n      </button>\n    <pre>http status code: {{status}}</pre>\n    <pre>http response data: {{data}}</pre>\n  </div>\n</file>\n<file name=\"script.js\">\n  angular.module('httpExample', [])\n    .controller('FetchController', ['$scope', '$http', '$templateCache',\n      function($scope, $http, $templateCache) {\n        $scope.method = 'GET';\n        $scope.url = 'http-hello.html';\n\n        $scope.fetch = function() {\n          $scope.code = null;\n          $scope.response = null;\n\n          $http({method: $scope.method, url: $scope.url, cache: $templateCache}).\n            then(function(response) {\n              $scope.status = response.status;\n              $scope.data = response.data;\n            }, function(response) {\n              $scope.data = response.data || \"Request failed\";\n              $scope.status = response.status;\n          });\n        };\n\n        $scope.updateModel = function(method, url) {\n          $scope.method = method;\n          $scope.url = url;\n        };\n      }]);\n</file>\n<file name=\"http-hello.html\">\n  Hello, $http!\n</file>\n<file name=\"protractor.js\" type=\"protractor\">\n  var status = element(by.binding('status'));\n  var data = element(by.binding('data'));\n  var fetchBtn = element(by.id('fetchbtn'));\n  var sampleGetBtn = element(by.id('samplegetbtn'));\n  var sampleJsonpBtn = element(by.id('samplejsonpbtn'));\n  var invalidJsonpBtn = element(by.id('invalidjsonpbtn'));\n\n  it('should make an xhr GET request', function() {\n    sampleGetBtn.click();\n    fetchBtn.click();\n    expect(status.getText()).toMatch('200');\n    expect(data.getText()).toMatch(/Hello, \\$http!/);\n  });\n\n// Commented out due to flakes. See https://github.com/angular/angular.js/issues/9185\n// it('should make a JSONP request to angularjs.org', function() {\n//   sampleJsonpBtn.click();\n//   fetchBtn.click();\n//   expect(status.getText()).toMatch('200');\n//   expect(data.getText()).toMatch(/Super Hero!/);\n// });\n\n  it('should make JSONP request to invalid URL and invoke the error handler',\n      function() {\n    invalidJsonpBtn.click();\n    fetchBtn.click();\n    expect(status.getText()).toMatch('0');\n    expect(data.getText()).toMatch('Request failed');\n  });\n</file>\n</example>\n     */\n    function $http(requestConfig) {\n\n      if (!isObject(requestConfig)) {\n        throw minErr('$http')('badreq', 'Http request configuration must be an object.  Received: {0}', requestConfig);\n      }\n\n      if (!isString(requestConfig.url)) {\n        throw minErr('$http')('badreq', 'Http request configuration url must be a string.  Received: {0}', requestConfig.url);\n      }\n\n      var config = extend({\n        method: 'get',\n        transformRequest: defaults.transformRequest,\n        transformResponse: defaults.transformResponse,\n        paramSerializer: defaults.paramSerializer\n      }, requestConfig);\n\n      config.headers = mergeHeaders(requestConfig);\n      config.method = uppercase(config.method);\n      config.paramSerializer = isString(config.paramSerializer) ?\n        $injector.get(config.paramSerializer) : config.paramSerializer;\n\n      var serverRequest = function(config) {\n        var headers = config.headers;\n        var reqData = transformData(config.data, headersGetter(headers), undefined, config.transformRequest);\n\n        // strip content-type if data is undefined\n        if (isUndefined(reqData)) {\n          forEach(headers, function(value, header) {\n            if (lowercase(header) === 'content-type') {\n                delete headers[header];\n            }\n          });\n        }\n\n        if (isUndefined(config.withCredentials) && !isUndefined(defaults.withCredentials)) {\n          config.withCredentials = defaults.withCredentials;\n        }\n\n        // send request\n        return sendReq(config, reqData).then(transformResponse, transformResponse);\n      };\n\n      var chain = [serverRequest, undefined];\n      var promise = $q.when(config);\n\n      // apply interceptors\n      forEach(reversedInterceptors, function(interceptor) {\n        if (interceptor.request || interceptor.requestError) {\n          chain.unshift(interceptor.request, interceptor.requestError);\n        }\n        if (interceptor.response || interceptor.responseError) {\n          chain.push(interceptor.response, interceptor.responseError);\n        }\n      });\n\n      while (chain.length) {\n        var thenFn = chain.shift();\n        var rejectFn = chain.shift();\n\n        promise = promise.then(thenFn, rejectFn);\n      }\n\n      if (useLegacyPromise) {\n        promise.success = function(fn) {\n          assertArgFn(fn, 'fn');\n\n          promise.then(function(response) {\n            fn(response.data, response.status, response.headers, config);\n          });\n          return promise;\n        };\n\n        promise.error = function(fn) {\n          assertArgFn(fn, 'fn');\n\n          promise.then(null, function(response) {\n            fn(response.data, response.status, response.headers, config);\n          });\n          return promise;\n        };\n      } else {\n        promise.success = $httpMinErrLegacyFn('success');\n        promise.error = $httpMinErrLegacyFn('error');\n      }\n\n      return promise;\n\n      function transformResponse(response) {\n        // make a copy since the response must be cacheable\n        var resp = extend({}, response);\n        resp.data = transformData(response.data, response.headers, response.status,\n                                  config.transformResponse);\n        return (isSuccess(response.status))\n          ? resp\n          : $q.reject(resp);\n      }\n\n      function executeHeaderFns(headers, config) {\n        var headerContent, processedHeaders = {};\n\n        forEach(headers, function(headerFn, header) {\n          if (isFunction(headerFn)) {\n            headerContent = headerFn(config);\n            if (headerContent != null) {\n              processedHeaders[header] = headerContent;\n            }\n          } else {\n            processedHeaders[header] = headerFn;\n          }\n        });\n\n        return processedHeaders;\n      }\n\n      function mergeHeaders(config) {\n        var defHeaders = defaults.headers,\n            reqHeaders = extend({}, config.headers),\n            defHeaderName, lowercaseDefHeaderName, reqHeaderName;\n\n        defHeaders = extend({}, defHeaders.common, defHeaders[lowercase(config.method)]);\n\n        // using for-in instead of forEach to avoid unnecessary iteration after header has been found\n        defaultHeadersIteration:\n        for (defHeaderName in defHeaders) {\n          lowercaseDefHeaderName = lowercase(defHeaderName);\n\n          for (reqHeaderName in reqHeaders) {\n            if (lowercase(reqHeaderName) === lowercaseDefHeaderName) {\n              continue defaultHeadersIteration;\n            }\n          }\n\n          reqHeaders[defHeaderName] = defHeaders[defHeaderName];\n        }\n\n        // execute if header value is a function for merged headers\n        return executeHeaderFns(reqHeaders, shallowCopy(config));\n      }\n    }\n\n    $http.pendingRequests = [];\n\n    /**\n     * @ngdoc method\n     * @name $http#get\n     *\n     * @description\n     * Shortcut method to perform `GET` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n\n    /**\n     * @ngdoc method\n     * @name $http#delete\n     *\n     * @description\n     * Shortcut method to perform `DELETE` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n\n    /**\n     * @ngdoc method\n     * @name $http#head\n     *\n     * @description\n     * Shortcut method to perform `HEAD` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n\n    /**\n     * @ngdoc method\n     * @name $http#jsonp\n     *\n     * @description\n     * Shortcut method to perform `JSONP` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request.\n     *                     The name of the callback should be the string `JSON_CALLBACK`.\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n    createShortMethods('get', 'delete', 'head', 'jsonp');\n\n    /**\n     * @ngdoc method\n     * @name $http#post\n     *\n     * @description\n     * Shortcut method to perform `POST` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request\n     * @param {*} data Request content\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n\n    /**\n     * @ngdoc method\n     * @name $http#put\n     *\n     * @description\n     * Shortcut method to perform `PUT` request.\n     *\n     * @param {string} url Relative or absolute URL specifying the destination of the request\n     * @param {*} data Request content\n     * @param {Object=} config Optional configuration object\n     * @returns {HttpPromise} Future object\n     */\n\n     /**\n      * @ngdoc method\n      * @name $http#patch\n      *\n      * @description\n      * Shortcut method to perform `PATCH` request.\n      *\n      * @param {string} url Relative or absolute URL specifying the destination of the request\n      * @param {*} data Request content\n      * @param {Object=} config Optional configuration object\n      * @returns {HttpPromise} Future object\n      */\n    createShortMethodsWithData('post', 'put', 'patch');\n\n        /**\n         * @ngdoc property\n         * @name $http#defaults\n         *\n         * @description\n         * Runtime equivalent of the `$httpProvider.defaults` property. Allows configuration of\n         * default headers, withCredentials as well as request and response transformations.\n         *\n         * See \"Setting HTTP Headers\" and \"Transforming Requests and Responses\" sections above.\n         */\n    $http.defaults = defaults;\n\n\n    return $http;\n\n\n    function createShortMethods(names) {\n      forEach(arguments, function(name) {\n        $http[name] = function(url, config) {\n          return $http(extend({}, config || {}, {\n            method: name,\n            url: url\n          }));\n        };\n      });\n    }\n\n\n    function createShortMethodsWithData(name) {\n      forEach(arguments, function(name) {\n        $http[name] = function(url, data, config) {\n          return $http(extend({}, config || {}, {\n            method: name,\n            url: url,\n            data: data\n          }));\n        };\n      });\n    }\n\n\n    /**\n     * Makes the request.\n     *\n     * !!! ACCESSES CLOSURE VARS:\n     * $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests\n     */\n    function sendReq(config, reqData) {\n      var deferred = $q.defer(),\n          promise = deferred.promise,\n          cache,\n          cachedResp,\n          reqHeaders = config.headers,\n          url = buildUrl(config.url, config.paramSerializer(config.params));\n\n      $http.pendingRequests.push(config);\n      promise.then(removePendingReq, removePendingReq);\n\n\n      if ((config.cache || defaults.cache) && config.cache !== false &&\n          (config.method === 'GET' || config.method === 'JSONP')) {\n        cache = isObject(config.cache) ? config.cache\n              : isObject(defaults.cache) ? defaults.cache\n              : defaultCache;\n      }\n\n      if (cache) {\n        cachedResp = cache.get(url);\n        if (isDefined(cachedResp)) {\n          if (isPromiseLike(cachedResp)) {\n            // cached request has already been sent, but there is no response yet\n            cachedResp.then(resolvePromiseWithResult, resolvePromiseWithResult);\n          } else {\n            // serving from cache\n            if (isArray(cachedResp)) {\n              resolvePromise(cachedResp[1], cachedResp[0], shallowCopy(cachedResp[2]), cachedResp[3]);\n            } else {\n              resolvePromise(cachedResp, 200, {}, 'OK');\n            }\n          }\n        } else {\n          // put the promise for the non-transformed response into cache as a placeholder\n          cache.put(url, promise);\n        }\n      }\n\n\n      // if we won't have the response in cache, set the xsrf headers and\n      // send the request to the backend\n      if (isUndefined(cachedResp)) {\n        var xsrfValue = urlIsSameOrigin(config.url)\n            ? $$cookieReader()[config.xsrfCookieName || defaults.xsrfCookieName]\n            : undefined;\n        if (xsrfValue) {\n          reqHeaders[(config.xsrfHeaderName || defaults.xsrfHeaderName)] = xsrfValue;\n        }\n\n        $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,\n            config.withCredentials, config.responseType,\n            createApplyHandlers(config.eventHandlers),\n            createApplyHandlers(config.uploadEventHandlers));\n      }\n\n      return promise;\n\n      function createApplyHandlers(eventHandlers) {\n        if (eventHandlers) {\n          var applyHandlers = {};\n          forEach(eventHandlers, function(eventHandler, key) {\n            applyHandlers[key] = function(event) {\n              if (useApplyAsync) {\n                $rootScope.$applyAsync(callEventHandler);\n              } else if ($rootScope.$$phase) {\n                callEventHandler();\n              } else {\n                $rootScope.$apply(callEventHandler);\n              }\n\n              function callEventHandler() {\n                eventHandler(event);\n              }\n            };\n          });\n          return applyHandlers;\n        }\n      }\n\n\n      /**\n       * Callback registered to $httpBackend():\n       *  - caches the response if desired\n       *  - resolves the raw $http promise\n       *  - calls $apply\n       */\n      function done(status, response, headersString, statusText) {\n        if (cache) {\n          if (isSuccess(status)) {\n            cache.put(url, [status, response, parseHeaders(headersString), statusText]);\n          } else {\n            // remove promise from the cache\n            cache.remove(url);\n          }\n        }\n\n        function resolveHttpPromise() {\n          resolvePromise(response, status, headersString, statusText);\n        }\n\n        if (useApplyAsync) {\n          $rootScope.$applyAsync(resolveHttpPromise);\n        } else {\n          resolveHttpPromise();\n          if (!$rootScope.$$phase) $rootScope.$apply();\n        }\n      }\n\n\n      /**\n       * Resolves the raw $http promise.\n       */\n      function resolvePromise(response, status, headers, statusText) {\n        //status: HTTP response status code, 0, -1 (aborted by timeout / promise)\n        status = status >= -1 ? status : 0;\n\n        (isSuccess(status) ? deferred.resolve : deferred.reject)({\n          data: response,\n          status: status,\n          headers: headersGetter(headers),\n          config: config,\n          statusText: statusText\n        });\n      }\n\n      function resolvePromiseWithResult(result) {\n        resolvePromise(result.data, result.status, shallowCopy(result.headers()), result.statusText);\n      }\n\n      function removePendingReq() {\n        var idx = $http.pendingRequests.indexOf(config);\n        if (idx !== -1) $http.pendingRequests.splice(idx, 1);\n      }\n    }\n\n\n    function buildUrl(url, serializedParams) {\n      if (serializedParams.length > 0) {\n        url += ((url.indexOf('?') == -1) ? '?' : '&') + serializedParams;\n      }\n      return url;\n    }\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $xhrFactory\n *\n * @description\n * Factory function used to create XMLHttpRequest objects.\n *\n * Replace or decorate this service to create your own custom XMLHttpRequest objects.\n *\n * ```\n * angular.module('myApp', [])\n * .factory('$xhrFactory', function() {\n *   return function createXhr(method, url) {\n *     return new window.XMLHttpRequest({mozSystem: true});\n *   };\n * });\n * ```\n *\n * @param {string} method HTTP method of the request (GET, POST, PUT, ..)\n * @param {string} url URL of the request.\n */\nfunction $xhrFactoryProvider() {\n  this.$get = function() {\n    return function createXhr() {\n      return new window.XMLHttpRequest();\n    };\n  };\n}\n\n/**\n * @ngdoc service\n * @name $httpBackend\n * @requires $window\n * @requires $document\n * @requires $xhrFactory\n *\n * @description\n * HTTP backend used by the {@link ng.$http service} that delegates to\n * XMLHttpRequest object or JSONP and deals with browser incompatibilities.\n *\n * You should never need to use this service directly, instead use the higher-level abstractions:\n * {@link ng.$http $http} or {@link ngResource.$resource $resource}.\n *\n * During testing this implementation is swapped with {@link ngMock.$httpBackend mock\n * $httpBackend} which can be trained with responses.\n */\nfunction $HttpBackendProvider() {\n  this.$get = ['$browser', '$window', '$document', '$xhrFactory', function($browser, $window, $document, $xhrFactory) {\n    return createHttpBackend($browser, $xhrFactory, $browser.defer, $window.angular.callbacks, $document[0]);\n  }];\n}\n\nfunction createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) {\n  // TODO(vojta): fix the signature\n  return function(method, url, post, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers) {\n    $browser.$$incOutstandingRequestCount();\n    url = url || $browser.url();\n\n    if (lowercase(method) == 'jsonp') {\n      var callbackId = '_' + (callbacks.counter++).toString(36);\n      callbacks[callbackId] = function(data) {\n        callbacks[callbackId].data = data;\n        callbacks[callbackId].called = true;\n      };\n\n      var jsonpDone = jsonpReq(url.replace('JSON_CALLBACK', 'angular.callbacks.' + callbackId),\n          callbackId, function(status, text) {\n        completeRequest(callback, status, callbacks[callbackId].data, \"\", text);\n        callbacks[callbackId] = noop;\n      });\n    } else {\n\n      var xhr = createXhr(method, url);\n\n      xhr.open(method, url, true);\n      forEach(headers, function(value, key) {\n        if (isDefined(value)) {\n            xhr.setRequestHeader(key, value);\n        }\n      });\n\n      xhr.onload = function requestLoaded() {\n        var statusText = xhr.statusText || '';\n\n        // responseText is the old-school way of retrieving response (supported by IE9)\n        // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)\n        var response = ('response' in xhr) ? xhr.response : xhr.responseText;\n\n        // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)\n        var status = xhr.status === 1223 ? 204 : xhr.status;\n\n        // fix status code when it is 0 (0 status is undocumented).\n        // Occurs when accessing file resources or on Android 4.1 stock browser\n        // while retrieving files from application cache.\n        if (status === 0) {\n          status = response ? 200 : urlResolve(url).protocol == 'file' ? 404 : 0;\n        }\n\n        completeRequest(callback,\n            status,\n            response,\n            xhr.getAllResponseHeaders(),\n            statusText);\n      };\n\n      var requestError = function() {\n        // The response is always empty\n        // See https://xhr.spec.whatwg.org/#request-error-steps and https://fetch.spec.whatwg.org/#concept-network-error\n        completeRequest(callback, -1, null, null, '');\n      };\n\n      xhr.onerror = requestError;\n      xhr.onabort = requestError;\n\n      forEach(eventHandlers, function(value, key) {\n          xhr.addEventListener(key, value);\n      });\n\n      forEach(uploadEventHandlers, function(value, key) {\n        xhr.upload.addEventListener(key, value);\n      });\n\n      if (withCredentials) {\n        xhr.withCredentials = true;\n      }\n\n      if (responseType) {\n        try {\n          xhr.responseType = responseType;\n        } catch (e) {\n          // WebKit added support for the json responseType value on 09/03/2013\n          // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are\n          // known to throw when setting the value \"json\" as the response type. Other older\n          // browsers implementing the responseType\n          //\n          // The json response type can be ignored if not supported, because JSON payloads are\n          // parsed on the client-side regardless.\n          if (responseType !== 'json') {\n            throw e;\n          }\n        }\n      }\n\n      xhr.send(isUndefined(post) ? null : post);\n    }\n\n    if (timeout > 0) {\n      var timeoutId = $browserDefer(timeoutRequest, timeout);\n    } else if (isPromiseLike(timeout)) {\n      timeout.then(timeoutRequest);\n    }\n\n\n    function timeoutRequest() {\n      jsonpDone && jsonpDone();\n      xhr && xhr.abort();\n    }\n\n    function completeRequest(callback, status, response, headersString, statusText) {\n      // cancel timeout and subsequent timeout promise resolution\n      if (isDefined(timeoutId)) {\n        $browserDefer.cancel(timeoutId);\n      }\n      jsonpDone = xhr = null;\n\n      callback(status, response, headersString, statusText);\n      $browser.$$completeOutstandingRequest(noop);\n    }\n  };\n\n  function jsonpReq(url, callbackId, done) {\n    // we can't use jQuery/jqLite here because jQuery does crazy stuff with script elements, e.g.:\n    // - fetches local scripts via XHR and evals them\n    // - adds and immediately removes script elements from the document\n    var script = rawDocument.createElement('script'), callback = null;\n    script.type = \"text/javascript\";\n    script.src = url;\n    script.async = true;\n\n    callback = function(event) {\n      removeEventListenerFn(script, \"load\", callback);\n      removeEventListenerFn(script, \"error\", callback);\n      rawDocument.body.removeChild(script);\n      script = null;\n      var status = -1;\n      var text = \"unknown\";\n\n      if (event) {\n        if (event.type === \"load\" && !callbacks[callbackId].called) {\n          event = { type: \"error\" };\n        }\n        text = event.type;\n        status = event.type === \"error\" ? 404 : 200;\n      }\n\n      if (done) {\n        done(status, text);\n      }\n    };\n\n    addEventListenerFn(script, \"load\", callback);\n    addEventListenerFn(script, \"error\", callback);\n    rawDocument.body.appendChild(script);\n    return callback;\n  }\n}\n\nvar $interpolateMinErr = angular.$interpolateMinErr = minErr('$interpolate');\n$interpolateMinErr.throwNoconcat = function(text) {\n  throw $interpolateMinErr('noconcat',\n      \"Error while interpolating: {0}\\nStrict Contextual Escaping disallows \" +\n      \"interpolations that concatenate multiple expressions when a trusted value is \" +\n      \"required.  See http://docs.angularjs.org/api/ng.$sce\", text);\n};\n\n$interpolateMinErr.interr = function(text, err) {\n  return $interpolateMinErr('interr', \"Can't interpolate: {0}\\n{1}\", text, err.toString());\n};\n\n/**\n * @ngdoc provider\n * @name $interpolateProvider\n *\n * @description\n *\n * Used for configuring the interpolation markup. Defaults to `{{` and `}}`.\n *\n * <div class=\"alert alert-danger\">\n * This feature is sometimes used to mix different markup languages, e.g. to wrap an Angular\n * template within a Python Jinja template (or any other template language). Mixing templating\n * languages is **very dangerous**. The embedding template language will not safely escape Angular\n * expressions, so any user-controlled values in the template will cause Cross Site Scripting (XSS)\n * security bugs!\n * </div>\n *\n * @example\n<example name=\"custom-interpolation-markup\" module=\"customInterpolationApp\">\n<file name=\"index.html\">\n<script>\n  var customInterpolationApp = angular.module('customInterpolationApp', []);\n\n  customInterpolationApp.config(function($interpolateProvider) {\n    $interpolateProvider.startSymbol('//');\n    $interpolateProvider.endSymbol('//');\n  });\n\n\n  customInterpolationApp.controller('DemoController', function() {\n      this.label = \"This binding is brought you by // interpolation symbols.\";\n  });\n</script>\n<div ng-controller=\"DemoController as demo\">\n    //demo.label//\n</div>\n</file>\n<file name=\"protractor.js\" type=\"protractor\">\n  it('should interpolate binding with custom symbols', function() {\n    expect(element(by.binding('demo.label')).getText()).toBe('This binding is brought you by // interpolation symbols.');\n  });\n</file>\n</example>\n */\nfunction $InterpolateProvider() {\n  var startSymbol = '{{';\n  var endSymbol = '}}';\n\n  /**\n   * @ngdoc method\n   * @name $interpolateProvider#startSymbol\n   * @description\n   * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.\n   *\n   * @param {string=} value new value to set the starting symbol to.\n   * @returns {string|self} Returns the symbol when used as getter and self if used as setter.\n   */\n  this.startSymbol = function(value) {\n    if (value) {\n      startSymbol = value;\n      return this;\n    } else {\n      return startSymbol;\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name $interpolateProvider#endSymbol\n   * @description\n   * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.\n   *\n   * @param {string=} value new value to set the ending symbol to.\n   * @returns {string|self} Returns the symbol when used as getter and self if used as setter.\n   */\n  this.endSymbol = function(value) {\n    if (value) {\n      endSymbol = value;\n      return this;\n    } else {\n      return endSymbol;\n    }\n  };\n\n\n  this.$get = ['$parse', '$exceptionHandler', '$sce', function($parse, $exceptionHandler, $sce) {\n    var startSymbolLength = startSymbol.length,\n        endSymbolLength = endSymbol.length,\n        escapedStartRegexp = new RegExp(startSymbol.replace(/./g, escape), 'g'),\n        escapedEndRegexp = new RegExp(endSymbol.replace(/./g, escape), 'g');\n\n    function escape(ch) {\n      return '\\\\\\\\\\\\' + ch;\n    }\n\n    function unescapeText(text) {\n      return text.replace(escapedStartRegexp, startSymbol).\n        replace(escapedEndRegexp, endSymbol);\n    }\n\n    function stringify(value) {\n      if (value == null) { // null || undefined\n        return '';\n      }\n      switch (typeof value) {\n        case 'string':\n          break;\n        case 'number':\n          value = '' + value;\n          break;\n        default:\n          value = toJson(value);\n      }\n\n      return value;\n    }\n\n    //TODO: this is the same as the constantWatchDelegate in parse.js\n    function constantWatchDelegate(scope, listener, objectEquality, constantInterp) {\n      var unwatch;\n      return unwatch = scope.$watch(function constantInterpolateWatch(scope) {\n        unwatch();\n        return constantInterp(scope);\n      }, listener, objectEquality);\n    }\n\n    /**\n     * @ngdoc service\n     * @name $interpolate\n     * @kind function\n     *\n     * @requires $parse\n     * @requires $sce\n     *\n     * @description\n     *\n     * Compiles a string with markup into an interpolation function. This service is used by the\n     * HTML {@link ng.$compile $compile} service for data binding. See\n     * {@link ng.$interpolateProvider $interpolateProvider} for configuring the\n     * interpolation markup.\n     *\n     *\n     * ```js\n     *   var $interpolate = ...; // injected\n     *   var exp = $interpolate('Hello {{name | uppercase}}!');\n     *   expect(exp({name:'Angular'})).toEqual('Hello ANGULAR!');\n     * ```\n     *\n     * `$interpolate` takes an optional fourth argument, `allOrNothing`. If `allOrNothing` is\n     * `true`, the interpolation function will return `undefined` unless all embedded expressions\n     * evaluate to a value other than `undefined`.\n     *\n     * ```js\n     *   var $interpolate = ...; // injected\n     *   var context = {greeting: 'Hello', name: undefined };\n     *\n     *   // default \"forgiving\" mode\n     *   var exp = $interpolate('{{greeting}} {{name}}!');\n     *   expect(exp(context)).toEqual('Hello !');\n     *\n     *   // \"allOrNothing\" mode\n     *   exp = $interpolate('{{greeting}} {{name}}!', false, null, true);\n     *   expect(exp(context)).toBeUndefined();\n     *   context.name = 'Angular';\n     *   expect(exp(context)).toEqual('Hello Angular!');\n     * ```\n     *\n     * `allOrNothing` is useful for interpolating URLs. `ngSrc` and `ngSrcset` use this behavior.\n     *\n     * ####Escaped Interpolation\n     * $interpolate provides a mechanism for escaping interpolation markers. Start and end markers\n     * can be escaped by preceding each of their characters with a REVERSE SOLIDUS U+005C (backslash).\n     * It will be rendered as a regular start/end marker, and will not be interpreted as an expression\n     * or binding.\n     *\n     * This enables web-servers to prevent script injection attacks and defacing attacks, to some\n     * degree, while also enabling code examples to work without relying on the\n     * {@link ng.directive:ngNonBindable ngNonBindable} directive.\n     *\n     * **For security purposes, it is strongly encouraged that web servers escape user-supplied data,\n     * replacing angle brackets (&lt;, &gt;) with &amp;lt; and &amp;gt; respectively, and replacing all\n     * interpolation start/end markers with their escaped counterparts.**\n     *\n     * Escaped interpolation markers are only replaced with the actual interpolation markers in rendered\n     * output when the $interpolate service processes the text. So, for HTML elements interpolated\n     * by {@link ng.$compile $compile}, or otherwise interpolated with the `mustHaveExpression` parameter\n     * set to `true`, the interpolated text must contain an unescaped interpolation expression. As such,\n     * this is typically useful only when user-data is used in rendering a template from the server, or\n     * when otherwise untrusted data is used by a directive.\n     *\n     * <example>\n     *  <file name=\"index.html\">\n     *    <div ng-init=\"username='A user'\">\n     *      <p ng-init=\"apptitle='Escaping demo'\">{{apptitle}}: \\{\\{ username = \"defaced value\"; \\}\\}\n     *        </p>\n     *      <p><strong>{{username}}</strong> attempts to inject code which will deface the\n     *        application, but fails to accomplish their task, because the server has correctly\n     *        escaped the interpolation start/end markers with REVERSE SOLIDUS U+005C (backslash)\n     *        characters.</p>\n     *      <p>Instead, the result of the attempted script injection is visible, and can be removed\n     *        from the database by an administrator.</p>\n     *    </div>\n     *  </file>\n     * </example>\n     *\n     * @param {string} text The text with markup to interpolate.\n     * @param {boolean=} mustHaveExpression if set to true then the interpolation string must have\n     *    embedded expression in order to return an interpolation function. Strings with no\n     *    embedded expression will return null for the interpolation function.\n     * @param {string=} trustedContext when provided, the returned function passes the interpolated\n     *    result through {@link ng.$sce#getTrusted $sce.getTrusted(interpolatedResult,\n     *    trustedContext)} before returning it.  Refer to the {@link ng.$sce $sce} service that\n     *    provides Strict Contextual Escaping for details.\n     * @param {boolean=} allOrNothing if `true`, then the returned function returns undefined\n     *    unless all embedded expressions evaluate to a value other than `undefined`.\n     * @returns {function(context)} an interpolation function which is used to compute the\n     *    interpolated string. The function has these parameters:\n     *\n     * - `context`: evaluation context for all expressions embedded in the interpolated text\n     */\n    function $interpolate(text, mustHaveExpression, trustedContext, allOrNothing) {\n      // Provide a quick exit and simplified result function for text with no interpolation\n      if (!text.length || text.indexOf(startSymbol) === -1) {\n        var constantInterp;\n        if (!mustHaveExpression) {\n          var unescapedText = unescapeText(text);\n          constantInterp = valueFn(unescapedText);\n          constantInterp.exp = text;\n          constantInterp.expressions = [];\n          constantInterp.$$watchDelegate = constantWatchDelegate;\n        }\n        return constantInterp;\n      }\n\n      allOrNothing = !!allOrNothing;\n      var startIndex,\n          endIndex,\n          index = 0,\n          expressions = [],\n          parseFns = [],\n          textLength = text.length,\n          exp,\n          concat = [],\n          expressionPositions = [];\n\n      while (index < textLength) {\n        if (((startIndex = text.indexOf(startSymbol, index)) != -1) &&\n             ((endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1)) {\n          if (index !== startIndex) {\n            concat.push(unescapeText(text.substring(index, startIndex)));\n          }\n          exp = text.substring(startIndex + startSymbolLength, endIndex);\n          expressions.push(exp);\n          parseFns.push($parse(exp, parseStringifyInterceptor));\n          index = endIndex + endSymbolLength;\n          expressionPositions.push(concat.length);\n          concat.push('');\n        } else {\n          // we did not find an interpolation, so we have to add the remainder to the separators array\n          if (index !== textLength) {\n            concat.push(unescapeText(text.substring(index)));\n          }\n          break;\n        }\n      }\n\n      // Concatenating expressions makes it hard to reason about whether some combination of\n      // concatenated values are unsafe to use and could easily lead to XSS.  By requiring that a\n      // single expression be used for iframe[src], object[src], etc., we ensure that the value\n      // that's used is assigned or constructed by some JS code somewhere that is more testable or\n      // make it obvious that you bound the value to some user controlled value.  This helps reduce\n      // the load when auditing for XSS issues.\n      if (trustedContext && concat.length > 1) {\n          $interpolateMinErr.throwNoconcat(text);\n      }\n\n      if (!mustHaveExpression || expressions.length) {\n        var compute = function(values) {\n          for (var i = 0, ii = expressions.length; i < ii; i++) {\n            if (allOrNothing && isUndefined(values[i])) return;\n            concat[expressionPositions[i]] = values[i];\n          }\n          return concat.join('');\n        };\n\n        var getValue = function(value) {\n          return trustedContext ?\n            $sce.getTrusted(trustedContext, value) :\n            $sce.valueOf(value);\n        };\n\n        return extend(function interpolationFn(context) {\n            var i = 0;\n            var ii = expressions.length;\n            var values = new Array(ii);\n\n            try {\n              for (; i < ii; i++) {\n                values[i] = parseFns[i](context);\n              }\n\n              return compute(values);\n            } catch (err) {\n              $exceptionHandler($interpolateMinErr.interr(text, err));\n            }\n\n          }, {\n          // all of these properties are undocumented for now\n          exp: text, //just for compatibility with regular watchers created via $watch\n          expressions: expressions,\n          $$watchDelegate: function(scope, listener) {\n            var lastValue;\n            return scope.$watchGroup(parseFns, function interpolateFnWatcher(values, oldValues) {\n              var currValue = compute(values);\n              if (isFunction(listener)) {\n                listener.call(this, currValue, values !== oldValues ? lastValue : currValue, scope);\n              }\n              lastValue = currValue;\n            });\n          }\n        });\n      }\n\n      function parseStringifyInterceptor(value) {\n        try {\n          value = getValue(value);\n          return allOrNothing && !isDefined(value) ? value : stringify(value);\n        } catch (err) {\n          $exceptionHandler($interpolateMinErr.interr(text, err));\n        }\n      }\n    }\n\n\n    /**\n     * @ngdoc method\n     * @name $interpolate#startSymbol\n     * @description\n     * Symbol to denote the start of expression in the interpolated string. Defaults to `{{`.\n     *\n     * Use {@link ng.$interpolateProvider#startSymbol `$interpolateProvider.startSymbol`} to change\n     * the symbol.\n     *\n     * @returns {string} start symbol.\n     */\n    $interpolate.startSymbol = function() {\n      return startSymbol;\n    };\n\n\n    /**\n     * @ngdoc method\n     * @name $interpolate#endSymbol\n     * @description\n     * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.\n     *\n     * Use {@link ng.$interpolateProvider#endSymbol `$interpolateProvider.endSymbol`} to change\n     * the symbol.\n     *\n     * @returns {string} end symbol.\n     */\n    $interpolate.endSymbol = function() {\n      return endSymbol;\n    };\n\n    return $interpolate;\n  }];\n}\n\nfunction $IntervalProvider() {\n  this.$get = ['$rootScope', '$window', '$q', '$$q', '$browser',\n       function($rootScope,   $window,   $q,   $$q,   $browser) {\n    var intervals = {};\n\n\n     /**\n      * @ngdoc service\n      * @name $interval\n      *\n      * @description\n      * Angular's wrapper for `window.setInterval`. The `fn` function is executed every `delay`\n      * milliseconds.\n      *\n      * The return value of registering an interval function is a promise. This promise will be\n      * notified upon each tick of the interval, and will be resolved after `count` iterations, or\n      * run indefinitely if `count` is not defined. The value of the notification will be the\n      * number of iterations that have run.\n      * To cancel an interval, call `$interval.cancel(promise)`.\n      *\n      * In tests you can use {@link ngMock.$interval#flush `$interval.flush(millis)`} to\n      * move forward by `millis` milliseconds and trigger any functions scheduled to run in that\n      * time.\n      *\n      * <div class=\"alert alert-warning\">\n      * **Note**: Intervals created by this service must be explicitly destroyed when you are finished\n      * with them.  In particular they are not automatically destroyed when a controller's scope or a\n      * directive's element are destroyed.\n      * You should take this into consideration and make sure to always cancel the interval at the\n      * appropriate moment.  See the example below for more details on how and when to do this.\n      * </div>\n      *\n      * @param {function()} fn A function that should be called repeatedly.\n      * @param {number} delay Number of milliseconds between each function call.\n      * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat\n      *   indefinitely.\n      * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise\n      *   will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.\n      * @param {...*=} Pass additional parameters to the executed function.\n      * @returns {promise} A promise which will be notified on each iteration.\n      *\n      * @example\n      * <example module=\"intervalExample\">\n      * <file name=\"index.html\">\n      *   <script>\n      *     angular.module('intervalExample', [])\n      *       .controller('ExampleController', ['$scope', '$interval',\n      *         function($scope, $interval) {\n      *           $scope.format = 'M/d/yy h:mm:ss a';\n      *           $scope.blood_1 = 100;\n      *           $scope.blood_2 = 120;\n      *\n      *           var stop;\n      *           $scope.fight = function() {\n      *             // Don't start a new fight if we are already fighting\n      *             if ( angular.isDefined(stop) ) return;\n      *\n      *             stop = $interval(function() {\n      *               if ($scope.blood_1 > 0 && $scope.blood_2 > 0) {\n      *                 $scope.blood_1 = $scope.blood_1 - 3;\n      *                 $scope.blood_2 = $scope.blood_2 - 4;\n      *               } else {\n      *                 $scope.stopFight();\n      *               }\n      *             }, 100);\n      *           };\n      *\n      *           $scope.stopFight = function() {\n      *             if (angular.isDefined(stop)) {\n      *               $interval.cancel(stop);\n      *               stop = undefined;\n      *             }\n      *           };\n      *\n      *           $scope.resetFight = function() {\n      *             $scope.blood_1 = 100;\n      *             $scope.blood_2 = 120;\n      *           };\n      *\n      *           $scope.$on('$destroy', function() {\n      *             // Make sure that the interval is destroyed too\n      *             $scope.stopFight();\n      *           });\n      *         }])\n      *       // Register the 'myCurrentTime' directive factory method.\n      *       // We inject $interval and dateFilter service since the factory method is DI.\n      *       .directive('myCurrentTime', ['$interval', 'dateFilter',\n      *         function($interval, dateFilter) {\n      *           // return the directive link function. (compile function not needed)\n      *           return function(scope, element, attrs) {\n      *             var format,  // date format\n      *                 stopTime; // so that we can cancel the time updates\n      *\n      *             // used to update the UI\n      *             function updateTime() {\n      *               element.text(dateFilter(new Date(), format));\n      *             }\n      *\n      *             // watch the expression, and update the UI on change.\n      *             scope.$watch(attrs.myCurrentTime, function(value) {\n      *               format = value;\n      *               updateTime();\n      *             });\n      *\n      *             stopTime = $interval(updateTime, 1000);\n      *\n      *             // listen on DOM destroy (removal) event, and cancel the next UI update\n      *             // to prevent updating time after the DOM element was removed.\n      *             element.on('$destroy', function() {\n      *               $interval.cancel(stopTime);\n      *             });\n      *           }\n      *         }]);\n      *   </script>\n      *\n      *   <div>\n      *     <div ng-controller=\"ExampleController\">\n      *       <label>Date format: <input ng-model=\"format\"></label> <hr/>\n      *       Current time is: <span my-current-time=\"format\"></span>\n      *       <hr/>\n      *       Blood 1 : <font color='red'>{{blood_1}}</font>\n      *       Blood 2 : <font color='red'>{{blood_2}}</font>\n      *       <button type=\"button\" data-ng-click=\"fight()\">Fight</button>\n      *       <button type=\"button\" data-ng-click=\"stopFight()\">StopFight</button>\n      *       <button type=\"button\" data-ng-click=\"resetFight()\">resetFight</button>\n      *     </div>\n      *   </div>\n      *\n      * </file>\n      * </example>\n      */\n    function interval(fn, delay, count, invokeApply) {\n      var hasParams = arguments.length > 4,\n          args = hasParams ? sliceArgs(arguments, 4) : [],\n          setInterval = $window.setInterval,\n          clearInterval = $window.clearInterval,\n          iteration = 0,\n          skipApply = (isDefined(invokeApply) && !invokeApply),\n          deferred = (skipApply ? $$q : $q).defer(),\n          promise = deferred.promise;\n\n      count = isDefined(count) ? count : 0;\n\n      promise.$$intervalId = setInterval(function tick() {\n        if (skipApply) {\n          $browser.defer(callback);\n        } else {\n          $rootScope.$evalAsync(callback);\n        }\n        deferred.notify(iteration++);\n\n        if (count > 0 && iteration >= count) {\n          deferred.resolve(iteration);\n          clearInterval(promise.$$intervalId);\n          delete intervals[promise.$$intervalId];\n        }\n\n        if (!skipApply) $rootScope.$apply();\n\n      }, delay);\n\n      intervals[promise.$$intervalId] = deferred;\n\n      return promise;\n\n      function callback() {\n        if (!hasParams) {\n          fn(iteration);\n        } else {\n          fn.apply(null, args);\n        }\n      }\n    }\n\n\n     /**\n      * @ngdoc method\n      * @name $interval#cancel\n      *\n      * @description\n      * Cancels a task associated with the `promise`.\n      *\n      * @param {Promise=} promise returned by the `$interval` function.\n      * @returns {boolean} Returns `true` if the task was successfully canceled.\n      */\n    interval.cancel = function(promise) {\n      if (promise && promise.$$intervalId in intervals) {\n        intervals[promise.$$intervalId].reject('canceled');\n        $window.clearInterval(promise.$$intervalId);\n        delete intervals[promise.$$intervalId];\n        return true;\n      }\n      return false;\n    };\n\n    return interval;\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $locale\n *\n * @description\n * $locale service provides localization rules for various Angular components. As of right now the\n * only public api is:\n *\n * * `id` – `{string}` – locale id formatted as `languageId-countryId` (e.g. `en-us`)\n */\n\nvar PATH_MATCH = /^([^\\?#]*)(\\?([^#]*))?(#(.*))?$/,\n    DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp': 21};\nvar $locationMinErr = minErr('$location');\n\n\n/**\n * Encode path using encodeUriSegment, ignoring forward slashes\n *\n * @param {string} path Path to encode\n * @returns {string}\n */\nfunction encodePath(path) {\n  var segments = path.split('/'),\n      i = segments.length;\n\n  while (i--) {\n    segments[i] = encodeUriSegment(segments[i]);\n  }\n\n  return segments.join('/');\n}\n\nfunction parseAbsoluteUrl(absoluteUrl, locationObj) {\n  var parsedUrl = urlResolve(absoluteUrl);\n\n  locationObj.$$protocol = parsedUrl.protocol;\n  locationObj.$$host = parsedUrl.hostname;\n  locationObj.$$port = toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;\n}\n\n\nfunction parseAppUrl(relativeUrl, locationObj) {\n  var prefixed = (relativeUrl.charAt(0) !== '/');\n  if (prefixed) {\n    relativeUrl = '/' + relativeUrl;\n  }\n  var match = urlResolve(relativeUrl);\n  locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ?\n      match.pathname.substring(1) : match.pathname);\n  locationObj.$$search = parseKeyValue(match.search);\n  locationObj.$$hash = decodeURIComponent(match.hash);\n\n  // make sure path starts with '/';\n  if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') {\n    locationObj.$$path = '/' + locationObj.$$path;\n  }\n}\n\n\n/**\n *\n * @param {string} begin\n * @param {string} whole\n * @returns {string} returns text from whole after begin or undefined if it does not begin with\n *                   expected string.\n */\nfunction beginsWith(begin, whole) {\n  if (whole.indexOf(begin) === 0) {\n    return whole.substr(begin.length);\n  }\n}\n\n\nfunction stripHash(url) {\n  var index = url.indexOf('#');\n  return index == -1 ? url : url.substr(0, index);\n}\n\nfunction trimEmptyHash(url) {\n  return url.replace(/(#.+)|#$/, '$1');\n}\n\n\nfunction stripFile(url) {\n  return url.substr(0, stripHash(url).lastIndexOf('/') + 1);\n}\n\n/* return the server only (scheme://host:port) */\nfunction serverBase(url) {\n  return url.substring(0, url.indexOf('/', url.indexOf('//') + 2));\n}\n\n\n/**\n * LocationHtml5Url represents an url\n * This object is exposed as $location service when HTML5 mode is enabled and supported\n *\n * @constructor\n * @param {string} appBase application base URL\n * @param {string} appBaseNoFile application base URL stripped of any filename\n * @param {string} basePrefix url path prefix\n */\nfunction LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {\n  this.$$html5 = true;\n  basePrefix = basePrefix || '';\n  parseAbsoluteUrl(appBase, this);\n\n\n  /**\n   * Parse given html5 (regular) url string into properties\n   * @param {string} url HTML5 url\n   * @private\n   */\n  this.$$parse = function(url) {\n    var pathUrl = beginsWith(appBaseNoFile, url);\n    if (!isString(pathUrl)) {\n      throw $locationMinErr('ipthprfx', 'Invalid url \"{0}\", missing path prefix \"{1}\".', url,\n          appBaseNoFile);\n    }\n\n    parseAppUrl(pathUrl, this);\n\n    if (!this.$$path) {\n      this.$$path = '/';\n    }\n\n    this.$$compose();\n  };\n\n  /**\n   * Compose url and update `absUrl` property\n   * @private\n   */\n  this.$$compose = function() {\n    var search = toKeyValue(this.$$search),\n        hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';\n\n    this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;\n    this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/'\n  };\n\n  this.$$parseLinkUrl = function(url, relHref) {\n    if (relHref && relHref[0] === '#') {\n      // special case for links to hash fragments:\n      // keep the old url and only replace the hash fragment\n      this.hash(relHref.slice(1));\n      return true;\n    }\n    var appUrl, prevAppUrl;\n    var rewrittenUrl;\n\n    if (isDefined(appUrl = beginsWith(appBase, url))) {\n      prevAppUrl = appUrl;\n      if (isDefined(appUrl = beginsWith(basePrefix, appUrl))) {\n        rewrittenUrl = appBaseNoFile + (beginsWith('/', appUrl) || appUrl);\n      } else {\n        rewrittenUrl = appBase + prevAppUrl;\n      }\n    } else if (isDefined(appUrl = beginsWith(appBaseNoFile, url))) {\n      rewrittenUrl = appBaseNoFile + appUrl;\n    } else if (appBaseNoFile == url + '/') {\n      rewrittenUrl = appBaseNoFile;\n    }\n    if (rewrittenUrl) {\n      this.$$parse(rewrittenUrl);\n    }\n    return !!rewrittenUrl;\n  };\n}\n\n\n/**\n * LocationHashbangUrl represents url\n * This object is exposed as $location service when developer doesn't opt into html5 mode.\n * It also serves as the base class for html5 mode fallback on legacy browsers.\n *\n * @constructor\n * @param {string} appBase application base URL\n * @param {string} appBaseNoFile application base URL stripped of any filename\n * @param {string} hashPrefix hashbang prefix\n */\nfunction LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {\n\n  parseAbsoluteUrl(appBase, this);\n\n\n  /**\n   * Parse given hashbang url into properties\n   * @param {string} url Hashbang url\n   * @private\n   */\n  this.$$parse = function(url) {\n    var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url);\n    var withoutHashUrl;\n\n    if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') {\n\n      // The rest of the url starts with a hash so we have\n      // got either a hashbang path or a plain hash fragment\n      withoutHashUrl = beginsWith(hashPrefix, withoutBaseUrl);\n      if (isUndefined(withoutHashUrl)) {\n        // There was no hashbang prefix so we just have a hash fragment\n        withoutHashUrl = withoutBaseUrl;\n      }\n\n    } else {\n      // There was no hashbang path nor hash fragment:\n      // If we are in HTML5 mode we use what is left as the path;\n      // Otherwise we ignore what is left\n      if (this.$$html5) {\n        withoutHashUrl = withoutBaseUrl;\n      } else {\n        withoutHashUrl = '';\n        if (isUndefined(withoutBaseUrl)) {\n          appBase = url;\n          this.replace();\n        }\n      }\n    }\n\n    parseAppUrl(withoutHashUrl, this);\n\n    this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);\n\n    this.$$compose();\n\n    /*\n     * In Windows, on an anchor node on documents loaded from\n     * the filesystem, the browser will return a pathname\n     * prefixed with the drive name ('/C:/path') when a\n     * pathname without a drive is set:\n     *  * a.setAttribute('href', '/foo')\n     *   * a.pathname === '/C:/foo' //true\n     *\n     * Inside of Angular, we're always using pathnames that\n     * do not include drive names for routing.\n     */\n    function removeWindowsDriveName(path, url, base) {\n      /*\n      Matches paths for file protocol on windows,\n      such as /C:/foo/bar, and captures only /foo/bar.\n      */\n      var windowsFilePathExp = /^\\/[A-Z]:(\\/.*)/;\n\n      var firstPathSegmentMatch;\n\n      //Get the relative path from the input URL.\n      if (url.indexOf(base) === 0) {\n        url = url.replace(base, '');\n      }\n\n      // The input URL intentionally contains a first path segment that ends with a colon.\n      if (windowsFilePathExp.exec(url)) {\n        return path;\n      }\n\n      firstPathSegmentMatch = windowsFilePathExp.exec(path);\n      return firstPathSegmentMatch ? firstPathSegmentMatch[1] : path;\n    }\n  };\n\n  /**\n   * Compose hashbang url and update `absUrl` property\n   * @private\n   */\n  this.$$compose = function() {\n    var search = toKeyValue(this.$$search),\n        hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';\n\n    this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;\n    this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : '');\n  };\n\n  this.$$parseLinkUrl = function(url, relHref) {\n    if (stripHash(appBase) == stripHash(url)) {\n      this.$$parse(url);\n      return true;\n    }\n    return false;\n  };\n}\n\n\n/**\n * LocationHashbangUrl represents url\n * This object is exposed as $location service when html5 history api is enabled but the browser\n * does not support it.\n *\n * @constructor\n * @param {string} appBase application base URL\n * @param {string} appBaseNoFile application base URL stripped of any filename\n * @param {string} hashPrefix hashbang prefix\n */\nfunction LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {\n  this.$$html5 = true;\n  LocationHashbangUrl.apply(this, arguments);\n\n  this.$$parseLinkUrl = function(url, relHref) {\n    if (relHref && relHref[0] === '#') {\n      // special case for links to hash fragments:\n      // keep the old url and only replace the hash fragment\n      this.hash(relHref.slice(1));\n      return true;\n    }\n\n    var rewrittenUrl;\n    var appUrl;\n\n    if (appBase == stripHash(url)) {\n      rewrittenUrl = url;\n    } else if ((appUrl = beginsWith(appBaseNoFile, url))) {\n      rewrittenUrl = appBase + hashPrefix + appUrl;\n    } else if (appBaseNoFile === url + '/') {\n      rewrittenUrl = appBaseNoFile;\n    }\n    if (rewrittenUrl) {\n      this.$$parse(rewrittenUrl);\n    }\n    return !!rewrittenUrl;\n  };\n\n  this.$$compose = function() {\n    var search = toKeyValue(this.$$search),\n        hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';\n\n    this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;\n    // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#'\n    this.$$absUrl = appBase + hashPrefix + this.$$url;\n  };\n\n}\n\n\nvar locationPrototype = {\n\n  /**\n   * Are we in html5 mode?\n   * @private\n   */\n  $$html5: false,\n\n  /**\n   * Has any change been replacing?\n   * @private\n   */\n  $$replace: false,\n\n  /**\n   * @ngdoc method\n   * @name $location#absUrl\n   *\n   * @description\n   * This method is getter only.\n   *\n   * Return full url representation with all segments encoded according to rules specified in\n   * [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt).\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var absUrl = $location.absUrl();\n   * // => \"http://example.com/#/some/path?foo=bar&baz=xoxo\"\n   * ```\n   *\n   * @return {string} full url\n   */\n  absUrl: locationGetter('$$absUrl'),\n\n  /**\n   * @ngdoc method\n   * @name $location#url\n   *\n   * @description\n   * This method is getter / setter.\n   *\n   * Return url (e.g. `/path?a=b#hash`) when called without any parameter.\n   *\n   * Change path, search and hash, when called with parameter and return `$location`.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var url = $location.url();\n   * // => \"/some/path?foo=bar&baz=xoxo\"\n   * ```\n   *\n   * @param {string=} url New url without base prefix (e.g. `/path?a=b#hash`)\n   * @return {string} url\n   */\n  url: function(url) {\n    if (isUndefined(url)) {\n      return this.$$url;\n    }\n\n    var match = PATH_MATCH.exec(url);\n    if (match[1] || url === '') this.path(decodeURIComponent(match[1]));\n    if (match[2] || match[1] || url === '') this.search(match[3] || '');\n    this.hash(match[5] || '');\n\n    return this;\n  },\n\n  /**\n   * @ngdoc method\n   * @name $location#protocol\n   *\n   * @description\n   * This method is getter only.\n   *\n   * Return protocol of current url.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var protocol = $location.protocol();\n   * // => \"http\"\n   * ```\n   *\n   * @return {string} protocol of current url\n   */\n  protocol: locationGetter('$$protocol'),\n\n  /**\n   * @ngdoc method\n   * @name $location#host\n   *\n   * @description\n   * This method is getter only.\n   *\n   * Return host of current url.\n   *\n   * Note: compared to the non-angular version `location.host` which returns `hostname:port`, this returns the `hostname` portion only.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var host = $location.host();\n   * // => \"example.com\"\n   *\n   * // given url http://user:password@example.com:8080/#/some/path?foo=bar&baz=xoxo\n   * host = $location.host();\n   * // => \"example.com\"\n   * host = location.host;\n   * // => \"example.com:8080\"\n   * ```\n   *\n   * @return {string} host of current url.\n   */\n  host: locationGetter('$$host'),\n\n  /**\n   * @ngdoc method\n   * @name $location#port\n   *\n   * @description\n   * This method is getter only.\n   *\n   * Return port of current url.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var port = $location.port();\n   * // => 80\n   * ```\n   *\n   * @return {Number} port\n   */\n  port: locationGetter('$$port'),\n\n  /**\n   * @ngdoc method\n   * @name $location#path\n   *\n   * @description\n   * This method is getter / setter.\n   *\n   * Return path of current url when called without any parameter.\n   *\n   * Change path when called with parameter and return `$location`.\n   *\n   * Note: Path should always begin with forward slash (/), this method will add the forward slash\n   * if it is missing.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var path = $location.path();\n   * // => \"/some/path\"\n   * ```\n   *\n   * @param {(string|number)=} path New path\n   * @return {string} path\n   */\n  path: locationGetterSetter('$$path', function(path) {\n    path = path !== null ? path.toString() : '';\n    return path.charAt(0) == '/' ? path : '/' + path;\n  }),\n\n  /**\n   * @ngdoc method\n   * @name $location#search\n   *\n   * @description\n   * This method is getter / setter.\n   *\n   * Return search part (as object) of current url when called without any parameter.\n   *\n   * Change search part when called with parameter and return `$location`.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo\n   * var searchObject = $location.search();\n   * // => {foo: 'bar', baz: 'xoxo'}\n   *\n   * // set foo to 'yipee'\n   * $location.search('foo', 'yipee');\n   * // $location.search() => {foo: 'yipee', baz: 'xoxo'}\n   * ```\n   *\n   * @param {string|Object.<string>|Object.<Array.<string>>} search New search params - string or\n   * hash object.\n   *\n   * When called with a single argument the method acts as a setter, setting the `search` component\n   * of `$location` to the specified value.\n   *\n   * If the argument is a hash object containing an array of values, these values will be encoded\n   * as duplicate search parameters in the url.\n   *\n   * @param {(string|Number|Array<string>|boolean)=} paramValue If `search` is a string or number, then `paramValue`\n   * will override only a single search property.\n   *\n   * If `paramValue` is an array, it will override the property of the `search` component of\n   * `$location` specified via the first argument.\n   *\n   * If `paramValue` is `null`, the property specified via the first argument will be deleted.\n   *\n   * If `paramValue` is `true`, the property specified via the first argument will be added with no\n   * value nor trailing equal sign.\n   *\n   * @return {Object} If called with no arguments returns the parsed `search` object. If called with\n   * one or more arguments returns `$location` object itself.\n   */\n  search: function(search, paramValue) {\n    switch (arguments.length) {\n      case 0:\n        return this.$$search;\n      case 1:\n        if (isString(search) || isNumber(search)) {\n          search = search.toString();\n          this.$$search = parseKeyValue(search);\n        } else if (isObject(search)) {\n          search = copy(search, {});\n          // remove object undefined or null properties\n          forEach(search, function(value, key) {\n            if (value == null) delete search[key];\n          });\n\n          this.$$search = search;\n        } else {\n          throw $locationMinErr('isrcharg',\n              'The first argument of the `$location#search()` call must be a string or an object.');\n        }\n        break;\n      default:\n        if (isUndefined(paramValue) || paramValue === null) {\n          delete this.$$search[search];\n        } else {\n          this.$$search[search] = paramValue;\n        }\n    }\n\n    this.$$compose();\n    return this;\n  },\n\n  /**\n   * @ngdoc method\n   * @name $location#hash\n   *\n   * @description\n   * This method is getter / setter.\n   *\n   * Returns the hash fragment when called without any parameters.\n   *\n   * Changes the hash fragment when called with a parameter and returns `$location`.\n   *\n   *\n   * ```js\n   * // given url http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue\n   * var hash = $location.hash();\n   * // => \"hashValue\"\n   * ```\n   *\n   * @param {(string|number)=} hash New hash fragment\n   * @return {string} hash\n   */\n  hash: locationGetterSetter('$$hash', function(hash) {\n    return hash !== null ? hash.toString() : '';\n  }),\n\n  /**\n   * @ngdoc method\n   * @name $location#replace\n   *\n   * @description\n   * If called, all changes to $location during the current `$digest` will replace the current history\n   * record, instead of adding a new one.\n   */\n  replace: function() {\n    this.$$replace = true;\n    return this;\n  }\n};\n\nforEach([LocationHashbangInHtml5Url, LocationHashbangUrl, LocationHtml5Url], function(Location) {\n  Location.prototype = Object.create(locationPrototype);\n\n  /**\n   * @ngdoc method\n   * @name $location#state\n   *\n   * @description\n   * This method is getter / setter.\n   *\n   * Return the history state object when called without any parameter.\n   *\n   * Change the history state object when called with one parameter and return `$location`.\n   * The state object is later passed to `pushState` or `replaceState`.\n   *\n   * NOTE: This method is supported only in HTML5 mode and only in browsers supporting\n   * the HTML5 History API (i.e. methods `pushState` and `replaceState`). If you need to support\n   * older browsers (like IE9 or Android < 4.0), don't use this method.\n   *\n   * @param {object=} state State object for pushState or replaceState\n   * @return {object} state\n   */\n  Location.prototype.state = function(state) {\n    if (!arguments.length) {\n      return this.$$state;\n    }\n\n    if (Location !== LocationHtml5Url || !this.$$html5) {\n      throw $locationMinErr('nostate', 'History API state support is available only ' +\n        'in HTML5 mode and only in browsers supporting HTML5 History API');\n    }\n    // The user might modify `stateObject` after invoking `$location.state(stateObject)`\n    // but we're changing the $$state reference to $browser.state() during the $digest\n    // so the modification window is narrow.\n    this.$$state = isUndefined(state) ? null : state;\n\n    return this;\n  };\n});\n\n\nfunction locationGetter(property) {\n  return function() {\n    return this[property];\n  };\n}\n\n\nfunction locationGetterSetter(property, preprocess) {\n  return function(value) {\n    if (isUndefined(value)) {\n      return this[property];\n    }\n\n    this[property] = preprocess(value);\n    this.$$compose();\n\n    return this;\n  };\n}\n\n\n/**\n * @ngdoc service\n * @name $location\n *\n * @requires $rootElement\n *\n * @description\n * The $location service parses the URL in the browser address bar (based on the\n * [window.location](https://developer.mozilla.org/en/window.location)) and makes the URL\n * available to your application. Changes to the URL in the address bar are reflected into\n * $location service and changes to $location are reflected into the browser address bar.\n *\n * **The $location service:**\n *\n * - Exposes the current URL in the browser address bar, so you can\n *   - Watch and observe the URL.\n *   - Change the URL.\n * - Synchronizes the URL with the browser when the user\n *   - Changes the address bar.\n *   - Clicks the back or forward button (or clicks a History link).\n *   - Clicks on a link.\n * - Represents the URL object as a set of methods (protocol, host, port, path, search, hash).\n *\n * For more information see {@link guide/$location Developer Guide: Using $location}\n */\n\n/**\n * @ngdoc provider\n * @name $locationProvider\n * @description\n * Use the `$locationProvider` to configure how the application deep linking paths are stored.\n */\nfunction $LocationProvider() {\n  var hashPrefix = '',\n      html5Mode = {\n        enabled: false,\n        requireBase: true,\n        rewriteLinks: true\n      };\n\n  /**\n   * @ngdoc method\n   * @name $locationProvider#hashPrefix\n   * @description\n   * @param {string=} prefix Prefix for hash part (containing path and search)\n   * @returns {*} current value if used as getter or itself (chaining) if used as setter\n   */\n  this.hashPrefix = function(prefix) {\n    if (isDefined(prefix)) {\n      hashPrefix = prefix;\n      return this;\n    } else {\n      return hashPrefix;\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name $locationProvider#html5Mode\n   * @description\n   * @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value.\n   *   If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values. Supported\n   *   properties:\n   *   - **enabled** – `{boolean}` – (default: false) If true, will rely on `history.pushState` to\n   *     change urls where supported. Will fall back to hash-prefixed paths in browsers that do not\n   *     support `pushState`.\n   *   - **requireBase** - `{boolean}` - (default: `true`) When html5Mode is enabled, specifies\n   *     whether or not a <base> tag is required to be present. If `enabled` and `requireBase` are\n   *     true, and a base tag is not present, an error will be thrown when `$location` is injected.\n   *     See the {@link guide/$location $location guide for more information}\n   *   - **rewriteLinks** - `{boolean}` - (default: `true`) When html5Mode is enabled,\n   *     enables/disables url rewriting for relative links.\n   *\n   * @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter\n   */\n  this.html5Mode = function(mode) {\n    if (isBoolean(mode)) {\n      html5Mode.enabled = mode;\n      return this;\n    } else if (isObject(mode)) {\n\n      if (isBoolean(mode.enabled)) {\n        html5Mode.enabled = mode.enabled;\n      }\n\n      if (isBoolean(mode.requireBase)) {\n        html5Mode.requireBase = mode.requireBase;\n      }\n\n      if (isBoolean(mode.rewriteLinks)) {\n        html5Mode.rewriteLinks = mode.rewriteLinks;\n      }\n\n      return this;\n    } else {\n      return html5Mode;\n    }\n  };\n\n  /**\n   * @ngdoc event\n   * @name $location#$locationChangeStart\n   * @eventType broadcast on root scope\n   * @description\n   * Broadcasted before a URL will change.\n   *\n   * This change can be prevented by calling\n   * `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} for more\n   * details about event object. Upon successful change\n   * {@link ng.$location#$locationChangeSuccess $locationChangeSuccess} is fired.\n   *\n   * The `newState` and `oldState` parameters may be defined only in HTML5 mode and when\n   * the browser supports the HTML5 History API.\n   *\n   * @param {Object} angularEvent Synthetic event object.\n   * @param {string} newUrl New URL\n   * @param {string=} oldUrl URL that was before it was changed.\n   * @param {string=} newState New history state object\n   * @param {string=} oldState History state object that was before it was changed.\n   */\n\n  /**\n   * @ngdoc event\n   * @name $location#$locationChangeSuccess\n   * @eventType broadcast on root scope\n   * @description\n   * Broadcasted after a URL was changed.\n   *\n   * The `newState` and `oldState` parameters may be defined only in HTML5 mode and when\n   * the browser supports the HTML5 History API.\n   *\n   * @param {Object} angularEvent Synthetic event object.\n   * @param {string} newUrl New URL\n   * @param {string=} oldUrl URL that was before it was changed.\n   * @param {string=} newState New history state object\n   * @param {string=} oldState History state object that was before it was changed.\n   */\n\n  this.$get = ['$rootScope', '$browser', '$sniffer', '$rootElement', '$window',\n      function($rootScope, $browser, $sniffer, $rootElement, $window) {\n    var $location,\n        LocationMode,\n        baseHref = $browser.baseHref(), // if base[href] is undefined, it defaults to ''\n        initialUrl = $browser.url(),\n        appBase;\n\n    if (html5Mode.enabled) {\n      if (!baseHref && html5Mode.requireBase) {\n        throw $locationMinErr('nobase',\n          \"$location in HTML5 mode requires a <base> tag to be present!\");\n      }\n      appBase = serverBase(initialUrl) + (baseHref || '/');\n      LocationMode = $sniffer.history ? LocationHtml5Url : LocationHashbangInHtml5Url;\n    } else {\n      appBase = stripHash(initialUrl);\n      LocationMode = LocationHashbangUrl;\n    }\n    var appBaseNoFile = stripFile(appBase);\n\n    $location = new LocationMode(appBase, appBaseNoFile, '#' + hashPrefix);\n    $location.$$parseLinkUrl(initialUrl, initialUrl);\n\n    $location.$$state = $browser.state();\n\n    var IGNORE_URI_REGEXP = /^\\s*(javascript|mailto):/i;\n\n    function setBrowserUrlWithFallback(url, replace, state) {\n      var oldUrl = $location.url();\n      var oldState = $location.$$state;\n      try {\n        $browser.url(url, replace, state);\n\n        // Make sure $location.state() returns referentially identical (not just deeply equal)\n        // state object; this makes possible quick checking if the state changed in the digest\n        // loop. Checking deep equality would be too expensive.\n        $location.$$state = $browser.state();\n      } catch (e) {\n        // Restore old values if pushState fails\n        $location.url(oldUrl);\n        $location.$$state = oldState;\n\n        throw e;\n      }\n    }\n\n    $rootElement.on('click', function(event) {\n      // TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)\n      // currently we open nice url link and redirect then\n\n      if (!html5Mode.rewriteLinks || event.ctrlKey || event.metaKey || event.shiftKey || event.which == 2 || event.button == 2) return;\n\n      var elm = jqLite(event.target);\n\n      // traverse the DOM up to find first A tag\n      while (nodeName_(elm[0]) !== 'a') {\n        // ignore rewriting if no A tag (reached root element, or no parent - removed from document)\n        if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return;\n      }\n\n      var absHref = elm.prop('href');\n      // get the actual href attribute - see\n      // http://msdn.microsoft.com/en-us/library/ie/dd347148(v=vs.85).aspx\n      var relHref = elm.attr('href') || elm.attr('xlink:href');\n\n      if (isObject(absHref) && absHref.toString() === '[object SVGAnimatedString]') {\n        // SVGAnimatedString.animVal should be identical to SVGAnimatedString.baseVal, unless during\n        // an animation.\n        absHref = urlResolve(absHref.animVal).href;\n      }\n\n      // Ignore when url is started with javascript: or mailto:\n      if (IGNORE_URI_REGEXP.test(absHref)) return;\n\n      if (absHref && !elm.attr('target') && !event.isDefaultPrevented()) {\n        if ($location.$$parseLinkUrl(absHref, relHref)) {\n          // We do a preventDefault for all urls that are part of the angular application,\n          // in html5mode and also without, so that we are able to abort navigation without\n          // getting double entries in the location history.\n          event.preventDefault();\n          // update location manually\n          if ($location.absUrl() != $browser.url()) {\n            $rootScope.$apply();\n            // hack to work around FF6 bug 684208 when scenario runner clicks on links\n            $window.angular['ff-684208-preventDefault'] = true;\n          }\n        }\n      }\n    });\n\n\n    // rewrite hashbang url <> html5 url\n    if (trimEmptyHash($location.absUrl()) != trimEmptyHash(initialUrl)) {\n      $browser.url($location.absUrl(), true);\n    }\n\n    var initializing = true;\n\n    // update $location when $browser url changes\n    $browser.onUrlChange(function(newUrl, newState) {\n\n      if (isUndefined(beginsWith(appBaseNoFile, newUrl))) {\n        // If we are navigating outside of the app then force a reload\n        $window.location.href = newUrl;\n        return;\n      }\n\n      $rootScope.$evalAsync(function() {\n        var oldUrl = $location.absUrl();\n        var oldState = $location.$$state;\n        var defaultPrevented;\n        newUrl = trimEmptyHash(newUrl);\n        $location.$$parse(newUrl);\n        $location.$$state = newState;\n\n        defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl,\n            newState, oldState).defaultPrevented;\n\n        // if the location was changed by a `$locationChangeStart` handler then stop\n        // processing this location change\n        if ($location.absUrl() !== newUrl) return;\n\n        if (defaultPrevented) {\n          $location.$$parse(oldUrl);\n          $location.$$state = oldState;\n          setBrowserUrlWithFallback(oldUrl, false, oldState);\n        } else {\n          initializing = false;\n          afterLocationChange(oldUrl, oldState);\n        }\n      });\n      if (!$rootScope.$$phase) $rootScope.$digest();\n    });\n\n    // update browser\n    $rootScope.$watch(function $locationWatch() {\n      var oldUrl = trimEmptyHash($browser.url());\n      var newUrl = trimEmptyHash($location.absUrl());\n      var oldState = $browser.state();\n      var currentReplace = $location.$$replace;\n      var urlOrStateChanged = oldUrl !== newUrl ||\n        ($location.$$html5 && $sniffer.history && oldState !== $location.$$state);\n\n      if (initializing || urlOrStateChanged) {\n        initializing = false;\n\n        $rootScope.$evalAsync(function() {\n          var newUrl = $location.absUrl();\n          var defaultPrevented = $rootScope.$broadcast('$locationChangeStart', newUrl, oldUrl,\n              $location.$$state, oldState).defaultPrevented;\n\n          // if the location was changed by a `$locationChangeStart` handler then stop\n          // processing this location change\n          if ($location.absUrl() !== newUrl) return;\n\n          if (defaultPrevented) {\n            $location.$$parse(oldUrl);\n            $location.$$state = oldState;\n          } else {\n            if (urlOrStateChanged) {\n              setBrowserUrlWithFallback(newUrl, currentReplace,\n                                        oldState === $location.$$state ? null : $location.$$state);\n            }\n            afterLocationChange(oldUrl, oldState);\n          }\n        });\n      }\n\n      $location.$$replace = false;\n\n      // we don't need to return anything because $evalAsync will make the digest loop dirty when\n      // there is a change\n    });\n\n    return $location;\n\n    function afterLocationChange(oldUrl, oldState) {\n      $rootScope.$broadcast('$locationChangeSuccess', $location.absUrl(), oldUrl,\n        $location.$$state, oldState);\n    }\n}];\n}\n\n/**\n * @ngdoc service\n * @name $log\n * @requires $window\n *\n * @description\n * Simple service for logging. Default implementation safely writes the message\n * into the browser's console (if present).\n *\n * The main purpose of this service is to simplify debugging and troubleshooting.\n *\n * The default is to log `debug` messages. You can use\n * {@link ng.$logProvider ng.$logProvider#debugEnabled} to change this.\n *\n * @example\n   <example module=\"logExample\">\n     <file name=\"script.js\">\n       angular.module('logExample', [])\n         .controller('LogController', ['$scope', '$log', function($scope, $log) {\n           $scope.$log = $log;\n           $scope.message = 'Hello World!';\n         }]);\n     </file>\n     <file name=\"index.html\">\n       <div ng-controller=\"LogController\">\n         <p>Reload this page with open console, enter text and hit the log button...</p>\n         <label>Message:\n         <input type=\"text\" ng-model=\"message\" /></label>\n         <button ng-click=\"$log.log(message)\">log</button>\n         <button ng-click=\"$log.warn(message)\">warn</button>\n         <button ng-click=\"$log.info(message)\">info</button>\n         <button ng-click=\"$log.error(message)\">error</button>\n         <button ng-click=\"$log.debug(message)\">debug</button>\n       </div>\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc provider\n * @name $logProvider\n * @description\n * Use the `$logProvider` to configure how the application logs messages\n */\nfunction $LogProvider() {\n  var debug = true,\n      self = this;\n\n  /**\n   * @ngdoc method\n   * @name $logProvider#debugEnabled\n   * @description\n   * @param {boolean=} flag enable or disable debug level messages\n   * @returns {*} current value if used as getter or itself (chaining) if used as setter\n   */\n  this.debugEnabled = function(flag) {\n    if (isDefined(flag)) {\n      debug = flag;\n    return this;\n    } else {\n      return debug;\n    }\n  };\n\n  this.$get = ['$window', function($window) {\n    return {\n      /**\n       * @ngdoc method\n       * @name $log#log\n       *\n       * @description\n       * Write a log message\n       */\n      log: consoleLog('log'),\n\n      /**\n       * @ngdoc method\n       * @name $log#info\n       *\n       * @description\n       * Write an information message\n       */\n      info: consoleLog('info'),\n\n      /**\n       * @ngdoc method\n       * @name $log#warn\n       *\n       * @description\n       * Write a warning message\n       */\n      warn: consoleLog('warn'),\n\n      /**\n       * @ngdoc method\n       * @name $log#error\n       *\n       * @description\n       * Write an error message\n       */\n      error: consoleLog('error'),\n\n      /**\n       * @ngdoc method\n       * @name $log#debug\n       *\n       * @description\n       * Write a debug message\n       */\n      debug: (function() {\n        var fn = consoleLog('debug');\n\n        return function() {\n          if (debug) {\n            fn.apply(self, arguments);\n          }\n        };\n      }())\n    };\n\n    function formatError(arg) {\n      if (arg instanceof Error) {\n        if (arg.stack) {\n          arg = (arg.message && arg.stack.indexOf(arg.message) === -1)\n              ? 'Error: ' + arg.message + '\\n' + arg.stack\n              : arg.stack;\n        } else if (arg.sourceURL) {\n          arg = arg.message + '\\n' + arg.sourceURL + ':' + arg.line;\n        }\n      }\n      return arg;\n    }\n\n    function consoleLog(type) {\n      var console = $window.console || {},\n          logFn = console[type] || console.log || noop,\n          hasApply = false;\n\n      // Note: reading logFn.apply throws an error in IE11 in IE8 document mode.\n      // The reason behind this is that console.log has type \"object\" in IE8...\n      try {\n        hasApply = !!logFn.apply;\n      } catch (e) {}\n\n      if (hasApply) {\n        return function() {\n          var args = [];\n          forEach(arguments, function(arg) {\n            args.push(formatError(arg));\n          });\n          return logFn.apply(console, args);\n        };\n      }\n\n      // we are IE which either doesn't have window.console => this is noop and we do nothing,\n      // or we are IE where console.log doesn't have apply so we log at least first 2 args\n      return function(arg1, arg2) {\n        logFn(arg1, arg2 == null ? '' : arg2);\n      };\n    }\n  }];\n}\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *     Any commits to this file should be reviewed with security in mind.  *\n *   Changes to this file can potentially create security vulnerabilities. *\n *          An approval from 2 Core members with history of modifying      *\n *                         this file is required.                          *\n *                                                                         *\n *  Does the change somehow allow for arbitrary javascript to be executed? *\n *    Or allows for someone to change the prototype of built-in objects?   *\n *     Or gives undesired access to variables likes document or window?    *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\nvar $parseMinErr = minErr('$parse');\n\n// Sandboxing Angular Expressions\n// ------------------------------\n// Angular expressions are generally considered safe because these expressions only have direct\n// access to `$scope` and locals. However, one can obtain the ability to execute arbitrary JS code by\n// obtaining a reference to native JS functions such as the Function constructor.\n//\n// As an example, consider the following Angular expression:\n//\n//   {}.toString.constructor('alert(\"evil JS code\")')\n//\n// This sandboxing technique is not perfect and doesn't aim to be. The goal is to prevent exploits\n// against the expression language, but not to prevent exploits that were enabled by exposing\n// sensitive JavaScript or browser APIs on Scope. Exposing such objects on a Scope is never a good\n// practice and therefore we are not even trying to protect against interaction with an object\n// explicitly exposed in this way.\n//\n// In general, it is not possible to access a Window object from an angular expression unless a\n// window or some DOM object that has a reference to window is published onto a Scope.\n// Similarly we prevent invocations of function known to be dangerous, as well as assignments to\n// native objects.\n//\n// See https://docs.angularjs.org/guide/security\n\n\nfunction ensureSafeMemberName(name, fullExpression) {\n  if (name === \"__defineGetter__\" || name === \"__defineSetter__\"\n      || name === \"__lookupGetter__\" || name === \"__lookupSetter__\"\n      || name === \"__proto__\") {\n    throw $parseMinErr('isecfld',\n        'Attempting to access a disallowed field in Angular expressions! '\n        + 'Expression: {0}', fullExpression);\n  }\n  return name;\n}\n\nfunction getStringValue(name) {\n  // Property names must be strings. This means that non-string objects cannot be used\n  // as keys in an object. Any non-string object, including a number, is typecasted\n  // into a string via the toString method.\n  // -- MDN, https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Property_accessors#Property_names\n  //\n  // So, to ensure that we are checking the same `name` that JavaScript would use, we cast it\n  // to a string. It's not always possible. If `name` is an object and its `toString` method is\n  // 'broken' (doesn't return a string, isn't a function, etc.), an error will be thrown:\n  //\n  // TypeError: Cannot convert object to primitive value\n  //\n  // For performance reasons, we don't catch this error here and allow it to propagate up the call\n  // stack. Note that you'll get the same error in JavaScript if you try to access a property using\n  // such a 'broken' object as a key.\n  return name + '';\n}\n\nfunction ensureSafeObject(obj, fullExpression) {\n  // nifty check if obj is Function that is fast and works across iframes and other contexts\n  if (obj) {\n    if (obj.constructor === obj) {\n      throw $parseMinErr('isecfn',\n          'Referencing Function in Angular expressions is disallowed! Expression: {0}',\n          fullExpression);\n    } else if (// isWindow(obj)\n        obj.window === obj) {\n      throw $parseMinErr('isecwindow',\n          'Referencing the Window in Angular expressions is disallowed! Expression: {0}',\n          fullExpression);\n    } else if (// isElement(obj)\n        obj.children && (obj.nodeName || (obj.prop && obj.attr && obj.find))) {\n      throw $parseMinErr('isecdom',\n          'Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}',\n          fullExpression);\n    } else if (// block Object so that we can't get hold of dangerous Object.* methods\n        obj === Object) {\n      throw $parseMinErr('isecobj',\n          'Referencing Object in Angular expressions is disallowed! Expression: {0}',\n          fullExpression);\n    }\n  }\n  return obj;\n}\n\nvar CALL = Function.prototype.call;\nvar APPLY = Function.prototype.apply;\nvar BIND = Function.prototype.bind;\n\nfunction ensureSafeFunction(obj, fullExpression) {\n  if (obj) {\n    if (obj.constructor === obj) {\n      throw $parseMinErr('isecfn',\n        'Referencing Function in Angular expressions is disallowed! Expression: {0}',\n        fullExpression);\n    } else if (obj === CALL || obj === APPLY || obj === BIND) {\n      throw $parseMinErr('isecff',\n        'Referencing call, apply or bind in Angular expressions is disallowed! Expression: {0}',\n        fullExpression);\n    }\n  }\n}\n\nfunction ensureSafeAssignContext(obj, fullExpression) {\n  if (obj) {\n    if (obj === (0).constructor || obj === (false).constructor || obj === ''.constructor ||\n        obj === {}.constructor || obj === [].constructor || obj === Function.constructor) {\n      throw $parseMinErr('isecaf',\n        'Assigning to a constructor is disallowed! Expression: {0}', fullExpression);\n    }\n  }\n}\n\nvar OPERATORS = createMap();\nforEach('+ - * / % === !== == != < > <= >= && || ! = |'.split(' '), function(operator) { OPERATORS[operator] = true; });\nvar ESCAPE = {\"n\":\"\\n\", \"f\":\"\\f\", \"r\":\"\\r\", \"t\":\"\\t\", \"v\":\"\\v\", \"'\":\"'\", '\"':'\"'};\n\n\n/////////////////////////////////////////\n\n\n/**\n * @constructor\n */\nvar Lexer = function(options) {\n  this.options = options;\n};\n\nLexer.prototype = {\n  constructor: Lexer,\n\n  lex: function(text) {\n    this.text = text;\n    this.index = 0;\n    this.tokens = [];\n\n    while (this.index < this.text.length) {\n      var ch = this.text.charAt(this.index);\n      if (ch === '\"' || ch === \"'\") {\n        this.readString(ch);\n      } else if (this.isNumber(ch) || ch === '.' && this.isNumber(this.peek())) {\n        this.readNumber();\n      } else if (this.isIdentifierStart(this.peekMultichar())) {\n        this.readIdent();\n      } else if (this.is(ch, '(){}[].,;:?')) {\n        this.tokens.push({index: this.index, text: ch});\n        this.index++;\n      } else if (this.isWhitespace(ch)) {\n        this.index++;\n      } else {\n        var ch2 = ch + this.peek();\n        var ch3 = ch2 + this.peek(2);\n        var op1 = OPERATORS[ch];\n        var op2 = OPERATORS[ch2];\n        var op3 = OPERATORS[ch3];\n        if (op1 || op2 || op3) {\n          var token = op3 ? ch3 : (op2 ? ch2 : ch);\n          this.tokens.push({index: this.index, text: token, operator: true});\n          this.index += token.length;\n        } else {\n          this.throwError('Unexpected next character ', this.index, this.index + 1);\n        }\n      }\n    }\n    return this.tokens;\n  },\n\n  is: function(ch, chars) {\n    return chars.indexOf(ch) !== -1;\n  },\n\n  peek: function(i) {\n    var num = i || 1;\n    return (this.index + num < this.text.length) ? this.text.charAt(this.index + num) : false;\n  },\n\n  isNumber: function(ch) {\n    return ('0' <= ch && ch <= '9') && typeof ch === \"string\";\n  },\n\n  isWhitespace: function(ch) {\n    // IE treats non-breaking space as \\u00A0\n    return (ch === ' ' || ch === '\\r' || ch === '\\t' ||\n            ch === '\\n' || ch === '\\v' || ch === '\\u00A0');\n  },\n\n  isIdentifierStart: function(ch) {\n    return this.options.isIdentifierStart ?\n        this.options.isIdentifierStart(ch, this.codePointAt(ch)) :\n        this.isValidIdentifierStart(ch);\n  },\n\n  isValidIdentifierStart: function(ch) {\n    return ('a' <= ch && ch <= 'z' ||\n            'A' <= ch && ch <= 'Z' ||\n            '_' === ch || ch === '$');\n  },\n\n  isIdentifierContinue: function(ch) {\n    return this.options.isIdentifierContinue ?\n        this.options.isIdentifierContinue(ch, this.codePointAt(ch)) :\n        this.isValidIdentifierContinue(ch);\n  },\n\n  isValidIdentifierContinue: function(ch, cp) {\n    return this.isValidIdentifierStart(ch, cp) || this.isNumber(ch);\n  },\n\n  codePointAt: function(ch) {\n    if (ch.length === 1) return ch.charCodeAt(0);\n    /*jshint bitwise: false*/\n    return (ch.charCodeAt(0) << 10) + ch.charCodeAt(1) - 0x35FDC00;\n    /*jshint bitwise: true*/\n  },\n\n  peekMultichar: function() {\n    var ch = this.text.charAt(this.index);\n    var peek = this.peek();\n    if (!peek) {\n      return ch;\n    }\n    var cp1 = ch.charCodeAt(0);\n    var cp2 = peek.charCodeAt(0);\n    if (cp1 >= 0xD800 && cp1 <= 0xDBFF && cp2 >= 0xDC00 && cp2 <= 0xDFFF) {\n      return ch + peek;\n    }\n    return ch;\n  },\n\n  isExpOperator: function(ch) {\n    return (ch === '-' || ch === '+' || this.isNumber(ch));\n  },\n\n  throwError: function(error, start, end) {\n    end = end || this.index;\n    var colStr = (isDefined(start)\n            ? 's ' + start +  '-' + this.index + ' [' + this.text.substring(start, end) + ']'\n            : ' ' + end);\n    throw $parseMinErr('lexerr', 'Lexer Error: {0} at column{1} in expression [{2}].',\n        error, colStr, this.text);\n  },\n\n  readNumber: function() {\n    var number = '';\n    var start = this.index;\n    while (this.index < this.text.length) {\n      var ch = lowercase(this.text.charAt(this.index));\n      if (ch == '.' || this.isNumber(ch)) {\n        number += ch;\n      } else {\n        var peekCh = this.peek();\n        if (ch == 'e' && this.isExpOperator(peekCh)) {\n          number += ch;\n        } else if (this.isExpOperator(ch) &&\n            peekCh && this.isNumber(peekCh) &&\n            number.charAt(number.length - 1) == 'e') {\n          number += ch;\n        } else if (this.isExpOperator(ch) &&\n            (!peekCh || !this.isNumber(peekCh)) &&\n            number.charAt(number.length - 1) == 'e') {\n          this.throwError('Invalid exponent');\n        } else {\n          break;\n        }\n      }\n      this.index++;\n    }\n    this.tokens.push({\n      index: start,\n      text: number,\n      constant: true,\n      value: Number(number)\n    });\n  },\n\n  readIdent: function() {\n    var start = this.index;\n    this.index += this.peekMultichar().length;\n    while (this.index < this.text.length) {\n      var ch = this.peekMultichar();\n      if (!this.isIdentifierContinue(ch)) {\n        break;\n      }\n      this.index += ch.length;\n    }\n    this.tokens.push({\n      index: start,\n      text: this.text.slice(start, this.index),\n      identifier: true\n    });\n  },\n\n  readString: function(quote) {\n    var start = this.index;\n    this.index++;\n    var string = '';\n    var rawString = quote;\n    var escape = false;\n    while (this.index < this.text.length) {\n      var ch = this.text.charAt(this.index);\n      rawString += ch;\n      if (escape) {\n        if (ch === 'u') {\n          var hex = this.text.substring(this.index + 1, this.index + 5);\n          if (!hex.match(/[\\da-f]{4}/i)) {\n            this.throwError('Invalid unicode escape [\\\\u' + hex + ']');\n          }\n          this.index += 4;\n          string += String.fromCharCode(parseInt(hex, 16));\n        } else {\n          var rep = ESCAPE[ch];\n          string = string + (rep || ch);\n        }\n        escape = false;\n      } else if (ch === '\\\\') {\n        escape = true;\n      } else if (ch === quote) {\n        this.index++;\n        this.tokens.push({\n          index: start,\n          text: rawString,\n          constant: true,\n          value: string\n        });\n        return;\n      } else {\n        string += ch;\n      }\n      this.index++;\n    }\n    this.throwError('Unterminated quote', start);\n  }\n};\n\nvar AST = function(lexer, options) {\n  this.lexer = lexer;\n  this.options = options;\n};\n\nAST.Program = 'Program';\nAST.ExpressionStatement = 'ExpressionStatement';\nAST.AssignmentExpression = 'AssignmentExpression';\nAST.ConditionalExpression = 'ConditionalExpression';\nAST.LogicalExpression = 'LogicalExpression';\nAST.BinaryExpression = 'BinaryExpression';\nAST.UnaryExpression = 'UnaryExpression';\nAST.CallExpression = 'CallExpression';\nAST.MemberExpression = 'MemberExpression';\nAST.Identifier = 'Identifier';\nAST.Literal = 'Literal';\nAST.ArrayExpression = 'ArrayExpression';\nAST.Property = 'Property';\nAST.ObjectExpression = 'ObjectExpression';\nAST.ThisExpression = 'ThisExpression';\nAST.LocalsExpression = 'LocalsExpression';\n\n// Internal use only\nAST.NGValueParameter = 'NGValueParameter';\n\nAST.prototype = {\n  ast: function(text) {\n    this.text = text;\n    this.tokens = this.lexer.lex(text);\n\n    var value = this.program();\n\n    if (this.tokens.length !== 0) {\n      this.throwError('is an unexpected token', this.tokens[0]);\n    }\n\n    return value;\n  },\n\n  program: function() {\n    var body = [];\n    while (true) {\n      if (this.tokens.length > 0 && !this.peek('}', ')', ';', ']'))\n        body.push(this.expressionStatement());\n      if (!this.expect(';')) {\n        return { type: AST.Program, body: body};\n      }\n    }\n  },\n\n  expressionStatement: function() {\n    return { type: AST.ExpressionStatement, expression: this.filterChain() };\n  },\n\n  filterChain: function() {\n    var left = this.expression();\n    var token;\n    while ((token = this.expect('|'))) {\n      left = this.filter(left);\n    }\n    return left;\n  },\n\n  expression: function() {\n    return this.assignment();\n  },\n\n  assignment: function() {\n    var result = this.ternary();\n    if (this.expect('=')) {\n      result = { type: AST.AssignmentExpression, left: result, right: this.assignment(), operator: '='};\n    }\n    return result;\n  },\n\n  ternary: function() {\n    var test = this.logicalOR();\n    var alternate;\n    var consequent;\n    if (this.expect('?')) {\n      alternate = this.expression();\n      if (this.consume(':')) {\n        consequent = this.expression();\n        return { type: AST.ConditionalExpression, test: test, alternate: alternate, consequent: consequent};\n      }\n    }\n    return test;\n  },\n\n  logicalOR: function() {\n    var left = this.logicalAND();\n    while (this.expect('||')) {\n      left = { type: AST.LogicalExpression, operator: '||', left: left, right: this.logicalAND() };\n    }\n    return left;\n  },\n\n  logicalAND: function() {\n    var left = this.equality();\n    while (this.expect('&&')) {\n      left = { type: AST.LogicalExpression, operator: '&&', left: left, right: this.equality()};\n    }\n    return left;\n  },\n\n  equality: function() {\n    var left = this.relational();\n    var token;\n    while ((token = this.expect('==','!=','===','!=='))) {\n      left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.relational() };\n    }\n    return left;\n  },\n\n  relational: function() {\n    var left = this.additive();\n    var token;\n    while ((token = this.expect('<', '>', '<=', '>='))) {\n      left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.additive() };\n    }\n    return left;\n  },\n\n  additive: function() {\n    var left = this.multiplicative();\n    var token;\n    while ((token = this.expect('+','-'))) {\n      left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.multiplicative() };\n    }\n    return left;\n  },\n\n  multiplicative: function() {\n    var left = this.unary();\n    var token;\n    while ((token = this.expect('*','/','%'))) {\n      left = { type: AST.BinaryExpression, operator: token.text, left: left, right: this.unary() };\n    }\n    return left;\n  },\n\n  unary: function() {\n    var token;\n    if ((token = this.expect('+', '-', '!'))) {\n      return { type: AST.UnaryExpression, operator: token.text, prefix: true, argument: this.unary() };\n    } else {\n      return this.primary();\n    }\n  },\n\n  primary: function() {\n    var primary;\n    if (this.expect('(')) {\n      primary = this.filterChain();\n      this.consume(')');\n    } else if (this.expect('[')) {\n      primary = this.arrayDeclaration();\n    } else if (this.expect('{')) {\n      primary = this.object();\n    } else if (this.selfReferential.hasOwnProperty(this.peek().text)) {\n      primary = copy(this.selfReferential[this.consume().text]);\n    } else if (this.options.literals.hasOwnProperty(this.peek().text)) {\n      primary = { type: AST.Literal, value: this.options.literals[this.consume().text]};\n    } else if (this.peek().identifier) {\n      primary = this.identifier();\n    } else if (this.peek().constant) {\n      primary = this.constant();\n    } else {\n      this.throwError('not a primary expression', this.peek());\n    }\n\n    var next;\n    while ((next = this.expect('(', '[', '.'))) {\n      if (next.text === '(') {\n        primary = {type: AST.CallExpression, callee: primary, arguments: this.parseArguments() };\n        this.consume(')');\n      } else if (next.text === '[') {\n        primary = { type: AST.MemberExpression, object: primary, property: this.expression(), computed: true };\n        this.consume(']');\n      } else if (next.text === '.') {\n        primary = { type: AST.MemberExpression, object: primary, property: this.identifier(), computed: false };\n      } else {\n        this.throwError('IMPOSSIBLE');\n      }\n    }\n    return primary;\n  },\n\n  filter: function(baseExpression) {\n    var args = [baseExpression];\n    var result = {type: AST.CallExpression, callee: this.identifier(), arguments: args, filter: true};\n\n    while (this.expect(':')) {\n      args.push(this.expression());\n    }\n\n    return result;\n  },\n\n  parseArguments: function() {\n    var args = [];\n    if (this.peekToken().text !== ')') {\n      do {\n        args.push(this.expression());\n      } while (this.expect(','));\n    }\n    return args;\n  },\n\n  identifier: function() {\n    var token = this.consume();\n    if (!token.identifier) {\n      this.throwError('is not a valid identifier', token);\n    }\n    return { type: AST.Identifier, name: token.text };\n  },\n\n  constant: function() {\n    // TODO check that it is a constant\n    return { type: AST.Literal, value: this.consume().value };\n  },\n\n  arrayDeclaration: function() {\n    var elements = [];\n    if (this.peekToken().text !== ']') {\n      do {\n        if (this.peek(']')) {\n          // Support trailing commas per ES5.1.\n          break;\n        }\n        elements.push(this.expression());\n      } while (this.expect(','));\n    }\n    this.consume(']');\n\n    return { type: AST.ArrayExpression, elements: elements };\n  },\n\n  object: function() {\n    var properties = [], property;\n    if (this.peekToken().text !== '}') {\n      do {\n        if (this.peek('}')) {\n          // Support trailing commas per ES5.1.\n          break;\n        }\n        property = {type: AST.Property, kind: 'init'};\n        if (this.peek().constant) {\n          property.key = this.constant();\n        } else if (this.peek().identifier) {\n          property.key = this.identifier();\n        } else {\n          this.throwError(\"invalid key\", this.peek());\n        }\n        this.consume(':');\n        property.value = this.expression();\n        properties.push(property);\n      } while (this.expect(','));\n    }\n    this.consume('}');\n\n    return {type: AST.ObjectExpression, properties: properties };\n  },\n\n  throwError: function(msg, token) {\n    throw $parseMinErr('syntax',\n        'Syntax Error: Token \\'{0}\\' {1} at column {2} of the expression [{3}] starting at [{4}].',\n          token.text, msg, (token.index + 1), this.text, this.text.substring(token.index));\n  },\n\n  consume: function(e1) {\n    if (this.tokens.length === 0) {\n      throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text);\n    }\n\n    var token = this.expect(e1);\n    if (!token) {\n      this.throwError('is unexpected, expecting [' + e1 + ']', this.peek());\n    }\n    return token;\n  },\n\n  peekToken: function() {\n    if (this.tokens.length === 0) {\n      throw $parseMinErr('ueoe', 'Unexpected end of expression: {0}', this.text);\n    }\n    return this.tokens[0];\n  },\n\n  peek: function(e1, e2, e3, e4) {\n    return this.peekAhead(0, e1, e2, e3, e4);\n  },\n\n  peekAhead: function(i, e1, e2, e3, e4) {\n    if (this.tokens.length > i) {\n      var token = this.tokens[i];\n      var t = token.text;\n      if (t === e1 || t === e2 || t === e3 || t === e4 ||\n          (!e1 && !e2 && !e3 && !e4)) {\n        return token;\n      }\n    }\n    return false;\n  },\n\n  expect: function(e1, e2, e3, e4) {\n    var token = this.peek(e1, e2, e3, e4);\n    if (token) {\n      this.tokens.shift();\n      return token;\n    }\n    return false;\n  },\n\n  selfReferential: {\n    'this': {type: AST.ThisExpression },\n    '$locals': {type: AST.LocalsExpression }\n  }\n};\n\nfunction ifDefined(v, d) {\n  return typeof v !== 'undefined' ? v : d;\n}\n\nfunction plusFn(l, r) {\n  if (typeof l === 'undefined') return r;\n  if (typeof r === 'undefined') return l;\n  return l + r;\n}\n\nfunction isStateless($filter, filterName) {\n  var fn = $filter(filterName);\n  return !fn.$stateful;\n}\n\nfunction findConstantAndWatchExpressions(ast, $filter) {\n  var allConstants;\n  var argsToWatch;\n  switch (ast.type) {\n  case AST.Program:\n    allConstants = true;\n    forEach(ast.body, function(expr) {\n      findConstantAndWatchExpressions(expr.expression, $filter);\n      allConstants = allConstants && expr.expression.constant;\n    });\n    ast.constant = allConstants;\n    break;\n  case AST.Literal:\n    ast.constant = true;\n    ast.toWatch = [];\n    break;\n  case AST.UnaryExpression:\n    findConstantAndWatchExpressions(ast.argument, $filter);\n    ast.constant = ast.argument.constant;\n    ast.toWatch = ast.argument.toWatch;\n    break;\n  case AST.BinaryExpression:\n    findConstantAndWatchExpressions(ast.left, $filter);\n    findConstantAndWatchExpressions(ast.right, $filter);\n    ast.constant = ast.left.constant && ast.right.constant;\n    ast.toWatch = ast.left.toWatch.concat(ast.right.toWatch);\n    break;\n  case AST.LogicalExpression:\n    findConstantAndWatchExpressions(ast.left, $filter);\n    findConstantAndWatchExpressions(ast.right, $filter);\n    ast.constant = ast.left.constant && ast.right.constant;\n    ast.toWatch = ast.constant ? [] : [ast];\n    break;\n  case AST.ConditionalExpression:\n    findConstantAndWatchExpressions(ast.test, $filter);\n    findConstantAndWatchExpressions(ast.alternate, $filter);\n    findConstantAndWatchExpressions(ast.consequent, $filter);\n    ast.constant = ast.test.constant && ast.alternate.constant && ast.consequent.constant;\n    ast.toWatch = ast.constant ? [] : [ast];\n    break;\n  case AST.Identifier:\n    ast.constant = false;\n    ast.toWatch = [ast];\n    break;\n  case AST.MemberExpression:\n    findConstantAndWatchExpressions(ast.object, $filter);\n    if (ast.computed) {\n      findConstantAndWatchExpressions(ast.property, $filter);\n    }\n    ast.constant = ast.object.constant && (!ast.computed || ast.property.constant);\n    ast.toWatch = [ast];\n    break;\n  case AST.CallExpression:\n    allConstants = ast.filter ? isStateless($filter, ast.callee.name) : false;\n    argsToWatch = [];\n    forEach(ast.arguments, function(expr) {\n      findConstantAndWatchExpressions(expr, $filter);\n      allConstants = allConstants && expr.constant;\n      if (!expr.constant) {\n        argsToWatch.push.apply(argsToWatch, expr.toWatch);\n      }\n    });\n    ast.constant = allConstants;\n    ast.toWatch = ast.filter && isStateless($filter, ast.callee.name) ? argsToWatch : [ast];\n    break;\n  case AST.AssignmentExpression:\n    findConstantAndWatchExpressions(ast.left, $filter);\n    findConstantAndWatchExpressions(ast.right, $filter);\n    ast.constant = ast.left.constant && ast.right.constant;\n    ast.toWatch = [ast];\n    break;\n  case AST.ArrayExpression:\n    allConstants = true;\n    argsToWatch = [];\n    forEach(ast.elements, function(expr) {\n      findConstantAndWatchExpressions(expr, $filter);\n      allConstants = allConstants && expr.constant;\n      if (!expr.constant) {\n        argsToWatch.push.apply(argsToWatch, expr.toWatch);\n      }\n    });\n    ast.constant = allConstants;\n    ast.toWatch = argsToWatch;\n    break;\n  case AST.ObjectExpression:\n    allConstants = true;\n    argsToWatch = [];\n    forEach(ast.properties, function(property) {\n      findConstantAndWatchExpressions(property.value, $filter);\n      allConstants = allConstants && property.value.constant;\n      if (!property.value.constant) {\n        argsToWatch.push.apply(argsToWatch, property.value.toWatch);\n      }\n    });\n    ast.constant = allConstants;\n    ast.toWatch = argsToWatch;\n    break;\n  case AST.ThisExpression:\n    ast.constant = false;\n    ast.toWatch = [];\n    break;\n  case AST.LocalsExpression:\n    ast.constant = false;\n    ast.toWatch = [];\n    break;\n  }\n}\n\nfunction getInputs(body) {\n  if (body.length != 1) return;\n  var lastExpression = body[0].expression;\n  var candidate = lastExpression.toWatch;\n  if (candidate.length !== 1) return candidate;\n  return candidate[0] !== lastExpression ? candidate : undefined;\n}\n\nfunction isAssignable(ast) {\n  return ast.type === AST.Identifier || ast.type === AST.MemberExpression;\n}\n\nfunction assignableAST(ast) {\n  if (ast.body.length === 1 && isAssignable(ast.body[0].expression)) {\n    return {type: AST.AssignmentExpression, left: ast.body[0].expression, right: {type: AST.NGValueParameter}, operator: '='};\n  }\n}\n\nfunction isLiteral(ast) {\n  return ast.body.length === 0 ||\n      ast.body.length === 1 && (\n      ast.body[0].expression.type === AST.Literal ||\n      ast.body[0].expression.type === AST.ArrayExpression ||\n      ast.body[0].expression.type === AST.ObjectExpression);\n}\n\nfunction isConstant(ast) {\n  return ast.constant;\n}\n\nfunction ASTCompiler(astBuilder, $filter) {\n  this.astBuilder = astBuilder;\n  this.$filter = $filter;\n}\n\nASTCompiler.prototype = {\n  compile: function(expression, expensiveChecks) {\n    var self = this;\n    var ast = this.astBuilder.ast(expression);\n    this.state = {\n      nextId: 0,\n      filters: {},\n      expensiveChecks: expensiveChecks,\n      fn: {vars: [], body: [], own: {}},\n      assign: {vars: [], body: [], own: {}},\n      inputs: []\n    };\n    findConstantAndWatchExpressions(ast, self.$filter);\n    var extra = '';\n    var assignable;\n    this.stage = 'assign';\n    if ((assignable = assignableAST(ast))) {\n      this.state.computing = 'assign';\n      var result = this.nextId();\n      this.recurse(assignable, result);\n      this.return_(result);\n      extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l');\n    }\n    var toWatch = getInputs(ast.body);\n    self.stage = 'inputs';\n    forEach(toWatch, function(watch, key) {\n      var fnKey = 'fn' + key;\n      self.state[fnKey] = {vars: [], body: [], own: {}};\n      self.state.computing = fnKey;\n      var intoId = self.nextId();\n      self.recurse(watch, intoId);\n      self.return_(intoId);\n      self.state.inputs.push(fnKey);\n      watch.watchId = key;\n    });\n    this.state.computing = 'fn';\n    this.stage = 'main';\n    this.recurse(ast);\n    var fnString =\n      // The build and minification steps remove the string \"use strict\" from the code, but this is done using a regex.\n      // This is a workaround for this until we do a better job at only removing the prefix only when we should.\n      '\"' + this.USE + ' ' + this.STRICT + '\";\\n' +\n      this.filterPrefix() +\n      'var fn=' + this.generateFunction('fn', 's,l,a,i') +\n      extra +\n      this.watchFns() +\n      'return fn;';\n\n    /* jshint -W054 */\n    var fn = (new Function('$filter',\n        'ensureSafeMemberName',\n        'ensureSafeObject',\n        'ensureSafeFunction',\n        'getStringValue',\n        'ensureSafeAssignContext',\n        'ifDefined',\n        'plus',\n        'text',\n        fnString))(\n          this.$filter,\n          ensureSafeMemberName,\n          ensureSafeObject,\n          ensureSafeFunction,\n          getStringValue,\n          ensureSafeAssignContext,\n          ifDefined,\n          plusFn,\n          expression);\n    /* jshint +W054 */\n    this.state = this.stage = undefined;\n    fn.literal = isLiteral(ast);\n    fn.constant = isConstant(ast);\n    return fn;\n  },\n\n  USE: 'use',\n\n  STRICT: 'strict',\n\n  watchFns: function() {\n    var result = [];\n    var fns = this.state.inputs;\n    var self = this;\n    forEach(fns, function(name) {\n      result.push('var ' + name + '=' + self.generateFunction(name, 's'));\n    });\n    if (fns.length) {\n      result.push('fn.inputs=[' + fns.join(',') + '];');\n    }\n    return result.join('');\n  },\n\n  generateFunction: function(name, params) {\n    return 'function(' + params + '){' +\n        this.varsPrefix(name) +\n        this.body(name) +\n        '};';\n  },\n\n  filterPrefix: function() {\n    var parts = [];\n    var self = this;\n    forEach(this.state.filters, function(id, filter) {\n      parts.push(id + '=$filter(' + self.escape(filter) + ')');\n    });\n    if (parts.length) return 'var ' + parts.join(',') + ';';\n    return '';\n  },\n\n  varsPrefix: function(section) {\n    return this.state[section].vars.length ? 'var ' + this.state[section].vars.join(',') + ';' : '';\n  },\n\n  body: function(section) {\n    return this.state[section].body.join('');\n  },\n\n  recurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) {\n    var left, right, self = this, args, expression;\n    recursionFn = recursionFn || noop;\n    if (!skipWatchIdCheck && isDefined(ast.watchId)) {\n      intoId = intoId || this.nextId();\n      this.if_('i',\n        this.lazyAssign(intoId, this.computedMember('i', ast.watchId)),\n        this.lazyRecurse(ast, intoId, nameId, recursionFn, create, true)\n      );\n      return;\n    }\n    switch (ast.type) {\n    case AST.Program:\n      forEach(ast.body, function(expression, pos) {\n        self.recurse(expression.expression, undefined, undefined, function(expr) { right = expr; });\n        if (pos !== ast.body.length - 1) {\n          self.current().body.push(right, ';');\n        } else {\n          self.return_(right);\n        }\n      });\n      break;\n    case AST.Literal:\n      expression = this.escape(ast.value);\n      this.assign(intoId, expression);\n      recursionFn(expression);\n      break;\n    case AST.UnaryExpression:\n      this.recurse(ast.argument, undefined, undefined, function(expr) { right = expr; });\n      expression = ast.operator + '(' + this.ifDefined(right, 0) + ')';\n      this.assign(intoId, expression);\n      recursionFn(expression);\n      break;\n    case AST.BinaryExpression:\n      this.recurse(ast.left, undefined, undefined, function(expr) { left = expr; });\n      this.recurse(ast.right, undefined, undefined, function(expr) { right = expr; });\n      if (ast.operator === '+') {\n        expression = this.plus(left, right);\n      } else if (ast.operator === '-') {\n        expression = this.ifDefined(left, 0) + ast.operator + this.ifDefined(right, 0);\n      } else {\n        expression = '(' + left + ')' + ast.operator + '(' + right + ')';\n      }\n      this.assign(intoId, expression);\n      recursionFn(expression);\n      break;\n    case AST.LogicalExpression:\n      intoId = intoId || this.nextId();\n      self.recurse(ast.left, intoId);\n      self.if_(ast.operator === '&&' ? intoId : self.not(intoId), self.lazyRecurse(ast.right, intoId));\n      recursionFn(intoId);\n      break;\n    case AST.ConditionalExpression:\n      intoId = intoId || this.nextId();\n      self.recurse(ast.test, intoId);\n      self.if_(intoId, self.lazyRecurse(ast.alternate, intoId), self.lazyRecurse(ast.consequent, intoId));\n      recursionFn(intoId);\n      break;\n    case AST.Identifier:\n      intoId = intoId || this.nextId();\n      if (nameId) {\n        nameId.context = self.stage === 'inputs' ? 's' : this.assign(this.nextId(), this.getHasOwnProperty('l', ast.name) + '?l:s');\n        nameId.computed = false;\n        nameId.name = ast.name;\n      }\n      ensureSafeMemberName(ast.name);\n      self.if_(self.stage === 'inputs' || self.not(self.getHasOwnProperty('l', ast.name)),\n        function() {\n          self.if_(self.stage === 'inputs' || 's', function() {\n            if (create && create !== 1) {\n              self.if_(\n                self.not(self.nonComputedMember('s', ast.name)),\n                self.lazyAssign(self.nonComputedMember('s', ast.name), '{}'));\n            }\n            self.assign(intoId, self.nonComputedMember('s', ast.name));\n          });\n        }, intoId && self.lazyAssign(intoId, self.nonComputedMember('l', ast.name))\n        );\n      if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.name)) {\n        self.addEnsureSafeObject(intoId);\n      }\n      recursionFn(intoId);\n      break;\n    case AST.MemberExpression:\n      left = nameId && (nameId.context = this.nextId()) || this.nextId();\n      intoId = intoId || this.nextId();\n      self.recurse(ast.object, left, undefined, function() {\n        self.if_(self.notNull(left), function() {\n          if (create && create !== 1) {\n            self.addEnsureSafeAssignContext(left);\n          }\n          if (ast.computed) {\n            right = self.nextId();\n            self.recurse(ast.property, right);\n            self.getStringValue(right);\n            self.addEnsureSafeMemberName(right);\n            if (create && create !== 1) {\n              self.if_(self.not(self.computedMember(left, right)), self.lazyAssign(self.computedMember(left, right), '{}'));\n            }\n            expression = self.ensureSafeObject(self.computedMember(left, right));\n            self.assign(intoId, expression);\n            if (nameId) {\n              nameId.computed = true;\n              nameId.name = right;\n            }\n          } else {\n            ensureSafeMemberName(ast.property.name);\n            if (create && create !== 1) {\n              self.if_(self.not(self.nonComputedMember(left, ast.property.name)), self.lazyAssign(self.nonComputedMember(left, ast.property.name), '{}'));\n            }\n            expression = self.nonComputedMember(left, ast.property.name);\n            if (self.state.expensiveChecks || isPossiblyDangerousMemberName(ast.property.name)) {\n              expression = self.ensureSafeObject(expression);\n            }\n            self.assign(intoId, expression);\n            if (nameId) {\n              nameId.computed = false;\n              nameId.name = ast.property.name;\n            }\n          }\n        }, function() {\n          self.assign(intoId, 'undefined');\n        });\n        recursionFn(intoId);\n      }, !!create);\n      break;\n    case AST.CallExpression:\n      intoId = intoId || this.nextId();\n      if (ast.filter) {\n        right = self.filter(ast.callee.name);\n        args = [];\n        forEach(ast.arguments, function(expr) {\n          var argument = self.nextId();\n          self.recurse(expr, argument);\n          args.push(argument);\n        });\n        expression = right + '(' + args.join(',') + ')';\n        self.assign(intoId, expression);\n        recursionFn(intoId);\n      } else {\n        right = self.nextId();\n        left = {};\n        args = [];\n        self.recurse(ast.callee, right, left, function() {\n          self.if_(self.notNull(right), function() {\n            self.addEnsureSafeFunction(right);\n            forEach(ast.arguments, function(expr) {\n              self.recurse(expr, self.nextId(), undefined, function(argument) {\n                args.push(self.ensureSafeObject(argument));\n              });\n            });\n            if (left.name) {\n              if (!self.state.expensiveChecks) {\n                self.addEnsureSafeObject(left.context);\n              }\n              expression = self.member(left.context, left.name, left.computed) + '(' + args.join(',') + ')';\n            } else {\n              expression = right + '(' + args.join(',') + ')';\n            }\n            expression = self.ensureSafeObject(expression);\n            self.assign(intoId, expression);\n          }, function() {\n            self.assign(intoId, 'undefined');\n          });\n          recursionFn(intoId);\n        });\n      }\n      break;\n    case AST.AssignmentExpression:\n      right = this.nextId();\n      left = {};\n      if (!isAssignable(ast.left)) {\n        throw $parseMinErr('lval', 'Trying to assign a value to a non l-value');\n      }\n      this.recurse(ast.left, undefined, left, function() {\n        self.if_(self.notNull(left.context), function() {\n          self.recurse(ast.right, right);\n          self.addEnsureSafeObject(self.member(left.context, left.name, left.computed));\n          self.addEnsureSafeAssignContext(left.context);\n          expression = self.member(left.context, left.name, left.computed) + ast.operator + right;\n          self.assign(intoId, expression);\n          recursionFn(intoId || expression);\n        });\n      }, 1);\n      break;\n    case AST.ArrayExpression:\n      args = [];\n      forEach(ast.elements, function(expr) {\n        self.recurse(expr, self.nextId(), undefined, function(argument) {\n          args.push(argument);\n        });\n      });\n      expression = '[' + args.join(',') + ']';\n      this.assign(intoId, expression);\n      recursionFn(expression);\n      break;\n    case AST.ObjectExpression:\n      args = [];\n      forEach(ast.properties, function(property) {\n        self.recurse(property.value, self.nextId(), undefined, function(expr) {\n          args.push(self.escape(\n              property.key.type === AST.Identifier ? property.key.name :\n                ('' + property.key.value)) +\n              ':' + expr);\n        });\n      });\n      expression = '{' + args.join(',') + '}';\n      this.assign(intoId, expression);\n      recursionFn(expression);\n      break;\n    case AST.ThisExpression:\n      this.assign(intoId, 's');\n      recursionFn('s');\n      break;\n    case AST.LocalsExpression:\n      this.assign(intoId, 'l');\n      recursionFn('l');\n      break;\n    case AST.NGValueParameter:\n      this.assign(intoId, 'v');\n      recursionFn('v');\n      break;\n    }\n  },\n\n  getHasOwnProperty: function(element, property) {\n    var key = element + '.' + property;\n    var own = this.current().own;\n    if (!own.hasOwnProperty(key)) {\n      own[key] = this.nextId(false, element + '&&(' + this.escape(property) + ' in ' + element + ')');\n    }\n    return own[key];\n  },\n\n  assign: function(id, value) {\n    if (!id) return;\n    this.current().body.push(id, '=', value, ';');\n    return id;\n  },\n\n  filter: function(filterName) {\n    if (!this.state.filters.hasOwnProperty(filterName)) {\n      this.state.filters[filterName] = this.nextId(true);\n    }\n    return this.state.filters[filterName];\n  },\n\n  ifDefined: function(id, defaultValue) {\n    return 'ifDefined(' + id + ',' + this.escape(defaultValue) + ')';\n  },\n\n  plus: function(left, right) {\n    return 'plus(' + left + ',' + right + ')';\n  },\n\n  return_: function(id) {\n    this.current().body.push('return ', id, ';');\n  },\n\n  if_: function(test, alternate, consequent) {\n    if (test === true) {\n      alternate();\n    } else {\n      var body = this.current().body;\n      body.push('if(', test, '){');\n      alternate();\n      body.push('}');\n      if (consequent) {\n        body.push('else{');\n        consequent();\n        body.push('}');\n      }\n    }\n  },\n\n  not: function(expression) {\n    return '!(' + expression + ')';\n  },\n\n  notNull: function(expression) {\n    return expression + '!=null';\n  },\n\n  nonComputedMember: function(left, right) {\n    var SAFE_IDENTIFIER = /[$_a-zA-Z][$_a-zA-Z0-9]*/;\n    var UNSAFE_CHARACTERS = /[^$_a-zA-Z0-9]/g;\n    if (SAFE_IDENTIFIER.test(right)) {\n      return left + '.' + right;\n    } else {\n      return left  + '[\"' + right.replace(UNSAFE_CHARACTERS, this.stringEscapeFn) + '\"]';\n    }\n  },\n\n  computedMember: function(left, right) {\n    return left + '[' + right + ']';\n  },\n\n  member: function(left, right, computed) {\n    if (computed) return this.computedMember(left, right);\n    return this.nonComputedMember(left, right);\n  },\n\n  addEnsureSafeObject: function(item) {\n    this.current().body.push(this.ensureSafeObject(item), ';');\n  },\n\n  addEnsureSafeMemberName: function(item) {\n    this.current().body.push(this.ensureSafeMemberName(item), ';');\n  },\n\n  addEnsureSafeFunction: function(item) {\n    this.current().body.push(this.ensureSafeFunction(item), ';');\n  },\n\n  addEnsureSafeAssignContext: function(item) {\n    this.current().body.push(this.ensureSafeAssignContext(item), ';');\n  },\n\n  ensureSafeObject: function(item) {\n    return 'ensureSafeObject(' + item + ',text)';\n  },\n\n  ensureSafeMemberName: function(item) {\n    return 'ensureSafeMemberName(' + item + ',text)';\n  },\n\n  ensureSafeFunction: function(item) {\n    return 'ensureSafeFunction(' + item + ',text)';\n  },\n\n  getStringValue: function(item) {\n    this.assign(item, 'getStringValue(' + item + ')');\n  },\n\n  ensureSafeAssignContext: function(item) {\n    return 'ensureSafeAssignContext(' + item + ',text)';\n  },\n\n  lazyRecurse: function(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck) {\n    var self = this;\n    return function() {\n      self.recurse(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck);\n    };\n  },\n\n  lazyAssign: function(id, value) {\n    var self = this;\n    return function() {\n      self.assign(id, value);\n    };\n  },\n\n  stringEscapeRegex: /[^ a-zA-Z0-9]/g,\n\n  stringEscapeFn: function(c) {\n    return '\\\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);\n  },\n\n  escape: function(value) {\n    if (isString(value)) return \"'\" + value.replace(this.stringEscapeRegex, this.stringEscapeFn) + \"'\";\n    if (isNumber(value)) return value.toString();\n    if (value === true) return 'true';\n    if (value === false) return 'false';\n    if (value === null) return 'null';\n    if (typeof value === 'undefined') return 'undefined';\n\n    throw $parseMinErr('esc', 'IMPOSSIBLE');\n  },\n\n  nextId: function(skip, init) {\n    var id = 'v' + (this.state.nextId++);\n    if (!skip) {\n      this.current().vars.push(id + (init ? '=' + init : ''));\n    }\n    return id;\n  },\n\n  current: function() {\n    return this.state[this.state.computing];\n  }\n};\n\n\nfunction ASTInterpreter(astBuilder, $filter) {\n  this.astBuilder = astBuilder;\n  this.$filter = $filter;\n}\n\nASTInterpreter.prototype = {\n  compile: function(expression, expensiveChecks) {\n    var self = this;\n    var ast = this.astBuilder.ast(expression);\n    this.expression = expression;\n    this.expensiveChecks = expensiveChecks;\n    findConstantAndWatchExpressions(ast, self.$filter);\n    var assignable;\n    var assign;\n    if ((assignable = assignableAST(ast))) {\n      assign = this.recurse(assignable);\n    }\n    var toWatch = getInputs(ast.body);\n    var inputs;\n    if (toWatch) {\n      inputs = [];\n      forEach(toWatch, function(watch, key) {\n        var input = self.recurse(watch);\n        watch.input = input;\n        inputs.push(input);\n        watch.watchId = key;\n      });\n    }\n    var expressions = [];\n    forEach(ast.body, function(expression) {\n      expressions.push(self.recurse(expression.expression));\n    });\n    var fn = ast.body.length === 0 ? noop :\n             ast.body.length === 1 ? expressions[0] :\n             function(scope, locals) {\n               var lastValue;\n               forEach(expressions, function(exp) {\n                 lastValue = exp(scope, locals);\n               });\n               return lastValue;\n             };\n    if (assign) {\n      fn.assign = function(scope, value, locals) {\n        return assign(scope, locals, value);\n      };\n    }\n    if (inputs) {\n      fn.inputs = inputs;\n    }\n    fn.literal = isLiteral(ast);\n    fn.constant = isConstant(ast);\n    return fn;\n  },\n\n  recurse: function(ast, context, create) {\n    var left, right, self = this, args, expression;\n    if (ast.input) {\n      return this.inputs(ast.input, ast.watchId);\n    }\n    switch (ast.type) {\n    case AST.Literal:\n      return this.value(ast.value, context);\n    case AST.UnaryExpression:\n      right = this.recurse(ast.argument);\n      return this['unary' + ast.operator](right, context);\n    case AST.BinaryExpression:\n      left = this.recurse(ast.left);\n      right = this.recurse(ast.right);\n      return this['binary' + ast.operator](left, right, context);\n    case AST.LogicalExpression:\n      left = this.recurse(ast.left);\n      right = this.recurse(ast.right);\n      return this['binary' + ast.operator](left, right, context);\n    case AST.ConditionalExpression:\n      return this['ternary?:'](\n        this.recurse(ast.test),\n        this.recurse(ast.alternate),\n        this.recurse(ast.consequent),\n        context\n      );\n    case AST.Identifier:\n      ensureSafeMemberName(ast.name, self.expression);\n      return self.identifier(ast.name,\n                             self.expensiveChecks || isPossiblyDangerousMemberName(ast.name),\n                             context, create, self.expression);\n    case AST.MemberExpression:\n      left = this.recurse(ast.object, false, !!create);\n      if (!ast.computed) {\n        ensureSafeMemberName(ast.property.name, self.expression);\n        right = ast.property.name;\n      }\n      if (ast.computed) right = this.recurse(ast.property);\n      return ast.computed ?\n        this.computedMember(left, right, context, create, self.expression) :\n        this.nonComputedMember(left, right, self.expensiveChecks, context, create, self.expression);\n    case AST.CallExpression:\n      args = [];\n      forEach(ast.arguments, function(expr) {\n        args.push(self.recurse(expr));\n      });\n      if (ast.filter) right = this.$filter(ast.callee.name);\n      if (!ast.filter) right = this.recurse(ast.callee, true);\n      return ast.filter ?\n        function(scope, locals, assign, inputs) {\n          var values = [];\n          for (var i = 0; i < args.length; ++i) {\n            values.push(args[i](scope, locals, assign, inputs));\n          }\n          var value = right.apply(undefined, values, inputs);\n          return context ? {context: undefined, name: undefined, value: value} : value;\n        } :\n        function(scope, locals, assign, inputs) {\n          var rhs = right(scope, locals, assign, inputs);\n          var value;\n          if (rhs.value != null) {\n            ensureSafeObject(rhs.context, self.expression);\n            ensureSafeFunction(rhs.value, self.expression);\n            var values = [];\n            for (var i = 0; i < args.length; ++i) {\n              values.push(ensureSafeObject(args[i](scope, locals, assign, inputs), self.expression));\n            }\n            value = ensureSafeObject(rhs.value.apply(rhs.context, values), self.expression);\n          }\n          return context ? {value: value} : value;\n        };\n    case AST.AssignmentExpression:\n      left = this.recurse(ast.left, true, 1);\n      right = this.recurse(ast.right);\n      return function(scope, locals, assign, inputs) {\n        var lhs = left(scope, locals, assign, inputs);\n        var rhs = right(scope, locals, assign, inputs);\n        ensureSafeObject(lhs.value, self.expression);\n        ensureSafeAssignContext(lhs.context);\n        lhs.context[lhs.name] = rhs;\n        return context ? {value: rhs} : rhs;\n      };\n    case AST.ArrayExpression:\n      args = [];\n      forEach(ast.elements, function(expr) {\n        args.push(self.recurse(expr));\n      });\n      return function(scope, locals, assign, inputs) {\n        var value = [];\n        for (var i = 0; i < args.length; ++i) {\n          value.push(args[i](scope, locals, assign, inputs));\n        }\n        return context ? {value: value} : value;\n      };\n    case AST.ObjectExpression:\n      args = [];\n      forEach(ast.properties, function(property) {\n        args.push({key: property.key.type === AST.Identifier ?\n                        property.key.name :\n                        ('' + property.key.value),\n                   value: self.recurse(property.value)\n        });\n      });\n      return function(scope, locals, assign, inputs) {\n        var value = {};\n        for (var i = 0; i < args.length; ++i) {\n          value[args[i].key] = args[i].value(scope, locals, assign, inputs);\n        }\n        return context ? {value: value} : value;\n      };\n    case AST.ThisExpression:\n      return function(scope) {\n        return context ? {value: scope} : scope;\n      };\n    case AST.LocalsExpression:\n      return function(scope, locals) {\n        return context ? {value: locals} : locals;\n      };\n    case AST.NGValueParameter:\n      return function(scope, locals, assign) {\n        return context ? {value: assign} : assign;\n      };\n    }\n  },\n\n  'unary+': function(argument, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = argument(scope, locals, assign, inputs);\n      if (isDefined(arg)) {\n        arg = +arg;\n      } else {\n        arg = 0;\n      }\n      return context ? {value: arg} : arg;\n    };\n  },\n  'unary-': function(argument, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = argument(scope, locals, assign, inputs);\n      if (isDefined(arg)) {\n        arg = -arg;\n      } else {\n        arg = 0;\n      }\n      return context ? {value: arg} : arg;\n    };\n  },\n  'unary!': function(argument, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = !argument(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary+': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var lhs = left(scope, locals, assign, inputs);\n      var rhs = right(scope, locals, assign, inputs);\n      var arg = plusFn(lhs, rhs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary-': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var lhs = left(scope, locals, assign, inputs);\n      var rhs = right(scope, locals, assign, inputs);\n      var arg = (isDefined(lhs) ? lhs : 0) - (isDefined(rhs) ? rhs : 0);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary*': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) * right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary/': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) / right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary%': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) % right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary===': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) === right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary!==': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) !== right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary==': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) == right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary!=': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) != right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary<': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) < right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary>': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) > right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary<=': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) <= right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary>=': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) >= right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary&&': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) && right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'binary||': function(left, right, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = left(scope, locals, assign, inputs) || right(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  'ternary?:': function(test, alternate, consequent, context) {\n    return function(scope, locals, assign, inputs) {\n      var arg = test(scope, locals, assign, inputs) ? alternate(scope, locals, assign, inputs) : consequent(scope, locals, assign, inputs);\n      return context ? {value: arg} : arg;\n    };\n  },\n  value: function(value, context) {\n    return function() { return context ? {context: undefined, name: undefined, value: value} : value; };\n  },\n  identifier: function(name, expensiveChecks, context, create, expression) {\n    return function(scope, locals, assign, inputs) {\n      var base = locals && (name in locals) ? locals : scope;\n      if (create && create !== 1 && base && !(base[name])) {\n        base[name] = {};\n      }\n      var value = base ? base[name] : undefined;\n      if (expensiveChecks) {\n        ensureSafeObject(value, expression);\n      }\n      if (context) {\n        return {context: base, name: name, value: value};\n      } else {\n        return value;\n      }\n    };\n  },\n  computedMember: function(left, right, context, create, expression) {\n    return function(scope, locals, assign, inputs) {\n      var lhs = left(scope, locals, assign, inputs);\n      var rhs;\n      var value;\n      if (lhs != null) {\n        rhs = right(scope, locals, assign, inputs);\n        rhs = getStringValue(rhs);\n        ensureSafeMemberName(rhs, expression);\n        if (create && create !== 1) {\n          ensureSafeAssignContext(lhs);\n          if (lhs && !(lhs[rhs])) {\n            lhs[rhs] = {};\n          }\n        }\n        value = lhs[rhs];\n        ensureSafeObject(value, expression);\n      }\n      if (context) {\n        return {context: lhs, name: rhs, value: value};\n      } else {\n        return value;\n      }\n    };\n  },\n  nonComputedMember: function(left, right, expensiveChecks, context, create, expression) {\n    return function(scope, locals, assign, inputs) {\n      var lhs = left(scope, locals, assign, inputs);\n      if (create && create !== 1) {\n        ensureSafeAssignContext(lhs);\n        if (lhs && !(lhs[right])) {\n          lhs[right] = {};\n        }\n      }\n      var value = lhs != null ? lhs[right] : undefined;\n      if (expensiveChecks || isPossiblyDangerousMemberName(right)) {\n        ensureSafeObject(value, expression);\n      }\n      if (context) {\n        return {context: lhs, name: right, value: value};\n      } else {\n        return value;\n      }\n    };\n  },\n  inputs: function(input, watchId) {\n    return function(scope, value, locals, inputs) {\n      if (inputs) return inputs[watchId];\n      return input(scope, value, locals);\n    };\n  }\n};\n\n/**\n * @constructor\n */\nvar Parser = function(lexer, $filter, options) {\n  this.lexer = lexer;\n  this.$filter = $filter;\n  this.options = options;\n  this.ast = new AST(lexer, options);\n  this.astCompiler = options.csp ? new ASTInterpreter(this.ast, $filter) :\n                                   new ASTCompiler(this.ast, $filter);\n};\n\nParser.prototype = {\n  constructor: Parser,\n\n  parse: function(text) {\n    return this.astCompiler.compile(text, this.options.expensiveChecks);\n  }\n};\n\nfunction isPossiblyDangerousMemberName(name) {\n  return name == 'constructor';\n}\n\nvar objectValueOf = Object.prototype.valueOf;\n\nfunction getValueOf(value) {\n  return isFunction(value.valueOf) ? value.valueOf() : objectValueOf.call(value);\n}\n\n///////////////////////////////////\n\n/**\n * @ngdoc service\n * @name $parse\n * @kind function\n *\n * @description\n *\n * Converts Angular {@link guide/expression expression} into a function.\n *\n * ```js\n *   var getter = $parse('user.name');\n *   var setter = getter.assign;\n *   var context = {user:{name:'angular'}};\n *   var locals = {user:{name:'local'}};\n *\n *   expect(getter(context)).toEqual('angular');\n *   setter(context, 'newValue');\n *   expect(context.user.name).toEqual('newValue');\n *   expect(getter(context, locals)).toEqual('local');\n * ```\n *\n *\n * @param {string} expression String expression to compile.\n * @returns {function(context, locals)} a function which represents the compiled expression:\n *\n *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n *      are evaluated against (typically a scope object).\n *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n *      `context`.\n *\n *    The returned function also has the following properties:\n *      * `literal` – `{boolean}` – whether the expression's top-level node is a JavaScript\n *        literal.\n *      * `constant` – `{boolean}` – whether the expression is made entirely of JavaScript\n *        constant literals.\n *      * `assign` – `{?function(context, value)}` – if the expression is assignable, this will be\n *        set to a function to change its value on the given context.\n *\n */\n\n\n/**\n * @ngdoc provider\n * @name $parseProvider\n *\n * @description\n * `$parseProvider` can be used for configuring the default behavior of the {@link ng.$parse $parse}\n *  service.\n */\nfunction $ParseProvider() {\n  var cacheDefault = createMap();\n  var cacheExpensive = createMap();\n  var literals = {\n    'true': true,\n    'false': false,\n    'null': null,\n    'undefined': undefined\n  };\n  var identStart, identContinue;\n\n  /**\n   * @ngdoc method\n   * @name $parseProvider#addLiteral\n   * @description\n   *\n   * Configure $parse service to add literal values that will be present as literal at expressions.\n   *\n   * @param {string} literalName Token for the literal value. The literal name value must be a valid literal name.\n   * @param {*} literalValue Value for this literal. All literal values must be primitives or `undefined`.\n   *\n   **/\n  this.addLiteral = function(literalName, literalValue) {\n    literals[literalName] = literalValue;\n  };\n\n /**\n  * @ngdoc method\n  * @name $parseProvider#setIdentifierFns\n  * @description\n  *\n  * Allows defining the set of characters that are allowed in Angular expressions. The function\n  * `identifierStart` will get called to know if a given character is a valid character to be the\n  * first character for an identifier. The function `identifierContinue` will get called to know if\n  * a given character is a valid character to be a follow-up identifier character. The functions\n  * `identifierStart` and `identifierContinue` will receive as arguments the single character to be\n  * identifier and the character code point. These arguments will be `string` and `numeric`. Keep in\n  * mind that the `string` parameter can be two characters long depending on the character\n  * representation. It is expected for the function to return `true` or `false`, whether that\n  * character is allowed or not.\n  *\n  * Since this function will be called extensivelly, keep the implementation of these functions fast,\n  * as the performance of these functions have a direct impact on the expressions parsing speed.\n  *\n  * @param {function=} identifierStart The function that will decide whether the given character is\n  *   a valid identifier start character.\n  * @param {function=} identifierContinue The function that will decide whether the given character is\n  *   a valid identifier continue character.\n  */\n  this.setIdentifierFns = function(identifierStart, identifierContinue) {\n    identStart = identifierStart;\n    identContinue = identifierContinue;\n    return this;\n  };\n\n  this.$get = ['$filter', function($filter) {\n    var noUnsafeEval = csp().noUnsafeEval;\n    var $parseOptions = {\n          csp: noUnsafeEval,\n          expensiveChecks: false,\n          literals: copy(literals),\n          isIdentifierStart: isFunction(identStart) && identStart,\n          isIdentifierContinue: isFunction(identContinue) && identContinue\n        },\n        $parseOptionsExpensive = {\n          csp: noUnsafeEval,\n          expensiveChecks: true,\n          literals: copy(literals),\n          isIdentifierStart: isFunction(identStart) && identStart,\n          isIdentifierContinue: isFunction(identContinue) && identContinue\n        };\n    var runningChecksEnabled = false;\n\n    $parse.$$runningExpensiveChecks = function() {\n      return runningChecksEnabled;\n    };\n\n    return $parse;\n\n    function $parse(exp, interceptorFn, expensiveChecks) {\n      var parsedExpression, oneTime, cacheKey;\n\n      expensiveChecks = expensiveChecks || runningChecksEnabled;\n\n      switch (typeof exp) {\n        case 'string':\n          exp = exp.trim();\n          cacheKey = exp;\n\n          var cache = (expensiveChecks ? cacheExpensive : cacheDefault);\n          parsedExpression = cache[cacheKey];\n\n          if (!parsedExpression) {\n            if (exp.charAt(0) === ':' && exp.charAt(1) === ':') {\n              oneTime = true;\n              exp = exp.substring(2);\n            }\n            var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions;\n            var lexer = new Lexer(parseOptions);\n            var parser = new Parser(lexer, $filter, parseOptions);\n            parsedExpression = parser.parse(exp);\n            if (parsedExpression.constant) {\n              parsedExpression.$$watchDelegate = constantWatchDelegate;\n            } else if (oneTime) {\n              parsedExpression.$$watchDelegate = parsedExpression.literal ?\n                  oneTimeLiteralWatchDelegate : oneTimeWatchDelegate;\n            } else if (parsedExpression.inputs) {\n              parsedExpression.$$watchDelegate = inputsWatchDelegate;\n            }\n            if (expensiveChecks) {\n              parsedExpression = expensiveChecksInterceptor(parsedExpression);\n            }\n            cache[cacheKey] = parsedExpression;\n          }\n          return addInterceptor(parsedExpression, interceptorFn);\n\n        case 'function':\n          return addInterceptor(exp, interceptorFn);\n\n        default:\n          return addInterceptor(noop, interceptorFn);\n      }\n    }\n\n    function expensiveChecksInterceptor(fn) {\n      if (!fn) return fn;\n      expensiveCheckFn.$$watchDelegate = fn.$$watchDelegate;\n      expensiveCheckFn.assign = expensiveChecksInterceptor(fn.assign);\n      expensiveCheckFn.constant = fn.constant;\n      expensiveCheckFn.literal = fn.literal;\n      for (var i = 0; fn.inputs && i < fn.inputs.length; ++i) {\n        fn.inputs[i] = expensiveChecksInterceptor(fn.inputs[i]);\n      }\n      expensiveCheckFn.inputs = fn.inputs;\n\n      return expensiveCheckFn;\n\n      function expensiveCheckFn(scope, locals, assign, inputs) {\n        var expensiveCheckOldValue = runningChecksEnabled;\n        runningChecksEnabled = true;\n        try {\n          return fn(scope, locals, assign, inputs);\n        } finally {\n          runningChecksEnabled = expensiveCheckOldValue;\n        }\n      }\n    }\n\n    function expressionInputDirtyCheck(newValue, oldValueOfValue) {\n\n      if (newValue == null || oldValueOfValue == null) { // null/undefined\n        return newValue === oldValueOfValue;\n      }\n\n      if (typeof newValue === 'object') {\n\n        // attempt to convert the value to a primitive type\n        // TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can\n        //             be cheaply dirty-checked\n        newValue = getValueOf(newValue);\n\n        if (typeof newValue === 'object') {\n          // objects/arrays are not supported - deep-watching them would be too expensive\n          return false;\n        }\n\n        // fall-through to the primitive equality check\n      }\n\n      //Primitive or NaN\n      return newValue === oldValueOfValue || (newValue !== newValue && oldValueOfValue !== oldValueOfValue);\n    }\n\n    function inputsWatchDelegate(scope, listener, objectEquality, parsedExpression, prettyPrintExpression) {\n      var inputExpressions = parsedExpression.inputs;\n      var lastResult;\n\n      if (inputExpressions.length === 1) {\n        var oldInputValueOf = expressionInputDirtyCheck; // init to something unique so that equals check fails\n        inputExpressions = inputExpressions[0];\n        return scope.$watch(function expressionInputWatch(scope) {\n          var newInputValue = inputExpressions(scope);\n          if (!expressionInputDirtyCheck(newInputValue, oldInputValueOf)) {\n            lastResult = parsedExpression(scope, undefined, undefined, [newInputValue]);\n            oldInputValueOf = newInputValue && getValueOf(newInputValue);\n          }\n          return lastResult;\n        }, listener, objectEquality, prettyPrintExpression);\n      }\n\n      var oldInputValueOfValues = [];\n      var oldInputValues = [];\n      for (var i = 0, ii = inputExpressions.length; i < ii; i++) {\n        oldInputValueOfValues[i] = expressionInputDirtyCheck; // init to something unique so that equals check fails\n        oldInputValues[i] = null;\n      }\n\n      return scope.$watch(function expressionInputsWatch(scope) {\n        var changed = false;\n\n        for (var i = 0, ii = inputExpressions.length; i < ii; i++) {\n          var newInputValue = inputExpressions[i](scope);\n          if (changed || (changed = !expressionInputDirtyCheck(newInputValue, oldInputValueOfValues[i]))) {\n            oldInputValues[i] = newInputValue;\n            oldInputValueOfValues[i] = newInputValue && getValueOf(newInputValue);\n          }\n        }\n\n        if (changed) {\n          lastResult = parsedExpression(scope, undefined, undefined, oldInputValues);\n        }\n\n        return lastResult;\n      }, listener, objectEquality, prettyPrintExpression);\n    }\n\n    function oneTimeWatchDelegate(scope, listener, objectEquality, parsedExpression) {\n      var unwatch, lastValue;\n      return unwatch = scope.$watch(function oneTimeWatch(scope) {\n        return parsedExpression(scope);\n      }, function oneTimeListener(value, old, scope) {\n        lastValue = value;\n        if (isFunction(listener)) {\n          listener.apply(this, arguments);\n        }\n        if (isDefined(value)) {\n          scope.$$postDigest(function() {\n            if (isDefined(lastValue)) {\n              unwatch();\n            }\n          });\n        }\n      }, objectEquality);\n    }\n\n    function oneTimeLiteralWatchDelegate(scope, listener, objectEquality, parsedExpression) {\n      var unwatch, lastValue;\n      return unwatch = scope.$watch(function oneTimeWatch(scope) {\n        return parsedExpression(scope);\n      }, function oneTimeListener(value, old, scope) {\n        lastValue = value;\n        if (isFunction(listener)) {\n          listener.call(this, value, old, scope);\n        }\n        if (isAllDefined(value)) {\n          scope.$$postDigest(function() {\n            if (isAllDefined(lastValue)) unwatch();\n          });\n        }\n      }, objectEquality);\n\n      function isAllDefined(value) {\n        var allDefined = true;\n        forEach(value, function(val) {\n          if (!isDefined(val)) allDefined = false;\n        });\n        return allDefined;\n      }\n    }\n\n    function constantWatchDelegate(scope, listener, objectEquality, parsedExpression) {\n      var unwatch;\n      return unwatch = scope.$watch(function constantWatch(scope) {\n        unwatch();\n        return parsedExpression(scope);\n      }, listener, objectEquality);\n    }\n\n    function addInterceptor(parsedExpression, interceptorFn) {\n      if (!interceptorFn) return parsedExpression;\n      var watchDelegate = parsedExpression.$$watchDelegate;\n      var useInputs = false;\n\n      var regularWatch =\n          watchDelegate !== oneTimeLiteralWatchDelegate &&\n          watchDelegate !== oneTimeWatchDelegate;\n\n      var fn = regularWatch ? function regularInterceptedExpression(scope, locals, assign, inputs) {\n        var value = useInputs && inputs ? inputs[0] : parsedExpression(scope, locals, assign, inputs);\n        return interceptorFn(value, scope, locals);\n      } : function oneTimeInterceptedExpression(scope, locals, assign, inputs) {\n        var value = parsedExpression(scope, locals, assign, inputs);\n        var result = interceptorFn(value, scope, locals);\n        // we only return the interceptor's result if the\n        // initial value is defined (for bind-once)\n        return isDefined(value) ? result : value;\n      };\n\n      // Propagate $$watchDelegates other then inputsWatchDelegate\n      if (parsedExpression.$$watchDelegate &&\n          parsedExpression.$$watchDelegate !== inputsWatchDelegate) {\n        fn.$$watchDelegate = parsedExpression.$$watchDelegate;\n      } else if (!interceptorFn.$stateful) {\n        // If there is an interceptor, but no watchDelegate then treat the interceptor like\n        // we treat filters - it is assumed to be a pure function unless flagged with $stateful\n        fn.$$watchDelegate = inputsWatchDelegate;\n        useInputs = !parsedExpression.inputs;\n        fn.inputs = parsedExpression.inputs ? parsedExpression.inputs : [parsedExpression];\n      }\n\n      return fn;\n    }\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $q\n * @requires $rootScope\n *\n * @description\n * A service that helps you run functions asynchronously, and use their return values (or exceptions)\n * when they are done processing.\n *\n * This is an implementation of promises/deferred objects inspired by\n * [Kris Kowal's Q](https://github.com/kriskowal/q).\n *\n * $q can be used in two fashions --- one which is more similar to Kris Kowal's Q or jQuery's Deferred\n * implementations, and the other which resembles ES6 (ES2015) promises to some degree.\n *\n * # $q constructor\n *\n * The streamlined ES6 style promise is essentially just using $q as a constructor which takes a `resolver`\n * function as the first argument. This is similar to the native Promise implementation from ES6,\n * see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).\n *\n * While the constructor-style use is supported, not all of the supporting methods from ES6 promises are\n * available yet.\n *\n * It can be used like so:\n *\n * ```js\n *   // for the purpose of this example let's assume that variables `$q` and `okToGreet`\n *   // are available in the current lexical scope (they could have been injected or passed in).\n *\n *   function asyncGreet(name) {\n *     // perform some asynchronous operation, resolve or reject the promise when appropriate.\n *     return $q(function(resolve, reject) {\n *       setTimeout(function() {\n *         if (okToGreet(name)) {\n *           resolve('Hello, ' + name + '!');\n *         } else {\n *           reject('Greeting ' + name + ' is not allowed.');\n *         }\n *       }, 1000);\n *     });\n *   }\n *\n *   var promise = asyncGreet('Robin Hood');\n *   promise.then(function(greeting) {\n *     alert('Success: ' + greeting);\n *   }, function(reason) {\n *     alert('Failed: ' + reason);\n *   });\n * ```\n *\n * Note: progress/notify callbacks are not currently supported via the ES6-style interface.\n *\n * Note: unlike ES6 behavior, an exception thrown in the constructor function will NOT implicitly reject the promise.\n *\n * However, the more traditional CommonJS-style usage is still available, and documented below.\n *\n * [The CommonJS Promise proposal](http://wiki.commonjs.org/wiki/Promises) describes a promise as an\n * interface for interacting with an object that represents the result of an action that is\n * performed asynchronously, and may or may not be finished at any given point in time.\n *\n * From the perspective of dealing with error handling, deferred and promise APIs are to\n * asynchronous programming what `try`, `catch` and `throw` keywords are to synchronous programming.\n *\n * ```js\n *   // for the purpose of this example let's assume that variables `$q` and `okToGreet`\n *   // are available in the current lexical scope (they could have been injected or passed in).\n *\n *   function asyncGreet(name) {\n *     var deferred = $q.defer();\n *\n *     setTimeout(function() {\n *       deferred.notify('About to greet ' + name + '.');\n *\n *       if (okToGreet(name)) {\n *         deferred.resolve('Hello, ' + name + '!');\n *       } else {\n *         deferred.reject('Greeting ' + name + ' is not allowed.');\n *       }\n *     }, 1000);\n *\n *     return deferred.promise;\n *   }\n *\n *   var promise = asyncGreet('Robin Hood');\n *   promise.then(function(greeting) {\n *     alert('Success: ' + greeting);\n *   }, function(reason) {\n *     alert('Failed: ' + reason);\n *   }, function(update) {\n *     alert('Got notification: ' + update);\n *   });\n * ```\n *\n * At first it might not be obvious why this extra complexity is worth the trouble. The payoff\n * comes in the way of guarantees that promise and deferred APIs make, see\n * https://github.com/kriskowal/uncommonjs/blob/master/promises/specification.md.\n *\n * Additionally the promise api allows for composition that is very hard to do with the\n * traditional callback ([CPS](http://en.wikipedia.org/wiki/Continuation-passing_style)) approach.\n * For more on this please see the [Q documentation](https://github.com/kriskowal/q) especially the\n * section on serial or parallel joining of promises.\n *\n * # The Deferred API\n *\n * A new instance of deferred is constructed by calling `$q.defer()`.\n *\n * The purpose of the deferred object is to expose the associated Promise instance as well as APIs\n * that can be used for signaling the successful or unsuccessful completion, as well as the status\n * of the task.\n *\n * **Methods**\n *\n * - `resolve(value)` – resolves the derived promise with the `value`. If the value is a rejection\n *   constructed via `$q.reject`, the promise will be rejected instead.\n * - `reject(reason)` – rejects the derived promise with the `reason`. This is equivalent to\n *   resolving it with a rejection constructed via `$q.reject`.\n * - `notify(value)` - provides updates on the status of the promise's execution. This may be called\n *   multiple times before the promise is either resolved or rejected.\n *\n * **Properties**\n *\n * - promise – `{Promise}` – promise object associated with this deferred.\n *\n *\n * # The Promise API\n *\n * A new promise instance is created when a deferred instance is created and can be retrieved by\n * calling `deferred.promise`.\n *\n * The purpose of the promise object is to allow for interested parties to get access to the result\n * of the deferred task when it completes.\n *\n * **Methods**\n *\n * - `then(successCallback, errorCallback, notifyCallback)` – regardless of when the promise was or\n *   will be resolved or rejected, `then` calls one of the success or error callbacks asynchronously\n *   as soon as the result is available. The callbacks are called with a single argument: the result\n *   or rejection reason. Additionally, the notify callback may be called zero or more times to\n *   provide a progress indication, before the promise is resolved or rejected.\n *\n *   This method *returns a new promise* which is resolved or rejected via the return value of the\n *   `successCallback`, `errorCallback` (unless that value is a promise, in which case it is resolved\n *   with the value which is resolved in that promise using\n *   [promise chaining](http://www.html5rocks.com/en/tutorials/es6/promises/#toc-promises-queues)).\n *   It also notifies via the return value of the `notifyCallback` method. The promise cannot be\n *   resolved or rejected from the notifyCallback method.\n *\n * - `catch(errorCallback)` – shorthand for `promise.then(null, errorCallback)`\n *\n * - `finally(callback, notifyCallback)` – allows you to observe either the fulfillment or rejection of a promise,\n *   but to do so without modifying the final value. This is useful to release resources or do some\n *   clean-up that needs to be done whether the promise was rejected or resolved. See the [full\n *   specification](https://github.com/kriskowal/q/wiki/API-Reference#promisefinallycallback) for\n *   more information.\n *\n * # Chaining promises\n *\n * Because calling the `then` method of a promise returns a new derived promise, it is easily\n * possible to create a chain of promises:\n *\n * ```js\n *   promiseB = promiseA.then(function(result) {\n *     return result + 1;\n *   });\n *\n *   // promiseB will be resolved immediately after promiseA is resolved and its value\n *   // will be the result of promiseA incremented by 1\n * ```\n *\n * It is possible to create chains of any length and since a promise can be resolved with another\n * promise (which will defer its resolution further), it is possible to pause/defer resolution of\n * the promises at any point in the chain. This makes it possible to implement powerful APIs like\n * $http's response interceptors.\n *\n *\n * # Differences between Kris Kowal's Q and $q\n *\n *  There are two main differences:\n *\n * - $q is integrated with the {@link ng.$rootScope.Scope} Scope model observation\n *   mechanism in angular, which means faster propagation of resolution or rejection into your\n *   models and avoiding unnecessary browser repaints, which would result in flickering UI.\n * - Q has many more features than $q, but that comes at a cost of bytes. $q is tiny, but contains\n *   all the important functionality needed for common async tasks.\n *\n * # Testing\n *\n *  ```js\n *    it('should simulate promise', inject(function($q, $rootScope) {\n *      var deferred = $q.defer();\n *      var promise = deferred.promise;\n *      var resolvedValue;\n *\n *      promise.then(function(value) { resolvedValue = value; });\n *      expect(resolvedValue).toBeUndefined();\n *\n *      // Simulate resolving of promise\n *      deferred.resolve(123);\n *      // Note that the 'then' function does not get called synchronously.\n *      // This is because we want the promise API to always be async, whether or not\n *      // it got called synchronously or asynchronously.\n *      expect(resolvedValue).toBeUndefined();\n *\n *      // Propagate promise resolution to 'then' functions using $apply().\n *      $rootScope.$apply();\n *      expect(resolvedValue).toEqual(123);\n *    }));\n *  ```\n *\n * @param {function(function, function)} resolver Function which is responsible for resolving or\n *   rejecting the newly created promise. The first parameter is a function which resolves the\n *   promise, the second parameter is a function which rejects the promise.\n *\n * @returns {Promise} The newly created promise.\n */\nfunction $QProvider() {\n\n  this.$get = ['$rootScope', '$exceptionHandler', function($rootScope, $exceptionHandler) {\n    return qFactory(function(callback) {\n      $rootScope.$evalAsync(callback);\n    }, $exceptionHandler);\n  }];\n}\n\nfunction $$QProvider() {\n  this.$get = ['$browser', '$exceptionHandler', function($browser, $exceptionHandler) {\n    return qFactory(function(callback) {\n      $browser.defer(callback);\n    }, $exceptionHandler);\n  }];\n}\n\n/**\n * Constructs a promise manager.\n *\n * @param {function(function)} nextTick Function for executing functions in the next turn.\n * @param {function(...*)} exceptionHandler Function into which unexpected exceptions are passed for\n *     debugging purposes.\n * @returns {object} Promise manager.\n */\nfunction qFactory(nextTick, exceptionHandler) {\n  var $qMinErr = minErr('$q', TypeError);\n\n  /**\n   * @ngdoc method\n   * @name ng.$q#defer\n   * @kind function\n   *\n   * @description\n   * Creates a `Deferred` object which represents a task which will finish in the future.\n   *\n   * @returns {Deferred} Returns a new instance of deferred.\n   */\n  var defer = function() {\n    var d = new Deferred();\n    //Necessary to support unbound execution :/\n    d.resolve = simpleBind(d, d.resolve);\n    d.reject = simpleBind(d, d.reject);\n    d.notify = simpleBind(d, d.notify);\n    return d;\n  };\n\n  function Promise() {\n    this.$$state = { status: 0 };\n  }\n\n  extend(Promise.prototype, {\n    then: function(onFulfilled, onRejected, progressBack) {\n      if (isUndefined(onFulfilled) && isUndefined(onRejected) && isUndefined(progressBack)) {\n        return this;\n      }\n      var result = new Deferred();\n\n      this.$$state.pending = this.$$state.pending || [];\n      this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]);\n      if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);\n\n      return result.promise;\n    },\n\n    \"catch\": function(callback) {\n      return this.then(null, callback);\n    },\n\n    \"finally\": function(callback, progressBack) {\n      return this.then(function(value) {\n        return handleCallback(value, true, callback);\n      }, function(error) {\n        return handleCallback(error, false, callback);\n      }, progressBack);\n    }\n  });\n\n  //Faster, more basic than angular.bind http://jsperf.com/angular-bind-vs-custom-vs-native\n  function simpleBind(context, fn) {\n    return function(value) {\n      fn.call(context, value);\n    };\n  }\n\n  function processQueue(state) {\n    var fn, deferred, pending;\n\n    pending = state.pending;\n    state.processScheduled = false;\n    state.pending = undefined;\n    for (var i = 0, ii = pending.length; i < ii; ++i) {\n      deferred = pending[i][0];\n      fn = pending[i][state.status];\n      try {\n        if (isFunction(fn)) {\n          deferred.resolve(fn(state.value));\n        } else if (state.status === 1) {\n          deferred.resolve(state.value);\n        } else {\n          deferred.reject(state.value);\n        }\n      } catch (e) {\n        deferred.reject(e);\n        exceptionHandler(e);\n      }\n    }\n  }\n\n  function scheduleProcessQueue(state) {\n    if (state.processScheduled || !state.pending) return;\n    state.processScheduled = true;\n    nextTick(function() { processQueue(state); });\n  }\n\n  function Deferred() {\n    this.promise = new Promise();\n  }\n\n  extend(Deferred.prototype, {\n    resolve: function(val) {\n      if (this.promise.$$state.status) return;\n      if (val === this.promise) {\n        this.$$reject($qMinErr(\n          'qcycle',\n          \"Expected promise to be resolved with value other than itself '{0}'\",\n          val));\n      } else {\n        this.$$resolve(val);\n      }\n\n    },\n\n    $$resolve: function(val) {\n      var then;\n      var that = this;\n      var done = false;\n      try {\n        if ((isObject(val) || isFunction(val))) then = val && val.then;\n        if (isFunction(then)) {\n          this.promise.$$state.status = -1;\n          then.call(val, resolvePromise, rejectPromise, simpleBind(this, this.notify));\n        } else {\n          this.promise.$$state.value = val;\n          this.promise.$$state.status = 1;\n          scheduleProcessQueue(this.promise.$$state);\n        }\n      } catch (e) {\n        rejectPromise(e);\n        exceptionHandler(e);\n      }\n\n      function resolvePromise(val) {\n        if (done) return;\n        done = true;\n        that.$$resolve(val);\n      }\n      function rejectPromise(val) {\n        if (done) return;\n        done = true;\n        that.$$reject(val);\n      }\n    },\n\n    reject: function(reason) {\n      if (this.promise.$$state.status) return;\n      this.$$reject(reason);\n    },\n\n    $$reject: function(reason) {\n      this.promise.$$state.value = reason;\n      this.promise.$$state.status = 2;\n      scheduleProcessQueue(this.promise.$$state);\n    },\n\n    notify: function(progress) {\n      var callbacks = this.promise.$$state.pending;\n\n      if ((this.promise.$$state.status <= 0) && callbacks && callbacks.length) {\n        nextTick(function() {\n          var callback, result;\n          for (var i = 0, ii = callbacks.length; i < ii; i++) {\n            result = callbacks[i][0];\n            callback = callbacks[i][3];\n            try {\n              result.notify(isFunction(callback) ? callback(progress) : progress);\n            } catch (e) {\n              exceptionHandler(e);\n            }\n          }\n        });\n      }\n    }\n  });\n\n  /**\n   * @ngdoc method\n   * @name $q#reject\n   * @kind function\n   *\n   * @description\n   * Creates a promise that is resolved as rejected with the specified `reason`. This api should be\n   * used to forward rejection in a chain of promises. If you are dealing with the last promise in\n   * a promise chain, you don't need to worry about it.\n   *\n   * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of\n   * `reject` as the `throw` keyword in JavaScript. This also means that if you \"catch\" an error via\n   * a promise error callback and you want to forward the error to the promise derived from the\n   * current promise, you have to \"rethrow\" the error by returning a rejection constructed via\n   * `reject`.\n   *\n   * ```js\n   *   promiseB = promiseA.then(function(result) {\n   *     // success: do something and resolve promiseB\n   *     //          with the old or a new result\n   *     return result;\n   *   }, function(reason) {\n   *     // error: handle the error if possible and\n   *     //        resolve promiseB with newPromiseOrValue,\n   *     //        otherwise forward the rejection to promiseB\n   *     if (canHandle(reason)) {\n   *      // handle the error and recover\n   *      return newPromiseOrValue;\n   *     }\n   *     return $q.reject(reason);\n   *   });\n   * ```\n   *\n   * @param {*} reason Constant, message, exception or an object representing the rejection reason.\n   * @returns {Promise} Returns a promise that was already resolved as rejected with the `reason`.\n   */\n  var reject = function(reason) {\n    var result = new Deferred();\n    result.reject(reason);\n    return result.promise;\n  };\n\n  var makePromise = function makePromise(value, resolved) {\n    var result = new Deferred();\n    if (resolved) {\n      result.resolve(value);\n    } else {\n      result.reject(value);\n    }\n    return result.promise;\n  };\n\n  var handleCallback = function handleCallback(value, isResolved, callback) {\n    var callbackOutput = null;\n    try {\n      if (isFunction(callback)) callbackOutput = callback();\n    } catch (e) {\n      return makePromise(e, false);\n    }\n    if (isPromiseLike(callbackOutput)) {\n      return callbackOutput.then(function() {\n        return makePromise(value, isResolved);\n      }, function(error) {\n        return makePromise(error, false);\n      });\n    } else {\n      return makePromise(value, isResolved);\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name $q#when\n   * @kind function\n   *\n   * @description\n   * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise.\n   * This is useful when you are dealing with an object that might or might not be a promise, or if\n   * the promise comes from a source that can't be trusted.\n   *\n   * @param {*} value Value or a promise\n   * @param {Function=} successCallback\n   * @param {Function=} errorCallback\n   * @param {Function=} progressCallback\n   * @returns {Promise} Returns a promise of the passed value or promise\n   */\n\n\n  var when = function(value, callback, errback, progressBack) {\n    var result = new Deferred();\n    result.resolve(value);\n    return result.promise.then(callback, errback, progressBack);\n  };\n\n  /**\n   * @ngdoc method\n   * @name $q#resolve\n   * @kind function\n   *\n   * @description\n   * Alias of {@link ng.$q#when when} to maintain naming consistency with ES6.\n   *\n   * @param {*} value Value or a promise\n   * @param {Function=} successCallback\n   * @param {Function=} errorCallback\n   * @param {Function=} progressCallback\n   * @returns {Promise} Returns a promise of the passed value or promise\n   */\n  var resolve = when;\n\n  /**\n   * @ngdoc method\n   * @name $q#all\n   * @kind function\n   *\n   * @description\n   * Combines multiple promises into a single promise that is resolved when all of the input\n   * promises are resolved.\n   *\n   * @param {Array.<Promise>|Object.<Promise>} promises An array or hash of promises.\n   * @returns {Promise} Returns a single promise that will be resolved with an array/hash of values,\n   *   each value corresponding to the promise at the same index/key in the `promises` array/hash.\n   *   If any of the promises is resolved with a rejection, this resulting promise will be rejected\n   *   with the same rejection value.\n   */\n\n  function all(promises) {\n    var deferred = new Deferred(),\n        counter = 0,\n        results = isArray(promises) ? [] : {};\n\n    forEach(promises, function(promise, key) {\n      counter++;\n      when(promise).then(function(value) {\n        if (results.hasOwnProperty(key)) return;\n        results[key] = value;\n        if (!(--counter)) deferred.resolve(results);\n      }, function(reason) {\n        if (results.hasOwnProperty(key)) return;\n        deferred.reject(reason);\n      });\n    });\n\n    if (counter === 0) {\n      deferred.resolve(results);\n    }\n\n    return deferred.promise;\n  }\n\n  var $Q = function Q(resolver) {\n    if (!isFunction(resolver)) {\n      throw $qMinErr('norslvr', \"Expected resolverFn, got '{0}'\", resolver);\n    }\n\n    var deferred = new Deferred();\n\n    function resolveFn(value) {\n      deferred.resolve(value);\n    }\n\n    function rejectFn(reason) {\n      deferred.reject(reason);\n    }\n\n    resolver(resolveFn, rejectFn);\n\n    return deferred.promise;\n  };\n\n  // Let's make the instanceof operator work for promises, so that\n  // `new $q(fn) instanceof $q` would evaluate to true.\n  $Q.prototype = Promise.prototype;\n\n  $Q.defer = defer;\n  $Q.reject = reject;\n  $Q.when = when;\n  $Q.resolve = resolve;\n  $Q.all = all;\n\n  return $Q;\n}\n\nfunction $$RAFProvider() { //rAF\n  this.$get = ['$window', '$timeout', function($window, $timeout) {\n    var requestAnimationFrame = $window.requestAnimationFrame ||\n                                $window.webkitRequestAnimationFrame;\n\n    var cancelAnimationFrame = $window.cancelAnimationFrame ||\n                               $window.webkitCancelAnimationFrame ||\n                               $window.webkitCancelRequestAnimationFrame;\n\n    var rafSupported = !!requestAnimationFrame;\n    var raf = rafSupported\n      ? function(fn) {\n          var id = requestAnimationFrame(fn);\n          return function() {\n            cancelAnimationFrame(id);\n          };\n        }\n      : function(fn) {\n          var timer = $timeout(fn, 16.66, false); // 1000 / 60 = 16.666\n          return function() {\n            $timeout.cancel(timer);\n          };\n        };\n\n    raf.supported = rafSupported;\n\n    return raf;\n  }];\n}\n\n/**\n * DESIGN NOTES\n *\n * The design decisions behind the scope are heavily favored for speed and memory consumption.\n *\n * The typical use of scope is to watch the expressions, which most of the time return the same\n * value as last time so we optimize the operation.\n *\n * Closures construction is expensive in terms of speed as well as memory:\n *   - No closures, instead use prototypical inheritance for API\n *   - Internal state needs to be stored on scope directly, which means that private state is\n *     exposed as $$____ properties\n *\n * Loop operations are optimized by using while(count--) { ... }\n *   - This means that in order to keep the same order of execution as addition we have to add\n *     items to the array at the beginning (unshift) instead of at the end (push)\n *\n * Child scopes are created and removed often\n *   - Using an array would be slow since inserts in the middle are expensive; so we use linked lists\n *\n * There are fewer watches than observers. This is why you don't want the observer to be implemented\n * in the same way as watch. Watch requires return of the initialization function which is expensive\n * to construct.\n */\n\n\n/**\n * @ngdoc provider\n * @name $rootScopeProvider\n * @description\n *\n * Provider for the $rootScope service.\n */\n\n/**\n * @ngdoc method\n * @name $rootScopeProvider#digestTtl\n * @description\n *\n * Sets the number of `$digest` iterations the scope should attempt to execute before giving up and\n * assuming that the model is unstable.\n *\n * The current default is 10 iterations.\n *\n * In complex applications it's possible that the dependencies between `$watch`s will result in\n * several digest iterations. However if an application needs more than the default 10 digest\n * iterations for its model to stabilize then you should investigate what is causing the model to\n * continuously change during the digest.\n *\n * Increasing the TTL could have performance implications, so you should not change it without\n * proper justification.\n *\n * @param {number} limit The number of digest iterations.\n */\n\n\n/**\n * @ngdoc service\n * @name $rootScope\n * @description\n *\n * Every application has a single root {@link ng.$rootScope.Scope scope}.\n * All other scopes are descendant scopes of the root scope. Scopes provide separation\n * between the model and the view, via a mechanism for watching the model for changes.\n * They also provide event emission/broadcast and subscription facility. See the\n * {@link guide/scope developer guide on scopes}.\n */\nfunction $RootScopeProvider() {\n  var TTL = 10;\n  var $rootScopeMinErr = minErr('$rootScope');\n  var lastDirtyWatch = null;\n  var applyAsyncId = null;\n\n  this.digestTtl = function(value) {\n    if (arguments.length) {\n      TTL = value;\n    }\n    return TTL;\n  };\n\n  function createChildScopeClass(parent) {\n    function ChildScope() {\n      this.$$watchers = this.$$nextSibling =\n          this.$$childHead = this.$$childTail = null;\n      this.$$listeners = {};\n      this.$$listenerCount = {};\n      this.$$watchersCount = 0;\n      this.$id = nextUid();\n      this.$$ChildScope = null;\n    }\n    ChildScope.prototype = parent;\n    return ChildScope;\n  }\n\n  this.$get = ['$exceptionHandler', '$parse', '$browser',\n      function($exceptionHandler, $parse, $browser) {\n\n    function destroyChildScope($event) {\n        $event.currentScope.$$destroyed = true;\n    }\n\n    function cleanUpScope($scope) {\n\n      if (msie === 9) {\n        // There is a memory leak in IE9 if all child scopes are not disconnected\n        // completely when a scope is destroyed. So this code will recurse up through\n        // all this scopes children\n        //\n        // See issue https://github.com/angular/angular.js/issues/10706\n        $scope.$$childHead && cleanUpScope($scope.$$childHead);\n        $scope.$$nextSibling && cleanUpScope($scope.$$nextSibling);\n      }\n\n      // The code below works around IE9 and V8's memory leaks\n      //\n      // See:\n      // - https://code.google.com/p/v8/issues/detail?id=2073#c26\n      // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909\n      // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451\n\n      $scope.$parent = $scope.$$nextSibling = $scope.$$prevSibling = $scope.$$childHead =\n          $scope.$$childTail = $scope.$root = $scope.$$watchers = null;\n    }\n\n    /**\n     * @ngdoc type\n     * @name $rootScope.Scope\n     *\n     * @description\n     * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the\n     * {@link auto.$injector $injector}. Child scopes are created using the\n     * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when\n     * compiled HTML template is executed.) See also the {@link guide/scope Scopes guide} for\n     * an in-depth introduction and usage examples.\n     *\n     *\n     * # Inheritance\n     * A scope can inherit from a parent scope, as in this example:\n     * ```js\n         var parent = $rootScope;\n         var child = parent.$new();\n\n         parent.salutation = \"Hello\";\n         expect(child.salutation).toEqual('Hello');\n\n         child.salutation = \"Welcome\";\n         expect(child.salutation).toEqual('Welcome');\n         expect(parent.salutation).toEqual('Hello');\n     * ```\n     *\n     * When interacting with `Scope` in tests, additional helper methods are available on the\n     * instances of `Scope` type. See {@link ngMock.$rootScope.Scope ngMock Scope} for additional\n     * details.\n     *\n     *\n     * @param {Object.<string, function()>=} providers Map of service factory which need to be\n     *                                       provided for the current scope. Defaults to {@link ng}.\n     * @param {Object.<string, *>=} instanceCache Provides pre-instantiated services which should\n     *                              append/override services provided by `providers`. This is handy\n     *                              when unit-testing and having the need to override a default\n     *                              service.\n     * @returns {Object} Newly created scope.\n     *\n     */\n    function Scope() {\n      this.$id = nextUid();\n      this.$$phase = this.$parent = this.$$watchers =\n                     this.$$nextSibling = this.$$prevSibling =\n                     this.$$childHead = this.$$childTail = null;\n      this.$root = this;\n      this.$$destroyed = false;\n      this.$$listeners = {};\n      this.$$listenerCount = {};\n      this.$$watchersCount = 0;\n      this.$$isolateBindings = null;\n    }\n\n    /**\n     * @ngdoc property\n     * @name $rootScope.Scope#$id\n     *\n     * @description\n     * Unique scope ID (monotonically increasing) useful for debugging.\n     */\n\n     /**\n      * @ngdoc property\n      * @name $rootScope.Scope#$parent\n      *\n      * @description\n      * Reference to the parent scope.\n      */\n\n      /**\n       * @ngdoc property\n       * @name $rootScope.Scope#$root\n       *\n       * @description\n       * Reference to the root scope.\n       */\n\n    Scope.prototype = {\n      constructor: Scope,\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$new\n       * @kind function\n       *\n       * @description\n       * Creates a new child {@link ng.$rootScope.Scope scope}.\n       *\n       * The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event.\n       * The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}.\n       *\n       * {@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is\n       * desired for the scope and its child scopes to be permanently detached from the parent and\n       * thus stop participating in model change detection and listener notification by invoking.\n       *\n       * @param {boolean} isolate If true, then the scope does not prototypically inherit from the\n       *         parent scope. The scope is isolated, as it can not see parent scope properties.\n       *         When creating widgets, it is useful for the widget to not accidentally read parent\n       *         state.\n       *\n       * @param {Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`\n       *                              of the newly created scope. Defaults to `this` scope if not provided.\n       *                              This is used when creating a transclude scope to correctly place it\n       *                              in the scope hierarchy while maintaining the correct prototypical\n       *                              inheritance.\n       *\n       * @returns {Object} The newly created child scope.\n       *\n       */\n      $new: function(isolate, parent) {\n        var child;\n\n        parent = parent || this;\n\n        if (isolate) {\n          child = new Scope();\n          child.$root = this.$root;\n        } else {\n          // Only create a child scope class if somebody asks for one,\n          // but cache it to allow the VM to optimize lookups.\n          if (!this.$$ChildScope) {\n            this.$$ChildScope = createChildScopeClass(this);\n          }\n          child = new this.$$ChildScope();\n        }\n        child.$parent = parent;\n        child.$$prevSibling = parent.$$childTail;\n        if (parent.$$childHead) {\n          parent.$$childTail.$$nextSibling = child;\n          parent.$$childTail = child;\n        } else {\n          parent.$$childHead = parent.$$childTail = child;\n        }\n\n        // When the new scope is not isolated or we inherit from `this`, and\n        // the parent scope is destroyed, the property `$$destroyed` is inherited\n        // prototypically. In all other cases, this property needs to be set\n        // when the parent scope is destroyed.\n        // The listener needs to be added after the parent is set\n        if (isolate || parent != this) child.$on('$destroy', destroyChildScope);\n\n        return child;\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$watch\n       * @kind function\n       *\n       * @description\n       * Registers a `listener` callback to be executed whenever the `watchExpression` changes.\n       *\n       * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest\n       *   $digest()} and should return the value that will be watched. (`watchExpression` should not change\n       *   its value when executed multiple times with the same input because it may be executed multiple\n       *   times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be\n       *   [idempotent](http://en.wikipedia.org/wiki/Idempotence).\n       * - The `listener` is called only when the value from the current `watchExpression` and the\n       *   previous call to `watchExpression` are not equal (with the exception of the initial run,\n       *   see below). Inequality is determined according to reference inequality,\n       *   [strict comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)\n       *    via the `!==` Javascript operator, unless `objectEquality == true`\n       *   (see next point)\n       * - When `objectEquality == true`, inequality of the `watchExpression` is determined\n       *   according to the {@link angular.equals} function. To save the value of the object for\n       *   later comparison, the {@link angular.copy} function is used. This therefore means that\n       *   watching complex objects will have adverse memory and performance implications.\n       * - The watch `listener` may change the model, which may trigger other `listener`s to fire.\n       *   This is achieved by rerunning the watchers until no changes are detected. The rerun\n       *   iteration limit is 10 to prevent an infinite loop deadlock.\n       *\n       *\n       * If you want to be notified whenever {@link ng.$rootScope.Scope#$digest $digest} is called,\n       * you can register a `watchExpression` function with no `listener`. (Be prepared for\n       * multiple calls to your `watchExpression` because it will execute multiple times in a\n       * single {@link ng.$rootScope.Scope#$digest $digest} cycle if a change is detected.)\n       *\n       * After a watcher is registered with the scope, the `listener` fn is called asynchronously\n       * (via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}) to initialize the\n       * watcher. In rare cases, this is undesirable because the listener is called when the result\n       * of `watchExpression` didn't change. To detect this scenario within the `listener` fn, you\n       * can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the\n       * listener was called due to initialization.\n       *\n       *\n       *\n       * # Example\n       * ```js\n           // let's assume that scope was dependency injected as the $rootScope\n           var scope = $rootScope;\n           scope.name = 'misko';\n           scope.counter = 0;\n\n           expect(scope.counter).toEqual(0);\n           scope.$watch('name', function(newValue, oldValue) {\n             scope.counter = scope.counter + 1;\n           });\n           expect(scope.counter).toEqual(0);\n\n           scope.$digest();\n           // the listener is always called during the first $digest loop after it was registered\n           expect(scope.counter).toEqual(1);\n\n           scope.$digest();\n           // but now it will not be called unless the value changes\n           expect(scope.counter).toEqual(1);\n\n           scope.name = 'adam';\n           scope.$digest();\n           expect(scope.counter).toEqual(2);\n\n\n\n           // Using a function as a watchExpression\n           var food;\n           scope.foodCounter = 0;\n           expect(scope.foodCounter).toEqual(0);\n           scope.$watch(\n             // This function returns the value being watched. It is called for each turn of the $digest loop\n             function() { return food; },\n             // This is the change listener, called when the value returned from the above function changes\n             function(newValue, oldValue) {\n               if ( newValue !== oldValue ) {\n                 // Only increment the counter if the value changed\n                 scope.foodCounter = scope.foodCounter + 1;\n               }\n             }\n           );\n           // No digest has been run so the counter will be zero\n           expect(scope.foodCounter).toEqual(0);\n\n           // Run the digest but since food has not changed count will still be zero\n           scope.$digest();\n           expect(scope.foodCounter).toEqual(0);\n\n           // Update food and run digest.  Now the counter will increment\n           food = 'cheeseburger';\n           scope.$digest();\n           expect(scope.foodCounter).toEqual(1);\n\n       * ```\n       *\n       *\n       *\n       * @param {(function()|string)} watchExpression Expression that is evaluated on each\n       *    {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers\n       *    a call to the `listener`.\n       *\n       *    - `string`: Evaluated as {@link guide/expression expression}\n       *    - `function(scope)`: called with current `scope` as a parameter.\n       * @param {function(newVal, oldVal, scope)} listener Callback called whenever the value\n       *    of `watchExpression` changes.\n       *\n       *    - `newVal` contains the current value of the `watchExpression`\n       *    - `oldVal` contains the previous value of the `watchExpression`\n       *    - `scope` refers to the current scope\n       * @param {boolean=} [objectEquality=false] Compare for object equality using {@link angular.equals} instead of\n       *     comparing for reference equality.\n       * @returns {function()} Returns a deregistration function for this listener.\n       */\n      $watch: function(watchExp, listener, objectEquality, prettyPrintExpression) {\n        var get = $parse(watchExp);\n\n        if (get.$$watchDelegate) {\n          return get.$$watchDelegate(this, listener, objectEquality, get, watchExp);\n        }\n        var scope = this,\n            array = scope.$$watchers,\n            watcher = {\n              fn: listener,\n              last: initWatchVal,\n              get: get,\n              exp: prettyPrintExpression || watchExp,\n              eq: !!objectEquality\n            };\n\n        lastDirtyWatch = null;\n\n        if (!isFunction(listener)) {\n          watcher.fn = noop;\n        }\n\n        if (!array) {\n          array = scope.$$watchers = [];\n        }\n        // we use unshift since we use a while loop in $digest for speed.\n        // the while loop reads in reverse order.\n        array.unshift(watcher);\n        incrementWatchersCount(this, 1);\n\n        return function deregisterWatch() {\n          if (arrayRemove(array, watcher) >= 0) {\n            incrementWatchersCount(scope, -1);\n          }\n          lastDirtyWatch = null;\n        };\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$watchGroup\n       * @kind function\n       *\n       * @description\n       * A variant of {@link ng.$rootScope.Scope#$watch $watch()} where it watches an array of `watchExpressions`.\n       * If any one expression in the collection changes the `listener` is executed.\n       *\n       * - The items in the `watchExpressions` array are observed via standard $watch operation and are examined on every\n       *   call to $digest() to see if any items changes.\n       * - The `listener` is called whenever any expression in the `watchExpressions` array changes.\n       *\n       * @param {Array.<string|Function(scope)>} watchExpressions Array of expressions that will be individually\n       * watched using {@link ng.$rootScope.Scope#$watch $watch()}\n       *\n       * @param {function(newValues, oldValues, scope)} listener Callback called whenever the return value of any\n       *    expression in `watchExpressions` changes\n       *    The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching\n       *    those of `watchExpression`\n       *    and the `oldValues` array contains the previous values of the `watchExpressions`, with the indexes matching\n       *    those of `watchExpression`\n       *    The `scope` refers to the current scope.\n       * @returns {function()} Returns a de-registration function for all listeners.\n       */\n      $watchGroup: function(watchExpressions, listener) {\n        var oldValues = new Array(watchExpressions.length);\n        var newValues = new Array(watchExpressions.length);\n        var deregisterFns = [];\n        var self = this;\n        var changeReactionScheduled = false;\n        var firstRun = true;\n\n        if (!watchExpressions.length) {\n          // No expressions means we call the listener ASAP\n          var shouldCall = true;\n          self.$evalAsync(function() {\n            if (shouldCall) listener(newValues, newValues, self);\n          });\n          return function deregisterWatchGroup() {\n            shouldCall = false;\n          };\n        }\n\n        if (watchExpressions.length === 1) {\n          // Special case size of one\n          return this.$watch(watchExpressions[0], function watchGroupAction(value, oldValue, scope) {\n            newValues[0] = value;\n            oldValues[0] = oldValue;\n            listener(newValues, (value === oldValue) ? newValues : oldValues, scope);\n          });\n        }\n\n        forEach(watchExpressions, function(expr, i) {\n          var unwatchFn = self.$watch(expr, function watchGroupSubAction(value, oldValue) {\n            newValues[i] = value;\n            oldValues[i] = oldValue;\n            if (!changeReactionScheduled) {\n              changeReactionScheduled = true;\n              self.$evalAsync(watchGroupAction);\n            }\n          });\n          deregisterFns.push(unwatchFn);\n        });\n\n        function watchGroupAction() {\n          changeReactionScheduled = false;\n\n          if (firstRun) {\n            firstRun = false;\n            listener(newValues, newValues, self);\n          } else {\n            listener(newValues, oldValues, self);\n          }\n        }\n\n        return function deregisterWatchGroup() {\n          while (deregisterFns.length) {\n            deregisterFns.shift()();\n          }\n        };\n      },\n\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$watchCollection\n       * @kind function\n       *\n       * @description\n       * Shallow watches the properties of an object and fires whenever any of the properties change\n       * (for arrays, this implies watching the array items; for object maps, this implies watching\n       * the properties). If a change is detected, the `listener` callback is fired.\n       *\n       * - The `obj` collection is observed via standard $watch operation and is examined on every\n       *   call to $digest() to see if any items have been added, removed, or moved.\n       * - The `listener` is called whenever anything within the `obj` has changed. Examples include\n       *   adding, removing, and moving items belonging to an object or array.\n       *\n       *\n       * # Example\n       * ```js\n          $scope.names = ['igor', 'matias', 'misko', 'james'];\n          $scope.dataCount = 4;\n\n          $scope.$watchCollection('names', function(newNames, oldNames) {\n            $scope.dataCount = newNames.length;\n          });\n\n          expect($scope.dataCount).toEqual(4);\n          $scope.$digest();\n\n          //still at 4 ... no changes\n          expect($scope.dataCount).toEqual(4);\n\n          $scope.names.pop();\n          $scope.$digest();\n\n          //now there's been a change\n          expect($scope.dataCount).toEqual(3);\n       * ```\n       *\n       *\n       * @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The\n       *    expression value should evaluate to an object or an array which is observed on each\n       *    {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the\n       *    collection will trigger a call to the `listener`.\n       *\n       * @param {function(newCollection, oldCollection, scope)} listener a callback function called\n       *    when a change is detected.\n       *    - The `newCollection` object is the newly modified data obtained from the `obj` expression\n       *    - The `oldCollection` object is a copy of the former collection data.\n       *      Due to performance considerations, the`oldCollection` value is computed only if the\n       *      `listener` function declares two or more arguments.\n       *    - The `scope` argument refers to the current scope.\n       *\n       * @returns {function()} Returns a de-registration function for this listener. When the\n       *    de-registration function is executed, the internal watch operation is terminated.\n       */\n      $watchCollection: function(obj, listener) {\n        $watchCollectionInterceptor.$stateful = true;\n\n        var self = this;\n        // the current value, updated on each dirty-check run\n        var newValue;\n        // a shallow copy of the newValue from the last dirty-check run,\n        // updated to match newValue during dirty-check run\n        var oldValue;\n        // a shallow copy of the newValue from when the last change happened\n        var veryOldValue;\n        // only track veryOldValue if the listener is asking for it\n        var trackVeryOldValue = (listener.length > 1);\n        var changeDetected = 0;\n        var changeDetector = $parse(obj, $watchCollectionInterceptor);\n        var internalArray = [];\n        var internalObject = {};\n        var initRun = true;\n        var oldLength = 0;\n\n        function $watchCollectionInterceptor(_value) {\n          newValue = _value;\n          var newLength, key, bothNaN, newItem, oldItem;\n\n          // If the new value is undefined, then return undefined as the watch may be a one-time watch\n          if (isUndefined(newValue)) return;\n\n          if (!isObject(newValue)) { // if primitive\n            if (oldValue !== newValue) {\n              oldValue = newValue;\n              changeDetected++;\n            }\n          } else if (isArrayLike(newValue)) {\n            if (oldValue !== internalArray) {\n              // we are transitioning from something which was not an array into array.\n              oldValue = internalArray;\n              oldLength = oldValue.length = 0;\n              changeDetected++;\n            }\n\n            newLength = newValue.length;\n\n            if (oldLength !== newLength) {\n              // if lengths do not match we need to trigger change notification\n              changeDetected++;\n              oldValue.length = oldLength = newLength;\n            }\n            // copy the items to oldValue and look for changes.\n            for (var i = 0; i < newLength; i++) {\n              oldItem = oldValue[i];\n              newItem = newValue[i];\n\n              bothNaN = (oldItem !== oldItem) && (newItem !== newItem);\n              if (!bothNaN && (oldItem !== newItem)) {\n                changeDetected++;\n                oldValue[i] = newItem;\n              }\n            }\n          } else {\n            if (oldValue !== internalObject) {\n              // we are transitioning from something which was not an object into object.\n              oldValue = internalObject = {};\n              oldLength = 0;\n              changeDetected++;\n            }\n            // copy the items to oldValue and look for changes.\n            newLength = 0;\n            for (key in newValue) {\n              if (hasOwnProperty.call(newValue, key)) {\n                newLength++;\n                newItem = newValue[key];\n                oldItem = oldValue[key];\n\n                if (key in oldValue) {\n                  bothNaN = (oldItem !== oldItem) && (newItem !== newItem);\n                  if (!bothNaN && (oldItem !== newItem)) {\n                    changeDetected++;\n                    oldValue[key] = newItem;\n                  }\n                } else {\n                  oldLength++;\n                  oldValue[key] = newItem;\n                  changeDetected++;\n                }\n              }\n            }\n            if (oldLength > newLength) {\n              // we used to have more keys, need to find them and destroy them.\n              changeDetected++;\n              for (key in oldValue) {\n                if (!hasOwnProperty.call(newValue, key)) {\n                  oldLength--;\n                  delete oldValue[key];\n                }\n              }\n            }\n          }\n          return changeDetected;\n        }\n\n        function $watchCollectionAction() {\n          if (initRun) {\n            initRun = false;\n            listener(newValue, newValue, self);\n          } else {\n            listener(newValue, veryOldValue, self);\n          }\n\n          // make a copy for the next time a collection is changed\n          if (trackVeryOldValue) {\n            if (!isObject(newValue)) {\n              //primitive\n              veryOldValue = newValue;\n            } else if (isArrayLike(newValue)) {\n              veryOldValue = new Array(newValue.length);\n              for (var i = 0; i < newValue.length; i++) {\n                veryOldValue[i] = newValue[i];\n              }\n            } else { // if object\n              veryOldValue = {};\n              for (var key in newValue) {\n                if (hasOwnProperty.call(newValue, key)) {\n                  veryOldValue[key] = newValue[key];\n                }\n              }\n            }\n          }\n        }\n\n        return this.$watch(changeDetector, $watchCollectionAction);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$digest\n       * @kind function\n       *\n       * @description\n       * Processes all of the {@link ng.$rootScope.Scope#$watch watchers} of the current scope and\n       * its children. Because a {@link ng.$rootScope.Scope#$watch watcher}'s listener can change\n       * the model, the `$digest()` keeps calling the {@link ng.$rootScope.Scope#$watch watchers}\n       * until no more listeners are firing. This means that it is possible to get into an infinite\n       * loop. This function will throw `'Maximum iteration limit exceeded.'` if the number of\n       * iterations exceeds 10.\n       *\n       * Usually, you don't call `$digest()` directly in\n       * {@link ng.directive:ngController controllers} or in\n       * {@link ng.$compileProvider#directive directives}.\n       * Instead, you should call {@link ng.$rootScope.Scope#$apply $apply()} (typically from within\n       * a {@link ng.$compileProvider#directive directive}), which will force a `$digest()`.\n       *\n       * If you want to be notified whenever `$digest()` is called,\n       * you can register a `watchExpression` function with\n       * {@link ng.$rootScope.Scope#$watch $watch()} with no `listener`.\n       *\n       * In unit tests, you may need to call `$digest()` to simulate the scope life cycle.\n       *\n       * # Example\n       * ```js\n           var scope = ...;\n           scope.name = 'misko';\n           scope.counter = 0;\n\n           expect(scope.counter).toEqual(0);\n           scope.$watch('name', function(newValue, oldValue) {\n             scope.counter = scope.counter + 1;\n           });\n           expect(scope.counter).toEqual(0);\n\n           scope.$digest();\n           // the listener is always called during the first $digest loop after it was registered\n           expect(scope.counter).toEqual(1);\n\n           scope.$digest();\n           // but now it will not be called unless the value changes\n           expect(scope.counter).toEqual(1);\n\n           scope.name = 'adam';\n           scope.$digest();\n           expect(scope.counter).toEqual(2);\n       * ```\n       *\n       */\n      $digest: function() {\n        var watch, value, last, fn, get,\n            watchers,\n            length,\n            dirty, ttl = TTL,\n            next, current, target = this,\n            watchLog = [],\n            logIdx, asyncTask;\n\n        beginPhase('$digest');\n        // Check for changes to browser url that happened in sync before the call to $digest\n        $browser.$$checkUrlChange();\n\n        if (this === $rootScope && applyAsyncId !== null) {\n          // If this is the root scope, and $applyAsync has scheduled a deferred $apply(), then\n          // cancel the scheduled $apply and flush the queue of expressions to be evaluated.\n          $browser.defer.cancel(applyAsyncId);\n          flushApplyAsync();\n        }\n\n        lastDirtyWatch = null;\n\n        do { // \"while dirty\" loop\n          dirty = false;\n          current = target;\n\n          while (asyncQueue.length) {\n            try {\n              asyncTask = asyncQueue.shift();\n              asyncTask.scope.$eval(asyncTask.expression, asyncTask.locals);\n            } catch (e) {\n              $exceptionHandler(e);\n            }\n            lastDirtyWatch = null;\n          }\n\n          traverseScopesLoop:\n          do { // \"traverse the scopes\" loop\n            if ((watchers = current.$$watchers)) {\n              // process our watches\n              length = watchers.length;\n              while (length--) {\n                try {\n                  watch = watchers[length];\n                  // Most common watches are on primitives, in which case we can short\n                  // circuit it with === operator, only when === fails do we use .equals\n                  if (watch) {\n                    get = watch.get;\n                    if ((value = get(current)) !== (last = watch.last) &&\n                        !(watch.eq\n                            ? equals(value, last)\n                            : (typeof value === 'number' && typeof last === 'number'\n                               && isNaN(value) && isNaN(last)))) {\n                      dirty = true;\n                      lastDirtyWatch = watch;\n                      watch.last = watch.eq ? copy(value, null) : value;\n                      fn = watch.fn;\n                      fn(value, ((last === initWatchVal) ? value : last), current);\n                      if (ttl < 5) {\n                        logIdx = 4 - ttl;\n                        if (!watchLog[logIdx]) watchLog[logIdx] = [];\n                        watchLog[logIdx].push({\n                          msg: isFunction(watch.exp) ? 'fn: ' + (watch.exp.name || watch.exp.toString()) : watch.exp,\n                          newVal: value,\n                          oldVal: last\n                        });\n                      }\n                    } else if (watch === lastDirtyWatch) {\n                      // If the most recently dirty watcher is now clean, short circuit since the remaining watchers\n                      // have already been tested.\n                      dirty = false;\n                      break traverseScopesLoop;\n                    }\n                  }\n                } catch (e) {\n                  $exceptionHandler(e);\n                }\n              }\n            }\n\n            // Insanity Warning: scope depth-first traversal\n            // yes, this code is a bit crazy, but it works and we have tests to prove it!\n            // this piece should be kept in sync with the traversal in $broadcast\n            if (!(next = ((current.$$watchersCount && current.$$childHead) ||\n                (current !== target && current.$$nextSibling)))) {\n              while (current !== target && !(next = current.$$nextSibling)) {\n                current = current.$parent;\n              }\n            }\n          } while ((current = next));\n\n          // `break traverseScopesLoop;` takes us to here\n\n          if ((dirty || asyncQueue.length) && !(ttl--)) {\n            clearPhase();\n            throw $rootScopeMinErr('infdig',\n                '{0} $digest() iterations reached. Aborting!\\n' +\n                'Watchers fired in the last 5 iterations: {1}',\n                TTL, watchLog);\n          }\n\n        } while (dirty || asyncQueue.length);\n\n        clearPhase();\n\n        while (postDigestQueue.length) {\n          try {\n            postDigestQueue.shift()();\n          } catch (e) {\n            $exceptionHandler(e);\n          }\n        }\n      },\n\n\n      /**\n       * @ngdoc event\n       * @name $rootScope.Scope#$destroy\n       * @eventType broadcast on scope being destroyed\n       *\n       * @description\n       * Broadcasted when a scope and its children are being destroyed.\n       *\n       * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to\n       * clean up DOM bindings before an element is removed from the DOM.\n       */\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$destroy\n       * @kind function\n       *\n       * @description\n       * Removes the current scope (and all of its children) from the parent scope. Removal implies\n       * that calls to {@link ng.$rootScope.Scope#$digest $digest()} will no longer\n       * propagate to the current scope and its children. Removal also implies that the current\n       * scope is eligible for garbage collection.\n       *\n       * The `$destroy()` is usually used by directives such as\n       * {@link ng.directive:ngRepeat ngRepeat} for managing the\n       * unrolling of the loop.\n       *\n       * Just before a scope is destroyed, a `$destroy` event is broadcasted on this scope.\n       * Application code can register a `$destroy` event handler that will give it a chance to\n       * perform any necessary cleanup.\n       *\n       * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to\n       * clean up DOM bindings before an element is removed from the DOM.\n       */\n      $destroy: function() {\n        // We can't destroy a scope that has been already destroyed.\n        if (this.$$destroyed) return;\n        var parent = this.$parent;\n\n        this.$broadcast('$destroy');\n        this.$$destroyed = true;\n\n        if (this === $rootScope) {\n          //Remove handlers attached to window when $rootScope is removed\n          $browser.$$applicationDestroyed();\n        }\n\n        incrementWatchersCount(this, -this.$$watchersCount);\n        for (var eventName in this.$$listenerCount) {\n          decrementListenerCount(this, this.$$listenerCount[eventName], eventName);\n        }\n\n        // sever all the references to parent scopes (after this cleanup, the current scope should\n        // not be retained by any of our references and should be eligible for garbage collection)\n        if (parent && parent.$$childHead == this) parent.$$childHead = this.$$nextSibling;\n        if (parent && parent.$$childTail == this) parent.$$childTail = this.$$prevSibling;\n        if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling;\n        if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling;\n\n        // Disable listeners, watchers and apply/digest methods\n        this.$destroy = this.$digest = this.$apply = this.$evalAsync = this.$applyAsync = noop;\n        this.$on = this.$watch = this.$watchGroup = function() { return noop; };\n        this.$$listeners = {};\n\n        // Disconnect the next sibling to prevent `cleanUpScope` destroying those too\n        this.$$nextSibling = null;\n        cleanUpScope(this);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$eval\n       * @kind function\n       *\n       * @description\n       * Executes the `expression` on the current scope and returns the result. Any exceptions in\n       * the expression are propagated (uncaught). This is useful when evaluating Angular\n       * expressions.\n       *\n       * # Example\n       * ```js\n           var scope = ng.$rootScope.Scope();\n           scope.a = 1;\n           scope.b = 2;\n\n           expect(scope.$eval('a+b')).toEqual(3);\n           expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3);\n       * ```\n       *\n       * @param {(string|function())=} expression An angular expression to be executed.\n       *\n       *    - `string`: execute using the rules as defined in  {@link guide/expression expression}.\n       *    - `function(scope)`: execute the function with the current `scope` parameter.\n       *\n       * @param {(object)=} locals Local variables object, useful for overriding values in scope.\n       * @returns {*} The result of evaluating the expression.\n       */\n      $eval: function(expr, locals) {\n        return $parse(expr)(this, locals);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$evalAsync\n       * @kind function\n       *\n       * @description\n       * Executes the expression on the current scope at a later point in time.\n       *\n       * The `$evalAsync` makes no guarantees as to when the `expression` will be executed, only\n       * that:\n       *\n       *   - it will execute after the function that scheduled the evaluation (preferably before DOM\n       *     rendering).\n       *   - at least one {@link ng.$rootScope.Scope#$digest $digest cycle} will be performed after\n       *     `expression` execution.\n       *\n       * Any exceptions from the execution of the expression are forwarded to the\n       * {@link ng.$exceptionHandler $exceptionHandler} service.\n       *\n       * __Note:__ if this function is called outside of a `$digest` cycle, a new `$digest` cycle\n       * will be scheduled. However, it is encouraged to always call code that changes the model\n       * from within an `$apply` call. That includes code evaluated via `$evalAsync`.\n       *\n       * @param {(string|function())=} expression An angular expression to be executed.\n       *\n       *    - `string`: execute using the rules as defined in {@link guide/expression expression}.\n       *    - `function(scope)`: execute the function with the current `scope` parameter.\n       *\n       * @param {(object)=} locals Local variables object, useful for overriding values in scope.\n       */\n      $evalAsync: function(expr, locals) {\n        // if we are outside of an $digest loop and this is the first time we are scheduling async\n        // task also schedule async auto-flush\n        if (!$rootScope.$$phase && !asyncQueue.length) {\n          $browser.defer(function() {\n            if (asyncQueue.length) {\n              $rootScope.$digest();\n            }\n          });\n        }\n\n        asyncQueue.push({scope: this, expression: $parse(expr), locals: locals});\n      },\n\n      $$postDigest: function(fn) {\n        postDigestQueue.push(fn);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$apply\n       * @kind function\n       *\n       * @description\n       * `$apply()` is used to execute an expression in angular from outside of the angular\n       * framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).\n       * Because we are calling into the angular framework we need to perform proper scope life\n       * cycle of {@link ng.$exceptionHandler exception handling},\n       * {@link ng.$rootScope.Scope#$digest executing watches}.\n       *\n       * ## Life cycle\n       *\n       * # Pseudo-Code of `$apply()`\n       * ```js\n           function $apply(expr) {\n             try {\n               return $eval(expr);\n             } catch (e) {\n               $exceptionHandler(e);\n             } finally {\n               $root.$digest();\n             }\n           }\n       * ```\n       *\n       *\n       * Scope's `$apply()` method transitions through the following stages:\n       *\n       * 1. The {@link guide/expression expression} is executed using the\n       *    {@link ng.$rootScope.Scope#$eval $eval()} method.\n       * 2. Any exceptions from the execution of the expression are forwarded to the\n       *    {@link ng.$exceptionHandler $exceptionHandler} service.\n       * 3. The {@link ng.$rootScope.Scope#$watch watch} listeners are fired immediately after the\n       *    expression was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method.\n       *\n       *\n       * @param {(string|function())=} exp An angular expression to be executed.\n       *\n       *    - `string`: execute using the rules as defined in {@link guide/expression expression}.\n       *    - `function(scope)`: execute the function with current `scope` parameter.\n       *\n       * @returns {*} The result of evaluating the expression.\n       */\n      $apply: function(expr) {\n        try {\n          beginPhase('$apply');\n          try {\n            return this.$eval(expr);\n          } finally {\n            clearPhase();\n          }\n        } catch (e) {\n          $exceptionHandler(e);\n        } finally {\n          try {\n            $rootScope.$digest();\n          } catch (e) {\n            $exceptionHandler(e);\n            throw e;\n          }\n        }\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$applyAsync\n       * @kind function\n       *\n       * @description\n       * Schedule the invocation of $apply to occur at a later time. The actual time difference\n       * varies across browsers, but is typically around ~10 milliseconds.\n       *\n       * This can be used to queue up multiple expressions which need to be evaluated in the same\n       * digest.\n       *\n       * @param {(string|function())=} exp An angular expression to be executed.\n       *\n       *    - `string`: execute using the rules as defined in {@link guide/expression expression}.\n       *    - `function(scope)`: execute the function with current `scope` parameter.\n       */\n      $applyAsync: function(expr) {\n        var scope = this;\n        expr && applyAsyncQueue.push($applyAsyncExpression);\n        expr = $parse(expr);\n        scheduleApplyAsync();\n\n        function $applyAsyncExpression() {\n          scope.$eval(expr);\n        }\n      },\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$on\n       * @kind function\n       *\n       * @description\n       * Listens on events of a given type. See {@link ng.$rootScope.Scope#$emit $emit} for\n       * discussion of event life cycle.\n       *\n       * The event listener function format is: `function(event, args...)`. The `event` object\n       * passed into the listener has the following attributes:\n       *\n       *   - `targetScope` - `{Scope}`: the scope on which the event was `$emit`-ed or\n       *     `$broadcast`-ed.\n       *   - `currentScope` - `{Scope}`: the scope that is currently handling the event. Once the\n       *     event propagates through the scope hierarchy, this property is set to null.\n       *   - `name` - `{string}`: name of the event.\n       *   - `stopPropagation` - `{function=}`: calling `stopPropagation` function will cancel\n       *     further event propagation (available only for events that were `$emit`-ed).\n       *   - `preventDefault` - `{function}`: calling `preventDefault` sets `defaultPrevented` flag\n       *     to true.\n       *   - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called.\n       *\n       * @param {string} name Event name to listen on.\n       * @param {function(event, ...args)} listener Function to call when the event is emitted.\n       * @returns {function()} Returns a deregistration function for this listener.\n       */\n      $on: function(name, listener) {\n        var namedListeners = this.$$listeners[name];\n        if (!namedListeners) {\n          this.$$listeners[name] = namedListeners = [];\n        }\n        namedListeners.push(listener);\n\n        var current = this;\n        do {\n          if (!current.$$listenerCount[name]) {\n            current.$$listenerCount[name] = 0;\n          }\n          current.$$listenerCount[name]++;\n        } while ((current = current.$parent));\n\n        var self = this;\n        return function() {\n          var indexOfListener = namedListeners.indexOf(listener);\n          if (indexOfListener !== -1) {\n            namedListeners[indexOfListener] = null;\n            decrementListenerCount(self, 1, name);\n          }\n        };\n      },\n\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$emit\n       * @kind function\n       *\n       * @description\n       * Dispatches an event `name` upwards through the scope hierarchy notifying the\n       * registered {@link ng.$rootScope.Scope#$on} listeners.\n       *\n       * The event life cycle starts at the scope on which `$emit` was called. All\n       * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get\n       * notified. Afterwards, the event traverses upwards toward the root scope and calls all\n       * registered listeners along the way. The event will stop propagating if one of the listeners\n       * cancels it.\n       *\n       * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed\n       * onto the {@link ng.$exceptionHandler $exceptionHandler} service.\n       *\n       * @param {string} name Event name to emit.\n       * @param {...*} args Optional one or more arguments which will be passed onto the event listeners.\n       * @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}).\n       */\n      $emit: function(name, args) {\n        var empty = [],\n            namedListeners,\n            scope = this,\n            stopPropagation = false,\n            event = {\n              name: name,\n              targetScope: scope,\n              stopPropagation: function() {stopPropagation = true;},\n              preventDefault: function() {\n                event.defaultPrevented = true;\n              },\n              defaultPrevented: false\n            },\n            listenerArgs = concat([event], arguments, 1),\n            i, length;\n\n        do {\n          namedListeners = scope.$$listeners[name] || empty;\n          event.currentScope = scope;\n          for (i = 0, length = namedListeners.length; i < length; i++) {\n\n            // if listeners were deregistered, defragment the array\n            if (!namedListeners[i]) {\n              namedListeners.splice(i, 1);\n              i--;\n              length--;\n              continue;\n            }\n            try {\n              //allow all listeners attached to the current scope to run\n              namedListeners[i].apply(null, listenerArgs);\n            } catch (e) {\n              $exceptionHandler(e);\n            }\n          }\n          //if any listener on the current scope stops propagation, prevent bubbling\n          if (stopPropagation) {\n            event.currentScope = null;\n            return event;\n          }\n          //traverse upwards\n          scope = scope.$parent;\n        } while (scope);\n\n        event.currentScope = null;\n\n        return event;\n      },\n\n\n      /**\n       * @ngdoc method\n       * @name $rootScope.Scope#$broadcast\n       * @kind function\n       *\n       * @description\n       * Dispatches an event `name` downwards to all child scopes (and their children) notifying the\n       * registered {@link ng.$rootScope.Scope#$on} listeners.\n       *\n       * The event life cycle starts at the scope on which `$broadcast` was called. All\n       * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get\n       * notified. Afterwards, the event propagates to all direct and indirect scopes of the current\n       * scope and calls all registered listeners along the way. The event cannot be canceled.\n       *\n       * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed\n       * onto the {@link ng.$exceptionHandler $exceptionHandler} service.\n       *\n       * @param {string} name Event name to broadcast.\n       * @param {...*} args Optional one or more arguments which will be passed onto the event listeners.\n       * @return {Object} Event object, see {@link ng.$rootScope.Scope#$on}\n       */\n      $broadcast: function(name, args) {\n        var target = this,\n            current = target,\n            next = target,\n            event = {\n              name: name,\n              targetScope: target,\n              preventDefault: function() {\n                event.defaultPrevented = true;\n              },\n              defaultPrevented: false\n            };\n\n        if (!target.$$listenerCount[name]) return event;\n\n        var listenerArgs = concat([event], arguments, 1),\n            listeners, i, length;\n\n        //down while you can, then up and next sibling or up and next sibling until back at root\n        while ((current = next)) {\n          event.currentScope = current;\n          listeners = current.$$listeners[name] || [];\n          for (i = 0, length = listeners.length; i < length; i++) {\n            // if listeners were deregistered, defragment the array\n            if (!listeners[i]) {\n              listeners.splice(i, 1);\n              i--;\n              length--;\n              continue;\n            }\n\n            try {\n              listeners[i].apply(null, listenerArgs);\n            } catch (e) {\n              $exceptionHandler(e);\n            }\n          }\n\n          // Insanity Warning: scope depth-first traversal\n          // yes, this code is a bit crazy, but it works and we have tests to prove it!\n          // this piece should be kept in sync with the traversal in $digest\n          // (though it differs due to having the extra check for $$listenerCount)\n          if (!(next = ((current.$$listenerCount[name] && current.$$childHead) ||\n              (current !== target && current.$$nextSibling)))) {\n            while (current !== target && !(next = current.$$nextSibling)) {\n              current = current.$parent;\n            }\n          }\n        }\n\n        event.currentScope = null;\n        return event;\n      }\n    };\n\n    var $rootScope = new Scope();\n\n    //The internal queues. Expose them on the $rootScope for debugging/testing purposes.\n    var asyncQueue = $rootScope.$$asyncQueue = [];\n    var postDigestQueue = $rootScope.$$postDigestQueue = [];\n    var applyAsyncQueue = $rootScope.$$applyAsyncQueue = [];\n\n    return $rootScope;\n\n\n    function beginPhase(phase) {\n      if ($rootScope.$$phase) {\n        throw $rootScopeMinErr('inprog', '{0} already in progress', $rootScope.$$phase);\n      }\n\n      $rootScope.$$phase = phase;\n    }\n\n    function clearPhase() {\n      $rootScope.$$phase = null;\n    }\n\n    function incrementWatchersCount(current, count) {\n      do {\n        current.$$watchersCount += count;\n      } while ((current = current.$parent));\n    }\n\n    function decrementListenerCount(current, count, name) {\n      do {\n        current.$$listenerCount[name] -= count;\n\n        if (current.$$listenerCount[name] === 0) {\n          delete current.$$listenerCount[name];\n        }\n      } while ((current = current.$parent));\n    }\n\n    /**\n     * function used as an initial value for watchers.\n     * because it's unique we can easily tell it apart from other values\n     */\n    function initWatchVal() {}\n\n    function flushApplyAsync() {\n      while (applyAsyncQueue.length) {\n        try {\n          applyAsyncQueue.shift()();\n        } catch (e) {\n          $exceptionHandler(e);\n        }\n      }\n      applyAsyncId = null;\n    }\n\n    function scheduleApplyAsync() {\n      if (applyAsyncId === null) {\n        applyAsyncId = $browser.defer(function() {\n          $rootScope.$apply(flushApplyAsync);\n        });\n      }\n    }\n  }];\n}\n\n/**\n * @ngdoc service\n * @name $rootElement\n *\n * @description\n * The root element of Angular application. This is either the element where {@link\n * ng.directive:ngApp ngApp} was declared or the element passed into\n * {@link angular.bootstrap}. The element represents the root element of application. It is also the\n * location where the application's {@link auto.$injector $injector} service gets\n * published, and can be retrieved using `$rootElement.injector()`.\n */\n\n\n// the implementation is in angular.bootstrap\n\n/**\n * @description\n * Private service to sanitize uris for links and images. Used by $compile and $sanitize.\n */\nfunction $$SanitizeUriProvider() {\n  var aHrefSanitizationWhitelist = /^\\s*(https?|ftp|mailto|tel|file):/,\n    imgSrcSanitizationWhitelist = /^\\s*((https?|ftp|file|blob):|data:image\\/)/;\n\n  /**\n   * @description\n   * Retrieves or overrides the default regular expression that is used for whitelisting of safe\n   * urls during a[href] sanitization.\n   *\n   * The sanitization is a security measure aimed at prevent XSS attacks via html links.\n   *\n   * Any url about to be assigned to a[href] via data-binding is first normalized and turned into\n   * an absolute url. Afterwards, the url is matched against the `aHrefSanitizationWhitelist`\n   * regular expression. If a match is found, the original url is written into the dom. Otherwise,\n   * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.\n   *\n   * @param {RegExp=} regexp New regexp to whitelist urls with.\n   * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for\n   *    chaining otherwise.\n   */\n  this.aHrefSanitizationWhitelist = function(regexp) {\n    if (isDefined(regexp)) {\n      aHrefSanitizationWhitelist = regexp;\n      return this;\n    }\n    return aHrefSanitizationWhitelist;\n  };\n\n\n  /**\n   * @description\n   * Retrieves or overrides the default regular expression that is used for whitelisting of safe\n   * urls during img[src] sanitization.\n   *\n   * The sanitization is a security measure aimed at prevent XSS attacks via html links.\n   *\n   * Any url about to be assigned to img[src] via data-binding is first normalized and turned into\n   * an absolute url. Afterwards, the url is matched against the `imgSrcSanitizationWhitelist`\n   * regular expression. If a match is found, the original url is written into the dom. Otherwise,\n   * the absolute url is prefixed with `'unsafe:'` string and only then is it written into the DOM.\n   *\n   * @param {RegExp=} regexp New regexp to whitelist urls with.\n   * @returns {RegExp|ng.$compileProvider} Current RegExp if called without value or self for\n   *    chaining otherwise.\n   */\n  this.imgSrcSanitizationWhitelist = function(regexp) {\n    if (isDefined(regexp)) {\n      imgSrcSanitizationWhitelist = regexp;\n      return this;\n    }\n    return imgSrcSanitizationWhitelist;\n  };\n\n  this.$get = function() {\n    return function sanitizeUri(uri, isImage) {\n      var regex = isImage ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist;\n      var normalizedVal;\n      normalizedVal = urlResolve(uri).href;\n      if (normalizedVal !== '' && !normalizedVal.match(regex)) {\n        return 'unsafe:' + normalizedVal;\n      }\n      return uri;\n    };\n  };\n}\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n *     Any commits to this file should be reviewed with security in mind.  *\n *   Changes to this file can potentially create security vulnerabilities. *\n *          An approval from 2 Core members with history of modifying      *\n *                         this file is required.                          *\n *                                                                         *\n *  Does the change somehow allow for arbitrary javascript to be executed? *\n *    Or allows for someone to change the prototype of built-in objects?   *\n *     Or gives undesired access to variables likes document or window?    *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\nvar $sceMinErr = minErr('$sce');\n\nvar SCE_CONTEXTS = {\n  HTML: 'html',\n  CSS: 'css',\n  URL: 'url',\n  // RESOURCE_URL is a subtype of URL used in contexts where a privileged resource is sourced from a\n  // url.  (e.g. ng-include, script src, templateUrl)\n  RESOURCE_URL: 'resourceUrl',\n  JS: 'js'\n};\n\n// Helper functions follow.\n\nfunction adjustMatcher(matcher) {\n  if (matcher === 'self') {\n    return matcher;\n  } else if (isString(matcher)) {\n    // Strings match exactly except for 2 wildcards - '*' and '**'.\n    // '*' matches any character except those from the set ':/.?&'.\n    // '**' matches any character (like .* in a RegExp).\n    // More than 2 *'s raises an error as it's ill defined.\n    if (matcher.indexOf('***') > -1) {\n      throw $sceMinErr('iwcard',\n          'Illegal sequence *** in string matcher.  String: {0}', matcher);\n    }\n    matcher = escapeForRegexp(matcher).\n                  replace('\\\\*\\\\*', '.*').\n                  replace('\\\\*', '[^:/.?&;]*');\n    return new RegExp('^' + matcher + '$');\n  } else if (isRegExp(matcher)) {\n    // The only other type of matcher allowed is a Regexp.\n    // Match entire URL / disallow partial matches.\n    // Flags are reset (i.e. no global, ignoreCase or multiline)\n    return new RegExp('^' + matcher.source + '$');\n  } else {\n    throw $sceMinErr('imatcher',\n        'Matchers may only be \"self\", string patterns or RegExp objects');\n  }\n}\n\n\nfunction adjustMatchers(matchers) {\n  var adjustedMatchers = [];\n  if (isDefined(matchers)) {\n    forEach(matchers, function(matcher) {\n      adjustedMatchers.push(adjustMatcher(matcher));\n    });\n  }\n  return adjustedMatchers;\n}\n\n\n/**\n * @ngdoc service\n * @name $sceDelegate\n * @kind function\n *\n * @description\n *\n * `$sceDelegate` is a service that is used by the `$sce` service to provide {@link ng.$sce Strict\n * Contextual Escaping (SCE)} services to AngularJS.\n *\n * Typically, you would configure or override the {@link ng.$sceDelegate $sceDelegate} instead of\n * the `$sce` service to customize the way Strict Contextual Escaping works in AngularJS.  This is\n * because, while the `$sce` provides numerous shorthand methods, etc., you really only need to\n * override 3 core functions (`trustAs`, `getTrusted` and `valueOf`) to replace the way things\n * work because `$sce` delegates to `$sceDelegate` for these operations.\n *\n * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} to configure this service.\n *\n * The default instance of `$sceDelegate` should work out of the box with little pain.  While you\n * can override it completely to change the behavior of `$sce`, the common case would\n * involve configuring the {@link ng.$sceDelegateProvider $sceDelegateProvider} instead by setting\n * your own whitelists and blacklists for trusting URLs used for loading AngularJS resources such as\n * templates.  Refer {@link ng.$sceDelegateProvider#resourceUrlWhitelist\n * $sceDelegateProvider.resourceUrlWhitelist} and {@link\n * ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist}\n */\n\n/**\n * @ngdoc provider\n * @name $sceDelegateProvider\n * @description\n *\n * The `$sceDelegateProvider` provider allows developers to configure the {@link ng.$sceDelegate\n * $sceDelegate} service.  This allows one to get/set the whitelists and blacklists used to ensure\n * that the URLs used for sourcing Angular templates are safe.  Refer {@link\n * ng.$sceDelegateProvider#resourceUrlWhitelist $sceDelegateProvider.resourceUrlWhitelist} and\n * {@link ng.$sceDelegateProvider#resourceUrlBlacklist $sceDelegateProvider.resourceUrlBlacklist}\n *\n * For the general details about this service in Angular, read the main page for {@link ng.$sce\n * Strict Contextual Escaping (SCE)}.\n *\n * **Example**:  Consider the following case. <a name=\"example\"></a>\n *\n * - your app is hosted at url `http://myapp.example.com/`\n * - but some of your templates are hosted on other domains you control such as\n *   `http://srv01.assets.example.com/`,  `http://srv02.assets.example.com/`, etc.\n * - and you have an open redirect at `http://myapp.example.com/clickThru?...`.\n *\n * Here is what a secure configuration for this scenario might look like:\n *\n * ```\n *  angular.module('myApp', []).config(function($sceDelegateProvider) {\n *    $sceDelegateProvider.resourceUrlWhitelist([\n *      // Allow same origin resource loads.\n *      'self',\n *      // Allow loading from our assets domain.  Notice the difference between * and **.\n *      'http://srv*.assets.example.com/**'\n *    ]);\n *\n *    // The blacklist overrides the whitelist so the open redirect here is blocked.\n *    $sceDelegateProvider.resourceUrlBlacklist([\n *      'http://myapp.example.com/clickThru**'\n *    ]);\n *  });\n * ```\n */\n\nfunction $SceDelegateProvider() {\n  this.SCE_CONTEXTS = SCE_CONTEXTS;\n\n  // Resource URLs can also be trusted by policy.\n  var resourceUrlWhitelist = ['self'],\n      resourceUrlBlacklist = [];\n\n  /**\n   * @ngdoc method\n   * @name $sceDelegateProvider#resourceUrlWhitelist\n   * @kind function\n   *\n   * @param {Array=} whitelist When provided, replaces the resourceUrlWhitelist with the value\n   *    provided.  This must be an array or null.  A snapshot of this array is used so further\n   *    changes to the array are ignored.\n   *\n   *    Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items\n   *    allowed in this array.\n   *\n   *    <div class=\"alert alert-warning\">\n   *    **Note:** an empty whitelist array will block all URLs!\n   *    </div>\n   *\n   * @return {Array} the currently set whitelist array.\n   *\n   * The **default value** when no whitelist has been explicitly set is `['self']` allowing only\n   * same origin resource requests.\n   *\n   * @description\n   * Sets/Gets the whitelist of trusted resource URLs.\n   */\n  this.resourceUrlWhitelist = function(value) {\n    if (arguments.length) {\n      resourceUrlWhitelist = adjustMatchers(value);\n    }\n    return resourceUrlWhitelist;\n  };\n\n  /**\n   * @ngdoc method\n   * @name $sceDelegateProvider#resourceUrlBlacklist\n   * @kind function\n   *\n   * @param {Array=} blacklist When provided, replaces the resourceUrlBlacklist with the value\n   *    provided.  This must be an array or null.  A snapshot of this array is used so further\n   *    changes to the array are ignored.\n   *\n   *    Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items\n   *    allowed in this array.\n   *\n   *    The typical usage for the blacklist is to **block\n   *    [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as\n   *    these would otherwise be trusted but actually return content from the redirected domain.\n   *\n   *    Finally, **the blacklist overrides the whitelist** and has the final say.\n   *\n   * @return {Array} the currently set blacklist array.\n   *\n   * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there\n   * is no blacklist.)\n   *\n   * @description\n   * Sets/Gets the blacklist of trusted resource URLs.\n   */\n\n  this.resourceUrlBlacklist = function(value) {\n    if (arguments.length) {\n      resourceUrlBlacklist = adjustMatchers(value);\n    }\n    return resourceUrlBlacklist;\n  };\n\n  this.$get = ['$injector', function($injector) {\n\n    var htmlSanitizer = function htmlSanitizer(html) {\n      throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.');\n    };\n\n    if ($injector.has('$sanitize')) {\n      htmlSanitizer = $injector.get('$sanitize');\n    }\n\n\n    function matchUrl(matcher, parsedUrl) {\n      if (matcher === 'self') {\n        return urlIsSameOrigin(parsedUrl);\n      } else {\n        // definitely a regex.  See adjustMatchers()\n        return !!matcher.exec(parsedUrl.href);\n      }\n    }\n\n    function isResourceUrlAllowedByPolicy(url) {\n      var parsedUrl = urlResolve(url.toString());\n      var i, n, allowed = false;\n      // Ensure that at least one item from the whitelist allows this url.\n      for (i = 0, n = resourceUrlWhitelist.length; i < n; i++) {\n        if (matchUrl(resourceUrlWhitelist[i], parsedUrl)) {\n          allowed = true;\n          break;\n        }\n      }\n      if (allowed) {\n        // Ensure that no item from the blacklist blocked this url.\n        for (i = 0, n = resourceUrlBlacklist.length; i < n; i++) {\n          if (matchUrl(resourceUrlBlacklist[i], parsedUrl)) {\n            allowed = false;\n            break;\n          }\n        }\n      }\n      return allowed;\n    }\n\n    function generateHolderType(Base) {\n      var holderType = function TrustedValueHolderType(trustedValue) {\n        this.$$unwrapTrustedValue = function() {\n          return trustedValue;\n        };\n      };\n      if (Base) {\n        holderType.prototype = new Base();\n      }\n      holderType.prototype.valueOf = function sceValueOf() {\n        return this.$$unwrapTrustedValue();\n      };\n      holderType.prototype.toString = function sceToString() {\n        return this.$$unwrapTrustedValue().toString();\n      };\n      return holderType;\n    }\n\n    var trustedValueHolderBase = generateHolderType(),\n        byType = {};\n\n    byType[SCE_CONTEXTS.HTML] = generateHolderType(trustedValueHolderBase);\n    byType[SCE_CONTEXTS.CSS] = generateHolderType(trustedValueHolderBase);\n    byType[SCE_CONTEXTS.URL] = generateHolderType(trustedValueHolderBase);\n    byType[SCE_CONTEXTS.JS] = generateHolderType(trustedValueHolderBase);\n    byType[SCE_CONTEXTS.RESOURCE_URL] = generateHolderType(byType[SCE_CONTEXTS.URL]);\n\n    /**\n     * @ngdoc method\n     * @name $sceDelegate#trustAs\n     *\n     * @description\n     * Returns an object that is trusted by angular for use in specified strict\n     * contextual escaping contexts (such as ng-bind-html, ng-include, any src\n     * attribute interpolation, any dom event binding attribute interpolation\n     * such as for onclick,  etc.) that uses the provided value.\n     * See {@link ng.$sce $sce} for enabling strict contextual escaping.\n     *\n     * @param {string} type The kind of context in which this value is safe for use.  e.g. url,\n     *   resourceUrl, html, js and css.\n     * @param {*} value The value that that should be considered trusted/safe.\n     * @returns {*} A value that can be used to stand in for the provided `value` in places\n     * where Angular expects a $sce.trustAs() return value.\n     */\n    function trustAs(type, trustedValue) {\n      var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null);\n      if (!Constructor) {\n        throw $sceMinErr('icontext',\n            'Attempted to trust a value in invalid context. Context: {0}; Value: {1}',\n            type, trustedValue);\n      }\n      if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') {\n        return trustedValue;\n      }\n      // All the current contexts in SCE_CONTEXTS happen to be strings.  In order to avoid trusting\n      // mutable objects, we ensure here that the value passed in is actually a string.\n      if (typeof trustedValue !== 'string') {\n        throw $sceMinErr('itype',\n            'Attempted to trust a non-string value in a content requiring a string: Context: {0}',\n            type);\n      }\n      return new Constructor(trustedValue);\n    }\n\n    /**\n     * @ngdoc method\n     * @name $sceDelegate#valueOf\n     *\n     * @description\n     * If the passed parameter had been returned by a prior call to {@link ng.$sceDelegate#trustAs\n     * `$sceDelegate.trustAs`}, returns the value that had been passed to {@link\n     * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}.\n     *\n     * If the passed parameter is not a value that had been returned by {@link\n     * ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}, returns it as-is.\n     *\n     * @param {*} value The result of a prior {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}\n     *      call or anything else.\n     * @returns {*} The `value` that was originally provided to {@link ng.$sceDelegate#trustAs\n     *     `$sceDelegate.trustAs`} if `value` is the result of such a call.  Otherwise, returns\n     *     `value` unchanged.\n     */\n    function valueOf(maybeTrusted) {\n      if (maybeTrusted instanceof trustedValueHolderBase) {\n        return maybeTrusted.$$unwrapTrustedValue();\n      } else {\n        return maybeTrusted;\n      }\n    }\n\n    /**\n     * @ngdoc method\n     * @name $sceDelegate#getTrusted\n     *\n     * @description\n     * Takes the result of a {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`} call and\n     * returns the originally supplied value if the queried context type is a supertype of the\n     * created type.  If this condition isn't satisfied, throws an exception.\n     *\n     * <div class=\"alert alert-danger\">\n     * Disabling auto-escaping is extremely dangerous, it usually creates a Cross Site Scripting\n     * (XSS) vulnerability in your application.\n     * </div>\n     *\n     * @param {string} type The kind of context in which this value is to be used.\n     * @param {*} maybeTrusted The result of a prior {@link ng.$sceDelegate#trustAs\n     *     `$sceDelegate.trustAs`} call.\n     * @returns {*} The value the was originally provided to {@link ng.$sceDelegate#trustAs\n     *     `$sceDelegate.trustAs`} if valid in this context.  Otherwise, throws an exception.\n     */\n    function getTrusted(type, maybeTrusted) {\n      if (maybeTrusted === null || isUndefined(maybeTrusted) || maybeTrusted === '') {\n        return maybeTrusted;\n      }\n      var constructor = (byType.hasOwnProperty(type) ? byType[type] : null);\n      if (constructor && maybeTrusted instanceof constructor) {\n        return maybeTrusted.$$unwrapTrustedValue();\n      }\n      // If we get here, then we may only take one of two actions.\n      // 1. sanitize the value for the requested type, or\n      // 2. throw an exception.\n      if (type === SCE_CONTEXTS.RESOURCE_URL) {\n        if (isResourceUrlAllowedByPolicy(maybeTrusted)) {\n          return maybeTrusted;\n        } else {\n          throw $sceMinErr('insecurl',\n              'Blocked loading resource from url not allowed by $sceDelegate policy.  URL: {0}',\n              maybeTrusted.toString());\n        }\n      } else if (type === SCE_CONTEXTS.HTML) {\n        return htmlSanitizer(maybeTrusted);\n      }\n      throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.');\n    }\n\n    return { trustAs: trustAs,\n             getTrusted: getTrusted,\n             valueOf: valueOf };\n  }];\n}\n\n\n/**\n * @ngdoc provider\n * @name $sceProvider\n * @description\n *\n * The $sceProvider provider allows developers to configure the {@link ng.$sce $sce} service.\n * -   enable/disable Strict Contextual Escaping (SCE) in a module\n * -   override the default implementation with a custom delegate\n *\n * Read more about {@link ng.$sce Strict Contextual Escaping (SCE)}.\n */\n\n/* jshint maxlen: false*/\n\n/**\n * @ngdoc service\n * @name $sce\n * @kind function\n *\n * @description\n *\n * `$sce` is a service that provides Strict Contextual Escaping services to AngularJS.\n *\n * # Strict Contextual Escaping\n *\n * Strict Contextual Escaping (SCE) is a mode in which AngularJS requires bindings in certain\n * contexts to result in a value that is marked as safe to use for that context.  One example of\n * such a context is binding arbitrary html controlled by the user via `ng-bind-html`.  We refer\n * to these contexts as privileged or SCE contexts.\n *\n * As of version 1.2, Angular ships with SCE enabled by default.\n *\n * Note:  When enabled (the default), IE<11 in quirks mode is not supported.  In this mode, IE<11 allow\n * one to execute arbitrary javascript by the use of the expression() syntax.  Refer\n * <http://blogs.msdn.com/b/ie/archive/2008/10/16/ending-expressions.aspx> to learn more about them.\n * You can ensure your document is in standards mode and not quirks mode by adding `<!doctype html>`\n * to the top of your HTML document.\n *\n * SCE assists in writing code in way that (a) is secure by default and (b) makes auditing for\n * security vulnerabilities such as XSS, clickjacking, etc. a lot easier.\n *\n * Here's an example of a binding in a privileged context:\n *\n * ```\n * <input ng-model=\"userHtml\" aria-label=\"User input\">\n * <div ng-bind-html=\"userHtml\"></div>\n * ```\n *\n * Notice that `ng-bind-html` is bound to `userHtml` controlled by the user.  With SCE\n * disabled, this application allows the user to render arbitrary HTML into the DIV.\n * In a more realistic example, one may be rendering user comments, blog articles, etc. via\n * bindings.  (HTML is just one example of a context where rendering user controlled input creates\n * security vulnerabilities.)\n *\n * For the case of HTML, you might use a library, either on the client side, or on the server side,\n * to sanitize unsafe HTML before binding to the value and rendering it in the document.\n *\n * How would you ensure that every place that used these types of bindings was bound to a value that\n * was sanitized by your library (or returned as safe for rendering by your server?)  How can you\n * ensure that you didn't accidentally delete the line that sanitized the value, or renamed some\n * properties/fields and forgot to update the binding to the sanitized value?\n *\n * To be secure by default, you want to ensure that any such bindings are disallowed unless you can\n * determine that something explicitly says it's safe to use a value for binding in that\n * context.  You can then audit your code (a simple grep would do) to ensure that this is only done\n * for those values that you can easily tell are safe - because they were received from your server,\n * sanitized by your library, etc.  You can organize your codebase to help with this - perhaps\n * allowing only the files in a specific directory to do this.  Ensuring that the internal API\n * exposed by that code doesn't markup arbitrary values as safe then becomes a more manageable task.\n *\n * In the case of AngularJS' SCE service, one uses {@link ng.$sce#trustAs $sce.trustAs}\n * (and shorthand methods such as {@link ng.$sce#trustAsHtml $sce.trustAsHtml}, etc.) to\n * obtain values that will be accepted by SCE / privileged contexts.\n *\n *\n * ## How does it work?\n *\n * In privileged contexts, directives and code will bind to the result of {@link ng.$sce#getTrusted\n * $sce.getTrusted(context, value)} rather than to the value directly.  Directives use {@link\n * ng.$sce#parseAs $sce.parseAs} rather than `$parse` to watch attribute bindings, which performs the\n * {@link ng.$sce#getTrusted $sce.getTrusted} behind the scenes on non-constant literals.\n *\n * As an example, {@link ng.directive:ngBindHtml ngBindHtml} uses {@link\n * ng.$sce#parseAsHtml $sce.parseAsHtml(binding expression)}.  Here's the actual code (slightly\n * simplified):\n *\n * ```\n * var ngBindHtmlDirective = ['$sce', function($sce) {\n *   return function(scope, element, attr) {\n *     scope.$watch($sce.parseAsHtml(attr.ngBindHtml), function(value) {\n *       element.html(value || '');\n *     });\n *   };\n * }];\n * ```\n *\n * ## Impact on loading templates\n *\n * This applies both to the {@link ng.directive:ngInclude `ng-include`} directive as well as\n * `templateUrl`'s specified by {@link guide/directive directives}.\n *\n * By default, Angular only loads templates from the same domain and protocol as the application\n * document.  This is done by calling {@link ng.$sce#getTrustedResourceUrl\n * $sce.getTrustedResourceUrl} on the template URL.  To load templates from other domains and/or\n * protocols, you may either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist\n * them} or {@link ng.$sce#trustAsResourceUrl wrap it} into a trusted value.\n *\n * *Please note*:\n * The browser's\n * [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest)\n * and [Cross-Origin Resource Sharing (CORS)](http://www.w3.org/TR/cors/)\n * policy apply in addition to this and may further restrict whether the template is successfully\n * loaded.  This means that without the right CORS policy, loading templates from a different domain\n * won't work on all browsers.  Also, loading templates from `file://` URL does not work on some\n * browsers.\n *\n * ## This feels like too much overhead\n *\n * It's important to remember that SCE only applies to interpolation expressions.\n *\n * If your expressions are constant literals, they're automatically trusted and you don't need to\n * call `$sce.trustAs` on them (remember to include the `ngSanitize` module) (e.g.\n * `<div ng-bind-html=\"'<b>implicitly trusted</b>'\"></div>`) just works.\n *\n * Additionally, `a[href]` and `img[src]` automatically sanitize their URLs and do not pass them\n * through {@link ng.$sce#getTrusted $sce.getTrusted}.  SCE doesn't play a role here.\n *\n * The included {@link ng.$sceDelegate $sceDelegate} comes with sane defaults to allow you to load\n * templates in `ng-include` from your application's domain without having to even know about SCE.\n * It blocks loading templates from other domains or loading templates over http from an https\n * served document.  You can change these by setting your own custom {@link\n * ng.$sceDelegateProvider#resourceUrlWhitelist whitelists} and {@link\n * ng.$sceDelegateProvider#resourceUrlBlacklist blacklists} for matching such URLs.\n *\n * This significantly reduces the overhead.  It is far easier to pay the small overhead and have an\n * application that's secure and can be audited to verify that with much more ease than bolting\n * security onto an application later.\n *\n * <a name=\"contexts\"></a>\n * ## What trusted context types are supported?\n *\n * | Context             | Notes          |\n * |---------------------|----------------|\n * | `$sce.HTML`         | For HTML that's safe to source into the application.  The {@link ng.directive:ngBindHtml ngBindHtml} directive uses this context for bindings. If an unsafe value is encountered and the {@link ngSanitize $sanitize} module is present this will sanitize the value instead of throwing an error. |\n * | `$sce.CSS`          | For CSS that's safe to source into the application.  Currently unused.  Feel free to use it in your own directives. |\n * | `$sce.URL`          | For URLs that are safe to follow as links.  Currently unused (`<a href=` and `<img src=` sanitize their urls and don't constitute an SCE context. |\n * | `$sce.RESOURCE_URL` | For URLs that are not only safe to follow as links, but whose contents are also safe to include in your application.  Examples include `ng-include`, `src` / `ngSrc` bindings for tags other than `IMG` (e.g. `IFRAME`, `OBJECT`, etc.)  <br><br>Note that `$sce.RESOURCE_URL` makes a stronger statement about the URL than `$sce.URL` does and therefore contexts requiring values trusted for `$sce.RESOURCE_URL` can be used anywhere that values trusted for `$sce.URL` are required. |\n * | `$sce.JS`           | For JavaScript that is safe to execute in your application's context.  Currently unused.  Feel free to use it in your own directives. |\n *\n * ## Format of items in {@link ng.$sceDelegateProvider#resourceUrlWhitelist resourceUrlWhitelist}/{@link ng.$sceDelegateProvider#resourceUrlBlacklist Blacklist} <a name=\"resourceUrlPatternItem\"></a>\n *\n *  Each element in these arrays must be one of the following:\n *\n *  - **'self'**\n *    - The special **string**, `'self'`, can be used to match against all URLs of the **same\n *      domain** as the application document using the **same protocol**.\n *  - **String** (except the special value `'self'`)\n *    - The string is matched against the full *normalized / absolute URL* of the resource\n *      being tested (substring matches are not good enough.)\n *    - There are exactly **two wildcard sequences** - `*` and `**`.  All other characters\n *      match themselves.\n *    - `*`: matches zero or more occurrences of any character other than one of the following 6\n *      characters: '`:`', '`/`', '`.`', '`?`', '`&`' and '`;`'.  It's a useful wildcard for use\n *      in a whitelist.\n *    - `**`: matches zero or more occurrences of *any* character.  As such, it's not\n *      appropriate for use in a scheme, domain, etc. as it would match too much.  (e.g.\n *      http://**.example.com/ would match http://evil.com/?ignore=.example.com/ and that might\n *      not have been the intention.)  Its usage at the very end of the path is ok.  (e.g.\n *      http://foo.example.com/templates/**).\n *  - **RegExp** (*see caveat below*)\n *    - *Caveat*:  While regular expressions are powerful and offer great flexibility,  their syntax\n *      (and all the inevitable escaping) makes them *harder to maintain*.  It's easy to\n *      accidentally introduce a bug when one updates a complex expression (imho, all regexes should\n *      have good test coverage).  For instance, the use of `.` in the regex is correct only in a\n *      small number of cases.  A `.` character in the regex used when matching the scheme or a\n *      subdomain could be matched against a `:` or literal `.` that was likely not intended.   It\n *      is highly recommended to use the string patterns and only fall back to regular expressions\n *      as a last resort.\n *    - The regular expression must be an instance of RegExp (i.e. not a string.)  It is\n *      matched against the **entire** *normalized / absolute URL* of the resource being tested\n *      (even when the RegExp did not have the `^` and `$` codes.)  In addition, any flags\n *      present on the RegExp (such as multiline, global, ignoreCase) are ignored.\n *    - If you are generating your JavaScript from some other templating engine (not\n *      recommended, e.g. in issue [#4006](https://github.com/angular/angular.js/issues/4006)),\n *      remember to escape your regular expression (and be aware that you might need more than\n *      one level of escaping depending on your templating engine and the way you interpolated\n *      the value.)  Do make use of your platform's escaping mechanism as it might be good\n *      enough before coding your own.  E.g. Ruby has\n *      [Regexp.escape(str)](http://www.ruby-doc.org/core-2.0.0/Regexp.html#method-c-escape)\n *      and Python has [re.escape](http://docs.python.org/library/re.html#re.escape).\n *      Javascript lacks a similar built in function for escaping.  Take a look at Google\n *      Closure library's [goog.string.regExpEscape(s)](\n *      http://docs.closure-library.googlecode.com/git/closure_goog_string_string.js.source.html#line962).\n *\n * Refer {@link ng.$sceDelegateProvider $sceDelegateProvider} for an example.\n *\n * ## Show me an example using SCE.\n *\n * <example module=\"mySceApp\" deps=\"angular-sanitize.js\">\n * <file name=\"index.html\">\n *   <div ng-controller=\"AppController as myCtrl\">\n *     <i ng-bind-html=\"myCtrl.explicitlyTrustedHtml\" id=\"explicitlyTrustedHtml\"></i><br><br>\n *     <b>User comments</b><br>\n *     By default, HTML that isn't explicitly trusted (e.g. Alice's comment) is sanitized when\n *     $sanitize is available.  If $sanitize isn't available, this results in an error instead of an\n *     exploit.\n *     <div class=\"well\">\n *       <div ng-repeat=\"userComment in myCtrl.userComments\">\n *         <b>{{userComment.name}}</b>:\n *         <span ng-bind-html=\"userComment.htmlComment\" class=\"htmlComment\"></span>\n *         <br>\n *       </div>\n *     </div>\n *   </div>\n * </file>\n *\n * <file name=\"script.js\">\n *   angular.module('mySceApp', ['ngSanitize'])\n *     .controller('AppController', ['$http', '$templateCache', '$sce',\n *       function($http, $templateCache, $sce) {\n *         var self = this;\n *         $http.get(\"test_data.json\", {cache: $templateCache}).success(function(userComments) {\n *           self.userComments = userComments;\n *         });\n *         self.explicitlyTrustedHtml = $sce.trustAsHtml(\n *             '<span onmouseover=\"this.textContent=&quot;Explicitly trusted HTML bypasses ' +\n *             'sanitization.&quot;\">Hover over this text.</span>');\n *       }]);\n * </file>\n *\n * <file name=\"test_data.json\">\n * [\n *   { \"name\": \"Alice\",\n *     \"htmlComment\":\n *         \"<span onmouseover='this.textContent=\\\"PWN3D!\\\"'>Is <i>anyone</i> reading this?</span>\"\n *   },\n *   { \"name\": \"Bob\",\n *     \"htmlComment\": \"<i>Yes!</i>  Am I the only other one?\"\n *   }\n * ]\n * </file>\n *\n * <file name=\"protractor.js\" type=\"protractor\">\n *   describe('SCE doc demo', function() {\n *     it('should sanitize untrusted values', function() {\n *       expect(element.all(by.css('.htmlComment')).first().getInnerHtml())\n *           .toBe('<span>Is <i>anyone</i> reading this?</span>');\n *     });\n *\n *     it('should NOT sanitize explicitly trusted values', function() {\n *       expect(element(by.id('explicitlyTrustedHtml')).getInnerHtml()).toBe(\n *           '<span onmouseover=\"this.textContent=&quot;Explicitly trusted HTML bypasses ' +\n *           'sanitization.&quot;\">Hover over this text.</span>');\n *     });\n *   });\n * </file>\n * </example>\n *\n *\n *\n * ## Can I disable SCE completely?\n *\n * Yes, you can.  However, this is strongly discouraged.  SCE gives you a lot of security benefits\n * for little coding overhead.  It will be much harder to take an SCE disabled application and\n * either secure it on your own or enable SCE at a later stage.  It might make sense to disable SCE\n * for cases where you have a lot of existing code that was written before SCE was introduced and\n * you're migrating them a module at a time.\n *\n * That said, here's how you can completely disable SCE:\n *\n * ```\n * angular.module('myAppWithSceDisabledmyApp', []).config(function($sceProvider) {\n *   // Completely disable SCE.  For demonstration purposes only!\n *   // Do not use in new projects.\n *   $sceProvider.enabled(false);\n * });\n * ```\n *\n */\n/* jshint maxlen: 100 */\n\nfunction $SceProvider() {\n  var enabled = true;\n\n  /**\n   * @ngdoc method\n   * @name $sceProvider#enabled\n   * @kind function\n   *\n   * @param {boolean=} value If provided, then enables/disables SCE.\n   * @return {boolean} true if SCE is enabled, false otherwise.\n   *\n   * @description\n   * Enables/disables SCE and returns the current value.\n   */\n  this.enabled = function(value) {\n    if (arguments.length) {\n      enabled = !!value;\n    }\n    return enabled;\n  };\n\n\n  /* Design notes on the default implementation for SCE.\n   *\n   * The API contract for the SCE delegate\n   * -------------------------------------\n   * The SCE delegate object must provide the following 3 methods:\n   *\n   * - trustAs(contextEnum, value)\n   *     This method is used to tell the SCE service that the provided value is OK to use in the\n   *     contexts specified by contextEnum.  It must return an object that will be accepted by\n   *     getTrusted() for a compatible contextEnum and return this value.\n   *\n   * - valueOf(value)\n   *     For values that were not produced by trustAs(), return them as is.  For values that were\n   *     produced by trustAs(), return the corresponding input value to trustAs.  Basically, if\n   *     trustAs is wrapping the given values into some type, this operation unwraps it when given\n   *     such a value.\n   *\n   * - getTrusted(contextEnum, value)\n   *     This function should return the a value that is safe to use in the context specified by\n   *     contextEnum or throw and exception otherwise.\n   *\n   * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be\n   * opaque or wrapped in some holder object.  That happens to be an implementation detail.  For\n   * instance, an implementation could maintain a registry of all trusted objects by context.  In\n   * such a case, trustAs() would return the same object that was passed in.  getTrusted() would\n   * return the same object passed in if it was found in the registry under a compatible context or\n   * throw an exception otherwise.  An implementation might only wrap values some of the time based\n   * on some criteria.  getTrusted() might return a value and not throw an exception for special\n   * constants or objects even if not wrapped.  All such implementations fulfill this contract.\n   *\n   *\n   * A note on the inheritance model for SCE contexts\n   * ------------------------------------------------\n   * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types.  This\n   * is purely an implementation details.\n   *\n   * The contract is simply this:\n   *\n   *     getTrusted($sce.RESOURCE_URL, value) succeeding implies that getTrusted($sce.URL, value)\n   *     will also succeed.\n   *\n   * Inheritance happens to capture this in a natural way.  In some future, we\n   * may not use inheritance anymore.  That is OK because no code outside of\n   * sce.js and sceSpecs.js would need to be aware of this detail.\n   */\n\n  this.$get = ['$parse', '$sceDelegate', function(\n                $parse,   $sceDelegate) {\n    // Prereq: Ensure that we're not running in IE<11 quirks mode.  In that mode, IE < 11 allow\n    // the \"expression(javascript expression)\" syntax which is insecure.\n    if (enabled && msie < 8) {\n      throw $sceMinErr('iequirks',\n        'Strict Contextual Escaping does not support Internet Explorer version < 11 in quirks ' +\n        'mode.  You can fix this by adding the text <!doctype html> to the top of your HTML ' +\n        'document.  See http://docs.angularjs.org/api/ng.$sce for more information.');\n    }\n\n    var sce = shallowCopy(SCE_CONTEXTS);\n\n    /**\n     * @ngdoc method\n     * @name $sce#isEnabled\n     * @kind function\n     *\n     * @return {Boolean} true if SCE is enabled, false otherwise.  If you want to set the value, you\n     * have to do it at module config time on {@link ng.$sceProvider $sceProvider}.\n     *\n     * @description\n     * Returns a boolean indicating if SCE is enabled.\n     */\n    sce.isEnabled = function() {\n      return enabled;\n    };\n    sce.trustAs = $sceDelegate.trustAs;\n    sce.getTrusted = $sceDelegate.getTrusted;\n    sce.valueOf = $sceDelegate.valueOf;\n\n    if (!enabled) {\n      sce.trustAs = sce.getTrusted = function(type, value) { return value; };\n      sce.valueOf = identity;\n    }\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAs\n     *\n     * @description\n     * Converts Angular {@link guide/expression expression} into a function.  This is like {@link\n     * ng.$parse $parse} and is identical when the expression is a literal constant.  Otherwise, it\n     * wraps the expression in a call to {@link ng.$sce#getTrusted $sce.getTrusted(*type*,\n     * *result*)}\n     *\n     * @param {string} type The kind of SCE context in which this result will be used.\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n    sce.parseAs = function sceParseAs(type, expr) {\n      var parsed = $parse(expr);\n      if (parsed.literal && parsed.constant) {\n        return parsed;\n      } else {\n        return $parse(expr, function(value) {\n          return sce.getTrusted(type, value);\n        });\n      }\n    };\n\n    /**\n     * @ngdoc method\n     * @name $sce#trustAs\n     *\n     * @description\n     * Delegates to {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs`}.  As such,\n     * returns an object that is trusted by angular for use in specified strict contextual\n     * escaping contexts (such as ng-bind-html, ng-include, any src attribute\n     * interpolation, any dom event binding attribute interpolation such as for onclick,  etc.)\n     * that uses the provided value.  See * {@link ng.$sce $sce} for enabling strict contextual\n     * escaping.\n     *\n     * @param {string} type The kind of context in which this value is safe for use.  e.g. url,\n     *   resourceUrl, html, js and css.\n     * @param {*} value The value that that should be considered trusted/safe.\n     * @returns {*} A value that can be used to stand in for the provided `value` in places\n     * where Angular expects a $sce.trustAs() return value.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#trustAsHtml\n     *\n     * @description\n     * Shorthand method.  `$sce.trustAsHtml(value)` →\n     *     {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.HTML, value)`}\n     *\n     * @param {*} value The value to trustAs.\n     * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedHtml\n     *     $sce.getTrustedHtml(value)} to obtain the original value.  (privileged directives\n     *     only accept expressions that are either literal constants or are the\n     *     return value of {@link ng.$sce#trustAs $sce.trustAs}.)\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#trustAsUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.trustAsUrl(value)` →\n     *     {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.URL, value)`}\n     *\n     * @param {*} value The value to trustAs.\n     * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedUrl\n     *     $sce.getTrustedUrl(value)} to obtain the original value.  (privileged directives\n     *     only accept expressions that are either literal constants or are the\n     *     return value of {@link ng.$sce#trustAs $sce.trustAs}.)\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#trustAsResourceUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.trustAsResourceUrl(value)` →\n     *     {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.RESOURCE_URL, value)`}\n     *\n     * @param {*} value The value to trustAs.\n     * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedResourceUrl\n     *     $sce.getTrustedResourceUrl(value)} to obtain the original value.  (privileged directives\n     *     only accept expressions that are either literal constants or are the return\n     *     value of {@link ng.$sce#trustAs $sce.trustAs}.)\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#trustAsJs\n     *\n     * @description\n     * Shorthand method.  `$sce.trustAsJs(value)` →\n     *     {@link ng.$sceDelegate#trustAs `$sceDelegate.trustAs($sce.JS, value)`}\n     *\n     * @param {*} value The value to trustAs.\n     * @returns {*} An object that can be passed to {@link ng.$sce#getTrustedJs\n     *     $sce.getTrustedJs(value)} to obtain the original value.  (privileged directives\n     *     only accept expressions that are either literal constants or are the\n     *     return value of {@link ng.$sce#trustAs $sce.trustAs}.)\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrusted\n     *\n     * @description\n     * Delegates to {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted`}.  As such,\n     * takes the result of a {@link ng.$sce#trustAs `$sce.trustAs`}() call and returns the\n     * originally supplied value if the queried context type is a supertype of the created type.\n     * If this condition isn't satisfied, throws an exception.\n     *\n     * @param {string} type The kind of context in which this value is to be used.\n     * @param {*} maybeTrusted The result of a prior {@link ng.$sce#trustAs `$sce.trustAs`}\n     *                         call.\n     * @returns {*} The value the was originally provided to\n     *              {@link ng.$sce#trustAs `$sce.trustAs`} if valid in this context.\n     *              Otherwise, throws an exception.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrustedHtml\n     *\n     * @description\n     * Shorthand method.  `$sce.getTrustedHtml(value)` →\n     *     {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.HTML, value)`}\n     *\n     * @param {*} value The value to pass to `$sce.getTrusted`.\n     * @returns {*} The return value of `$sce.getTrusted($sce.HTML, value)`\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrustedCss\n     *\n     * @description\n     * Shorthand method.  `$sce.getTrustedCss(value)` →\n     *     {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.CSS, value)`}\n     *\n     * @param {*} value The value to pass to `$sce.getTrusted`.\n     * @returns {*} The return value of `$sce.getTrusted($sce.CSS, value)`\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrustedUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.getTrustedUrl(value)` →\n     *     {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.URL, value)`}\n     *\n     * @param {*} value The value to pass to `$sce.getTrusted`.\n     * @returns {*} The return value of `$sce.getTrusted($sce.URL, value)`\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrustedResourceUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.getTrustedResourceUrl(value)` →\n     *     {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.RESOURCE_URL, value)`}\n     *\n     * @param {*} value The value to pass to `$sceDelegate.getTrusted`.\n     * @returns {*} The return value of `$sce.getTrusted($sce.RESOURCE_URL, value)`\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#getTrustedJs\n     *\n     * @description\n     * Shorthand method.  `$sce.getTrustedJs(value)` →\n     *     {@link ng.$sceDelegate#getTrusted `$sceDelegate.getTrusted($sce.JS, value)`}\n     *\n     * @param {*} value The value to pass to `$sce.getTrusted`.\n     * @returns {*} The return value of `$sce.getTrusted($sce.JS, value)`\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAsHtml\n     *\n     * @description\n     * Shorthand method.  `$sce.parseAsHtml(expression string)` →\n     *     {@link ng.$sce#parseAs `$sce.parseAs($sce.HTML, value)`}\n     *\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAsCss\n     *\n     * @description\n     * Shorthand method.  `$sce.parseAsCss(value)` →\n     *     {@link ng.$sce#parseAs `$sce.parseAs($sce.CSS, value)`}\n     *\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAsUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.parseAsUrl(value)` →\n     *     {@link ng.$sce#parseAs `$sce.parseAs($sce.URL, value)`}\n     *\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAsResourceUrl\n     *\n     * @description\n     * Shorthand method.  `$sce.parseAsResourceUrl(value)` →\n     *     {@link ng.$sce#parseAs `$sce.parseAs($sce.RESOURCE_URL, value)`}\n     *\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n\n    /**\n     * @ngdoc method\n     * @name $sce#parseAsJs\n     *\n     * @description\n     * Shorthand method.  `$sce.parseAsJs(value)` →\n     *     {@link ng.$sce#parseAs `$sce.parseAs($sce.JS, value)`}\n     *\n     * @param {string} expression String expression to compile.\n     * @returns {function(context, locals)} a function which represents the compiled expression:\n     *\n     *    * `context` – `{object}` – an object against which any expressions embedded in the strings\n     *      are evaluated against (typically a scope object).\n     *    * `locals` – `{object=}` – local variables context object, useful for overriding values in\n     *      `context`.\n     */\n\n    // Shorthand delegations.\n    var parse = sce.parseAs,\n        getTrusted = sce.getTrusted,\n        trustAs = sce.trustAs;\n\n    forEach(SCE_CONTEXTS, function(enumValue, name) {\n      var lName = lowercase(name);\n      sce[camelCase(\"parse_as_\" + lName)] = function(expr) {\n        return parse(enumValue, expr);\n      };\n      sce[camelCase(\"get_trusted_\" + lName)] = function(value) {\n        return getTrusted(enumValue, value);\n      };\n      sce[camelCase(\"trust_as_\" + lName)] = function(value) {\n        return trustAs(enumValue, value);\n      };\n    });\n\n    return sce;\n  }];\n}\n\n/**\n * !!! This is an undocumented \"private\" service !!!\n *\n * @name $sniffer\n * @requires $window\n * @requires $document\n *\n * @property {boolean} history Does the browser support html5 history api ?\n * @property {boolean} transitions Does the browser support CSS transition events ?\n * @property {boolean} animations Does the browser support CSS animation events ?\n *\n * @description\n * This is very simple implementation of testing browser's features.\n */\nfunction $SnifferProvider() {\n  this.$get = ['$window', '$document', function($window, $document) {\n    var eventSupport = {},\n        // Chrome Packaged Apps are not allowed to access `history.pushState`. They can be detected by\n        // the presence of `chrome.app.runtime` (see https://developer.chrome.com/apps/api_index)\n        isChromePackagedApp = $window.chrome && $window.chrome.app && $window.chrome.app.runtime,\n        hasHistoryPushState = !isChromePackagedApp && $window.history && $window.history.pushState,\n        android =\n          toInt((/android (\\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),\n        boxee = /Boxee/i.test(($window.navigator || {}).userAgent),\n        document = $document[0] || {},\n        vendorPrefix,\n        vendorRegex = /^(Moz|webkit|ms)(?=[A-Z])/,\n        bodyStyle = document.body && document.body.style,\n        transitions = false,\n        animations = false,\n        match;\n\n    if (bodyStyle) {\n      for (var prop in bodyStyle) {\n        if (match = vendorRegex.exec(prop)) {\n          vendorPrefix = match[0];\n          vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1);\n          break;\n        }\n      }\n\n      if (!vendorPrefix) {\n        vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit';\n      }\n\n      transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));\n      animations  = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));\n\n      if (android && (!transitions ||  !animations)) {\n        transitions = isString(bodyStyle.webkitTransition);\n        animations = isString(bodyStyle.webkitAnimation);\n      }\n    }\n\n\n    return {\n      // Android has history.pushState, but it does not update location correctly\n      // so let's not use the history API at all.\n      // http://code.google.com/p/android/issues/detail?id=17471\n      // https://github.com/angular/angular.js/issues/904\n\n      // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has\n      // so let's not use the history API also\n      // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined\n      // jshint -W018\n      history: !!(hasHistoryPushState && !(android < 4) && !boxee),\n      // jshint +W018\n      hasEvent: function(event) {\n        // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have\n        // it. In particular the event is not fired when backspace or delete key are pressed or\n        // when cut operation is performed.\n        // IE10+ implements 'input' event but it erroneously fires under various situations,\n        // e.g. when placeholder changes, or a form is focused.\n        if (event === 'input' && msie <= 11) return false;\n\n        if (isUndefined(eventSupport[event])) {\n          var divElm = document.createElement('div');\n          eventSupport[event] = 'on' + event in divElm;\n        }\n\n        return eventSupport[event];\n      },\n      csp: csp(),\n      vendorPrefix: vendorPrefix,\n      transitions: transitions,\n      animations: animations,\n      android: android\n    };\n  }];\n}\n\nvar $templateRequestMinErr = minErr('$compile');\n\n/**\n * @ngdoc provider\n * @name $templateRequestProvider\n * @description\n * Used to configure the options passed to the {@link $http} service when making a template request.\n *\n * For example, it can be used for specifying the \"Accept\" header that is sent to the server, when\n * requesting a template.\n */\nfunction $TemplateRequestProvider() {\n\n  var httpOptions;\n\n  /**\n   * @ngdoc method\n   * @name $templateRequestProvider#httpOptions\n   * @description\n   * The options to be passed to the {@link $http} service when making the request.\n   * You can use this to override options such as the \"Accept\" header for template requests.\n   *\n   * The {@link $templateRequest} will set the `cache` and the `transformResponse` properties of the\n   * options if not overridden here.\n   *\n   * @param {string=} value new value for the {@link $http} options.\n   * @returns {string|self} Returns the {@link $http} options when used as getter and self if used as setter.\n   */\n  this.httpOptions = function(val) {\n    if (val) {\n      httpOptions = val;\n      return this;\n    }\n    return httpOptions;\n  };\n\n  /**\n   * @ngdoc service\n   * @name $templateRequest\n   *\n   * @description\n   * The `$templateRequest` service runs security checks then downloads the provided template using\n   * `$http` and, upon success, stores the contents inside of `$templateCache`. If the HTTP request\n   * fails or the response data of the HTTP request is empty, a `$compile` error will be thrown (the\n   * exception can be thwarted by setting the 2nd parameter of the function to true). Note that the\n   * contents of `$templateCache` are trusted, so the call to `$sce.getTrustedUrl(tpl)` is omitted\n   * when `tpl` is of type string and `$templateCache` has the matching entry.\n   *\n   * If you want to pass custom options to the `$http` service, such as setting the Accept header you\n   * can configure this via {@link $templateRequestProvider#httpOptions}.\n   *\n   * @param {string|TrustedResourceUrl} tpl The HTTP request template URL\n   * @param {boolean=} ignoreRequestError Whether or not to ignore the exception when the request fails or the template is empty\n   *\n   * @return {Promise} a promise for the HTTP response data of the given URL.\n   *\n   * @property {number} totalPendingRequests total amount of pending template requests being downloaded.\n   */\n  this.$get = ['$templateCache', '$http', '$q', '$sce', function($templateCache, $http, $q, $sce) {\n\n    function handleRequestFn(tpl, ignoreRequestError) {\n      handleRequestFn.totalPendingRequests++;\n\n      // We consider the template cache holds only trusted templates, so\n      // there's no need to go through whitelisting again for keys that already\n      // are included in there. This also makes Angular accept any script\n      // directive, no matter its name. However, we still need to unwrap trusted\n      // types.\n      if (!isString(tpl) || !$templateCache.get(tpl)) {\n        tpl = $sce.getTrustedResourceUrl(tpl);\n      }\n\n      var transformResponse = $http.defaults && $http.defaults.transformResponse;\n\n      if (isArray(transformResponse)) {\n        transformResponse = transformResponse.filter(function(transformer) {\n          return transformer !== defaultHttpResponseTransform;\n        });\n      } else if (transformResponse === defaultHttpResponseTransform) {\n        transformResponse = null;\n      }\n\n      return $http.get(tpl, extend({\n          cache: $templateCache,\n          transformResponse: transformResponse\n        }, httpOptions))\n        ['finally'](function() {\n          handleRequestFn.totalPendingRequests--;\n        })\n        .then(function(response) {\n          $templateCache.put(tpl, response.data);\n          return response.data;\n        }, handleError);\n\n      function handleError(resp) {\n        if (!ignoreRequestError) {\n          throw $templateRequestMinErr('tpload', 'Failed to load template: {0} (HTTP status: {1} {2})',\n            tpl, resp.status, resp.statusText);\n        }\n        return $q.reject(resp);\n      }\n    }\n\n    handleRequestFn.totalPendingRequests = 0;\n\n    return handleRequestFn;\n  }];\n}\n\nfunction $$TestabilityProvider() {\n  this.$get = ['$rootScope', '$browser', '$location',\n       function($rootScope,   $browser,   $location) {\n\n    /**\n     * @name $testability\n     *\n     * @description\n     * The private $$testability service provides a collection of methods for use when debugging\n     * or by automated test and debugging tools.\n     */\n    var testability = {};\n\n    /**\n     * @name $$testability#findBindings\n     *\n     * @description\n     * Returns an array of elements that are bound (via ng-bind or {{}})\n     * to expressions matching the input.\n     *\n     * @param {Element} element The element root to search from.\n     * @param {string} expression The binding expression to match.\n     * @param {boolean} opt_exactMatch If true, only returns exact matches\n     *     for the expression. Filters and whitespace are ignored.\n     */\n    testability.findBindings = function(element, expression, opt_exactMatch) {\n      var bindings = element.getElementsByClassName('ng-binding');\n      var matches = [];\n      forEach(bindings, function(binding) {\n        var dataBinding = angular.element(binding).data('$binding');\n        if (dataBinding) {\n          forEach(dataBinding, function(bindingName) {\n            if (opt_exactMatch) {\n              var matcher = new RegExp('(^|\\\\s)' + escapeForRegexp(expression) + '(\\\\s|\\\\||$)');\n              if (matcher.test(bindingName)) {\n                matches.push(binding);\n              }\n            } else {\n              if (bindingName.indexOf(expression) != -1) {\n                matches.push(binding);\n              }\n            }\n          });\n        }\n      });\n      return matches;\n    };\n\n    /**\n     * @name $$testability#findModels\n     *\n     * @description\n     * Returns an array of elements that are two-way found via ng-model to\n     * expressions matching the input.\n     *\n     * @param {Element} element The element root to search from.\n     * @param {string} expression The model expression to match.\n     * @param {boolean} opt_exactMatch If true, only returns exact matches\n     *     for the expression.\n     */\n    testability.findModels = function(element, expression, opt_exactMatch) {\n      var prefixes = ['ng-', 'data-ng-', 'ng\\\\:'];\n      for (var p = 0; p < prefixes.length; ++p) {\n        var attributeEquals = opt_exactMatch ? '=' : '*=';\n        var selector = '[' + prefixes[p] + 'model' + attributeEquals + '\"' + expression + '\"]';\n        var elements = element.querySelectorAll(selector);\n        if (elements.length) {\n          return elements;\n        }\n      }\n    };\n\n    /**\n     * @name $$testability#getLocation\n     *\n     * @description\n     * Shortcut for getting the location in a browser agnostic way. Returns\n     *     the path, search, and hash. (e.g. /path?a=b#hash)\n     */\n    testability.getLocation = function() {\n      return $location.url();\n    };\n\n    /**\n     * @name $$testability#setLocation\n     *\n     * @description\n     * Shortcut for navigating to a location without doing a full page reload.\n     *\n     * @param {string} url The location url (path, search and hash,\n     *     e.g. /path?a=b#hash) to go to.\n     */\n    testability.setLocation = function(url) {\n      if (url !== $location.url()) {\n        $location.url(url);\n        $rootScope.$digest();\n      }\n    };\n\n    /**\n     * @name $$testability#whenStable\n     *\n     * @description\n     * Calls the callback when $timeout and $http requests are completed.\n     *\n     * @param {function} callback\n     */\n    testability.whenStable = function(callback) {\n      $browser.notifyWhenNoOutstandingRequests(callback);\n    };\n\n    return testability;\n  }];\n}\n\nfunction $TimeoutProvider() {\n  this.$get = ['$rootScope', '$browser', '$q', '$$q', '$exceptionHandler',\n       function($rootScope,   $browser,   $q,   $$q,   $exceptionHandler) {\n\n    var deferreds = {};\n\n\n     /**\n      * @ngdoc service\n      * @name $timeout\n      *\n      * @description\n      * Angular's wrapper for `window.setTimeout`. The `fn` function is wrapped into a try/catch\n      * block and delegates any exceptions to\n      * {@link ng.$exceptionHandler $exceptionHandler} service.\n      *\n      * The return value of calling `$timeout` is a promise, which will be resolved when\n      * the delay has passed and the timeout function, if provided, is executed.\n      *\n      * To cancel a timeout request, call `$timeout.cancel(promise)`.\n      *\n      * In tests you can use {@link ngMock.$timeout `$timeout.flush()`} to\n      * synchronously flush the queue of deferred functions.\n      *\n      * If you only want a promise that will be resolved after some specified delay\n      * then you can call `$timeout` without the `fn` function.\n      *\n      * @param {function()=} fn A function, whose execution should be delayed.\n      * @param {number=} [delay=0] Delay in milliseconds.\n      * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise\n      *   will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block.\n      * @param {...*=} Pass additional parameters to the executed function.\n      * @returns {Promise} Promise that will be resolved when the timeout is reached. The promise\n      *   will be resolved with the return value of the `fn` function.\n      *\n      */\n    function timeout(fn, delay, invokeApply) {\n      if (!isFunction(fn)) {\n        invokeApply = delay;\n        delay = fn;\n        fn = noop;\n      }\n\n      var args = sliceArgs(arguments, 3),\n          skipApply = (isDefined(invokeApply) && !invokeApply),\n          deferred = (skipApply ? $$q : $q).defer(),\n          promise = deferred.promise,\n          timeoutId;\n\n      timeoutId = $browser.defer(function() {\n        try {\n          deferred.resolve(fn.apply(null, args));\n        } catch (e) {\n          deferred.reject(e);\n          $exceptionHandler(e);\n        }\n        finally {\n          delete deferreds[promise.$$timeoutId];\n        }\n\n        if (!skipApply) $rootScope.$apply();\n      }, delay);\n\n      promise.$$timeoutId = timeoutId;\n      deferreds[timeoutId] = deferred;\n\n      return promise;\n    }\n\n\n     /**\n      * @ngdoc method\n      * @name $timeout#cancel\n      *\n      * @description\n      * Cancels a task associated with the `promise`. As a result of this, the promise will be\n      * resolved with a rejection.\n      *\n      * @param {Promise=} promise Promise returned by the `$timeout` function.\n      * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully\n      *   canceled.\n      */\n    timeout.cancel = function(promise) {\n      if (promise && promise.$$timeoutId in deferreds) {\n        deferreds[promise.$$timeoutId].reject('canceled');\n        delete deferreds[promise.$$timeoutId];\n        return $browser.defer.cancel(promise.$$timeoutId);\n      }\n      return false;\n    };\n\n    return timeout;\n  }];\n}\n\n// NOTE:  The usage of window and document instead of $window and $document here is\n// deliberate.  This service depends on the specific behavior of anchor nodes created by the\n// browser (resolving and parsing URLs) that is unlikely to be provided by mock objects and\n// cause us to break tests.  In addition, when the browser resolves a URL for XHR, it\n// doesn't know about mocked locations and resolves URLs to the real document - which is\n// exactly the behavior needed here.  There is little value is mocking these out for this\n// service.\nvar urlParsingNode = window.document.createElement(\"a\");\nvar originUrl = urlResolve(window.location.href);\n\n\n/**\n *\n * Implementation Notes for non-IE browsers\n * ----------------------------------------\n * Assigning a URL to the href property of an anchor DOM node, even one attached to the DOM,\n * results both in the normalizing and parsing of the URL.  Normalizing means that a relative\n * URL will be resolved into an absolute URL in the context of the application document.\n * Parsing means that the anchor node's host, hostname, protocol, port, pathname and related\n * properties are all populated to reflect the normalized URL.  This approach has wide\n * compatibility - Safari 1+, Mozilla 1+, Opera 7+,e etc.  See\n * http://www.aptana.com/reference/html/api/HTMLAnchorElement.html\n *\n * Implementation Notes for IE\n * ---------------------------\n * IE <= 10 normalizes the URL when assigned to the anchor node similar to the other\n * browsers.  However, the parsed components will not be set if the URL assigned did not specify\n * them.  (e.g. if you assign a.href = \"foo\", then a.protocol, a.host, etc. will be empty.)  We\n * work around that by performing the parsing in a 2nd step by taking a previously normalized\n * URL (e.g. by assigning to a.href) and assigning it a.href again.  This correctly populates the\n * properties such as protocol, hostname, port, etc.\n *\n * References:\n *   http://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement\n *   http://www.aptana.com/reference/html/api/HTMLAnchorElement.html\n *   http://url.spec.whatwg.org/#urlutils\n *   https://github.com/angular/angular.js/pull/2902\n *   http://james.padolsey.com/javascript/parsing-urls-with-the-dom/\n *\n * @kind function\n * @param {string} url The URL to be parsed.\n * @description Normalizes and parses a URL.\n * @returns {object} Returns the normalized URL as a dictionary.\n *\n *   | member name   | Description    |\n *   |---------------|----------------|\n *   | href          | A normalized version of the provided URL if it was not an absolute URL |\n *   | protocol      | The protocol including the trailing colon                              |\n *   | host          | The host and port (if the port is non-default) of the normalizedUrl    |\n *   | search        | The search params, minus the question mark                             |\n *   | hash          | The hash string, minus the hash symbol\n *   | hostname      | The hostname\n *   | port          | The port, without \":\"\n *   | pathname      | The pathname, beginning with \"/\"\n *\n */\nfunction urlResolve(url) {\n  var href = url;\n\n  if (msie) {\n    // Normalize before parse.  Refer Implementation Notes on why this is\n    // done in two steps on IE.\n    urlParsingNode.setAttribute(\"href\", href);\n    href = urlParsingNode.href;\n  }\n\n  urlParsingNode.setAttribute('href', href);\n\n  // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n  return {\n    href: urlParsingNode.href,\n    protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n    host: urlParsingNode.host,\n    search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n    hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n    hostname: urlParsingNode.hostname,\n    port: urlParsingNode.port,\n    pathname: (urlParsingNode.pathname.charAt(0) === '/')\n      ? urlParsingNode.pathname\n      : '/' + urlParsingNode.pathname\n  };\n}\n\n/**\n * Parse a request URL and determine whether this is a same-origin request as the application document.\n *\n * @param {string|object} requestUrl The url of the request as a string that will be resolved\n * or a parsed URL object.\n * @returns {boolean} Whether the request is for the same origin as the application document.\n */\nfunction urlIsSameOrigin(requestUrl) {\n  var parsed = (isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;\n  return (parsed.protocol === originUrl.protocol &&\n          parsed.host === originUrl.host);\n}\n\n/**\n * @ngdoc service\n * @name $window\n *\n * @description\n * A reference to the browser's `window` object. While `window`\n * is globally available in JavaScript, it causes testability problems, because\n * it is a global variable. In angular we always refer to it through the\n * `$window` service, so it may be overridden, removed or mocked for testing.\n *\n * Expressions, like the one defined for the `ngClick` directive in the example\n * below, are evaluated with respect to the current scope.  Therefore, there is\n * no risk of inadvertently coding in a dependency on a global value in such an\n * expression.\n *\n * @example\n   <example module=\"windowExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('windowExample', [])\n           .controller('ExampleController', ['$scope', '$window', function($scope, $window) {\n             $scope.greeting = 'Hello, World!';\n             $scope.doGreeting = function(greeting) {\n               $window.alert(greeting);\n             };\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <input type=\"text\" ng-model=\"greeting\" aria-label=\"greeting\" />\n         <button ng-click=\"doGreeting(greeting)\">ALERT</button>\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n      it('should display the greeting in the input box', function() {\n       element(by.model('greeting')).sendKeys('Hello, E2E Tests');\n       // If we click the button it will block the test runner\n       // element(':button').click();\n      });\n     </file>\n   </example>\n */\nfunction $WindowProvider() {\n  this.$get = valueFn(window);\n}\n\n/**\n * @name $$cookieReader\n * @requires $document\n *\n * @description\n * This is a private service for reading cookies used by $http and ngCookies\n *\n * @return {Object} a key/value map of the current cookies\n */\nfunction $$CookieReader($document) {\n  var rawDocument = $document[0] || {};\n  var lastCookies = {};\n  var lastCookieString = '';\n\n  function safeDecodeURIComponent(str) {\n    try {\n      return decodeURIComponent(str);\n    } catch (e) {\n      return str;\n    }\n  }\n\n  return function() {\n    var cookieArray, cookie, i, index, name;\n    var currentCookieString = rawDocument.cookie || '';\n\n    if (currentCookieString !== lastCookieString) {\n      lastCookieString = currentCookieString;\n      cookieArray = lastCookieString.split('; ');\n      lastCookies = {};\n\n      for (i = 0; i < cookieArray.length; i++) {\n        cookie = cookieArray[i];\n        index = cookie.indexOf('=');\n        if (index > 0) { //ignore nameless cookies\n          name = safeDecodeURIComponent(cookie.substring(0, index));\n          // the first value that is seen for a cookie is the most\n          // specific one.  values for the same cookie name that\n          // follow are for less specific paths.\n          if (isUndefined(lastCookies[name])) {\n            lastCookies[name] = safeDecodeURIComponent(cookie.substring(index + 1));\n          }\n        }\n      }\n    }\n    return lastCookies;\n  };\n}\n\n$$CookieReader.$inject = ['$document'];\n\nfunction $$CookieReaderProvider() {\n  this.$get = $$CookieReader;\n}\n\n/* global currencyFilter: true,\n dateFilter: true,\n filterFilter: true,\n jsonFilter: true,\n limitToFilter: true,\n lowercaseFilter: true,\n numberFilter: true,\n orderByFilter: true,\n uppercaseFilter: true,\n */\n\n/**\n * @ngdoc provider\n * @name $filterProvider\n * @description\n *\n * Filters are just functions which transform input to an output. However filters need to be\n * Dependency Injected. To achieve this a filter definition consists of a factory function which is\n * annotated with dependencies and is responsible for creating a filter function.\n *\n * <div class=\"alert alert-warning\">\n * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.\n * Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace\n * your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores\n * (`myapp_subsection_filterx`).\n * </div>\n *\n * ```js\n *   // Filter registration\n *   function MyModule($provide, $filterProvider) {\n *     // create a service to demonstrate injection (not always needed)\n *     $provide.value('greet', function(name){\n *       return 'Hello ' + name + '!';\n *     });\n *\n *     // register a filter factory which uses the\n *     // greet service to demonstrate DI.\n *     $filterProvider.register('greet', function(greet){\n *       // return the filter function which uses the greet service\n *       // to generate salutation\n *       return function(text) {\n *         // filters need to be forgiving so check input validity\n *         return text && greet(text) || text;\n *       };\n *     });\n *   }\n * ```\n *\n * The filter function is registered with the `$injector` under the filter name suffix with\n * `Filter`.\n *\n * ```js\n *   it('should be the same instance', inject(\n *     function($filterProvider) {\n *       $filterProvider.register('reverse', function(){\n *         return ...;\n *       });\n *     },\n *     function($filter, reverseFilter) {\n *       expect($filter('reverse')).toBe(reverseFilter);\n *     });\n * ```\n *\n *\n * For more information about how angular filters work, and how to create your own filters, see\n * {@link guide/filter Filters} in the Angular Developer Guide.\n */\n\n/**\n * @ngdoc service\n * @name $filter\n * @kind function\n * @description\n * Filters are used for formatting data displayed to the user.\n *\n * The general syntax in templates is as follows:\n *\n *         {{ expression [| filter_name[:parameter_value] ... ] }}\n *\n * @param {String} name Name of the filter function to retrieve\n * @return {Function} the filter function\n * @example\n   <example name=\"$filter\" module=\"filterExample\">\n     <file name=\"index.html\">\n       <div ng-controller=\"MainCtrl\">\n        <h3>{{ originalText }}</h3>\n        <h3>{{ filteredText }}</h3>\n       </div>\n     </file>\n\n     <file name=\"script.js\">\n      angular.module('filterExample', [])\n      .controller('MainCtrl', function($scope, $filter) {\n        $scope.originalText = 'hello';\n        $scope.filteredText = $filter('uppercase')($scope.originalText);\n      });\n     </file>\n   </example>\n  */\n$FilterProvider.$inject = ['$provide'];\nfunction $FilterProvider($provide) {\n  var suffix = 'Filter';\n\n  /**\n   * @ngdoc method\n   * @name $filterProvider#register\n   * @param {string|Object} name Name of the filter function, or an object map of filters where\n   *    the keys are the filter names and the values are the filter factories.\n   *\n   *    <div class=\"alert alert-warning\">\n   *    **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.\n   *    Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace\n   *    your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores\n   *    (`myapp_subsection_filterx`).\n   *    </div>\n    * @param {Function} factory If the first argument was a string, a factory function for the filter to be registered.\n   * @returns {Object} Registered filter instance, or if a map of filters was provided then a map\n   *    of the registered filter instances.\n   */\n  function register(name, factory) {\n    if (isObject(name)) {\n      var filters = {};\n      forEach(name, function(filter, key) {\n        filters[key] = register(key, filter);\n      });\n      return filters;\n    } else {\n      return $provide.factory(name + suffix, factory);\n    }\n  }\n  this.register = register;\n\n  this.$get = ['$injector', function($injector) {\n    return function(name) {\n      return $injector.get(name + suffix);\n    };\n  }];\n\n  ////////////////////////////////////////\n\n  /* global\n    currencyFilter: false,\n    dateFilter: false,\n    filterFilter: false,\n    jsonFilter: false,\n    limitToFilter: false,\n    lowercaseFilter: false,\n    numberFilter: false,\n    orderByFilter: false,\n    uppercaseFilter: false,\n  */\n\n  register('currency', currencyFilter);\n  register('date', dateFilter);\n  register('filter', filterFilter);\n  register('json', jsonFilter);\n  register('limitTo', limitToFilter);\n  register('lowercase', lowercaseFilter);\n  register('number', numberFilter);\n  register('orderBy', orderByFilter);\n  register('uppercase', uppercaseFilter);\n}\n\n/**\n * @ngdoc filter\n * @name filter\n * @kind function\n *\n * @description\n * Selects a subset of items from `array` and returns it as a new array.\n *\n * @param {Array} array The source array.\n * @param {string|Object|function()} expression The predicate to be used for selecting items from\n *   `array`.\n *\n *   Can be one of:\n *\n *   - `string`: The string is used for matching against the contents of the `array`. All strings or\n *     objects with string properties in `array` that match this string will be returned. This also\n *     applies to nested object properties.\n *     The predicate can be negated by prefixing the string with `!`.\n *\n *   - `Object`: A pattern object can be used to filter specific properties on objects contained\n *     by `array`. For example `{name:\"M\", phone:\"1\"}` predicate will return an array of items\n *     which have property `name` containing \"M\" and property `phone` containing \"1\". A special\n *     property name `$` can be used (as in `{$:\"text\"}`) to accept a match against any\n *     property of the object or its nested object properties. That's equivalent to the simple\n *     substring match with a `string` as described above. The predicate can be negated by prefixing\n *     the string with `!`.\n *     For example `{name: \"!M\"}` predicate will return an array of items which have property `name`\n *     not containing \"M\".\n *\n *     Note that a named property will match properties on the same level only, while the special\n *     `$` property will match properties on the same level or deeper. E.g. an array item like\n *     `{name: {first: 'John', last: 'Doe'}}` will **not** be matched by `{name: 'John'}`, but\n *     **will** be matched by `{$: 'John'}`.\n *\n *   - `function(value, index, array)`: A predicate function can be used to write arbitrary filters.\n *     The function is called for each element of the array, with the element, its index, and\n *     the entire array itself as arguments.\n *\n *     The final result is an array of those elements that the predicate returned true for.\n *\n * @param {function(actual, expected)|true|undefined} comparator Comparator which is used in\n *     determining if the expected value (from the filter expression) and actual value (from\n *     the object in the array) should be considered a match.\n *\n *   Can be one of:\n *\n *   - `function(actual, expected)`:\n *     The function will be given the object value and the predicate value to compare and\n *     should return true if both values should be considered equal.\n *\n *   - `true`: A shorthand for `function(actual, expected) { return angular.equals(actual, expected)}`.\n *     This is essentially strict comparison of expected and actual.\n *\n *   - `false|undefined`: A short hand for a function which will look for a substring match in case\n *     insensitive way.\n *\n *     Primitive values are converted to strings. Objects are not compared against primitives,\n *     unless they have a custom `toString` method (e.g. `Date` objects).\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n       <div ng-init=\"friends = [{name:'John', phone:'555-1276'},\n                                {name:'Mary', phone:'800-BIG-MARY'},\n                                {name:'Mike', phone:'555-4321'},\n                                {name:'Adam', phone:'555-5678'},\n                                {name:'Julie', phone:'555-8765'},\n                                {name:'Juliette', phone:'555-5678'}]\"></div>\n\n       <label>Search: <input ng-model=\"searchText\"></label>\n       <table id=\"searchTextResults\">\n         <tr><th>Name</th><th>Phone</th></tr>\n         <tr ng-repeat=\"friend in friends | filter:searchText\">\n           <td>{{friend.name}}</td>\n           <td>{{friend.phone}}</td>\n         </tr>\n       </table>\n       <hr>\n       <label>Any: <input ng-model=\"search.$\"></label> <br>\n       <label>Name only <input ng-model=\"search.name\"></label><br>\n       <label>Phone only <input ng-model=\"search.phone\"></label><br>\n       <label>Equality <input type=\"checkbox\" ng-model=\"strict\"></label><br>\n       <table id=\"searchObjResults\">\n         <tr><th>Name</th><th>Phone</th></tr>\n         <tr ng-repeat=\"friendObj in friends | filter:search:strict\">\n           <td>{{friendObj.name}}</td>\n           <td>{{friendObj.phone}}</td>\n         </tr>\n       </table>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       var expectFriendNames = function(expectedNames, key) {\n         element.all(by.repeater(key + ' in friends').column(key + '.name')).then(function(arr) {\n           arr.forEach(function(wd, i) {\n             expect(wd.getText()).toMatch(expectedNames[i]);\n           });\n         });\n       };\n\n       it('should search across all fields when filtering with a string', function() {\n         var searchText = element(by.model('searchText'));\n         searchText.clear();\n         searchText.sendKeys('m');\n         expectFriendNames(['Mary', 'Mike', 'Adam'], 'friend');\n\n         searchText.clear();\n         searchText.sendKeys('76');\n         expectFriendNames(['John', 'Julie'], 'friend');\n       });\n\n       it('should search in specific fields when filtering with a predicate object', function() {\n         var searchAny = element(by.model('search.$'));\n         searchAny.clear();\n         searchAny.sendKeys('i');\n         expectFriendNames(['Mary', 'Mike', 'Julie', 'Juliette'], 'friendObj');\n       });\n       it('should use a equal comparison when comparator is true', function() {\n         var searchName = element(by.model('search.name'));\n         var strict = element(by.model('strict'));\n         searchName.clear();\n         searchName.sendKeys('Julie');\n         strict.click();\n         expectFriendNames(['Julie'], 'friendObj');\n       });\n     </file>\n   </example>\n */\nfunction filterFilter() {\n  return function(array, expression, comparator) {\n    if (!isArrayLike(array)) {\n      if (array == null) {\n        return array;\n      } else {\n        throw minErr('filter')('notarray', 'Expected array but received: {0}', array);\n      }\n    }\n\n    var expressionType = getTypeForFilter(expression);\n    var predicateFn;\n    var matchAgainstAnyProp;\n\n    switch (expressionType) {\n      case 'function':\n        predicateFn = expression;\n        break;\n      case 'boolean':\n      case 'null':\n      case 'number':\n      case 'string':\n        matchAgainstAnyProp = true;\n        //jshint -W086\n      case 'object':\n        //jshint +W086\n        predicateFn = createPredicateFn(expression, comparator, matchAgainstAnyProp);\n        break;\n      default:\n        return array;\n    }\n\n    return Array.prototype.filter.call(array, predicateFn);\n  };\n}\n\n// Helper functions for `filterFilter`\nfunction createPredicateFn(expression, comparator, matchAgainstAnyProp) {\n  var shouldMatchPrimitives = isObject(expression) && ('$' in expression);\n  var predicateFn;\n\n  if (comparator === true) {\n    comparator = equals;\n  } else if (!isFunction(comparator)) {\n    comparator = function(actual, expected) {\n      if (isUndefined(actual)) {\n        // No substring matching against `undefined`\n        return false;\n      }\n      if ((actual === null) || (expected === null)) {\n        // No substring matching against `null`; only match against `null`\n        return actual === expected;\n      }\n      if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {\n        // Should not compare primitives against objects, unless they have custom `toString` method\n        return false;\n      }\n\n      actual = lowercase('' + actual);\n      expected = lowercase('' + expected);\n      return actual.indexOf(expected) !== -1;\n    };\n  }\n\n  predicateFn = function(item) {\n    if (shouldMatchPrimitives && !isObject(item)) {\n      return deepCompare(item, expression.$, comparator, false);\n    }\n    return deepCompare(item, expression, comparator, matchAgainstAnyProp);\n  };\n\n  return predicateFn;\n}\n\nfunction deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) {\n  var actualType = getTypeForFilter(actual);\n  var expectedType = getTypeForFilter(expected);\n\n  if ((expectedType === 'string') && (expected.charAt(0) === '!')) {\n    return !deepCompare(actual, expected.substring(1), comparator, matchAgainstAnyProp);\n  } else if (isArray(actual)) {\n    // In case `actual` is an array, consider it a match\n    // if ANY of it's items matches `expected`\n    return actual.some(function(item) {\n      return deepCompare(item, expected, comparator, matchAgainstAnyProp);\n    });\n  }\n\n  switch (actualType) {\n    case 'object':\n      var key;\n      if (matchAgainstAnyProp) {\n        for (key in actual) {\n          if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, true)) {\n            return true;\n          }\n        }\n        return dontMatchWholeObject ? false : deepCompare(actual, expected, comparator, false);\n      } else if (expectedType === 'object') {\n        for (key in expected) {\n          var expectedVal = expected[key];\n          if (isFunction(expectedVal) || isUndefined(expectedVal)) {\n            continue;\n          }\n\n          var matchAnyProperty = key === '$';\n          var actualVal = matchAnyProperty ? actual : actual[key];\n          if (!deepCompare(actualVal, expectedVal, comparator, matchAnyProperty, matchAnyProperty)) {\n            return false;\n          }\n        }\n        return true;\n      } else {\n        return comparator(actual, expected);\n      }\n      break;\n    case 'function':\n      return false;\n    default:\n      return comparator(actual, expected);\n  }\n}\n\n// Used for easily differentiating between `null` and actual `object`\nfunction getTypeForFilter(val) {\n  return (val === null) ? 'null' : typeof val;\n}\n\nvar MAX_DIGITS = 22;\nvar DECIMAL_SEP = '.';\nvar ZERO_CHAR = '0';\n\n/**\n * @ngdoc filter\n * @name currency\n * @kind function\n *\n * @description\n * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default\n * symbol for current locale is used.\n *\n * @param {number} amount Input to filter.\n * @param {string=} symbol Currency symbol or identifier to be displayed.\n * @param {number=} fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale\n * @returns {string} Formatted number.\n *\n *\n * @example\n   <example module=\"currencyExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('currencyExample', [])\n           .controller('ExampleController', ['$scope', function($scope) {\n             $scope.amount = 1234.56;\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <input type=\"number\" ng-model=\"amount\" aria-label=\"amount\"> <br>\n         default currency symbol ($): <span id=\"currency-default\">{{amount | currency}}</span><br>\n         custom currency identifier (USD$): <span id=\"currency-custom\">{{amount | currency:\"USD$\"}}</span>\n         no fractions (0): <span id=\"currency-no-fractions\">{{amount | currency:\"USD$\":0}}</span>\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should init with 1234.56', function() {\n         expect(element(by.id('currency-default')).getText()).toBe('$1,234.56');\n         expect(element(by.id('currency-custom')).getText()).toBe('USD$1,234.56');\n         expect(element(by.id('currency-no-fractions')).getText()).toBe('USD$1,235');\n       });\n       it('should update', function() {\n         if (browser.params.browser == 'safari') {\n           // Safari does not understand the minus key. See\n           // https://github.com/angular/protractor/issues/481\n           return;\n         }\n         element(by.model('amount')).clear();\n         element(by.model('amount')).sendKeys('-1234');\n         expect(element(by.id('currency-default')).getText()).toBe('-$1,234.00');\n         expect(element(by.id('currency-custom')).getText()).toBe('-USD$1,234.00');\n         expect(element(by.id('currency-no-fractions')).getText()).toBe('-USD$1,234');\n       });\n     </file>\n   </example>\n */\ncurrencyFilter.$inject = ['$locale'];\nfunction currencyFilter($locale) {\n  var formats = $locale.NUMBER_FORMATS;\n  return function(amount, currencySymbol, fractionSize) {\n    if (isUndefined(currencySymbol)) {\n      currencySymbol = formats.CURRENCY_SYM;\n    }\n\n    if (isUndefined(fractionSize)) {\n      fractionSize = formats.PATTERNS[1].maxFrac;\n    }\n\n    // if null or undefined pass it through\n    return (amount == null)\n        ? amount\n        : formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, fractionSize).\n            replace(/\\u00A4/g, currencySymbol);\n  };\n}\n\n/**\n * @ngdoc filter\n * @name number\n * @kind function\n *\n * @description\n * Formats a number as text.\n *\n * If the input is null or undefined, it will just be returned.\n * If the input is infinite (Infinity or -Infinity), the Infinity symbol '∞' or '-∞' is returned, respectively.\n * If the input is not a number an empty string is returned.\n *\n *\n * @param {number|string} number Number to format.\n * @param {(number|string)=} fractionSize Number of decimal places to round the number to.\n * If this is not provided then the fraction size is computed from the current locale's number\n * formatting pattern. In the case of the default locale, it will be 3.\n * @returns {string} Number rounded to `fractionSize` appropriately formatted based on the current\n *                   locale (e.g., in the en_US locale it will have \".\" as the decimal separator and\n *                   include \",\" group separators after each third digit).\n *\n * @example\n   <example module=\"numberFilterExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('numberFilterExample', [])\n           .controller('ExampleController', ['$scope', function($scope) {\n             $scope.val = 1234.56789;\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <label>Enter number: <input ng-model='val'></label><br>\n         Default formatting: <span id='number-default'>{{val | number}}</span><br>\n         No fractions: <span>{{val | number:0}}</span><br>\n         Negative number: <span>{{-val | number:4}}</span>\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should format numbers', function() {\n         expect(element(by.id('number-default')).getText()).toBe('1,234.568');\n         expect(element(by.binding('val | number:0')).getText()).toBe('1,235');\n         expect(element(by.binding('-val | number:4')).getText()).toBe('-1,234.5679');\n       });\n\n       it('should update', function() {\n         element(by.model('val')).clear();\n         element(by.model('val')).sendKeys('3374.333');\n         expect(element(by.id('number-default')).getText()).toBe('3,374.333');\n         expect(element(by.binding('val | number:0')).getText()).toBe('3,374');\n         expect(element(by.binding('-val | number:4')).getText()).toBe('-3,374.3330');\n      });\n     </file>\n   </example>\n */\nnumberFilter.$inject = ['$locale'];\nfunction numberFilter($locale) {\n  var formats = $locale.NUMBER_FORMATS;\n  return function(number, fractionSize) {\n\n    // if null or undefined pass it through\n    return (number == null)\n        ? number\n        : formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP, formats.DECIMAL_SEP,\n                       fractionSize);\n  };\n}\n\n/**\n * Parse a number (as a string) into three components that can be used\n * for formatting the number.\n *\n * (Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/)\n *\n * @param  {string} numStr The number to parse\n * @return {object} An object describing this number, containing the following keys:\n *  - d : an array of digits containing leading zeros as necessary\n *  - i : the number of the digits in `d` that are to the left of the decimal point\n *  - e : the exponent for numbers that would need more than `MAX_DIGITS` digits in `d`\n *\n */\nfunction parse(numStr) {\n  var exponent = 0, digits, numberOfIntegerDigits;\n  var i, j, zeros;\n\n  // Decimal point?\n  if ((numberOfIntegerDigits = numStr.indexOf(DECIMAL_SEP)) > -1) {\n    numStr = numStr.replace(DECIMAL_SEP, '');\n  }\n\n  // Exponential form?\n  if ((i = numStr.search(/e/i)) > 0) {\n    // Work out the exponent.\n    if (numberOfIntegerDigits < 0) numberOfIntegerDigits = i;\n    numberOfIntegerDigits += +numStr.slice(i + 1);\n    numStr = numStr.substring(0, i);\n  } else if (numberOfIntegerDigits < 0) {\n    // There was no decimal point or exponent so it is an integer.\n    numberOfIntegerDigits = numStr.length;\n  }\n\n  // Count the number of leading zeros.\n  for (i = 0; numStr.charAt(i) == ZERO_CHAR; i++) {/* jshint noempty: false */}\n\n  if (i == (zeros = numStr.length)) {\n    // The digits are all zero.\n    digits = [0];\n    numberOfIntegerDigits = 1;\n  } else {\n    // Count the number of trailing zeros\n    zeros--;\n    while (numStr.charAt(zeros) == ZERO_CHAR) zeros--;\n\n    // Trailing zeros are insignificant so ignore them\n    numberOfIntegerDigits -= i;\n    digits = [];\n    // Convert string to array of digits without leading/trailing zeros.\n    for (j = 0; i <= zeros; i++, j++) {\n      digits[j] = +numStr.charAt(i);\n    }\n  }\n\n  // If the number overflows the maximum allowed digits then use an exponent.\n  if (numberOfIntegerDigits > MAX_DIGITS) {\n    digits = digits.splice(0, MAX_DIGITS - 1);\n    exponent = numberOfIntegerDigits - 1;\n    numberOfIntegerDigits = 1;\n  }\n\n  return { d: digits, e: exponent, i: numberOfIntegerDigits };\n}\n\n/**\n * Round the parsed number to the specified number of decimal places\n * This function changed the parsedNumber in-place\n */\nfunction roundNumber(parsedNumber, fractionSize, minFrac, maxFrac) {\n    var digits = parsedNumber.d;\n    var fractionLen = digits.length - parsedNumber.i;\n\n    // determine fractionSize if it is not specified; `+fractionSize` converts it to a number\n    fractionSize = (isUndefined(fractionSize)) ? Math.min(Math.max(minFrac, fractionLen), maxFrac) : +fractionSize;\n\n    // The index of the digit to where rounding is to occur\n    var roundAt = fractionSize + parsedNumber.i;\n    var digit = digits[roundAt];\n\n    if (roundAt > 0) {\n      // Drop fractional digits beyond `roundAt`\n      digits.splice(Math.max(parsedNumber.i, roundAt));\n\n      // Set non-fractional digits beyond `roundAt` to 0\n      for (var j = roundAt; j < digits.length; j++) {\n        digits[j] = 0;\n      }\n    } else {\n      // We rounded to zero so reset the parsedNumber\n      fractionLen = Math.max(0, fractionLen);\n      parsedNumber.i = 1;\n      digits.length = Math.max(1, roundAt = fractionSize + 1);\n      digits[0] = 0;\n      for (var i = 1; i < roundAt; i++) digits[i] = 0;\n    }\n\n    if (digit >= 5) {\n      if (roundAt - 1 < 0) {\n        for (var k = 0; k > roundAt; k--) {\n          digits.unshift(0);\n          parsedNumber.i++;\n        }\n        digits.unshift(1);\n        parsedNumber.i++;\n      } else {\n        digits[roundAt - 1]++;\n      }\n    }\n\n    // Pad out with zeros to get the required fraction length\n    for (; fractionLen < Math.max(0, fractionSize); fractionLen++) digits.push(0);\n\n\n    // Do any carrying, e.g. a digit was rounded up to 10\n    var carry = digits.reduceRight(function(carry, d, i, digits) {\n      d = d + carry;\n      digits[i] = d % 10;\n      return Math.floor(d / 10);\n    }, 0);\n    if (carry) {\n      digits.unshift(carry);\n      parsedNumber.i++;\n    }\n}\n\n/**\n * Format a number into a string\n * @param  {number} number       The number to format\n * @param  {{\n *           minFrac, // the minimum number of digits required in the fraction part of the number\n *           maxFrac, // the maximum number of digits required in the fraction part of the number\n *           gSize,   // number of digits in each group of separated digits\n *           lgSize,  // number of digits in the last group of digits before the decimal separator\n *           negPre,  // the string to go in front of a negative number (e.g. `-` or `(`))\n *           posPre,  // the string to go in front of a positive number\n *           negSuf,  // the string to go after a negative number (e.g. `)`)\n *           posSuf   // the string to go after a positive number\n *         }} pattern\n * @param  {string} groupSep     The string to separate groups of number (e.g. `,`)\n * @param  {string} decimalSep   The string to act as the decimal separator (e.g. `.`)\n * @param  {[type]} fractionSize The size of the fractional part of the number\n * @return {string}              The number formatted as a string\n */\nfunction formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {\n\n  if (!(isString(number) || isNumber(number)) || isNaN(number)) return '';\n\n  var isInfinity = !isFinite(number);\n  var isZero = false;\n  var numStr = Math.abs(number) + '',\n      formattedText = '',\n      parsedNumber;\n\n  if (isInfinity) {\n    formattedText = '\\u221e';\n  } else {\n    parsedNumber = parse(numStr);\n\n    roundNumber(parsedNumber, fractionSize, pattern.minFrac, pattern.maxFrac);\n\n    var digits = parsedNumber.d;\n    var integerLen = parsedNumber.i;\n    var exponent = parsedNumber.e;\n    var decimals = [];\n    isZero = digits.reduce(function(isZero, d) { return isZero && !d; }, true);\n\n    // pad zeros for small numbers\n    while (integerLen < 0) {\n      digits.unshift(0);\n      integerLen++;\n    }\n\n    // extract decimals digits\n    if (integerLen > 0) {\n      decimals = digits.splice(integerLen);\n    } else {\n      decimals = digits;\n      digits = [0];\n    }\n\n    // format the integer digits with grouping separators\n    var groups = [];\n    if (digits.length >= pattern.lgSize) {\n      groups.unshift(digits.splice(-pattern.lgSize).join(''));\n    }\n    while (digits.length > pattern.gSize) {\n      groups.unshift(digits.splice(-pattern.gSize).join(''));\n    }\n    if (digits.length) {\n      groups.unshift(digits.join(''));\n    }\n    formattedText = groups.join(groupSep);\n\n    // append the decimal digits\n    if (decimals.length) {\n      formattedText += decimalSep + decimals.join('');\n    }\n\n    if (exponent) {\n      formattedText += 'e+' + exponent;\n    }\n  }\n  if (number < 0 && !isZero) {\n    return pattern.negPre + formattedText + pattern.negSuf;\n  } else {\n    return pattern.posPre + formattedText + pattern.posSuf;\n  }\n}\n\nfunction padNumber(num, digits, trim, negWrap) {\n  var neg = '';\n  if (num < 0 || (negWrap && num <= 0)) {\n    if (negWrap) {\n      num = -num + 1;\n    } else {\n      num = -num;\n      neg = '-';\n    }\n  }\n  num = '' + num;\n  while (num.length < digits) num = ZERO_CHAR + num;\n  if (trim) {\n    num = num.substr(num.length - digits);\n  }\n  return neg + num;\n}\n\n\nfunction dateGetter(name, size, offset, trim, negWrap) {\n  offset = offset || 0;\n  return function(date) {\n    var value = date['get' + name]();\n    if (offset > 0 || value > -offset) {\n      value += offset;\n    }\n    if (value === 0 && offset == -12) value = 12;\n    return padNumber(value, size, trim, negWrap);\n  };\n}\n\nfunction dateStrGetter(name, shortForm, standAlone) {\n  return function(date, formats) {\n    var value = date['get' + name]();\n    var propPrefix = (standAlone ? 'STANDALONE' : '') + (shortForm ? 'SHORT' : '');\n    var get = uppercase(propPrefix + name);\n\n    return formats[get][value];\n  };\n}\n\nfunction timeZoneGetter(date, formats, offset) {\n  var zone = -1 * offset;\n  var paddedZone = (zone >= 0) ? \"+\" : \"\";\n\n  paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) +\n                padNumber(Math.abs(zone % 60), 2);\n\n  return paddedZone;\n}\n\nfunction getFirstThursdayOfYear(year) {\n    // 0 = index of January\n    var dayOfWeekOnFirst = (new Date(year, 0, 1)).getDay();\n    // 4 = index of Thursday (+1 to account for 1st = 5)\n    // 11 = index of *next* Thursday (+1 account for 1st = 12)\n    return new Date(year, 0, ((dayOfWeekOnFirst <= 4) ? 5 : 12) - dayOfWeekOnFirst);\n}\n\nfunction getThursdayThisWeek(datetime) {\n    return new Date(datetime.getFullYear(), datetime.getMonth(),\n      // 4 = index of Thursday\n      datetime.getDate() + (4 - datetime.getDay()));\n}\n\nfunction weekGetter(size) {\n   return function(date) {\n      var firstThurs = getFirstThursdayOfYear(date.getFullYear()),\n         thisThurs = getThursdayThisWeek(date);\n\n      var diff = +thisThurs - +firstThurs,\n         result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week\n\n      return padNumber(result, size);\n   };\n}\n\nfunction ampmGetter(date, formats) {\n  return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1];\n}\n\nfunction eraGetter(date, formats) {\n  return date.getFullYear() <= 0 ? formats.ERAS[0] : formats.ERAS[1];\n}\n\nfunction longEraGetter(date, formats) {\n  return date.getFullYear() <= 0 ? formats.ERANAMES[0] : formats.ERANAMES[1];\n}\n\nvar DATE_FORMATS = {\n  yyyy: dateGetter('FullYear', 4, 0, false, true),\n    yy: dateGetter('FullYear', 2, 0, true, true),\n     y: dateGetter('FullYear', 1, 0, false, true),\n  MMMM: dateStrGetter('Month'),\n   MMM: dateStrGetter('Month', true),\n    MM: dateGetter('Month', 2, 1),\n     M: dateGetter('Month', 1, 1),\n  LLLL: dateStrGetter('Month', false, true),\n    dd: dateGetter('Date', 2),\n     d: dateGetter('Date', 1),\n    HH: dateGetter('Hours', 2),\n     H: dateGetter('Hours', 1),\n    hh: dateGetter('Hours', 2, -12),\n     h: dateGetter('Hours', 1, -12),\n    mm: dateGetter('Minutes', 2),\n     m: dateGetter('Minutes', 1),\n    ss: dateGetter('Seconds', 2),\n     s: dateGetter('Seconds', 1),\n     // while ISO 8601 requires fractions to be prefixed with `.` or `,`\n     // we can be just safely rely on using `sss` since we currently don't support single or two digit fractions\n   sss: dateGetter('Milliseconds', 3),\n  EEEE: dateStrGetter('Day'),\n   EEE: dateStrGetter('Day', true),\n     a: ampmGetter,\n     Z: timeZoneGetter,\n    ww: weekGetter(2),\n     w: weekGetter(1),\n     G: eraGetter,\n     GG: eraGetter,\n     GGG: eraGetter,\n     GGGG: longEraGetter\n};\n\nvar DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsaZEwG']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|m+|s+|a|Z|G+|w+))(.*)/,\n    NUMBER_STRING = /^\\-?\\d+$/;\n\n/**\n * @ngdoc filter\n * @name date\n * @kind function\n *\n * @description\n *   Formats `date` to a string based on the requested `format`.\n *\n *   `format` string can be composed of the following elements:\n *\n *   * `'yyyy'`: 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)\n *   * `'yy'`: 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)\n *   * `'y'`: 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)\n *   * `'MMMM'`: Month in year (January-December)\n *   * `'MMM'`: Month in year (Jan-Dec)\n *   * `'MM'`: Month in year, padded (01-12)\n *   * `'M'`: Month in year (1-12)\n *   * `'LLLL'`: Stand-alone month in year (January-December)\n *   * `'dd'`: Day in month, padded (01-31)\n *   * `'d'`: Day in month (1-31)\n *   * `'EEEE'`: Day in Week,(Sunday-Saturday)\n *   * `'EEE'`: Day in Week, (Sun-Sat)\n *   * `'HH'`: Hour in day, padded (00-23)\n *   * `'H'`: Hour in day (0-23)\n *   * `'hh'`: Hour in AM/PM, padded (01-12)\n *   * `'h'`: Hour in AM/PM, (1-12)\n *   * `'mm'`: Minute in hour, padded (00-59)\n *   * `'m'`: Minute in hour (0-59)\n *   * `'ss'`: Second in minute, padded (00-59)\n *   * `'s'`: Second in minute (0-59)\n *   * `'sss'`: Millisecond in second, padded (000-999)\n *   * `'a'`: AM/PM marker\n *   * `'Z'`: 4 digit (+sign) representation of the timezone offset (-1200-+1200)\n *   * `'ww'`: Week of year, padded (00-53). Week 01 is the week with the first Thursday of the year\n *   * `'w'`: Week of year (0-53). Week 1 is the week with the first Thursday of the year\n *   * `'G'`, `'GG'`, `'GGG'`: The abbreviated form of the era string (e.g. 'AD')\n *   * `'GGGG'`: The long form of the era string (e.g. 'Anno Domini')\n *\n *   `format` string can also be one of the following predefined\n *   {@link guide/i18n localizable formats}:\n *\n *   * `'medium'`: equivalent to `'MMM d, y h:mm:ss a'` for en_US locale\n *     (e.g. Sep 3, 2010 12:05:08 PM)\n *   * `'short'`: equivalent to `'M/d/yy h:mm a'` for en_US  locale (e.g. 9/3/10 12:05 PM)\n *   * `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` for en_US  locale\n *     (e.g. Friday, September 3, 2010)\n *   * `'longDate'`: equivalent to `'MMMM d, y'` for en_US  locale (e.g. September 3, 2010)\n *   * `'mediumDate'`: equivalent to `'MMM d, y'` for en_US  locale (e.g. Sep 3, 2010)\n *   * `'shortDate'`: equivalent to `'M/d/yy'` for en_US locale (e.g. 9/3/10)\n *   * `'mediumTime'`: equivalent to `'h:mm:ss a'` for en_US locale (e.g. 12:05:08 PM)\n *   * `'shortTime'`: equivalent to `'h:mm a'` for en_US locale (e.g. 12:05 PM)\n *\n *   `format` string can contain literal values. These need to be escaped by surrounding with single quotes (e.g.\n *   `\"h 'in the morning'\"`). In order to output a single quote, escape it - i.e., two single quotes in a sequence\n *   (e.g. `\"h 'o''clock'\"`).\n *\n * @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or\n *    number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its\n *    shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is\n *    specified in the string input, the time is considered to be in the local timezone.\n * @param {string=} format Formatting rules (see Description). If not specified,\n *    `mediumDate` is used.\n * @param {string=} timezone Timezone to be used for formatting. It understands UTC/GMT and the\n *    continental US time zone abbreviations, but for general use, use a time zone offset, for\n *    example, `'+0430'` (4 hours, 30 minutes east of the Greenwich meridian)\n *    If not specified, the timezone of the browser will be used.\n * @returns {string} Formatted string or the input if input is not recognized as date/millis.\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n       <span ng-non-bindable>{{1288323623006 | date:'medium'}}</span>:\n           <span>{{1288323623006 | date:'medium'}}</span><br>\n       <span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span>:\n          <span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br>\n       <span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:\n          <span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br>\n       <span ng-non-bindable>{{1288323623006 | date:\"MM/dd/yyyy 'at' h:mma\"}}</span>:\n          <span>{{'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"}}</span><br>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should format date', function() {\n         expect(element(by.binding(\"1288323623006 | date:'medium'\")).getText()).\n            toMatch(/Oct 2\\d, 2010 \\d{1,2}:\\d{2}:\\d{2} (AM|PM)/);\n         expect(element(by.binding(\"1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'\")).getText()).\n            toMatch(/2010\\-10\\-2\\d \\d{2}:\\d{2}:\\d{2} (\\-|\\+)?\\d{4}/);\n         expect(element(by.binding(\"'1288323623006' | date:'MM/dd/yyyy @ h:mma'\")).getText()).\n            toMatch(/10\\/2\\d\\/2010 @ \\d{1,2}:\\d{2}(AM|PM)/);\n         expect(element(by.binding(\"'1288323623006' | date:\\\"MM/dd/yyyy 'at' h:mma\\\"\")).getText()).\n            toMatch(/10\\/2\\d\\/2010 at \\d{1,2}:\\d{2}(AM|PM)/);\n       });\n     </file>\n   </example>\n */\ndateFilter.$inject = ['$locale'];\nfunction dateFilter($locale) {\n\n\n  var R_ISO8601_STR = /^(\\d{4})-?(\\d\\d)-?(\\d\\d)(?:T(\\d\\d)(?::?(\\d\\d)(?::?(\\d\\d)(?:\\.(\\d+))?)?)?(Z|([+-])(\\d\\d):?(\\d\\d))?)?$/;\n                     // 1        2       3         4          5          6          7          8  9     10      11\n  function jsonStringToDate(string) {\n    var match;\n    if (match = string.match(R_ISO8601_STR)) {\n      var date = new Date(0),\n          tzHour = 0,\n          tzMin  = 0,\n          dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,\n          timeSetter = match[8] ? date.setUTCHours : date.setHours;\n\n      if (match[9]) {\n        tzHour = toInt(match[9] + match[10]);\n        tzMin = toInt(match[9] + match[11]);\n      }\n      dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));\n      var h = toInt(match[4] || 0) - tzHour;\n      var m = toInt(match[5] || 0) - tzMin;\n      var s = toInt(match[6] || 0);\n      var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);\n      timeSetter.call(date, h, m, s, ms);\n      return date;\n    }\n    return string;\n  }\n\n\n  return function(date, format, timezone) {\n    var text = '',\n        parts = [],\n        fn, match;\n\n    format = format || 'mediumDate';\n    format = $locale.DATETIME_FORMATS[format] || format;\n    if (isString(date)) {\n      date = NUMBER_STRING.test(date) ? toInt(date) : jsonStringToDate(date);\n    }\n\n    if (isNumber(date)) {\n      date = new Date(date);\n    }\n\n    if (!isDate(date) || !isFinite(date.getTime())) {\n      return date;\n    }\n\n    while (format) {\n      match = DATE_FORMATS_SPLIT.exec(format);\n      if (match) {\n        parts = concat(parts, match, 1);\n        format = parts.pop();\n      } else {\n        parts.push(format);\n        format = null;\n      }\n    }\n\n    var dateTimezoneOffset = date.getTimezoneOffset();\n    if (timezone) {\n      dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n      date = convertTimezoneToLocal(date, timezone, true);\n    }\n    forEach(parts, function(value) {\n      fn = DATE_FORMATS[value];\n      text += fn ? fn(date, $locale.DATETIME_FORMATS, dateTimezoneOffset)\n                 : value === \"''\" ? \"'\" : value.replace(/(^'|'$)/g, '').replace(/''/g, \"'\");\n    });\n\n    return text;\n  };\n}\n\n\n/**\n * @ngdoc filter\n * @name json\n * @kind function\n *\n * @description\n *   Allows you to convert a JavaScript object into JSON string.\n *\n *   This filter is mostly useful for debugging. When using the double curly {{value}} notation\n *   the binding is automatically converted to JSON.\n *\n * @param {*} object Any JavaScript object (including arrays and primitive types) to filter.\n * @param {number=} spacing The number of spaces to use per indentation, defaults to 2.\n * @returns {string} JSON string.\n *\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n       <pre id=\"default-spacing\">{{ {'name':'value'} | json }}</pre>\n       <pre id=\"custom-spacing\">{{ {'name':'value'} | json:4 }}</pre>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should jsonify filtered objects', function() {\n         expect(element(by.id('default-spacing')).getText()).toMatch(/\\{\\n  \"name\": ?\"value\"\\n}/);\n         expect(element(by.id('custom-spacing')).getText()).toMatch(/\\{\\n    \"name\": ?\"value\"\\n}/);\n       });\n     </file>\n   </example>\n *\n */\nfunction jsonFilter() {\n  return function(object, spacing) {\n    if (isUndefined(spacing)) {\n        spacing = 2;\n    }\n    return toJson(object, spacing);\n  };\n}\n\n\n/**\n * @ngdoc filter\n * @name lowercase\n * @kind function\n * @description\n * Converts string to lowercase.\n * @see angular.lowercase\n */\nvar lowercaseFilter = valueFn(lowercase);\n\n\n/**\n * @ngdoc filter\n * @name uppercase\n * @kind function\n * @description\n * Converts string to uppercase.\n * @see angular.uppercase\n */\nvar uppercaseFilter = valueFn(uppercase);\n\n/**\n * @ngdoc filter\n * @name limitTo\n * @kind function\n *\n * @description\n * Creates a new array or string containing only a specified number of elements. The elements\n * are taken from either the beginning or the end of the source array, string or number, as specified by\n * the value and sign (positive or negative) of `limit`. If a number is used as input, it is\n * converted to a string.\n *\n * @param {Array|string|number} input Source array, string or number to be limited.\n * @param {string|number} limit The length of the returned array or string. If the `limit` number\n *     is positive, `limit` number of items from the beginning of the source array/string are copied.\n *     If the number is negative, `limit` number  of items from the end of the source array/string\n *     are copied. The `limit` will be trimmed if it exceeds `array.length`. If `limit` is undefined,\n *     the input will be returned unchanged.\n * @param {(string|number)=} begin Index at which to begin limitation. As a negative index, `begin`\n *     indicates an offset from the end of `input`. Defaults to `0`.\n * @returns {Array|string} A new sub-array or substring of length `limit` or less if input array\n *     had less than `limit` elements.\n *\n * @example\n   <example module=\"limitToExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('limitToExample', [])\n           .controller('ExampleController', ['$scope', function($scope) {\n             $scope.numbers = [1,2,3,4,5,6,7,8,9];\n             $scope.letters = \"abcdefghi\";\n             $scope.longNumber = 2345432342;\n             $scope.numLimit = 3;\n             $scope.letterLimit = 3;\n             $scope.longNumberLimit = 3;\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <label>\n            Limit {{numbers}} to:\n            <input type=\"number\" step=\"1\" ng-model=\"numLimit\">\n         </label>\n         <p>Output numbers: {{ numbers | limitTo:numLimit }}</p>\n         <label>\n            Limit {{letters}} to:\n            <input type=\"number\" step=\"1\" ng-model=\"letterLimit\">\n         </label>\n         <p>Output letters: {{ letters | limitTo:letterLimit }}</p>\n         <label>\n            Limit {{longNumber}} to:\n            <input type=\"number\" step=\"1\" ng-model=\"longNumberLimit\">\n         </label>\n         <p>Output long number: {{ longNumber | limitTo:longNumberLimit }}</p>\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       var numLimitInput = element(by.model('numLimit'));\n       var letterLimitInput = element(by.model('letterLimit'));\n       var longNumberLimitInput = element(by.model('longNumberLimit'));\n       var limitedNumbers = element(by.binding('numbers | limitTo:numLimit'));\n       var limitedLetters = element(by.binding('letters | limitTo:letterLimit'));\n       var limitedLongNumber = element(by.binding('longNumber | limitTo:longNumberLimit'));\n\n       it('should limit the number array to first three items', function() {\n         expect(numLimitInput.getAttribute('value')).toBe('3');\n         expect(letterLimitInput.getAttribute('value')).toBe('3');\n         expect(longNumberLimitInput.getAttribute('value')).toBe('3');\n         expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3]');\n         expect(limitedLetters.getText()).toEqual('Output letters: abc');\n         expect(limitedLongNumber.getText()).toEqual('Output long number: 234');\n       });\n\n       // There is a bug in safari and protractor that doesn't like the minus key\n       // it('should update the output when -3 is entered', function() {\n       //   numLimitInput.clear();\n       //   numLimitInput.sendKeys('-3');\n       //   letterLimitInput.clear();\n       //   letterLimitInput.sendKeys('-3');\n       //   longNumberLimitInput.clear();\n       //   longNumberLimitInput.sendKeys('-3');\n       //   expect(limitedNumbers.getText()).toEqual('Output numbers: [7,8,9]');\n       //   expect(limitedLetters.getText()).toEqual('Output letters: ghi');\n       //   expect(limitedLongNumber.getText()).toEqual('Output long number: 342');\n       // });\n\n       it('should not exceed the maximum size of input array', function() {\n         numLimitInput.clear();\n         numLimitInput.sendKeys('100');\n         letterLimitInput.clear();\n         letterLimitInput.sendKeys('100');\n         longNumberLimitInput.clear();\n         longNumberLimitInput.sendKeys('100');\n         expect(limitedNumbers.getText()).toEqual('Output numbers: [1,2,3,4,5,6,7,8,9]');\n         expect(limitedLetters.getText()).toEqual('Output letters: abcdefghi');\n         expect(limitedLongNumber.getText()).toEqual('Output long number: 2345432342');\n       });\n     </file>\n   </example>\n*/\nfunction limitToFilter() {\n  return function(input, limit, begin) {\n    if (Math.abs(Number(limit)) === Infinity) {\n      limit = Number(limit);\n    } else {\n      limit = toInt(limit);\n    }\n    if (isNaN(limit)) return input;\n\n    if (isNumber(input)) input = input.toString();\n    if (!isArray(input) && !isString(input)) return input;\n\n    begin = (!begin || isNaN(begin)) ? 0 : toInt(begin);\n    begin = (begin < 0) ? Math.max(0, input.length + begin) : begin;\n\n    if (limit >= 0) {\n      return input.slice(begin, begin + limit);\n    } else {\n      if (begin === 0) {\n        return input.slice(limit, input.length);\n      } else {\n        return input.slice(Math.max(0, begin + limit), begin);\n      }\n    }\n  };\n}\n\n/**\n * @ngdoc filter\n * @name orderBy\n * @kind function\n *\n * @description\n * Orders a specified `array` by the `expression` predicate. It is ordered alphabetically\n * for strings and numerically for numbers. Note: if you notice numbers are not being sorted\n * as expected, make sure they are actually being saved as numbers and not strings.\n * Array-like values (e.g. NodeLists, jQuery objects, TypedArrays, Strings, etc) are also supported.\n *\n * @param {Array} array The array (or array-like object) to sort.\n * @param {function(*)|string|Array.<(function(*)|string)>=} expression A predicate to be\n *    used by the comparator to determine the order of elements.\n *\n *    Can be one of:\n *\n *    - `function`: Getter function. The result of this function will be sorted using the\n *      `<`, `===`, `>` operator.\n *    - `string`: An Angular expression. The result of this expression is used to compare elements\n *      (for example `name` to sort by a property called `name` or `name.substr(0, 3)` to sort by\n *      3 first characters of a property called `name`). The result of a constant expression\n *      is interpreted as a property name to be used in comparisons (for example `\"special name\"`\n *      to sort object by the value of their `special name` property). An expression can be\n *      optionally prefixed with `+` or `-` to control ascending or descending sort order\n *      (for example, `+name` or `-name`). If no property is provided, (e.g. `'+'`) then the array\n *      element itself is used to compare where sorting.\n *    - `Array`: An array of function or string predicates. The first predicate in the array\n *      is used for sorting, but when two items are equivalent, the next predicate is used.\n *\n *    If the predicate is missing or empty then it defaults to `'+'`.\n *\n * @param {boolean=} reverse Reverse the order of the array.\n * @returns {Array} Sorted copy of the source array.\n *\n *\n * @example\n * The example below demonstrates a simple ngRepeat, where the data is sorted\n * by age in descending order (predicate is set to `'-age'`).\n * `reverse` is not set, which means it defaults to `false`.\n   <example module=\"orderByExample\">\n     <file name=\"index.html\">\n       <div ng-controller=\"ExampleController\">\n         <table class=\"friend\">\n           <tr>\n             <th>Name</th>\n             <th>Phone Number</th>\n             <th>Age</th>\n           </tr>\n           <tr ng-repeat=\"friend in friends | orderBy:'-age'\">\n             <td>{{friend.name}}</td>\n             <td>{{friend.phone}}</td>\n             <td>{{friend.age}}</td>\n           </tr>\n         </table>\n       </div>\n     </file>\n     <file name=\"script.js\">\n       angular.module('orderByExample', [])\n         .controller('ExampleController', ['$scope', function($scope) {\n           $scope.friends =\n               [{name:'John', phone:'555-1212', age:10},\n                {name:'Mary', phone:'555-9876', age:19},\n                {name:'Mike', phone:'555-4321', age:21},\n                {name:'Adam', phone:'555-5678', age:35},\n                {name:'Julie', phone:'555-8765', age:29}];\n         }]);\n     </file>\n   </example>\n *\n * The predicate and reverse parameters can be controlled dynamically through scope properties,\n * as shown in the next example.\n * @example\n   <example module=\"orderByExample\">\n     <file name=\"index.html\">\n       <div ng-controller=\"ExampleController\">\n         <pre>Sorting predicate = {{predicate}}; reverse = {{reverse}}</pre>\n         <hr/>\n         <button ng-click=\"predicate=''\">Set to unsorted</button>\n         <table class=\"friend\">\n           <tr>\n            <th>\n                <button ng-click=\"order('name')\">Name</button>\n                <span class=\"sortorder\" ng-show=\"predicate === 'name'\" ng-class=\"{reverse:reverse}\"></span>\n            </th>\n            <th>\n                <button ng-click=\"order('phone')\">Phone Number</button>\n                <span class=\"sortorder\" ng-show=\"predicate === 'phone'\" ng-class=\"{reverse:reverse}\"></span>\n            </th>\n            <th>\n                <button ng-click=\"order('age')\">Age</button>\n                <span class=\"sortorder\" ng-show=\"predicate === 'age'\" ng-class=\"{reverse:reverse}\"></span>\n            </th>\n           </tr>\n           <tr ng-repeat=\"friend in friends | orderBy:predicate:reverse\">\n             <td>{{friend.name}}</td>\n             <td>{{friend.phone}}</td>\n             <td>{{friend.age}}</td>\n           </tr>\n         </table>\n       </div>\n     </file>\n     <file name=\"script.js\">\n       angular.module('orderByExample', [])\n         .controller('ExampleController', ['$scope', function($scope) {\n           $scope.friends =\n               [{name:'John', phone:'555-1212', age:10},\n                {name:'Mary', phone:'555-9876', age:19},\n                {name:'Mike', phone:'555-4321', age:21},\n                {name:'Adam', phone:'555-5678', age:35},\n                {name:'Julie', phone:'555-8765', age:29}];\n           $scope.predicate = 'age';\n           $scope.reverse = true;\n           $scope.order = function(predicate) {\n             $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;\n             $scope.predicate = predicate;\n           };\n         }]);\n      </file>\n     <file name=\"style.css\">\n       .sortorder:after {\n         content: '\\25b2';\n       }\n       .sortorder.reverse:after {\n         content: '\\25bc';\n       }\n     </file>\n   </example>\n *\n * It's also possible to call the orderBy filter manually, by injecting `$filter`, retrieving the\n * filter routine with `$filter('orderBy')`, and calling the returned filter routine with the\n * desired parameters.\n *\n * Example:\n *\n * @example\n  <example module=\"orderByExample\">\n    <file name=\"index.html\">\n    <div ng-controller=\"ExampleController\">\n      <pre>Sorting predicate = {{predicate}}; reverse = {{reverse}}</pre>\n      <table class=\"friend\">\n        <tr>\n          <th>\n              <button ng-click=\"order('name')\">Name</button>\n              <span class=\"sortorder\" ng-show=\"predicate === 'name'\" ng-class=\"{reverse:reverse}\"></span>\n          </th>\n          <th>\n              <button ng-click=\"order('phone')\">Phone Number</button>\n              <span class=\"sortorder\" ng-show=\"predicate === 'phone'\" ng-class=\"{reverse:reverse}\"></span>\n          </th>\n          <th>\n              <button ng-click=\"order('age')\">Age</button>\n              <span class=\"sortorder\" ng-show=\"predicate === 'age'\" ng-class=\"{reverse:reverse}\"></span>\n          </th>\n        </tr>\n        <tr ng-repeat=\"friend in friends\">\n          <td>{{friend.name}}</td>\n          <td>{{friend.phone}}</td>\n          <td>{{friend.age}}</td>\n        </tr>\n      </table>\n    </div>\n    </file>\n\n    <file name=\"script.js\">\n      angular.module('orderByExample', [])\n        .controller('ExampleController', ['$scope', '$filter', function($scope, $filter) {\n          var orderBy = $filter('orderBy');\n          $scope.friends = [\n            { name: 'John',    phone: '555-1212',    age: 10 },\n            { name: 'Mary',    phone: '555-9876',    age: 19 },\n            { name: 'Mike',    phone: '555-4321',    age: 21 },\n            { name: 'Adam',    phone: '555-5678',    age: 35 },\n            { name: 'Julie',   phone: '555-8765',    age: 29 }\n          ];\n          $scope.order = function(predicate) {\n            $scope.predicate = predicate;\n            $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;\n            $scope.friends = orderBy($scope.friends, predicate, $scope.reverse);\n          };\n          $scope.order('age', true);\n        }]);\n    </file>\n\n    <file name=\"style.css\">\n       .sortorder:after {\n         content: '\\25b2';\n       }\n       .sortorder.reverse:after {\n         content: '\\25bc';\n       }\n    </file>\n</example>\n */\norderByFilter.$inject = ['$parse'];\nfunction orderByFilter($parse) {\n  return function(array, sortPredicate, reverseOrder) {\n\n    if (array == null) return array;\n    if (!isArrayLike(array)) {\n      throw minErr('orderBy')('notarray', 'Expected array but received: {0}', array);\n    }\n\n    if (!isArray(sortPredicate)) { sortPredicate = [sortPredicate]; }\n    if (sortPredicate.length === 0) { sortPredicate = ['+']; }\n\n    var predicates = processPredicates(sortPredicate, reverseOrder);\n    // Add a predicate at the end that evaluates to the element index. This makes the\n    // sort stable as it works as a tie-breaker when all the input predicates cannot\n    // distinguish between two elements.\n    predicates.push({ get: function() { return {}; }, descending: reverseOrder ? -1 : 1});\n\n    // The next three lines are a version of a Swartzian Transform idiom from Perl\n    // (sometimes called the Decorate-Sort-Undecorate idiom)\n    // See https://en.wikipedia.org/wiki/Schwartzian_transform\n    var compareValues = Array.prototype.map.call(array, getComparisonObject);\n    compareValues.sort(doComparison);\n    array = compareValues.map(function(item) { return item.value; });\n\n    return array;\n\n    function getComparisonObject(value, index) {\n      return {\n        value: value,\n        predicateValues: predicates.map(function(predicate) {\n          return getPredicateValue(predicate.get(value), index);\n        })\n      };\n    }\n\n    function doComparison(v1, v2) {\n      var result = 0;\n      for (var index=0, length = predicates.length; index < length; ++index) {\n        result = compare(v1.predicateValues[index], v2.predicateValues[index]) * predicates[index].descending;\n        if (result) break;\n      }\n      return result;\n    }\n  };\n\n  function processPredicates(sortPredicate, reverseOrder) {\n    reverseOrder = reverseOrder ? -1 : 1;\n    return sortPredicate.map(function(predicate) {\n      var descending = 1, get = identity;\n\n      if (isFunction(predicate)) {\n        get = predicate;\n      } else if (isString(predicate)) {\n        if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {\n          descending = predicate.charAt(0) == '-' ? -1 : 1;\n          predicate = predicate.substring(1);\n        }\n        if (predicate !== '') {\n          get = $parse(predicate);\n          if (get.constant) {\n            var key = get();\n            get = function(value) { return value[key]; };\n          }\n        }\n      }\n      return { get: get, descending: descending * reverseOrder };\n    });\n  }\n\n  function isPrimitive(value) {\n    switch (typeof value) {\n      case 'number': /* falls through */\n      case 'boolean': /* falls through */\n      case 'string':\n        return true;\n      default:\n        return false;\n    }\n  }\n\n  function objectValue(value, index) {\n    // If `valueOf` is a valid function use that\n    if (typeof value.valueOf === 'function') {\n      value = value.valueOf();\n      if (isPrimitive(value)) return value;\n    }\n    // If `toString` is a valid function and not the one from `Object.prototype` use that\n    if (hasCustomToString(value)) {\n      value = value.toString();\n      if (isPrimitive(value)) return value;\n    }\n    // We have a basic object so we use the position of the object in the collection\n    return index;\n  }\n\n  function getPredicateValue(value, index) {\n    var type = typeof value;\n    if (value === null) {\n      type = 'string';\n      value = 'null';\n    } else if (type === 'string') {\n      value = value.toLowerCase();\n    } else if (type === 'object') {\n      value = objectValue(value, index);\n    }\n    return { value: value, type: type };\n  }\n\n  function compare(v1, v2) {\n    var result = 0;\n    if (v1.type === v2.type) {\n      if (v1.value !== v2.value) {\n        result = v1.value < v2.value ? -1 : 1;\n      }\n    } else {\n      result = v1.type < v2.type ? -1 : 1;\n    }\n    return result;\n  }\n}\n\nfunction ngDirective(directive) {\n  if (isFunction(directive)) {\n    directive = {\n      link: directive\n    };\n  }\n  directive.restrict = directive.restrict || 'AC';\n  return valueFn(directive);\n}\n\n/**\n * @ngdoc directive\n * @name a\n * @restrict E\n *\n * @description\n * Modifies the default behavior of the html A tag so that the default action is prevented when\n * the href attribute is empty.\n *\n * This change permits the easy creation of action links with the `ngClick` directive\n * without changing the location or causing page reloads, e.g.:\n * `<a href=\"\" ng-click=\"list.addItem()\">Add Item</a>`\n */\nvar htmlAnchorDirective = valueFn({\n  restrict: 'E',\n  compile: function(element, attr) {\n    if (!attr.href && !attr.xlinkHref) {\n      return function(scope, element) {\n        // If the linked element is not an anchor tag anymore, do nothing\n        if (element[0].nodeName.toLowerCase() !== 'a') return;\n\n        // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.\n        var href = toString.call(element.prop('href')) === '[object SVGAnimatedString]' ?\n                   'xlink:href' : 'href';\n        element.on('click', function(event) {\n          // if we have no href url, then don't navigate anywhere.\n          if (!element.attr(href)) {\n            event.preventDefault();\n          }\n        });\n      };\n    }\n  }\n});\n\n/**\n * @ngdoc directive\n * @name ngHref\n * @restrict A\n * @priority 99\n *\n * @description\n * Using Angular markup like `{{hash}}` in an href attribute will\n * make the link go to the wrong URL if the user clicks it before\n * Angular has a chance to replace the `{{hash}}` markup with its\n * value. Until Angular replaces the markup the link will be broken\n * and will most likely return a 404 error. The `ngHref` directive\n * solves this problem.\n *\n * The wrong way to write it:\n * ```html\n * <a href=\"http://www.gravatar.com/avatar/{{hash}}\">link1</a>\n * ```\n *\n * The correct way to write it:\n * ```html\n * <a ng-href=\"http://www.gravatar.com/avatar/{{hash}}\">link1</a>\n * ```\n *\n * @element A\n * @param {template} ngHref any string which can contain `{{}}` markup.\n *\n * @example\n * This example shows various combinations of `href`, `ng-href` and `ng-click` attributes\n * in links and their different behaviors:\n    <example>\n      <file name=\"index.html\">\n        <input ng-model=\"value\" /><br />\n        <a id=\"link-1\" href ng-click=\"value = 1\">link 1</a> (link, don't reload)<br />\n        <a id=\"link-2\" href=\"\" ng-click=\"value = 2\">link 2</a> (link, don't reload)<br />\n        <a id=\"link-3\" ng-href=\"/{{'123'}}\">link 3</a> (link, reload!)<br />\n        <a id=\"link-4\" href=\"\" name=\"xx\" ng-click=\"value = 4\">anchor</a> (link, don't reload)<br />\n        <a id=\"link-5\" name=\"xxx\" ng-click=\"value = 5\">anchor</a> (no link)<br />\n        <a id=\"link-6\" ng-href=\"{{value}}\">link</a> (link, change location)\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should execute ng-click but not reload when href without value', function() {\n          element(by.id('link-1')).click();\n          expect(element(by.model('value')).getAttribute('value')).toEqual('1');\n          expect(element(by.id('link-1')).getAttribute('href')).toBe('');\n        });\n\n        it('should execute ng-click but not reload when href empty string', function() {\n          element(by.id('link-2')).click();\n          expect(element(by.model('value')).getAttribute('value')).toEqual('2');\n          expect(element(by.id('link-2')).getAttribute('href')).toBe('');\n        });\n\n        it('should execute ng-click and change url when ng-href specified', function() {\n          expect(element(by.id('link-3')).getAttribute('href')).toMatch(/\\/123$/);\n\n          element(by.id('link-3')).click();\n\n          // At this point, we navigate away from an Angular page, so we need\n          // to use browser.driver to get the base webdriver.\n\n          browser.wait(function() {\n            return browser.driver.getCurrentUrl().then(function(url) {\n              return url.match(/\\/123$/);\n            });\n          }, 5000, 'page should navigate to /123');\n        });\n\n        it('should execute ng-click but not reload when href empty string and name specified', function() {\n          element(by.id('link-4')).click();\n          expect(element(by.model('value')).getAttribute('value')).toEqual('4');\n          expect(element(by.id('link-4')).getAttribute('href')).toBe('');\n        });\n\n        it('should execute ng-click but not reload when no href but name specified', function() {\n          element(by.id('link-5')).click();\n          expect(element(by.model('value')).getAttribute('value')).toEqual('5');\n          expect(element(by.id('link-5')).getAttribute('href')).toBe(null);\n        });\n\n        it('should only change url when only ng-href', function() {\n          element(by.model('value')).clear();\n          element(by.model('value')).sendKeys('6');\n          expect(element(by.id('link-6')).getAttribute('href')).toMatch(/\\/6$/);\n\n          element(by.id('link-6')).click();\n\n          // At this point, we navigate away from an Angular page, so we need\n          // to use browser.driver to get the base webdriver.\n          browser.wait(function() {\n            return browser.driver.getCurrentUrl().then(function(url) {\n              return url.match(/\\/6$/);\n            });\n          }, 5000, 'page should navigate to /6');\n        });\n      </file>\n    </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngSrc\n * @restrict A\n * @priority 99\n *\n * @description\n * Using Angular markup like `{{hash}}` in a `src` attribute doesn't\n * work right: The browser will fetch from the URL with the literal\n * text `{{hash}}` until Angular replaces the expression inside\n * `{{hash}}`. The `ngSrc` directive solves this problem.\n *\n * The buggy way to write it:\n * ```html\n * <img src=\"http://www.gravatar.com/avatar/{{hash}}\" alt=\"Description\"/>\n * ```\n *\n * The correct way to write it:\n * ```html\n * <img ng-src=\"http://www.gravatar.com/avatar/{{hash}}\" alt=\"Description\" />\n * ```\n *\n * @element IMG\n * @param {template} ngSrc any string which can contain `{{}}` markup.\n */\n\n/**\n * @ngdoc directive\n * @name ngSrcset\n * @restrict A\n * @priority 99\n *\n * @description\n * Using Angular markup like `{{hash}}` in a `srcset` attribute doesn't\n * work right: The browser will fetch from the URL with the literal\n * text `{{hash}}` until Angular replaces the expression inside\n * `{{hash}}`. The `ngSrcset` directive solves this problem.\n *\n * The buggy way to write it:\n * ```html\n * <img srcset=\"http://www.gravatar.com/avatar/{{hash}} 2x\" alt=\"Description\"/>\n * ```\n *\n * The correct way to write it:\n * ```html\n * <img ng-srcset=\"http://www.gravatar.com/avatar/{{hash}} 2x\" alt=\"Description\" />\n * ```\n *\n * @element IMG\n * @param {template} ngSrcset any string which can contain `{{}}` markup.\n */\n\n/**\n * @ngdoc directive\n * @name ngDisabled\n * @restrict A\n * @priority 100\n *\n * @description\n *\n * This directive sets the `disabled` attribute on the element if the\n * {@link guide/expression expression} inside `ngDisabled` evaluates to truthy.\n *\n * A special directive is necessary because we cannot use interpolation inside the `disabled`\n * attribute. See the {@link guide/interpolation interpolation guide} for more info.\n *\n * @example\n    <example>\n      <file name=\"index.html\">\n        <label>Click me to toggle: <input type=\"checkbox\" ng-model=\"checked\"></label><br/>\n        <button ng-model=\"button\" ng-disabled=\"checked\">Button</button>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should toggle button', function() {\n          expect(element(by.css('button')).getAttribute('disabled')).toBeFalsy();\n          element(by.model('checked')).click();\n          expect(element(by.css('button')).getAttribute('disabled')).toBeTruthy();\n        });\n      </file>\n    </example>\n *\n * @element INPUT\n * @param {expression} ngDisabled If the {@link guide/expression expression} is truthy,\n *     then the `disabled` attribute will be set on the element\n */\n\n\n/**\n * @ngdoc directive\n * @name ngChecked\n * @restrict A\n * @priority 100\n *\n * @description\n * Sets the `checked` attribute on the element, if the expression inside `ngChecked` is truthy.\n *\n * Note that this directive should not be used together with {@link ngModel `ngModel`},\n * as this can lead to unexpected behavior.\n *\n * A special directive is necessary because we cannot use interpolation inside the `checked`\n * attribute. See the {@link guide/interpolation interpolation guide} for more info.\n *\n * @example\n    <example>\n      <file name=\"index.html\">\n        <label>Check me to check both: <input type=\"checkbox\" ng-model=\"master\"></label><br/>\n        <input id=\"checkSlave\" type=\"checkbox\" ng-checked=\"master\" aria-label=\"Slave input\">\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should check both checkBoxes', function() {\n          expect(element(by.id('checkSlave')).getAttribute('checked')).toBeFalsy();\n          element(by.model('master')).click();\n          expect(element(by.id('checkSlave')).getAttribute('checked')).toBeTruthy();\n        });\n      </file>\n    </example>\n *\n * @element INPUT\n * @param {expression} ngChecked If the {@link guide/expression expression} is truthy,\n *     then the `checked` attribute will be set on the element\n */\n\n\n/**\n * @ngdoc directive\n * @name ngReadonly\n * @restrict A\n * @priority 100\n *\n * @description\n *\n * Sets the `readOnly` attribute on the element, if the expression inside `ngReadonly` is truthy.\n *\n * A special directive is necessary because we cannot use interpolation inside the `readOnly`\n * attribute. See the {@link guide/interpolation interpolation guide} for more info.\n *\n * @example\n    <example>\n      <file name=\"index.html\">\n        <label>Check me to make text readonly: <input type=\"checkbox\" ng-model=\"checked\"></label><br/>\n        <input type=\"text\" ng-readonly=\"checked\" value=\"I'm Angular\" aria-label=\"Readonly field\" />\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should toggle readonly attr', function() {\n          expect(element(by.css('[type=\"text\"]')).getAttribute('readonly')).toBeFalsy();\n          element(by.model('checked')).click();\n          expect(element(by.css('[type=\"text\"]')).getAttribute('readonly')).toBeTruthy();\n        });\n      </file>\n    </example>\n *\n * @element INPUT\n * @param {expression} ngReadonly If the {@link guide/expression expression} is truthy,\n *     then special attribute \"readonly\" will be set on the element\n */\n\n\n/**\n * @ngdoc directive\n * @name ngSelected\n * @restrict A\n * @priority 100\n *\n * @description\n *\n * Sets the `selected` attribute on the element, if the expression inside `ngSelected` is truthy.\n *\n * A special directive is necessary because we cannot use interpolation inside the `selected`\n * attribute. See the {@link guide/interpolation interpolation guide} for more info.\n *\n * @example\n    <example>\n      <file name=\"index.html\">\n        <label>Check me to select: <input type=\"checkbox\" ng-model=\"selected\"></label><br/>\n        <select aria-label=\"ngSelected demo\">\n          <option>Hello!</option>\n          <option id=\"greet\" ng-selected=\"selected\">Greetings!</option>\n        </select>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should select Greetings!', function() {\n          expect(element(by.id('greet')).getAttribute('selected')).toBeFalsy();\n          element(by.model('selected')).click();\n          expect(element(by.id('greet')).getAttribute('selected')).toBeTruthy();\n        });\n      </file>\n    </example>\n *\n * @element OPTION\n * @param {expression} ngSelected If the {@link guide/expression expression} is truthy,\n *     then special attribute \"selected\" will be set on the element\n */\n\n/**\n * @ngdoc directive\n * @name ngOpen\n * @restrict A\n * @priority 100\n *\n * @description\n *\n * Sets the `open` attribute on the element, if the expression inside `ngOpen` is truthy.\n *\n * A special directive is necessary because we cannot use interpolation inside the `open`\n * attribute. See the {@link guide/interpolation interpolation guide} for more info.\n *\n * @example\n     <example>\n       <file name=\"index.html\">\n         <label>Check me check multiple: <input type=\"checkbox\" ng-model=\"open\"></label><br/>\n         <details id=\"details\" ng-open=\"open\">\n            <summary>Show/Hide me</summary>\n         </details>\n       </file>\n       <file name=\"protractor.js\" type=\"protractor\">\n         it('should toggle open', function() {\n           expect(element(by.id('details')).getAttribute('open')).toBeFalsy();\n           element(by.model('open')).click();\n           expect(element(by.id('details')).getAttribute('open')).toBeTruthy();\n         });\n       </file>\n     </example>\n *\n * @element DETAILS\n * @param {expression} ngOpen If the {@link guide/expression expression} is truthy,\n *     then special attribute \"open\" will be set on the element\n */\n\nvar ngAttributeAliasDirectives = {};\n\n// boolean attrs are evaluated\nforEach(BOOLEAN_ATTR, function(propName, attrName) {\n  // binding to multiple is not supported\n  if (propName == \"multiple\") return;\n\n  function defaultLinkFn(scope, element, attr) {\n    scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {\n      attr.$set(attrName, !!value);\n    });\n  }\n\n  var normalized = directiveNormalize('ng-' + attrName);\n  var linkFn = defaultLinkFn;\n\n  if (propName === 'checked') {\n    linkFn = function(scope, element, attr) {\n      // ensuring ngChecked doesn't interfere with ngModel when both are set on the same input\n      if (attr.ngModel !== attr[normalized]) {\n        defaultLinkFn(scope, element, attr);\n      }\n    };\n  }\n\n  ngAttributeAliasDirectives[normalized] = function() {\n    return {\n      restrict: 'A',\n      priority: 100,\n      link: linkFn\n    };\n  };\n});\n\n// aliased input attrs are evaluated\nforEach(ALIASED_ATTR, function(htmlAttr, ngAttr) {\n  ngAttributeAliasDirectives[ngAttr] = function() {\n    return {\n      priority: 100,\n      link: function(scope, element, attr) {\n        //special case ngPattern when a literal regular expression value\n        //is used as the expression (this way we don't have to watch anything).\n        if (ngAttr === \"ngPattern\" && attr.ngPattern.charAt(0) == \"/\") {\n          var match = attr.ngPattern.match(REGEX_STRING_REGEXP);\n          if (match) {\n            attr.$set(\"ngPattern\", new RegExp(match[1], match[2]));\n            return;\n          }\n        }\n\n        scope.$watch(attr[ngAttr], function ngAttrAliasWatchAction(value) {\n          attr.$set(ngAttr, value);\n        });\n      }\n    };\n  };\n});\n\n// ng-src, ng-srcset, ng-href are interpolated\nforEach(['src', 'srcset', 'href'], function(attrName) {\n  var normalized = directiveNormalize('ng-' + attrName);\n  ngAttributeAliasDirectives[normalized] = function() {\n    return {\n      priority: 99, // it needs to run after the attributes are interpolated\n      link: function(scope, element, attr) {\n        var propName = attrName,\n            name = attrName;\n\n        if (attrName === 'href' &&\n            toString.call(element.prop('href')) === '[object SVGAnimatedString]') {\n          name = 'xlinkHref';\n          attr.$attr[name] = 'xlink:href';\n          propName = null;\n        }\n\n        attr.$observe(normalized, function(value) {\n          if (!value) {\n            if (attrName === 'href') {\n              attr.$set(name, null);\n            }\n            return;\n          }\n\n          attr.$set(name, value);\n\n          // on IE, if \"ng:src\" directive declaration is used and \"src\" attribute doesn't exist\n          // then calling element.setAttribute('src', 'foo') doesn't do anything, so we need\n          // to set the property as well to achieve the desired effect.\n          // we use attr[attrName] value since $set can sanitize the url.\n          if (msie && propName) element.prop(propName, attr[name]);\n        });\n      }\n    };\n  };\n});\n\n/* global -nullFormCtrl, -SUBMITTED_CLASS, addSetValidityMethod: true\n */\nvar nullFormCtrl = {\n  $addControl: noop,\n  $$renameControl: nullFormRenameControl,\n  $removeControl: noop,\n  $setValidity: noop,\n  $setDirty: noop,\n  $setPristine: noop,\n  $setSubmitted: noop\n},\nSUBMITTED_CLASS = 'ng-submitted';\n\nfunction nullFormRenameControl(control, name) {\n  control.$name = name;\n}\n\n/**\n * @ngdoc type\n * @name form.FormController\n *\n * @property {boolean} $pristine True if user has not interacted with the form yet.\n * @property {boolean} $dirty True if user has already interacted with the form.\n * @property {boolean} $valid True if all of the containing forms and controls are valid.\n * @property {boolean} $invalid True if at least one containing control or form is invalid.\n * @property {boolean} $pending True if at least one containing control or form is pending.\n * @property {boolean} $submitted True if user has submitted the form even if its invalid.\n *\n * @property {Object} $error Is an object hash, containing references to controls or\n *  forms with failing validators, where:\n *\n *  - keys are validation tokens (error names),\n *  - values are arrays of controls or forms that have a failing validator for given error name.\n *\n *  Built-in validation tokens:\n *\n *  - `email`\n *  - `max`\n *  - `maxlength`\n *  - `min`\n *  - `minlength`\n *  - `number`\n *  - `pattern`\n *  - `required`\n *  - `url`\n *  - `date`\n *  - `datetimelocal`\n *  - `time`\n *  - `week`\n *  - `month`\n *\n * @description\n * `FormController` keeps track of all its controls and nested forms as well as the state of them,\n * such as being valid/invalid or dirty/pristine.\n *\n * Each {@link ng.directive:form form} directive creates an instance\n * of `FormController`.\n *\n */\n//asks for $scope to fool the BC controller module\nFormController.$inject = ['$element', '$attrs', '$scope', '$animate', '$interpolate'];\nfunction FormController(element, attrs, $scope, $animate, $interpolate) {\n  var form = this,\n      controls = [];\n\n  // init state\n  form.$error = {};\n  form.$$success = {};\n  form.$pending = undefined;\n  form.$name = $interpolate(attrs.name || attrs.ngForm || '')($scope);\n  form.$dirty = false;\n  form.$pristine = true;\n  form.$valid = true;\n  form.$invalid = false;\n  form.$submitted = false;\n  form.$$parentForm = nullFormCtrl;\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$rollbackViewValue\n   *\n   * @description\n   * Rollback all form controls pending updates to the `$modelValue`.\n   *\n   * Updates may be pending by a debounced event or because the input is waiting for a some future\n   * event defined in `ng-model-options`. This method is typically needed by the reset button of\n   * a form that uses `ng-model-options` to pend updates.\n   */\n  form.$rollbackViewValue = function() {\n    forEach(controls, function(control) {\n      control.$rollbackViewValue();\n    });\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$commitViewValue\n   *\n   * @description\n   * Commit all form controls pending updates to the `$modelValue`.\n   *\n   * Updates may be pending by a debounced event or because the input is waiting for a some future\n   * event defined in `ng-model-options`. This method is rarely needed as `NgModelController`\n   * usually handles calling this in response to input events.\n   */\n  form.$commitViewValue = function() {\n    forEach(controls, function(control) {\n      control.$commitViewValue();\n    });\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$addControl\n   * @param {object} control control object, either a {@link form.FormController} or an\n   * {@link ngModel.NgModelController}\n   *\n   * @description\n   * Register a control with the form. Input elements using ngModelController do this automatically\n   * when they are linked.\n   *\n   * Note that the current state of the control will not be reflected on the new parent form. This\n   * is not an issue with normal use, as freshly compiled and linked controls are in a `$pristine`\n   * state.\n   *\n   * However, if the method is used programmatically, for example by adding dynamically created controls,\n   * or controls that have been previously removed without destroying their corresponding DOM element,\n   * it's the developers responsibility to make sure the current state propagates to the parent form.\n   *\n   * For example, if an input control is added that is already `$dirty` and has `$error` properties,\n   * calling `$setDirty()` and `$validate()` afterwards will propagate the state to the parent form.\n   */\n  form.$addControl = function(control) {\n    // Breaking change - before, inputs whose name was \"hasOwnProperty\" were quietly ignored\n    // and not added to the scope.  Now we throw an error.\n    assertNotHasOwnProperty(control.$name, 'input');\n    controls.push(control);\n\n    if (control.$name) {\n      form[control.$name] = control;\n    }\n\n    control.$$parentForm = form;\n  };\n\n  // Private API: rename a form control\n  form.$$renameControl = function(control, newName) {\n    var oldName = control.$name;\n\n    if (form[oldName] === control) {\n      delete form[oldName];\n    }\n    form[newName] = control;\n    control.$name = newName;\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$removeControl\n   * @param {object} control control object, either a {@link form.FormController} or an\n   * {@link ngModel.NgModelController}\n   *\n   * @description\n   * Deregister a control from the form.\n   *\n   * Input elements using ngModelController do this automatically when they are destroyed.\n   *\n   * Note that only the removed control's validation state (`$errors`etc.) will be removed from the\n   * form. `$dirty`, `$submitted` states will not be changed, because the expected behavior can be\n   * different from case to case. For example, removing the only `$dirty` control from a form may or\n   * may not mean that the form is still `$dirty`.\n   */\n  form.$removeControl = function(control) {\n    if (control.$name && form[control.$name] === control) {\n      delete form[control.$name];\n    }\n    forEach(form.$pending, function(value, name) {\n      form.$setValidity(name, null, control);\n    });\n    forEach(form.$error, function(value, name) {\n      form.$setValidity(name, null, control);\n    });\n    forEach(form.$$success, function(value, name) {\n      form.$setValidity(name, null, control);\n    });\n\n    arrayRemove(controls, control);\n    control.$$parentForm = nullFormCtrl;\n  };\n\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$setValidity\n   *\n   * @description\n   * Sets the validity of a form control.\n   *\n   * This method will also propagate to parent forms.\n   */\n  addSetValidityMethod({\n    ctrl: this,\n    $element: element,\n    set: function(object, property, controller) {\n      var list = object[property];\n      if (!list) {\n        object[property] = [controller];\n      } else {\n        var index = list.indexOf(controller);\n        if (index === -1) {\n          list.push(controller);\n        }\n      }\n    },\n    unset: function(object, property, controller) {\n      var list = object[property];\n      if (!list) {\n        return;\n      }\n      arrayRemove(list, controller);\n      if (list.length === 0) {\n        delete object[property];\n      }\n    },\n    $animate: $animate\n  });\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$setDirty\n   *\n   * @description\n   * Sets the form to a dirty state.\n   *\n   * This method can be called to add the 'ng-dirty' class and set the form to a dirty\n   * state (ng-dirty class). This method will also propagate to parent forms.\n   */\n  form.$setDirty = function() {\n    $animate.removeClass(element, PRISTINE_CLASS);\n    $animate.addClass(element, DIRTY_CLASS);\n    form.$dirty = true;\n    form.$pristine = false;\n    form.$$parentForm.$setDirty();\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$setPristine\n   *\n   * @description\n   * Sets the form to its pristine state.\n   *\n   * This method can be called to remove the 'ng-dirty' class and set the form to its pristine\n   * state (ng-pristine class). This method will also propagate to all the controls contained\n   * in this form.\n   *\n   * Setting a form back to a pristine state is often useful when we want to 'reuse' a form after\n   * saving or resetting it.\n   */\n  form.$setPristine = function() {\n    $animate.setClass(element, PRISTINE_CLASS, DIRTY_CLASS + ' ' + SUBMITTED_CLASS);\n    form.$dirty = false;\n    form.$pristine = true;\n    form.$submitted = false;\n    forEach(controls, function(control) {\n      control.$setPristine();\n    });\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$setUntouched\n   *\n   * @description\n   * Sets the form to its untouched state.\n   *\n   * This method can be called to remove the 'ng-touched' class and set the form controls to their\n   * untouched state (ng-untouched class).\n   *\n   * Setting a form controls back to their untouched state is often useful when setting the form\n   * back to its pristine state.\n   */\n  form.$setUntouched = function() {\n    forEach(controls, function(control) {\n      control.$setUntouched();\n    });\n  };\n\n  /**\n   * @ngdoc method\n   * @name form.FormController#$setSubmitted\n   *\n   * @description\n   * Sets the form to its submitted state.\n   */\n  form.$setSubmitted = function() {\n    $animate.addClass(element, SUBMITTED_CLASS);\n    form.$submitted = true;\n    form.$$parentForm.$setSubmitted();\n  };\n}\n\n/**\n * @ngdoc directive\n * @name ngForm\n * @restrict EAC\n *\n * @description\n * Nestable alias of {@link ng.directive:form `form`} directive. HTML\n * does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a\n * sub-group of controls needs to be determined.\n *\n * Note: the purpose of `ngForm` is to group controls,\n * but not to be a replacement for the `<form>` tag with all of its capabilities\n * (e.g. posting to the server, ...).\n *\n * @param {string=} ngForm|name Name of the form. If specified, the form controller will be published into\n *                       related scope, under this name.\n *\n */\n\n /**\n * @ngdoc directive\n * @name form\n * @restrict E\n *\n * @description\n * Directive that instantiates\n * {@link form.FormController FormController}.\n *\n * If the `name` attribute is specified, the form controller is published onto the current scope under\n * this name.\n *\n * # Alias: {@link ng.directive:ngForm `ngForm`}\n *\n * In Angular, forms can be nested. This means that the outer form is valid when all of the child\n * forms are valid as well. However, browsers do not allow nesting of `<form>` elements, so\n * Angular provides the {@link ng.directive:ngForm `ngForm`} directive, which behaves identically to\n * `form` but can be nested. Nested forms can be useful, for example, if the validity of a sub-group\n * of controls needs to be determined.\n *\n * # CSS classes\n *  - `ng-valid` is set if the form is valid.\n *  - `ng-invalid` is set if the form is invalid.\n *  - `ng-pending` is set if the form is pending.\n *  - `ng-pristine` is set if the form is pristine.\n *  - `ng-dirty` is set if the form is dirty.\n *  - `ng-submitted` is set if the form was submitted.\n *\n * Keep in mind that ngAnimate can detect each of these classes when added and removed.\n *\n *\n * # Submitting a form and preventing the default action\n *\n * Since the role of forms in client-side Angular applications is different than in classical\n * roundtrip apps, it is desirable for the browser not to translate the form submission into a full\n * page reload that sends the data to the server. Instead some javascript logic should be triggered\n * to handle the form submission in an application-specific way.\n *\n * For this reason, Angular prevents the default action (form submission to the server) unless the\n * `<form>` element has an `action` attribute specified.\n *\n * You can use one of the following two ways to specify what javascript method should be called when\n * a form is submitted:\n *\n * - {@link ng.directive:ngSubmit ngSubmit} directive on the form element\n * - {@link ng.directive:ngClick ngClick} directive on the first\n  *  button or input field of type submit (input[type=submit])\n *\n * To prevent double execution of the handler, use only one of the {@link ng.directive:ngSubmit ngSubmit}\n * or {@link ng.directive:ngClick ngClick} directives.\n * This is because of the following form submission rules in the HTML specification:\n *\n * - If a form has only one input field then hitting enter in this field triggers form submit\n * (`ngSubmit`)\n * - if a form has 2+ input fields and no buttons or input[type=submit] then hitting enter\n * doesn't trigger submit\n * - if a form has one or more input fields and one or more buttons or input[type=submit] then\n * hitting enter in any of the input fields will trigger the click handler on the *first* button or\n * input[type=submit] (`ngClick`) *and* a submit handler on the enclosing form (`ngSubmit`)\n *\n * Any pending `ngModelOptions` changes will take place immediately when an enclosing form is\n * submitted. Note that `ngClick` events will occur before the model is updated. Use `ngSubmit`\n * to have access to the updated model.\n *\n * ## Animation Hooks\n *\n * Animations in ngForm are triggered when any of the associated CSS classes are added and removed.\n * These classes are: `.ng-pristine`, `.ng-dirty`, `.ng-invalid` and `.ng-valid` as well as any\n * other validations that are performed within the form. Animations in ngForm are similar to how\n * they work in ngClass and animations can be hooked into using CSS transitions, keyframes as well\n * as JS animations.\n *\n * The following example shows a simple way to utilize CSS transitions to style a form element\n * that has been rendered as invalid after it has been validated:\n *\n * <pre>\n * //be sure to include ngAnimate as a module to hook into more\n * //advanced animations\n * .my-form {\n *   transition:0.5s linear all;\n *   background: white;\n * }\n * .my-form.ng-invalid {\n *   background: red;\n *   color:white;\n * }\n * </pre>\n *\n * @example\n    <example deps=\"angular-animate.js\" animations=\"true\" fixBase=\"true\" module=\"formExample\">\n      <file name=\"index.html\">\n       <script>\n         angular.module('formExample', [])\n           .controller('FormController', ['$scope', function($scope) {\n             $scope.userType = 'guest';\n           }]);\n       </script>\n       <style>\n        .my-form {\n          transition:all linear 0.5s;\n          background: transparent;\n        }\n        .my-form.ng-invalid {\n          background: red;\n        }\n       </style>\n       <form name=\"myForm\" ng-controller=\"FormController\" class=\"my-form\">\n         userType: <input name=\"input\" ng-model=\"userType\" required>\n         <span class=\"error\" ng-show=\"myForm.input.$error.required\">Required!</span><br>\n         <code>userType = {{userType}}</code><br>\n         <code>myForm.input.$valid = {{myForm.input.$valid}}</code><br>\n         <code>myForm.input.$error = {{myForm.input.$error}}</code><br>\n         <code>myForm.$valid = {{myForm.$valid}}</code><br>\n         <code>myForm.$error.required = {{!!myForm.$error.required}}</code><br>\n        </form>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should initialize to model', function() {\n          var userType = element(by.binding('userType'));\n          var valid = element(by.binding('myForm.input.$valid'));\n\n          expect(userType.getText()).toContain('guest');\n          expect(valid.getText()).toContain('true');\n        });\n\n        it('should be invalid if empty', function() {\n          var userType = element(by.binding('userType'));\n          var valid = element(by.binding('myForm.input.$valid'));\n          var userInput = element(by.model('userType'));\n\n          userInput.clear();\n          userInput.sendKeys('');\n\n          expect(userType.getText()).toEqual('userType =');\n          expect(valid.getText()).toContain('false');\n        });\n      </file>\n    </example>\n *\n * @param {string=} name Name of the form. If specified, the form controller will be published into\n *                       related scope, under this name.\n */\nvar formDirectiveFactory = function(isNgForm) {\n  return ['$timeout', '$parse', function($timeout, $parse) {\n    var formDirective = {\n      name: 'form',\n      restrict: isNgForm ? 'EAC' : 'E',\n      require: ['form', '^^?form'], //first is the form's own ctrl, second is an optional parent form\n      controller: FormController,\n      compile: function ngFormCompile(formElement, attr) {\n        // Setup initial state of the control\n        formElement.addClass(PRISTINE_CLASS).addClass(VALID_CLASS);\n\n        var nameAttr = attr.name ? 'name' : (isNgForm && attr.ngForm ? 'ngForm' : false);\n\n        return {\n          pre: function ngFormPreLink(scope, formElement, attr, ctrls) {\n            var controller = ctrls[0];\n\n            // if `action` attr is not present on the form, prevent the default action (submission)\n            if (!('action' in attr)) {\n              // we can't use jq events because if a form is destroyed during submission the default\n              // action is not prevented. see #1238\n              //\n              // IE 9 is not affected because it doesn't fire a submit event and try to do a full\n              // page reload if the form was destroyed by submission of the form via a click handler\n              // on a button in the form. Looks like an IE9 specific bug.\n              var handleFormSubmission = function(event) {\n                scope.$apply(function() {\n                  controller.$commitViewValue();\n                  controller.$setSubmitted();\n                });\n\n                event.preventDefault();\n              };\n\n              addEventListenerFn(formElement[0], 'submit', handleFormSubmission);\n\n              // unregister the preventDefault listener so that we don't not leak memory but in a\n              // way that will achieve the prevention of the default action.\n              formElement.on('$destroy', function() {\n                $timeout(function() {\n                  removeEventListenerFn(formElement[0], 'submit', handleFormSubmission);\n                }, 0, false);\n              });\n            }\n\n            var parentFormCtrl = ctrls[1] || controller.$$parentForm;\n            parentFormCtrl.$addControl(controller);\n\n            var setter = nameAttr ? getSetter(controller.$name) : noop;\n\n            if (nameAttr) {\n              setter(scope, controller);\n              attr.$observe(nameAttr, function(newValue) {\n                if (controller.$name === newValue) return;\n                setter(scope, undefined);\n                controller.$$parentForm.$$renameControl(controller, newValue);\n                setter = getSetter(controller.$name);\n                setter(scope, controller);\n              });\n            }\n            formElement.on('$destroy', function() {\n              controller.$$parentForm.$removeControl(controller);\n              setter(scope, undefined);\n              extend(controller, nullFormCtrl); //stop propagating child destruction handlers upwards\n            });\n          }\n        };\n      }\n    };\n\n    return formDirective;\n\n    function getSetter(expression) {\n      if (expression === '') {\n        //create an assignable expression, so forms with an empty name can be renamed later\n        return $parse('this[\"\"]').assign;\n      }\n      return $parse(expression).assign || noop;\n    }\n  }];\n};\n\nvar formDirective = formDirectiveFactory();\nvar ngFormDirective = formDirectiveFactory(true);\n\n/* global VALID_CLASS: false,\n  INVALID_CLASS: false,\n  PRISTINE_CLASS: false,\n  DIRTY_CLASS: false,\n  UNTOUCHED_CLASS: false,\n  TOUCHED_CLASS: false,\n  ngModelMinErr: false,\n*/\n\n// Regex code was initially obtained from SO prior to modification: https://stackoverflow.com/questions/3143070/javascript-regex-iso-datetime#answer-3143231\nvar ISO_DATE_REGEXP = /^\\d{4,}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+(?:[+-][0-2]\\d:[0-5]\\d|Z)$/;\n// See valid URLs in RFC3987 (http://tools.ietf.org/html/rfc3987)\n// Note: We are being more lenient, because browsers are too.\n//   1. Scheme\n//   2. Slashes\n//   3. Username\n//   4. Password\n//   5. Hostname\n//   6. Port\n//   7. Path\n//   8. Query\n//   9. Fragment\n//                 1111111111111111 222   333333    44444        555555555555555555555555    666     77777777     8888888     999\nvar URL_REGEXP = /^[a-z][a-z\\d.+-]*:\\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\\s:/?#]+|\\[[a-f\\d:]+\\])(?::\\d+)?(?:\\/[^?#]*)?(?:\\?[^#]*)?(?:#.*)?$/i;\nvar EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;\nvar NUMBER_REGEXP = /^\\s*(\\-|\\+)?(\\d+|(\\d*(\\.\\d*)))([eE][+-]?\\d+)?\\s*$/;\nvar DATE_REGEXP = /^(\\d{4,})-(\\d{2})-(\\d{2})$/;\nvar DATETIMELOCAL_REGEXP = /^(\\d{4,})-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d)(?::(\\d\\d)(\\.\\d{1,3})?)?$/;\nvar WEEK_REGEXP = /^(\\d{4,})-W(\\d\\d)$/;\nvar MONTH_REGEXP = /^(\\d{4,})-(\\d\\d)$/;\nvar TIME_REGEXP = /^(\\d\\d):(\\d\\d)(?::(\\d\\d)(\\.\\d{1,3})?)?$/;\n\nvar PARTIAL_VALIDATION_EVENTS = 'keydown wheel mousedown';\nvar PARTIAL_VALIDATION_TYPES = createMap();\nforEach('date,datetime-local,month,time,week'.split(','), function(type) {\n  PARTIAL_VALIDATION_TYPES[type] = true;\n});\n\nvar inputType = {\n\n  /**\n   * @ngdoc input\n   * @name input[text]\n   *\n   * @description\n   * Standard HTML text input with angular data binding, inherited by most of the `input` elements.\n   *\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} required Adds `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n   *    minlength.\n   * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n   *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of\n   *    any length.\n   * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string\n   *    that contains the regular expression body that will be converted to a regular expression\n   *    as in the ngPattern directive.\n   * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n   *    does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n   *    If the expression evaluates to a RegExp object, then this is used directly.\n   *    If the expression evaluates to a string, then it will be converted to a RegExp\n   *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n   *    `new RegExp('^abc$')`.<br />\n   *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n   *    start at the index of the last search's match, thus not taking the whole input value into\n   *    account.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input.\n   *    This parameter is ignored for input[type=password] controls, which will never trim the\n   *    input.\n   *\n   * @example\n      <example name=\"text-input-directive\" module=\"textInputExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('textInputExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.example = {\n                 text: 'guest',\n                 word: /^\\s*\\w*\\s*$/\n               };\n             }]);\n         </script>\n         <form name=\"myForm\" ng-controller=\"ExampleController\">\n           <label>Single word:\n             <input type=\"text\" name=\"input\" ng-model=\"example.text\"\n                    ng-pattern=\"example.word\" required ng-trim=\"false\">\n           </label>\n           <div role=\"alert\">\n             <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n               Required!</span>\n             <span class=\"error\" ng-show=\"myForm.input.$error.pattern\">\n               Single word only!</span>\n           </div>\n           <tt>text = {{example.text}}</tt><br/>\n           <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n           <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n           <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n           <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n          </form>\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          var text = element(by.binding('example.text'));\n          var valid = element(by.binding('myForm.input.$valid'));\n          var input = element(by.model('example.text'));\n\n          it('should initialize to model', function() {\n            expect(text.getText()).toContain('guest');\n            expect(valid.getText()).toContain('true');\n          });\n\n          it('should be invalid if empty', function() {\n            input.clear();\n            input.sendKeys('');\n\n            expect(text.getText()).toEqual('text =');\n            expect(valid.getText()).toContain('false');\n          });\n\n          it('should be invalid if multi word', function() {\n            input.clear();\n            input.sendKeys('hello world');\n\n            expect(valid.getText()).toContain('false');\n          });\n        </file>\n      </example>\n   */\n  'text': textInputType,\n\n    /**\n     * @ngdoc input\n     * @name input[date]\n     *\n     * @description\n     * Input with date validation and transformation. In browsers that do not yet support\n     * the HTML5 date input, a text element will be used. In that case, text must be entered in a valid ISO-8601\n     * date format (yyyy-MM-dd), for example: `2009-01-06`. Since many\n     * modern browsers do not yet support this input type, it is important to provide cues to users on the\n     * expected input format via a placeholder or label.\n     *\n     * The model must always be a Date object, otherwise Angular will throw an error.\n     * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string.\n     *\n     * The timezone to be used to read/write the `Date` instance in the model can be defined using\n     * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.\n     *\n     * @param {string} ngModel Assignable angular expression to data-bind to.\n     * @param {string=} name Property name of the form under which the control is published.\n     * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a\n     *   valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute\n     *   (e.g. `min=\"{{minDate | date:'yyyy-MM-dd'}}\"`). Note that `min` will also add native HTML5\n     *   constraint validation.\n     * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be\n     *   a valid ISO date string (yyyy-MM-dd). You can also use interpolation inside this attribute\n     *   (e.g. `max=\"{{maxDate | date:'yyyy-MM-dd'}}\"`). Note that `max` will also add native HTML5\n     *   constraint validation.\n     * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO date string\n     *   the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.\n     * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO date string\n     *   the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.\n     * @param {string=} required Sets `required` validation error key if the value is not entered.\n     * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n     *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n     *    `required` when you want to data-bind to the `required` attribute.\n     * @param {string=} ngChange Angular expression to be executed when input changes due to user\n     *    interaction with the input element.\n     *\n     * @example\n     <example name=\"date-input-directive\" module=\"dateInputExample\">\n     <file name=\"index.html\">\n       <script>\n          angular.module('dateInputExample', [])\n            .controller('DateController', ['$scope', function($scope) {\n              $scope.example = {\n                value: new Date(2013, 9, 22)\n              };\n            }]);\n       </script>\n       <form name=\"myForm\" ng-controller=\"DateController as dateCtrl\">\n          <label for=\"exampleInput\">Pick a date in 2013:</label>\n          <input type=\"date\" id=\"exampleInput\" name=\"input\" ng-model=\"example.value\"\n              placeholder=\"yyyy-MM-dd\" min=\"2013-01-01\" max=\"2013-12-31\" required />\n          <div role=\"alert\">\n            <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n                Required!</span>\n            <span class=\"error\" ng-show=\"myForm.input.$error.date\">\n                Not a valid date!</span>\n           </div>\n           <tt>value = {{example.value | date: \"yyyy-MM-dd\"}}</tt><br/>\n           <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n           <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n           <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n           <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n       </form>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n        var value = element(by.binding('example.value | date: \"yyyy-MM-dd\"'));\n        var valid = element(by.binding('myForm.input.$valid'));\n        var input = element(by.model('example.value'));\n\n        // currently protractor/webdriver does not support\n        // sending keys to all known HTML5 input controls\n        // for various browsers (see https://github.com/angular/protractor/issues/562).\n        function setInput(val) {\n          // set the value of the element and force validation.\n          var scr = \"var ipt = document.getElementById('exampleInput'); \" +\n          \"ipt.value = '\" + val + \"';\" +\n          \"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('\" + val + \"'); });\";\n          browser.executeScript(scr);\n        }\n\n        it('should initialize to model', function() {\n          expect(value.getText()).toContain('2013-10-22');\n          expect(valid.getText()).toContain('myForm.input.$valid = true');\n        });\n\n        it('should be invalid if empty', function() {\n          setInput('');\n          expect(value.getText()).toEqual('value =');\n          expect(valid.getText()).toContain('myForm.input.$valid = false');\n        });\n\n        it('should be invalid if over max', function() {\n          setInput('2015-01-01');\n          expect(value.getText()).toContain('');\n          expect(valid.getText()).toContain('myForm.input.$valid = false');\n        });\n     </file>\n     </example>\n     */\n  'date': createDateInputType('date', DATE_REGEXP,\n         createDateParser(DATE_REGEXP, ['yyyy', 'MM', 'dd']),\n         'yyyy-MM-dd'),\n\n   /**\n    * @ngdoc input\n    * @name input[datetime-local]\n    *\n    * @description\n    * Input with datetime validation and transformation. In browsers that do not yet support\n    * the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601\n    * local datetime format (yyyy-MM-ddTHH:mm:ss), for example: `2010-12-28T14:57:00`.\n    *\n    * The model must always be a Date object, otherwise Angular will throw an error.\n    * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string.\n    *\n    * The timezone to be used to read/write the `Date` instance in the model can be defined using\n    * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.\n    *\n    * @param {string} ngModel Assignable angular expression to data-bind to.\n    * @param {string=} name Property name of the form under which the control is published.\n    * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.\n    *   This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation\n    *   inside this attribute (e.g. `min=\"{{minDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}\"`).\n    *   Note that `min` will also add native HTML5 constraint validation.\n    * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.\n    *   This must be a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss). You can also use interpolation\n    *   inside this attribute (e.g. `max=\"{{maxDatetimeLocal | date:'yyyy-MM-ddTHH:mm:ss'}}\"`).\n    *   Note that `max` will also add native HTML5 constraint validation.\n    * @param {(date|string)=} ngMin Sets the `min` validation error key to the Date / ISO datetime string\n    *   the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.\n    * @param {(date|string)=} ngMax Sets the `max` validation error key to the Date / ISO datetime string\n    *   the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.\n    * @param {string=} required Sets `required` validation error key if the value is not entered.\n    * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n    *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n    *    `required` when you want to data-bind to the `required` attribute.\n    * @param {string=} ngChange Angular expression to be executed when input changes due to user\n    *    interaction with the input element.\n    *\n    * @example\n    <example name=\"datetimelocal-input-directive\" module=\"dateExample\">\n    <file name=\"index.html\">\n      <script>\n        angular.module('dateExample', [])\n          .controller('DateController', ['$scope', function($scope) {\n            $scope.example = {\n              value: new Date(2010, 11, 28, 14, 57)\n            };\n          }]);\n      </script>\n      <form name=\"myForm\" ng-controller=\"DateController as dateCtrl\">\n        <label for=\"exampleInput\">Pick a date between in 2013:</label>\n        <input type=\"datetime-local\" id=\"exampleInput\" name=\"input\" ng-model=\"example.value\"\n            placeholder=\"yyyy-MM-ddTHH:mm:ss\" min=\"2001-01-01T00:00:00\" max=\"2013-12-31T00:00:00\" required />\n        <div role=\"alert\">\n          <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n              Required!</span>\n          <span class=\"error\" ng-show=\"myForm.input.$error.datetimelocal\">\n              Not a valid date!</span>\n        </div>\n        <tt>value = {{example.value | date: \"yyyy-MM-ddTHH:mm:ss\"}}</tt><br/>\n        <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n        <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n        <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n        <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n      </form>\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var value = element(by.binding('example.value | date: \"yyyy-MM-ddTHH:mm:ss\"'));\n      var valid = element(by.binding('myForm.input.$valid'));\n      var input = element(by.model('example.value'));\n\n      // currently protractor/webdriver does not support\n      // sending keys to all known HTML5 input controls\n      // for various browsers (https://github.com/angular/protractor/issues/562).\n      function setInput(val) {\n        // set the value of the element and force validation.\n        var scr = \"var ipt = document.getElementById('exampleInput'); \" +\n        \"ipt.value = '\" + val + \"';\" +\n        \"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('\" + val + \"'); });\";\n        browser.executeScript(scr);\n      }\n\n      it('should initialize to model', function() {\n        expect(value.getText()).toContain('2010-12-28T14:57:00');\n        expect(valid.getText()).toContain('myForm.input.$valid = true');\n      });\n\n      it('should be invalid if empty', function() {\n        setInput('');\n        expect(value.getText()).toEqual('value =');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n\n      it('should be invalid if over max', function() {\n        setInput('2015-01-01T23:59:00');\n        expect(value.getText()).toContain('');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n    </file>\n    </example>\n    */\n  'datetime-local': createDateInputType('datetimelocal', DATETIMELOCAL_REGEXP,\n      createDateParser(DATETIMELOCAL_REGEXP, ['yyyy', 'MM', 'dd', 'HH', 'mm', 'ss', 'sss']),\n      'yyyy-MM-ddTHH:mm:ss.sss'),\n\n  /**\n   * @ngdoc input\n   * @name input[time]\n   *\n   * @description\n   * Input with time validation and transformation. In browsers that do not yet support\n   * the HTML5 time input, a text element will be used. In that case, the text must be entered in a valid ISO-8601\n   * local time format (HH:mm:ss), for example: `14:57:00`. Model must be a Date object. This binding will always output a\n   * Date object to the model of January 1, 1970, or local date `new Date(1970, 0, 1, HH, mm, ss)`.\n   *\n   * The model must always be a Date object, otherwise Angular will throw an error.\n   * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string.\n   *\n   * The timezone to be used to read/write the `Date` instance in the model can be defined using\n   * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.\n   *   This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this\n   *   attribute (e.g. `min=\"{{minTime | date:'HH:mm:ss'}}\"`). Note that `min` will also add\n   *   native HTML5 constraint validation.\n   * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.\n   *   This must be a valid ISO time format (HH:mm:ss). You can also use interpolation inside this\n   *   attribute (e.g. `max=\"{{maxTime | date:'HH:mm:ss'}}\"`). Note that `max` will also add\n   *   native HTML5 constraint validation.\n   * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO time string the\n   *   `ngMin` expression evaluates to. Note that it does not set the `min` attribute.\n   * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO time string the\n   *   `ngMax` expression evaluates to. Note that it does not set the `max` attribute.\n   * @param {string=} required Sets `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n   <example name=\"time-input-directive\" module=\"timeExample\">\n   <file name=\"index.html\">\n     <script>\n      angular.module('timeExample', [])\n        .controller('DateController', ['$scope', function($scope) {\n          $scope.example = {\n            value: new Date(1970, 0, 1, 14, 57, 0)\n          };\n        }]);\n     </script>\n     <form name=\"myForm\" ng-controller=\"DateController as dateCtrl\">\n        <label for=\"exampleInput\">Pick a time between 8am and 5pm:</label>\n        <input type=\"time\" id=\"exampleInput\" name=\"input\" ng-model=\"example.value\"\n            placeholder=\"HH:mm:ss\" min=\"08:00:00\" max=\"17:00:00\" required />\n        <div role=\"alert\">\n          <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n              Required!</span>\n          <span class=\"error\" ng-show=\"myForm.input.$error.time\">\n              Not a valid date!</span>\n        </div>\n        <tt>value = {{example.value | date: \"HH:mm:ss\"}}</tt><br/>\n        <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n        <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n        <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n        <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n     </form>\n   </file>\n   <file name=\"protractor.js\" type=\"protractor\">\n      var value = element(by.binding('example.value | date: \"HH:mm:ss\"'));\n      var valid = element(by.binding('myForm.input.$valid'));\n      var input = element(by.model('example.value'));\n\n      // currently protractor/webdriver does not support\n      // sending keys to all known HTML5 input controls\n      // for various browsers (https://github.com/angular/protractor/issues/562).\n      function setInput(val) {\n        // set the value of the element and force validation.\n        var scr = \"var ipt = document.getElementById('exampleInput'); \" +\n        \"ipt.value = '\" + val + \"';\" +\n        \"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('\" + val + \"'); });\";\n        browser.executeScript(scr);\n      }\n\n      it('should initialize to model', function() {\n        expect(value.getText()).toContain('14:57:00');\n        expect(valid.getText()).toContain('myForm.input.$valid = true');\n      });\n\n      it('should be invalid if empty', function() {\n        setInput('');\n        expect(value.getText()).toEqual('value =');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n\n      it('should be invalid if over max', function() {\n        setInput('23:59:00');\n        expect(value.getText()).toContain('');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n   </file>\n   </example>\n   */\n  'time': createDateInputType('time', TIME_REGEXP,\n      createDateParser(TIME_REGEXP, ['HH', 'mm', 'ss', 'sss']),\n     'HH:mm:ss.sss'),\n\n   /**\n    * @ngdoc input\n    * @name input[week]\n    *\n    * @description\n    * Input with week-of-the-year validation and transformation to Date. In browsers that do not yet support\n    * the HTML5 week input, a text element will be used. In that case, the text must be entered in a valid ISO-8601\n    * week format (yyyy-W##), for example: `2013-W02`.\n    *\n    * The model must always be a Date object, otherwise Angular will throw an error.\n    * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string.\n    *\n    * The timezone to be used to read/write the `Date` instance in the model can be defined using\n    * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.\n    *\n    * @param {string} ngModel Assignable angular expression to data-bind to.\n    * @param {string=} name Property name of the form under which the control is published.\n    * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.\n    *   This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this\n    *   attribute (e.g. `min=\"{{minWeek | date:'yyyy-Www'}}\"`). Note that `min` will also add\n    *   native HTML5 constraint validation.\n    * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.\n    *   This must be a valid ISO week format (yyyy-W##). You can also use interpolation inside this\n    *   attribute (e.g. `max=\"{{maxWeek | date:'yyyy-Www'}}\"`). Note that `max` will also add\n    *   native HTML5 constraint validation.\n    * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string\n    *   the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.\n    * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string\n    *   the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.\n    * @param {string=} required Sets `required` validation error key if the value is not entered.\n    * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n    *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n    *    `required` when you want to data-bind to the `required` attribute.\n    * @param {string=} ngChange Angular expression to be executed when input changes due to user\n    *    interaction with the input element.\n    *\n    * @example\n    <example name=\"week-input-directive\" module=\"weekExample\">\n    <file name=\"index.html\">\n      <script>\n      angular.module('weekExample', [])\n        .controller('DateController', ['$scope', function($scope) {\n          $scope.example = {\n            value: new Date(2013, 0, 3)\n          };\n        }]);\n      </script>\n      <form name=\"myForm\" ng-controller=\"DateController as dateCtrl\">\n        <label>Pick a date between in 2013:\n          <input id=\"exampleInput\" type=\"week\" name=\"input\" ng-model=\"example.value\"\n                 placeholder=\"YYYY-W##\" min=\"2012-W32\"\n                 max=\"2013-W52\" required />\n        </label>\n        <div role=\"alert\">\n          <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n              Required!</span>\n          <span class=\"error\" ng-show=\"myForm.input.$error.week\">\n              Not a valid date!</span>\n        </div>\n        <tt>value = {{example.value | date: \"yyyy-Www\"}}</tt><br/>\n        <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n        <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n        <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n        <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n      </form>\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var value = element(by.binding('example.value | date: \"yyyy-Www\"'));\n      var valid = element(by.binding('myForm.input.$valid'));\n      var input = element(by.model('example.value'));\n\n      // currently protractor/webdriver does not support\n      // sending keys to all known HTML5 input controls\n      // for various browsers (https://github.com/angular/protractor/issues/562).\n      function setInput(val) {\n        // set the value of the element and force validation.\n        var scr = \"var ipt = document.getElementById('exampleInput'); \" +\n        \"ipt.value = '\" + val + \"';\" +\n        \"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('\" + val + \"'); });\";\n        browser.executeScript(scr);\n      }\n\n      it('should initialize to model', function() {\n        expect(value.getText()).toContain('2013-W01');\n        expect(valid.getText()).toContain('myForm.input.$valid = true');\n      });\n\n      it('should be invalid if empty', function() {\n        setInput('');\n        expect(value.getText()).toEqual('value =');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n\n      it('should be invalid if over max', function() {\n        setInput('2015-W01');\n        expect(value.getText()).toContain('');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n    </file>\n    </example>\n    */\n  'week': createDateInputType('week', WEEK_REGEXP, weekParser, 'yyyy-Www'),\n\n  /**\n   * @ngdoc input\n   * @name input[month]\n   *\n   * @description\n   * Input with month validation and transformation. In browsers that do not yet support\n   * the HTML5 month input, a text element will be used. In that case, the text must be entered in a valid ISO-8601\n   * month format (yyyy-MM), for example: `2009-01`.\n   *\n   * The model must always be a Date object, otherwise Angular will throw an error.\n   * Invalid `Date` objects (dates whose `getTime()` is `NaN`) will be rendered as an empty string.\n   * If the model is not set to the first of the month, the next view to model update will set it\n   * to the first of the month.\n   *\n   * The timezone to be used to read/write the `Date` instance in the model can be defined using\n   * {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.\n   *   This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this\n   *   attribute (e.g. `min=\"{{minMonth | date:'yyyy-MM'}}\"`). Note that `min` will also add\n   *   native HTML5 constraint validation.\n   * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.\n   *   This must be a valid ISO month format (yyyy-MM). You can also use interpolation inside this\n   *   attribute (e.g. `max=\"{{maxMonth | date:'yyyy-MM'}}\"`). Note that `max` will also add\n   *   native HTML5 constraint validation.\n   * @param {(date|string)=} ngMin Sets the `min` validation constraint to the Date / ISO week string\n   *   the `ngMin` expression evaluates to. Note that it does not set the `min` attribute.\n   * @param {(date|string)=} ngMax Sets the `max` validation constraint to the Date / ISO week string\n   *   the `ngMax` expression evaluates to. Note that it does not set the `max` attribute.\n\n   * @param {string=} required Sets `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n   <example name=\"month-input-directive\" module=\"monthExample\">\n   <file name=\"index.html\">\n     <script>\n      angular.module('monthExample', [])\n        .controller('DateController', ['$scope', function($scope) {\n          $scope.example = {\n            value: new Date(2013, 9, 1)\n          };\n        }]);\n     </script>\n     <form name=\"myForm\" ng-controller=\"DateController as dateCtrl\">\n       <label for=\"exampleInput\">Pick a month in 2013:</label>\n       <input id=\"exampleInput\" type=\"month\" name=\"input\" ng-model=\"example.value\"\n          placeholder=\"yyyy-MM\" min=\"2013-01\" max=\"2013-12\" required />\n       <div role=\"alert\">\n         <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n            Required!</span>\n         <span class=\"error\" ng-show=\"myForm.input.$error.month\">\n            Not a valid month!</span>\n       </div>\n       <tt>value = {{example.value | date: \"yyyy-MM\"}}</tt><br/>\n       <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n       <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n       <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n       <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n     </form>\n   </file>\n   <file name=\"protractor.js\" type=\"protractor\">\n      var value = element(by.binding('example.value | date: \"yyyy-MM\"'));\n      var valid = element(by.binding('myForm.input.$valid'));\n      var input = element(by.model('example.value'));\n\n      // currently protractor/webdriver does not support\n      // sending keys to all known HTML5 input controls\n      // for various browsers (https://github.com/angular/protractor/issues/562).\n      function setInput(val) {\n        // set the value of the element and force validation.\n        var scr = \"var ipt = document.getElementById('exampleInput'); \" +\n        \"ipt.value = '\" + val + \"';\" +\n        \"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('\" + val + \"'); });\";\n        browser.executeScript(scr);\n      }\n\n      it('should initialize to model', function() {\n        expect(value.getText()).toContain('2013-10');\n        expect(valid.getText()).toContain('myForm.input.$valid = true');\n      });\n\n      it('should be invalid if empty', function() {\n        setInput('');\n        expect(value.getText()).toEqual('value =');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n\n      it('should be invalid if over max', function() {\n        setInput('2015-01');\n        expect(value.getText()).toContain('');\n        expect(valid.getText()).toContain('myForm.input.$valid = false');\n      });\n   </file>\n   </example>\n   */\n  'month': createDateInputType('month', MONTH_REGEXP,\n     createDateParser(MONTH_REGEXP, ['yyyy', 'MM']),\n     'yyyy-MM'),\n\n  /**\n   * @ngdoc input\n   * @name input[number]\n   *\n   * @description\n   * Text input with number validation and transformation. Sets the `number` validation\n   * error if not a valid number.\n   *\n   * <div class=\"alert alert-warning\">\n   * The model must always be of type `number` otherwise Angular will throw an error.\n   * Be aware that a string containing a number is not enough. See the {@link ngModel:numfmt}\n   * error docs for more information and an example of how to convert your model if necessary.\n   * </div>\n   *\n   * ## Issues with HTML5 constraint validation\n   *\n   * In browsers that follow the\n   * [HTML5 specification](https://html.spec.whatwg.org/multipage/forms.html#number-state-%28type=number%29),\n   * `input[number]` does not work as expected with {@link ngModelOptions `ngModelOptions.allowInvalid`}.\n   * If a non-number is entered in the input, the browser will report the value as an empty string,\n   * which means the view / model values in `ngModel` and subsequently the scope value\n   * will also be an empty string.\n   *\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} min Sets the `min` validation error key if the value entered is less than `min`.\n   * @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`.\n   * @param {string=} required Sets `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n   *    minlength.\n   * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n   *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of\n   *    any length.\n   * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string\n   *    that contains the regular expression body that will be converted to a regular expression\n   *    as in the ngPattern directive.\n   * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n   *    does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n   *    If the expression evaluates to a RegExp object, then this is used directly.\n   *    If the expression evaluates to a string, then it will be converted to a RegExp\n   *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n   *    `new RegExp('^abc$')`.<br />\n   *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n   *    start at the index of the last search's match, thus not taking the whole input value into\n   *    account.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n      <example name=\"number-input-directive\" module=\"numberExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('numberExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.example = {\n                 value: 12\n               };\n             }]);\n         </script>\n         <form name=\"myForm\" ng-controller=\"ExampleController\">\n           <label>Number:\n             <input type=\"number\" name=\"input\" ng-model=\"example.value\"\n                    min=\"0\" max=\"99\" required>\n          </label>\n           <div role=\"alert\">\n             <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n               Required!</span>\n             <span class=\"error\" ng-show=\"myForm.input.$error.number\">\n               Not valid number!</span>\n           </div>\n           <tt>value = {{example.value}}</tt><br/>\n           <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n           <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n           <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n           <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n          </form>\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          var value = element(by.binding('example.value'));\n          var valid = element(by.binding('myForm.input.$valid'));\n          var input = element(by.model('example.value'));\n\n          it('should initialize to model', function() {\n            expect(value.getText()).toContain('12');\n            expect(valid.getText()).toContain('true');\n          });\n\n          it('should be invalid if empty', function() {\n            input.clear();\n            input.sendKeys('');\n            expect(value.getText()).toEqual('value =');\n            expect(valid.getText()).toContain('false');\n          });\n\n          it('should be invalid if over max', function() {\n            input.clear();\n            input.sendKeys('123');\n            expect(value.getText()).toEqual('value =');\n            expect(valid.getText()).toContain('false');\n          });\n        </file>\n      </example>\n   */\n  'number': numberInputType,\n\n\n  /**\n   * @ngdoc input\n   * @name input[url]\n   *\n   * @description\n   * Text input with URL validation. Sets the `url` validation error key if the content is not a\n   * valid URL.\n   *\n   * <div class=\"alert alert-warning\">\n   * **Note:** `input[url]` uses a regex to validate urls that is derived from the regex\n   * used in Chromium. If you need stricter validation, you can use `ng-pattern` or modify\n   * the built-in validators (see the {@link guide/forms Forms guide})\n   * </div>\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} required Sets `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n   *    minlength.\n   * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n   *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of\n   *    any length.\n   * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string\n   *    that contains the regular expression body that will be converted to a regular expression\n   *    as in the ngPattern directive.\n   * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n   *    does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n   *    If the expression evaluates to a RegExp object, then this is used directly.\n   *    If the expression evaluates to a string, then it will be converted to a RegExp\n   *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n   *    `new RegExp('^abc$')`.<br />\n   *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n   *    start at the index of the last search's match, thus not taking the whole input value into\n   *    account.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n      <example name=\"url-input-directive\" module=\"urlExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('urlExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.url = {\n                 text: 'http://google.com'\n               };\n             }]);\n         </script>\n         <form name=\"myForm\" ng-controller=\"ExampleController\">\n           <label>URL:\n             <input type=\"url\" name=\"input\" ng-model=\"url.text\" required>\n           <label>\n           <div role=\"alert\">\n             <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n               Required!</span>\n             <span class=\"error\" ng-show=\"myForm.input.$error.url\">\n               Not valid url!</span>\n           </div>\n           <tt>text = {{url.text}}</tt><br/>\n           <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n           <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n           <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n           <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n           <tt>myForm.$error.url = {{!!myForm.$error.url}}</tt><br/>\n          </form>\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          var text = element(by.binding('url.text'));\n          var valid = element(by.binding('myForm.input.$valid'));\n          var input = element(by.model('url.text'));\n\n          it('should initialize to model', function() {\n            expect(text.getText()).toContain('http://google.com');\n            expect(valid.getText()).toContain('true');\n          });\n\n          it('should be invalid if empty', function() {\n            input.clear();\n            input.sendKeys('');\n\n            expect(text.getText()).toEqual('text =');\n            expect(valid.getText()).toContain('false');\n          });\n\n          it('should be invalid if not url', function() {\n            input.clear();\n            input.sendKeys('box');\n\n            expect(valid.getText()).toContain('false');\n          });\n        </file>\n      </example>\n   */\n  'url': urlInputType,\n\n\n  /**\n   * @ngdoc input\n   * @name input[email]\n   *\n   * @description\n   * Text input with email validation. Sets the `email` validation error key if not a valid email\n   * address.\n   *\n   * <div class=\"alert alert-warning\">\n   * **Note:** `input[email]` uses a regex to validate email addresses that is derived from the regex\n   * used in Chromium. If you need stricter validation (e.g. requiring a top-level domain), you can\n   * use `ng-pattern` or modify the built-in validators (see the {@link guide/forms Forms guide})\n   * </div>\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} required Sets `required` validation error key if the value is not entered.\n   * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n   *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n   *    `required` when you want to data-bind to the `required` attribute.\n   * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n   *    minlength.\n   * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n   *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of\n   *    any length.\n   * @param {string=} pattern Similar to `ngPattern` except that the attribute value is the actual string\n   *    that contains the regular expression body that will be converted to a regular expression\n   *    as in the ngPattern directive.\n   * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n   *    does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n   *    If the expression evaluates to a RegExp object, then this is used directly.\n   *    If the expression evaluates to a string, then it will be converted to a RegExp\n   *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n   *    `new RegExp('^abc$')`.<br />\n   *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n   *    start at the index of the last search's match, thus not taking the whole input value into\n   *    account.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n      <example name=\"email-input-directive\" module=\"emailExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('emailExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.email = {\n                 text: 'me@example.com'\n               };\n             }]);\n         </script>\n           <form name=\"myForm\" ng-controller=\"ExampleController\">\n             <label>Email:\n               <input type=\"email\" name=\"input\" ng-model=\"email.text\" required>\n             </label>\n             <div role=\"alert\">\n               <span class=\"error\" ng-show=\"myForm.input.$error.required\">\n                 Required!</span>\n               <span class=\"error\" ng-show=\"myForm.input.$error.email\">\n                 Not valid email!</span>\n             </div>\n             <tt>text = {{email.text}}</tt><br/>\n             <tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>\n             <tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>\n             <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n             <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n             <tt>myForm.$error.email = {{!!myForm.$error.email}}</tt><br/>\n           </form>\n         </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          var text = element(by.binding('email.text'));\n          var valid = element(by.binding('myForm.input.$valid'));\n          var input = element(by.model('email.text'));\n\n          it('should initialize to model', function() {\n            expect(text.getText()).toContain('me@example.com');\n            expect(valid.getText()).toContain('true');\n          });\n\n          it('should be invalid if empty', function() {\n            input.clear();\n            input.sendKeys('');\n            expect(text.getText()).toEqual('text =');\n            expect(valid.getText()).toContain('false');\n          });\n\n          it('should be invalid if not email', function() {\n            input.clear();\n            input.sendKeys('xxx');\n\n            expect(valid.getText()).toContain('false');\n          });\n        </file>\n      </example>\n   */\n  'email': emailInputType,\n\n\n  /**\n   * @ngdoc input\n   * @name input[radio]\n   *\n   * @description\n   * HTML radio button.\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string} value The value to which the `ngModel` expression should be set when selected.\n   *    Note that `value` only supports `string` values, i.e. the scope model needs to be a string,\n   *    too. Use `ngValue` if you need complex models (`number`, `object`, ...).\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   * @param {string} ngValue Angular expression to which `ngModel` will be be set when the radio\n   *    is selected. Should be used instead of the `value` attribute if you need\n   *    a non-string `ngModel` (`boolean`, `array`, ...).\n   *\n   * @example\n      <example name=\"radio-input-directive\" module=\"radioExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('radioExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.color = {\n                 name: 'blue'\n               };\n               $scope.specialValue = {\n                 \"id\": \"12345\",\n                 \"value\": \"green\"\n               };\n             }]);\n         </script>\n         <form name=\"myForm\" ng-controller=\"ExampleController\">\n           <label>\n             <input type=\"radio\" ng-model=\"color.name\" value=\"red\">\n             Red\n           </label><br/>\n           <label>\n             <input type=\"radio\" ng-model=\"color.name\" ng-value=\"specialValue\">\n             Green\n           </label><br/>\n           <label>\n             <input type=\"radio\" ng-model=\"color.name\" value=\"blue\">\n             Blue\n           </label><br/>\n           <tt>color = {{color.name | json}}</tt><br/>\n          </form>\n          Note that `ng-value=\"specialValue\"` sets radio item's value to be the value of `$scope.specialValue`.\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          it('should change state', function() {\n            var color = element(by.binding('color.name'));\n\n            expect(color.getText()).toContain('blue');\n\n            element.all(by.model('color.name')).get(0).click();\n\n            expect(color.getText()).toContain('red');\n          });\n        </file>\n      </example>\n   */\n  'radio': radioInputType,\n\n\n  /**\n   * @ngdoc input\n   * @name input[checkbox]\n   *\n   * @description\n   * HTML checkbox.\n   *\n   * @param {string} ngModel Assignable angular expression to data-bind to.\n   * @param {string=} name Property name of the form under which the control is published.\n   * @param {expression=} ngTrueValue The value to which the expression should be set when selected.\n   * @param {expression=} ngFalseValue The value to which the expression should be set when not selected.\n   * @param {string=} ngChange Angular expression to be executed when input changes due to user\n   *    interaction with the input element.\n   *\n   * @example\n      <example name=\"checkbox-input-directive\" module=\"checkboxExample\">\n        <file name=\"index.html\">\n         <script>\n           angular.module('checkboxExample', [])\n             .controller('ExampleController', ['$scope', function($scope) {\n               $scope.checkboxModel = {\n                value1 : true,\n                value2 : 'YES'\n              };\n             }]);\n         </script>\n         <form name=\"myForm\" ng-controller=\"ExampleController\">\n           <label>Value1:\n             <input type=\"checkbox\" ng-model=\"checkboxModel.value1\">\n           </label><br/>\n           <label>Value2:\n             <input type=\"checkbox\" ng-model=\"checkboxModel.value2\"\n                    ng-true-value=\"'YES'\" ng-false-value=\"'NO'\">\n            </label><br/>\n           <tt>value1 = {{checkboxModel.value1}}</tt><br/>\n           <tt>value2 = {{checkboxModel.value2}}</tt><br/>\n          </form>\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          it('should change state', function() {\n            var value1 = element(by.binding('checkboxModel.value1'));\n            var value2 = element(by.binding('checkboxModel.value2'));\n\n            expect(value1.getText()).toContain('true');\n            expect(value2.getText()).toContain('YES');\n\n            element(by.model('checkboxModel.value1')).click();\n            element(by.model('checkboxModel.value2')).click();\n\n            expect(value1.getText()).toContain('false');\n            expect(value2.getText()).toContain('NO');\n          });\n        </file>\n      </example>\n   */\n  'checkbox': checkboxInputType,\n\n  'hidden': noop,\n  'button': noop,\n  'submit': noop,\n  'reset': noop,\n  'file': noop\n};\n\nfunction stringBasedInputType(ctrl) {\n  ctrl.$formatters.push(function(value) {\n    return ctrl.$isEmpty(value) ? value : value.toString();\n  });\n}\n\nfunction textInputType(scope, element, attr, ctrl, $sniffer, $browser) {\n  baseInputType(scope, element, attr, ctrl, $sniffer, $browser);\n  stringBasedInputType(ctrl);\n}\n\nfunction baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {\n  var type = lowercase(element[0].type);\n\n  // In composition mode, users are still inputing intermediate text buffer,\n  // hold the listener until composition is done.\n  // More about composition events: https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent\n  if (!$sniffer.android) {\n    var composing = false;\n\n    element.on('compositionstart', function() {\n      composing = true;\n    });\n\n    element.on('compositionend', function() {\n      composing = false;\n      listener();\n    });\n  }\n\n  var timeout;\n\n  var listener = function(ev) {\n    if (timeout) {\n      $browser.defer.cancel(timeout);\n      timeout = null;\n    }\n    if (composing) return;\n    var value = element.val(),\n        event = ev && ev.type;\n\n    // By default we will trim the value\n    // If the attribute ng-trim exists we will avoid trimming\n    // If input type is 'password', the value is never trimmed\n    if (type !== 'password' && (!attr.ngTrim || attr.ngTrim !== 'false')) {\n      value = trim(value);\n    }\n\n    // If a control is suffering from bad input (due to native validators), browsers discard its\n    // value, so it may be necessary to revalidate (by calling $setViewValue again) even if the\n    // control's value is the same empty value twice in a row.\n    if (ctrl.$viewValue !== value || (value === '' && ctrl.$$hasNativeValidators)) {\n      ctrl.$setViewValue(value, event);\n    }\n  };\n\n  // if the browser does support \"input\" event, we are fine - except on IE9 which doesn't fire the\n  // input event on backspace, delete or cut\n  if ($sniffer.hasEvent('input')) {\n    element.on('input', listener);\n  } else {\n    var deferListener = function(ev, input, origValue) {\n      if (!timeout) {\n        timeout = $browser.defer(function() {\n          timeout = null;\n          if (!input || input.value !== origValue) {\n            listener(ev);\n          }\n        });\n      }\n    };\n\n    element.on('keydown', function(event) {\n      var key = event.keyCode;\n\n      // ignore\n      //    command            modifiers                   arrows\n      if (key === 91 || (15 < key && key < 19) || (37 <= key && key <= 40)) return;\n\n      deferListener(event, this, this.value);\n    });\n\n    // if user modifies input value using context menu in IE, we need \"paste\" and \"cut\" events to catch it\n    if ($sniffer.hasEvent('paste')) {\n      element.on('paste cut', deferListener);\n    }\n  }\n\n  // if user paste into input using mouse on older browser\n  // or form autocomplete on newer browser, we need \"change\" event to catch it\n  element.on('change', listener);\n\n  // Some native input types (date-family) have the ability to change validity without\n  // firing any input/change events.\n  // For these event types, when native validators are present and the browser supports the type,\n  // check for validity changes on various DOM events.\n  if (PARTIAL_VALIDATION_TYPES[type] && ctrl.$$hasNativeValidators && type === attr.type) {\n    element.on(PARTIAL_VALIDATION_EVENTS, function(ev) {\n      if (!timeout) {\n        var validity = this[VALIDITY_STATE_PROPERTY];\n        var origBadInput = validity.badInput;\n        var origTypeMismatch = validity.typeMismatch;\n        timeout = $browser.defer(function() {\n          timeout = null;\n          if (validity.badInput !== origBadInput || validity.typeMismatch !== origTypeMismatch) {\n            listener(ev);\n          }\n        });\n      }\n    });\n  }\n\n  ctrl.$render = function() {\n    // Workaround for Firefox validation #12102.\n    var value = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;\n    if (element.val() !== value) {\n      element.val(value);\n    }\n  };\n}\n\nfunction weekParser(isoWeek, existingDate) {\n  if (isDate(isoWeek)) {\n    return isoWeek;\n  }\n\n  if (isString(isoWeek)) {\n    WEEK_REGEXP.lastIndex = 0;\n    var parts = WEEK_REGEXP.exec(isoWeek);\n    if (parts) {\n      var year = +parts[1],\n          week = +parts[2],\n          hours = 0,\n          minutes = 0,\n          seconds = 0,\n          milliseconds = 0,\n          firstThurs = getFirstThursdayOfYear(year),\n          addDays = (week - 1) * 7;\n\n      if (existingDate) {\n        hours = existingDate.getHours();\n        minutes = existingDate.getMinutes();\n        seconds = existingDate.getSeconds();\n        milliseconds = existingDate.getMilliseconds();\n      }\n\n      return new Date(year, 0, firstThurs.getDate() + addDays, hours, minutes, seconds, milliseconds);\n    }\n  }\n\n  return NaN;\n}\n\nfunction createDateParser(regexp, mapping) {\n  return function(iso, date) {\n    var parts, map;\n\n    if (isDate(iso)) {\n      return iso;\n    }\n\n    if (isString(iso)) {\n      // When a date is JSON'ified to wraps itself inside of an extra\n      // set of double quotes. This makes the date parsing code unable\n      // to match the date string and parse it as a date.\n      if (iso.charAt(0) == '\"' && iso.charAt(iso.length - 1) == '\"') {\n        iso = iso.substring(1, iso.length - 1);\n      }\n      if (ISO_DATE_REGEXP.test(iso)) {\n        return new Date(iso);\n      }\n      regexp.lastIndex = 0;\n      parts = regexp.exec(iso);\n\n      if (parts) {\n        parts.shift();\n        if (date) {\n          map = {\n            yyyy: date.getFullYear(),\n            MM: date.getMonth() + 1,\n            dd: date.getDate(),\n            HH: date.getHours(),\n            mm: date.getMinutes(),\n            ss: date.getSeconds(),\n            sss: date.getMilliseconds() / 1000\n          };\n        } else {\n          map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 };\n        }\n\n        forEach(parts, function(part, index) {\n          if (index < mapping.length) {\n            map[mapping[index]] = +part;\n          }\n        });\n        return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm, map.ss || 0, map.sss * 1000 || 0);\n      }\n    }\n\n    return NaN;\n  };\n}\n\nfunction createDateInputType(type, regexp, parseDate, format) {\n  return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) {\n    badInputChecker(scope, element, attr, ctrl);\n    baseInputType(scope, element, attr, ctrl, $sniffer, $browser);\n    var timezone = ctrl && ctrl.$options && ctrl.$options.timezone;\n    var previousDate;\n\n    ctrl.$$parserName = type;\n    ctrl.$parsers.push(function(value) {\n      if (ctrl.$isEmpty(value)) return null;\n      if (regexp.test(value)) {\n        // Note: We cannot read ctrl.$modelValue, as there might be a different\n        // parser/formatter in the processing chain so that the model\n        // contains some different data format!\n        var parsedDate = parseDate(value, previousDate);\n        if (timezone) {\n          parsedDate = convertTimezoneToLocal(parsedDate, timezone);\n        }\n        return parsedDate;\n      }\n      return undefined;\n    });\n\n    ctrl.$formatters.push(function(value) {\n      if (value && !isDate(value)) {\n        throw ngModelMinErr('datefmt', 'Expected `{0}` to be a date', value);\n      }\n      if (isValidDate(value)) {\n        previousDate = value;\n        if (previousDate && timezone) {\n          previousDate = convertTimezoneToLocal(previousDate, timezone, true);\n        }\n        return $filter('date')(value, format, timezone);\n      } else {\n        previousDate = null;\n        return '';\n      }\n    });\n\n    if (isDefined(attr.min) || attr.ngMin) {\n      var minVal;\n      ctrl.$validators.min = function(value) {\n        return !isValidDate(value) || isUndefined(minVal) || parseDate(value) >= minVal;\n      };\n      attr.$observe('min', function(val) {\n        minVal = parseObservedDateValue(val);\n        ctrl.$validate();\n      });\n    }\n\n    if (isDefined(attr.max) || attr.ngMax) {\n      var maxVal;\n      ctrl.$validators.max = function(value) {\n        return !isValidDate(value) || isUndefined(maxVal) || parseDate(value) <= maxVal;\n      };\n      attr.$observe('max', function(val) {\n        maxVal = parseObservedDateValue(val);\n        ctrl.$validate();\n      });\n    }\n\n    function isValidDate(value) {\n      // Invalid Date: getTime() returns NaN\n      return value && !(value.getTime && value.getTime() !== value.getTime());\n    }\n\n    function parseObservedDateValue(val) {\n      return isDefined(val) && !isDate(val) ? parseDate(val) || undefined : val;\n    }\n  };\n}\n\nfunction badInputChecker(scope, element, attr, ctrl) {\n  var node = element[0];\n  var nativeValidation = ctrl.$$hasNativeValidators = isObject(node.validity);\n  if (nativeValidation) {\n    ctrl.$parsers.push(function(value) {\n      var validity = element.prop(VALIDITY_STATE_PROPERTY) || {};\n      return validity.badInput || validity.typeMismatch ? undefined : value;\n    });\n  }\n}\n\nfunction numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {\n  badInputChecker(scope, element, attr, ctrl);\n  baseInputType(scope, element, attr, ctrl, $sniffer, $browser);\n\n  ctrl.$$parserName = 'number';\n  ctrl.$parsers.push(function(value) {\n    if (ctrl.$isEmpty(value))      return null;\n    if (NUMBER_REGEXP.test(value)) return parseFloat(value);\n    return undefined;\n  });\n\n  ctrl.$formatters.push(function(value) {\n    if (!ctrl.$isEmpty(value)) {\n      if (!isNumber(value)) {\n        throw ngModelMinErr('numfmt', 'Expected `{0}` to be a number', value);\n      }\n      value = value.toString();\n    }\n    return value;\n  });\n\n  if (isDefined(attr.min) || attr.ngMin) {\n    var minVal;\n    ctrl.$validators.min = function(value) {\n      return ctrl.$isEmpty(value) || isUndefined(minVal) || value >= minVal;\n    };\n\n    attr.$observe('min', function(val) {\n      if (isDefined(val) && !isNumber(val)) {\n        val = parseFloat(val, 10);\n      }\n      minVal = isNumber(val) && !isNaN(val) ? val : undefined;\n      // TODO(matsko): implement validateLater to reduce number of validations\n      ctrl.$validate();\n    });\n  }\n\n  if (isDefined(attr.max) || attr.ngMax) {\n    var maxVal;\n    ctrl.$validators.max = function(value) {\n      return ctrl.$isEmpty(value) || isUndefined(maxVal) || value <= maxVal;\n    };\n\n    attr.$observe('max', function(val) {\n      if (isDefined(val) && !isNumber(val)) {\n        val = parseFloat(val, 10);\n      }\n      maxVal = isNumber(val) && !isNaN(val) ? val : undefined;\n      // TODO(matsko): implement validateLater to reduce number of validations\n      ctrl.$validate();\n    });\n  }\n}\n\nfunction urlInputType(scope, element, attr, ctrl, $sniffer, $browser) {\n  // Note: no badInputChecker here by purpose as `url` is only a validation\n  // in browsers, i.e. we can always read out input.value even if it is not valid!\n  baseInputType(scope, element, attr, ctrl, $sniffer, $browser);\n  stringBasedInputType(ctrl);\n\n  ctrl.$$parserName = 'url';\n  ctrl.$validators.url = function(modelValue, viewValue) {\n    var value = modelValue || viewValue;\n    return ctrl.$isEmpty(value) || URL_REGEXP.test(value);\n  };\n}\n\nfunction emailInputType(scope, element, attr, ctrl, $sniffer, $browser) {\n  // Note: no badInputChecker here by purpose as `url` is only a validation\n  // in browsers, i.e. we can always read out input.value even if it is not valid!\n  baseInputType(scope, element, attr, ctrl, $sniffer, $browser);\n  stringBasedInputType(ctrl);\n\n  ctrl.$$parserName = 'email';\n  ctrl.$validators.email = function(modelValue, viewValue) {\n    var value = modelValue || viewValue;\n    return ctrl.$isEmpty(value) || EMAIL_REGEXP.test(value);\n  };\n}\n\nfunction radioInputType(scope, element, attr, ctrl) {\n  // make the name unique, if not defined\n  if (isUndefined(attr.name)) {\n    element.attr('name', nextUid());\n  }\n\n  var listener = function(ev) {\n    if (element[0].checked) {\n      ctrl.$setViewValue(attr.value, ev && ev.type);\n    }\n  };\n\n  element.on('click', listener);\n\n  ctrl.$render = function() {\n    var value = attr.value;\n    element[0].checked = (value == ctrl.$viewValue);\n  };\n\n  attr.$observe('value', ctrl.$render);\n}\n\nfunction parseConstantExpr($parse, context, name, expression, fallback) {\n  var parseFn;\n  if (isDefined(expression)) {\n    parseFn = $parse(expression);\n    if (!parseFn.constant) {\n      throw ngModelMinErr('constexpr', 'Expected constant expression for `{0}`, but saw ' +\n                                   '`{1}`.', name, expression);\n    }\n    return parseFn(context);\n  }\n  return fallback;\n}\n\nfunction checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter, $parse) {\n  var trueValue = parseConstantExpr($parse, scope, 'ngTrueValue', attr.ngTrueValue, true);\n  var falseValue = parseConstantExpr($parse, scope, 'ngFalseValue', attr.ngFalseValue, false);\n\n  var listener = function(ev) {\n    ctrl.$setViewValue(element[0].checked, ev && ev.type);\n  };\n\n  element.on('click', listener);\n\n  ctrl.$render = function() {\n    element[0].checked = ctrl.$viewValue;\n  };\n\n  // Override the standard `$isEmpty` because the $viewValue of an empty checkbox is always set to `false`\n  // This is because of the parser below, which compares the `$modelValue` with `trueValue` to convert\n  // it to a boolean.\n  ctrl.$isEmpty = function(value) {\n    return value === false;\n  };\n\n  ctrl.$formatters.push(function(value) {\n    return equals(value, trueValue);\n  });\n\n  ctrl.$parsers.push(function(value) {\n    return value ? trueValue : falseValue;\n  });\n}\n\n\n/**\n * @ngdoc directive\n * @name textarea\n * @restrict E\n *\n * @description\n * HTML textarea element control with angular data-binding. The data-binding and validation\n * properties of this element are exactly the same as those of the\n * {@link ng.directive:input input element}.\n *\n * @param {string} ngModel Assignable angular expression to data-bind to.\n * @param {string=} name Property name of the form under which the control is published.\n * @param {string=} required Sets `required` validation error key if the value is not entered.\n * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n *    `required` when you want to data-bind to the `required` attribute.\n * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n *    minlength.\n * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of any\n *    length.\n * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n *    does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n *    If the expression evaluates to a RegExp object, then this is used directly.\n *    If the expression evaluates to a string, then it will be converted to a RegExp\n *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n *    `new RegExp('^abc$')`.<br />\n *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n *    start at the index of the last search's match, thus not taking the whole input value into\n *    account.\n * @param {string=} ngChange Angular expression to be executed when input changes due to user\n *    interaction with the input element.\n * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input.\n */\n\n\n/**\n * @ngdoc directive\n * @name input\n * @restrict E\n *\n * @description\n * HTML input element control. When used together with {@link ngModel `ngModel`}, it provides data-binding,\n * input state control, and validation.\n * Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers.\n *\n * <div class=\"alert alert-warning\">\n * **Note:** Not every feature offered is available for all input types.\n * Specifically, data binding and event handling via `ng-model` is unsupported for `input[file]`.\n * </div>\n *\n * @param {string} ngModel Assignable angular expression to data-bind to.\n * @param {string=} name Property name of the form under which the control is published.\n * @param {string=} required Sets `required` validation error key if the value is not entered.\n * @param {boolean=} ngRequired Sets `required` attribute if set to true\n * @param {number=} ngMinlength Sets `minlength` validation error key if the value is shorter than\n *    minlength.\n * @param {number=} ngMaxlength Sets `maxlength` validation error key if the value is longer than\n *    maxlength. Setting the attribute to a negative or non-numeric value, allows view values of any\n *    length.\n * @param {string=} ngPattern Sets `pattern` validation error key if the ngModel {@link ngModel.NgModelController#$viewValue $viewValue}\n *    value does not match a RegExp found by evaluating the Angular expression given in the attribute value.\n *    If the expression evaluates to a RegExp object, then this is used directly.\n *    If the expression evaluates to a string, then it will be converted to a RegExp\n *    after wrapping it in `^` and `$` characters. For instance, `\"abc\"` will be converted to\n *    `new RegExp('^abc$')`.<br />\n *    **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n *    start at the index of the last search's match, thus not taking the whole input value into\n *    account.\n * @param {string=} ngChange Angular expression to be executed when input changes due to user\n *    interaction with the input element.\n * @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input.\n *    This parameter is ignored for input[type=password] controls, which will never trim the\n *    input.\n *\n * @example\n    <example name=\"input-directive\" module=\"inputExample\">\n      <file name=\"index.html\">\n       <script>\n          angular.module('inputExample', [])\n            .controller('ExampleController', ['$scope', function($scope) {\n              $scope.user = {name: 'guest', last: 'visitor'};\n            }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <form name=\"myForm\">\n           <label>\n              User name:\n              <input type=\"text\" name=\"userName\" ng-model=\"user.name\" required>\n           </label>\n           <div role=\"alert\">\n             <span class=\"error\" ng-show=\"myForm.userName.$error.required\">\n              Required!</span>\n           </div>\n           <label>\n              Last name:\n              <input type=\"text\" name=\"lastName\" ng-model=\"user.last\"\n              ng-minlength=\"3\" ng-maxlength=\"10\">\n           </label>\n           <div role=\"alert\">\n             <span class=\"error\" ng-show=\"myForm.lastName.$error.minlength\">\n               Too short!</span>\n             <span class=\"error\" ng-show=\"myForm.lastName.$error.maxlength\">\n               Too long!</span>\n           </div>\n         </form>\n         <hr>\n         <tt>user = {{user}}</tt><br/>\n         <tt>myForm.userName.$valid = {{myForm.userName.$valid}}</tt><br/>\n         <tt>myForm.userName.$error = {{myForm.userName.$error}}</tt><br/>\n         <tt>myForm.lastName.$valid = {{myForm.lastName.$valid}}</tt><br/>\n         <tt>myForm.lastName.$error = {{myForm.lastName.$error}}</tt><br/>\n         <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n         <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n         <tt>myForm.$error.minlength = {{!!myForm.$error.minlength}}</tt><br/>\n         <tt>myForm.$error.maxlength = {{!!myForm.$error.maxlength}}</tt><br/>\n       </div>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        var user = element(by.exactBinding('user'));\n        var userNameValid = element(by.binding('myForm.userName.$valid'));\n        var lastNameValid = element(by.binding('myForm.lastName.$valid'));\n        var lastNameError = element(by.binding('myForm.lastName.$error'));\n        var formValid = element(by.binding('myForm.$valid'));\n        var userNameInput = element(by.model('user.name'));\n        var userLastInput = element(by.model('user.last'));\n\n        it('should initialize to model', function() {\n          expect(user.getText()).toContain('{\"name\":\"guest\",\"last\":\"visitor\"}');\n          expect(userNameValid.getText()).toContain('true');\n          expect(formValid.getText()).toContain('true');\n        });\n\n        it('should be invalid if empty when required', function() {\n          userNameInput.clear();\n          userNameInput.sendKeys('');\n\n          expect(user.getText()).toContain('{\"last\":\"visitor\"}');\n          expect(userNameValid.getText()).toContain('false');\n          expect(formValid.getText()).toContain('false');\n        });\n\n        it('should be valid if empty when min length is set', function() {\n          userLastInput.clear();\n          userLastInput.sendKeys('');\n\n          expect(user.getText()).toContain('{\"name\":\"guest\",\"last\":\"\"}');\n          expect(lastNameValid.getText()).toContain('true');\n          expect(formValid.getText()).toContain('true');\n        });\n\n        it('should be invalid if less than required min length', function() {\n          userLastInput.clear();\n          userLastInput.sendKeys('xx');\n\n          expect(user.getText()).toContain('{\"name\":\"guest\"}');\n          expect(lastNameValid.getText()).toContain('false');\n          expect(lastNameError.getText()).toContain('minlength');\n          expect(formValid.getText()).toContain('false');\n        });\n\n        it('should be invalid if longer than max length', function() {\n          userLastInput.clear();\n          userLastInput.sendKeys('some ridiculously long name');\n\n          expect(user.getText()).toContain('{\"name\":\"guest\"}');\n          expect(lastNameValid.getText()).toContain('false');\n          expect(lastNameError.getText()).toContain('maxlength');\n          expect(formValid.getText()).toContain('false');\n        });\n      </file>\n    </example>\n */\nvar inputDirective = ['$browser', '$sniffer', '$filter', '$parse',\n    function($browser, $sniffer, $filter, $parse) {\n  return {\n    restrict: 'E',\n    require: ['?ngModel'],\n    link: {\n      pre: function(scope, element, attr, ctrls) {\n        if (ctrls[0]) {\n          (inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrls[0], $sniffer,\n                                                              $browser, $filter, $parse);\n        }\n      }\n    }\n  };\n}];\n\n\n\nvar CONSTANT_VALUE_REGEXP = /^(true|false|\\d+)$/;\n/**\n * @ngdoc directive\n * @name ngValue\n *\n * @description\n * Binds the given expression to the value of `<option>` or {@link input[radio] `input[radio]`},\n * so that when the element is selected, the {@link ngModel `ngModel`} of that element is set to\n * the bound value.\n *\n * `ngValue` is useful when dynamically generating lists of radio buttons using\n * {@link ngRepeat `ngRepeat`}, as shown below.\n *\n * Likewise, `ngValue` can be used to generate `<option>` elements for\n * the {@link select `select`} element. In that case however, only strings are supported\n * for the `value `attribute, so the resulting `ngModel` will always be a string.\n * Support for `select` models with non-string values is available via `ngOptions`.\n *\n * @element input\n * @param {string=} ngValue angular expression, whose value will be bound to the `value` attribute\n *   of the `input` element\n *\n * @example\n    <example name=\"ngValue-directive\" module=\"valueExample\">\n      <file name=\"index.html\">\n       <script>\n          angular.module('valueExample', [])\n            .controller('ExampleController', ['$scope', function($scope) {\n              $scope.names = ['pizza', 'unicorns', 'robots'];\n              $scope.my = { favorite: 'unicorns' };\n            }]);\n       </script>\n        <form ng-controller=\"ExampleController\">\n          <h2>Which is your favorite?</h2>\n            <label ng-repeat=\"name in names\" for=\"{{name}}\">\n              {{name}}\n              <input type=\"radio\"\n                     ng-model=\"my.favorite\"\n                     ng-value=\"name\"\n                     id=\"{{name}}\"\n                     name=\"favorite\">\n            </label>\n          <div>You chose {{my.favorite}}</div>\n        </form>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        var favorite = element(by.binding('my.favorite'));\n\n        it('should initialize to model', function() {\n          expect(favorite.getText()).toContain('unicorns');\n        });\n        it('should bind the values to the inputs', function() {\n          element.all(by.model('my.favorite')).get(0).click();\n          expect(favorite.getText()).toContain('pizza');\n        });\n      </file>\n    </example>\n */\nvar ngValueDirective = function() {\n  return {\n    restrict: 'A',\n    priority: 100,\n    compile: function(tpl, tplAttr) {\n      if (CONSTANT_VALUE_REGEXP.test(tplAttr.ngValue)) {\n        return function ngValueConstantLink(scope, elm, attr) {\n          attr.$set('value', scope.$eval(attr.ngValue));\n        };\n      } else {\n        return function ngValueLink(scope, elm, attr) {\n          scope.$watch(attr.ngValue, function valueWatchAction(value) {\n            attr.$set('value', value);\n          });\n        };\n      }\n    }\n  };\n};\n\n/**\n * @ngdoc directive\n * @name ngBind\n * @restrict AC\n *\n * @description\n * The `ngBind` attribute tells Angular to replace the text content of the specified HTML element\n * with the value of a given expression, and to update the text content when the value of that\n * expression changes.\n *\n * Typically, you don't use `ngBind` directly, but instead you use the double curly markup like\n * `{{ expression }}` which is similar but less verbose.\n *\n * It is preferable to use `ngBind` instead of `{{ expression }}` if a template is momentarily\n * displayed by the browser in its raw state before Angular compiles it. Since `ngBind` is an\n * element attribute, it makes the bindings invisible to the user while the page is loading.\n *\n * An alternative solution to this problem would be using the\n * {@link ng.directive:ngCloak ngCloak} directive.\n *\n *\n * @element ANY\n * @param {expression} ngBind {@link guide/expression Expression} to evaluate.\n *\n * @example\n * Enter a name in the Live Preview text box; the greeting below the text box changes instantly.\n   <example module=\"bindExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('bindExample', [])\n           .controller('ExampleController', ['$scope', function($scope) {\n             $scope.name = 'Whirled';\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n         <label>Enter name: <input type=\"text\" ng-model=\"name\"></label><br>\n         Hello <span ng-bind=\"name\"></span>!\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-bind', function() {\n         var nameInput = element(by.model('name'));\n\n         expect(element(by.binding('name')).getText()).toBe('Whirled');\n         nameInput.clear();\n         nameInput.sendKeys('world');\n         expect(element(by.binding('name')).getText()).toBe('world');\n       });\n     </file>\n   </example>\n */\nvar ngBindDirective = ['$compile', function($compile) {\n  return {\n    restrict: 'AC',\n    compile: function ngBindCompile(templateElement) {\n      $compile.$$addBindingClass(templateElement);\n      return function ngBindLink(scope, element, attr) {\n        $compile.$$addBindingInfo(element, attr.ngBind);\n        element = element[0];\n        scope.$watch(attr.ngBind, function ngBindWatchAction(value) {\n          element.textContent = isUndefined(value) ? '' : value;\n        });\n      };\n    }\n  };\n}];\n\n\n/**\n * @ngdoc directive\n * @name ngBindTemplate\n *\n * @description\n * The `ngBindTemplate` directive specifies that the element\n * text content should be replaced with the interpolation of the template\n * in the `ngBindTemplate` attribute.\n * Unlike `ngBind`, the `ngBindTemplate` can contain multiple `{{` `}}`\n * expressions. This directive is needed since some HTML elements\n * (such as TITLE and OPTION) cannot contain SPAN elements.\n *\n * @element ANY\n * @param {string} ngBindTemplate template of form\n *   <tt>{{</tt> <tt>expression</tt> <tt>}}</tt> to eval.\n *\n * @example\n * Try it here: enter text in text box and watch the greeting change.\n   <example module=\"bindExample\">\n     <file name=\"index.html\">\n       <script>\n         angular.module('bindExample', [])\n           .controller('ExampleController', ['$scope', function($scope) {\n             $scope.salutation = 'Hello';\n             $scope.name = 'World';\n           }]);\n       </script>\n       <div ng-controller=\"ExampleController\">\n        <label>Salutation: <input type=\"text\" ng-model=\"salutation\"></label><br>\n        <label>Name: <input type=\"text\" ng-model=\"name\"></label><br>\n        <pre ng-bind-template=\"{{salutation}} {{name}}!\"></pre>\n       </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-bind', function() {\n         var salutationElem = element(by.binding('salutation'));\n         var salutationInput = element(by.model('salutation'));\n         var nameInput = element(by.model('name'));\n\n         expect(salutationElem.getText()).toBe('Hello World!');\n\n         salutationInput.clear();\n         salutationInput.sendKeys('Greetings');\n         nameInput.clear();\n         nameInput.sendKeys('user');\n\n         expect(salutationElem.getText()).toBe('Greetings user!');\n       });\n     </file>\n   </example>\n */\nvar ngBindTemplateDirective = ['$interpolate', '$compile', function($interpolate, $compile) {\n  return {\n    compile: function ngBindTemplateCompile(templateElement) {\n      $compile.$$addBindingClass(templateElement);\n      return function ngBindTemplateLink(scope, element, attr) {\n        var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate));\n        $compile.$$addBindingInfo(element, interpolateFn.expressions);\n        element = element[0];\n        attr.$observe('ngBindTemplate', function(value) {\n          element.textContent = isUndefined(value) ? '' : value;\n        });\n      };\n    }\n  };\n}];\n\n\n/**\n * @ngdoc directive\n * @name ngBindHtml\n *\n * @description\n * Evaluates the expression and inserts the resulting HTML into the element in a secure way. By default,\n * the resulting HTML content will be sanitized using the {@link ngSanitize.$sanitize $sanitize} service.\n * To utilize this functionality, ensure that `$sanitize` is available, for example, by including {@link\n * ngSanitize} in your module's dependencies (not in core Angular). In order to use {@link ngSanitize}\n * in your module's dependencies, you need to include \"angular-sanitize.js\" in your application.\n *\n * You may also bypass sanitization for values you know are safe. To do so, bind to\n * an explicitly trusted value via {@link ng.$sce#trustAsHtml $sce.trustAsHtml}.  See the example\n * under {@link ng.$sce#show-me-an-example-using-sce- Strict Contextual Escaping (SCE)}.\n *\n * Note: If a `$sanitize` service is unavailable and the bound value isn't explicitly trusted, you\n * will have an exception (instead of an exploit.)\n *\n * @element ANY\n * @param {expression} ngBindHtml {@link guide/expression Expression} to evaluate.\n *\n * @example\n\n   <example module=\"bindHtmlExample\" deps=\"angular-sanitize.js\">\n     <file name=\"index.html\">\n       <div ng-controller=\"ExampleController\">\n        <p ng-bind-html=\"myHTML\"></p>\n       </div>\n     </file>\n\n     <file name=\"script.js\">\n       angular.module('bindHtmlExample', ['ngSanitize'])\n         .controller('ExampleController', ['$scope', function($scope) {\n           $scope.myHTML =\n              'I am an <code>HTML</code>string with ' +\n              '<a href=\"#\">links!</a> and other <em>stuff</em>';\n         }]);\n     </file>\n\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-bind-html', function() {\n         expect(element(by.binding('myHTML')).getText()).toBe(\n             'I am an HTMLstring with links! and other stuff');\n       });\n     </file>\n   </example>\n */\nvar ngBindHtmlDirective = ['$sce', '$parse', '$compile', function($sce, $parse, $compile) {\n  return {\n    restrict: 'A',\n    compile: function ngBindHtmlCompile(tElement, tAttrs) {\n      var ngBindHtmlGetter = $parse(tAttrs.ngBindHtml);\n      var ngBindHtmlWatch = $parse(tAttrs.ngBindHtml, function getStringValue(value) {\n        return (value || '').toString();\n      });\n      $compile.$$addBindingClass(tElement);\n\n      return function ngBindHtmlLink(scope, element, attr) {\n        $compile.$$addBindingInfo(element, attr.ngBindHtml);\n\n        scope.$watch(ngBindHtmlWatch, function ngBindHtmlWatchAction() {\n          // we re-evaluate the expr because we want a TrustedValueHolderType\n          // for $sce, not a string\n          element.html($sce.getTrustedHtml(ngBindHtmlGetter(scope)) || '');\n        });\n      };\n    }\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngChange\n *\n * @description\n * Evaluate the given expression when the user changes the input.\n * The expression is evaluated immediately, unlike the JavaScript onchange event\n * which only triggers at the end of a change (usually, when the user leaves the\n * form element or presses the return key).\n *\n * The `ngChange` expression is only evaluated when a change in the input value causes\n * a new value to be committed to the model.\n *\n * It will not be evaluated:\n * * if the value returned from the `$parsers` transformation pipeline has not changed\n * * if the input has continued to be invalid since the model will stay `null`\n * * if the model is changed programmatically and not by a change to the input value\n *\n *\n * Note, this directive requires `ngModel` to be present.\n *\n * @element input\n * @param {expression} ngChange {@link guide/expression Expression} to evaluate upon change\n * in input value.\n *\n * @example\n * <example name=\"ngChange-directive\" module=\"changeExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('changeExample', [])\n *         .controller('ExampleController', ['$scope', function($scope) {\n *           $scope.counter = 0;\n *           $scope.change = function() {\n *             $scope.counter++;\n *           };\n *         }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <input type=\"checkbox\" ng-model=\"confirmed\" ng-change=\"change()\" id=\"ng-change-example1\" />\n *       <input type=\"checkbox\" ng-model=\"confirmed\" id=\"ng-change-example2\" />\n *       <label for=\"ng-change-example2\">Confirmed</label><br />\n *       <tt>debug = {{confirmed}}</tt><br/>\n *       <tt>counter = {{counter}}</tt><br/>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *     var counter = element(by.binding('counter'));\n *     var debug = element(by.binding('confirmed'));\n *\n *     it('should evaluate the expression if changing from view', function() {\n *       expect(counter.getText()).toContain('0');\n *\n *       element(by.id('ng-change-example1')).click();\n *\n *       expect(counter.getText()).toContain('1');\n *       expect(debug.getText()).toContain('true');\n *     });\n *\n *     it('should not evaluate the expression if changing from model', function() {\n *       element(by.id('ng-change-example2')).click();\n\n *       expect(counter.getText()).toContain('0');\n *       expect(debug.getText()).toContain('true');\n *     });\n *   </file>\n * </example>\n */\nvar ngChangeDirective = valueFn({\n  restrict: 'A',\n  require: 'ngModel',\n  link: function(scope, element, attr, ctrl) {\n    ctrl.$viewChangeListeners.push(function() {\n      scope.$eval(attr.ngChange);\n    });\n  }\n});\n\nfunction classDirective(name, selector) {\n  name = 'ngClass' + name;\n  return ['$animate', function($animate) {\n    return {\n      restrict: 'AC',\n      link: function(scope, element, attr) {\n        var oldVal;\n\n        scope.$watch(attr[name], ngClassWatchAction, true);\n\n        attr.$observe('class', function(value) {\n          ngClassWatchAction(scope.$eval(attr[name]));\n        });\n\n\n        if (name !== 'ngClass') {\n          scope.$watch('$index', function($index, old$index) {\n            // jshint bitwise: false\n            var mod = $index & 1;\n            if (mod !== (old$index & 1)) {\n              var classes = arrayClasses(scope.$eval(attr[name]));\n              mod === selector ?\n                addClasses(classes) :\n                removeClasses(classes);\n            }\n          });\n        }\n\n        function addClasses(classes) {\n          var newClasses = digestClassCounts(classes, 1);\n          attr.$addClass(newClasses);\n        }\n\n        function removeClasses(classes) {\n          var newClasses = digestClassCounts(classes, -1);\n          attr.$removeClass(newClasses);\n        }\n\n        function digestClassCounts(classes, count) {\n          // Use createMap() to prevent class assumptions involving property\n          // names in Object.prototype\n          var classCounts = element.data('$classCounts') || createMap();\n          var classesToUpdate = [];\n          forEach(classes, function(className) {\n            if (count > 0 || classCounts[className]) {\n              classCounts[className] = (classCounts[className] || 0) + count;\n              if (classCounts[className] === +(count > 0)) {\n                classesToUpdate.push(className);\n              }\n            }\n          });\n          element.data('$classCounts', classCounts);\n          return classesToUpdate.join(' ');\n        }\n\n        function updateClasses(oldClasses, newClasses) {\n          var toAdd = arrayDifference(newClasses, oldClasses);\n          var toRemove = arrayDifference(oldClasses, newClasses);\n          toAdd = digestClassCounts(toAdd, 1);\n          toRemove = digestClassCounts(toRemove, -1);\n          if (toAdd && toAdd.length) {\n            $animate.addClass(element, toAdd);\n          }\n          if (toRemove && toRemove.length) {\n            $animate.removeClass(element, toRemove);\n          }\n        }\n\n        function ngClassWatchAction(newVal) {\n          if (selector === true || scope.$index % 2 === selector) {\n            var newClasses = arrayClasses(newVal || []);\n            if (!oldVal) {\n              addClasses(newClasses);\n            } else if (!equals(newVal,oldVal)) {\n              var oldClasses = arrayClasses(oldVal);\n              updateClasses(oldClasses, newClasses);\n            }\n          }\n          if (isArray(newVal)) {\n            oldVal = newVal.map(function(v) { return shallowCopy(v); });\n          } else {\n            oldVal = shallowCopy(newVal);\n          }\n        }\n      }\n    };\n\n    function arrayDifference(tokens1, tokens2) {\n      var values = [];\n\n      outer:\n      for (var i = 0; i < tokens1.length; i++) {\n        var token = tokens1[i];\n        for (var j = 0; j < tokens2.length; j++) {\n          if (token == tokens2[j]) continue outer;\n        }\n        values.push(token);\n      }\n      return values;\n    }\n\n    function arrayClasses(classVal) {\n      var classes = [];\n      if (isArray(classVal)) {\n        forEach(classVal, function(v) {\n          classes = classes.concat(arrayClasses(v));\n        });\n        return classes;\n      } else if (isString(classVal)) {\n        return classVal.split(' ');\n      } else if (isObject(classVal)) {\n        forEach(classVal, function(v, k) {\n          if (v) {\n            classes = classes.concat(k.split(' '));\n          }\n        });\n        return classes;\n      }\n      return classVal;\n    }\n  }];\n}\n\n/**\n * @ngdoc directive\n * @name ngClass\n * @restrict AC\n *\n * @description\n * The `ngClass` directive allows you to dynamically set CSS classes on an HTML element by databinding\n * an expression that represents all classes to be added.\n *\n * The directive operates in three different ways, depending on which of three types the expression\n * evaluates to:\n *\n * 1. If the expression evaluates to a string, the string should be one or more space-delimited class\n * names.\n *\n * 2. If the expression evaluates to an object, then for each key-value pair of the\n * object with a truthy value the corresponding key is used as a class name.\n *\n * 3. If the expression evaluates to an array, each element of the array should either be a string as in\n * type 1 or an object as in type 2. This means that you can mix strings and objects together in an array\n * to give you more control over what CSS classes appear. See the code below for an example of this.\n *\n *\n * The directive won't add duplicate classes if a particular class was already set.\n *\n * When the expression changes, the previously added classes are removed and only then are the\n * new classes added.\n *\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link ng.$animate#addClass addClass}       | just before the class is applied to the element   |\n * | {@link ng.$animate#removeClass removeClass} | just before the class is removed from the element |\n *\n * @element ANY\n * @param {expression} ngClass {@link guide/expression Expression} to eval. The result\n *   of the evaluation can be a string representing space delimited class\n *   names, an array, or a map of class names to boolean values. In the case of a map, the\n *   names of the properties whose values are truthy will be added as css classes to the\n *   element.\n *\n * @example Example that demonstrates basic bindings via ngClass directive.\n   <example>\n     <file name=\"index.html\">\n       <p ng-class=\"{strike: deleted, bold: important, 'has-error': error}\">Map Syntax Example</p>\n       <label>\n          <input type=\"checkbox\" ng-model=\"deleted\">\n          deleted (apply \"strike\" class)\n       </label><br>\n       <label>\n          <input type=\"checkbox\" ng-model=\"important\">\n          important (apply \"bold\" class)\n       </label><br>\n       <label>\n          <input type=\"checkbox\" ng-model=\"error\">\n          error (apply \"has-error\" class)\n       </label>\n       <hr>\n       <p ng-class=\"style\">Using String Syntax</p>\n       <input type=\"text\" ng-model=\"style\"\n              placeholder=\"Type: bold strike red\" aria-label=\"Type: bold strike red\">\n       <hr>\n       <p ng-class=\"[style1, style2, style3]\">Using Array Syntax</p>\n       <input ng-model=\"style1\"\n              placeholder=\"Type: bold, strike or red\" aria-label=\"Type: bold, strike or red\"><br>\n       <input ng-model=\"style2\"\n              placeholder=\"Type: bold, strike or red\" aria-label=\"Type: bold, strike or red 2\"><br>\n       <input ng-model=\"style3\"\n              placeholder=\"Type: bold, strike or red\" aria-label=\"Type: bold, strike or red 3\"><br>\n       <hr>\n       <p ng-class=\"[style4, {orange: warning}]\">Using Array and Map Syntax</p>\n       <input ng-model=\"style4\" placeholder=\"Type: bold, strike\" aria-label=\"Type: bold, strike\"><br>\n       <label><input type=\"checkbox\" ng-model=\"warning\"> warning (apply \"orange\" class)</label>\n     </file>\n     <file name=\"style.css\">\n       .strike {\n           text-decoration: line-through;\n       }\n       .bold {\n           font-weight: bold;\n       }\n       .red {\n           color: red;\n       }\n       .has-error {\n           color: red;\n           background-color: yellow;\n       }\n       .orange {\n           color: orange;\n       }\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       var ps = element.all(by.css('p'));\n\n       it('should let you toggle the class', function() {\n\n         expect(ps.first().getAttribute('class')).not.toMatch(/bold/);\n         expect(ps.first().getAttribute('class')).not.toMatch(/has-error/);\n\n         element(by.model('important')).click();\n         expect(ps.first().getAttribute('class')).toMatch(/bold/);\n\n         element(by.model('error')).click();\n         expect(ps.first().getAttribute('class')).toMatch(/has-error/);\n       });\n\n       it('should let you toggle string example', function() {\n         expect(ps.get(1).getAttribute('class')).toBe('');\n         element(by.model('style')).clear();\n         element(by.model('style')).sendKeys('red');\n         expect(ps.get(1).getAttribute('class')).toBe('red');\n       });\n\n       it('array example should have 3 classes', function() {\n         expect(ps.get(2).getAttribute('class')).toBe('');\n         element(by.model('style1')).sendKeys('bold');\n         element(by.model('style2')).sendKeys('strike');\n         element(by.model('style3')).sendKeys('red');\n         expect(ps.get(2).getAttribute('class')).toBe('bold strike red');\n       });\n\n       it('array with map example should have 2 classes', function() {\n         expect(ps.last().getAttribute('class')).toBe('');\n         element(by.model('style4')).sendKeys('bold');\n         element(by.model('warning')).click();\n         expect(ps.last().getAttribute('class')).toBe('bold orange');\n       });\n     </file>\n   </example>\n\n   ## Animations\n\n   The example below demonstrates how to perform animations using ngClass.\n\n   <example module=\"ngAnimate\" deps=\"angular-animate.js\" animations=\"true\">\n     <file name=\"index.html\">\n      <input id=\"setbtn\" type=\"button\" value=\"set\" ng-click=\"myVar='my-class'\">\n      <input id=\"clearbtn\" type=\"button\" value=\"clear\" ng-click=\"myVar=''\">\n      <br>\n      <span class=\"base-class\" ng-class=\"myVar\">Sample Text</span>\n     </file>\n     <file name=\"style.css\">\n       .base-class {\n         transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;\n       }\n\n       .base-class.my-class {\n         color: red;\n         font-size:3em;\n       }\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-class', function() {\n         expect(element(by.css('.base-class')).getAttribute('class')).not.\n           toMatch(/my-class/);\n\n         element(by.id('setbtn')).click();\n\n         expect(element(by.css('.base-class')).getAttribute('class')).\n           toMatch(/my-class/);\n\n         element(by.id('clearbtn')).click();\n\n         expect(element(by.css('.base-class')).getAttribute('class')).not.\n           toMatch(/my-class/);\n       });\n     </file>\n   </example>\n\n\n   ## ngClass and pre-existing CSS3 Transitions/Animations\n   The ngClass directive still supports CSS3 Transitions/Animations even if they do not follow the ngAnimate CSS naming structure.\n   Upon animation ngAnimate will apply supplementary CSS classes to track the start and end of an animation, but this will not hinder\n   any pre-existing CSS transitions already on the element. To get an idea of what happens during a class-based animation, be sure\n   to view the step by step details of {@link $animate#addClass $animate.addClass} and\n   {@link $animate#removeClass $animate.removeClass}.\n */\nvar ngClassDirective = classDirective('', true);\n\n/**\n * @ngdoc directive\n * @name ngClassOdd\n * @restrict AC\n *\n * @description\n * The `ngClassOdd` and `ngClassEven` directives work exactly as\n * {@link ng.directive:ngClass ngClass}, except they work in\n * conjunction with `ngRepeat` and take effect only on odd (even) rows.\n *\n * This directive can be applied only within the scope of an\n * {@link ng.directive:ngRepeat ngRepeat}.\n *\n * @element ANY\n * @param {expression} ngClassOdd {@link guide/expression Expression} to eval. The result\n *   of the evaluation can be a string representing space delimited class names or an array.\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n        <ol ng-init=\"names=['John', 'Mary', 'Cate', 'Suz']\">\n          <li ng-repeat=\"name in names\">\n           <span ng-class-odd=\"'odd'\" ng-class-even=\"'even'\">\n             {{name}}\n           </span>\n          </li>\n        </ol>\n     </file>\n     <file name=\"style.css\">\n       .odd {\n         color: red;\n       }\n       .even {\n         color: blue;\n       }\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-class-odd and ng-class-even', function() {\n         expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).\n           toMatch(/odd/);\n         expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')).\n           toMatch(/even/);\n       });\n     </file>\n   </example>\n */\nvar ngClassOddDirective = classDirective('Odd', 0);\n\n/**\n * @ngdoc directive\n * @name ngClassEven\n * @restrict AC\n *\n * @description\n * The `ngClassOdd` and `ngClassEven` directives work exactly as\n * {@link ng.directive:ngClass ngClass}, except they work in\n * conjunction with `ngRepeat` and take effect only on odd (even) rows.\n *\n * This directive can be applied only within the scope of an\n * {@link ng.directive:ngRepeat ngRepeat}.\n *\n * @element ANY\n * @param {expression} ngClassEven {@link guide/expression Expression} to eval. The\n *   result of the evaluation can be a string representing space delimited class names or an array.\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n        <ol ng-init=\"names=['John', 'Mary', 'Cate', 'Suz']\">\n          <li ng-repeat=\"name in names\">\n           <span ng-class-odd=\"'odd'\" ng-class-even=\"'even'\">\n             {{name}} &nbsp; &nbsp; &nbsp;\n           </span>\n          </li>\n        </ol>\n     </file>\n     <file name=\"style.css\">\n       .odd {\n         color: red;\n       }\n       .even {\n         color: blue;\n       }\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-class-odd and ng-class-even', function() {\n         expect(element(by.repeater('name in names').row(0).column('name')).getAttribute('class')).\n           toMatch(/odd/);\n         expect(element(by.repeater('name in names').row(1).column('name')).getAttribute('class')).\n           toMatch(/even/);\n       });\n     </file>\n   </example>\n */\nvar ngClassEvenDirective = classDirective('Even', 1);\n\n/**\n * @ngdoc directive\n * @name ngCloak\n * @restrict AC\n *\n * @description\n * The `ngCloak` directive is used to prevent the Angular html template from being briefly\n * displayed by the browser in its raw (uncompiled) form while your application is loading. Use this\n * directive to avoid the undesirable flicker effect caused by the html template display.\n *\n * The directive can be applied to the `<body>` element, but the preferred usage is to apply\n * multiple `ngCloak` directives to small portions of the page to permit progressive rendering\n * of the browser view.\n *\n * `ngCloak` works in cooperation with the following css rule embedded within `angular.js` and\n * `angular.min.js`.\n * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}).\n *\n * ```css\n * [ng\\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {\n *   display: none !important;\n * }\n * ```\n *\n * When this css rule is loaded by the browser, all html elements (including their children) that\n * are tagged with the `ngCloak` directive are hidden. When Angular encounters this directive\n * during the compilation of the template it deletes the `ngCloak` element attribute, making\n * the compiled element visible.\n *\n * For the best result, the `angular.js` script must be loaded in the head section of the html\n * document; alternatively, the css rule above must be included in the external stylesheet of the\n * application.\n *\n * @element ANY\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n        <div id=\"template1\" ng-cloak>{{ 'hello' }}</div>\n        <div id=\"template2\" class=\"ng-cloak\">{{ 'world' }}</div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should remove the template directive and css class', function() {\n         expect($('#template1').getAttribute('ng-cloak')).\n           toBeNull();\n         expect($('#template2').getAttribute('ng-cloak')).\n           toBeNull();\n       });\n     </file>\n   </example>\n *\n */\nvar ngCloakDirective = ngDirective({\n  compile: function(element, attr) {\n    attr.$set('ngCloak', undefined);\n    element.removeClass('ng-cloak');\n  }\n});\n\n/**\n * @ngdoc directive\n * @name ngController\n *\n * @description\n * The `ngController` directive attaches a controller class to the view. This is a key aspect of how angular\n * supports the principles behind the Model-View-Controller design pattern.\n *\n * MVC components in angular:\n *\n * * Model — Models are the properties of a scope; scopes are attached to the DOM where scope properties\n *   are accessed through bindings.\n * * View — The template (HTML with data bindings) that is rendered into the View.\n * * Controller — The `ngController` directive specifies a Controller class; the class contains business\n *   logic behind the application to decorate the scope with functions and values\n *\n * Note that you can also attach controllers to the DOM by declaring it in a route definition\n * via the {@link ngRoute.$route $route} service. A common mistake is to declare the controller\n * again using `ng-controller` in the template itself.  This will cause the controller to be attached\n * and executed twice.\n *\n * @element ANY\n * @scope\n * @priority 500\n * @param {expression} ngController Name of a constructor function registered with the current\n * {@link ng.$controllerProvider $controllerProvider} or an {@link guide/expression expression}\n * that on the current scope evaluates to a constructor function.\n *\n * The controller instance can be published into a scope property by specifying\n * `ng-controller=\"as propertyName\"`.\n *\n * If the current `$controllerProvider` is configured to use globals (via\n * {@link ng.$controllerProvider#allowGlobals `$controllerProvider.allowGlobals()` }), this may\n * also be the name of a globally accessible constructor function (not recommended).\n *\n * @example\n * Here is a simple form for editing user contact information. Adding, removing, clearing, and\n * greeting are methods declared on the controller (see source tab). These methods can\n * easily be called from the angular markup. Any changes to the data are automatically reflected\n * in the View without the need for a manual update.\n *\n * Two different declaration styles are included below:\n *\n * * one binds methods and properties directly onto the controller using `this`:\n * `ng-controller=\"SettingsController1 as settings\"`\n * * one injects `$scope` into the controller:\n * `ng-controller=\"SettingsController2\"`\n *\n * The second option is more common in the Angular community, and is generally used in boilerplates\n * and in this guide. However, there are advantages to binding properties directly to the controller\n * and avoiding scope.\n *\n * * Using `controller as` makes it obvious which controller you are accessing in the template when\n * multiple controllers apply to an element.\n * * If you are writing your controllers as classes you have easier access to the properties and\n * methods, which will appear on the scope, from inside the controller code.\n * * Since there is always a `.` in the bindings, you don't have to worry about prototypal\n * inheritance masking primitives.\n *\n * This example demonstrates the `controller as` syntax.\n *\n * <example name=\"ngControllerAs\" module=\"controllerAsExample\">\n *   <file name=\"index.html\">\n *    <div id=\"ctrl-as-exmpl\" ng-controller=\"SettingsController1 as settings\">\n *      <label>Name: <input type=\"text\" ng-model=\"settings.name\"/></label>\n *      <button ng-click=\"settings.greet()\">greet</button><br/>\n *      Contact:\n *      <ul>\n *        <li ng-repeat=\"contact in settings.contacts\">\n *          <select ng-model=\"contact.type\" aria-label=\"Contact method\" id=\"select_{{$index}}\">\n *             <option>phone</option>\n *             <option>email</option>\n *          </select>\n *          <input type=\"text\" ng-model=\"contact.value\" aria-labelledby=\"select_{{$index}}\" />\n *          <button ng-click=\"settings.clearContact(contact)\">clear</button>\n *          <button ng-click=\"settings.removeContact(contact)\" aria-label=\"Remove\">X</button>\n *        </li>\n *        <li><button ng-click=\"settings.addContact()\">add</button></li>\n *     </ul>\n *    </div>\n *   </file>\n *   <file name=\"app.js\">\n *    angular.module('controllerAsExample', [])\n *      .controller('SettingsController1', SettingsController1);\n *\n *    function SettingsController1() {\n *      this.name = \"John Smith\";\n *      this.contacts = [\n *        {type: 'phone', value: '408 555 1212'},\n *        {type: 'email', value: 'john.smith@example.org'} ];\n *    }\n *\n *    SettingsController1.prototype.greet = function() {\n *      alert(this.name);\n *    };\n *\n *    SettingsController1.prototype.addContact = function() {\n *      this.contacts.push({type: 'email', value: 'yourname@example.org'});\n *    };\n *\n *    SettingsController1.prototype.removeContact = function(contactToRemove) {\n *     var index = this.contacts.indexOf(contactToRemove);\n *      this.contacts.splice(index, 1);\n *    };\n *\n *    SettingsController1.prototype.clearContact = function(contact) {\n *      contact.type = 'phone';\n *      contact.value = '';\n *    };\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *     it('should check controller as', function() {\n *       var container = element(by.id('ctrl-as-exmpl'));\n *         expect(container.element(by.model('settings.name'))\n *           .getAttribute('value')).toBe('John Smith');\n *\n *       var firstRepeat =\n *           container.element(by.repeater('contact in settings.contacts').row(0));\n *       var secondRepeat =\n *           container.element(by.repeater('contact in settings.contacts').row(1));\n *\n *       expect(firstRepeat.element(by.model('contact.value')).getAttribute('value'))\n *           .toBe('408 555 1212');\n *\n *       expect(secondRepeat.element(by.model('contact.value')).getAttribute('value'))\n *           .toBe('john.smith@example.org');\n *\n *       firstRepeat.element(by.buttonText('clear')).click();\n *\n *       expect(firstRepeat.element(by.model('contact.value')).getAttribute('value'))\n *           .toBe('');\n *\n *       container.element(by.buttonText('add')).click();\n *\n *       expect(container.element(by.repeater('contact in settings.contacts').row(2))\n *           .element(by.model('contact.value'))\n *           .getAttribute('value'))\n *           .toBe('yourname@example.org');\n *     });\n *   </file>\n * </example>\n *\n * This example demonstrates the \"attach to `$scope`\" style of controller.\n *\n * <example name=\"ngController\" module=\"controllerExample\">\n *  <file name=\"index.html\">\n *   <div id=\"ctrl-exmpl\" ng-controller=\"SettingsController2\">\n *     <label>Name: <input type=\"text\" ng-model=\"name\"/></label>\n *     <button ng-click=\"greet()\">greet</button><br/>\n *     Contact:\n *     <ul>\n *       <li ng-repeat=\"contact in contacts\">\n *         <select ng-model=\"contact.type\" id=\"select_{{$index}}\">\n *            <option>phone</option>\n *            <option>email</option>\n *         </select>\n *         <input type=\"text\" ng-model=\"contact.value\" aria-labelledby=\"select_{{$index}}\" />\n *         <button ng-click=\"clearContact(contact)\">clear</button>\n *         <button ng-click=\"removeContact(contact)\">X</button>\n *       </li>\n *       <li>[ <button ng-click=\"addContact()\">add</button> ]</li>\n *    </ul>\n *   </div>\n *  </file>\n *  <file name=\"app.js\">\n *   angular.module('controllerExample', [])\n *     .controller('SettingsController2', ['$scope', SettingsController2]);\n *\n *   function SettingsController2($scope) {\n *     $scope.name = \"John Smith\";\n *     $scope.contacts = [\n *       {type:'phone', value:'408 555 1212'},\n *       {type:'email', value:'john.smith@example.org'} ];\n *\n *     $scope.greet = function() {\n *       alert($scope.name);\n *     };\n *\n *     $scope.addContact = function() {\n *       $scope.contacts.push({type:'email', value:'yourname@example.org'});\n *     };\n *\n *     $scope.removeContact = function(contactToRemove) {\n *       var index = $scope.contacts.indexOf(contactToRemove);\n *       $scope.contacts.splice(index, 1);\n *     };\n *\n *     $scope.clearContact = function(contact) {\n *       contact.type = 'phone';\n *       contact.value = '';\n *     };\n *   }\n *  </file>\n *  <file name=\"protractor.js\" type=\"protractor\">\n *    it('should check controller', function() {\n *      var container = element(by.id('ctrl-exmpl'));\n *\n *      expect(container.element(by.model('name'))\n *          .getAttribute('value')).toBe('John Smith');\n *\n *      var firstRepeat =\n *          container.element(by.repeater('contact in contacts').row(0));\n *      var secondRepeat =\n *          container.element(by.repeater('contact in contacts').row(1));\n *\n *      expect(firstRepeat.element(by.model('contact.value')).getAttribute('value'))\n *          .toBe('408 555 1212');\n *      expect(secondRepeat.element(by.model('contact.value')).getAttribute('value'))\n *          .toBe('john.smith@example.org');\n *\n *      firstRepeat.element(by.buttonText('clear')).click();\n *\n *      expect(firstRepeat.element(by.model('contact.value')).getAttribute('value'))\n *          .toBe('');\n *\n *      container.element(by.buttonText('add')).click();\n *\n *      expect(container.element(by.repeater('contact in contacts').row(2))\n *          .element(by.model('contact.value'))\n *          .getAttribute('value'))\n *          .toBe('yourname@example.org');\n *    });\n *  </file>\n *</example>\n\n */\nvar ngControllerDirective = [function() {\n  return {\n    restrict: 'A',\n    scope: true,\n    controller: '@',\n    priority: 500\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngCsp\n *\n * @element html\n * @description\n *\n * Angular has some features that can break certain\n * [CSP (Content Security Policy)](https://developer.mozilla.org/en/Security/CSP) rules.\n *\n * If you intend to implement these rules then you must tell Angular not to use these features.\n *\n * This is necessary when developing things like Google Chrome Extensions or Universal Windows Apps.\n *\n *\n * The following rules affect Angular:\n *\n * * `unsafe-eval`: this rule forbids apps to use `eval` or `Function(string)` generated functions\n * (among other things). Angular makes use of this in the {@link $parse} service to provide a 30%\n * increase in the speed of evaluating Angular expressions.\n *\n * * `unsafe-inline`: this rule forbids apps from inject custom styles into the document. Angular\n * makes use of this to include some CSS rules (e.g. {@link ngCloak} and {@link ngHide}).\n * To make these directives work when a CSP rule is blocking inline styles, you must link to the\n * `angular-csp.css` in your HTML manually.\n *\n * If you do not provide `ngCsp` then Angular tries to autodetect if CSP is blocking unsafe-eval\n * and automatically deactivates this feature in the {@link $parse} service. This autodetection,\n * however, triggers a CSP error to be logged in the console:\n *\n * ```\n * Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of\n * script in the following Content Security Policy directive: \"default-src 'self'\". Note that\n * 'script-src' was not explicitly set, so 'default-src' is used as a fallback.\n * ```\n *\n * This error is harmless but annoying. To prevent the error from showing up, put the `ngCsp`\n * directive on an element of the HTML document that appears before the `<script>` tag that loads\n * the `angular.js` file.\n *\n * *Note: This directive is only available in the `ng-csp` and `data-ng-csp` attribute form.*\n *\n * You can specify which of the CSP related Angular features should be deactivated by providing\n * a value for the `ng-csp` attribute. The options are as follows:\n *\n * * no-inline-style: this stops Angular from injecting CSS styles into the DOM\n *\n * * no-unsafe-eval: this stops Angular from optimizing $parse with unsafe eval of strings\n *\n * You can use these values in the following combinations:\n *\n *\n * * No declaration means that Angular will assume that you can do inline styles, but it will do\n * a runtime check for unsafe-eval. E.g. `<body>`. This is backwardly compatible with previous versions\n * of Angular.\n *\n * * A simple `ng-csp` (or `data-ng-csp`) attribute will tell Angular to deactivate both inline\n * styles and unsafe eval. E.g. `<body ng-csp>`. This is backwardly compatible with previous versions\n * of Angular.\n *\n * * Specifying only `no-unsafe-eval` tells Angular that we must not use eval, but that we can inject\n * inline styles. E.g. `<body ng-csp=\"no-unsafe-eval\">`.\n *\n * * Specifying only `no-inline-style` tells Angular that we must not inject styles, but that we can\n * run eval - no automatic check for unsafe eval will occur. E.g. `<body ng-csp=\"no-inline-style\">`\n *\n * * Specifying both `no-unsafe-eval` and `no-inline-style` tells Angular that we must not inject\n * styles nor use eval, which is the same as an empty: ng-csp.\n * E.g.`<body ng-csp=\"no-inline-style;no-unsafe-eval\">`\n *\n * @example\n * This example shows how to apply the `ngCsp` directive to the `html` tag.\n   ```html\n     <!doctype html>\n     <html ng-app ng-csp>\n     ...\n     ...\n     </html>\n   ```\n  * @example\n      // Note: the suffix `.csp` in the example name triggers\n      // csp mode in our http server!\n      <example name=\"example.csp\" module=\"cspExample\" ng-csp=\"true\">\n        <file name=\"index.html\">\n          <div ng-controller=\"MainController as ctrl\">\n            <div>\n              <button ng-click=\"ctrl.inc()\" id=\"inc\">Increment</button>\n              <span id=\"counter\">\n                {{ctrl.counter}}\n              </span>\n            </div>\n\n            <div>\n              <button ng-click=\"ctrl.evil()\" id=\"evil\">Evil</button>\n              <span id=\"evilError\">\n                {{ctrl.evilError}}\n              </span>\n            </div>\n          </div>\n        </file>\n        <file name=\"script.js\">\n           angular.module('cspExample', [])\n             .controller('MainController', function() {\n                this.counter = 0;\n                this.inc = function() {\n                  this.counter++;\n                };\n                this.evil = function() {\n                  // jshint evil:true\n                  try {\n                    eval('1+2');\n                  } catch (e) {\n                    this.evilError = e.message;\n                  }\n                };\n              });\n        </file>\n        <file name=\"protractor.js\" type=\"protractor\">\n          var util, webdriver;\n\n          var incBtn = element(by.id('inc'));\n          var counter = element(by.id('counter'));\n          var evilBtn = element(by.id('evil'));\n          var evilError = element(by.id('evilError'));\n\n          function getAndClearSevereErrors() {\n            return browser.manage().logs().get('browser').then(function(browserLog) {\n              return browserLog.filter(function(logEntry) {\n                return logEntry.level.value > webdriver.logging.Level.WARNING.value;\n              });\n            });\n          }\n\n          function clearErrors() {\n            getAndClearSevereErrors();\n          }\n\n          function expectNoErrors() {\n            getAndClearSevereErrors().then(function(filteredLog) {\n              expect(filteredLog.length).toEqual(0);\n              if (filteredLog.length) {\n                console.log('browser console errors: ' + util.inspect(filteredLog));\n              }\n            });\n          }\n\n          function expectError(regex) {\n            getAndClearSevereErrors().then(function(filteredLog) {\n              var found = false;\n              filteredLog.forEach(function(log) {\n                if (log.message.match(regex)) {\n                  found = true;\n                }\n              });\n              if (!found) {\n                throw new Error('expected an error that matches ' + regex);\n              }\n            });\n          }\n\n          beforeEach(function() {\n            util = require('util');\n            webdriver = require('protractor/node_modules/selenium-webdriver');\n          });\n\n          // For now, we only test on Chrome,\n          // as Safari does not load the page with Protractor's injected scripts,\n          // and Firefox webdriver always disables content security policy (#6358)\n          if (browser.params.browser !== 'chrome') {\n            return;\n          }\n\n          it('should not report errors when the page is loaded', function() {\n            // clear errors so we are not dependent on previous tests\n            clearErrors();\n            // Need to reload the page as the page is already loaded when\n            // we come here\n            browser.driver.getCurrentUrl().then(function(url) {\n              browser.get(url);\n            });\n            expectNoErrors();\n          });\n\n          it('should evaluate expressions', function() {\n            expect(counter.getText()).toEqual('0');\n            incBtn.click();\n            expect(counter.getText()).toEqual('1');\n            expectNoErrors();\n          });\n\n          it('should throw and report an error when using \"eval\"', function() {\n            evilBtn.click();\n            expect(evilError.getText()).toMatch(/Content Security Policy/);\n            expectError(/Content Security Policy/);\n          });\n        </file>\n      </example>\n  */\n\n// ngCsp is not implemented as a proper directive any more, because we need it be processed while we\n// bootstrap the system (before $parse is instantiated), for this reason we just have\n// the csp() fn that looks for the `ng-csp` attribute anywhere in the current doc\n\n/**\n * @ngdoc directive\n * @name ngClick\n *\n * @description\n * The ngClick directive allows you to specify custom behavior when\n * an element is clicked.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngClick {@link guide/expression Expression} to evaluate upon\n * click. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-click=\"count = count + 1\" ng-init=\"count=0\">\n        Increment\n      </button>\n      <span>\n        count: {{count}}\n      </span>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-click', function() {\n         expect(element(by.binding('count')).getText()).toMatch('0');\n         element(by.css('button')).click();\n         expect(element(by.binding('count')).getText()).toMatch('1');\n       });\n     </file>\n   </example>\n */\n/*\n * A collection of directives that allows creation of custom event handlers that are defined as\n * angular expressions and are compiled and executed within the current scope.\n */\nvar ngEventDirectives = {};\n\n// For events that might fire synchronously during DOM manipulation\n// we need to execute their event handlers asynchronously using $evalAsync,\n// so that they are not executed in an inconsistent state.\nvar forceAsyncEvents = {\n  'blur': true,\n  'focus': true\n};\nforEach(\n  'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste'.split(' '),\n  function(eventName) {\n    var directiveName = directiveNormalize('ng-' + eventName);\n    ngEventDirectives[directiveName] = ['$parse', '$rootScope', function($parse, $rootScope) {\n      return {\n        restrict: 'A',\n        compile: function($element, attr) {\n          // We expose the powerful $event object on the scope that provides access to the Window,\n          // etc. that isn't protected by the fast paths in $parse.  We explicitly request better\n          // checks at the cost of speed since event handler expressions are not executed as\n          // frequently as regular change detection.\n          var fn = $parse(attr[directiveName], /* interceptorFn */ null, /* expensiveChecks */ true);\n          return function ngEventHandler(scope, element) {\n            element.on(eventName, function(event) {\n              var callback = function() {\n                fn(scope, {$event:event});\n              };\n              if (forceAsyncEvents[eventName] && $rootScope.$$phase) {\n                scope.$evalAsync(callback);\n              } else {\n                scope.$apply(callback);\n              }\n            });\n          };\n        }\n      };\n    }];\n  }\n);\n\n/**\n * @ngdoc directive\n * @name ngDblclick\n *\n * @description\n * The `ngDblclick` directive allows you to specify custom behavior on a dblclick event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngDblclick {@link guide/expression Expression} to evaluate upon\n * a dblclick. (The Event object is available as `$event`)\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-dblclick=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (on double click)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngMousedown\n *\n * @description\n * The ngMousedown directive allows you to specify custom behavior on mousedown event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMousedown {@link guide/expression Expression} to evaluate upon\n * mousedown. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mousedown=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (on mouse down)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngMouseup\n *\n * @description\n * Specify custom behavior on mouseup event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMouseup {@link guide/expression Expression} to evaluate upon\n * mouseup. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mouseup=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (on mouse up)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngMouseover\n *\n * @description\n * Specify custom behavior on mouseover event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMouseover {@link guide/expression Expression} to evaluate upon\n * mouseover. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mouseover=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (when mouse is over)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngMouseenter\n *\n * @description\n * Specify custom behavior on mouseenter event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMouseenter {@link guide/expression Expression} to evaluate upon\n * mouseenter. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mouseenter=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (when mouse enters)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngMouseleave\n *\n * @description\n * Specify custom behavior on mouseleave event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMouseleave {@link guide/expression Expression} to evaluate upon\n * mouseleave. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mouseleave=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (when mouse leaves)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngMousemove\n *\n * @description\n * Specify custom behavior on mousemove event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngMousemove {@link guide/expression Expression} to evaluate upon\n * mousemove. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <button ng-mousemove=\"count = count + 1\" ng-init=\"count=0\">\n        Increment (when mouse moves)\n      </button>\n      count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngKeydown\n *\n * @description\n * Specify custom behavior on keydown event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngKeydown {@link guide/expression Expression} to evaluate upon\n * keydown. (Event object is available as `$event` and can be interrogated for keyCode, altKey, etc.)\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <input ng-keydown=\"count = count + 1\" ng-init=\"count=0\">\n      key down count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngKeyup\n *\n * @description\n * Specify custom behavior on keyup event.\n *\n * @element ANY\n * @priority 0\n * @param {expression} ngKeyup {@link guide/expression Expression} to evaluate upon\n * keyup. (Event object is available as `$event` and can be interrogated for keyCode, altKey, etc.)\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n       <p>Typing in the input box below updates the key count</p>\n       <input ng-keyup=\"count = count + 1\" ng-init=\"count=0\"> key up count: {{count}}\n\n       <p>Typing in the input box below updates the keycode</p>\n       <input ng-keyup=\"event=$event\">\n       <p>event keyCode: {{ event.keyCode }}</p>\n       <p>event altKey: {{ event.altKey }}</p>\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngKeypress\n *\n * @description\n * Specify custom behavior on keypress event.\n *\n * @element ANY\n * @param {expression} ngKeypress {@link guide/expression Expression} to evaluate upon\n * keypress. ({@link guide/expression#-event- Event object is available as `$event`}\n * and can be interrogated for keyCode, altKey, etc.)\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <input ng-keypress=\"count = count + 1\" ng-init=\"count=0\">\n      key press count: {{count}}\n     </file>\n   </example>\n */\n\n\n/**\n * @ngdoc directive\n * @name ngSubmit\n *\n * @description\n * Enables binding angular expressions to onsubmit events.\n *\n * Additionally it prevents the default action (which for form means sending the request to the\n * server and reloading the current page), but only if the form does not contain `action`,\n * `data-action`, or `x-action` attributes.\n *\n * <div class=\"alert alert-warning\">\n * **Warning:** Be careful not to cause \"double-submission\" by using both the `ngClick` and\n * `ngSubmit` handlers together. See the\n * {@link form#submitting-a-form-and-preventing-the-default-action `form` directive documentation}\n * for a detailed discussion of when `ngSubmit` may be triggered.\n * </div>\n *\n * @element form\n * @priority 0\n * @param {expression} ngSubmit {@link guide/expression Expression} to eval.\n * ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example module=\"submitExample\">\n     <file name=\"index.html\">\n      <script>\n        angular.module('submitExample', [])\n          .controller('ExampleController', ['$scope', function($scope) {\n            $scope.list = [];\n            $scope.text = 'hello';\n            $scope.submit = function() {\n              if ($scope.text) {\n                $scope.list.push(this.text);\n                $scope.text = '';\n              }\n            };\n          }]);\n      </script>\n      <form ng-submit=\"submit()\" ng-controller=\"ExampleController\">\n        Enter text and hit enter:\n        <input type=\"text\" ng-model=\"text\" name=\"text\" />\n        <input type=\"submit\" id=\"submit\" value=\"Submit\" />\n        <pre>list={{list}}</pre>\n      </form>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-submit', function() {\n         expect(element(by.binding('list')).getText()).toBe('list=[]');\n         element(by.css('#submit')).click();\n         expect(element(by.binding('list')).getText()).toContain('hello');\n         expect(element(by.model('text')).getAttribute('value')).toBe('');\n       });\n       it('should ignore empty strings', function() {\n         expect(element(by.binding('list')).getText()).toBe('list=[]');\n         element(by.css('#submit')).click();\n         element(by.css('#submit')).click();\n         expect(element(by.binding('list')).getText()).toContain('hello');\n        });\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngFocus\n *\n * @description\n * Specify custom behavior on focus event.\n *\n * Note: As the `focus` event is executed synchronously when calling `input.focus()`\n * AngularJS executes the expression using `scope.$evalAsync` if the event is fired\n * during an `$apply` to ensure a consistent state.\n *\n * @element window, input, select, textarea, a\n * @priority 0\n * @param {expression} ngFocus {@link guide/expression Expression} to evaluate upon\n * focus. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n * See {@link ng.directive:ngClick ngClick}\n */\n\n/**\n * @ngdoc directive\n * @name ngBlur\n *\n * @description\n * Specify custom behavior on blur event.\n *\n * A [blur event](https://developer.mozilla.org/en-US/docs/Web/Events/blur) fires when\n * an element has lost focus.\n *\n * Note: As the `blur` event is executed synchronously also during DOM manipulations\n * (e.g. removing a focussed input),\n * AngularJS executes the expression using `scope.$evalAsync` if the event is fired\n * during an `$apply` to ensure a consistent state.\n *\n * @element window, input, select, textarea, a\n * @priority 0\n * @param {expression} ngBlur {@link guide/expression Expression} to evaluate upon\n * blur. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n * See {@link ng.directive:ngClick ngClick}\n */\n\n/**\n * @ngdoc directive\n * @name ngCopy\n *\n * @description\n * Specify custom behavior on copy event.\n *\n * @element window, input, select, textarea, a\n * @priority 0\n * @param {expression} ngCopy {@link guide/expression Expression} to evaluate upon\n * copy. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <input ng-copy=\"copied=true\" ng-init=\"copied=false; value='copy me'\" ng-model=\"value\">\n      copied: {{copied}}\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngCut\n *\n * @description\n * Specify custom behavior on cut event.\n *\n * @element window, input, select, textarea, a\n * @priority 0\n * @param {expression} ngCut {@link guide/expression Expression} to evaluate upon\n * cut. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <input ng-cut=\"cut=true\" ng-init=\"cut=false; value='cut me'\" ng-model=\"value\">\n      cut: {{cut}}\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngPaste\n *\n * @description\n * Specify custom behavior on paste event.\n *\n * @element window, input, select, textarea, a\n * @priority 0\n * @param {expression} ngPaste {@link guide/expression Expression} to evaluate upon\n * paste. ({@link guide/expression#-event- Event object is available as `$event`})\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n      <input ng-paste=\"paste=true\" ng-init=\"paste=false\" placeholder='paste here'>\n      pasted: {{paste}}\n     </file>\n   </example>\n */\n\n/**\n * @ngdoc directive\n * @name ngIf\n * @restrict A\n * @multiElement\n *\n * @description\n * The `ngIf` directive removes or recreates a portion of the DOM tree based on an\n * {expression}. If the expression assigned to `ngIf` evaluates to a false\n * value then the element is removed from the DOM, otherwise a clone of the\n * element is reinserted into the DOM.\n *\n * `ngIf` differs from `ngShow` and `ngHide` in that `ngIf` completely removes and recreates the\n * element in the DOM rather than changing its visibility via the `display` css property.  A common\n * case when this difference is significant is when using css selectors that rely on an element's\n * position within the DOM, such as the `:first-child` or `:last-child` pseudo-classes.\n *\n * Note that when an element is removed using `ngIf` its scope is destroyed and a new scope\n * is created when the element is restored.  The scope created within `ngIf` inherits from\n * its parent scope using\n * [prototypal inheritance](https://github.com/angular/angular.js/wiki/Understanding-Scopes#javascript-prototypal-inheritance).\n * An important implication of this is if `ngModel` is used within `ngIf` to bind to\n * a javascript primitive defined in the parent scope. In this case any modifications made to the\n * variable within the child scope will override (hide) the value in the parent scope.\n *\n * Also, `ngIf` recreates elements using their compiled state. An example of this behavior\n * is if an element's class attribute is directly modified after it's compiled, using something like\n * jQuery's `.addClass()` method, and the element is later removed. When `ngIf` recreates the element\n * the added class will be lost because the original compiled state is used to regenerate the element.\n *\n * Additionally, you can provide animations via the `ngAnimate` module to animate the `enter`\n * and `leave` effects.\n *\n * @animations\n * | Animation                        | Occurs                               |\n * |----------------------------------|-------------------------------------|\n * | {@link ng.$animate#enter enter}  | just after the `ngIf` contents change and a new DOM element is created and injected into the `ngIf` container |\n * | {@link ng.$animate#leave leave}  | just before the `ngIf` contents are removed from the DOM |\n *\n * @element ANY\n * @scope\n * @priority 600\n * @param {expression} ngIf If the {@link guide/expression expression} is falsy then\n *     the element is removed from the DOM tree. If it is truthy a copy of the compiled\n *     element is added to the DOM tree.\n *\n * @example\n  <example module=\"ngAnimate\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n      <label>Click me: <input type=\"checkbox\" ng-model=\"checked\" ng-init=\"checked=true\" /></label><br/>\n      Show when checked:\n      <span ng-if=\"checked\" class=\"animate-if\">\n        This is removed when the checkbox is unchecked.\n      </span>\n    </file>\n    <file name=\"animations.css\">\n      .animate-if {\n        background:white;\n        border:1px solid black;\n        padding:10px;\n      }\n\n      .animate-if.ng-enter, .animate-if.ng-leave {\n        transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;\n      }\n\n      .animate-if.ng-enter,\n      .animate-if.ng-leave.ng-leave-active {\n        opacity:0;\n      }\n\n      .animate-if.ng-leave,\n      .animate-if.ng-enter.ng-enter-active {\n        opacity:1;\n      }\n    </file>\n  </example>\n */\nvar ngIfDirective = ['$animate', '$compile', function($animate, $compile) {\n  return {\n    multiElement: true,\n    transclude: 'element',\n    priority: 600,\n    terminal: true,\n    restrict: 'A',\n    $$tlb: true,\n    link: function($scope, $element, $attr, ctrl, $transclude) {\n        var block, childScope, previousElements;\n        $scope.$watch($attr.ngIf, function ngIfWatchAction(value) {\n\n          if (value) {\n            if (!childScope) {\n              $transclude(function(clone, newScope) {\n                childScope = newScope;\n                clone[clone.length++] = $compile.$$createComment('end ngIf', $attr.ngIf);\n                // Note: We only need the first/last node of the cloned nodes.\n                // However, we need to keep the reference to the jqlite wrapper as it might be changed later\n                // by a directive with templateUrl when its template arrives.\n                block = {\n                  clone: clone\n                };\n                $animate.enter(clone, $element.parent(), $element);\n              });\n            }\n          } else {\n            if (previousElements) {\n              previousElements.remove();\n              previousElements = null;\n            }\n            if (childScope) {\n              childScope.$destroy();\n              childScope = null;\n            }\n            if (block) {\n              previousElements = getBlockNodes(block.clone);\n              $animate.leave(previousElements).then(function() {\n                previousElements = null;\n              });\n              block = null;\n            }\n          }\n        });\n    }\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngInclude\n * @restrict ECA\n *\n * @description\n * Fetches, compiles and includes an external HTML fragment.\n *\n * By default, the template URL is restricted to the same domain and protocol as the\n * application document. This is done by calling {@link $sce#getTrustedResourceUrl\n * $sce.getTrustedResourceUrl} on it. To load templates from other domains or protocols\n * you may either {@link ng.$sceDelegateProvider#resourceUrlWhitelist whitelist them} or\n * {@link $sce#trustAsResourceUrl wrap them} as trusted values. Refer to Angular's {@link\n * ng.$sce Strict Contextual Escaping}.\n *\n * In addition, the browser's\n * [Same Origin Policy](https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest)\n * and [Cross-Origin Resource Sharing (CORS)](http://www.w3.org/TR/cors/)\n * policy may further restrict whether the template is successfully loaded.\n * For example, `ngInclude` won't work for cross-domain requests on all browsers and for `file://`\n * access on some browsers.\n *\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link ng.$animate#enter enter}  | when the expression changes, on the new include |\n * | {@link ng.$animate#leave leave}  | when the expression changes, on the old include |\n *\n * The enter and leave animation occur concurrently.\n *\n * @scope\n * @priority 400\n *\n * @param {string} ngInclude|src angular expression evaluating to URL. If the source is a string constant,\n *                 make sure you wrap it in **single** quotes, e.g. `src=\"'myPartialTemplate.html'\"`.\n * @param {string=} onload Expression to evaluate when a new partial is loaded.\n *                  <div class=\"alert alert-warning\">\n *                  **Note:** When using onload on SVG elements in IE11, the browser will try to call\n *                  a function with the name on the window element, which will usually throw a\n *                  \"function is undefined\" error. To fix this, you can instead use `data-onload` or a\n *                  different form that {@link guide/directive#normalization matches} `onload`.\n *                  </div>\n   *\n * @param {string=} autoscroll Whether `ngInclude` should call {@link ng.$anchorScroll\n *                  $anchorScroll} to scroll the viewport after the content is loaded.\n *\n *                  - If the attribute is not set, disable scrolling.\n *                  - If the attribute is set without value, enable scrolling.\n *                  - Otherwise enable scrolling only if the expression evaluates to truthy value.\n *\n * @example\n  <example module=\"includeExample\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n     <div ng-controller=\"ExampleController\">\n       <select ng-model=\"template\" ng-options=\"t.name for t in templates\">\n        <option value=\"\">(blank)</option>\n       </select>\n       url of the template: <code>{{template.url}}</code>\n       <hr/>\n       <div class=\"slide-animate-container\">\n         <div class=\"slide-animate\" ng-include=\"template.url\"></div>\n       </div>\n     </div>\n    </file>\n    <file name=\"script.js\">\n      angular.module('includeExample', ['ngAnimate'])\n        .controller('ExampleController', ['$scope', function($scope) {\n          $scope.templates =\n            [ { name: 'template1.html', url: 'template1.html'},\n              { name: 'template2.html', url: 'template2.html'} ];\n          $scope.template = $scope.templates[0];\n        }]);\n     </file>\n    <file name=\"template1.html\">\n      Content of template1.html\n    </file>\n    <file name=\"template2.html\">\n      Content of template2.html\n    </file>\n    <file name=\"animations.css\">\n      .slide-animate-container {\n        position:relative;\n        background:white;\n        border:1px solid black;\n        height:40px;\n        overflow:hidden;\n      }\n\n      .slide-animate {\n        padding:10px;\n      }\n\n      .slide-animate.ng-enter, .slide-animate.ng-leave {\n        transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;\n\n        position:absolute;\n        top:0;\n        left:0;\n        right:0;\n        bottom:0;\n        display:block;\n        padding:10px;\n      }\n\n      .slide-animate.ng-enter {\n        top:-50px;\n      }\n      .slide-animate.ng-enter.ng-enter-active {\n        top:0;\n      }\n\n      .slide-animate.ng-leave {\n        top:0;\n      }\n      .slide-animate.ng-leave.ng-leave-active {\n        top:50px;\n      }\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var templateSelect = element(by.model('template'));\n      var includeElem = element(by.css('[ng-include]'));\n\n      it('should load template1.html', function() {\n        expect(includeElem.getText()).toMatch(/Content of template1.html/);\n      });\n\n      it('should load template2.html', function() {\n        if (browser.params.browser == 'firefox') {\n          // Firefox can't handle using selects\n          // See https://github.com/angular/protractor/issues/480\n          return;\n        }\n        templateSelect.click();\n        templateSelect.all(by.css('option')).get(2).click();\n        expect(includeElem.getText()).toMatch(/Content of template2.html/);\n      });\n\n      it('should change to blank', function() {\n        if (browser.params.browser == 'firefox') {\n          // Firefox can't handle using selects\n          return;\n        }\n        templateSelect.click();\n        templateSelect.all(by.css('option')).get(0).click();\n        expect(includeElem.isPresent()).toBe(false);\n      });\n    </file>\n  </example>\n */\n\n\n/**\n * @ngdoc event\n * @name ngInclude#$includeContentRequested\n * @eventType emit on the scope ngInclude was declared in\n * @description\n * Emitted every time the ngInclude content is requested.\n *\n * @param {Object} angularEvent Synthetic event object.\n * @param {String} src URL of content to load.\n */\n\n\n/**\n * @ngdoc event\n * @name ngInclude#$includeContentLoaded\n * @eventType emit on the current ngInclude scope\n * @description\n * Emitted every time the ngInclude content is reloaded.\n *\n * @param {Object} angularEvent Synthetic event object.\n * @param {String} src URL of content to load.\n */\n\n\n/**\n * @ngdoc event\n * @name ngInclude#$includeContentError\n * @eventType emit on the scope ngInclude was declared in\n * @description\n * Emitted when a template HTTP request yields an erroneous response (status < 200 || status > 299)\n *\n * @param {Object} angularEvent Synthetic event object.\n * @param {String} src URL of content to load.\n */\nvar ngIncludeDirective = ['$templateRequest', '$anchorScroll', '$animate',\n                  function($templateRequest,   $anchorScroll,   $animate) {\n  return {\n    restrict: 'ECA',\n    priority: 400,\n    terminal: true,\n    transclude: 'element',\n    controller: angular.noop,\n    compile: function(element, attr) {\n      var srcExp = attr.ngInclude || attr.src,\n          onloadExp = attr.onload || '',\n          autoScrollExp = attr.autoscroll;\n\n      return function(scope, $element, $attr, ctrl, $transclude) {\n        var changeCounter = 0,\n            currentScope,\n            previousElement,\n            currentElement;\n\n        var cleanupLastIncludeContent = function() {\n          if (previousElement) {\n            previousElement.remove();\n            previousElement = null;\n          }\n          if (currentScope) {\n            currentScope.$destroy();\n            currentScope = null;\n          }\n          if (currentElement) {\n            $animate.leave(currentElement).then(function() {\n              previousElement = null;\n            });\n            previousElement = currentElement;\n            currentElement = null;\n          }\n        };\n\n        scope.$watch(srcExp, function ngIncludeWatchAction(src) {\n          var afterAnimation = function() {\n            if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) {\n              $anchorScroll();\n            }\n          };\n          var thisChangeId = ++changeCounter;\n\n          if (src) {\n            //set the 2nd param to true to ignore the template request error so that the inner\n            //contents and scope can be cleaned up.\n            $templateRequest(src, true).then(function(response) {\n              if (scope.$$destroyed) return;\n\n              if (thisChangeId !== changeCounter) return;\n              var newScope = scope.$new();\n              ctrl.template = response;\n\n              // Note: This will also link all children of ng-include that were contained in the original\n              // html. If that content contains controllers, ... they could pollute/change the scope.\n              // However, using ng-include on an element with additional content does not make sense...\n              // Note: We can't remove them in the cloneAttchFn of $transclude as that\n              // function is called before linking the content, which would apply child\n              // directives to non existing elements.\n              var clone = $transclude(newScope, function(clone) {\n                cleanupLastIncludeContent();\n                $animate.enter(clone, null, $element).then(afterAnimation);\n              });\n\n              currentScope = newScope;\n              currentElement = clone;\n\n              currentScope.$emit('$includeContentLoaded', src);\n              scope.$eval(onloadExp);\n            }, function() {\n              if (scope.$$destroyed) return;\n\n              if (thisChangeId === changeCounter) {\n                cleanupLastIncludeContent();\n                scope.$emit('$includeContentError', src);\n              }\n            });\n            scope.$emit('$includeContentRequested', src);\n          } else {\n            cleanupLastIncludeContent();\n            ctrl.template = null;\n          }\n        });\n      };\n    }\n  };\n}];\n\n// This directive is called during the $transclude call of the first `ngInclude` directive.\n// It will replace and compile the content of the element with the loaded template.\n// We need this directive so that the element content is already filled when\n// the link function of another directive on the same element as ngInclude\n// is called.\nvar ngIncludeFillContentDirective = ['$compile',\n  function($compile) {\n    return {\n      restrict: 'ECA',\n      priority: -400,\n      require: 'ngInclude',\n      link: function(scope, $element, $attr, ctrl) {\n        if (toString.call($element[0]).match(/SVG/)) {\n          // WebKit: https://bugs.webkit.org/show_bug.cgi?id=135698 --- SVG elements do not\n          // support innerHTML, so detect this here and try to generate the contents\n          // specially.\n          $element.empty();\n          $compile(jqLiteBuildFragment(ctrl.template, window.document).childNodes)(scope,\n              function namespaceAdaptedClone(clone) {\n            $element.append(clone);\n          }, {futureParentElement: $element});\n          return;\n        }\n\n        $element.html(ctrl.template);\n        $compile($element.contents())(scope);\n      }\n    };\n  }];\n\n/**\n * @ngdoc directive\n * @name ngInit\n * @restrict AC\n *\n * @description\n * The `ngInit` directive allows you to evaluate an expression in the\n * current scope.\n *\n * <div class=\"alert alert-danger\">\n * This directive can be abused to add unnecessary amounts of logic into your templates.\n * There are only a few appropriate uses of `ngInit`, such as for aliasing special properties of\n * {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below; and for injecting data via\n * server side scripting. Besides these few cases, you should use {@link guide/controller controllers}\n * rather than `ngInit` to initialize values on a scope.\n * </div>\n *\n * <div class=\"alert alert-warning\">\n * **Note**: If you have assignment in `ngInit` along with a {@link ng.$filter `filter`}, make\n * sure you have parentheses to ensure correct operator precedence:\n * <pre class=\"prettyprint\">\n * `<div ng-init=\"test1 = ($index | toString)\"></div>`\n * </pre>\n * </div>\n *\n * @priority 450\n *\n * @element ANY\n * @param {expression} ngInit {@link guide/expression Expression} to eval.\n *\n * @example\n   <example module=\"initExample\">\n     <file name=\"index.html\">\n   <script>\n     angular.module('initExample', [])\n       .controller('ExampleController', ['$scope', function($scope) {\n         $scope.list = [['a', 'b'], ['c', 'd']];\n       }]);\n   </script>\n   <div ng-controller=\"ExampleController\">\n     <div ng-repeat=\"innerList in list\" ng-init=\"outerIndex = $index\">\n       <div ng-repeat=\"value in innerList\" ng-init=\"innerIndex = $index\">\n          <span class=\"example-init\">list[ {{outerIndex}} ][ {{innerIndex}} ] = {{value}};</span>\n       </div>\n     </div>\n   </div>\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       it('should alias index positions', function() {\n         var elements = element.all(by.css('.example-init'));\n         expect(elements.get(0).getText()).toBe('list[ 0 ][ 0 ] = a;');\n         expect(elements.get(1).getText()).toBe('list[ 0 ][ 1 ] = b;');\n         expect(elements.get(2).getText()).toBe('list[ 1 ][ 0 ] = c;');\n         expect(elements.get(3).getText()).toBe('list[ 1 ][ 1 ] = d;');\n       });\n     </file>\n   </example>\n */\nvar ngInitDirective = ngDirective({\n  priority: 450,\n  compile: function() {\n    return {\n      pre: function(scope, element, attrs) {\n        scope.$eval(attrs.ngInit);\n      }\n    };\n  }\n});\n\n/**\n * @ngdoc directive\n * @name ngList\n *\n * @description\n * Text input that converts between a delimited string and an array of strings. The default\n * delimiter is a comma followed by a space - equivalent to `ng-list=\", \"`. You can specify a custom\n * delimiter as the value of the `ngList` attribute - for example, `ng-list=\" | \"`.\n *\n * The behaviour of the directive is affected by the use of the `ngTrim` attribute.\n * * If `ngTrim` is set to `\"false\"` then whitespace around both the separator and each\n *   list item is respected. This implies that the user of the directive is responsible for\n *   dealing with whitespace but also allows you to use whitespace as a delimiter, such as a\n *   tab or newline character.\n * * Otherwise whitespace around the delimiter is ignored when splitting (although it is respected\n *   when joining the list items back together) and whitespace around each list item is stripped\n *   before it is added to the model.\n *\n * ### Example with Validation\n *\n * <example name=\"ngList-directive\" module=\"listExample\">\n *   <file name=\"app.js\">\n *      angular.module('listExample', [])\n *        .controller('ExampleController', ['$scope', function($scope) {\n *          $scope.names = ['morpheus', 'neo', 'trinity'];\n *        }]);\n *   </file>\n *   <file name=\"index.html\">\n *    <form name=\"myForm\" ng-controller=\"ExampleController\">\n *      <label>List: <input name=\"namesInput\" ng-model=\"names\" ng-list required></label>\n *      <span role=\"alert\">\n *        <span class=\"error\" ng-show=\"myForm.namesInput.$error.required\">\n *        Required!</span>\n *      </span>\n *      <br>\n *      <tt>names = {{names}}</tt><br/>\n *      <tt>myForm.namesInput.$valid = {{myForm.namesInput.$valid}}</tt><br/>\n *      <tt>myForm.namesInput.$error = {{myForm.namesInput.$error}}</tt><br/>\n *      <tt>myForm.$valid = {{myForm.$valid}}</tt><br/>\n *      <tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>\n *     </form>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *     var listInput = element(by.model('names'));\n *     var names = element(by.exactBinding('names'));\n *     var valid = element(by.binding('myForm.namesInput.$valid'));\n *     var error = element(by.css('span.error'));\n *\n *     it('should initialize to model', function() {\n *       expect(names.getText()).toContain('[\"morpheus\",\"neo\",\"trinity\"]');\n *       expect(valid.getText()).toContain('true');\n *       expect(error.getCssValue('display')).toBe('none');\n *     });\n *\n *     it('should be invalid if empty', function() {\n *       listInput.clear();\n *       listInput.sendKeys('');\n *\n *       expect(names.getText()).toContain('');\n *       expect(valid.getText()).toContain('false');\n *       expect(error.getCssValue('display')).not.toBe('none');\n *     });\n *   </file>\n * </example>\n *\n * ### Example - splitting on newline\n * <example name=\"ngList-directive-newlines\">\n *   <file name=\"index.html\">\n *    <textarea ng-model=\"list\" ng-list=\"&#10;\" ng-trim=\"false\"></textarea>\n *    <pre>{{ list | json }}</pre>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *     it(\"should split the text by newlines\", function() {\n *       var listInput = element(by.model('list'));\n *       var output = element(by.binding('list | json'));\n *       listInput.sendKeys('abc\\ndef\\nghi');\n *       expect(output.getText()).toContain('[\\n  \"abc\",\\n  \"def\",\\n  \"ghi\"\\n]');\n *     });\n *   </file>\n * </example>\n *\n * @element input\n * @param {string=} ngList optional delimiter that should be used to split the value.\n */\nvar ngListDirective = function() {\n  return {\n    restrict: 'A',\n    priority: 100,\n    require: 'ngModel',\n    link: function(scope, element, attr, ctrl) {\n      // We want to control whitespace trimming so we use this convoluted approach\n      // to access the ngList attribute, which doesn't pre-trim the attribute\n      var ngList = element.attr(attr.$attr.ngList) || ', ';\n      var trimValues = attr.ngTrim !== 'false';\n      var separator = trimValues ? trim(ngList) : ngList;\n\n      var parse = function(viewValue) {\n        // If the viewValue is invalid (say required but empty) it will be `undefined`\n        if (isUndefined(viewValue)) return;\n\n        var list = [];\n\n        if (viewValue) {\n          forEach(viewValue.split(separator), function(value) {\n            if (value) list.push(trimValues ? trim(value) : value);\n          });\n        }\n\n        return list;\n      };\n\n      ctrl.$parsers.push(parse);\n      ctrl.$formatters.push(function(value) {\n        if (isArray(value)) {\n          return value.join(ngList);\n        }\n\n        return undefined;\n      });\n\n      // Override the standard $isEmpty because an empty array means the input is empty.\n      ctrl.$isEmpty = function(value) {\n        return !value || !value.length;\n      };\n    }\n  };\n};\n\n/* global VALID_CLASS: true,\n  INVALID_CLASS: true,\n  PRISTINE_CLASS: true,\n  DIRTY_CLASS: true,\n  UNTOUCHED_CLASS: true,\n  TOUCHED_CLASS: true,\n*/\n\nvar VALID_CLASS = 'ng-valid',\n    INVALID_CLASS = 'ng-invalid',\n    PRISTINE_CLASS = 'ng-pristine',\n    DIRTY_CLASS = 'ng-dirty',\n    UNTOUCHED_CLASS = 'ng-untouched',\n    TOUCHED_CLASS = 'ng-touched',\n    PENDING_CLASS = 'ng-pending',\n    EMPTY_CLASS = 'ng-empty',\n    NOT_EMPTY_CLASS = 'ng-not-empty';\n\nvar ngModelMinErr = minErr('ngModel');\n\n/**\n * @ngdoc type\n * @name ngModel.NgModelController\n *\n * @property {*} $viewValue The actual value from the control's view. For `input` elements, this is a\n * String. See {@link ngModel.NgModelController#$setViewValue} for information about when the $viewValue\n * is set.\n * @property {*} $modelValue The value in the model that the control is bound to.\n * @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever\n       the control reads value from the DOM. The functions are called in array order, each passing\n       its return value through to the next. The last return value is forwarded to the\n       {@link ngModel.NgModelController#$validators `$validators`} collection.\n\nParsers are used to sanitize / convert the {@link ngModel.NgModelController#$viewValue\n`$viewValue`}.\n\nReturning `undefined` from a parser means a parse error occurred. In that case,\nno {@link ngModel.NgModelController#$validators `$validators`} will run and the `ngModel`\nwill be set to `undefined` unless {@link ngModelOptions `ngModelOptions.allowInvalid`}\nis set to `true`. The parse error is stored in `ngModel.$error.parse`.\n\n *\n * @property {Array.<Function>} $formatters Array of functions to execute, as a pipeline, whenever\n       the model value changes. The functions are called in reverse array order, each passing the value through to the\n       next. The last return value is used as the actual DOM value.\n       Used to format / convert values for display in the control.\n * ```js\n * function formatter(value) {\n *   if (value) {\n *     return value.toUpperCase();\n *   }\n * }\n * ngModel.$formatters.push(formatter);\n * ```\n *\n * @property {Object.<string, function>} $validators A collection of validators that are applied\n *      whenever the model value changes. The key value within the object refers to the name of the\n *      validator while the function refers to the validation operation. The validation operation is\n *      provided with the model value as an argument and must return a true or false value depending\n *      on the response of that validation.\n *\n * ```js\n * ngModel.$validators.validCharacters = function(modelValue, viewValue) {\n *   var value = modelValue || viewValue;\n *   return /[0-9]+/.test(value) &&\n *          /[a-z]+/.test(value) &&\n *          /[A-Z]+/.test(value) &&\n *          /\\W+/.test(value);\n * };\n * ```\n *\n * @property {Object.<string, function>} $asyncValidators A collection of validations that are expected to\n *      perform an asynchronous validation (e.g. a HTTP request). The validation function that is provided\n *      is expected to return a promise when it is run during the model validation process. Once the promise\n *      is delivered then the validation status will be set to true when fulfilled and false when rejected.\n *      When the asynchronous validators are triggered, each of the validators will run in parallel and the model\n *      value will only be updated once all validators have been fulfilled. As long as an asynchronous validator\n *      is unfulfilled, its key will be added to the controllers `$pending` property. Also, all asynchronous validators\n *      will only run once all synchronous validators have passed.\n *\n * Please note that if $http is used then it is important that the server returns a success HTTP response code\n * in order to fulfill the validation and a status level of `4xx` in order to reject the validation.\n *\n * ```js\n * ngModel.$asyncValidators.uniqueUsername = function(modelValue, viewValue) {\n *   var value = modelValue || viewValue;\n *\n *   // Lookup user by username\n *   return $http.get('/api/users/' + value).\n *      then(function resolved() {\n *        //username exists, this means validation fails\n *        return $q.reject('exists');\n *      }, function rejected() {\n *        //username does not exist, therefore this validation passes\n *        return true;\n *      });\n * };\n * ```\n *\n * @property {Array.<Function>} $viewChangeListeners Array of functions to execute whenever the\n *     view value has changed. It is called with no arguments, and its return value is ignored.\n *     This can be used in place of additional $watches against the model value.\n *\n * @property {Object} $error An object hash with all failing validator ids as keys.\n * @property {Object} $pending An object hash with all pending validator ids as keys.\n *\n * @property {boolean} $untouched True if control has not lost focus yet.\n * @property {boolean} $touched True if control has lost focus.\n * @property {boolean} $pristine True if user has not interacted with the control yet.\n * @property {boolean} $dirty True if user has already interacted with the control.\n * @property {boolean} $valid True if there is no error.\n * @property {boolean} $invalid True if at least one error on the control.\n * @property {string} $name The name attribute of the control.\n *\n * @description\n *\n * `NgModelController` provides API for the {@link ngModel `ngModel`} directive.\n * The controller contains services for data-binding, validation, CSS updates, and value formatting\n * and parsing. It purposefully does not contain any logic which deals with DOM rendering or\n * listening to DOM events.\n * Such DOM related logic should be provided by other directives which make use of\n * `NgModelController` for data-binding to control elements.\n * Angular provides this DOM logic for most {@link input `input`} elements.\n * At the end of this page you can find a {@link ngModel.NgModelController#custom-control-example\n * custom control example} that uses `ngModelController` to bind to `contenteditable` elements.\n *\n * @example\n * ### Custom Control Example\n * This example shows how to use `NgModelController` with a custom control to achieve\n * data-binding. Notice how different directives (`contenteditable`, `ng-model`, and `required`)\n * collaborate together to achieve the desired result.\n *\n * `contenteditable` is an HTML5 attribute, which tells the browser to let the element\n * contents be edited in place by the user.\n *\n * We are using the {@link ng.service:$sce $sce} service here and include the {@link ngSanitize $sanitize}\n * module to automatically remove \"bad\" content like inline event listener (e.g. `<span onclick=\"...\">`).\n * However, as we are using `$sce` the model can still decide to provide unsafe content if it marks\n * that content using the `$sce` service.\n *\n * <example name=\"NgModelController\" module=\"customControl\" deps=\"angular-sanitize.js\">\n    <file name=\"style.css\">\n      [contenteditable] {\n        border: 1px solid black;\n        background-color: white;\n        min-height: 20px;\n      }\n\n      .ng-invalid {\n        border: 1px solid red;\n      }\n\n    </file>\n    <file name=\"script.js\">\n      angular.module('customControl', ['ngSanitize']).\n        directive('contenteditable', ['$sce', function($sce) {\n          return {\n            restrict: 'A', // only activate on element attribute\n            require: '?ngModel', // get a hold of NgModelController\n            link: function(scope, element, attrs, ngModel) {\n              if (!ngModel) return; // do nothing if no ng-model\n\n              // Specify how UI should be updated\n              ngModel.$render = function() {\n                element.html($sce.getTrustedHtml(ngModel.$viewValue || ''));\n              };\n\n              // Listen for change events to enable binding\n              element.on('blur keyup change', function() {\n                scope.$evalAsync(read);\n              });\n              read(); // initialize\n\n              // Write data to the model\n              function read() {\n                var html = element.html();\n                // When we clear the content editable the browser leaves a <br> behind\n                // If strip-br attribute is provided then we strip this out\n                if ( attrs.stripBr && html == '<br>' ) {\n                  html = '';\n                }\n                ngModel.$setViewValue(html);\n              }\n            }\n          };\n        }]);\n    </file>\n    <file name=\"index.html\">\n      <form name=\"myForm\">\n       <div contenteditable\n            name=\"myWidget\" ng-model=\"userContent\"\n            strip-br=\"true\"\n            required>Change me!</div>\n        <span ng-show=\"myForm.myWidget.$error.required\">Required!</span>\n       <hr>\n       <textarea ng-model=\"userContent\" aria-label=\"Dynamic textarea\"></textarea>\n      </form>\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n    it('should data-bind and become invalid', function() {\n      if (browser.params.browser == 'safari' || browser.params.browser == 'firefox') {\n        // SafariDriver can't handle contenteditable\n        // and Firefox driver can't clear contenteditables very well\n        return;\n      }\n      var contentEditable = element(by.css('[contenteditable]'));\n      var content = 'Change me!';\n\n      expect(contentEditable.getText()).toEqual(content);\n\n      contentEditable.clear();\n      contentEditable.sendKeys(protractor.Key.BACK_SPACE);\n      expect(contentEditable.getText()).toEqual('');\n      expect(contentEditable.getAttribute('class')).toMatch(/ng-invalid-required/);\n    });\n    </file>\n * </example>\n *\n *\n */\nvar NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$parse', '$animate', '$timeout', '$rootScope', '$q', '$interpolate',\n    function($scope, $exceptionHandler, $attr, $element, $parse, $animate, $timeout, $rootScope, $q, $interpolate) {\n  this.$viewValue = Number.NaN;\n  this.$modelValue = Number.NaN;\n  this.$$rawModelValue = undefined; // stores the parsed modelValue / model set from scope regardless of validity.\n  this.$validators = {};\n  this.$asyncValidators = {};\n  this.$parsers = [];\n  this.$formatters = [];\n  this.$viewChangeListeners = [];\n  this.$untouched = true;\n  this.$touched = false;\n  this.$pristine = true;\n  this.$dirty = false;\n  this.$valid = true;\n  this.$invalid = false;\n  this.$error = {}; // keep invalid keys here\n  this.$$success = {}; // keep valid keys here\n  this.$pending = undefined; // keep pending keys here\n  this.$name = $interpolate($attr.name || '', false)($scope);\n  this.$$parentForm = nullFormCtrl;\n\n  var parsedNgModel = $parse($attr.ngModel),\n      parsedNgModelAssign = parsedNgModel.assign,\n      ngModelGet = parsedNgModel,\n      ngModelSet = parsedNgModelAssign,\n      pendingDebounce = null,\n      parserValid,\n      ctrl = this;\n\n  this.$$setOptions = function(options) {\n    ctrl.$options = options;\n    if (options && options.getterSetter) {\n      var invokeModelGetter = $parse($attr.ngModel + '()'),\n          invokeModelSetter = $parse($attr.ngModel + '($$$p)');\n\n      ngModelGet = function($scope) {\n        var modelValue = parsedNgModel($scope);\n        if (isFunction(modelValue)) {\n          modelValue = invokeModelGetter($scope);\n        }\n        return modelValue;\n      };\n      ngModelSet = function($scope, newValue) {\n        if (isFunction(parsedNgModel($scope))) {\n          invokeModelSetter($scope, {$$$p: newValue});\n        } else {\n          parsedNgModelAssign($scope, newValue);\n        }\n      };\n    } else if (!parsedNgModel.assign) {\n      throw ngModelMinErr('nonassign', \"Expression '{0}' is non-assignable. Element: {1}\",\n          $attr.ngModel, startingTag($element));\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$render\n   *\n   * @description\n   * Called when the view needs to be updated. It is expected that the user of the ng-model\n   * directive will implement this method.\n   *\n   * The `$render()` method is invoked in the following situations:\n   *\n   * * `$rollbackViewValue()` is called.  If we are rolling back the view value to the last\n   *   committed value then `$render()` is called to update the input control.\n   * * The value referenced by `ng-model` is changed programmatically and both the `$modelValue` and\n   *   the `$viewValue` are different from last time.\n   *\n   * Since `ng-model` does not do a deep watch, `$render()` is only invoked if the values of\n   * `$modelValue` and `$viewValue` are actually different from their previous values. If `$modelValue`\n   * or `$viewValue` are objects (rather than a string or number) then `$render()` will not be\n   * invoked if you only change a property on the objects.\n   */\n  this.$render = noop;\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$isEmpty\n   *\n   * @description\n   * This is called when we need to determine if the value of an input is empty.\n   *\n   * For instance, the required directive does this to work out if the input has data or not.\n   *\n   * The default `$isEmpty` function checks whether the value is `undefined`, `''`, `null` or `NaN`.\n   *\n   * You can override this for input directives whose concept of being empty is different from the\n   * default. The `checkboxInputType` directive does this because in its case a value of `false`\n   * implies empty.\n   *\n   * @param {*} value The value of the input to check for emptiness.\n   * @returns {boolean} True if `value` is \"empty\".\n   */\n  this.$isEmpty = function(value) {\n    return isUndefined(value) || value === '' || value === null || value !== value;\n  };\n\n  this.$$updateEmptyClasses = function(value) {\n    if (ctrl.$isEmpty(value)) {\n      $animate.removeClass($element, NOT_EMPTY_CLASS);\n      $animate.addClass($element, EMPTY_CLASS);\n    } else {\n      $animate.removeClass($element, EMPTY_CLASS);\n      $animate.addClass($element, NOT_EMPTY_CLASS);\n    }\n  };\n\n\n  var currentValidationRunId = 0;\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setValidity\n   *\n   * @description\n   * Change the validity state, and notify the form.\n   *\n   * This method can be called within $parsers/$formatters or a custom validation implementation.\n   * However, in most cases it should be sufficient to use the `ngModel.$validators` and\n   * `ngModel.$asyncValidators` collections which will call `$setValidity` automatically.\n   *\n   * @param {string} validationErrorKey Name of the validator. The `validationErrorKey` will be assigned\n   *        to either `$error[validationErrorKey]` or `$pending[validationErrorKey]`\n   *        (for unfulfilled `$asyncValidators`), so that it is available for data-binding.\n   *        The `validationErrorKey` should be in camelCase and will get converted into dash-case\n   *        for class name. Example: `myError` will result in `ng-valid-my-error` and `ng-invalid-my-error`\n   *        class and can be bound to as  `{{someForm.someControl.$error.myError}}` .\n   * @param {boolean} isValid Whether the current state is valid (true), invalid (false), pending (undefined),\n   *                          or skipped (null). Pending is used for unfulfilled `$asyncValidators`.\n   *                          Skipped is used by Angular when validators do not run because of parse errors and\n   *                          when `$asyncValidators` do not run because any of the `$validators` failed.\n   */\n  addSetValidityMethod({\n    ctrl: this,\n    $element: $element,\n    set: function(object, property) {\n      object[property] = true;\n    },\n    unset: function(object, property) {\n      delete object[property];\n    },\n    $animate: $animate\n  });\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setPristine\n   *\n   * @description\n   * Sets the control to its pristine state.\n   *\n   * This method can be called to remove the `ng-dirty` class and set the control to its pristine\n   * state (`ng-pristine` class). A model is considered to be pristine when the control\n   * has not been changed from when first compiled.\n   */\n  this.$setPristine = function() {\n    ctrl.$dirty = false;\n    ctrl.$pristine = true;\n    $animate.removeClass($element, DIRTY_CLASS);\n    $animate.addClass($element, PRISTINE_CLASS);\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setDirty\n   *\n   * @description\n   * Sets the control to its dirty state.\n   *\n   * This method can be called to remove the `ng-pristine` class and set the control to its dirty\n   * state (`ng-dirty` class). A model is considered to be dirty when the control has been changed\n   * from when first compiled.\n   */\n  this.$setDirty = function() {\n    ctrl.$dirty = true;\n    ctrl.$pristine = false;\n    $animate.removeClass($element, PRISTINE_CLASS);\n    $animate.addClass($element, DIRTY_CLASS);\n    ctrl.$$parentForm.$setDirty();\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setUntouched\n   *\n   * @description\n   * Sets the control to its untouched state.\n   *\n   * This method can be called to remove the `ng-touched` class and set the control to its\n   * untouched state (`ng-untouched` class). Upon compilation, a model is set as untouched\n   * by default, however this function can be used to restore that state if the model has\n   * already been touched by the user.\n   */\n  this.$setUntouched = function() {\n    ctrl.$touched = false;\n    ctrl.$untouched = true;\n    $animate.setClass($element, UNTOUCHED_CLASS, TOUCHED_CLASS);\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setTouched\n   *\n   * @description\n   * Sets the control to its touched state.\n   *\n   * This method can be called to remove the `ng-untouched` class and set the control to its\n   * touched state (`ng-touched` class). A model is considered to be touched when the user has\n   * first focused the control element and then shifted focus away from the control (blur event).\n   */\n  this.$setTouched = function() {\n    ctrl.$touched = true;\n    ctrl.$untouched = false;\n    $animate.setClass($element, TOUCHED_CLASS, UNTOUCHED_CLASS);\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$rollbackViewValue\n   *\n   * @description\n   * Cancel an update and reset the input element's value to prevent an update to the `$modelValue`,\n   * which may be caused by a pending debounced event or because the input is waiting for a some\n   * future event.\n   *\n   * If you have an input that uses `ng-model-options` to set up debounced updates or updates that\n   * depend on special events such as blur, you can have a situation where there is a period when\n   * the `$viewValue` is out of sync with the ngModel's `$modelValue`.\n   *\n   * In this case, you can use `$rollbackViewValue()` to manually cancel the debounced / future update\n   * and reset the input to the last committed view value.\n   *\n   * It is also possible that you run into difficulties if you try to update the ngModel's `$modelValue`\n   * programmatically before these debounced/future events have resolved/occurred, because Angular's\n   * dirty checking mechanism is not able to tell whether the model has actually changed or not.\n   *\n   * The `$rollbackViewValue()` method should be called before programmatically changing the model of an\n   * input which may have such events pending. This is important in order to make sure that the\n   * input field will be updated with the new model value and any pending operations are cancelled.\n   *\n   * <example name=\"ng-model-cancel-update\" module=\"cancel-update-example\">\n   *   <file name=\"app.js\">\n   *     angular.module('cancel-update-example', [])\n   *\n   *     .controller('CancelUpdateController', ['$scope', function($scope) {\n   *       $scope.model = {};\n   *\n   *       $scope.setEmpty = function(e, value, rollback) {\n   *         if (e.keyCode == 27) {\n   *           e.preventDefault();\n   *           if (rollback) {\n   *             $scope.myForm[value].$rollbackViewValue();\n   *           }\n   *           $scope.model[value] = '';\n   *         }\n   *       };\n   *     }]);\n   *   </file>\n   *   <file name=\"index.html\">\n   *     <div ng-controller=\"CancelUpdateController\">\n   *        <p>Both of these inputs are only updated if they are blurred. Hitting escape should\n   *        empty them. Follow these steps and observe the difference:</p>\n   *       <ol>\n   *         <li>Type something in the input. You will see that the model is not yet updated</li>\n   *         <li>Press the Escape key.\n   *           <ol>\n   *             <li> In the first example, nothing happens, because the model is already '', and no\n   *             update is detected. If you blur the input, the model will be set to the current view.\n   *             </li>\n   *             <li> In the second example, the pending update is cancelled, and the input is set back\n   *             to the last committed view value (''). Blurring the input does nothing.\n   *             </li>\n   *           </ol>\n   *         </li>\n   *       </ol>\n   *\n   *       <form name=\"myForm\" ng-model-options=\"{ updateOn: 'blur' }\">\n   *         <div>\n   *        <p id=\"inputDescription1\">Without $rollbackViewValue():</p>\n   *         <input name=\"value1\" aria-describedby=\"inputDescription1\" ng-model=\"model.value1\"\n   *                ng-keydown=\"setEmpty($event, 'value1')\">\n   *         value1: \"{{ model.value1 }}\"\n   *         </div>\n   *\n   *         <div>\n   *        <p id=\"inputDescription2\">With $rollbackViewValue():</p>\n   *         <input name=\"value2\" aria-describedby=\"inputDescription2\" ng-model=\"model.value2\"\n   *                ng-keydown=\"setEmpty($event, 'value2', true)\">\n   *         value2: \"{{ model.value2 }}\"\n   *         </div>\n   *       </form>\n   *     </div>\n   *   </file>\n       <file name=\"style.css\">\n          div {\n            display: table-cell;\n          }\n          div:nth-child(1) {\n            padding-right: 30px;\n          }\n\n        </file>\n   * </example>\n   */\n  this.$rollbackViewValue = function() {\n    $timeout.cancel(pendingDebounce);\n    ctrl.$viewValue = ctrl.$$lastCommittedViewValue;\n    ctrl.$render();\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$validate\n   *\n   * @description\n   * Runs each of the registered validators (first synchronous validators and then\n   * asynchronous validators).\n   * If the validity changes to invalid, the model will be set to `undefined`,\n   * unless {@link ngModelOptions `ngModelOptions.allowInvalid`} is `true`.\n   * If the validity changes to valid, it will set the model to the last available valid\n   * `$modelValue`, i.e. either the last parsed value or the last value set from the scope.\n   */\n  this.$validate = function() {\n    // ignore $validate before model is initialized\n    if (isNumber(ctrl.$modelValue) && isNaN(ctrl.$modelValue)) {\n      return;\n    }\n\n    var viewValue = ctrl.$$lastCommittedViewValue;\n    // Note: we use the $$rawModelValue as $modelValue might have been\n    // set to undefined during a view -> model update that found validation\n    // errors. We can't parse the view here, since that could change\n    // the model although neither viewValue nor the model on the scope changed\n    var modelValue = ctrl.$$rawModelValue;\n\n    var prevValid = ctrl.$valid;\n    var prevModelValue = ctrl.$modelValue;\n\n    var allowInvalid = ctrl.$options && ctrl.$options.allowInvalid;\n\n    ctrl.$$runValidators(modelValue, viewValue, function(allValid) {\n      // If there was no change in validity, don't update the model\n      // This prevents changing an invalid modelValue to undefined\n      if (!allowInvalid && prevValid !== allValid) {\n        // Note: Don't check ctrl.$valid here, as we could have\n        // external validators (e.g. calculated on the server),\n        // that just call $setValidity and need the model value\n        // to calculate their validity.\n        ctrl.$modelValue = allValid ? modelValue : undefined;\n\n        if (ctrl.$modelValue !== prevModelValue) {\n          ctrl.$$writeModelToScope();\n        }\n      }\n    });\n\n  };\n\n  this.$$runValidators = function(modelValue, viewValue, doneCallback) {\n    currentValidationRunId++;\n    var localValidationRunId = currentValidationRunId;\n\n    // check parser error\n    if (!processParseErrors()) {\n      validationDone(false);\n      return;\n    }\n    if (!processSyncValidators()) {\n      validationDone(false);\n      return;\n    }\n    processAsyncValidators();\n\n    function processParseErrors() {\n      var errorKey = ctrl.$$parserName || 'parse';\n      if (isUndefined(parserValid)) {\n        setValidity(errorKey, null);\n      } else {\n        if (!parserValid) {\n          forEach(ctrl.$validators, function(v, name) {\n            setValidity(name, null);\n          });\n          forEach(ctrl.$asyncValidators, function(v, name) {\n            setValidity(name, null);\n          });\n        }\n        // Set the parse error last, to prevent unsetting it, should a $validators key == parserName\n        setValidity(errorKey, parserValid);\n        return parserValid;\n      }\n      return true;\n    }\n\n    function processSyncValidators() {\n      var syncValidatorsValid = true;\n      forEach(ctrl.$validators, function(validator, name) {\n        var result = validator(modelValue, viewValue);\n        syncValidatorsValid = syncValidatorsValid && result;\n        setValidity(name, result);\n      });\n      if (!syncValidatorsValid) {\n        forEach(ctrl.$asyncValidators, function(v, name) {\n          setValidity(name, null);\n        });\n        return false;\n      }\n      return true;\n    }\n\n    function processAsyncValidators() {\n      var validatorPromises = [];\n      var allValid = true;\n      forEach(ctrl.$asyncValidators, function(validator, name) {\n        var promise = validator(modelValue, viewValue);\n        if (!isPromiseLike(promise)) {\n          throw ngModelMinErr('nopromise',\n            \"Expected asynchronous validator to return a promise but got '{0}' instead.\", promise);\n        }\n        setValidity(name, undefined);\n        validatorPromises.push(promise.then(function() {\n          setValidity(name, true);\n        }, function() {\n          allValid = false;\n          setValidity(name, false);\n        }));\n      });\n      if (!validatorPromises.length) {\n        validationDone(true);\n      } else {\n        $q.all(validatorPromises).then(function() {\n          validationDone(allValid);\n        }, noop);\n      }\n    }\n\n    function setValidity(name, isValid) {\n      if (localValidationRunId === currentValidationRunId) {\n        ctrl.$setValidity(name, isValid);\n      }\n    }\n\n    function validationDone(allValid) {\n      if (localValidationRunId === currentValidationRunId) {\n\n        doneCallback(allValid);\n      }\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$commitViewValue\n   *\n   * @description\n   * Commit a pending update to the `$modelValue`.\n   *\n   * Updates may be pending by a debounced event or because the input is waiting for a some future\n   * event defined in `ng-model-options`. this method is rarely needed as `NgModelController`\n   * usually handles calling this in response to input events.\n   */\n  this.$commitViewValue = function() {\n    var viewValue = ctrl.$viewValue;\n\n    $timeout.cancel(pendingDebounce);\n\n    // If the view value has not changed then we should just exit, except in the case where there is\n    // a native validator on the element. In this case the validation state may have changed even though\n    // the viewValue has stayed empty.\n    if (ctrl.$$lastCommittedViewValue === viewValue && (viewValue !== '' || !ctrl.$$hasNativeValidators)) {\n      return;\n    }\n    ctrl.$$updateEmptyClasses(viewValue);\n    ctrl.$$lastCommittedViewValue = viewValue;\n\n    // change to dirty\n    if (ctrl.$pristine) {\n      this.$setDirty();\n    }\n    this.$$parseAndValidate();\n  };\n\n  this.$$parseAndValidate = function() {\n    var viewValue = ctrl.$$lastCommittedViewValue;\n    var modelValue = viewValue;\n    parserValid = isUndefined(modelValue) ? undefined : true;\n\n    if (parserValid) {\n      for (var i = 0; i < ctrl.$parsers.length; i++) {\n        modelValue = ctrl.$parsers[i](modelValue);\n        if (isUndefined(modelValue)) {\n          parserValid = false;\n          break;\n        }\n      }\n    }\n    if (isNumber(ctrl.$modelValue) && isNaN(ctrl.$modelValue)) {\n      // ctrl.$modelValue has not been touched yet...\n      ctrl.$modelValue = ngModelGet($scope);\n    }\n    var prevModelValue = ctrl.$modelValue;\n    var allowInvalid = ctrl.$options && ctrl.$options.allowInvalid;\n    ctrl.$$rawModelValue = modelValue;\n\n    if (allowInvalid) {\n      ctrl.$modelValue = modelValue;\n      writeToModelIfNeeded();\n    }\n\n    // Pass the $$lastCommittedViewValue here, because the cached viewValue might be out of date.\n    // This can happen if e.g. $setViewValue is called from inside a parser\n    ctrl.$$runValidators(modelValue, ctrl.$$lastCommittedViewValue, function(allValid) {\n      if (!allowInvalid) {\n        // Note: Don't check ctrl.$valid here, as we could have\n        // external validators (e.g. calculated on the server),\n        // that just call $setValidity and need the model value\n        // to calculate their validity.\n        ctrl.$modelValue = allValid ? modelValue : undefined;\n        writeToModelIfNeeded();\n      }\n    });\n\n    function writeToModelIfNeeded() {\n      if (ctrl.$modelValue !== prevModelValue) {\n        ctrl.$$writeModelToScope();\n      }\n    }\n  };\n\n  this.$$writeModelToScope = function() {\n    ngModelSet($scope, ctrl.$modelValue);\n    forEach(ctrl.$viewChangeListeners, function(listener) {\n      try {\n        listener();\n      } catch (e) {\n        $exceptionHandler(e);\n      }\n    });\n  };\n\n  /**\n   * @ngdoc method\n   * @name ngModel.NgModelController#$setViewValue\n   *\n   * @description\n   * Update the view value.\n   *\n   * This method should be called when a control wants to change the view value; typically,\n   * this is done from within a DOM event handler. For example, the {@link ng.directive:input input}\n   * directive calls it when the value of the input changes and {@link ng.directive:select select}\n   * calls it when an option is selected.\n   *\n   * When `$setViewValue` is called, the new `value` will be staged for committing through the `$parsers`\n   * and `$validators` pipelines. If there are no special {@link ngModelOptions} specified then the staged\n   * value sent directly for processing, finally to be applied to `$modelValue` and then the\n   * **expression** specified in the `ng-model` attribute. Lastly, all the registered change listeners,\n   * in the `$viewChangeListeners` list, are called.\n   *\n   * In case the {@link ng.directive:ngModelOptions ngModelOptions} directive is used with `updateOn`\n   * and the `default` trigger is not listed, all those actions will remain pending until one of the\n   * `updateOn` events is triggered on the DOM element.\n   * All these actions will be debounced if the {@link ng.directive:ngModelOptions ngModelOptions}\n   * directive is used with a custom debounce for this particular event.\n   * Note that a `$digest` is only triggered once the `updateOn` events are fired, or if `debounce`\n   * is specified, once the timer runs out.\n   *\n   * When used with standard inputs, the view value will always be a string (which is in some cases\n   * parsed into another type, such as a `Date` object for `input[date]`.)\n   * However, custom controls might also pass objects to this method. In this case, we should make\n   * a copy of the object before passing it to `$setViewValue`. This is because `ngModel` does not\n   * perform a deep watch of objects, it only looks for a change of identity. If you only change\n   * the property of the object then ngModel will not realize that the object has changed and\n   * will not invoke the `$parsers` and `$validators` pipelines. For this reason, you should\n   * not change properties of the copy once it has been passed to `$setViewValue`.\n   * Otherwise you may cause the model value on the scope to change incorrectly.\n   *\n   * <div class=\"alert alert-info\">\n   * In any case, the value passed to the method should always reflect the current value\n   * of the control. For example, if you are calling `$setViewValue` for an input element,\n   * you should pass the input DOM value. Otherwise, the control and the scope model become\n   * out of sync. It's also important to note that `$setViewValue` does not call `$render` or change\n   * the control's DOM value in any way. If we want to change the control's DOM value\n   * programmatically, we should update the `ngModel` scope expression. Its new value will be\n   * picked up by the model controller, which will run it through the `$formatters`, `$render` it\n   * to update the DOM, and finally call `$validate` on it.\n   * </div>\n   *\n   * @param {*} value value from the view.\n   * @param {string} trigger Event that triggered the update.\n   */\n  this.$setViewValue = function(value, trigger) {\n    ctrl.$viewValue = value;\n    if (!ctrl.$options || ctrl.$options.updateOnDefault) {\n      ctrl.$$debounceViewValueCommit(trigger);\n    }\n  };\n\n  this.$$debounceViewValueCommit = function(trigger) {\n    var debounceDelay = 0,\n        options = ctrl.$options,\n        debounce;\n\n    if (options && isDefined(options.debounce)) {\n      debounce = options.debounce;\n      if (isNumber(debounce)) {\n        debounceDelay = debounce;\n      } else if (isNumber(debounce[trigger])) {\n        debounceDelay = debounce[trigger];\n      } else if (isNumber(debounce['default'])) {\n        debounceDelay = debounce['default'];\n      }\n    }\n\n    $timeout.cancel(pendingDebounce);\n    if (debounceDelay) {\n      pendingDebounce = $timeout(function() {\n        ctrl.$commitViewValue();\n      }, debounceDelay);\n    } else if ($rootScope.$$phase) {\n      ctrl.$commitViewValue();\n    } else {\n      $scope.$apply(function() {\n        ctrl.$commitViewValue();\n      });\n    }\n  };\n\n  // model -> value\n  // Note: we cannot use a normal scope.$watch as we want to detect the following:\n  // 1. scope value is 'a'\n  // 2. user enters 'b'\n  // 3. ng-change kicks in and reverts scope value to 'a'\n  //    -> scope value did not change since the last digest as\n  //       ng-change executes in apply phase\n  // 4. view should be changed back to 'a'\n  $scope.$watch(function ngModelWatch() {\n    var modelValue = ngModelGet($scope);\n\n    // if scope model value and ngModel value are out of sync\n    // TODO(perf): why not move this to the action fn?\n    if (modelValue !== ctrl.$modelValue &&\n       // checks for NaN is needed to allow setting the model to NaN when there's an asyncValidator\n       (ctrl.$modelValue === ctrl.$modelValue || modelValue === modelValue)\n    ) {\n      ctrl.$modelValue = ctrl.$$rawModelValue = modelValue;\n      parserValid = undefined;\n\n      var formatters = ctrl.$formatters,\n          idx = formatters.length;\n\n      var viewValue = modelValue;\n      while (idx--) {\n        viewValue = formatters[idx](viewValue);\n      }\n      if (ctrl.$viewValue !== viewValue) {\n        ctrl.$$updateEmptyClasses(viewValue);\n        ctrl.$viewValue = ctrl.$$lastCommittedViewValue = viewValue;\n        ctrl.$render();\n\n        ctrl.$$runValidators(modelValue, viewValue, noop);\n      }\n    }\n\n    return modelValue;\n  });\n}];\n\n\n/**\n * @ngdoc directive\n * @name ngModel\n *\n * @element input\n * @priority 1\n *\n * @description\n * The `ngModel` directive binds an `input`,`select`, `textarea` (or custom form control) to a\n * property on the scope using {@link ngModel.NgModelController NgModelController},\n * which is created and exposed by this directive.\n *\n * `ngModel` is responsible for:\n *\n * - Binding the view into the model, which other directives such as `input`, `textarea` or `select`\n *   require.\n * - Providing validation behavior (i.e. required, number, email, url).\n * - Keeping the state of the control (valid/invalid, dirty/pristine, touched/untouched, validation errors).\n * - Setting related css classes on the element (`ng-valid`, `ng-invalid`, `ng-dirty`, `ng-pristine`, `ng-touched`,\n *   `ng-untouched`, `ng-empty`, `ng-not-empty`) including animations.\n * - Registering the control with its parent {@link ng.directive:form form}.\n *\n * Note: `ngModel` will try to bind to the property given by evaluating the expression on the\n * current scope. If the property doesn't already exist on this scope, it will be created\n * implicitly and added to the scope.\n *\n * For best practices on using `ngModel`, see:\n *\n *  - [Understanding Scopes](https://github.com/angular/angular.js/wiki/Understanding-Scopes)\n *\n * For basic examples, how to use `ngModel`, see:\n *\n *  - {@link ng.directive:input input}\n *    - {@link input[text] text}\n *    - {@link input[checkbox] checkbox}\n *    - {@link input[radio] radio}\n *    - {@link input[number] number}\n *    - {@link input[email] email}\n *    - {@link input[url] url}\n *    - {@link input[date] date}\n *    - {@link input[datetime-local] datetime-local}\n *    - {@link input[time] time}\n *    - {@link input[month] month}\n *    - {@link input[week] week}\n *  - {@link ng.directive:select select}\n *  - {@link ng.directive:textarea textarea}\n *\n * # Complex Models (objects or collections)\n *\n * By default, `ngModel` watches the model by reference, not value. This is important to know when\n * binding inputs to models that are objects (e.g. `Date`) or collections (e.g. arrays). If only properties of the\n * object or collection change, `ngModel` will not be notified and so the input will not be  re-rendered.\n *\n * The model must be assigned an entirely new object or collection before a re-rendering will occur.\n *\n * Some directives have options that will cause them to use a custom `$watchCollection` on the model expression\n * - for example, `ngOptions` will do so when a `track by` clause is included in the comprehension expression or\n * if the select is given the `multiple` attribute.\n *\n * The `$watchCollection()` method only does a shallow comparison, meaning that changing properties deeper than the\n * first level of the object (or only changing the properties of an item in the collection if it's an array) will still\n * not trigger a re-rendering of the model.\n *\n * # CSS classes\n * The following CSS classes are added and removed on the associated input/select/textarea element\n * depending on the validity of the model.\n *\n *  - `ng-valid`: the model is valid\n *  - `ng-invalid`: the model is invalid\n *  - `ng-valid-[key]`: for each valid key added by `$setValidity`\n *  - `ng-invalid-[key]`: for each invalid key added by `$setValidity`\n *  - `ng-pristine`: the control hasn't been interacted with yet\n *  - `ng-dirty`: the control has been interacted with\n *  - `ng-touched`: the control has been blurred\n *  - `ng-untouched`: the control hasn't been blurred\n *  - `ng-pending`: any `$asyncValidators` are unfulfilled\n *  - `ng-empty`: the view does not contain a value or the value is deemed \"empty\", as defined\n *     by the {@link ngModel.NgModelController#$isEmpty} method\n *  - `ng-not-empty`: the view contains a non-empty value\n *\n * Keep in mind that ngAnimate can detect each of these classes when added and removed.\n *\n * ## Animation Hooks\n *\n * Animations within models are triggered when any of the associated CSS classes are added and removed\n * on the input element which is attached to the model. These classes include: `.ng-pristine`, `.ng-dirty`,\n * `.ng-invalid` and `.ng-valid` as well as any other validations that are performed on the model itself.\n * The animations that are triggered within ngModel are similar to how they work in ngClass and\n * animations can be hooked into using CSS transitions, keyframes as well as JS animations.\n *\n * The following example shows a simple way to utilize CSS transitions to style an input element\n * that has been rendered as invalid after it has been validated:\n *\n * <pre>\n * //be sure to include ngAnimate as a module to hook into more\n * //advanced animations\n * .my-input {\n *   transition:0.5s linear all;\n *   background: white;\n * }\n * .my-input.ng-invalid {\n *   background: red;\n *   color:white;\n * }\n * </pre>\n *\n * @example\n * <example deps=\"angular-animate.js\" animations=\"true\" fixBase=\"true\" module=\"inputExample\">\n     <file name=\"index.html\">\n       <script>\n        angular.module('inputExample', [])\n          .controller('ExampleController', ['$scope', function($scope) {\n            $scope.val = '1';\n          }]);\n       </script>\n       <style>\n         .my-input {\n           transition:all linear 0.5s;\n           background: transparent;\n         }\n         .my-input.ng-invalid {\n           color:white;\n           background: red;\n         }\n       </style>\n       <p id=\"inputDescription\">\n        Update input to see transitions when valid/invalid.\n        Integer is a valid value.\n       </p>\n       <form name=\"testForm\" ng-controller=\"ExampleController\">\n         <input ng-model=\"val\" ng-pattern=\"/^\\d+$/\" name=\"anim\" class=\"my-input\"\n                aria-describedby=\"inputDescription\" />\n       </form>\n     </file>\n * </example>\n *\n * ## Binding to a getter/setter\n *\n * Sometimes it's helpful to bind `ngModel` to a getter/setter function.  A getter/setter is a\n * function that returns a representation of the model when called with zero arguments, and sets\n * the internal state of a model when called with an argument. It's sometimes useful to use this\n * for models that have an internal representation that's different from what the model exposes\n * to the view.\n *\n * <div class=\"alert alert-success\">\n * **Best Practice:** It's best to keep getters fast because Angular is likely to call them more\n * frequently than other parts of your code.\n * </div>\n *\n * You use this behavior by adding `ng-model-options=\"{ getterSetter: true }\"` to an element that\n * has `ng-model` attached to it. You can also add `ng-model-options=\"{ getterSetter: true }\"` to\n * a `<form>`, which will enable this behavior for all `<input>`s within it. See\n * {@link ng.directive:ngModelOptions `ngModelOptions`} for more.\n *\n * The following example shows how to use `ngModel` with a getter/setter:\n *\n * @example\n * <example name=\"ngModel-getter-setter\" module=\"getterSetterExample\">\n     <file name=\"index.html\">\n       <div ng-controller=\"ExampleController\">\n         <form name=\"userForm\">\n           <label>Name:\n             <input type=\"text\" name=\"userName\"\n                    ng-model=\"user.name\"\n                    ng-model-options=\"{ getterSetter: true }\" />\n           </label>\n         </form>\n         <pre>user.name = <span ng-bind=\"user.name()\"></span></pre>\n       </div>\n     </file>\n     <file name=\"app.js\">\n       angular.module('getterSetterExample', [])\n         .controller('ExampleController', ['$scope', function($scope) {\n           var _name = 'Brian';\n           $scope.user = {\n             name: function(newName) {\n              // Note that newName can be undefined for two reasons:\n              // 1. Because it is called as a getter and thus called with no arguments\n              // 2. Because the property should actually be set to undefined. This happens e.g. if the\n              //    input is invalid\n              return arguments.length ? (_name = newName) : _name;\n             }\n           };\n         }]);\n     </file>\n * </example>\n */\nvar ngModelDirective = ['$rootScope', function($rootScope) {\n  return {\n    restrict: 'A',\n    require: ['ngModel', '^?form', '^?ngModelOptions'],\n    controller: NgModelController,\n    // Prelink needs to run before any input directive\n    // so that we can set the NgModelOptions in NgModelController\n    // before anyone else uses it.\n    priority: 1,\n    compile: function ngModelCompile(element) {\n      // Setup initial state of the control\n      element.addClass(PRISTINE_CLASS).addClass(UNTOUCHED_CLASS).addClass(VALID_CLASS);\n\n      return {\n        pre: function ngModelPreLink(scope, element, attr, ctrls) {\n          var modelCtrl = ctrls[0],\n              formCtrl = ctrls[1] || modelCtrl.$$parentForm;\n\n          modelCtrl.$$setOptions(ctrls[2] && ctrls[2].$options);\n\n          // notify others, especially parent forms\n          formCtrl.$addControl(modelCtrl);\n\n          attr.$observe('name', function(newValue) {\n            if (modelCtrl.$name !== newValue) {\n              modelCtrl.$$parentForm.$$renameControl(modelCtrl, newValue);\n            }\n          });\n\n          scope.$on('$destroy', function() {\n            modelCtrl.$$parentForm.$removeControl(modelCtrl);\n          });\n        },\n        post: function ngModelPostLink(scope, element, attr, ctrls) {\n          var modelCtrl = ctrls[0];\n          if (modelCtrl.$options && modelCtrl.$options.updateOn) {\n            element.on(modelCtrl.$options.updateOn, function(ev) {\n              modelCtrl.$$debounceViewValueCommit(ev && ev.type);\n            });\n          }\n\n          element.on('blur', function() {\n            if (modelCtrl.$touched) return;\n\n            if ($rootScope.$$phase) {\n              scope.$evalAsync(modelCtrl.$setTouched);\n            } else {\n              scope.$apply(modelCtrl.$setTouched);\n            }\n          });\n        }\n      };\n    }\n  };\n}];\n\nvar DEFAULT_REGEXP = /(\\s+|^)default(\\s+|$)/;\n\n/**\n * @ngdoc directive\n * @name ngModelOptions\n *\n * @description\n * Allows tuning how model updates are done. Using `ngModelOptions` you can specify a custom list of\n * events that will trigger a model update and/or a debouncing delay so that the actual update only\n * takes place when a timer expires; this timer will be reset after another change takes place.\n *\n * Given the nature of `ngModelOptions`, the value displayed inside input fields in the view might\n * be different from the value in the actual model. This means that if you update the model you\n * should also invoke {@link ngModel.NgModelController `$rollbackViewValue`} on the relevant input field in\n * order to make sure it is synchronized with the model and that any debounced action is canceled.\n *\n * The easiest way to reference the control's {@link ngModel.NgModelController `$rollbackViewValue`}\n * method is by making sure the input is placed inside a form that has a `name` attribute. This is\n * important because `form` controllers are published to the related scope under the name in their\n * `name` attribute.\n *\n * Any pending changes will take place immediately when an enclosing form is submitted via the\n * `submit` event. Note that `ngClick` events will occur before the model is updated. Use `ngSubmit`\n * to have access to the updated model.\n *\n * `ngModelOptions` has an effect on the element it's declared on and its descendants.\n *\n * @param {Object} ngModelOptions options to apply to the current model. Valid keys are:\n *   - `updateOn`: string specifying which event should the input be bound to. You can set several\n *     events using an space delimited list. There is a special event called `default` that\n *     matches the default events belonging of the control.\n *   - `debounce`: integer value which contains the debounce model update value in milliseconds. A\n *     value of 0 triggers an immediate update. If an object is supplied instead, you can specify a\n *     custom value for each event. For example:\n *     `ng-model-options=\"{ updateOn: 'default blur', debounce: { 'default': 500, 'blur': 0 } }\"`\n *   - `allowInvalid`: boolean value which indicates that the model can be set with values that did\n *     not validate correctly instead of the default behavior of setting the model to undefined.\n *   - `getterSetter`: boolean value which determines whether or not to treat functions bound to\n       `ngModel` as getters/setters.\n *   - `timezone`: Defines the timezone to be used to read/write the `Date` instance in the model for\n *     `<input type=\"date\">`, `<input type=\"time\">`, ... . It understands UTC/GMT and the\n *     continental US time zone abbreviations, but for general use, use a time zone offset, for\n *     example, `'+0430'` (4 hours, 30 minutes east of the Greenwich meridian)\n *     If not specified, the timezone of the browser will be used.\n *\n * @example\n\n  The following example shows how to override immediate updates. Changes on the inputs within the\n  form will update the model only when the control loses focus (blur event). If `escape` key is\n  pressed while the input field is focused, the value is reset to the value in the current model.\n\n  <example name=\"ngModelOptions-directive-blur\" module=\"optionsExample\">\n    <file name=\"index.html\">\n      <div ng-controller=\"ExampleController\">\n        <form name=\"userForm\">\n          <label>Name:\n            <input type=\"text\" name=\"userName\"\n                   ng-model=\"user.name\"\n                   ng-model-options=\"{ updateOn: 'blur' }\"\n                   ng-keyup=\"cancel($event)\" />\n          </label><br />\n          <label>Other data:\n            <input type=\"text\" ng-model=\"user.data\" />\n          </label><br />\n        </form>\n        <pre>user.name = <span ng-bind=\"user.name\"></span></pre>\n        <pre>user.data = <span ng-bind=\"user.data\"></span></pre>\n      </div>\n    </file>\n    <file name=\"app.js\">\n      angular.module('optionsExample', [])\n        .controller('ExampleController', ['$scope', function($scope) {\n          $scope.user = { name: 'John', data: '' };\n\n          $scope.cancel = function(e) {\n            if (e.keyCode == 27) {\n              $scope.userForm.userName.$rollbackViewValue();\n            }\n          };\n        }]);\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var model = element(by.binding('user.name'));\n      var input = element(by.model('user.name'));\n      var other = element(by.model('user.data'));\n\n      it('should allow custom events', function() {\n        input.sendKeys(' Doe');\n        input.click();\n        expect(model.getText()).toEqual('John');\n        other.click();\n        expect(model.getText()).toEqual('John Doe');\n      });\n\n      it('should $rollbackViewValue when model changes', function() {\n        input.sendKeys(' Doe');\n        expect(input.getAttribute('value')).toEqual('John Doe');\n        input.sendKeys(protractor.Key.ESCAPE);\n        expect(input.getAttribute('value')).toEqual('John');\n        other.click();\n        expect(model.getText()).toEqual('John');\n      });\n    </file>\n  </example>\n\n  This one shows how to debounce model changes. Model will be updated only 1 sec after last change.\n  If the `Clear` button is pressed, any debounced action is canceled and the value becomes empty.\n\n  <example name=\"ngModelOptions-directive-debounce\" module=\"optionsExample\">\n    <file name=\"index.html\">\n      <div ng-controller=\"ExampleController\">\n        <form name=\"userForm\">\n          <label>Name:\n            <input type=\"text\" name=\"userName\"\n                   ng-model=\"user.name\"\n                   ng-model-options=\"{ debounce: 1000 }\" />\n          </label>\n          <button ng-click=\"userForm.userName.$rollbackViewValue(); user.name=''\">Clear</button>\n          <br />\n        </form>\n        <pre>user.name = <span ng-bind=\"user.name\"></span></pre>\n      </div>\n    </file>\n    <file name=\"app.js\">\n      angular.module('optionsExample', [])\n        .controller('ExampleController', ['$scope', function($scope) {\n          $scope.user = { name: 'Igor' };\n        }]);\n    </file>\n  </example>\n\n  This one shows how to bind to getter/setters:\n\n  <example name=\"ngModelOptions-directive-getter-setter\" module=\"getterSetterExample\">\n    <file name=\"index.html\">\n      <div ng-controller=\"ExampleController\">\n        <form name=\"userForm\">\n          <label>Name:\n            <input type=\"text\" name=\"userName\"\n                   ng-model=\"user.name\"\n                   ng-model-options=\"{ getterSetter: true }\" />\n          </label>\n        </form>\n        <pre>user.name = <span ng-bind=\"user.name()\"></span></pre>\n      </div>\n    </file>\n    <file name=\"app.js\">\n      angular.module('getterSetterExample', [])\n        .controller('ExampleController', ['$scope', function($scope) {\n          var _name = 'Brian';\n          $scope.user = {\n            name: function(newName) {\n              // Note that newName can be undefined for two reasons:\n              // 1. Because it is called as a getter and thus called with no arguments\n              // 2. Because the property should actually be set to undefined. This happens e.g. if the\n              //    input is invalid\n              return arguments.length ? (_name = newName) : _name;\n            }\n          };\n        }]);\n    </file>\n  </example>\n */\nvar ngModelOptionsDirective = function() {\n  return {\n    restrict: 'A',\n    controller: ['$scope', '$attrs', function($scope, $attrs) {\n      var that = this;\n      this.$options = copy($scope.$eval($attrs.ngModelOptions));\n      // Allow adding/overriding bound events\n      if (isDefined(this.$options.updateOn)) {\n        this.$options.updateOnDefault = false;\n        // extract \"default\" pseudo-event from list of events that can trigger a model update\n        this.$options.updateOn = trim(this.$options.updateOn.replace(DEFAULT_REGEXP, function() {\n          that.$options.updateOnDefault = true;\n          return ' ';\n        }));\n      } else {\n        this.$options.updateOnDefault = true;\n      }\n    }]\n  };\n};\n\n\n\n// helper methods\nfunction addSetValidityMethod(context) {\n  var ctrl = context.ctrl,\n      $element = context.$element,\n      classCache = {},\n      set = context.set,\n      unset = context.unset,\n      $animate = context.$animate;\n\n  classCache[INVALID_CLASS] = !(classCache[VALID_CLASS] = $element.hasClass(VALID_CLASS));\n\n  ctrl.$setValidity = setValidity;\n\n  function setValidity(validationErrorKey, state, controller) {\n    if (isUndefined(state)) {\n      createAndSet('$pending', validationErrorKey, controller);\n    } else {\n      unsetAndCleanup('$pending', validationErrorKey, controller);\n    }\n    if (!isBoolean(state)) {\n      unset(ctrl.$error, validationErrorKey, controller);\n      unset(ctrl.$$success, validationErrorKey, controller);\n    } else {\n      if (state) {\n        unset(ctrl.$error, validationErrorKey, controller);\n        set(ctrl.$$success, validationErrorKey, controller);\n      } else {\n        set(ctrl.$error, validationErrorKey, controller);\n        unset(ctrl.$$success, validationErrorKey, controller);\n      }\n    }\n    if (ctrl.$pending) {\n      cachedToggleClass(PENDING_CLASS, true);\n      ctrl.$valid = ctrl.$invalid = undefined;\n      toggleValidationCss('', null);\n    } else {\n      cachedToggleClass(PENDING_CLASS, false);\n      ctrl.$valid = isObjectEmpty(ctrl.$error);\n      ctrl.$invalid = !ctrl.$valid;\n      toggleValidationCss('', ctrl.$valid);\n    }\n\n    // re-read the state as the set/unset methods could have\n    // combined state in ctrl.$error[validationError] (used for forms),\n    // where setting/unsetting only increments/decrements the value,\n    // and does not replace it.\n    var combinedState;\n    if (ctrl.$pending && ctrl.$pending[validationErrorKey]) {\n      combinedState = undefined;\n    } else if (ctrl.$error[validationErrorKey]) {\n      combinedState = false;\n    } else if (ctrl.$$success[validationErrorKey]) {\n      combinedState = true;\n    } else {\n      combinedState = null;\n    }\n\n    toggleValidationCss(validationErrorKey, combinedState);\n    ctrl.$$parentForm.$setValidity(validationErrorKey, combinedState, ctrl);\n  }\n\n  function createAndSet(name, value, controller) {\n    if (!ctrl[name]) {\n      ctrl[name] = {};\n    }\n    set(ctrl[name], value, controller);\n  }\n\n  function unsetAndCleanup(name, value, controller) {\n    if (ctrl[name]) {\n      unset(ctrl[name], value, controller);\n    }\n    if (isObjectEmpty(ctrl[name])) {\n      ctrl[name] = undefined;\n    }\n  }\n\n  function cachedToggleClass(className, switchValue) {\n    if (switchValue && !classCache[className]) {\n      $animate.addClass($element, className);\n      classCache[className] = true;\n    } else if (!switchValue && classCache[className]) {\n      $animate.removeClass($element, className);\n      classCache[className] = false;\n    }\n  }\n\n  function toggleValidationCss(validationErrorKey, isValid) {\n    validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : '';\n\n    cachedToggleClass(VALID_CLASS + validationErrorKey, isValid === true);\n    cachedToggleClass(INVALID_CLASS + validationErrorKey, isValid === false);\n  }\n}\n\nfunction isObjectEmpty(obj) {\n  if (obj) {\n    for (var prop in obj) {\n      if (obj.hasOwnProperty(prop)) {\n        return false;\n      }\n    }\n  }\n  return true;\n}\n\n/**\n * @ngdoc directive\n * @name ngNonBindable\n * @restrict AC\n * @priority 1000\n *\n * @description\n * The `ngNonBindable` directive tells Angular not to compile or bind the contents of the current\n * DOM element. This is useful if the element contains what appears to be Angular directives and\n * bindings but which should be ignored by Angular. This could be the case if you have a site that\n * displays snippets of code, for instance.\n *\n * @element ANY\n *\n * @example\n * In this example there are two locations where a simple interpolation binding (`{{}}`) is present,\n * but the one wrapped in `ngNonBindable` is left alone.\n *\n * @example\n    <example>\n      <file name=\"index.html\">\n        <div>Normal: {{1 + 2}}</div>\n        <div ng-non-bindable>Ignored: {{1 + 2}}</div>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n       it('should check ng-non-bindable', function() {\n         expect(element(by.binding('1 + 2')).getText()).toContain('3');\n         expect(element.all(by.css('div')).last().getText()).toMatch(/1 \\+ 2/);\n       });\n      </file>\n    </example>\n */\nvar ngNonBindableDirective = ngDirective({ terminal: true, priority: 1000 });\n\n/* global jqLiteRemove */\n\nvar ngOptionsMinErr = minErr('ngOptions');\n\n/**\n * @ngdoc directive\n * @name ngOptions\n * @restrict A\n *\n * @description\n *\n * The `ngOptions` attribute can be used to dynamically generate a list of `<option>`\n * elements for the `<select>` element using the array or object obtained by evaluating the\n * `ngOptions` comprehension expression.\n *\n * In many cases, `ngRepeat` can be used on `<option>` elements instead of `ngOptions` to achieve a\n * similar result. However, `ngOptions` provides some benefits such as reducing memory and\n * increasing speed by not creating a new scope for each repeated instance, as well as providing\n * more flexibility in how the `<select>`'s model is assigned via the `select` **`as`** part of the\n * comprehension expression. `ngOptions` should be used when the `<select>` model needs to be bound\n *  to a non-string value. This is because an option element can only be bound to string values at\n * present.\n *\n * When an item in the `<select>` menu is selected, the array element or object property\n * represented by the selected option will be bound to the model identified by the `ngModel`\n * directive.\n *\n * Optionally, a single hard-coded `<option>` element, with the value set to an empty string, can\n * be nested into the `<select>` element. This element will then represent the `null` or \"not selected\"\n * option. See example below for demonstration.\n *\n * ## Complex Models (objects or collections)\n *\n * By default, `ngModel` watches the model by reference, not value. This is important to know when\n * binding the select to a model that is an object or a collection.\n *\n * One issue occurs if you want to preselect an option. For example, if you set\n * the model to an object that is equal to an object in your collection, `ngOptions` won't be able to set the selection,\n * because the objects are not identical. So by default, you should always reference the item in your collection\n * for preselections, e.g.: `$scope.selected = $scope.collection[3]`.\n *\n * Another solution is to use a `track by` clause, because then `ngOptions` will track the identity\n * of the item not by reference, but by the result of the `track by` expression. For example, if your\n * collection items have an id property, you would `track by item.id`.\n *\n * A different issue with objects or collections is that ngModel won't detect if an object property or\n * a collection item changes. For that reason, `ngOptions` additionally watches the model using\n * `$watchCollection`, when the expression contains a `track by` clause or the the select has the `multiple` attribute.\n * This allows ngOptions to trigger a re-rendering of the options even if the actual object/collection\n * has not changed identity, but only a property on the object or an item in the collection changes.\n *\n * Note that `$watchCollection` does a shallow comparison of the properties of the object (or the items in the collection\n * if the model is an array). This means that changing a property deeper than the first level inside the\n * object/collection will not trigger a re-rendering.\n *\n * ## `select` **`as`**\n *\n * Using `select` **`as`** will bind the result of the `select` expression to the model, but\n * the value of the `<select>` and `<option>` html elements will be either the index (for array data sources)\n * or property name (for object data sources) of the value within the collection. If a **`track by`** expression\n * is used, the result of that expression will be set as the value of the `option` and `select` elements.\n *\n *\n * ### `select` **`as`** and **`track by`**\n *\n * <div class=\"alert alert-warning\">\n * Be careful when using `select` **`as`** and **`track by`** in the same expression.\n * </div>\n *\n * Given this array of items on the $scope:\n *\n * ```js\n * $scope.items = [{\n *   id: 1,\n *   label: 'aLabel',\n *   subItem: { name: 'aSubItem' }\n * }, {\n *   id: 2,\n *   label: 'bLabel',\n *   subItem: { name: 'bSubItem' }\n * }];\n * ```\n *\n * This will work:\n *\n * ```html\n * <select ng-options=\"item as item.label for item in items track by item.id\" ng-model=\"selected\"></select>\n * ```\n * ```js\n * $scope.selected = $scope.items[0];\n * ```\n *\n * but this will not work:\n *\n * ```html\n * <select ng-options=\"item.subItem as item.label for item in items track by item.id\" ng-model=\"selected\"></select>\n * ```\n * ```js\n * $scope.selected = $scope.items[0].subItem;\n * ```\n *\n * In both examples, the **`track by`** expression is applied successfully to each `item` in the\n * `items` array. Because the selected option has been set programmatically in the controller, the\n * **`track by`** expression is also applied to the `ngModel` value. In the first example, the\n * `ngModel` value is `items[0]` and the **`track by`** expression evaluates to `items[0].id` with\n * no issue. In the second example, the `ngModel` value is `items[0].subItem` and the **`track by`**\n * expression evaluates to `items[0].subItem.id` (which is undefined). As a result, the model value\n * is not matched against any `<option>` and the `<select>` appears as having no selected value.\n *\n *\n * @param {string} ngModel Assignable angular expression to data-bind to.\n * @param {string=} name Property name of the form under which the control is published.\n * @param {string=} required The control is considered valid only if value is entered.\n * @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to\n *    the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of\n *    `required` when you want to data-bind to the `required` attribute.\n * @param {comprehension_expression=} ngOptions in one of the following forms:\n *\n *   * for array data sources:\n *     * `label` **`for`** `value` **`in`** `array`\n *     * `select` **`as`** `label` **`for`** `value` **`in`** `array`\n *     * `label` **`group by`** `group` **`for`** `value` **`in`** `array`\n *     * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array`\n *     * `label` **`group by`** `group` **`for`** `value` **`in`** `array` **`track by`** `trackexpr`\n *     * `label` **`disable when`** `disable` **`for`** `value` **`in`** `array` **`track by`** `trackexpr`\n *     * `label` **`for`** `value` **`in`** `array` | orderBy:`orderexpr` **`track by`** `trackexpr`\n *        (for including a filter with `track by`)\n *   * for object data sources:\n *     * `label` **`for (`**`key` **`,`** `value`**`) in`** `object`\n *     * `select` **`as`** `label` **`for (`**`key` **`,`** `value`**`) in`** `object`\n *     * `label` **`group by`** `group` **`for (`**`key`**`,`** `value`**`) in`** `object`\n *     * `label` **`disable when`** `disable` **`for (`**`key`**`,`** `value`**`) in`** `object`\n *     * `select` **`as`** `label` **`group by`** `group`\n *         **`for` `(`**`key`**`,`** `value`**`) in`** `object`\n *     * `select` **`as`** `label` **`disable when`** `disable`\n *         **`for` `(`**`key`**`,`** `value`**`) in`** `object`\n *\n * Where:\n *\n *   * `array` / `object`: an expression which evaluates to an array / object to iterate over.\n *   * `value`: local variable which will refer to each item in the `array` or each property value\n *      of `object` during iteration.\n *   * `key`: local variable which will refer to a property name in `object` during iteration.\n *   * `label`: The result of this expression will be the label for `<option>` element. The\n *     `expression` will most likely refer to the `value` variable (e.g. `value.propertyName`).\n *   * `select`: The result of this expression will be bound to the model of the parent `<select>`\n *      element. If not specified, `select` expression will default to `value`.\n *   * `group`: The result of this expression will be used to group options using the `<optgroup>`\n *      DOM element.\n *   * `disable`: The result of this expression will be used to disable the rendered `<option>`\n *      element. Return `true` to disable.\n *   * `trackexpr`: Used when working with an array of objects. The result of this expression will be\n *      used to identify the objects in the array. The `trackexpr` will most likely refer to the\n *     `value` variable (e.g. `value.propertyName`). With this the selection is preserved\n *      even when the options are recreated (e.g. reloaded from the server).\n *\n * @example\n    <example module=\"selectExample\">\n      <file name=\"index.html\">\n        <script>\n        angular.module('selectExample', [])\n          .controller('ExampleController', ['$scope', function($scope) {\n            $scope.colors = [\n              {name:'black', shade:'dark'},\n              {name:'white', shade:'light', notAnOption: true},\n              {name:'red', shade:'dark'},\n              {name:'blue', shade:'dark', notAnOption: true},\n              {name:'yellow', shade:'light', notAnOption: false}\n            ];\n            $scope.myColor = $scope.colors[2]; // red\n          }]);\n        </script>\n        <div ng-controller=\"ExampleController\">\n          <ul>\n            <li ng-repeat=\"color in colors\">\n              <label>Name: <input ng-model=\"color.name\"></label>\n              <label><input type=\"checkbox\" ng-model=\"color.notAnOption\"> Disabled?</label>\n              <button ng-click=\"colors.splice($index, 1)\" aria-label=\"Remove\">X</button>\n            </li>\n            <li>\n              <button ng-click=\"colors.push({})\">add</button>\n            </li>\n          </ul>\n          <hr/>\n          <label>Color (null not allowed):\n            <select ng-model=\"myColor\" ng-options=\"color.name for color in colors\"></select>\n          </label><br/>\n          <label>Color (null allowed):\n          <span  class=\"nullable\">\n            <select ng-model=\"myColor\" ng-options=\"color.name for color in colors\">\n              <option value=\"\">-- choose color --</option>\n            </select>\n          </span></label><br/>\n\n          <label>Color grouped by shade:\n            <select ng-model=\"myColor\" ng-options=\"color.name group by color.shade for color in colors\">\n            </select>\n          </label><br/>\n\n          <label>Color grouped by shade, with some disabled:\n            <select ng-model=\"myColor\"\n                  ng-options=\"color.name group by color.shade disable when color.notAnOption for color in colors\">\n            </select>\n          </label><br/>\n\n\n\n          Select <button ng-click=\"myColor = { name:'not in list', shade: 'other' }\">bogus</button>.\n          <br/>\n          <hr/>\n          Currently selected: {{ {selected_color:myColor} }}\n          <div style=\"border:solid 1px black; height:20px\"\n               ng-style=\"{'background-color':myColor.name}\">\n          </div>\n        </div>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n         it('should check ng-options', function() {\n           expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('red');\n           element.all(by.model('myColor')).first().click();\n           element.all(by.css('select[ng-model=\"myColor\"] option')).first().click();\n           expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('black');\n           element(by.css('.nullable select[ng-model=\"myColor\"]')).click();\n           element.all(by.css('.nullable select[ng-model=\"myColor\"] option')).first().click();\n           expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('null');\n         });\n      </file>\n    </example>\n */\n\n// jshint maxlen: false\n//                     //00001111111111000000000002222222222000000000000000000000333333333300000000000000000000000004444444444400000000000005555555555555550000000006666666666666660000000777777777777777000000000000000888888888800000000000000000009999999999\nvar NG_OPTIONS_REGEXP = /^\\s*([\\s\\S]+?)(?:\\s+as\\s+([\\s\\S]+?))?(?:\\s+group\\s+by\\s+([\\s\\S]+?))?(?:\\s+disable\\s+when\\s+([\\s\\S]+?))?\\s+for\\s+(?:([\\$\\w][\\$\\w]*)|(?:\\(\\s*([\\$\\w][\\$\\w]*)\\s*,\\s*([\\$\\w][\\$\\w]*)\\s*\\)))\\s+in\\s+([\\s\\S]+?)(?:\\s+track\\s+by\\s+([\\s\\S]+?))?$/;\n                        // 1: value expression (valueFn)\n                        // 2: label expression (displayFn)\n                        // 3: group by expression (groupByFn)\n                        // 4: disable when expression (disableWhenFn)\n                        // 5: array item variable name\n                        // 6: object item key variable name\n                        // 7: object item value variable name\n                        // 8: collection expression\n                        // 9: track by expression\n// jshint maxlen: 100\n\n\nvar ngOptionsDirective = ['$compile', '$document', '$parse', function($compile, $document, $parse) {\n\n  function parseOptionsExpression(optionsExp, selectElement, scope) {\n\n    var match = optionsExp.match(NG_OPTIONS_REGEXP);\n    if (!(match)) {\n      throw ngOptionsMinErr('iexp',\n        \"Expected expression in form of \" +\n        \"'_select_ (as _label_)? for (_key_,)?_value_ in _collection_'\" +\n        \" but got '{0}'. Element: {1}\",\n        optionsExp, startingTag(selectElement));\n    }\n\n    // Extract the parts from the ngOptions expression\n\n    // The variable name for the value of the item in the collection\n    var valueName = match[5] || match[7];\n    // The variable name for the key of the item in the collection\n    var keyName = match[6];\n\n    // An expression that generates the viewValue for an option if there is a label expression\n    var selectAs = / as /.test(match[0]) && match[1];\n    // An expression that is used to track the id of each object in the options collection\n    var trackBy = match[9];\n    // An expression that generates the viewValue for an option if there is no label expression\n    var valueFn = $parse(match[2] ? match[1] : valueName);\n    var selectAsFn = selectAs && $parse(selectAs);\n    var viewValueFn = selectAsFn || valueFn;\n    var trackByFn = trackBy && $parse(trackBy);\n\n    // Get the value by which we are going to track the option\n    // if we have a trackFn then use that (passing scope and locals)\n    // otherwise just hash the given viewValue\n    var getTrackByValueFn = trackBy ?\n                              function(value, locals) { return trackByFn(scope, locals); } :\n                              function getHashOfValue(value) { return hashKey(value); };\n    var getTrackByValue = function(value, key) {\n      return getTrackByValueFn(value, getLocals(value, key));\n    };\n\n    var displayFn = $parse(match[2] || match[1]);\n    var groupByFn = $parse(match[3] || '');\n    var disableWhenFn = $parse(match[4] || '');\n    var valuesFn = $parse(match[8]);\n\n    var locals = {};\n    var getLocals = keyName ? function(value, key) {\n      locals[keyName] = key;\n      locals[valueName] = value;\n      return locals;\n    } : function(value) {\n      locals[valueName] = value;\n      return locals;\n    };\n\n\n    function Option(selectValue, viewValue, label, group, disabled) {\n      this.selectValue = selectValue;\n      this.viewValue = viewValue;\n      this.label = label;\n      this.group = group;\n      this.disabled = disabled;\n    }\n\n    function getOptionValuesKeys(optionValues) {\n      var optionValuesKeys;\n\n      if (!keyName && isArrayLike(optionValues)) {\n        optionValuesKeys = optionValues;\n      } else {\n        // if object, extract keys, in enumeration order, unsorted\n        optionValuesKeys = [];\n        for (var itemKey in optionValues) {\n          if (optionValues.hasOwnProperty(itemKey) && itemKey.charAt(0) !== '$') {\n            optionValuesKeys.push(itemKey);\n          }\n        }\n      }\n      return optionValuesKeys;\n    }\n\n    return {\n      trackBy: trackBy,\n      getTrackByValue: getTrackByValue,\n      getWatchables: $parse(valuesFn, function(optionValues) {\n        // Create a collection of things that we would like to watch (watchedArray)\n        // so that they can all be watched using a single $watchCollection\n        // that only runs the handler once if anything changes\n        var watchedArray = [];\n        optionValues = optionValues || [];\n\n        var optionValuesKeys = getOptionValuesKeys(optionValues);\n        var optionValuesLength = optionValuesKeys.length;\n        for (var index = 0; index < optionValuesLength; index++) {\n          var key = (optionValues === optionValuesKeys) ? index : optionValuesKeys[index];\n          var value = optionValues[key];\n\n          var locals = getLocals(value, key);\n          var selectValue = getTrackByValueFn(value, locals);\n          watchedArray.push(selectValue);\n\n          // Only need to watch the displayFn if there is a specific label expression\n          if (match[2] || match[1]) {\n            var label = displayFn(scope, locals);\n            watchedArray.push(label);\n          }\n\n          // Only need to watch the disableWhenFn if there is a specific disable expression\n          if (match[4]) {\n            var disableWhen = disableWhenFn(scope, locals);\n            watchedArray.push(disableWhen);\n          }\n        }\n        return watchedArray;\n      }),\n\n      getOptions: function() {\n\n        var optionItems = [];\n        var selectValueMap = {};\n\n        // The option values were already computed in the `getWatchables` fn,\n        // which must have been called to trigger `getOptions`\n        var optionValues = valuesFn(scope) || [];\n        var optionValuesKeys = getOptionValuesKeys(optionValues);\n        var optionValuesLength = optionValuesKeys.length;\n\n        for (var index = 0; index < optionValuesLength; index++) {\n          var key = (optionValues === optionValuesKeys) ? index : optionValuesKeys[index];\n          var value = optionValues[key];\n          var locals = getLocals(value, key);\n          var viewValue = viewValueFn(scope, locals);\n          var selectValue = getTrackByValueFn(viewValue, locals);\n          var label = displayFn(scope, locals);\n          var group = groupByFn(scope, locals);\n          var disabled = disableWhenFn(scope, locals);\n          var optionItem = new Option(selectValue, viewValue, label, group, disabled);\n\n          optionItems.push(optionItem);\n          selectValueMap[selectValue] = optionItem;\n        }\n\n        return {\n          items: optionItems,\n          selectValueMap: selectValueMap,\n          getOptionFromViewValue: function(value) {\n            return selectValueMap[getTrackByValue(value)];\n          },\n          getViewValueFromOption: function(option) {\n            // If the viewValue could be an object that may be mutated by the application,\n            // we need to make a copy and not return the reference to the value on the option.\n            return trackBy ? angular.copy(option.viewValue) : option.viewValue;\n          }\n        };\n      }\n    };\n  }\n\n\n  // we can't just jqLite('<option>') since jqLite is not smart enough\n  // to create it in <select> and IE barfs otherwise.\n  var optionTemplate = window.document.createElement('option'),\n      optGroupTemplate = window.document.createElement('optgroup');\n\n    function ngOptionsPostLink(scope, selectElement, attr, ctrls) {\n\n      var selectCtrl = ctrls[0];\n      var ngModelCtrl = ctrls[1];\n      var multiple = attr.multiple;\n\n      // The emptyOption allows the application developer to provide their own custom \"empty\"\n      // option when the viewValue does not match any of the option values.\n      var emptyOption;\n      for (var i = 0, children = selectElement.children(), ii = children.length; i < ii; i++) {\n        if (children[i].value === '') {\n          emptyOption = children.eq(i);\n          break;\n        }\n      }\n\n      var providedEmptyOption = !!emptyOption;\n\n      var unknownOption = jqLite(optionTemplate.cloneNode(false));\n      unknownOption.val('?');\n\n      var options;\n      var ngOptions = parseOptionsExpression(attr.ngOptions, selectElement, scope);\n      // This stores the newly created options before they are appended to the select.\n      // Since the contents are removed from the fragment when it is appended,\n      // we only need to create it once.\n      var listFragment = $document[0].createDocumentFragment();\n\n      var renderEmptyOption = function() {\n        if (!providedEmptyOption) {\n          selectElement.prepend(emptyOption);\n        }\n        selectElement.val('');\n        emptyOption.prop('selected', true); // needed for IE\n        emptyOption.attr('selected', true);\n      };\n\n      var removeEmptyOption = function() {\n        if (!providedEmptyOption) {\n          emptyOption.remove();\n        }\n      };\n\n\n      var renderUnknownOption = function() {\n        selectElement.prepend(unknownOption);\n        selectElement.val('?');\n        unknownOption.prop('selected', true); // needed for IE\n        unknownOption.attr('selected', true);\n      };\n\n      var removeUnknownOption = function() {\n        unknownOption.remove();\n      };\n\n      // Update the controller methods for multiple selectable options\n      if (!multiple) {\n\n        selectCtrl.writeValue = function writeNgOptionsValue(value) {\n          var option = options.getOptionFromViewValue(value);\n\n          if (option) {\n            // Don't update the option when it is already selected.\n            // For example, the browser will select the first option by default. In that case,\n            // most properties are set automatically - except the `selected` attribute, which we\n            // set always\n\n            if (selectElement[0].value !== option.selectValue) {\n              removeUnknownOption();\n              removeEmptyOption();\n\n              selectElement[0].value = option.selectValue;\n              option.element.selected = true;\n            }\n\n            option.element.setAttribute('selected', 'selected');\n          } else {\n            if (value === null || providedEmptyOption) {\n              removeUnknownOption();\n              renderEmptyOption();\n            } else {\n              removeEmptyOption();\n              renderUnknownOption();\n            }\n          }\n        };\n\n        selectCtrl.readValue = function readNgOptionsValue() {\n\n          var selectedOption = options.selectValueMap[selectElement.val()];\n\n          if (selectedOption && !selectedOption.disabled) {\n            removeEmptyOption();\n            removeUnknownOption();\n            return options.getViewValueFromOption(selectedOption);\n          }\n          return null;\n        };\n\n        // If we are using `track by` then we must watch the tracked value on the model\n        // since ngModel only watches for object identity change\n        if (ngOptions.trackBy) {\n          scope.$watch(\n            function() { return ngOptions.getTrackByValue(ngModelCtrl.$viewValue); },\n            function() { ngModelCtrl.$render(); }\n          );\n        }\n\n      } else {\n\n        ngModelCtrl.$isEmpty = function(value) {\n          return !value || value.length === 0;\n        };\n\n\n        selectCtrl.writeValue = function writeNgOptionsMultiple(value) {\n          options.items.forEach(function(option) {\n            option.element.selected = false;\n          });\n\n          if (value) {\n            value.forEach(function(item) {\n              var option = options.getOptionFromViewValue(item);\n              if (option) option.element.selected = true;\n            });\n          }\n        };\n\n\n        selectCtrl.readValue = function readNgOptionsMultiple() {\n          var selectedValues = selectElement.val() || [],\n              selections = [];\n\n          forEach(selectedValues, function(value) {\n            var option = options.selectValueMap[value];\n            if (option && !option.disabled) selections.push(options.getViewValueFromOption(option));\n          });\n\n          return selections;\n        };\n\n        // If we are using `track by` then we must watch these tracked values on the model\n        // since ngModel only watches for object identity change\n        if (ngOptions.trackBy) {\n\n          scope.$watchCollection(function() {\n            if (isArray(ngModelCtrl.$viewValue)) {\n              return ngModelCtrl.$viewValue.map(function(value) {\n                return ngOptions.getTrackByValue(value);\n              });\n            }\n          }, function() {\n            ngModelCtrl.$render();\n          });\n\n        }\n      }\n\n\n      if (providedEmptyOption) {\n\n        // we need to remove it before calling selectElement.empty() because otherwise IE will\n        // remove the label from the element. wtf?\n        emptyOption.remove();\n\n        // compile the element since there might be bindings in it\n        $compile(emptyOption)(scope);\n\n        // remove the class, which is added automatically because we recompile the element and it\n        // becomes the compilation root\n        emptyOption.removeClass('ng-scope');\n      } else {\n        emptyOption = jqLite(optionTemplate.cloneNode(false));\n      }\n\n      selectElement.empty();\n\n      // We need to do this here to ensure that the options object is defined\n      // when we first hit it in writeNgOptionsValue\n      updateOptions();\n\n      // We will re-render the option elements if the option values or labels change\n      scope.$watchCollection(ngOptions.getWatchables, updateOptions);\n\n      // ------------------------------------------------------------------ //\n\n      function addOptionElement(option, parent) {\n        var optionElement = optionTemplate.cloneNode(false);\n        parent.appendChild(optionElement);\n        updateOptionElement(option, optionElement);\n      }\n\n\n      function updateOptionElement(option, element) {\n        option.element = element;\n        element.disabled = option.disabled;\n        // NOTE: The label must be set before the value, otherwise IE10/11/EDGE create unresponsive\n        // selects in certain circumstances when multiple selects are next to each other and display\n        // the option list in listbox style, i.e. the select is [multiple], or specifies a [size].\n        // See https://github.com/angular/angular.js/issues/11314 for more info.\n        // This is unfortunately untestable with unit / e2e tests\n        if (option.label !== element.label) {\n          element.label = option.label;\n          element.textContent = option.label;\n        }\n        if (option.value !== element.value) element.value = option.selectValue;\n      }\n\n      function updateOptions() {\n        var previousValue = options && selectCtrl.readValue();\n\n        // We must remove all current options, but cannot simply set innerHTML = null\n        // since the providedEmptyOption might have an ngIf on it that inserts comments which we\n        // must preserve.\n        // Instead, iterate over the current option elements and remove them or their optgroup\n        // parents\n        if (options) {\n\n          for (var i = options.items.length - 1; i >= 0; i--) {\n            var option = options.items[i];\n            if (option.group) {\n              jqLiteRemove(option.element.parentNode);\n            } else {\n              jqLiteRemove(option.element);\n            }\n          }\n        }\n\n        options = ngOptions.getOptions();\n\n        var groupElementMap = {};\n\n        // Ensure that the empty option is always there if it was explicitly provided\n        if (providedEmptyOption) {\n          selectElement.prepend(emptyOption);\n        }\n\n        options.items.forEach(function addOption(option) {\n          var groupElement;\n\n          if (isDefined(option.group)) {\n\n            // This option is to live in a group\n            // See if we have already created this group\n            groupElement = groupElementMap[option.group];\n\n            if (!groupElement) {\n\n              groupElement = optGroupTemplate.cloneNode(false);\n              listFragment.appendChild(groupElement);\n\n              // Update the label on the group element\n              groupElement.label = option.group;\n\n              // Store it for use later\n              groupElementMap[option.group] = groupElement;\n            }\n\n            addOptionElement(option, groupElement);\n\n          } else {\n\n            // This option is not in a group\n            addOptionElement(option, listFragment);\n          }\n        });\n\n        selectElement[0].appendChild(listFragment);\n\n        ngModelCtrl.$render();\n\n        // Check to see if the value has changed due to the update to the options\n        if (!ngModelCtrl.$isEmpty(previousValue)) {\n          var nextValue = selectCtrl.readValue();\n          var isNotPrimitive = ngOptions.trackBy || multiple;\n          if (isNotPrimitive ? !equals(previousValue, nextValue) : previousValue !== nextValue) {\n            ngModelCtrl.$setViewValue(nextValue);\n            ngModelCtrl.$render();\n          }\n        }\n\n      }\n  }\n\n  return {\n    restrict: 'A',\n    terminal: true,\n    require: ['select', 'ngModel'],\n    link: {\n      pre: function ngOptionsPreLink(scope, selectElement, attr, ctrls) {\n        // Deactivate the SelectController.register method to prevent\n        // option directives from accidentally registering themselves\n        // (and unwanted $destroy handlers etc.)\n        ctrls[0].registerOption = noop;\n      },\n      post: ngOptionsPostLink\n    }\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngPluralize\n * @restrict EA\n *\n * @description\n * `ngPluralize` is a directive that displays messages according to en-US localization rules.\n * These rules are bundled with angular.js, but can be overridden\n * (see {@link guide/i18n Angular i18n} dev guide). You configure ngPluralize directive\n * by specifying the mappings between\n * [plural categories](http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html)\n * and the strings to be displayed.\n *\n * # Plural categories and explicit number rules\n * There are two\n * [plural categories](http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html)\n * in Angular's default en-US locale: \"one\" and \"other\".\n *\n * While a plural category may match many numbers (for example, in en-US locale, \"other\" can match\n * any number that is not 1), an explicit number rule can only match one number. For example, the\n * explicit number rule for \"3\" matches the number 3. There are examples of plural categories\n * and explicit number rules throughout the rest of this documentation.\n *\n * # Configuring ngPluralize\n * You configure ngPluralize by providing 2 attributes: `count` and `when`.\n * You can also provide an optional attribute, `offset`.\n *\n * The value of the `count` attribute can be either a string or an {@link guide/expression\n * Angular expression}; these are evaluated on the current scope for its bound value.\n *\n * The `when` attribute specifies the mappings between plural categories and the actual\n * string to be displayed. The value of the attribute should be a JSON object.\n *\n * The following example shows how to configure ngPluralize:\n *\n * ```html\n * <ng-pluralize count=\"personCount\"\n                 when=\"{'0': 'Nobody is viewing.',\n *                      'one': '1 person is viewing.',\n *                      'other': '{} people are viewing.'}\">\n * </ng-pluralize>\n *```\n *\n * In the example, `\"0: Nobody is viewing.\"` is an explicit number rule. If you did not\n * specify this rule, 0 would be matched to the \"other\" category and \"0 people are viewing\"\n * would be shown instead of \"Nobody is viewing\". You can specify an explicit number rule for\n * other numbers, for example 12, so that instead of showing \"12 people are viewing\", you can\n * show \"a dozen people are viewing\".\n *\n * You can use a set of closed braces (`{}`) as a placeholder for the number that you want substituted\n * into pluralized strings. In the previous example, Angular will replace `{}` with\n * <span ng-non-bindable>`{{personCount}}`</span>. The closed braces `{}` is a placeholder\n * for <span ng-non-bindable>{{numberExpression}}</span>.\n *\n * If no rule is defined for a category, then an empty string is displayed and a warning is generated.\n * Note that some locales define more categories than `one` and `other`. For example, fr-fr defines `few` and `many`.\n *\n * # Configuring ngPluralize with offset\n * The `offset` attribute allows further customization of pluralized text, which can result in\n * a better user experience. For example, instead of the message \"4 people are viewing this document\",\n * you might display \"John, Kate and 2 others are viewing this document\".\n * The offset attribute allows you to offset a number by any desired value.\n * Let's take a look at an example:\n *\n * ```html\n * <ng-pluralize count=\"personCount\" offset=2\n *               when=\"{'0': 'Nobody is viewing.',\n *                      '1': '{{person1}} is viewing.',\n *                      '2': '{{person1}} and {{person2}} are viewing.',\n *                      'one': '{{person1}}, {{person2}} and one other person are viewing.',\n *                      'other': '{{person1}}, {{person2}} and {} other people are viewing.'}\">\n * </ng-pluralize>\n * ```\n *\n * Notice that we are still using two plural categories(one, other), but we added\n * three explicit number rules 0, 1 and 2.\n * When one person, perhaps John, views the document, \"John is viewing\" will be shown.\n * When three people view the document, no explicit number rule is found, so\n * an offset of 2 is taken off 3, and Angular uses 1 to decide the plural category.\n * In this case, plural category 'one' is matched and \"John, Mary and one other person are viewing\"\n * is shown.\n *\n * Note that when you specify offsets, you must provide explicit number rules for\n * numbers from 0 up to and including the offset. If you use an offset of 3, for example,\n * you must provide explicit number rules for 0, 1, 2 and 3. You must also provide plural strings for\n * plural categories \"one\" and \"other\".\n *\n * @param {string|expression} count The variable to be bound to.\n * @param {string} when The mapping between plural category to its corresponding strings.\n * @param {number=} offset Offset to deduct from the total number.\n *\n * @example\n    <example module=\"pluralizeExample\">\n      <file name=\"index.html\">\n        <script>\n          angular.module('pluralizeExample', [])\n            .controller('ExampleController', ['$scope', function($scope) {\n              $scope.person1 = 'Igor';\n              $scope.person2 = 'Misko';\n              $scope.personCount = 1;\n            }]);\n        </script>\n        <div ng-controller=\"ExampleController\">\n          <label>Person 1:<input type=\"text\" ng-model=\"person1\" value=\"Igor\" /></label><br/>\n          <label>Person 2:<input type=\"text\" ng-model=\"person2\" value=\"Misko\" /></label><br/>\n          <label>Number of People:<input type=\"text\" ng-model=\"personCount\" value=\"1\" /></label><br/>\n\n          <!--- Example with simple pluralization rules for en locale --->\n          Without Offset:\n          <ng-pluralize count=\"personCount\"\n                        when=\"{'0': 'Nobody is viewing.',\n                               'one': '1 person is viewing.',\n                               'other': '{} people are viewing.'}\">\n          </ng-pluralize><br>\n\n          <!--- Example with offset --->\n          With Offset(2):\n          <ng-pluralize count=\"personCount\" offset=2\n                        when=\"{'0': 'Nobody is viewing.',\n                               '1': '{{person1}} is viewing.',\n                               '2': '{{person1}} and {{person2}} are viewing.',\n                               'one': '{{person1}}, {{person2}} and one other person are viewing.',\n                               'other': '{{person1}}, {{person2}} and {} other people are viewing.'}\">\n          </ng-pluralize>\n        </div>\n      </file>\n      <file name=\"protractor.js\" type=\"protractor\">\n        it('should show correct pluralized string', function() {\n          var withoutOffset = element.all(by.css('ng-pluralize')).get(0);\n          var withOffset = element.all(by.css('ng-pluralize')).get(1);\n          var countInput = element(by.model('personCount'));\n\n          expect(withoutOffset.getText()).toEqual('1 person is viewing.');\n          expect(withOffset.getText()).toEqual('Igor is viewing.');\n\n          countInput.clear();\n          countInput.sendKeys('0');\n\n          expect(withoutOffset.getText()).toEqual('Nobody is viewing.');\n          expect(withOffset.getText()).toEqual('Nobody is viewing.');\n\n          countInput.clear();\n          countInput.sendKeys('2');\n\n          expect(withoutOffset.getText()).toEqual('2 people are viewing.');\n          expect(withOffset.getText()).toEqual('Igor and Misko are viewing.');\n\n          countInput.clear();\n          countInput.sendKeys('3');\n\n          expect(withoutOffset.getText()).toEqual('3 people are viewing.');\n          expect(withOffset.getText()).toEqual('Igor, Misko and one other person are viewing.');\n\n          countInput.clear();\n          countInput.sendKeys('4');\n\n          expect(withoutOffset.getText()).toEqual('4 people are viewing.');\n          expect(withOffset.getText()).toEqual('Igor, Misko and 2 other people are viewing.');\n        });\n        it('should show data-bound names', function() {\n          var withOffset = element.all(by.css('ng-pluralize')).get(1);\n          var personCount = element(by.model('personCount'));\n          var person1 = element(by.model('person1'));\n          var person2 = element(by.model('person2'));\n          personCount.clear();\n          personCount.sendKeys('4');\n          person1.clear();\n          person1.sendKeys('Di');\n          person2.clear();\n          person2.sendKeys('Vojta');\n          expect(withOffset.getText()).toEqual('Di, Vojta and 2 other people are viewing.');\n        });\n      </file>\n    </example>\n */\nvar ngPluralizeDirective = ['$locale', '$interpolate', '$log', function($locale, $interpolate, $log) {\n  var BRACE = /{}/g,\n      IS_WHEN = /^when(Minus)?(.+)$/;\n\n  return {\n    link: function(scope, element, attr) {\n      var numberExp = attr.count,\n          whenExp = attr.$attr.when && element.attr(attr.$attr.when), // we have {{}} in attrs\n          offset = attr.offset || 0,\n          whens = scope.$eval(whenExp) || {},\n          whensExpFns = {},\n          startSymbol = $interpolate.startSymbol(),\n          endSymbol = $interpolate.endSymbol(),\n          braceReplacement = startSymbol + numberExp + '-' + offset + endSymbol,\n          watchRemover = angular.noop,\n          lastCount;\n\n      forEach(attr, function(expression, attributeName) {\n        var tmpMatch = IS_WHEN.exec(attributeName);\n        if (tmpMatch) {\n          var whenKey = (tmpMatch[1] ? '-' : '') + lowercase(tmpMatch[2]);\n          whens[whenKey] = element.attr(attr.$attr[attributeName]);\n        }\n      });\n      forEach(whens, function(expression, key) {\n        whensExpFns[key] = $interpolate(expression.replace(BRACE, braceReplacement));\n\n      });\n\n      scope.$watch(numberExp, function ngPluralizeWatchAction(newVal) {\n        var count = parseFloat(newVal);\n        var countIsNaN = isNaN(count);\n\n        if (!countIsNaN && !(count in whens)) {\n          // If an explicit number rule such as 1, 2, 3... is defined, just use it.\n          // Otherwise, check it against pluralization rules in $locale service.\n          count = $locale.pluralCat(count - offset);\n        }\n\n        // If both `count` and `lastCount` are NaN, we don't need to re-register a watch.\n        // In JS `NaN !== NaN`, so we have to explicitly check.\n        if ((count !== lastCount) && !(countIsNaN && isNumber(lastCount) && isNaN(lastCount))) {\n          watchRemover();\n          var whenExpFn = whensExpFns[count];\n          if (isUndefined(whenExpFn)) {\n            if (newVal != null) {\n              $log.debug(\"ngPluralize: no rule defined for '\" + count + \"' in \" + whenExp);\n            }\n            watchRemover = noop;\n            updateElementText();\n          } else {\n            watchRemover = scope.$watch(whenExpFn, updateElementText);\n          }\n          lastCount = count;\n        }\n      });\n\n      function updateElementText(newText) {\n        element.text(newText || '');\n      }\n    }\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngRepeat\n * @multiElement\n *\n * @description\n * The `ngRepeat` directive instantiates a template once per item from a collection. Each template\n * instance gets its own scope, where the given loop variable is set to the current collection item,\n * and `$index` is set to the item index or key.\n *\n * Special properties are exposed on the local scope of each template instance, including:\n *\n * | Variable  | Type            | Details                                                                     |\n * |-----------|-----------------|-----------------------------------------------------------------------------|\n * | `$index`  | {@type number}  | iterator offset of the repeated element (0..length-1)                       |\n * | `$first`  | {@type boolean} | true if the repeated element is first in the iterator.                      |\n * | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. |\n * | `$last`   | {@type boolean} | true if the repeated element is last in the iterator.                       |\n * | `$even`   | {@type boolean} | true if the iterator position `$index` is even (otherwise false).           |\n * | `$odd`    | {@type boolean} | true if the iterator position `$index` is odd (otherwise false).            |\n *\n * <div class=\"alert alert-info\">\n *   Creating aliases for these properties is possible with {@link ng.directive:ngInit `ngInit`}.\n *   This may be useful when, for instance, nesting ngRepeats.\n * </div>\n *\n *\n * # Iterating over object properties\n *\n * It is possible to get `ngRepeat` to iterate over the properties of an object using the following\n * syntax:\n *\n * ```js\n * <div ng-repeat=\"(key, value) in myObj\"> ... </div>\n * ```\n *\n * However, there are a limitations compared to array iteration:\n *\n * - The JavaScript specification does not define the order of keys\n *   returned for an object, so Angular relies on the order returned by the browser\n *   when running `for key in myObj`. Browsers generally follow the strategy of providing\n *   keys in the order in which they were defined, although there are exceptions when keys are deleted\n *   and reinstated. See the\n *   [MDN page on `delete` for more info](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete#Cross-browser_notes).\n *\n * - `ngRepeat` will silently *ignore* object keys starting with `$`, because\n *   it's a prefix used by Angular for public (`$`) and private (`$$`) properties.\n *\n * - The built-in filters {@link ng.orderBy orderBy} and {@link ng.filter filter} do not work with\n *   objects, and will throw if used with one.\n *\n * If you are hitting any of these limitations, the recommended workaround is to convert your object into an array\n * that is sorted into the order that you prefer before providing it to `ngRepeat`. You could\n * do this with a filter such as [toArrayFilter](http://ngmodules.org/modules/angular-toArrayFilter)\n * or implement a `$watch` on the object yourself.\n *\n *\n * # Tracking and Duplicates\n *\n * `ngRepeat` uses {@link $rootScope.Scope#$watchCollection $watchCollection} to detect changes in\n * the collection. When a change happens, ngRepeat then makes the corresponding changes to the DOM:\n *\n * * When an item is added, a new instance of the template is added to the DOM.\n * * When an item is removed, its template instance is removed from the DOM.\n * * When items are reordered, their respective templates are reordered in the DOM.\n *\n * To minimize creation of DOM elements, `ngRepeat` uses a function\n * to \"keep track\" of all items in the collection and their corresponding DOM elements.\n * For example, if an item is added to the collection, ngRepeat will know that all other items\n * already have DOM elements, and will not re-render them.\n *\n * The default tracking function (which tracks items by their identity) does not allow\n * duplicate items in arrays. This is because when there are duplicates, it is not possible\n * to maintain a one-to-one mapping between collection items and DOM elements.\n *\n * If you do need to repeat duplicate items, you can substitute the default tracking behavior\n * with your own using the `track by` expression.\n *\n * For example, you may track items by the index of each item in the collection, using the\n * special scope property `$index`:\n * ```html\n *    <div ng-repeat=\"n in [42, 42, 43, 43] track by $index\">\n *      {{n}}\n *    </div>\n * ```\n *\n * You may also use arbitrary expressions in `track by`, including references to custom functions\n * on the scope:\n * ```html\n *    <div ng-repeat=\"n in [42, 42, 43, 43] track by myTrackingFunction(n)\">\n *      {{n}}\n *    </div>\n * ```\n *\n * <div class=\"alert alert-success\">\n * If you are working with objects that have an identifier property, you should track\n * by the identifier instead of the whole object. Should you reload your data later, `ngRepeat`\n * will not have to rebuild the DOM elements for items it has already rendered, even if the\n * JavaScript objects in the collection have been substituted for new ones. For large collections,\n * this significantly improves rendering performance. If you don't have a unique identifier,\n * `track by $index` can also provide a performance boost.\n * </div>\n * ```html\n *    <div ng-repeat=\"model in collection track by model.id\">\n *      {{model.name}}\n *    </div>\n * ```\n *\n * When no `track by` expression is provided, it is equivalent to tracking by the built-in\n * `$id` function, which tracks items by their identity:\n * ```html\n *    <div ng-repeat=\"obj in collection track by $id(obj)\">\n *      {{obj.prop}}\n *    </div>\n * ```\n *\n * <div class=\"alert alert-warning\">\n * **Note:** `track by` must always be the last expression:\n * </div>\n * ```\n * <div ng-repeat=\"model in collection | orderBy: 'id' as filtered_result track by model.id\">\n *     {{model.name}}\n * </div>\n * ```\n *\n * # Special repeat start and end points\n * To repeat a series of elements instead of just one parent element, ngRepeat (as well as other ng directives) supports extending\n * the range of the repeater by defining explicit start and end points by using **ng-repeat-start** and **ng-repeat-end** respectively.\n * The **ng-repeat-start** directive works the same as **ng-repeat**, but will repeat all the HTML code (including the tag it's defined on)\n * up to and including the ending HTML tag where **ng-repeat-end** is placed.\n *\n * The example below makes use of this feature:\n * ```html\n *   <header ng-repeat-start=\"item in items\">\n *     Header {{ item }}\n *   </header>\n *   <div class=\"body\">\n *     Body {{ item }}\n *   </div>\n *   <footer ng-repeat-end>\n *     Footer {{ item }}\n *   </footer>\n * ```\n *\n * And with an input of {@type ['A','B']} for the items variable in the example above, the output will evaluate to:\n * ```html\n *   <header>\n *     Header A\n *   </header>\n *   <div class=\"body\">\n *     Body A\n *   </div>\n *   <footer>\n *     Footer A\n *   </footer>\n *   <header>\n *     Header B\n *   </header>\n *   <div class=\"body\">\n *     Body B\n *   </div>\n *   <footer>\n *     Footer B\n *   </footer>\n * ```\n *\n * The custom start and end points for ngRepeat also support all other HTML directive syntax flavors provided in AngularJS (such\n * as **data-ng-repeat-start**, **x-ng-repeat-start** and **ng:repeat-start**).\n *\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link ng.$animate#enter enter} | when a new item is added to the list or when an item is revealed after a filter |\n * | {@link ng.$animate#leave leave} | when an item is removed from the list or when an item is filtered out |\n * | {@link ng.$animate#move move } | when an adjacent item is filtered out causing a reorder or when the item contents are reordered |\n *\n * See the example below for defining CSS animations with ngRepeat.\n *\n * @element ANY\n * @scope\n * @priority 1000\n * @param {repeat_expression} ngRepeat The expression indicating how to enumerate a collection. These\n *   formats are currently supported:\n *\n *   * `variable in expression` – where variable is the user defined loop variable and `expression`\n *     is a scope expression giving the collection to enumerate.\n *\n *     For example: `album in artist.albums`.\n *\n *   * `(key, value) in expression` – where `key` and `value` can be any user defined identifiers,\n *     and `expression` is the scope expression giving the collection to enumerate.\n *\n *     For example: `(name, age) in {'adam':10, 'amalie':12}`.\n *\n *   * `variable in expression track by tracking_expression` – You can also provide an optional tracking expression\n *     which can be used to associate the objects in the collection with the DOM elements. If no tracking expression\n *     is specified, ng-repeat associates elements by identity. It is an error to have\n *     more than one tracking expression value resolve to the same key. (This would mean that two distinct objects are\n *     mapped to the same DOM element, which is not possible.)\n *\n *     Note that the tracking expression must come last, after any filters, and the alias expression.\n *\n *     For example: `item in items` is equivalent to `item in items track by $id(item)`. This implies that the DOM elements\n *     will be associated by item identity in the array.\n *\n *     For example: `item in items track by $id(item)`. A built in `$id()` function can be used to assign a unique\n *     `$$hashKey` property to each item in the array. This property is then used as a key to associated DOM elements\n *     with the corresponding item in the array by identity. Moving the same object in array would move the DOM\n *     element in the same way in the DOM.\n *\n *     For example: `item in items track by item.id` is a typical pattern when the items come from the database. In this\n *     case the object identity does not matter. Two objects are considered equivalent as long as their `id`\n *     property is same.\n *\n *     For example: `item in items | filter:searchText track by item.id` is a pattern that might be used to apply a filter\n *     to items in conjunction with a tracking expression.\n *\n *   * `variable in expression as alias_expression` – You can also provide an optional alias expression which will then store the\n *     intermediate results of the repeater after the filters have been applied. Typically this is used to render a special message\n *     when a filter is active on the repeater, but the filtered result set is empty.\n *\n *     For example: `item in items | filter:x as results` will store the fragment of the repeated items as `results`, but only after\n *     the items have been processed through the filter.\n *\n *     Please note that `as [variable name] is not an operator but rather a part of ngRepeat micro-syntax so it can be used only at the end\n *     (and not as operator, inside an expression).\n *\n *     For example: `item in items | filter : x | orderBy : order | limitTo : limit as results` .\n *\n * @example\n * This example uses `ngRepeat` to display a list of people. A filter is used to restrict the displayed\n * results by name. New (entering) and removed (leaving) items are animated.\n  <example module=\"ngRepeat\" name=\"ngRepeat\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n      <div ng-controller=\"repeatController\">\n        I have {{friends.length}} friends. They are:\n        <input type=\"search\" ng-model=\"q\" placeholder=\"filter friends...\" aria-label=\"filter friends\" />\n        <ul class=\"example-animate-container\">\n          <li class=\"animate-repeat\" ng-repeat=\"friend in friends | filter:q as results\">\n            [{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old.\n          </li>\n          <li class=\"animate-repeat\" ng-if=\"results.length == 0\">\n            <strong>No results found...</strong>\n          </li>\n        </ul>\n      </div>\n    </file>\n    <file name=\"script.js\">\n      angular.module('ngRepeat', ['ngAnimate']).controller('repeatController', function($scope) {\n        $scope.friends = [\n          {name:'John', age:25, gender:'boy'},\n          {name:'Jessie', age:30, gender:'girl'},\n          {name:'Johanna', age:28, gender:'girl'},\n          {name:'Joy', age:15, gender:'girl'},\n          {name:'Mary', age:28, gender:'girl'},\n          {name:'Peter', age:95, gender:'boy'},\n          {name:'Sebastian', age:50, gender:'boy'},\n          {name:'Erika', age:27, gender:'girl'},\n          {name:'Patrick', age:40, gender:'boy'},\n          {name:'Samantha', age:60, gender:'girl'}\n        ];\n      });\n    </file>\n    <file name=\"animations.css\">\n      .example-animate-container {\n        background:white;\n        border:1px solid black;\n        list-style:none;\n        margin:0;\n        padding:0 10px;\n      }\n\n      .animate-repeat {\n        line-height:30px;\n        list-style:none;\n        box-sizing:border-box;\n      }\n\n      .animate-repeat.ng-move,\n      .animate-repeat.ng-enter,\n      .animate-repeat.ng-leave {\n        transition:all linear 0.5s;\n      }\n\n      .animate-repeat.ng-leave.ng-leave-active,\n      .animate-repeat.ng-move,\n      .animate-repeat.ng-enter {\n        opacity:0;\n        max-height:0;\n      }\n\n      .animate-repeat.ng-leave,\n      .animate-repeat.ng-move.ng-move-active,\n      .animate-repeat.ng-enter.ng-enter-active {\n        opacity:1;\n        max-height:30px;\n      }\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var friends = element.all(by.repeater('friend in friends'));\n\n      it('should render initial data set', function() {\n        expect(friends.count()).toBe(10);\n        expect(friends.get(0).getText()).toEqual('[1] John who is 25 years old.');\n        expect(friends.get(1).getText()).toEqual('[2] Jessie who is 30 years old.');\n        expect(friends.last().getText()).toEqual('[10] Samantha who is 60 years old.');\n        expect(element(by.binding('friends.length')).getText())\n            .toMatch(\"I have 10 friends. They are:\");\n      });\n\n       it('should update repeater when filter predicate changes', function() {\n         expect(friends.count()).toBe(10);\n\n         element(by.model('q')).sendKeys('ma');\n\n         expect(friends.count()).toBe(2);\n         expect(friends.get(0).getText()).toEqual('[1] Mary who is 28 years old.');\n         expect(friends.last().getText()).toEqual('[2] Samantha who is 60 years old.');\n       });\n      </file>\n    </example>\n */\nvar ngRepeatDirective = ['$parse', '$animate', '$compile', function($parse, $animate, $compile) {\n  var NG_REMOVED = '$$NG_REMOVED';\n  var ngRepeatMinErr = minErr('ngRepeat');\n\n  var updateScope = function(scope, index, valueIdentifier, value, keyIdentifier, key, arrayLength) {\n    // TODO(perf): generate setters to shave off ~40ms or 1-1.5%\n    scope[valueIdentifier] = value;\n    if (keyIdentifier) scope[keyIdentifier] = key;\n    scope.$index = index;\n    scope.$first = (index === 0);\n    scope.$last = (index === (arrayLength - 1));\n    scope.$middle = !(scope.$first || scope.$last);\n    // jshint bitwise: false\n    scope.$odd = !(scope.$even = (index&1) === 0);\n    // jshint bitwise: true\n  };\n\n  var getBlockStart = function(block) {\n    return block.clone[0];\n  };\n\n  var getBlockEnd = function(block) {\n    return block.clone[block.clone.length - 1];\n  };\n\n\n  return {\n    restrict: 'A',\n    multiElement: true,\n    transclude: 'element',\n    priority: 1000,\n    terminal: true,\n    $$tlb: true,\n    compile: function ngRepeatCompile($element, $attr) {\n      var expression = $attr.ngRepeat;\n      var ngRepeatEndComment = $compile.$$createComment('end ngRepeat', expression);\n\n      var match = expression.match(/^\\s*([\\s\\S]+?)\\s+in\\s+([\\s\\S]+?)(?:\\s+as\\s+([\\s\\S]+?))?(?:\\s+track\\s+by\\s+([\\s\\S]+?))?\\s*$/);\n\n      if (!match) {\n        throw ngRepeatMinErr('iexp', \"Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.\",\n            expression);\n      }\n\n      var lhs = match[1];\n      var rhs = match[2];\n      var aliasAs = match[3];\n      var trackByExp = match[4];\n\n      match = lhs.match(/^(?:(\\s*[\\$\\w]+)|\\(\\s*([\\$\\w]+)\\s*,\\s*([\\$\\w]+)\\s*\\))$/);\n\n      if (!match) {\n        throw ngRepeatMinErr('iidexp', \"'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.\",\n            lhs);\n      }\n      var valueIdentifier = match[3] || match[1];\n      var keyIdentifier = match[2];\n\n      if (aliasAs && (!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(aliasAs) ||\n          /^(null|undefined|this|\\$index|\\$first|\\$middle|\\$last|\\$even|\\$odd|\\$parent|\\$root|\\$id)$/.test(aliasAs))) {\n        throw ngRepeatMinErr('badident', \"alias '{0}' is invalid --- must be a valid JS identifier which is not a reserved name.\",\n          aliasAs);\n      }\n\n      var trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn;\n      var hashFnLocals = {$id: hashKey};\n\n      if (trackByExp) {\n        trackByExpGetter = $parse(trackByExp);\n      } else {\n        trackByIdArrayFn = function(key, value) {\n          return hashKey(value);\n        };\n        trackByIdObjFn = function(key) {\n          return key;\n        };\n      }\n\n      return function ngRepeatLink($scope, $element, $attr, ctrl, $transclude) {\n\n        if (trackByExpGetter) {\n          trackByIdExpFn = function(key, value, index) {\n            // assign key, value, and $index to the locals so that they can be used in hash functions\n            if (keyIdentifier) hashFnLocals[keyIdentifier] = key;\n            hashFnLocals[valueIdentifier] = value;\n            hashFnLocals.$index = index;\n            return trackByExpGetter($scope, hashFnLocals);\n          };\n        }\n\n        // Store a list of elements from previous run. This is a hash where key is the item from the\n        // iterator, and the value is objects with following properties.\n        //   - scope: bound scope\n        //   - element: previous element.\n        //   - index: position\n        //\n        // We are using no-proto object so that we don't need to guard against inherited props via\n        // hasOwnProperty.\n        var lastBlockMap = createMap();\n\n        //watch props\n        $scope.$watchCollection(rhs, function ngRepeatAction(collection) {\n          var index, length,\n              previousNode = $element[0],     // node that cloned nodes should be inserted after\n                                              // initialized to the comment node anchor\n              nextNode,\n              // Same as lastBlockMap but it has the current state. It will become the\n              // lastBlockMap on the next iteration.\n              nextBlockMap = createMap(),\n              collectionLength,\n              key, value, // key/value of iteration\n              trackById,\n              trackByIdFn,\n              collectionKeys,\n              block,       // last object information {scope, element, id}\n              nextBlockOrder,\n              elementsToRemove;\n\n          if (aliasAs) {\n            $scope[aliasAs] = collection;\n          }\n\n          if (isArrayLike(collection)) {\n            collectionKeys = collection;\n            trackByIdFn = trackByIdExpFn || trackByIdArrayFn;\n          } else {\n            trackByIdFn = trackByIdExpFn || trackByIdObjFn;\n            // if object, extract keys, in enumeration order, unsorted\n            collectionKeys = [];\n            for (var itemKey in collection) {\n              if (hasOwnProperty.call(collection, itemKey) && itemKey.charAt(0) !== '$') {\n                collectionKeys.push(itemKey);\n              }\n            }\n          }\n\n          collectionLength = collectionKeys.length;\n          nextBlockOrder = new Array(collectionLength);\n\n          // locate existing items\n          for (index = 0; index < collectionLength; index++) {\n            key = (collection === collectionKeys) ? index : collectionKeys[index];\n            value = collection[key];\n            trackById = trackByIdFn(key, value, index);\n            if (lastBlockMap[trackById]) {\n              // found previously seen block\n              block = lastBlockMap[trackById];\n              delete lastBlockMap[trackById];\n              nextBlockMap[trackById] = block;\n              nextBlockOrder[index] = block;\n            } else if (nextBlockMap[trackById]) {\n              // if collision detected. restore lastBlockMap and throw an error\n              forEach(nextBlockOrder, function(block) {\n                if (block && block.scope) lastBlockMap[block.id] = block;\n              });\n              throw ngRepeatMinErr('dupes',\n                  \"Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}\",\n                  expression, trackById, value);\n            } else {\n              // new never before seen block\n              nextBlockOrder[index] = {id: trackById, scope: undefined, clone: undefined};\n              nextBlockMap[trackById] = true;\n            }\n          }\n\n          // remove leftover items\n          for (var blockKey in lastBlockMap) {\n            block = lastBlockMap[blockKey];\n            elementsToRemove = getBlockNodes(block.clone);\n            $animate.leave(elementsToRemove);\n            if (elementsToRemove[0].parentNode) {\n              // if the element was not removed yet because of pending animation, mark it as deleted\n              // so that we can ignore it later\n              for (index = 0, length = elementsToRemove.length; index < length; index++) {\n                elementsToRemove[index][NG_REMOVED] = true;\n              }\n            }\n            block.scope.$destroy();\n          }\n\n          // we are not using forEach for perf reasons (trying to avoid #call)\n          for (index = 0; index < collectionLength; index++) {\n            key = (collection === collectionKeys) ? index : collectionKeys[index];\n            value = collection[key];\n            block = nextBlockOrder[index];\n\n            if (block.scope) {\n              // if we have already seen this object, then we need to reuse the\n              // associated scope/element\n\n              nextNode = previousNode;\n\n              // skip nodes that are already pending removal via leave animation\n              do {\n                nextNode = nextNode.nextSibling;\n              } while (nextNode && nextNode[NG_REMOVED]);\n\n              if (getBlockStart(block) != nextNode) {\n                // existing item which got moved\n                $animate.move(getBlockNodes(block.clone), null, previousNode);\n              }\n              previousNode = getBlockEnd(block);\n              updateScope(block.scope, index, valueIdentifier, value, keyIdentifier, key, collectionLength);\n            } else {\n              // new item which we don't know about\n              $transclude(function ngRepeatTransclude(clone, scope) {\n                block.scope = scope;\n                // http://jsperf.com/clone-vs-createcomment\n                var endNode = ngRepeatEndComment.cloneNode(false);\n                clone[clone.length++] = endNode;\n\n                $animate.enter(clone, null, previousNode);\n                previousNode = endNode;\n                // Note: We only need the first/last node of the cloned nodes.\n                // However, we need to keep the reference to the jqlite wrapper as it might be changed later\n                // by a directive with templateUrl when its template arrives.\n                block.clone = clone;\n                nextBlockMap[block.id] = block;\n                updateScope(block.scope, index, valueIdentifier, value, keyIdentifier, key, collectionLength);\n              });\n            }\n          }\n          lastBlockMap = nextBlockMap;\n        });\n      };\n    }\n  };\n}];\n\nvar NG_HIDE_CLASS = 'ng-hide';\nvar NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';\n/**\n * @ngdoc directive\n * @name ngShow\n * @multiElement\n *\n * @description\n * The `ngShow` directive shows or hides the given HTML element based on the expression\n * provided to the `ngShow` attribute. The element is shown or hidden by removing or adding\n * the `.ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined\n * in AngularJS and sets the display style to none (using an !important flag).\n * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}).\n *\n * ```html\n * <!-- when $scope.myValue is truthy (element is visible) -->\n * <div ng-show=\"myValue\"></div>\n *\n * <!-- when $scope.myValue is falsy (element is hidden) -->\n * <div ng-show=\"myValue\" class=\"ng-hide\"></div>\n * ```\n *\n * When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added to the class\n * attribute on the element causing it to become hidden. When truthy, the `.ng-hide` CSS class is removed\n * from the element causing the element not to appear hidden.\n *\n * ## Why is !important used?\n *\n * You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector\n * can be easily overridden by heavier selectors. For example, something as simple\n * as changing the display style on a HTML list item would make hidden elements appear visible.\n * This also becomes a bigger issue when dealing with CSS frameworks.\n *\n * By using !important, the show and hide behavior will work as expected despite any clash between CSS selector\n * specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the\n * styling to change how to hide an element then it is just a matter of using !important in their own CSS code.\n *\n * ### Overriding `.ng-hide`\n *\n * By default, the `.ng-hide` class will style the element with `display: none!important`. If you wish to change\n * the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`\n * class CSS. Note that the selector that needs to be used is actually `.ng-hide:not(.ng-hide-animate)` to cope\n * with extra animation classes that can be added.\n *\n * ```css\n * .ng-hide:not(.ng-hide-animate) {\n *   /&#42; this is just another form of hiding an element &#42;/\n *   display: block!important;\n *   position: absolute;\n *   top: -9999px;\n *   left: -9999px;\n * }\n * ```\n *\n * By default you don't need to override in CSS anything and the animations will work around the display style.\n *\n * ## A note about animations with `ngShow`\n *\n * Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression\n * is true and false. This system works like the animation system present with ngClass except that\n * you must also include the !important flag to override the display property\n * so that you can perform an animation when the element is hidden during the time of the animation.\n *\n * ```css\n * //\n * //a working example can be found at the bottom of this page\n * //\n * .my-element.ng-hide-add, .my-element.ng-hide-remove {\n *   /&#42; this is required as of 1.3x to properly\n *      apply all styling in a show/hide animation &#42;/\n *   transition: 0s linear all;\n * }\n *\n * .my-element.ng-hide-add-active,\n * .my-element.ng-hide-remove-active {\n *   /&#42; the transition is defined in the active class &#42;/\n *   transition: 1s linear all;\n * }\n *\n * .my-element.ng-hide-add { ... }\n * .my-element.ng-hide-add.ng-hide-add-active { ... }\n * .my-element.ng-hide-remove { ... }\n * .my-element.ng-hide-remove.ng-hide-remove-active { ... }\n * ```\n *\n * Keep in mind that, as of AngularJS version 1.3, there is no need to change the display\n * property to block during animation states--ngAnimate will handle the style toggling automatically for you.\n *\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link $animate#addClass addClass} `.ng-hide`  | after the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden |\n * | {@link $animate#removeClass removeClass}  `.ng-hide`  | after the `ngShow` expression evaluates to a truthy value and just before contents are set to visible |\n *\n * @element ANY\n * @param {expression} ngShow If the {@link guide/expression expression} is truthy\n *     then the element is shown or hidden respectively.\n *\n * @example\n  <example module=\"ngAnimate\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n      Click me: <input type=\"checkbox\" ng-model=\"checked\" aria-label=\"Toggle ngHide\"><br/>\n      <div>\n        Show:\n        <div class=\"check-element animate-show\" ng-show=\"checked\">\n          <span class=\"glyphicon glyphicon-thumbs-up\"></span> I show up when your checkbox is checked.\n        </div>\n      </div>\n      <div>\n        Hide:\n        <div class=\"check-element animate-show\" ng-hide=\"checked\">\n          <span class=\"glyphicon glyphicon-thumbs-down\"></span> I hide when your checkbox is checked.\n        </div>\n      </div>\n    </file>\n    <file name=\"glyphicons.css\">\n      @import url(../../components/bootstrap-3.1.1/css/bootstrap.css);\n    </file>\n    <file name=\"animations.css\">\n      .animate-show {\n        line-height: 20px;\n        opacity: 1;\n        padding: 10px;\n        border: 1px solid black;\n        background: white;\n      }\n\n      .animate-show.ng-hide-add, .animate-show.ng-hide-remove {\n        transition: all linear 0.5s;\n      }\n\n      .animate-show.ng-hide {\n        line-height: 0;\n        opacity: 0;\n        padding: 0 10px;\n      }\n\n      .check-element {\n        padding: 10px;\n        border: 1px solid black;\n        background: white;\n      }\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));\n      var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));\n\n      it('should check ng-show / ng-hide', function() {\n        expect(thumbsUp.isDisplayed()).toBeFalsy();\n        expect(thumbsDown.isDisplayed()).toBeTruthy();\n\n        element(by.model('checked')).click();\n\n        expect(thumbsUp.isDisplayed()).toBeTruthy();\n        expect(thumbsDown.isDisplayed()).toBeFalsy();\n      });\n    </file>\n  </example>\n */\nvar ngShowDirective = ['$animate', function($animate) {\n  return {\n    restrict: 'A',\n    multiElement: true,\n    link: function(scope, element, attr) {\n      scope.$watch(attr.ngShow, function ngShowWatchAction(value) {\n        // we're adding a temporary, animation-specific class for ng-hide since this way\n        // we can control when the element is actually displayed on screen without having\n        // to have a global/greedy CSS selector that breaks when other animations are run.\n        // Read: https://github.com/angular/angular.js/issues/9103#issuecomment-58335845\n        $animate[value ? 'removeClass' : 'addClass'](element, NG_HIDE_CLASS, {\n          tempClasses: NG_HIDE_IN_PROGRESS_CLASS\n        });\n      });\n    }\n  };\n}];\n\n\n/**\n * @ngdoc directive\n * @name ngHide\n * @multiElement\n *\n * @description\n * The `ngHide` directive shows or hides the given HTML element based on the expression\n * provided to the `ngHide` attribute. The element is shown or hidden by removing or adding\n * the `ng-hide` CSS class onto the element. The `.ng-hide` CSS class is predefined\n * in AngularJS and sets the display style to none (using an !important flag).\n * For CSP mode please add `angular-csp.css` to your html file (see {@link ng.directive:ngCsp ngCsp}).\n *\n * ```html\n * <!-- when $scope.myValue is truthy (element is hidden) -->\n * <div ng-hide=\"myValue\" class=\"ng-hide\"></div>\n *\n * <!-- when $scope.myValue is falsy (element is visible) -->\n * <div ng-hide=\"myValue\"></div>\n * ```\n *\n * When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added to the class\n * attribute on the element causing it to become hidden. When falsy, the `.ng-hide` CSS class is removed\n * from the element causing the element not to appear hidden.\n *\n * ## Why is !important used?\n *\n * You may be wondering why !important is used for the `.ng-hide` CSS class. This is because the `.ng-hide` selector\n * can be easily overridden by heavier selectors. For example, something as simple\n * as changing the display style on a HTML list item would make hidden elements appear visible.\n * This also becomes a bigger issue when dealing with CSS frameworks.\n *\n * By using !important, the show and hide behavior will work as expected despite any clash between CSS selector\n * specificity (when !important isn't used with any conflicting styles). If a developer chooses to override the\n * styling to change how to hide an element then it is just a matter of using !important in their own CSS code.\n *\n * ### Overriding `.ng-hide`\n *\n * By default, the `.ng-hide` class will style the element with `display: none!important`. If you wish to change\n * the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`\n * class in CSS:\n *\n * ```css\n * .ng-hide {\n *   /&#42; this is just another form of hiding an element &#42;/\n *   display: block!important;\n *   position: absolute;\n *   top: -9999px;\n *   left: -9999px;\n * }\n * ```\n *\n * By default you don't need to override in CSS anything and the animations will work around the display style.\n *\n * ## A note about animations with `ngHide`\n *\n * Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression\n * is true and false. This system works like the animation system present with ngClass, except that the `.ng-hide`\n * CSS class is added and removed for you instead of your own CSS class.\n *\n * ```css\n * //\n * //a working example can be found at the bottom of this page\n * //\n * .my-element.ng-hide-add, .my-element.ng-hide-remove {\n *   transition: 0.5s linear all;\n * }\n *\n * .my-element.ng-hide-add { ... }\n * .my-element.ng-hide-add.ng-hide-add-active { ... }\n * .my-element.ng-hide-remove { ... }\n * .my-element.ng-hide-remove.ng-hide-remove-active { ... }\n * ```\n *\n * Keep in mind that, as of AngularJS version 1.3, there is no need to change the display\n * property to block during animation states--ngAnimate will handle the style toggling automatically for you.\n *\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link $animate#addClass addClass} `.ng-hide`  | after the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden |\n * | {@link $animate#removeClass removeClass}  `.ng-hide`  | after the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible |\n *\n *\n * @element ANY\n * @param {expression} ngHide If the {@link guide/expression expression} is truthy then\n *     the element is shown or hidden respectively.\n *\n * @example\n  <example module=\"ngAnimate\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n      Click me: <input type=\"checkbox\" ng-model=\"checked\" aria-label=\"Toggle ngShow\"><br/>\n      <div>\n        Show:\n        <div class=\"check-element animate-hide\" ng-show=\"checked\">\n          <span class=\"glyphicon glyphicon-thumbs-up\"></span> I show up when your checkbox is checked.\n        </div>\n      </div>\n      <div>\n        Hide:\n        <div class=\"check-element animate-hide\" ng-hide=\"checked\">\n          <span class=\"glyphicon glyphicon-thumbs-down\"></span> I hide when your checkbox is checked.\n        </div>\n      </div>\n    </file>\n    <file name=\"glyphicons.css\">\n      @import url(../../components/bootstrap-3.1.1/css/bootstrap.css);\n    </file>\n    <file name=\"animations.css\">\n      .animate-hide {\n        transition: all linear 0.5s;\n        line-height: 20px;\n        opacity: 1;\n        padding: 10px;\n        border: 1px solid black;\n        background: white;\n      }\n\n      .animate-hide.ng-hide {\n        line-height: 0;\n        opacity: 0;\n        padding: 0 10px;\n      }\n\n      .check-element {\n        padding: 10px;\n        border: 1px solid black;\n        background: white;\n      }\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));\n      var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));\n\n      it('should check ng-show / ng-hide', function() {\n        expect(thumbsUp.isDisplayed()).toBeFalsy();\n        expect(thumbsDown.isDisplayed()).toBeTruthy();\n\n        element(by.model('checked')).click();\n\n        expect(thumbsUp.isDisplayed()).toBeTruthy();\n        expect(thumbsDown.isDisplayed()).toBeFalsy();\n      });\n    </file>\n  </example>\n */\nvar ngHideDirective = ['$animate', function($animate) {\n  return {\n    restrict: 'A',\n    multiElement: true,\n    link: function(scope, element, attr) {\n      scope.$watch(attr.ngHide, function ngHideWatchAction(value) {\n        // The comment inside of the ngShowDirective explains why we add and\n        // remove a temporary class for the show/hide animation\n        $animate[value ? 'addClass' : 'removeClass'](element,NG_HIDE_CLASS, {\n          tempClasses: NG_HIDE_IN_PROGRESS_CLASS\n        });\n      });\n    }\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name ngStyle\n * @restrict AC\n *\n * @description\n * The `ngStyle` directive allows you to set CSS style on an HTML element conditionally.\n *\n * @element ANY\n * @param {expression} ngStyle\n *\n * {@link guide/expression Expression} which evals to an\n * object whose keys are CSS style names and values are corresponding values for those CSS\n * keys.\n *\n * Since some CSS style names are not valid keys for an object, they must be quoted.\n * See the 'background-color' style in the example below.\n *\n * @example\n   <example>\n     <file name=\"index.html\">\n        <input type=\"button\" value=\"set color\" ng-click=\"myStyle={color:'red'}\">\n        <input type=\"button\" value=\"set background\" ng-click=\"myStyle={'background-color':'blue'}\">\n        <input type=\"button\" value=\"clear\" ng-click=\"myStyle={}\">\n        <br/>\n        <span ng-style=\"myStyle\">Sample Text</span>\n        <pre>myStyle={{myStyle}}</pre>\n     </file>\n     <file name=\"style.css\">\n       span {\n         color: black;\n       }\n     </file>\n     <file name=\"protractor.js\" type=\"protractor\">\n       var colorSpan = element(by.css('span'));\n\n       it('should check ng-style', function() {\n         expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');\n         element(by.css('input[value=\\'set color\\']')).click();\n         expect(colorSpan.getCssValue('color')).toBe('rgba(255, 0, 0, 1)');\n         element(by.css('input[value=clear]')).click();\n         expect(colorSpan.getCssValue('color')).toBe('rgba(0, 0, 0, 1)');\n       });\n     </file>\n   </example>\n */\nvar ngStyleDirective = ngDirective(function(scope, element, attr) {\n  scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {\n    if (oldStyles && (newStyles !== oldStyles)) {\n      forEach(oldStyles, function(val, style) { element.css(style, '');});\n    }\n    if (newStyles) element.css(newStyles);\n  }, true);\n});\n\n/**\n * @ngdoc directive\n * @name ngSwitch\n * @restrict EA\n *\n * @description\n * The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.\n * Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location\n * as specified in the template.\n *\n * The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it\n * from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element\n * matches the value obtained from the evaluated expression. In other words, you define a container element\n * (where you place the directive), place an expression on the **`on=\"...\"` attribute**\n * (or the **`ng-switch=\"...\"` attribute**), define any inner elements inside of the directive and place\n * a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on\n * expression is evaluated. If a matching expression is not found via a when attribute then an element with the default\n * attribute is displayed.\n *\n * <div class=\"alert alert-info\">\n * Be aware that the attribute values to match against cannot be expressions. They are interpreted\n * as literal string values to match against.\n * For example, **`ng-switch-when=\"someVal\"`** will match against the string `\"someVal\"` not against the\n * value of the expression `$scope.someVal`.\n * </div>\n\n * @animations\n * | Animation                        | Occurs                              |\n * |----------------------------------|-------------------------------------|\n * | {@link ng.$animate#enter enter}  | after the ngSwitch contents change and the matched child element is placed inside the container |\n * | {@link ng.$animate#leave leave}  | after the ngSwitch contents change and just before the former contents are removed from the DOM |\n *\n * @usage\n *\n * ```\n * <ANY ng-switch=\"expression\">\n *   <ANY ng-switch-when=\"matchValue1\">...</ANY>\n *   <ANY ng-switch-when=\"matchValue2\">...</ANY>\n *   <ANY ng-switch-default>...</ANY>\n * </ANY>\n * ```\n *\n *\n * @scope\n * @priority 1200\n * @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.\n * On child elements add:\n *\n * * `ngSwitchWhen`: the case statement to match against. If match then this\n *   case will be displayed. If the same match appears multiple times, all the\n *   elements will be displayed.\n * * `ngSwitchDefault`: the default case when no other case match. If there\n *   are multiple default cases, all of them will be displayed when no other\n *   case match.\n *\n *\n * @example\n  <example module=\"switchExample\" deps=\"angular-animate.js\" animations=\"true\">\n    <file name=\"index.html\">\n      <div ng-controller=\"ExampleController\">\n        <select ng-model=\"selection\" ng-options=\"item for item in items\">\n        </select>\n        <code>selection={{selection}}</code>\n        <hr/>\n        <div class=\"animate-switch-container\"\n          ng-switch on=\"selection\">\n            <div class=\"animate-switch\" ng-switch-when=\"settings\">Settings Div</div>\n            <div class=\"animate-switch\" ng-switch-when=\"home\">Home Span</div>\n            <div class=\"animate-switch\" ng-switch-default>default</div>\n        </div>\n      </div>\n    </file>\n    <file name=\"script.js\">\n      angular.module('switchExample', ['ngAnimate'])\n        .controller('ExampleController', ['$scope', function($scope) {\n          $scope.items = ['settings', 'home', 'other'];\n          $scope.selection = $scope.items[0];\n        }]);\n    </file>\n    <file name=\"animations.css\">\n      .animate-switch-container {\n        position:relative;\n        background:white;\n        border:1px solid black;\n        height:40px;\n        overflow:hidden;\n      }\n\n      .animate-switch {\n        padding:10px;\n      }\n\n      .animate-switch.ng-animate {\n        transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;\n\n        position:absolute;\n        top:0;\n        left:0;\n        right:0;\n        bottom:0;\n      }\n\n      .animate-switch.ng-leave.ng-leave-active,\n      .animate-switch.ng-enter {\n        top:-50px;\n      }\n      .animate-switch.ng-leave,\n      .animate-switch.ng-enter.ng-enter-active {\n        top:0;\n      }\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      var switchElem = element(by.css('[ng-switch]'));\n      var select = element(by.model('selection'));\n\n      it('should start in settings', function() {\n        expect(switchElem.getText()).toMatch(/Settings Div/);\n      });\n      it('should change to home', function() {\n        select.all(by.css('option')).get(1).click();\n        expect(switchElem.getText()).toMatch(/Home Span/);\n      });\n      it('should select default', function() {\n        select.all(by.css('option')).get(2).click();\n        expect(switchElem.getText()).toMatch(/default/);\n      });\n    </file>\n  </example>\n */\nvar ngSwitchDirective = ['$animate', '$compile', function($animate, $compile) {\n  return {\n    require: 'ngSwitch',\n\n    // asks for $scope to fool the BC controller module\n    controller: ['$scope', function ngSwitchController() {\n     this.cases = {};\n    }],\n    link: function(scope, element, attr, ngSwitchController) {\n      var watchExpr = attr.ngSwitch || attr.on,\n          selectedTranscludes = [],\n          selectedElements = [],\n          previousLeaveAnimations = [],\n          selectedScopes = [];\n\n      var spliceFactory = function(array, index) {\n          return function() { array.splice(index, 1); };\n      };\n\n      scope.$watch(watchExpr, function ngSwitchWatchAction(value) {\n        var i, ii;\n        for (i = 0, ii = previousLeaveAnimations.length; i < ii; ++i) {\n          $animate.cancel(previousLeaveAnimations[i]);\n        }\n        previousLeaveAnimations.length = 0;\n\n        for (i = 0, ii = selectedScopes.length; i < ii; ++i) {\n          var selected = getBlockNodes(selectedElements[i].clone);\n          selectedScopes[i].$destroy();\n          var promise = previousLeaveAnimations[i] = $animate.leave(selected);\n          promise.then(spliceFactory(previousLeaveAnimations, i));\n        }\n\n        selectedElements.length = 0;\n        selectedScopes.length = 0;\n\n        if ((selectedTranscludes = ngSwitchController.cases['!' + value] || ngSwitchController.cases['?'])) {\n          forEach(selectedTranscludes, function(selectedTransclude) {\n            selectedTransclude.transclude(function(caseElement, selectedScope) {\n              selectedScopes.push(selectedScope);\n              var anchor = selectedTransclude.element;\n              caseElement[caseElement.length++] = $compile.$$createComment('end ngSwitchWhen');\n              var block = { clone: caseElement };\n\n              selectedElements.push(block);\n              $animate.enter(caseElement, anchor.parent(), anchor);\n            });\n          });\n        }\n      });\n    }\n  };\n}];\n\nvar ngSwitchWhenDirective = ngDirective({\n  transclude: 'element',\n  priority: 1200,\n  require: '^ngSwitch',\n  multiElement: true,\n  link: function(scope, element, attrs, ctrl, $transclude) {\n    ctrl.cases['!' + attrs.ngSwitchWhen] = (ctrl.cases['!' + attrs.ngSwitchWhen] || []);\n    ctrl.cases['!' + attrs.ngSwitchWhen].push({ transclude: $transclude, element: element });\n  }\n});\n\nvar ngSwitchDefaultDirective = ngDirective({\n  transclude: 'element',\n  priority: 1200,\n  require: '^ngSwitch',\n  multiElement: true,\n  link: function(scope, element, attr, ctrl, $transclude) {\n    ctrl.cases['?'] = (ctrl.cases['?'] || []);\n    ctrl.cases['?'].push({ transclude: $transclude, element: element });\n   }\n});\n\n/**\n * @ngdoc directive\n * @name ngTransclude\n * @restrict EAC\n *\n * @description\n * Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.\n *\n * You can specify that you want to insert a named transclusion slot, instead of the default slot, by providing the slot name\n * as the value of the `ng-transclude` or `ng-transclude-slot` attribute.\n *\n * If the transcluded content is not empty (i.e. contains one or more DOM nodes, including whitespace text nodes), any existing\n * content of this element will be removed before the transcluded content is inserted.\n * If the transcluded content is empty, the existing content is left intact. This lets you provide fallback content in the case\n * that no transcluded content is provided.\n *\n * @element ANY\n *\n * @param {string} ngTransclude|ngTranscludeSlot the name of the slot to insert at this point. If this is not provided, is empty\n *                                               or its value is the same as the name of the attribute then the default slot is used.\n *\n * @example\n * ### Basic transclusion\n * This example demonstrates basic transclusion of content into a component directive.\n * <example name=\"simpleTranscludeExample\" module=\"transcludeExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('transcludeExample', [])\n *        .directive('pane', function(){\n *           return {\n *             restrict: 'E',\n *             transclude: true,\n *             scope: { title:'@' },\n *             template: '<div style=\"border: 1px solid black;\">' +\n *                         '<div style=\"background-color: gray\">{{title}}</div>' +\n *                         '<ng-transclude></ng-transclude>' +\n *                       '</div>'\n *           };\n *       })\n *       .controller('ExampleController', ['$scope', function($scope) {\n *         $scope.title = 'Lorem Ipsum';\n *         $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';\n *       }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <input ng-model=\"title\" aria-label=\"title\"> <br/>\n *       <textarea ng-model=\"text\" aria-label=\"text\"></textarea> <br/>\n *       <pane title=\"{{title}}\">{{text}}</pane>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *      it('should have transcluded', function() {\n *        var titleElement = element(by.model('title'));\n *        titleElement.clear();\n *        titleElement.sendKeys('TITLE');\n *        var textElement = element(by.model('text'));\n *        textElement.clear();\n *        textElement.sendKeys('TEXT');\n *        expect(element(by.binding('title')).getText()).toEqual('TITLE');\n *        expect(element(by.binding('text')).getText()).toEqual('TEXT');\n *      });\n *   </file>\n * </example>\n *\n * @example\n * ### Transclude fallback content\n * This example shows how to use `NgTransclude` with fallback content, that\n * is displayed if no transcluded content is provided.\n *\n * <example module=\"transcludeFallbackContentExample\">\n * <file name=\"index.html\">\n * <script>\n * angular.module('transcludeFallbackContentExample', [])\n * .directive('myButton', function(){\n *             return {\n *               restrict: 'E',\n *               transclude: true,\n *               scope: true,\n *               template: '<button style=\"cursor: pointer;\">' +\n *                           '<ng-transclude>' +\n *                             '<b style=\"color: red;\">Button1</b>' +\n *                           '</ng-transclude>' +\n *                         '</button>'\n *             };\n *         });\n * </script>\n * <!-- fallback button content -->\n * <my-button id=\"fallback\"></my-button>\n * <!-- modified button content -->\n * <my-button id=\"modified\">\n *   <i style=\"color: green;\">Button2</i>\n * </my-button>\n * </file>\n * <file name=\"protractor.js\" type=\"protractor\">\n * it('should have different transclude element content', function() {\n *          expect(element(by.id('fallback')).getText()).toBe('Button1');\n *          expect(element(by.id('modified')).getText()).toBe('Button2');\n *        });\n * </file>\n * </example>\n *\n * @example\n * ### Multi-slot transclusion\n * This example demonstrates using multi-slot transclusion in a component directive.\n * <example name=\"multiSlotTranscludeExample\" module=\"multiSlotTranscludeExample\">\n *   <file name=\"index.html\">\n *    <style>\n *      .title, .footer {\n *        background-color: gray\n *      }\n *    </style>\n *    <div ng-controller=\"ExampleController\">\n *      <input ng-model=\"title\" aria-label=\"title\"> <br/>\n *      <textarea ng-model=\"text\" aria-label=\"text\"></textarea> <br/>\n *      <pane>\n *        <pane-title><a ng-href=\"{{link}}\">{{title}}</a></pane-title>\n *        <pane-body><p>{{text}}</p></pane-body>\n *      </pane>\n *    </div>\n *   </file>\n *   <file name=\"app.js\">\n *    angular.module('multiSlotTranscludeExample', [])\n *     .directive('pane', function(){\n *        return {\n *          restrict: 'E',\n *          transclude: {\n *            'title': '?paneTitle',\n *            'body': 'paneBody',\n *            'footer': '?paneFooter'\n *          },\n *          template: '<div style=\"border: 1px solid black;\">' +\n *                      '<div class=\"title\" ng-transclude=\"title\">Fallback Title</div>' +\n *                      '<div ng-transclude=\"body\"></div>' +\n *                      '<div class=\"footer\" ng-transclude=\"footer\">Fallback Footer</div>' +\n *                    '</div>'\n *        };\n *    })\n *    .controller('ExampleController', ['$scope', function($scope) {\n *      $scope.title = 'Lorem Ipsum';\n *      $scope.link = \"https://google.com\";\n *      $scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';\n *    }]);\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *      it('should have transcluded the title and the body', function() {\n *        var titleElement = element(by.model('title'));\n *        titleElement.clear();\n *        titleElement.sendKeys('TITLE');\n *        var textElement = element(by.model('text'));\n *        textElement.clear();\n *        textElement.sendKeys('TEXT');\n *        expect(element(by.css('.title')).getText()).toEqual('TITLE');\n *        expect(element(by.binding('text')).getText()).toEqual('TEXT');\n *        expect(element(by.css('.footer')).getText()).toEqual('Fallback Footer');\n *      });\n *   </file>\n * </example>\n */\nvar ngTranscludeMinErr = minErr('ngTransclude');\nvar ngTranscludeDirective = ngDirective({\n  restrict: 'EAC',\n  link: function($scope, $element, $attrs, controller, $transclude) {\n\n    if ($attrs.ngTransclude === $attrs.$attr.ngTransclude) {\n      // If the attribute is of the form: `ng-transclude=\"ng-transclude\"`\n      // then treat it like the default\n      $attrs.ngTransclude = '';\n    }\n\n    function ngTranscludeCloneAttachFn(clone) {\n      if (clone.length) {\n        $element.empty();\n        $element.append(clone);\n      }\n    }\n\n    if (!$transclude) {\n      throw ngTranscludeMinErr('orphan',\n       'Illegal use of ngTransclude directive in the template! ' +\n       'No parent directive that requires a transclusion found. ' +\n       'Element: {0}',\n       startingTag($element));\n    }\n\n    // If there is no slot name defined or the slot name is not optional\n    // then transclude the slot\n    var slotName = $attrs.ngTransclude || $attrs.ngTranscludeSlot;\n    $transclude(ngTranscludeCloneAttachFn, null, slotName);\n  }\n});\n\n/**\n * @ngdoc directive\n * @name script\n * @restrict E\n *\n * @description\n * Load the content of a `<script>` element into {@link ng.$templateCache `$templateCache`}, so that the\n * template can be used by {@link ng.directive:ngInclude `ngInclude`},\n * {@link ngRoute.directive:ngView `ngView`}, or {@link guide/directive directives}. The type of the\n * `<script>` element must be specified as `text/ng-template`, and a cache name for the template must be\n * assigned through the element's `id`, which can then be used as a directive's `templateUrl`.\n *\n * @param {string} type Must be set to `'text/ng-template'`.\n * @param {string} id Cache name of the template.\n *\n * @example\n  <example>\n    <file name=\"index.html\">\n      <script type=\"text/ng-template\" id=\"/tpl.html\">\n        Content of the template.\n      </script>\n\n      <a ng-click=\"currentTpl='/tpl.html'\" id=\"tpl-link\">Load inlined template</a>\n      <div id=\"tpl-content\" ng-include src=\"currentTpl\"></div>\n    </file>\n    <file name=\"protractor.js\" type=\"protractor\">\n      it('should load template defined inside script tag', function() {\n        element(by.css('#tpl-link')).click();\n        expect(element(by.css('#tpl-content')).getText()).toMatch(/Content of the template/);\n      });\n    </file>\n  </example>\n */\nvar scriptDirective = ['$templateCache', function($templateCache) {\n  return {\n    restrict: 'E',\n    terminal: true,\n    compile: function(element, attr) {\n      if (attr.type == 'text/ng-template') {\n        var templateUrl = attr.id,\n            text = element[0].text;\n\n        $templateCache.put(templateUrl, text);\n      }\n    }\n  };\n}];\n\nvar noopNgModelController = { $setViewValue: noop, $render: noop };\n\nfunction chromeHack(optionElement) {\n  // Workaround for https://code.google.com/p/chromium/issues/detail?id=381459\n  // Adding an <option selected=\"selected\"> element to a <select required=\"required\"> should\n  // automatically select the new element\n  if (optionElement[0].hasAttribute('selected')) {\n    optionElement[0].selected = true;\n  }\n}\n\n/**\n * @ngdoc type\n * @name  select.SelectController\n * @description\n * The controller for the `<select>` directive. This provides support for reading\n * and writing the selected value(s) of the control and also coordinates dynamically\n * added `<option>` elements, perhaps by an `ngRepeat` directive.\n */\nvar SelectController =\n        ['$element', '$scope', function($element, $scope) {\n\n  var self = this,\n      optionsMap = new HashMap();\n\n  // If the ngModel doesn't get provided then provide a dummy noop version to prevent errors\n  self.ngModelCtrl = noopNgModelController;\n\n  // The \"unknown\" option is one that is prepended to the list if the viewValue\n  // does not match any of the options. When it is rendered the value of the unknown\n  // option is '? XXX ?' where XXX is the hashKey of the value that is not known.\n  //\n  // We can't just jqLite('<option>') since jqLite is not smart enough\n  // to create it in <select> and IE barfs otherwise.\n  self.unknownOption = jqLite(window.document.createElement('option'));\n  self.renderUnknownOption = function(val) {\n    var unknownVal = '? ' + hashKey(val) + ' ?';\n    self.unknownOption.val(unknownVal);\n    $element.prepend(self.unknownOption);\n    $element.val(unknownVal);\n  };\n\n  $scope.$on('$destroy', function() {\n    // disable unknown option so that we don't do work when the whole select is being destroyed\n    self.renderUnknownOption = noop;\n  });\n\n  self.removeUnknownOption = function() {\n    if (self.unknownOption.parent()) self.unknownOption.remove();\n  };\n\n\n  // Read the value of the select control, the implementation of this changes depending\n  // upon whether the select can have multiple values and whether ngOptions is at work.\n  self.readValue = function readSingleValue() {\n    self.removeUnknownOption();\n    return $element.val();\n  };\n\n\n  // Write the value to the select control, the implementation of this changes depending\n  // upon whether the select can have multiple values and whether ngOptions is at work.\n  self.writeValue = function writeSingleValue(value) {\n    if (self.hasOption(value)) {\n      self.removeUnknownOption();\n      $element.val(value);\n      if (value === '') self.emptyOption.prop('selected', true); // to make IE9 happy\n    } else {\n      if (value == null && self.emptyOption) {\n        self.removeUnknownOption();\n        $element.val('');\n      } else {\n        self.renderUnknownOption(value);\n      }\n    }\n  };\n\n\n  // Tell the select control that an option, with the given value, has been added\n  self.addOption = function(value, element) {\n    // Skip comment nodes, as they only pollute the `optionsMap`\n    if (element[0].nodeType === NODE_TYPE_COMMENT) return;\n\n    assertNotHasOwnProperty(value, '\"option value\"');\n    if (value === '') {\n      self.emptyOption = element;\n    }\n    var count = optionsMap.get(value) || 0;\n    optionsMap.put(value, count + 1);\n    self.ngModelCtrl.$render();\n    chromeHack(element);\n  };\n\n  // Tell the select control that an option, with the given value, has been removed\n  self.removeOption = function(value) {\n    var count = optionsMap.get(value);\n    if (count) {\n      if (count === 1) {\n        optionsMap.remove(value);\n        if (value === '') {\n          self.emptyOption = undefined;\n        }\n      } else {\n        optionsMap.put(value, count - 1);\n      }\n    }\n  };\n\n  // Check whether the select control has an option matching the given value\n  self.hasOption = function(value) {\n    return !!optionsMap.get(value);\n  };\n\n\n  self.registerOption = function(optionScope, optionElement, optionAttrs, interpolateValueFn, interpolateTextFn) {\n\n    if (interpolateValueFn) {\n      // The value attribute is interpolated\n      var oldVal;\n      optionAttrs.$observe('value', function valueAttributeObserveAction(newVal) {\n        if (isDefined(oldVal)) {\n          self.removeOption(oldVal);\n        }\n        oldVal = newVal;\n        self.addOption(newVal, optionElement);\n      });\n    } else if (interpolateTextFn) {\n      // The text content is interpolated\n      optionScope.$watch(interpolateTextFn, function interpolateWatchAction(newVal, oldVal) {\n        optionAttrs.$set('value', newVal);\n        if (oldVal !== newVal) {\n          self.removeOption(oldVal);\n        }\n        self.addOption(newVal, optionElement);\n      });\n    } else {\n      // The value attribute is static\n      self.addOption(optionAttrs.value, optionElement);\n    }\n\n    optionElement.on('$destroy', function() {\n      self.removeOption(optionAttrs.value);\n      self.ngModelCtrl.$render();\n    });\n  };\n}];\n\n/**\n * @ngdoc directive\n * @name select\n * @restrict E\n *\n * @description\n * HTML `SELECT` element with angular data-binding.\n *\n * The `select` directive is used together with {@link ngModel `ngModel`} to provide data-binding\n * between the scope and the `<select>` control (including setting default values).\n * It also handles dynamic `<option>` elements, which can be added using the {@link ngRepeat `ngRepeat}` or\n * {@link ngOptions `ngOptions`} directives.\n *\n * When an item in the `<select>` menu is selected, the value of the selected option will be bound\n * to the model identified by the `ngModel` directive. With static or repeated options, this is\n * the content of the `value` attribute or the textContent of the `<option>`, if the value attribute is missing.\n * If you want dynamic value attributes, you can use interpolation inside the value attribute.\n *\n * <div class=\"alert alert-warning\">\n * Note that the value of a `select` directive used without `ngOptions` is always a string.\n * When the model needs to be bound to a non-string value, you must either explicitly convert it\n * using a directive (see example below) or use `ngOptions` to specify the set of options.\n * This is because an option element can only be bound to string values at present.\n * </div>\n *\n * If the viewValue of `ngModel` does not match any of the options, then the control\n * will automatically add an \"unknown\" option, which it then removes when the mismatch is resolved.\n *\n * Optionally, a single hard-coded `<option>` element, with the value set to an empty string, can\n * be nested into the `<select>` element. This element will then represent the `null` or \"not selected\"\n * option. See example below for demonstration.\n *\n * <div class=\"alert alert-info\">\n * In many cases, `ngRepeat` can be used on `<option>` elements instead of {@link ng.directive:ngOptions\n * ngOptions} to achieve a similar result. However, `ngOptions` provides some benefits, such as\n * more flexibility in how the `<select>`'s model is assigned via the `select` **`as`** part of the\n * comprehension expression, and additionally in reducing memory and increasing speed by not creating\n * a new scope for each repeated instance.\n * </div>\n *\n *\n * @param {string} ngModel Assignable angular expression to data-bind to.\n * @param {string=} name Property name of the form under which the control is published.\n * @param {string=} multiple Allows multiple options to be selected. The selected values will be\n *     bound to the model as an array.\n * @param {string=} required Sets `required` validation error key if the value is not entered.\n * @param {string=} ngRequired Adds required attribute and required validation constraint to\n * the element when the ngRequired expression evaluates to true. Use ngRequired instead of required\n * when you want to data-bind to the required attribute.\n * @param {string=} ngChange Angular expression to be executed when selected option(s) changes due to user\n *    interaction with the select element.\n * @param {string=} ngOptions sets the options that the select is populated with and defines what is\n * set on the model on selection. See {@link ngOptions `ngOptions`}.\n *\n * @example\n * ### Simple `select` elements with static options\n *\n * <example name=\"static-select\" module=\"staticSelect\">\n * <file name=\"index.html\">\n * <div ng-controller=\"ExampleController\">\n *   <form name=\"myForm\">\n *     <label for=\"singleSelect\"> Single select: </label><br>\n *     <select name=\"singleSelect\" ng-model=\"data.singleSelect\">\n *       <option value=\"option-1\">Option 1</option>\n *       <option value=\"option-2\">Option 2</option>\n *     </select><br>\n *\n *     <label for=\"singleSelect\"> Single select with \"not selected\" option and dynamic option values: </label><br>\n *     <select name=\"singleSelect\" id=\"singleSelect\" ng-model=\"data.singleSelect\">\n *       <option value=\"\">---Please select---</option> <!-- not selected / blank option -->\n *       <option value=\"{{data.option1}}\">Option 1</option> <!-- interpolation -->\n *       <option value=\"option-2\">Option 2</option>\n *     </select><br>\n *     <button ng-click=\"forceUnknownOption()\">Force unknown option</button><br>\n *     <tt>singleSelect = {{data.singleSelect}}</tt>\n *\n *     <hr>\n *     <label for=\"multipleSelect\"> Multiple select: </label><br>\n *     <select name=\"multipleSelect\" id=\"multipleSelect\" ng-model=\"data.multipleSelect\" multiple>\n *       <option value=\"option-1\">Option 1</option>\n *       <option value=\"option-2\">Option 2</option>\n *       <option value=\"option-3\">Option 3</option>\n *     </select><br>\n *     <tt>multipleSelect = {{data.multipleSelect}}</tt><br/>\n *   </form>\n * </div>\n * </file>\n * <file name=\"app.js\">\n *  angular.module('staticSelect', [])\n *    .controller('ExampleController', ['$scope', function($scope) {\n *      $scope.data = {\n *       singleSelect: null,\n *       multipleSelect: [],\n *       option1: 'option-1',\n *      };\n *\n *      $scope.forceUnknownOption = function() {\n *        $scope.data.singleSelect = 'nonsense';\n *      };\n *   }]);\n * </file>\n *</example>\n *\n * ### Using `ngRepeat` to generate `select` options\n * <example name=\"ngrepeat-select\" module=\"ngrepeatSelect\">\n * <file name=\"index.html\">\n * <div ng-controller=\"ExampleController\">\n *   <form name=\"myForm\">\n *     <label for=\"repeatSelect\"> Repeat select: </label>\n *     <select name=\"repeatSelect\" id=\"repeatSelect\" ng-model=\"data.repeatSelect\">\n *       <option ng-repeat=\"option in data.availableOptions\" value=\"{{option.id}}\">{{option.name}}</option>\n *     </select>\n *   </form>\n *   <hr>\n *   <tt>repeatSelect = {{data.repeatSelect}}</tt><br/>\n * </div>\n * </file>\n * <file name=\"app.js\">\n *  angular.module('ngrepeatSelect', [])\n *    .controller('ExampleController', ['$scope', function($scope) {\n *      $scope.data = {\n *       repeatSelect: null,\n *       availableOptions: [\n *         {id: '1', name: 'Option A'},\n *         {id: '2', name: 'Option B'},\n *         {id: '3', name: 'Option C'}\n *       ],\n *      };\n *   }]);\n * </file>\n *</example>\n *\n *\n * ### Using `select` with `ngOptions` and setting a default value\n * See the {@link ngOptions ngOptions documentation} for more `ngOptions` usage examples.\n *\n * <example name=\"select-with-default-values\" module=\"defaultValueSelect\">\n * <file name=\"index.html\">\n * <div ng-controller=\"ExampleController\">\n *   <form name=\"myForm\">\n *     <label for=\"mySelect\">Make a choice:</label>\n *     <select name=\"mySelect\" id=\"mySelect\"\n *       ng-options=\"option.name for option in data.availableOptions track by option.id\"\n *       ng-model=\"data.selectedOption\"></select>\n *   </form>\n *   <hr>\n *   <tt>option = {{data.selectedOption}}</tt><br/>\n * </div>\n * </file>\n * <file name=\"app.js\">\n *  angular.module('defaultValueSelect', [])\n *    .controller('ExampleController', ['$scope', function($scope) {\n *      $scope.data = {\n *       availableOptions: [\n *         {id: '1', name: 'Option A'},\n *         {id: '2', name: 'Option B'},\n *         {id: '3', name: 'Option C'}\n *       ],\n *       selectedOption: {id: '3', name: 'Option C'} //This sets the default value of the select in the ui\n *       };\n *   }]);\n * </file>\n *</example>\n *\n *\n * ### Binding `select` to a non-string value via `ngModel` parsing / formatting\n *\n * <example name=\"select-with-non-string-options\" module=\"nonStringSelect\">\n *   <file name=\"index.html\">\n *     <select ng-model=\"model.id\" convert-to-number>\n *       <option value=\"0\">Zero</option>\n *       <option value=\"1\">One</option>\n *       <option value=\"2\">Two</option>\n *     </select>\n *     {{ model }}\n *   </file>\n *   <file name=\"app.js\">\n *     angular.module('nonStringSelect', [])\n *       .run(function($rootScope) {\n *         $rootScope.model = { id: 2 };\n *       })\n *       .directive('convertToNumber', function() {\n *         return {\n *           require: 'ngModel',\n *           link: function(scope, element, attrs, ngModel) {\n *             ngModel.$parsers.push(function(val) {\n *               return parseInt(val, 10);\n *             });\n *             ngModel.$formatters.push(function(val) {\n *               return '' + val;\n *             });\n *           }\n *         };\n *       });\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n *     it('should initialize to model', function() {\n *       var select = element(by.css('select'));\n *       expect(element(by.model('model.id')).$('option:checked').getText()).toEqual('Two');\n *     });\n *   </file>\n * </example>\n *\n */\nvar selectDirective = function() {\n\n  return {\n    restrict: 'E',\n    require: ['select', '?ngModel'],\n    controller: SelectController,\n    priority: 1,\n    link: {\n      pre: selectPreLink,\n      post: selectPostLink\n    }\n  };\n\n  function selectPreLink(scope, element, attr, ctrls) {\n\n      // if ngModel is not defined, we don't need to do anything\n      var ngModelCtrl = ctrls[1];\n      if (!ngModelCtrl) return;\n\n      var selectCtrl = ctrls[0];\n\n      selectCtrl.ngModelCtrl = ngModelCtrl;\n\n      // When the selected item(s) changes we delegate getting the value of the select control\n      // to the `readValue` method, which can be changed if the select can have multiple\n      // selected values or if the options are being generated by `ngOptions`\n      element.on('change', function() {\n        scope.$apply(function() {\n          ngModelCtrl.$setViewValue(selectCtrl.readValue());\n        });\n      });\n\n      // If the select allows multiple values then we need to modify how we read and write\n      // values from and to the control; also what it means for the value to be empty and\n      // we have to add an extra watch since ngModel doesn't work well with arrays - it\n      // doesn't trigger rendering if only an item in the array changes.\n      if (attr.multiple) {\n\n        // Read value now needs to check each option to see if it is selected\n        selectCtrl.readValue = function readMultipleValue() {\n          var array = [];\n          forEach(element.find('option'), function(option) {\n            if (option.selected) {\n              array.push(option.value);\n            }\n          });\n          return array;\n        };\n\n        // Write value now needs to set the selected property of each matching option\n        selectCtrl.writeValue = function writeMultipleValue(value) {\n          var items = new HashMap(value);\n          forEach(element.find('option'), function(option) {\n            option.selected = isDefined(items.get(option.value));\n          });\n        };\n\n        // we have to do it on each watch since ngModel watches reference, but\n        // we need to work of an array, so we need to see if anything was inserted/removed\n        var lastView, lastViewRef = NaN;\n        scope.$watch(function selectMultipleWatch() {\n          if (lastViewRef === ngModelCtrl.$viewValue && !equals(lastView, ngModelCtrl.$viewValue)) {\n            lastView = shallowCopy(ngModelCtrl.$viewValue);\n            ngModelCtrl.$render();\n          }\n          lastViewRef = ngModelCtrl.$viewValue;\n        });\n\n        // If we are a multiple select then value is now a collection\n        // so the meaning of $isEmpty changes\n        ngModelCtrl.$isEmpty = function(value) {\n          return !value || value.length === 0;\n        };\n\n      }\n    }\n\n    function selectPostLink(scope, element, attrs, ctrls) {\n      // if ngModel is not defined, we don't need to do anything\n      var ngModelCtrl = ctrls[1];\n      if (!ngModelCtrl) return;\n\n      var selectCtrl = ctrls[0];\n\n      // We delegate rendering to the `writeValue` method, which can be changed\n      // if the select can have multiple selected values or if the options are being\n      // generated by `ngOptions`.\n      // This must be done in the postLink fn to prevent $render to be called before\n      // all nodes have been linked correctly.\n      ngModelCtrl.$render = function() {\n        selectCtrl.writeValue(ngModelCtrl.$viewValue);\n      };\n    }\n};\n\n\n// The option directive is purely designed to communicate the existence (or lack of)\n// of dynamically created (and destroyed) option elements to their containing select\n// directive via its controller.\nvar optionDirective = ['$interpolate', function($interpolate) {\n  return {\n    restrict: 'E',\n    priority: 100,\n    compile: function(element, attr) {\n      if (isDefined(attr.value)) {\n        // If the value attribute is defined, check if it contains an interpolation\n        var interpolateValueFn = $interpolate(attr.value, true);\n      } else {\n        // If the value attribute is not defined then we fall back to the\n        // text content of the option element, which may be interpolated\n        var interpolateTextFn = $interpolate(element.text(), true);\n        if (!interpolateTextFn) {\n          attr.$set('value', element.text());\n        }\n      }\n\n      return function(scope, element, attr) {\n        // This is an optimization over using ^^ since we don't want to have to search\n        // all the way to the root of the DOM for every single option element\n        var selectCtrlName = '$selectController',\n            parent = element.parent(),\n            selectCtrl = parent.data(selectCtrlName) ||\n              parent.parent().data(selectCtrlName); // in case we are in optgroup\n\n        if (selectCtrl) {\n          selectCtrl.registerOption(scope, element, attr, interpolateValueFn, interpolateTextFn);\n        }\n      };\n    }\n  };\n}];\n\nvar styleDirective = valueFn({\n  restrict: 'E',\n  terminal: false\n});\n\n/**\n * @ngdoc directive\n * @name ngRequired\n *\n * @description\n *\n * ngRequired adds the required {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.\n * It is most often used for {@link input `input`} and {@link select `select`} controls, but can also be\n * applied to custom controls.\n *\n * The directive sets the `required` attribute on the element if the Angular expression inside\n * `ngRequired` evaluates to true. A special directive for setting `required` is necessary because we\n * cannot use interpolation inside `required`. See the {@link guide/interpolation interpolation guide}\n * for more info.\n *\n * The validator will set the `required` error key to true if the `required` attribute is set and\n * calling {@link ngModel.NgModelController#$isEmpty `NgModelController.$isEmpty`} with the\n * {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`} returns `true`. For example, the\n * `$isEmpty()` implementation for `input[text]` checks the length of the `$viewValue`. When developing\n * custom controls, `$isEmpty()` can be overwritten to account for a $viewValue that is not string-based.\n *\n * @example\n * <example name=\"ngRequiredDirective\" module=\"ngRequiredExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('ngRequiredExample', [])\n *         .controller('ExampleController', ['$scope', function($scope) {\n *           $scope.required = true;\n *         }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <form name=\"form\">\n *         <label for=\"required\">Toggle required: </label>\n *         <input type=\"checkbox\" ng-model=\"required\" id=\"required\" />\n *         <br>\n *         <label for=\"input\">This input must be filled if `required` is true: </label>\n *         <input type=\"text\" ng-model=\"model\" id=\"input\" name=\"input\" ng-required=\"required\" /><br>\n *         <hr>\n *         required error set? = <code>{{form.input.$error.required}}</code><br>\n *         model = <code>{{model}}</code>\n *       </form>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n       var required = element(by.binding('form.input.$error.required'));\n       var model = element(by.binding('model'));\n       var input = element(by.id('input'));\n\n       it('should set the required error', function() {\n         expect(required.getText()).toContain('true');\n\n         input.sendKeys('123');\n         expect(required.getText()).not.toContain('true');\n         expect(model.getText()).toContain('123');\n       });\n *   </file>\n * </example>\n */\nvar requiredDirective = function() {\n  return {\n    restrict: 'A',\n    require: '?ngModel',\n    link: function(scope, elm, attr, ctrl) {\n      if (!ctrl) return;\n      attr.required = true; // force truthy in case we are on non input element\n\n      ctrl.$validators.required = function(modelValue, viewValue) {\n        return !attr.required || !ctrl.$isEmpty(viewValue);\n      };\n\n      attr.$observe('required', function() {\n        ctrl.$validate();\n      });\n    }\n  };\n};\n\n/**\n * @ngdoc directive\n * @name ngPattern\n *\n * @description\n *\n * ngPattern adds the pattern {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.\n * It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.\n *\n * The validator sets the `pattern` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}\n * does not match a RegExp which is obtained by evaluating the Angular expression given in the\n * `ngPattern` attribute value:\n * * If the expression evaluates to a RegExp object, then this is used directly.\n * * If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it\n * in `^` and `$` characters. For instance, `\"abc\"` will be converted to `new RegExp('^abc$')`.\n *\n * <div class=\"alert alert-info\">\n * **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to\n * start at the index of the last search's match, thus not taking the whole input value into\n * account.\n * </div>\n *\n * <div class=\"alert alert-info\">\n * **Note:** This directive is also added when the plain `pattern` attribute is used, with two\n * differences:\n * <ol>\n *   <li>\n *     `ngPattern` does not set the `pattern` attribute and therefore HTML5 constraint validation is\n *     not available.\n *   </li>\n *   <li>\n *     The `ngPattern` attribute must be an expression, while the `pattern` value must be\n *     interpolated.\n *   </li>\n * </ol>\n * </div>\n *\n * @example\n * <example name=\"ngPatternDirective\" module=\"ngPatternExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('ngPatternExample', [])\n *         .controller('ExampleController', ['$scope', function($scope) {\n *           $scope.regex = '\\\\d+';\n *         }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <form name=\"form\">\n *         <label for=\"regex\">Set a pattern (regex string): </label>\n *         <input type=\"text\" ng-model=\"regex\" id=\"regex\" />\n *         <br>\n *         <label for=\"input\">This input is restricted by the current pattern: </label>\n *         <input type=\"text\" ng-model=\"model\" id=\"input\" name=\"input\" ng-pattern=\"regex\" /><br>\n *         <hr>\n *         input valid? = <code>{{form.input.$valid}}</code><br>\n *         model = <code>{{model}}</code>\n *       </form>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n       var model = element(by.binding('model'));\n       var input = element(by.id('input'));\n\n       it('should validate the input with the default pattern', function() {\n         input.sendKeys('aaa');\n         expect(model.getText()).not.toContain('aaa');\n\n         input.clear().then(function() {\n           input.sendKeys('123');\n           expect(model.getText()).toContain('123');\n         });\n       });\n *   </file>\n * </example>\n */\nvar patternDirective = function() {\n  return {\n    restrict: 'A',\n    require: '?ngModel',\n    link: function(scope, elm, attr, ctrl) {\n      if (!ctrl) return;\n\n      var regexp, patternExp = attr.ngPattern || attr.pattern;\n      attr.$observe('pattern', function(regex) {\n        if (isString(regex) && regex.length > 0) {\n          regex = new RegExp('^' + regex + '$');\n        }\n\n        if (regex && !regex.test) {\n          throw minErr('ngPattern')('noregexp',\n            'Expected {0} to be a RegExp but was {1}. Element: {2}', patternExp,\n            regex, startingTag(elm));\n        }\n\n        regexp = regex || undefined;\n        ctrl.$validate();\n      });\n\n      ctrl.$validators.pattern = function(modelValue, viewValue) {\n        // HTML5 pattern constraint validates the input value, so we validate the viewValue\n        return ctrl.$isEmpty(viewValue) || isUndefined(regexp) || regexp.test(viewValue);\n      };\n    }\n  };\n};\n\n/**\n * @ngdoc directive\n * @name ngMaxlength\n *\n * @description\n *\n * ngMaxlength adds the maxlength {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.\n * It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.\n *\n * The validator sets the `maxlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}\n * is longer than the integer obtained by evaluating the Angular expression given in the\n * `ngMaxlength` attribute value.\n *\n * <div class=\"alert alert-info\">\n * **Note:** This directive is also added when the plain `maxlength` attribute is used, with two\n * differences:\n * <ol>\n *   <li>\n *     `ngMaxlength` does not set the `maxlength` attribute and therefore HTML5 constraint\n *     validation is not available.\n *   </li>\n *   <li>\n *     The `ngMaxlength` attribute must be an expression, while the `maxlength` value must be\n *     interpolated.\n *   </li>\n * </ol>\n * </div>\n *\n * @example\n * <example name=\"ngMaxlengthDirective\" module=\"ngMaxlengthExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('ngMaxlengthExample', [])\n *         .controller('ExampleController', ['$scope', function($scope) {\n *           $scope.maxlength = 5;\n *         }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <form name=\"form\">\n *         <label for=\"maxlength\">Set a maxlength: </label>\n *         <input type=\"number\" ng-model=\"maxlength\" id=\"maxlength\" />\n *         <br>\n *         <label for=\"input\">This input is restricted by the current maxlength: </label>\n *         <input type=\"text\" ng-model=\"model\" id=\"input\" name=\"input\" ng-maxlength=\"maxlength\" /><br>\n *         <hr>\n *         input valid? = <code>{{form.input.$valid}}</code><br>\n *         model = <code>{{model}}</code>\n *       </form>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n       var model = element(by.binding('model'));\n       var input = element(by.id('input'));\n\n       it('should validate the input with the default maxlength', function() {\n         input.sendKeys('abcdef');\n         expect(model.getText()).not.toContain('abcdef');\n\n         input.clear().then(function() {\n           input.sendKeys('abcde');\n           expect(model.getText()).toContain('abcde');\n         });\n       });\n *   </file>\n * </example>\n */\nvar maxlengthDirective = function() {\n  return {\n    restrict: 'A',\n    require: '?ngModel',\n    link: function(scope, elm, attr, ctrl) {\n      if (!ctrl) return;\n\n      var maxlength = -1;\n      attr.$observe('maxlength', function(value) {\n        var intVal = toInt(value);\n        maxlength = isNaN(intVal) ? -1 : intVal;\n        ctrl.$validate();\n      });\n      ctrl.$validators.maxlength = function(modelValue, viewValue) {\n        return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);\n      };\n    }\n  };\n};\n\n/**\n * @ngdoc directive\n * @name ngMinlength\n *\n * @description\n *\n * ngMinlength adds the minlength {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.\n * It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.\n *\n * The validator sets the `minlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}\n * is shorter than the integer obtained by evaluating the Angular expression given in the\n * `ngMinlength` attribute value.\n *\n * <div class=\"alert alert-info\">\n * **Note:** This directive is also added when the plain `minlength` attribute is used, with two\n * differences:\n * <ol>\n *   <li>\n *     `ngMinlength` does not set the `minlength` attribute and therefore HTML5 constraint\n *     validation is not available.\n *   </li>\n *   <li>\n *     The `ngMinlength` value must be an expression, while the `minlength` value must be\n *     interpolated.\n *   </li>\n * </ol>\n * </div>\n *\n * @example\n * <example name=\"ngMinlengthDirective\" module=\"ngMinlengthExample\">\n *   <file name=\"index.html\">\n *     <script>\n *       angular.module('ngMinlengthExample', [])\n *         .controller('ExampleController', ['$scope', function($scope) {\n *           $scope.minlength = 3;\n *         }]);\n *     </script>\n *     <div ng-controller=\"ExampleController\">\n *       <form name=\"form\">\n *         <label for=\"minlength\">Set a minlength: </label>\n *         <input type=\"number\" ng-model=\"minlength\" id=\"minlength\" />\n *         <br>\n *         <label for=\"input\">This input is restricted by the current minlength: </label>\n *         <input type=\"text\" ng-model=\"model\" id=\"input\" name=\"input\" ng-minlength=\"minlength\" /><br>\n *         <hr>\n *         input valid? = <code>{{form.input.$valid}}</code><br>\n *         model = <code>{{model}}</code>\n *       </form>\n *     </div>\n *   </file>\n *   <file name=\"protractor.js\" type=\"protractor\">\n       var model = element(by.binding('model'));\n       var input = element(by.id('input'));\n\n       it('should validate the input with the default minlength', function() {\n         input.sendKeys('ab');\n         expect(model.getText()).not.toContain('ab');\n\n         input.sendKeys('abc');\n         expect(model.getText()).toContain('abc');\n       });\n *   </file>\n * </example>\n */\nvar minlengthDirective = function() {\n  return {\n    restrict: 'A',\n    require: '?ngModel',\n    link: function(scope, elm, attr, ctrl) {\n      if (!ctrl) return;\n\n      var minlength = 0;\n      attr.$observe('minlength', function(value) {\n        minlength = toInt(value) || 0;\n        ctrl.$validate();\n      });\n      ctrl.$validators.minlength = function(modelValue, viewValue) {\n        return ctrl.$isEmpty(viewValue) || viewValue.length >= minlength;\n      };\n    }\n  };\n};\n\nif (window.angular.bootstrap) {\n  //AngularJS is already loaded, so we can return here...\n  if (window.console) {\n    console.log('WARNING: Tried to load angular more than once.');\n  }\n  return;\n}\n\n//try to bind to jquery now so that one can write jqLite(document).ready()\n//but we will rebind on bootstrap again.\nbindJQuery();\n\npublishExternalAPI(angular);\n\nangular.module(\"ngLocale\", [], [\"$provide\", function($provide) {\nvar PLURAL_CATEGORY = {ZERO: \"zero\", ONE: \"one\", TWO: \"two\", FEW: \"few\", MANY: \"many\", OTHER: \"other\"};\nfunction getDecimals(n) {\n  n = n + '';\n  var i = n.indexOf('.');\n  return (i == -1) ? 0 : n.length - i - 1;\n}\n\nfunction getVF(n, opt_precision) {\n  var v = opt_precision;\n\n  if (undefined === v) {\n    v = Math.min(getDecimals(n), 3);\n  }\n\n  var base = Math.pow(10, v);\n  var f = ((n * base) | 0) % base;\n  return {v: v, f: f};\n}\n\n$provide.value(\"$locale\", {\n  \"DATETIME_FORMATS\": {\n    \"AMPMS\": [\n      \"AM\",\n      \"PM\"\n    ],\n    \"DAY\": [\n      \"Sunday\",\n      \"Monday\",\n      \"Tuesday\",\n      \"Wednesday\",\n      \"Thursday\",\n      \"Friday\",\n      \"Saturday\"\n    ],\n    \"ERANAMES\": [\n      \"Before Christ\",\n      \"Anno Domini\"\n    ],\n    \"ERAS\": [\n      \"BC\",\n      \"AD\"\n    ],\n    \"FIRSTDAYOFWEEK\": 6,\n    \"MONTH\": [\n      \"January\",\n      \"February\",\n      \"March\",\n      \"April\",\n      \"May\",\n      \"June\",\n      \"July\",\n      \"August\",\n      \"September\",\n      \"October\",\n      \"November\",\n      \"December\"\n    ],\n    \"SHORTDAY\": [\n      \"Sun\",\n      \"Mon\",\n      \"Tue\",\n      \"Wed\",\n      \"Thu\",\n      \"Fri\",\n      \"Sat\"\n    ],\n    \"SHORTMONTH\": [\n      \"Jan\",\n      \"Feb\",\n      \"Mar\",\n      \"Apr\",\n      \"May\",\n      \"Jun\",\n      \"Jul\",\n      \"Aug\",\n      \"Sep\",\n      \"Oct\",\n      \"Nov\",\n      \"Dec\"\n    ],\n    \"STANDALONEMONTH\": [\n      \"January\",\n      \"February\",\n      \"March\",\n      \"April\",\n      \"May\",\n      \"June\",\n      \"July\",\n      \"August\",\n      \"September\",\n      \"October\",\n      \"November\",\n      \"December\"\n    ],\n    \"WEEKENDRANGE\": [\n      5,\n      6\n    ],\n    \"fullDate\": \"EEEE, MMMM d, y\",\n    \"longDate\": \"MMMM d, y\",\n    \"medium\": \"MMM d, y h:mm:ss a\",\n    \"mediumDate\": \"MMM d, y\",\n    \"mediumTime\": \"h:mm:ss a\",\n    \"short\": \"M/d/yy h:mm a\",\n    \"shortDate\": \"M/d/yy\",\n    \"shortTime\": \"h:mm a\"\n  },\n  \"NUMBER_FORMATS\": {\n    \"CURRENCY_SYM\": \"$\",\n    \"DECIMAL_SEP\": \".\",\n    \"GROUP_SEP\": \",\",\n    \"PATTERNS\": [\n      {\n        \"gSize\": 3,\n        \"lgSize\": 3,\n        \"maxFrac\": 3,\n        \"minFrac\": 0,\n        \"minInt\": 1,\n        \"negPre\": \"-\",\n        \"negSuf\": \"\",\n        \"posPre\": \"\",\n        \"posSuf\": \"\"\n      },\n      {\n        \"gSize\": 3,\n        \"lgSize\": 3,\n        \"maxFrac\": 2,\n        \"minFrac\": 2,\n        \"minInt\": 1,\n        \"negPre\": \"-\\u00a4\",\n        \"negSuf\": \"\",\n        \"posPre\": \"\\u00a4\",\n        \"posSuf\": \"\"\n      }\n    ]\n  },\n  \"id\": \"en-us\",\n  \"localeID\": \"en_US\",\n  \"pluralCat\": function(n, opt_precision) {  var i = n | 0;  var vf = getVF(n, opt_precision);  if (i == 1 && vf.v == 0) {    return PLURAL_CATEGORY.ONE;  }  return PLURAL_CATEGORY.OTHER;}\n});\n}]);\n\n  jqLite(window.document).ready(function() {\n    angularInit(window.document, bootstrap);\n  });\n\n})(window);\n\n!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend('<style type=\"text/css\">@charset \"UTF-8\";[ng\\\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}</style>');"
  },
  {
    "path": "html/lib/angular-bootstrap/ui-bootstrap-tpls.js",
    "content": "/*\n * angular-ui-bootstrap\n * http://angular-ui.github.io/bootstrap/\n\n * Version: 1.3.2 - 2016-04-14\n * License: MIT\n */angular.module(\"ui.bootstrap\", [\"ui.bootstrap.tpls\", \"ui.bootstrap.collapse\",\"ui.bootstrap.accordion\",\"ui.bootstrap.alert\",\"ui.bootstrap.buttons\",\"ui.bootstrap.carousel\",\"ui.bootstrap.dateparser\",\"ui.bootstrap.isClass\",\"ui.bootstrap.datepicker\",\"ui.bootstrap.position\",\"ui.bootstrap.datepickerPopup\",\"ui.bootstrap.debounce\",\"ui.bootstrap.dropdown\",\"ui.bootstrap.stackedMap\",\"ui.bootstrap.modal\",\"ui.bootstrap.paging\",\"ui.bootstrap.pager\",\"ui.bootstrap.pagination\",\"ui.bootstrap.tooltip\",\"ui.bootstrap.popover\",\"ui.bootstrap.progressbar\",\"ui.bootstrap.rating\",\"ui.bootstrap.tabs\",\"ui.bootstrap.timepicker\",\"ui.bootstrap.typeahead\"]);\nangular.module(\"ui.bootstrap.tpls\", [\"uib/template/accordion/accordion-group.html\",\"uib/template/accordion/accordion.html\",\"uib/template/alert/alert.html\",\"uib/template/carousel/carousel.html\",\"uib/template/carousel/slide.html\",\"uib/template/datepicker/datepicker.html\",\"uib/template/datepicker/day.html\",\"uib/template/datepicker/month.html\",\"uib/template/datepicker/year.html\",\"uib/template/datepickerPopup/popup.html\",\"uib/template/modal/backdrop.html\",\"uib/template/modal/window.html\",\"uib/template/pager/pager.html\",\"uib/template/pagination/pagination.html\",\"uib/template/tooltip/tooltip-html-popup.html\",\"uib/template/tooltip/tooltip-popup.html\",\"uib/template/tooltip/tooltip-template-popup.html\",\"uib/template/popover/popover-html.html\",\"uib/template/popover/popover-template.html\",\"uib/template/popover/popover.html\",\"uib/template/progressbar/bar.html\",\"uib/template/progressbar/progress.html\",\"uib/template/progressbar/progressbar.html\",\"uib/template/rating/rating.html\",\"uib/template/tabs/tab.html\",\"uib/template/tabs/tabset.html\",\"uib/template/timepicker/timepicker.html\",\"uib/template/typeahead/typeahead-match.html\",\"uib/template/typeahead/typeahead-popup.html\"]);\nangular.module('ui.bootstrap.collapse', [])\n\n  .directive('uibCollapse', ['$animate', '$q', '$parse', '$injector', function($animate, $q, $parse, $injector) {\n    var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;\n    return {\n      link: function(scope, element, attrs) {\n        var expandingExpr = $parse(attrs.expanding),\n            expandedExpr = $parse(attrs.expanded),\n            collapsingExpr = $parse(attrs.collapsing),\n            collapsedExpr = $parse(attrs.collapsed);\n\n        if (!scope.$eval(attrs.uibCollapse)) {\n          element.addClass('in')\n            .addClass('collapse')\n            .attr('aria-expanded', true)\n            .attr('aria-hidden', false)\n            .css({height: 'auto'});\n        }\n\n        function expand() {\n          if (element.hasClass('collapse') && element.hasClass('in')) {\n            return;\n          }\n\n          $q.resolve(expandingExpr(scope))\n            .then(function() {\n              element.removeClass('collapse')\n                .addClass('collapsing')\n                .attr('aria-expanded', true)\n                .attr('aria-hidden', false);\n\n              if ($animateCss) {\n                $animateCss(element, {\n                  addClass: 'in',\n                  easing: 'ease',\n                  to: { height: element[0].scrollHeight + 'px' }\n                }).start()['finally'](expandDone);\n              } else {\n                $animate.addClass(element, 'in', {\n                  to: { height: element[0].scrollHeight + 'px' }\n                }).then(expandDone);\n              }\n            });\n        }\n\n        function expandDone() {\n          element.removeClass('collapsing')\n            .addClass('collapse')\n            .css({height: 'auto'});\n          expandedExpr(scope);\n        }\n\n        function collapse() {\n          if (!element.hasClass('collapse') && !element.hasClass('in')) {\n            return collapseDone();\n          }\n\n          $q.resolve(collapsingExpr(scope))\n            .then(function() {\n              element\n                // IMPORTANT: The height must be set before adding \"collapsing\" class.\n                // Otherwise, the browser attempts to animate from height 0 (in\n                // collapsing class) to the given height here.\n                .css({height: element[0].scrollHeight + 'px'})\n                // initially all panel collapse have the collapse class, this removal\n                // prevents the animation from jumping to collapsed state\n                .removeClass('collapse')\n                .addClass('collapsing')\n                .attr('aria-expanded', false)\n                .attr('aria-hidden', true);\n\n              if ($animateCss) {\n                $animateCss(element, {\n                  removeClass: 'in',\n                  to: {height: '0'}\n                }).start()['finally'](collapseDone);\n              } else {\n                $animate.removeClass(element, 'in', {\n                  to: {height: '0'}\n                }).then(collapseDone);\n              }\n            });\n        }\n\n        function collapseDone() {\n          element.css({height: '0'}); // Required so that collapse works when animation is disabled\n          element.removeClass('collapsing')\n            .addClass('collapse');\n          collapsedExpr(scope);\n        }\n\n        scope.$watch(attrs.uibCollapse, function(shouldCollapse) {\n          if (shouldCollapse) {\n            collapse();\n          } else {\n            expand();\n          }\n        });\n      }\n    };\n  }]);\n\nangular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])\n\n.constant('uibAccordionConfig', {\n  closeOthers: true\n})\n\n.controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) {\n  // This array keeps track of the accordion groups\n  this.groups = [];\n\n  // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to\n  this.closeOthers = function(openGroup) {\n    var closeOthers = angular.isDefined($attrs.closeOthers) ?\n      $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers;\n    if (closeOthers) {\n      angular.forEach(this.groups, function(group) {\n        if (group !== openGroup) {\n          group.isOpen = false;\n        }\n      });\n    }\n  };\n\n  // This is called from the accordion-group directive to add itself to the accordion\n  this.addGroup = function(groupScope) {\n    var that = this;\n    this.groups.push(groupScope);\n\n    groupScope.$on('$destroy', function(event) {\n      that.removeGroup(groupScope);\n    });\n  };\n\n  // This is called from the accordion-group directive when to remove itself\n  this.removeGroup = function(group) {\n    var index = this.groups.indexOf(group);\n    if (index !== -1) {\n      this.groups.splice(index, 1);\n    }\n  };\n}])\n\n// The accordion directive simply sets up the directive controller\n// and adds an accordion CSS class to itself element.\n.directive('uibAccordion', function() {\n  return {\n    controller: 'UibAccordionController',\n    controllerAs: 'accordion',\n    transclude: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/accordion/accordion.html';\n    }\n  };\n})\n\n// The accordion-group directive indicates a block of html that will expand and collapse in an accordion\n.directive('uibAccordionGroup', function() {\n  return {\n    require: '^uibAccordion',         // We need this directive to be inside an accordion\n    transclude: true,              // It transcludes the contents of the directive into the template\n    replace: true,                // The element containing the directive will be replaced with the template\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/accordion/accordion-group.html';\n    },\n    scope: {\n      heading: '@',               // Interpolate the heading attribute onto this scope\n      panelClass: '@?',           // Ditto with panelClass\n      isOpen: '=?',\n      isDisabled: '=?'\n    },\n    controller: function() {\n      this.setHeading = function(element) {\n        this.heading = element;\n      };\n    },\n    link: function(scope, element, attrs, accordionCtrl) {\n      accordionCtrl.addGroup(scope);\n\n      scope.openClass = attrs.openClass || 'panel-open';\n      scope.panelClass = attrs.panelClass || 'panel-default';\n      scope.$watch('isOpen', function(value) {\n        element.toggleClass(scope.openClass, !!value);\n        if (value) {\n          accordionCtrl.closeOthers(scope);\n        }\n      });\n\n      scope.toggleOpen = function($event) {\n        if (!scope.isDisabled) {\n          if (!$event || $event.which === 32) {\n            scope.isOpen = !scope.isOpen;\n          }\n        }\n      };\n\n      var id = 'accordiongroup-' + scope.$id + '-' + Math.floor(Math.random() * 10000);\n      scope.headingId = id + '-tab';\n      scope.panelId = id + '-panel';\n    }\n  };\n})\n\n// Use accordion-heading below an accordion-group to provide a heading containing HTML\n.directive('uibAccordionHeading', function() {\n  return {\n    transclude: true,   // Grab the contents to be used as the heading\n    template: '',       // In effect remove this element!\n    replace: true,\n    require: '^uibAccordionGroup',\n    link: function(scope, element, attrs, accordionGroupCtrl, transclude) {\n      // Pass the heading to the accordion-group controller\n      // so that it can be transcluded into the right place in the template\n      // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]\n      accordionGroupCtrl.setHeading(transclude(scope, angular.noop));\n    }\n  };\n})\n\n// Use in the accordion-group template to indicate where you want the heading to be transcluded\n// You must provide the property on the accordion-group controller that will hold the transcluded element\n.directive('uibAccordionTransclude', function() {\n  return {\n    require: '^uibAccordionGroup',\n    link: function(scope, element, attrs, controller) {\n      scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {\n        if (heading) {\n          var elem = angular.element(element[0].querySelector('[uib-accordion-header]'));\n          elem.html('');\n          elem.append(heading);\n        }\n      });\n    }\n  };\n});\n\nangular.module('ui.bootstrap.alert', [])\n\n.controller('UibAlertController', ['$scope', '$attrs', '$interpolate', '$timeout', function($scope, $attrs, $interpolate, $timeout) {\n  $scope.closeable = !!$attrs.close;\n\n  var dismissOnTimeout = angular.isDefined($attrs.dismissOnTimeout) ?\n    $interpolate($attrs.dismissOnTimeout)($scope.$parent) : null;\n\n  if (dismissOnTimeout) {\n    $timeout(function() {\n      $scope.close();\n    }, parseInt(dismissOnTimeout, 10));\n  }\n}])\n\n.directive('uibAlert', function() {\n  return {\n    controller: 'UibAlertController',\n    controllerAs: 'alert',\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/alert/alert.html';\n    },\n    transclude: true,\n    replace: true,\n    scope: {\n      type: '@',\n      close: '&'\n    }\n  };\n});\n\nangular.module('ui.bootstrap.buttons', [])\n\n.constant('uibButtonConfig', {\n  activeClass: 'active',\n  toggleEvent: 'click'\n})\n\n.controller('UibButtonsController', ['uibButtonConfig', function(buttonConfig) {\n  this.activeClass = buttonConfig.activeClass || 'active';\n  this.toggleEvent = buttonConfig.toggleEvent || 'click';\n}])\n\n.directive('uibBtnRadio', ['$parse', function($parse) {\n  return {\n    require: ['uibBtnRadio', 'ngModel'],\n    controller: 'UibButtonsController',\n    controllerAs: 'buttons',\n    link: function(scope, element, attrs, ctrls) {\n      var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n      var uncheckableExpr = $parse(attrs.uibUncheckable);\n\n      element.find('input').css({display: 'none'});\n\n      //model -> UI\n      ngModelCtrl.$render = function() {\n        element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.uibBtnRadio)));\n      };\n\n      //ui->model\n      element.on(buttonsCtrl.toggleEvent, function() {\n        if (attrs.disabled) {\n          return;\n        }\n\n        var isActive = element.hasClass(buttonsCtrl.activeClass);\n\n        if (!isActive || angular.isDefined(attrs.uncheckable)) {\n          scope.$apply(function() {\n            ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.uibBtnRadio));\n            ngModelCtrl.$render();\n          });\n        }\n      });\n\n      if (attrs.uibUncheckable) {\n        scope.$watch(uncheckableExpr, function(uncheckable) {\n          attrs.$set('uncheckable', uncheckable ? '' : undefined);\n        });\n      }\n    }\n  };\n}])\n\n.directive('uibBtnCheckbox', function() {\n  return {\n    require: ['uibBtnCheckbox', 'ngModel'],\n    controller: 'UibButtonsController',\n    controllerAs: 'button',\n    link: function(scope, element, attrs, ctrls) {\n      var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n      element.find('input').css({display: 'none'});\n\n      function getTrueValue() {\n        return getCheckboxValue(attrs.btnCheckboxTrue, true);\n      }\n\n      function getFalseValue() {\n        return getCheckboxValue(attrs.btnCheckboxFalse, false);\n      }\n\n      function getCheckboxValue(attribute, defaultValue) {\n        return angular.isDefined(attribute) ? scope.$eval(attribute) : defaultValue;\n      }\n\n      //model -> UI\n      ngModelCtrl.$render = function() {\n        element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));\n      };\n\n      //ui->model\n      element.on(buttonsCtrl.toggleEvent, function() {\n        if (attrs.disabled) {\n          return;\n        }\n\n        scope.$apply(function() {\n          ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());\n          ngModelCtrl.$render();\n        });\n      });\n    }\n  };\n});\n\nangular.module('ui.bootstrap.carousel', [])\n\n.controller('UibCarouselController', ['$scope', '$element', '$interval', '$timeout', '$animate', function($scope, $element, $interval, $timeout, $animate) {\n  var self = this,\n    slides = self.slides = $scope.slides = [],\n    SLIDE_DIRECTION = 'uib-slideDirection',\n    currentIndex = $scope.active,\n    currentInterval, isPlaying, bufferedTransitions = [];\n\n  var destroyed = false;\n\n  self.addSlide = function(slide, element) {\n    slides.push({\n      slide: slide,\n      element: element\n    });\n    slides.sort(function(a, b) {\n      return +a.slide.index - +b.slide.index;\n    });\n    //if this is the first slide or the slide is set to active, select it\n    if (slide.index === $scope.active || slides.length === 1 && !angular.isNumber($scope.active)) {\n      if ($scope.$currentTransition) {\n        $scope.$currentTransition = null;\n      }\n\n      currentIndex = slide.index;\n      $scope.active = slide.index;\n      setActive(currentIndex);\n      self.select(slides[findSlideIndex(slide)]);\n      if (slides.length === 1) {\n        $scope.play();\n      }\n    }\n  };\n\n  self.getCurrentIndex = function() {\n    for (var i = 0; i < slides.length; i++) {\n      if (slides[i].slide.index === currentIndex) {\n        return i;\n      }\n    }\n  };\n\n  self.next = $scope.next = function() {\n    var newIndex = (self.getCurrentIndex() + 1) % slides.length;\n\n    if (newIndex === 0 && $scope.noWrap()) {\n      $scope.pause();\n      return;\n    }\n\n    return self.select(slides[newIndex], 'next');\n  };\n\n  self.prev = $scope.prev = function() {\n    var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1;\n\n    if ($scope.noWrap() && newIndex === slides.length - 1) {\n      $scope.pause();\n      return;\n    }\n\n    return self.select(slides[newIndex], 'prev');\n  };\n\n  self.removeSlide = function(slide) {\n    var index = findSlideIndex(slide);\n\n    var bufferedIndex = bufferedTransitions.indexOf(slides[index]);\n    if (bufferedIndex !== -1) {\n      bufferedTransitions.splice(bufferedIndex, 1);\n    }\n\n    //get the index of the slide inside the carousel\n    slides.splice(index, 1);\n    if (slides.length > 0 && currentIndex === index) {\n      if (index >= slides.length) {\n        currentIndex = slides.length - 1;\n        $scope.active = currentIndex;\n        setActive(currentIndex);\n        self.select(slides[slides.length - 1]);\n      } else {\n        currentIndex = index;\n        $scope.active = currentIndex;\n        setActive(currentIndex);\n        self.select(slides[index]);\n      }\n    } else if (currentIndex > index) {\n      currentIndex--;\n      $scope.active = currentIndex;\n    }\n\n    //clean the active value when no more slide\n    if (slides.length === 0) {\n      currentIndex = null;\n      $scope.active = null;\n      clearBufferedTransitions();\n    }\n  };\n\n  /* direction: \"prev\" or \"next\" */\n  self.select = $scope.select = function(nextSlide, direction) {\n    var nextIndex = findSlideIndex(nextSlide.slide);\n    //Decide direction if it's not given\n    if (direction === undefined) {\n      direction = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';\n    }\n    //Prevent this user-triggered transition from occurring if there is already one in progress\n    if (nextSlide.slide.index !== currentIndex &&\n      !$scope.$currentTransition) {\n      goNext(nextSlide.slide, nextIndex, direction);\n    } else if (nextSlide && nextSlide.slide.index !== currentIndex && $scope.$currentTransition) {\n      bufferedTransitions.push(slides[nextIndex]);\n    }\n  };\n\n  /* Allow outside people to call indexOf on slides array */\n  $scope.indexOfSlide = function(slide) {\n    return +slide.slide.index;\n  };\n\n  $scope.isActive = function(slide) {\n    return $scope.active === slide.slide.index;\n  };\n\n  $scope.isPrevDisabled = function() {\n    return $scope.active === 0 && $scope.noWrap();\n  };\n\n  $scope.isNextDisabled = function() {\n    return $scope.active === slides.length - 1 && $scope.noWrap();\n  };\n\n  $scope.pause = function() {\n    if (!$scope.noPause) {\n      isPlaying = false;\n      resetTimer();\n    }\n  };\n\n  $scope.play = function() {\n    if (!isPlaying) {\n      isPlaying = true;\n      restartTimer();\n    }\n  };\n\n  $scope.$on('$destroy', function() {\n    destroyed = true;\n    resetTimer();\n  });\n\n  $scope.$watch('noTransition', function(noTransition) {\n    $animate.enabled($element, !noTransition);\n  });\n\n  $scope.$watch('interval', restartTimer);\n\n  $scope.$watchCollection('slides', resetTransition);\n\n  $scope.$watch('active', function(index) {\n    if (angular.isNumber(index) && currentIndex !== index) {\n      for (var i = 0; i < slides.length; i++) {\n        if (slides[i].slide.index === index) {\n          index = i;\n          break;\n        }\n      }\n\n      var slide = slides[index];\n      if (slide) {\n        setActive(index);\n        self.select(slides[index]);\n        currentIndex = index;\n      }\n    }\n  });\n\n  function clearBufferedTransitions() {\n    while (bufferedTransitions.length) {\n      bufferedTransitions.shift();\n    }\n  }\n\n  function getSlideByIndex(index) {\n    for (var i = 0, l = slides.length; i < l; ++i) {\n      if (slides[i].index === index) {\n        return slides[i];\n      }\n    }\n  }\n\n  function setActive(index) {\n    for (var i = 0; i < slides.length; i++) {\n      slides[i].slide.active = i === index;\n    }\n  }\n\n  function goNext(slide, index, direction) {\n    if (destroyed) {\n      return;\n    }\n\n    angular.extend(slide, {direction: direction});\n    angular.extend(slides[currentIndex].slide || {}, {direction: direction});\n    if ($animate.enabled($element) && !$scope.$currentTransition &&\n      slides[index].element && self.slides.length > 1) {\n      slides[index].element.data(SLIDE_DIRECTION, slide.direction);\n      var currentIdx = self.getCurrentIndex();\n\n      if (angular.isNumber(currentIdx) && slides[currentIdx].element) {\n        slides[currentIdx].element.data(SLIDE_DIRECTION, slide.direction);\n      }\n\n      $scope.$currentTransition = true;\n      $animate.on('addClass', slides[index].element, function(element, phase) {\n        if (phase === 'close') {\n          $scope.$currentTransition = null;\n          $animate.off('addClass', element);\n          if (bufferedTransitions.length) {\n            var nextSlide = bufferedTransitions.pop().slide;\n            var nextIndex = nextSlide.index;\n            var nextDirection = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';\n            clearBufferedTransitions();\n\n            goNext(nextSlide, nextIndex, nextDirection);\n          }\n        }\n      });\n    }\n\n    $scope.active = slide.index;\n    currentIndex = slide.index;\n    setActive(index);\n\n    //every time you change slides, reset the timer\n    restartTimer();\n  }\n\n  function findSlideIndex(slide) {\n    for (var i = 0; i < slides.length; i++) {\n      if (slides[i].slide === slide) {\n        return i;\n      }\n    }\n  }\n\n  function resetTimer() {\n    if (currentInterval) {\n      $interval.cancel(currentInterval);\n      currentInterval = null;\n    }\n  }\n\n  function resetTransition(slides) {\n    if (!slides.length) {\n      $scope.$currentTransition = null;\n      clearBufferedTransitions();\n    }\n  }\n\n  function restartTimer() {\n    resetTimer();\n    var interval = +$scope.interval;\n    if (!isNaN(interval) && interval > 0) {\n      currentInterval = $interval(timerFn, interval);\n    }\n  }\n\n  function timerFn() {\n    var interval = +$scope.interval;\n    if (isPlaying && !isNaN(interval) && interval > 0 && slides.length) {\n      $scope.next();\n    } else {\n      $scope.pause();\n    }\n  }\n}])\n\n.directive('uibCarousel', function() {\n  return {\n    transclude: true,\n    replace: true,\n    controller: 'UibCarouselController',\n    controllerAs: 'carousel',\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/carousel/carousel.html';\n    },\n    scope: {\n      active: '=',\n      interval: '=',\n      noTransition: '=',\n      noPause: '=',\n      noWrap: '&'\n    }\n  };\n})\n\n.directive('uibSlide', function() {\n  return {\n    require: '^uibCarousel',\n    transclude: true,\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/carousel/slide.html';\n    },\n    scope: {\n      actual: '=?',\n      index: '=?'\n    },\n    link: function (scope, element, attrs, carouselCtrl) {\n      carouselCtrl.addSlide(scope, element);\n      //when the scope is destroyed then remove the slide from the current slides array\n      scope.$on('$destroy', function() {\n        carouselCtrl.removeSlide(scope);\n      });\n    }\n  };\n})\n\n.animation('.item', ['$animateCss',\nfunction($animateCss) {\n  var SLIDE_DIRECTION = 'uib-slideDirection';\n\n  function removeClass(element, className, callback) {\n    element.removeClass(className);\n    if (callback) {\n      callback();\n    }\n  }\n\n  return {\n    beforeAddClass: function(element, className, done) {\n      if (className === 'active') {\n        var stopped = false;\n        var direction = element.data(SLIDE_DIRECTION);\n        var directionClass = direction === 'next' ? 'left' : 'right';\n        var removeClassFn = removeClass.bind(this, element,\n          directionClass + ' ' + direction, done);\n        element.addClass(direction);\n\n        $animateCss(element, {addClass: directionClass})\n          .start()\n          .done(removeClassFn);\n\n        return function() {\n          stopped = true;\n        };\n      }\n      done();\n    },\n    beforeRemoveClass: function (element, className, done) {\n      if (className === 'active') {\n        var stopped = false;\n        var direction = element.data(SLIDE_DIRECTION);\n        var directionClass = direction === 'next' ? 'left' : 'right';\n        var removeClassFn = removeClass.bind(this, element, directionClass, done);\n\n        $animateCss(element, {addClass: directionClass})\n          .start()\n          .done(removeClassFn);\n\n        return function() {\n          stopped = true;\n        };\n      }\n      done();\n    }\n  };\n}]);\n\nangular.module('ui.bootstrap.dateparser', [])\n\n.service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', function($log, $locale, dateFilter, orderByFilter) {\n  // Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js\n  var SPECIAL_CHARACTERS_REGEXP = /[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g;\n\n  var localeId;\n  var formatCodeToRegex;\n\n  this.init = function() {\n    localeId = $locale.id;\n\n    this.parsers = {};\n    this.formatters = {};\n\n    formatCodeToRegex = [\n      {\n        key: 'yyyy',\n        regex: '\\\\d{4}',\n        apply: function(value) { this.year = +value; },\n        formatter: function(date) {\n          var _date = new Date();\n          _date.setFullYear(Math.abs(date.getFullYear()));\n          return dateFilter(_date, 'yyyy');\n        }\n      },\n      {\n        key: 'yy',\n        regex: '\\\\d{2}',\n        apply: function(value) { value = +value; this.year = value < 69 ? value + 2000 : value + 1900; },\n        formatter: function(date) {\n          var _date = new Date();\n          _date.setFullYear(Math.abs(date.getFullYear()));\n          return dateFilter(_date, 'yy');\n        }\n      },\n      {\n        key: 'y',\n        regex: '\\\\d{1,4}',\n        apply: function(value) { this.year = +value; },\n        formatter: function(date) {\n          var _date = new Date();\n          _date.setFullYear(Math.abs(date.getFullYear()));\n          return dateFilter(_date, 'y');\n        }\n      },\n      {\n        key: 'M!',\n        regex: '0?[1-9]|1[0-2]',\n        apply: function(value) { this.month = value - 1; },\n        formatter: function(date) {\n          var value = date.getMonth();\n          if (/^[0-9]$/.test(value)) {\n            return dateFilter(date, 'MM');\n          }\n\n          return dateFilter(date, 'M');\n        }\n      },\n      {\n        key: 'MMMM',\n        regex: $locale.DATETIME_FORMATS.MONTH.join('|'),\n        apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); },\n        formatter: function(date) { return dateFilter(date, 'MMMM'); }\n      },\n      {\n        key: 'MMM',\n        regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'),\n        apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); },\n        formatter: function(date) { return dateFilter(date, 'MMM'); }\n      },\n      {\n        key: 'MM',\n        regex: '0[1-9]|1[0-2]',\n        apply: function(value) { this.month = value - 1; },\n        formatter: function(date) { return dateFilter(date, 'MM'); }\n      },\n      {\n        key: 'M',\n        regex: '[1-9]|1[0-2]',\n        apply: function(value) { this.month = value - 1; },\n        formatter: function(date) { return dateFilter(date, 'M'); }\n      },\n      {\n        key: 'd!',\n        regex: '[0-2]?[0-9]{1}|3[0-1]{1}',\n        apply: function(value) { this.date = +value; },\n        formatter: function(date) {\n          var value = date.getDate();\n          if (/^[1-9]$/.test(value)) {\n            return dateFilter(date, 'dd');\n          }\n\n          return dateFilter(date, 'd');\n        }\n      },\n      {\n        key: 'dd',\n        regex: '[0-2][0-9]{1}|3[0-1]{1}',\n        apply: function(value) { this.date = +value; },\n        formatter: function(date) { return dateFilter(date, 'dd'); }\n      },\n      {\n        key: 'd',\n        regex: '[1-2]?[0-9]{1}|3[0-1]{1}',\n        apply: function(value) { this.date = +value; },\n        formatter: function(date) { return dateFilter(date, 'd'); }\n      },\n      {\n        key: 'EEEE',\n        regex: $locale.DATETIME_FORMATS.DAY.join('|'),\n        formatter: function(date) { return dateFilter(date, 'EEEE'); }\n      },\n      {\n        key: 'EEE',\n        regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|'),\n        formatter: function(date) { return dateFilter(date, 'EEE'); }\n      },\n      {\n        key: 'HH',\n        regex: '(?:0|1)[0-9]|2[0-3]',\n        apply: function(value) { this.hours = +value; },\n        formatter: function(date) { return dateFilter(date, 'HH'); }\n      },\n      {\n        key: 'hh',\n        regex: '0[0-9]|1[0-2]',\n        apply: function(value) { this.hours = +value; },\n        formatter: function(date) { return dateFilter(date, 'hh'); }\n      },\n      {\n        key: 'H',\n        regex: '1?[0-9]|2[0-3]',\n        apply: function(value) { this.hours = +value; },\n        formatter: function(date) { return dateFilter(date, 'H'); }\n      },\n      {\n        key: 'h',\n        regex: '[0-9]|1[0-2]',\n        apply: function(value) { this.hours = +value; },\n        formatter: function(date) { return dateFilter(date, 'h'); }\n      },\n      {\n        key: 'mm',\n        regex: '[0-5][0-9]',\n        apply: function(value) { this.minutes = +value; },\n        formatter: function(date) { return dateFilter(date, 'mm'); }\n      },\n      {\n        key: 'm',\n        regex: '[0-9]|[1-5][0-9]',\n        apply: function(value) { this.minutes = +value; },\n        formatter: function(date) { return dateFilter(date, 'm'); }\n      },\n      {\n        key: 'sss',\n        regex: '[0-9][0-9][0-9]',\n        apply: function(value) { this.milliseconds = +value; },\n        formatter: function(date) { return dateFilter(date, 'sss'); }\n      },\n      {\n        key: 'ss',\n        regex: '[0-5][0-9]',\n        apply: function(value) { this.seconds = +value; },\n        formatter: function(date) { return dateFilter(date, 'ss'); }\n      },\n      {\n        key: 's',\n        regex: '[0-9]|[1-5][0-9]',\n        apply: function(value) { this.seconds = +value; },\n        formatter: function(date) { return dateFilter(date, 's'); }\n      },\n      {\n        key: 'a',\n        regex: $locale.DATETIME_FORMATS.AMPMS.join('|'),\n        apply: function(value) {\n          if (this.hours === 12) {\n            this.hours = 0;\n          }\n\n          if (value === 'PM') {\n            this.hours += 12;\n          }\n        },\n        formatter: function(date) { return dateFilter(date, 'a'); }\n      },\n      {\n        key: 'Z',\n        regex: '[+-]\\\\d{4}',\n        apply: function(value) {\n          var matches = value.match(/([+-])(\\d{2})(\\d{2})/),\n            sign = matches[1],\n            hours = matches[2],\n            minutes = matches[3];\n          this.hours += toInt(sign + hours);\n          this.minutes += toInt(sign + minutes);\n        },\n        formatter: function(date) {\n          return dateFilter(date, 'Z');\n        }\n      },\n      {\n        key: 'ww',\n        regex: '[0-4][0-9]|5[0-3]',\n        formatter: function(date) { return dateFilter(date, 'ww'); }\n      },\n      {\n        key: 'w',\n        regex: '[0-9]|[1-4][0-9]|5[0-3]',\n        formatter: function(date) { return dateFilter(date, 'w'); }\n      },\n      {\n        key: 'GGGG',\n        regex: $locale.DATETIME_FORMATS.ERANAMES.join('|').replace(/\\s/g, '\\\\s'),\n        formatter: function(date) { return dateFilter(date, 'GGGG'); }\n      },\n      {\n        key: 'GGG',\n        regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n        formatter: function(date) { return dateFilter(date, 'GGG'); }\n      },\n      {\n        key: 'GG',\n        regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n        formatter: function(date) { return dateFilter(date, 'GG'); }\n      },\n      {\n        key: 'G',\n        regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n        formatter: function(date) { return dateFilter(date, 'G'); }\n      }\n    ];\n  };\n\n  this.init();\n\n  function createParser(format, func) {\n    var map = [], regex = format.split('');\n\n    // check for literal values\n    var quoteIndex = format.indexOf('\\'');\n    if (quoteIndex > -1) {\n      var inLiteral = false;\n      format = format.split('');\n      for (var i = quoteIndex; i < format.length; i++) {\n        if (inLiteral) {\n          if (format[i] === '\\'') {\n            if (i + 1 < format.length && format[i+1] === '\\'') { // escaped single quote\n              format[i+1] = '$';\n              regex[i+1] = '';\n            } else { // end of literal\n              regex[i] = '';\n              inLiteral = false;\n            }\n          }\n          format[i] = '$';\n        } else {\n          if (format[i] === '\\'') { // start of literal\n            format[i] = '$';\n            regex[i] = '';\n            inLiteral = true;\n          }\n        }\n      }\n\n      format = format.join('');\n    }\n\n    angular.forEach(formatCodeToRegex, function(data) {\n      var index = format.indexOf(data.key);\n\n      if (index > -1) {\n        format = format.split('');\n\n        regex[index] = '(' + data.regex + ')';\n        format[index] = '$'; // Custom symbol to define consumed part of format\n        for (var i = index + 1, n = index + data.key.length; i < n; i++) {\n          regex[i] = '';\n          format[i] = '$';\n        }\n        format = format.join('');\n\n        map.push({\n          index: index,\n          key: data.key,\n          apply: data[func],\n          matcher: data.regex\n        });\n      }\n    });\n\n    return {\n      regex: new RegExp('^' + regex.join('') + '$'),\n      map: orderByFilter(map, 'index')\n    };\n  }\n\n  this.filter = function(date, format) {\n    if (!angular.isDate(date) || isNaN(date) || !format) {\n      return '';\n    }\n\n    format = $locale.DATETIME_FORMATS[format] || format;\n\n    if ($locale.id !== localeId) {\n      this.init();\n    }\n\n    if (!this.formatters[format]) {\n      this.formatters[format] = createParser(format, 'formatter');\n    }\n\n    var parser = this.formatters[format],\n      map = parser.map;\n\n    var _format = format;\n\n    return map.reduce(function(str, mapper, i) {\n      var match = _format.match(new RegExp('(.*)' + mapper.key));\n      if (match && angular.isString(match[1])) {\n        str += match[1];\n        _format = _format.replace(match[1] + mapper.key, '');\n      }\n\n      var endStr = i === map.length - 1 ? _format : '';\n\n      if (mapper.apply) {\n        return str + mapper.apply.call(null, date) + endStr;\n      }\n\n      return str + endStr;\n    }, '');\n  };\n\n  this.parse = function(input, format, baseDate) {\n    if (!angular.isString(input) || !format) {\n      return input;\n    }\n\n    format = $locale.DATETIME_FORMATS[format] || format;\n    format = format.replace(SPECIAL_CHARACTERS_REGEXP, '\\\\$&');\n\n    if ($locale.id !== localeId) {\n      this.init();\n    }\n\n    if (!this.parsers[format]) {\n      this.parsers[format] = createParser(format, 'apply');\n    }\n\n    var parser = this.parsers[format],\n        regex = parser.regex,\n        map = parser.map,\n        results = input.match(regex),\n        tzOffset = false;\n    if (results && results.length) {\n      var fields, dt;\n      if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) {\n        fields = {\n          year: baseDate.getFullYear(),\n          month: baseDate.getMonth(),\n          date: baseDate.getDate(),\n          hours: baseDate.getHours(),\n          minutes: baseDate.getMinutes(),\n          seconds: baseDate.getSeconds(),\n          milliseconds: baseDate.getMilliseconds()\n        };\n      } else {\n        if (baseDate) {\n          $log.warn('dateparser:', 'baseDate is not a valid date');\n        }\n        fields = { year: 1900, month: 0, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };\n      }\n\n      for (var i = 1, n = results.length; i < n; i++) {\n        var mapper = map[i - 1];\n        if (mapper.matcher === 'Z') {\n          tzOffset = true;\n        }\n\n        if (mapper.apply) {\n          mapper.apply.call(fields, results[i]);\n        }\n      }\n\n      var datesetter = tzOffset ? Date.prototype.setUTCFullYear :\n        Date.prototype.setFullYear;\n      var timesetter = tzOffset ? Date.prototype.setUTCHours :\n        Date.prototype.setHours;\n\n      if (isValid(fields.year, fields.month, fields.date)) {\n        if (angular.isDate(baseDate) && !isNaN(baseDate.getTime()) && !tzOffset) {\n          dt = new Date(baseDate);\n          datesetter.call(dt, fields.year, fields.month, fields.date);\n          timesetter.call(dt, fields.hours, fields.minutes,\n            fields.seconds, fields.milliseconds);\n        } else {\n          dt = new Date(0);\n          datesetter.call(dt, fields.year, fields.month, fields.date);\n          timesetter.call(dt, fields.hours || 0, fields.minutes || 0,\n            fields.seconds || 0, fields.milliseconds || 0);\n        }\n      }\n\n      return dt;\n    }\n  };\n\n  // Check if date is valid for specific month (and year for February).\n  // Month: 0 = Jan, 1 = Feb, etc\n  function isValid(year, month, date) {\n    if (date < 1) {\n      return false;\n    }\n\n    if (month === 1 && date > 28) {\n      return date === 29 && (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0);\n    }\n\n    if (month === 3 || month === 5 || month === 8 || month === 10) {\n      return date < 31;\n    }\n\n    return true;\n  }\n\n  function toInt(str) {\n    return parseInt(str, 10);\n  }\n\n  this.toTimezone = toTimezone;\n  this.fromTimezone = fromTimezone;\n  this.timezoneToOffset = timezoneToOffset;\n  this.addDateMinutes = addDateMinutes;\n  this.convertTimezoneToLocal = convertTimezoneToLocal;\n\n  function toTimezone(date, timezone) {\n    return date && timezone ? convertTimezoneToLocal(date, timezone) : date;\n  }\n\n  function fromTimezone(date, timezone) {\n    return date && timezone ? convertTimezoneToLocal(date, timezone, true) : date;\n  }\n\n  //https://github.com/angular/angular.js/blob/4daafd3dbe6a80d578f5a31df1bb99c77559543e/src/Angular.js#L1207\n  function timezoneToOffset(timezone, fallback) {\n    var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;\n    return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;\n  }\n\n  function addDateMinutes(date, minutes) {\n    date = new Date(date.getTime());\n    date.setMinutes(date.getMinutes() + minutes);\n    return date;\n  }\n\n  function convertTimezoneToLocal(date, timezone, reverse) {\n    reverse = reverse ? -1 : 1;\n    var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset());\n    return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset()));\n  }\n}]);\n\n// Avoiding use of ng-class as it creates a lot of watchers when a class is to be applied to\n// at most one element.\nangular.module('ui.bootstrap.isClass', [])\n.directive('uibIsClass', [\n         '$animate',\nfunction ($animate) {\n  //                    11111111          22222222\n  var ON_REGEXP = /^\\s*([\\s\\S]+?)\\s+on\\s+([\\s\\S]+?)\\s*$/;\n  //                    11111111           22222222\n  var IS_REGEXP = /^\\s*([\\s\\S]+?)\\s+for\\s+([\\s\\S]+?)\\s*$/;\n\n  var dataPerTracked = {};\n\n  return {\n    restrict: 'A',\n    compile: function(tElement, tAttrs) {\n      var linkedScopes = [];\n      var instances = [];\n      var expToData = {};\n      var lastActivated = null;\n      var onExpMatches = tAttrs.uibIsClass.match(ON_REGEXP);\n      var onExp = onExpMatches[2];\n      var expsStr = onExpMatches[1];\n      var exps = expsStr.split(',');\n\n      return linkFn;\n\n      function linkFn(scope, element, attrs) {\n        linkedScopes.push(scope);\n        instances.push({\n          scope: scope,\n          element: element\n        });\n\n        exps.forEach(function(exp, k) {\n          addForExp(exp, scope);\n        });\n\n        scope.$on('$destroy', removeScope);\n      }\n\n      function addForExp(exp, scope) {\n        var matches = exp.match(IS_REGEXP);\n        var clazz = scope.$eval(matches[1]);\n        var compareWithExp = matches[2];\n        var data = expToData[exp];\n        if (!data) {\n          var watchFn = function(compareWithVal) {\n            var newActivated = null;\n            instances.some(function(instance) {\n              var thisVal = instance.scope.$eval(onExp);\n              if (thisVal === compareWithVal) {\n                newActivated = instance;\n                return true;\n              }\n            });\n            if (data.lastActivated !== newActivated) {\n              if (data.lastActivated) {\n                $animate.removeClass(data.lastActivated.element, clazz);\n              }\n              if (newActivated) {\n                $animate.addClass(newActivated.element, clazz);\n              }\n              data.lastActivated = newActivated;\n            }\n          };\n          expToData[exp] = data = {\n            lastActivated: null,\n            scope: scope,\n            watchFn: watchFn,\n            compareWithExp: compareWithExp,\n            watcher: scope.$watch(compareWithExp, watchFn)\n          };\n        }\n        data.watchFn(scope.$eval(compareWithExp));\n      }\n\n      function removeScope(e) {\n        var removedScope = e.targetScope;\n        var index = linkedScopes.indexOf(removedScope);\n        linkedScopes.splice(index, 1);\n        instances.splice(index, 1);\n        if (linkedScopes.length) {\n          var newWatchScope = linkedScopes[0];\n          angular.forEach(expToData, function(data) {\n            if (data.scope === removedScope) {\n              data.watcher = newWatchScope.$watch(data.compareWithExp, data.watchFn);\n              data.scope = newWatchScope;\n            }\n          });\n        } else {\n          expToData = {};\n        }\n      }\n    }\n  };\n}]);\nangular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.isClass'])\n\n.value('$datepickerSuppressError', false)\n\n.value('$datepickerLiteralWarning', true)\n\n.constant('uibDatepickerConfig', {\n  datepickerMode: 'day',\n  formatDay: 'dd',\n  formatMonth: 'MMMM',\n  formatYear: 'yyyy',\n  formatDayHeader: 'EEE',\n  formatDayTitle: 'MMMM yyyy',\n  formatMonthTitle: 'yyyy',\n  maxDate: null,\n  maxMode: 'year',\n  minDate: null,\n  minMode: 'day',\n  ngModelOptions: {},\n  shortcutPropagation: false,\n  showWeeks: true,\n  yearColumns: 5,\n  yearRows: 4\n})\n\n.controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',\n  function($scope, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {\n  var self = this,\n      ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;\n      ngModelOptions = {},\n      watchListeners = [],\n      optionsUsed = !!$attrs.datepickerOptions;\n\n  if (!$scope.datepickerOptions) {\n    $scope.datepickerOptions = {};\n  }\n\n  // Modes chain\n  this.modes = ['day', 'month', 'year'];\n\n  [\n    'customClass',\n    'dateDisabled',\n    'datepickerMode',\n    'formatDay',\n    'formatDayHeader',\n    'formatDayTitle',\n    'formatMonth',\n    'formatMonthTitle',\n    'formatYear',\n    'maxDate',\n    'maxMode',\n    'minDate',\n    'minMode',\n    'showWeeks',\n    'shortcutPropagation',\n    'startingDay',\n    'yearColumns',\n    'yearRows'\n  ].forEach(function(key) {\n    switch (key) {\n      case 'customClass':\n      case 'dateDisabled':\n        $scope[key] = $scope.datepickerOptions[key] || angular.noop;\n        break;\n      case 'datepickerMode':\n        $scope.datepickerMode = angular.isDefined($scope.datepickerOptions.datepickerMode) ?\n          $scope.datepickerOptions.datepickerMode : datepickerConfig.datepickerMode;\n        break;\n      case 'formatDay':\n      case 'formatDayHeader':\n      case 'formatDayTitle':\n      case 'formatMonth':\n      case 'formatMonthTitle':\n      case 'formatYear':\n        self[key] = angular.isDefined($scope.datepickerOptions[key]) ?\n          $interpolate($scope.datepickerOptions[key])($scope.$parent) :\n          datepickerConfig[key];\n        break;\n      case 'showWeeks':\n      case 'shortcutPropagation':\n      case 'yearColumns':\n      case 'yearRows':\n        self[key] = angular.isDefined($scope.datepickerOptions[key]) ?\n          $scope.datepickerOptions[key] : datepickerConfig[key];\n        break;\n      case 'startingDay':\n        if (angular.isDefined($scope.datepickerOptions.startingDay)) {\n          self.startingDay = $scope.datepickerOptions.startingDay;\n        } else if (angular.isNumber(datepickerConfig.startingDay)) {\n          self.startingDay = datepickerConfig.startingDay;\n        } else {\n          self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7;\n        }\n\n        break;\n      case 'maxDate':\n      case 'minDate':\n        $scope.$watch('datepickerOptions.' + key, function(value) {\n          if (value) {\n            if (angular.isDate(value)) {\n              self[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone);\n            } else {\n              if ($datepickerLiteralWarning) {\n                $log.warn('Literal date support has been deprecated, please switch to date object usage');\n              }\n\n              self[key] = new Date(dateFilter(value, 'medium'));\n            }\n          } else {\n            self[key] = datepickerConfig[key] ?\n              dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) :\n              null;\n          }\n\n          self.refreshView();\n        });\n\n        break;\n      case 'maxMode':\n      case 'minMode':\n        if ($scope.datepickerOptions[key]) {\n          $scope.$watch(function() { return $scope.datepickerOptions[key]; }, function(value) {\n            self[key] = $scope[key] = angular.isDefined(value) ? value : datepickerOptions[key];\n            if (key === 'minMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) < self.modes.indexOf(self[key]) ||\n              key === 'maxMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) > self.modes.indexOf(self[key])) {\n              $scope.datepickerMode = self[key];\n              $scope.datepickerOptions.datepickerMode = self[key];\n            }\n          });\n        } else {\n          self[key] = $scope[key] = datepickerConfig[key] || null;\n        }\n\n        break;\n    }\n  });\n\n  $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);\n\n  $scope.disabled = angular.isDefined($attrs.disabled) || false;\n  if (angular.isDefined($attrs.ngDisabled)) {\n    watchListeners.push($scope.$parent.$watch($attrs.ngDisabled, function(disabled) {\n      $scope.disabled = disabled;\n      self.refreshView();\n    }));\n  }\n\n  $scope.isActive = function(dateObject) {\n    if (self.compare(dateObject.date, self.activeDate) === 0) {\n      $scope.activeDateId = dateObject.uid;\n      return true;\n    }\n    return false;\n  };\n\n  this.init = function(ngModelCtrl_) {\n    ngModelCtrl = ngModelCtrl_;\n    ngModelOptions = ngModelCtrl_.$options || datepickerConfig.ngModelOptions;\n    if ($scope.datepickerOptions.initDate) {\n      self.activeDate = dateParser.fromTimezone($scope.datepickerOptions.initDate, ngModelOptions.timezone) || new Date();\n      $scope.$watch('datepickerOptions.initDate', function(initDate) {\n        if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {\n          self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone);\n          self.refreshView();\n        }\n      });\n    } else {\n      self.activeDate = new Date();\n    }\n\n    this.activeDate = ngModelCtrl.$modelValue ?\n      dateParser.fromTimezone(new Date(ngModelCtrl.$modelValue), ngModelOptions.timezone) :\n      dateParser.fromTimezone(new Date(), ngModelOptions.timezone);\n\n    ngModelCtrl.$render = function() {\n      self.render();\n    };\n  };\n\n  this.render = function() {\n    if (ngModelCtrl.$viewValue) {\n      var date = new Date(ngModelCtrl.$viewValue),\n          isValid = !isNaN(date);\n\n      if (isValid) {\n        this.activeDate = dateParser.fromTimezone(date, ngModelOptions.timezone);\n      } else if (!$datepickerSuppressError) {\n        $log.error('Datepicker directive: \"ng-model\" value must be a Date object');\n      }\n    }\n    this.refreshView();\n  };\n\n  this.refreshView = function() {\n    if (this.element) {\n      $scope.selectedDt = null;\n      this._refreshView();\n      if ($scope.activeDt) {\n        $scope.activeDateId = $scope.activeDt.uid;\n      }\n\n      var date = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;\n      date = dateParser.fromTimezone(date, ngModelOptions.timezone);\n      ngModelCtrl.$setValidity('dateDisabled', !date ||\n        this.element && !this.isDisabled(date));\n    }\n  };\n\n  this.createDateObject = function(date, format) {\n    var model = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;\n    model = dateParser.fromTimezone(model, ngModelOptions.timezone);\n    var today = new Date();\n    today = dateParser.fromTimezone(today, ngModelOptions.timezone);\n    var time = this.compare(date, today);\n    var dt = {\n      date: date,\n      label: dateParser.filter(date, format),\n      selected: model && this.compare(date, model) === 0,\n      disabled: this.isDisabled(date),\n      past: time < 0,\n      current: time === 0,\n      future: time > 0,\n      customClass: this.customClass(date) || null\n    };\n\n    if (model && this.compare(date, model) === 0) {\n      $scope.selectedDt = dt;\n    }\n\n    if (self.activeDate && this.compare(dt.date, self.activeDate) === 0) {\n      $scope.activeDt = dt;\n    }\n\n    return dt;\n  };\n\n  this.isDisabled = function(date) {\n    return $scope.disabled ||\n      this.minDate && this.compare(date, this.minDate) < 0 ||\n      this.maxDate && this.compare(date, this.maxDate) > 0 ||\n      $scope.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode});\n  };\n\n  this.customClass = function(date) {\n    return $scope.customClass({date: date, mode: $scope.datepickerMode});\n  };\n\n  // Split array into smaller arrays\n  this.split = function(arr, size) {\n    var arrays = [];\n    while (arr.length > 0) {\n      arrays.push(arr.splice(0, size));\n    }\n    return arrays;\n  };\n\n  $scope.select = function(date) {\n    if ($scope.datepickerMode === self.minMode) {\n      var dt = ngModelCtrl.$viewValue ? dateParser.fromTimezone(new Date(ngModelCtrl.$viewValue), ngModelOptions.timezone) : new Date(0, 0, 0, 0, 0, 0, 0);\n      dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n      dt = dateParser.toTimezone(dt, ngModelOptions.timezone);\n      ngModelCtrl.$setViewValue(dt);\n      ngModelCtrl.$render();\n    } else {\n      self.activeDate = date;\n      setMode(self.modes[self.modes.indexOf($scope.datepickerMode) - 1]);\n\n      $scope.$emit('uib:datepicker.mode');\n    }\n\n    $scope.$broadcast('uib:datepicker.focus');\n  };\n\n  $scope.move = function(direction) {\n    var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),\n        month = self.activeDate.getMonth() + direction * (self.step.months || 0);\n    self.activeDate.setFullYear(year, month, 1);\n    self.refreshView();\n  };\n\n  $scope.toggleMode = function(direction) {\n    direction = direction || 1;\n\n    if ($scope.datepickerMode === self.maxMode && direction === 1 ||\n      $scope.datepickerMode === self.minMode && direction === -1) {\n      return;\n    }\n\n    setMode(self.modes[self.modes.indexOf($scope.datepickerMode) + direction]);\n\n    $scope.$emit('uib:datepicker.mode');\n  };\n\n  // Key event mapper\n  $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };\n\n  var focusElement = function() {\n    self.element[0].focus();\n  };\n\n  // Listen for focus requests from popup directive\n  $scope.$on('uib:datepicker.focus', focusElement);\n\n  $scope.keydown = function(evt) {\n    var key = $scope.keys[evt.which];\n\n    if (!key || evt.shiftKey || evt.altKey || $scope.disabled) {\n      return;\n    }\n\n    evt.preventDefault();\n    if (!self.shortcutPropagation) {\n      evt.stopPropagation();\n    }\n\n    if (key === 'enter' || key === 'space') {\n      if (self.isDisabled(self.activeDate)) {\n        return; // do nothing\n      }\n      $scope.select(self.activeDate);\n    } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {\n      $scope.toggleMode(key === 'up' ? 1 : -1);\n    } else {\n      self.handleKeyDown(key, evt);\n      self.refreshView();\n    }\n  };\n\n  $scope.$on('$destroy', function() {\n    //Clear all watch listeners on destroy\n    while (watchListeners.length) {\n      watchListeners.shift()();\n    }\n  });\n\n  function setMode(mode) {\n    $scope.datepickerMode = mode;\n    $scope.datepickerOptions.datepickerMode = mode;\n  }\n}])\n\n.controller('UibDaypickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n  var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n  this.step = { months: 1 };\n  this.element = $element;\n  function getDaysInMonth(year, month) {\n    return month === 1 && year % 4 === 0 &&\n      (year % 100 !== 0 || year % 400 === 0) ? 29 : DAYS_IN_MONTH[month];\n  }\n\n  this.init = function(ctrl) {\n    angular.extend(ctrl, this);\n    scope.showWeeks = ctrl.showWeeks;\n    ctrl.refreshView();\n  };\n\n  this.getDates = function(startDate, n) {\n    var dates = new Array(n), current = new Date(startDate), i = 0, date;\n    while (i < n) {\n      date = new Date(current);\n      dates[i++] = date;\n      current.setDate(current.getDate() + 1);\n    }\n    return dates;\n  };\n\n  this._refreshView = function() {\n    var year = this.activeDate.getFullYear(),\n      month = this.activeDate.getMonth(),\n      firstDayOfMonth = new Date(this.activeDate);\n\n    firstDayOfMonth.setFullYear(year, month, 1);\n\n    var difference = this.startingDay - firstDayOfMonth.getDay(),\n      numDisplayedFromPreviousMonth = difference > 0 ?\n        7 - difference : - difference,\n      firstDate = new Date(firstDayOfMonth);\n\n    if (numDisplayedFromPreviousMonth > 0) {\n      firstDate.setDate(-numDisplayedFromPreviousMonth + 1);\n    }\n\n    // 42 is the number of days on a six-week calendar\n    var days = this.getDates(firstDate, 42);\n    for (var i = 0; i < 42; i ++) {\n      days[i] = angular.extend(this.createDateObject(days[i], this.formatDay), {\n        secondary: days[i].getMonth() !== month,\n        uid: scope.uniqueId + '-' + i\n      });\n    }\n\n    scope.labels = new Array(7);\n    for (var j = 0; j < 7; j++) {\n      scope.labels[j] = {\n        abbr: dateFilter(days[j].date, this.formatDayHeader),\n        full: dateFilter(days[j].date, 'EEEE')\n      };\n    }\n\n    scope.title = dateFilter(this.activeDate, this.formatDayTitle);\n    scope.rows = this.split(days, 7);\n\n    if (scope.showWeeks) {\n      scope.weekNumbers = [];\n      var thursdayIndex = (4 + 7 - this.startingDay) % 7,\n          numWeeks = scope.rows.length;\n      for (var curWeek = 0; curWeek < numWeeks; curWeek++) {\n        scope.weekNumbers.push(\n          getISO8601WeekNumber(scope.rows[curWeek][thursdayIndex].date));\n      }\n    }\n  };\n\n  this.compare = function(date1, date2) {\n    var _date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());\n    var _date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());\n    _date1.setFullYear(date1.getFullYear());\n    _date2.setFullYear(date2.getFullYear());\n    return _date1 - _date2;\n  };\n\n  function getISO8601WeekNumber(date) {\n    var checkDate = new Date(date);\n    checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday\n    var time = checkDate.getTime();\n    checkDate.setMonth(0); // Compare with Jan 1\n    checkDate.setDate(1);\n    return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;\n  }\n\n  this.handleKeyDown = function(key, evt) {\n    var date = this.activeDate.getDate();\n\n    if (key === 'left') {\n      date = date - 1;\n    } else if (key === 'up') {\n      date = date - 7;\n    } else if (key === 'right') {\n      date = date + 1;\n    } else if (key === 'down') {\n      date = date + 7;\n    } else if (key === 'pageup' || key === 'pagedown') {\n      var month = this.activeDate.getMonth() + (key === 'pageup' ? - 1 : 1);\n      this.activeDate.setMonth(month, 1);\n      date = Math.min(getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth()), date);\n    } else if (key === 'home') {\n      date = 1;\n    } else if (key === 'end') {\n      date = getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth());\n    }\n    this.activeDate.setDate(date);\n  };\n}])\n\n.controller('UibMonthpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n  this.step = { years: 1 };\n  this.element = $element;\n\n  this.init = function(ctrl) {\n    angular.extend(ctrl, this);\n    ctrl.refreshView();\n  };\n\n  this._refreshView = function() {\n    var months = new Array(12),\n        year = this.activeDate.getFullYear(),\n        date;\n\n    for (var i = 0; i < 12; i++) {\n      date = new Date(this.activeDate);\n      date.setFullYear(year, i, 1);\n      months[i] = angular.extend(this.createDateObject(date, this.formatMonth), {\n        uid: scope.uniqueId + '-' + i\n      });\n    }\n\n    scope.title = dateFilter(this.activeDate, this.formatMonthTitle);\n    scope.rows = this.split(months, 3);\n  };\n\n  this.compare = function(date1, date2) {\n    var _date1 = new Date(date1.getFullYear(), date1.getMonth());\n    var _date2 = new Date(date2.getFullYear(), date2.getMonth());\n    _date1.setFullYear(date1.getFullYear());\n    _date2.setFullYear(date2.getFullYear());\n    return _date1 - _date2;\n  };\n\n  this.handleKeyDown = function(key, evt) {\n    var date = this.activeDate.getMonth();\n\n    if (key === 'left') {\n      date = date - 1;\n    } else if (key === 'up') {\n      date = date - 3;\n    } else if (key === 'right') {\n      date = date + 1;\n    } else if (key === 'down') {\n      date = date + 3;\n    } else if (key === 'pageup' || key === 'pagedown') {\n      var year = this.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);\n      this.activeDate.setFullYear(year);\n    } else if (key === 'home') {\n      date = 0;\n    } else if (key === 'end') {\n      date = 11;\n    }\n    this.activeDate.setMonth(date);\n  };\n}])\n\n.controller('UibYearpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n  var columns, range;\n  this.element = $element;\n\n  function getStartingYear(year) {\n    return parseInt((year - 1) / range, 10) * range + 1;\n  }\n\n  this.yearpickerInit = function() {\n    columns = this.yearColumns;\n    range = this.yearRows * columns;\n    this.step = { years: range };\n  };\n\n  this._refreshView = function() {\n    var years = new Array(range), date;\n\n    for (var i = 0, start = getStartingYear(this.activeDate.getFullYear()); i < range; i++) {\n      date = new Date(this.activeDate);\n      date.setFullYear(start + i, 0, 1);\n      years[i] = angular.extend(this.createDateObject(date, this.formatYear), {\n        uid: scope.uniqueId + '-' + i\n      });\n    }\n\n    scope.title = [years[0].label, years[range - 1].label].join(' - ');\n    scope.rows = this.split(years, columns);\n    scope.columns = columns;\n  };\n\n  this.compare = function(date1, date2) {\n    return date1.getFullYear() - date2.getFullYear();\n  };\n\n  this.handleKeyDown = function(key, evt) {\n    var date = this.activeDate.getFullYear();\n\n    if (key === 'left') {\n      date = date - 1;\n    } else if (key === 'up') {\n      date = date - columns;\n    } else if (key === 'right') {\n      date = date + 1;\n    } else if (key === 'down') {\n      date = date + columns;\n    } else if (key === 'pageup' || key === 'pagedown') {\n      date += (key === 'pageup' ? - 1 : 1) * range;\n    } else if (key === 'home') {\n      date = getStartingYear(this.activeDate.getFullYear());\n    } else if (key === 'end') {\n      date = getStartingYear(this.activeDate.getFullYear()) + range - 1;\n    }\n    this.activeDate.setFullYear(date);\n  };\n}])\n\n.directive('uibDatepicker', function() {\n  return {\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/datepicker/datepicker.html';\n    },\n    scope: {\n      datepickerOptions: '=?'\n    },\n    require: ['uibDatepicker', '^ngModel'],\n    controller: 'UibDatepickerController',\n    controllerAs: 'datepicker',\n    link: function(scope, element, attrs, ctrls) {\n      var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n      datepickerCtrl.init(ngModelCtrl);\n    }\n  };\n})\n\n.directive('uibDaypicker', function() {\n  return {\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/datepicker/day.html';\n    },\n    require: ['^uibDatepicker', 'uibDaypicker'],\n    controller: 'UibDaypickerController',\n    link: function(scope, element, attrs, ctrls) {\n      var datepickerCtrl = ctrls[0],\n        daypickerCtrl = ctrls[1];\n\n      daypickerCtrl.init(datepickerCtrl);\n    }\n  };\n})\n\n.directive('uibMonthpicker', function() {\n  return {\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/datepicker/month.html';\n    },\n    require: ['^uibDatepicker', 'uibMonthpicker'],\n    controller: 'UibMonthpickerController',\n    link: function(scope, element, attrs, ctrls) {\n      var datepickerCtrl = ctrls[0],\n        monthpickerCtrl = ctrls[1];\n\n      monthpickerCtrl.init(datepickerCtrl);\n    }\n  };\n})\n\n.directive('uibYearpicker', function() {\n  return {\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/datepicker/year.html';\n    },\n    require: ['^uibDatepicker', 'uibYearpicker'],\n    controller: 'UibYearpickerController',\n    link: function(scope, element, attrs, ctrls) {\n      var ctrl = ctrls[0];\n      angular.extend(ctrl, ctrls[1]);\n      ctrl.yearpickerInit();\n\n      ctrl.refreshView();\n    }\n  };\n});\n\nangular.module('ui.bootstrap.position', [])\n\n/**\n * A set of utility methods for working with the DOM.\n * It is meant to be used where we need to absolute-position elements in\n * relation to another element (this is the case for tooltips, popovers,\n * typeahead suggestions etc.).\n */\n  .factory('$uibPosition', ['$document', '$window', function($document, $window) {\n    /**\n     * Used by scrollbarWidth() function to cache scrollbar's width.\n     * Do not access this variable directly, use scrollbarWidth() instead.\n     */\n    var SCROLLBAR_WIDTH;\n    /**\n     * scrollbar on body and html element in IE and Edge overlay\n     * content and should be considered 0 width.\n     */\n    var BODY_SCROLLBAR_WIDTH;\n    var OVERFLOW_REGEX = {\n      normal: /(auto|scroll)/,\n      hidden: /(auto|scroll|hidden)/\n    };\n    var PLACEMENT_REGEX = {\n      auto: /\\s?auto?\\s?/i,\n      primary: /^(top|bottom|left|right)$/,\n      secondary: /^(top|bottom|left|right|center)$/,\n      vertical: /^(top|bottom)$/\n    };\n    var BODY_REGEX = /(HTML|BODY)/;\n\n    return {\n\n      /**\n       * Provides a raw DOM element from a jQuery/jQLite element.\n       *\n       * @param {element} elem - The element to convert.\n       *\n       * @returns {element} A HTML element.\n       */\n      getRawNode: function(elem) {\n        return elem.nodeName ? elem : elem[0] || elem;\n      },\n\n      /**\n       * Provides a parsed number for a style property.  Strips\n       * units and casts invalid numbers to 0.\n       *\n       * @param {string} value - The style value to parse.\n       *\n       * @returns {number} A valid number.\n       */\n      parseStyle: function(value) {\n        value = parseFloat(value);\n        return isFinite(value) ? value : 0;\n      },\n\n      /**\n       * Provides the closest positioned ancestor.\n       *\n       * @param {element} element - The element to get the offest parent for.\n       *\n       * @returns {element} The closest positioned ancestor.\n       */\n      offsetParent: function(elem) {\n        elem = this.getRawNode(elem);\n\n        var offsetParent = elem.offsetParent || $document[0].documentElement;\n\n        function isStaticPositioned(el) {\n          return ($window.getComputedStyle(el).position || 'static') === 'static';\n        }\n\n        while (offsetParent && offsetParent !== $document[0].documentElement && isStaticPositioned(offsetParent)) {\n          offsetParent = offsetParent.offsetParent;\n        }\n\n        return offsetParent || $document[0].documentElement;\n      },\n\n      /**\n       * Provides the scrollbar width, concept from TWBS measureScrollbar()\n       * function in https://github.com/twbs/bootstrap/blob/master/js/modal.js\n       * In IE and Edge, scollbar on body and html element overlay and should\n       * return a width of 0.\n       *\n       * @returns {number} The width of the browser scollbar.\n       */\n      scrollbarWidth: function(isBody) {\n        if (isBody) {\n          if (angular.isUndefined(BODY_SCROLLBAR_WIDTH)) {\n            var bodyElem = $document.find('body');\n            bodyElem.addClass('uib-position-body-scrollbar-measure');\n            BODY_SCROLLBAR_WIDTH = $window.innerWidth - bodyElem[0].clientWidth;\n            BODY_SCROLLBAR_WIDTH = isFinite(BODY_SCROLLBAR_WIDTH) ? BODY_SCROLLBAR_WIDTH : 0;\n            bodyElem.removeClass('uib-position-body-scrollbar-measure');\n          }\n          return BODY_SCROLLBAR_WIDTH;\n        }\n\n        if (angular.isUndefined(SCROLLBAR_WIDTH)) {\n          var scrollElem = angular.element('<div class=\"uib-position-scrollbar-measure\"></div>');\n          $document.find('body').append(scrollElem);\n          SCROLLBAR_WIDTH = scrollElem[0].offsetWidth - scrollElem[0].clientWidth;\n          SCROLLBAR_WIDTH = isFinite(SCROLLBAR_WIDTH) ? SCROLLBAR_WIDTH : 0;\n          scrollElem.remove();\n        }\n\n        return SCROLLBAR_WIDTH;\n      },\n\n      /**\n       * Provides the padding required on an element to replace the scrollbar.\n       *\n       * @returns {object} An object with the following properties:\n       *   <ul>\n       *     <li>**scrollbarWidth**: the width of the scrollbar</li>\n       *     <li>**widthOverflow**: whether the the width is overflowing</li>\n       *     <li>**right**: the amount of right padding on the element needed to replace the scrollbar</li>\n       *     <li>**rightOriginal**: the amount of right padding currently on the element</li>\n       *     <li>**heightOverflow**: whether the the height is overflowing</li>\n       *     <li>**bottom**: the amount of bottom padding on the element needed to replace the scrollbar</li>\n       *     <li>**bottomOriginal**: the amount of bottom padding currently on the element</li>\n       *   </ul>\n       */\n      scrollbarPadding: function(elem) {\n        elem = this.getRawNode(elem);\n\n        var elemStyle = $window.getComputedStyle(elem);\n        var paddingRight = this.parseStyle(elemStyle.paddingRight);\n        var paddingBottom = this.parseStyle(elemStyle.paddingBottom);\n        var scrollParent = this.scrollParent(elem, false, true);\n        var scrollbarWidth = this.scrollbarWidth(scrollParent, BODY_REGEX.test(scrollParent.tagName));\n\n        return {\n          scrollbarWidth: scrollbarWidth,\n          widthOverflow: scrollParent.scrollWidth > scrollParent.clientWidth,\n          right: paddingRight + scrollbarWidth,\n          originalRight: paddingRight,\n          heightOverflow: scrollParent.scrollHeight > scrollParent.clientHeight,\n          bottom: paddingBottom + scrollbarWidth,\n          originalBottom: paddingBottom\n         };\n      },\n\n      /**\n       * Checks to see if the element is scrollable.\n       *\n       * @param {element} elem - The element to check.\n       * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,\n       *   default is false.\n       *\n       * @returns {boolean} Whether the element is scrollable.\n       */\n      isScrollable: function(elem, includeHidden) {\n        elem = this.getRawNode(elem);\n\n        var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;\n        var elemStyle = $window.getComputedStyle(elem);\n        return overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX);\n      },\n\n      /**\n       * Provides the closest scrollable ancestor.\n       * A port of the jQuery UI scrollParent method:\n       * https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js\n       *\n       * @param {element} elem - The element to find the scroll parent of.\n       * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,\n       *   default is false.\n       * @param {boolean=} [includeSelf=false] - Should the element being passed be\n       * included in the scrollable llokup.\n       *\n       * @returns {element} A HTML element.\n       */\n      scrollParent: function(elem, includeHidden, includeSelf) {\n        elem = this.getRawNode(elem);\n\n        var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;\n        var documentEl = $document[0].documentElement;\n        var elemStyle = $window.getComputedStyle(elem);\n        if (includeSelf && overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX)) {\n          return elem;\n        }\n        var excludeStatic = elemStyle.position === 'absolute';\n        var scrollParent = elem.parentElement || documentEl;\n\n        if (scrollParent === documentEl || elemStyle.position === 'fixed') {\n          return documentEl;\n        }\n\n        while (scrollParent.parentElement && scrollParent !== documentEl) {\n          var spStyle = $window.getComputedStyle(scrollParent);\n          if (excludeStatic && spStyle.position !== 'static') {\n            excludeStatic = false;\n          }\n\n          if (!excludeStatic && overflowRegex.test(spStyle.overflow + spStyle.overflowY + spStyle.overflowX)) {\n            break;\n          }\n          scrollParent = scrollParent.parentElement;\n        }\n\n        return scrollParent;\n      },\n\n      /**\n       * Provides read-only equivalent of jQuery's position function:\n       * http://api.jquery.com/position/ - distance to closest positioned\n       * ancestor.  Does not account for margins by default like jQuery position.\n       *\n       * @param {element} elem - The element to caclulate the position on.\n       * @param {boolean=} [includeMargins=false] - Should margins be accounted\n       * for, default is false.\n       *\n       * @returns {object} An object with the following properties:\n       *   <ul>\n       *     <li>**width**: the width of the element</li>\n       *     <li>**height**: the height of the element</li>\n       *     <li>**top**: distance to top edge of offset parent</li>\n       *     <li>**left**: distance to left edge of offset parent</li>\n       *   </ul>\n       */\n      position: function(elem, includeMagins) {\n        elem = this.getRawNode(elem);\n\n        var elemOffset = this.offset(elem);\n        if (includeMagins) {\n          var elemStyle = $window.getComputedStyle(elem);\n          elemOffset.top -= this.parseStyle(elemStyle.marginTop);\n          elemOffset.left -= this.parseStyle(elemStyle.marginLeft);\n        }\n        var parent = this.offsetParent(elem);\n        var parentOffset = {top: 0, left: 0};\n\n        if (parent !== $document[0].documentElement) {\n          parentOffset = this.offset(parent);\n          parentOffset.top += parent.clientTop - parent.scrollTop;\n          parentOffset.left += parent.clientLeft - parent.scrollLeft;\n        }\n\n        return {\n          width: Math.round(angular.isNumber(elemOffset.width) ? elemOffset.width : elem.offsetWidth),\n          height: Math.round(angular.isNumber(elemOffset.height) ? elemOffset.height : elem.offsetHeight),\n          top: Math.round(elemOffset.top - parentOffset.top),\n          left: Math.round(elemOffset.left - parentOffset.left)\n        };\n      },\n\n      /**\n       * Provides read-only equivalent of jQuery's offset function:\n       * http://api.jquery.com/offset/ - distance to viewport.  Does\n       * not account for borders, margins, or padding on the body\n       * element.\n       *\n       * @param {element} elem - The element to calculate the offset on.\n       *\n       * @returns {object} An object with the following properties:\n       *   <ul>\n       *     <li>**width**: the width of the element</li>\n       *     <li>**height**: the height of the element</li>\n       *     <li>**top**: distance to top edge of viewport</li>\n       *     <li>**right**: distance to bottom edge of viewport</li>\n       *   </ul>\n       */\n      offset: function(elem) {\n        elem = this.getRawNode(elem);\n\n        var elemBCR = elem.getBoundingClientRect();\n        return {\n          width: Math.round(angular.isNumber(elemBCR.width) ? elemBCR.width : elem.offsetWidth),\n          height: Math.round(angular.isNumber(elemBCR.height) ? elemBCR.height : elem.offsetHeight),\n          top: Math.round(elemBCR.top + ($window.pageYOffset || $document[0].documentElement.scrollTop)),\n          left: Math.round(elemBCR.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft))\n        };\n      },\n\n      /**\n       * Provides offset distance to the closest scrollable ancestor\n       * or viewport.  Accounts for border and scrollbar width.\n       *\n       * Right and bottom dimensions represent the distance to the\n       * respective edge of the viewport element.  If the element\n       * edge extends beyond the viewport, a negative value will be\n       * reported.\n       *\n       * @param {element} elem - The element to get the viewport offset for.\n       * @param {boolean=} [useDocument=false] - Should the viewport be the document element instead\n       * of the first scrollable element, default is false.\n       * @param {boolean=} [includePadding=true] - Should the padding on the offset parent element\n       * be accounted for, default is true.\n       *\n       * @returns {object} An object with the following properties:\n       *   <ul>\n       *     <li>**top**: distance to the top content edge of viewport element</li>\n       *     <li>**bottom**: distance to the bottom content edge of viewport element</li>\n       *     <li>**left**: distance to the left content edge of viewport element</li>\n       *     <li>**right**: distance to the right content edge of viewport element</li>\n       *   </ul>\n       */\n      viewportOffset: function(elem, useDocument, includePadding) {\n        elem = this.getRawNode(elem);\n        includePadding = includePadding !== false ? true : false;\n\n        var elemBCR = elem.getBoundingClientRect();\n        var offsetBCR = {top: 0, left: 0, bottom: 0, right: 0};\n\n        var offsetParent = useDocument ? $document[0].documentElement : this.scrollParent(elem);\n        var offsetParentBCR = offsetParent.getBoundingClientRect();\n\n        offsetBCR.top = offsetParentBCR.top + offsetParent.clientTop;\n        offsetBCR.left = offsetParentBCR.left + offsetParent.clientLeft;\n        if (offsetParent === $document[0].documentElement) {\n          offsetBCR.top += $window.pageYOffset;\n          offsetBCR.left += $window.pageXOffset;\n        }\n        offsetBCR.bottom = offsetBCR.top + offsetParent.clientHeight;\n        offsetBCR.right = offsetBCR.left + offsetParent.clientWidth;\n\n        if (includePadding) {\n          var offsetParentStyle = $window.getComputedStyle(offsetParent);\n          offsetBCR.top += this.parseStyle(offsetParentStyle.paddingTop);\n          offsetBCR.bottom -= this.parseStyle(offsetParentStyle.paddingBottom);\n          offsetBCR.left += this.parseStyle(offsetParentStyle.paddingLeft);\n          offsetBCR.right -= this.parseStyle(offsetParentStyle.paddingRight);\n        }\n\n        return {\n          top: Math.round(elemBCR.top - offsetBCR.top),\n          bottom: Math.round(offsetBCR.bottom - elemBCR.bottom),\n          left: Math.round(elemBCR.left - offsetBCR.left),\n          right: Math.round(offsetBCR.right - elemBCR.right)\n        };\n      },\n\n      /**\n       * Provides an array of placement values parsed from a placement string.\n       * Along with the 'auto' indicator, supported placement strings are:\n       *   <ul>\n       *     <li>top: element on top, horizontally centered on host element.</li>\n       *     <li>top-left: element on top, left edge aligned with host element left edge.</li>\n       *     <li>top-right: element on top, lerightft edge aligned with host element right edge.</li>\n       *     <li>bottom: element on bottom, horizontally centered on host element.</li>\n       *     <li>bottom-left: element on bottom, left edge aligned with host element left edge.</li>\n       *     <li>bottom-right: element on bottom, right edge aligned with host element right edge.</li>\n       *     <li>left: element on left, vertically centered on host element.</li>\n       *     <li>left-top: element on left, top edge aligned with host element top edge.</li>\n       *     <li>left-bottom: element on left, bottom edge aligned with host element bottom edge.</li>\n       *     <li>right: element on right, vertically centered on host element.</li>\n       *     <li>right-top: element on right, top edge aligned with host element top edge.</li>\n       *     <li>right-bottom: element on right, bottom edge aligned with host element bottom edge.</li>\n       *   </ul>\n       * A placement string with an 'auto' indicator is expected to be\n       * space separated from the placement, i.e: 'auto bottom-left'  If\n       * the primary and secondary placement values do not match 'top,\n       * bottom, left, right' then 'top' will be the primary placement and\n       * 'center' will be the secondary placement.  If 'auto' is passed, true\n       * will be returned as the 3rd value of the array.\n       *\n       * @param {string} placement - The placement string to parse.\n       *\n       * @returns {array} An array with the following values\n       * <ul>\n       *   <li>**[0]**: The primary placement.</li>\n       *   <li>**[1]**: The secondary placement.</li>\n       *   <li>**[2]**: If auto is passed: true, else undefined.</li>\n       * </ul>\n       */\n      parsePlacement: function(placement) {\n        var autoPlace = PLACEMENT_REGEX.auto.test(placement);\n        if (autoPlace) {\n          placement = placement.replace(PLACEMENT_REGEX.auto, '');\n        }\n\n        placement = placement.split('-');\n\n        placement[0] = placement[0] || 'top';\n        if (!PLACEMENT_REGEX.primary.test(placement[0])) {\n          placement[0] = 'top';\n        }\n\n        placement[1] = placement[1] || 'center';\n        if (!PLACEMENT_REGEX.secondary.test(placement[1])) {\n          placement[1] = 'center';\n        }\n\n        if (autoPlace) {\n          placement[2] = true;\n        } else {\n          placement[2] = false;\n        }\n\n        return placement;\n      },\n\n      /**\n       * Provides coordinates for an element to be positioned relative to\n       * another element.  Passing 'auto' as part of the placement parameter\n       * will enable smart placement - where the element fits. i.e:\n       * 'auto left-top' will check to see if there is enough space to the left\n       * of the hostElem to fit the targetElem, if not place right (same for secondary\n       * top placement).  Available space is calculated using the viewportOffset\n       * function.\n       *\n       * @param {element} hostElem - The element to position against.\n       * @param {element} targetElem - The element to position.\n       * @param {string=} [placement=top] - The placement for the targetElem,\n       *   default is 'top'. 'center' is assumed as secondary placement for\n       *   'top', 'left', 'right', and 'bottom' placements.  Available placements are:\n       *   <ul>\n       *     <li>top</li>\n       *     <li>top-right</li>\n       *     <li>top-left</li>\n       *     <li>bottom</li>\n       *     <li>bottom-left</li>\n       *     <li>bottom-right</li>\n       *     <li>left</li>\n       *     <li>left-top</li>\n       *     <li>left-bottom</li>\n       *     <li>right</li>\n       *     <li>right-top</li>\n       *     <li>right-bottom</li>\n       *   </ul>\n       * @param {boolean=} [appendToBody=false] - Should the top and left values returned\n       *   be calculated from the body element, default is false.\n       *\n       * @returns {object} An object with the following properties:\n       *   <ul>\n       *     <li>**top**: Value for targetElem top.</li>\n       *     <li>**left**: Value for targetElem left.</li>\n       *     <li>**placement**: The resolved placement.</li>\n       *   </ul>\n       */\n      positionElements: function(hostElem, targetElem, placement, appendToBody) {\n        hostElem = this.getRawNode(hostElem);\n        targetElem = this.getRawNode(targetElem);\n\n        // need to read from prop to support tests.\n        var targetWidth = angular.isDefined(targetElem.offsetWidth) ? targetElem.offsetWidth : targetElem.prop('offsetWidth');\n        var targetHeight = angular.isDefined(targetElem.offsetHeight) ? targetElem.offsetHeight : targetElem.prop('offsetHeight');\n\n        placement = this.parsePlacement(placement);\n\n        var hostElemPos = appendToBody ? this.offset(hostElem) : this.position(hostElem);\n        var targetElemPos = {top: 0, left: 0, placement: ''};\n\n        if (placement[2]) {\n          var viewportOffset = this.viewportOffset(hostElem, appendToBody);\n\n          var targetElemStyle = $window.getComputedStyle(targetElem);\n          var adjustedSize = {\n            width: targetWidth + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginLeft) + this.parseStyle(targetElemStyle.marginRight))),\n            height: targetHeight + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginTop) + this.parseStyle(targetElemStyle.marginBottom)))\n          };\n\n          placement[0] = placement[0] === 'top' && adjustedSize.height > viewportOffset.top && adjustedSize.height <= viewportOffset.bottom ? 'bottom' :\n                         placement[0] === 'bottom' && adjustedSize.height > viewportOffset.bottom && adjustedSize.height <= viewportOffset.top ? 'top' :\n                         placement[0] === 'left' && adjustedSize.width > viewportOffset.left && adjustedSize.width <= viewportOffset.right ? 'right' :\n                         placement[0] === 'right' && adjustedSize.width > viewportOffset.right && adjustedSize.width <= viewportOffset.left ? 'left' :\n                         placement[0];\n\n          placement[1] = placement[1] === 'top' && adjustedSize.height - hostElemPos.height > viewportOffset.bottom && adjustedSize.height - hostElemPos.height <= viewportOffset.top ? 'bottom' :\n                         placement[1] === 'bottom' && adjustedSize.height - hostElemPos.height > viewportOffset.top && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom ? 'top' :\n                         placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :\n                         placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :\n                         placement[1];\n\n          if (placement[1] === 'center') {\n            if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n              var xOverflow = hostElemPos.width / 2 - targetWidth / 2;\n              if (viewportOffset.left + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.right) {\n                placement[1] = 'left';\n              } else if (viewportOffset.right + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.left) {\n                placement[1] = 'right';\n              }\n            } else {\n              var yOverflow = hostElemPos.height / 2 - adjustedSize.height / 2;\n              if (viewportOffset.top + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom) {\n                placement[1] = 'top';\n              } else if (viewportOffset.bottom + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.top) {\n                placement[1] = 'bottom';\n              }\n            }\n          }\n        }\n\n        switch (placement[0]) {\n          case 'top':\n            targetElemPos.top = hostElemPos.top - targetHeight;\n            break;\n          case 'bottom':\n            targetElemPos.top = hostElemPos.top + hostElemPos.height;\n            break;\n          case 'left':\n            targetElemPos.left = hostElemPos.left - targetWidth;\n            break;\n          case 'right':\n            targetElemPos.left = hostElemPos.left + hostElemPos.width;\n            break;\n        }\n\n        switch (placement[1]) {\n          case 'top':\n            targetElemPos.top = hostElemPos.top;\n            break;\n          case 'bottom':\n            targetElemPos.top = hostElemPos.top + hostElemPos.height - targetHeight;\n            break;\n          case 'left':\n            targetElemPos.left = hostElemPos.left;\n            break;\n          case 'right':\n            targetElemPos.left = hostElemPos.left + hostElemPos.width - targetWidth;\n            break;\n          case 'center':\n            if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n              targetElemPos.left = hostElemPos.left + hostElemPos.width / 2 - targetWidth / 2;\n            } else {\n              targetElemPos.top = hostElemPos.top + hostElemPos.height / 2 - targetHeight / 2;\n            }\n            break;\n        }\n\n        targetElemPos.top = Math.round(targetElemPos.top);\n        targetElemPos.left = Math.round(targetElemPos.left);\n        targetElemPos.placement = placement[1] === 'center' ? placement[0] : placement[0] + '-' + placement[1];\n\n        return targetElemPos;\n      },\n\n      /**\n      * Provides a way for positioning tooltip & dropdown\n      * arrows when using placement options beyond the standard\n      * left, right, top, or bottom.\n      *\n      * @param {element} elem - The tooltip/dropdown element.\n      * @param {string} placement - The placement for the elem.\n      */\n      positionArrow: function(elem, placement) {\n        elem = this.getRawNode(elem);\n\n        var innerElem = elem.querySelector('.tooltip-inner, .popover-inner');\n        if (!innerElem) {\n          return;\n        }\n\n        var isTooltip = angular.element(innerElem).hasClass('tooltip-inner');\n\n        var arrowElem = isTooltip ? elem.querySelector('.tooltip-arrow') : elem.querySelector('.arrow');\n        if (!arrowElem) {\n          return;\n        }\n\n        var arrowCss = {\n          top: '',\n          bottom: '',\n          left: '',\n          right: ''\n        };\n\n        placement = this.parsePlacement(placement);\n        if (placement[1] === 'center') {\n          // no adjustment necessary - just reset styles\n          angular.element(arrowElem).css(arrowCss);\n          return;\n        }\n\n        var borderProp = 'border-' + placement[0] + '-width';\n        var borderWidth = $window.getComputedStyle(arrowElem)[borderProp];\n\n        var borderRadiusProp = 'border-';\n        if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n          borderRadiusProp += placement[0] + '-' + placement[1];\n        } else {\n          borderRadiusProp += placement[1] + '-' + placement[0];\n        }\n        borderRadiusProp += '-radius';\n        var borderRadius = $window.getComputedStyle(isTooltip ? innerElem : elem)[borderRadiusProp];\n\n        switch (placement[0]) {\n          case 'top':\n            arrowCss.bottom = isTooltip ? '0' : '-' + borderWidth;\n            break;\n          case 'bottom':\n            arrowCss.top = isTooltip ? '0' : '-' + borderWidth;\n            break;\n          case 'left':\n            arrowCss.right = isTooltip ? '0' : '-' + borderWidth;\n            break;\n          case 'right':\n            arrowCss.left = isTooltip ? '0' : '-' + borderWidth;\n            break;\n        }\n\n        arrowCss[placement[1]] = borderRadius;\n\n        angular.element(arrowElem).css(arrowCss);\n      }\n    };\n  }]);\n\nangular.module('ui.bootstrap.datepickerPopup', ['ui.bootstrap.datepicker', 'ui.bootstrap.position'])\n\n.value('$datepickerPopupLiteralWarning', true)\n\n.constant('uibDatepickerPopupConfig', {\n  altInputFormats: [],\n  appendToBody: false,\n  clearText: 'Clear',\n  closeOnDateSelection: true,\n  closeText: 'Done',\n  currentText: 'Today',\n  datepickerPopup: 'yyyy-MM-dd',\n  datepickerPopupTemplateUrl: 'uib/template/datepickerPopup/popup.html',\n  datepickerTemplateUrl: 'uib/template/datepicker/datepicker.html',\n  html5Types: {\n    date: 'yyyy-MM-dd',\n    'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',\n    'month': 'yyyy-MM'\n  },\n  onOpenFocus: true,\n  showButtonBar: true,\n  placement: 'auto bottom-left'\n})\n\n.controller('UibDatepickerPopupController', ['$scope', '$element', '$attrs', '$compile', '$log', '$parse', '$window', '$document', '$rootScope', '$uibPosition', 'dateFilter', 'uibDateParser', 'uibDatepickerPopupConfig', '$timeout', 'uibDatepickerConfig', '$datepickerPopupLiteralWarning',\nfunction($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $rootScope, $position, dateFilter, dateParser, datepickerPopupConfig, $timeout, datepickerConfig, $datepickerPopupLiteralWarning) {\n  var cache = {},\n    isHtml5DateInput = false;\n  var dateFormat, closeOnDateSelection, appendToBody, onOpenFocus,\n    datepickerPopupTemplateUrl, datepickerTemplateUrl, popupEl, datepickerEl, scrollParentEl,\n    ngModel, ngModelOptions, $popup, altInputFormats, watchListeners = [],\n    timezone;\n\n  this.init = function(_ngModel_) {\n    ngModel = _ngModel_;\n    ngModelOptions = _ngModel_.$options;\n    closeOnDateSelection = angular.isDefined($attrs.closeOnDateSelection) ?\n      $scope.$parent.$eval($attrs.closeOnDateSelection) :\n      datepickerPopupConfig.closeOnDateSelection;\n    appendToBody = angular.isDefined($attrs.datepickerAppendToBody) ?\n      $scope.$parent.$eval($attrs.datepickerAppendToBody) :\n      datepickerPopupConfig.appendToBody;\n    onOpenFocus = angular.isDefined($attrs.onOpenFocus) ?\n      $scope.$parent.$eval($attrs.onOpenFocus) : datepickerPopupConfig.onOpenFocus;\n    datepickerPopupTemplateUrl = angular.isDefined($attrs.datepickerPopupTemplateUrl) ?\n      $attrs.datepickerPopupTemplateUrl :\n      datepickerPopupConfig.datepickerPopupTemplateUrl;\n    datepickerTemplateUrl = angular.isDefined($attrs.datepickerTemplateUrl) ?\n      $attrs.datepickerTemplateUrl : datepickerPopupConfig.datepickerTemplateUrl;\n    altInputFormats = angular.isDefined($attrs.altInputFormats) ?\n      $scope.$parent.$eval($attrs.altInputFormats) :\n      datepickerPopupConfig.altInputFormats;\n\n    $scope.showButtonBar = angular.isDefined($attrs.showButtonBar) ?\n      $scope.$parent.$eval($attrs.showButtonBar) :\n      datepickerPopupConfig.showButtonBar;\n\n    if (datepickerPopupConfig.html5Types[$attrs.type]) {\n      dateFormat = datepickerPopupConfig.html5Types[$attrs.type];\n      isHtml5DateInput = true;\n    } else {\n      dateFormat = $attrs.uibDatepickerPopup || datepickerPopupConfig.datepickerPopup;\n      $attrs.$observe('uibDatepickerPopup', function(value, oldValue) {\n        var newDateFormat = value || datepickerPopupConfig.datepickerPopup;\n        // Invalidate the $modelValue to ensure that formatters re-run\n        // FIXME: Refactor when PR is merged: https://github.com/angular/angular.js/pull/10764\n        if (newDateFormat !== dateFormat) {\n          dateFormat = newDateFormat;\n          ngModel.$modelValue = null;\n\n          if (!dateFormat) {\n            throw new Error('uibDatepickerPopup must have a date format specified.');\n          }\n        }\n      });\n    }\n\n    if (!dateFormat) {\n      throw new Error('uibDatepickerPopup must have a date format specified.');\n    }\n\n    if (isHtml5DateInput && $attrs.uibDatepickerPopup) {\n      throw new Error('HTML5 date input types do not support custom formats.');\n    }\n\n    // popup element used to display calendar\n    popupEl = angular.element('<div uib-datepicker-popup-wrap><div uib-datepicker></div></div>');\n    if (ngModelOptions) {\n      timezone = ngModelOptions.timezone;\n      $scope.ngModelOptions = angular.copy(ngModelOptions);\n      $scope.ngModelOptions.timezone = null;\n      if ($scope.ngModelOptions.updateOnDefault === true) {\n        $scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?\n          $scope.ngModelOptions.updateOn + ' default' : 'default';\n      }\n\n      popupEl.attr('ng-model-options', 'ngModelOptions');\n    } else {\n      timezone = null;\n    }\n\n    popupEl.attr({\n      'ng-model': 'date',\n      'ng-change': 'dateSelection(date)',\n      'template-url': datepickerPopupTemplateUrl\n    });\n\n    // datepicker element\n    datepickerEl = angular.element(popupEl.children()[0]);\n    datepickerEl.attr('template-url', datepickerTemplateUrl);\n\n    if (!$scope.datepickerOptions) {\n      $scope.datepickerOptions = {};\n    }\n\n    if (isHtml5DateInput) {\n      if ($attrs.type === 'month') {\n        $scope.datepickerOptions.datepickerMode = 'month';\n        $scope.datepickerOptions.minMode = 'month';\n      }\n    }\n\n    datepickerEl.attr('datepicker-options', 'datepickerOptions');\n\n    if (!isHtml5DateInput) {\n      // Internal API to maintain the correct ng-invalid-[key] class\n      ngModel.$$parserName = 'date';\n      ngModel.$validators.date = validator;\n      ngModel.$parsers.unshift(parseDate);\n      ngModel.$formatters.push(function(value) {\n        if (ngModel.$isEmpty(value)) {\n          $scope.date = value;\n          return value;\n        }\n\n        $scope.date = dateParser.fromTimezone(value, timezone);\n\n        if (angular.isNumber($scope.date)) {\n          $scope.date = new Date($scope.date);\n        }\n\n        return dateParser.filter($scope.date, dateFormat);\n      });\n    } else {\n      ngModel.$formatters.push(function(value) {\n        $scope.date = dateParser.fromTimezone(value, timezone);\n        return value;\n      });\n    }\n\n    // Detect changes in the view from the text box\n    ngModel.$viewChangeListeners.push(function() {\n      $scope.date = parseDateString(ngModel.$viewValue);\n    });\n\n    $element.on('keydown', inputKeydownBind);\n\n    $popup = $compile(popupEl)($scope);\n    // Prevent jQuery cache memory leak (template is now redundant after linking)\n    popupEl.remove();\n\n    if (appendToBody) {\n      $document.find('body').append($popup);\n    } else {\n      $element.after($popup);\n    }\n\n    $scope.$on('$destroy', function() {\n      if ($scope.isOpen === true) {\n        if (!$rootScope.$$phase) {\n          $scope.$apply(function() {\n            $scope.isOpen = false;\n          });\n        }\n      }\n\n      $popup.remove();\n      $element.off('keydown', inputKeydownBind);\n      $document.off('click', documentClickBind);\n      if (scrollParentEl) {\n        scrollParentEl.off('scroll', positionPopup);\n      }\n      angular.element($window).off('resize', positionPopup);\n\n      //Clear all watch listeners on destroy\n      while (watchListeners.length) {\n        watchListeners.shift()();\n      }\n    });\n  };\n\n  $scope.getText = function(key) {\n    return $scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];\n  };\n\n  $scope.isDisabled = function(date) {\n    if (date === 'today') {\n      date = dateParser.fromTimezone(new Date(), timezone);\n    }\n\n    var dates = {};\n    angular.forEach(['minDate', 'maxDate'], function(key) {\n      if (!$scope.datepickerOptions[key]) {\n        dates[key] = null;\n      } else if (angular.isDate($scope.datepickerOptions[key])) {\n        dates[key] = dateParser.fromTimezone(new Date($scope.datepickerOptions[key]), timezone);\n      } else {\n        if ($datepickerPopupLiteralWarning) {\n          $log.warn('Literal date support has been deprecated, please switch to date object usage');\n        }\n\n        dates[key] = new Date(dateFilter($scope.datepickerOptions[key], 'medium'));\n      }\n    });\n\n    return $scope.datepickerOptions &&\n      dates.minDate && $scope.compare(date, dates.minDate) < 0 ||\n      dates.maxDate && $scope.compare(date, dates.maxDate) > 0;\n  };\n\n  $scope.compare = function(date1, date2) {\n    return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());\n  };\n\n  // Inner change\n  $scope.dateSelection = function(dt) {\n    if (angular.isDefined(dt)) {\n      $scope.date = dt;\n    }\n    var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function\n    $element.val(date);\n    ngModel.$setViewValue(date);\n\n    if (closeOnDateSelection) {\n      $scope.isOpen = false;\n      $element[0].focus();\n    }\n  };\n\n  $scope.keydown = function(evt) {\n    if (evt.which === 27) {\n      evt.stopPropagation();\n      $scope.isOpen = false;\n      $element[0].focus();\n    }\n  };\n\n  $scope.select = function(date, evt) {\n    evt.stopPropagation();\n\n    if (date === 'today') {\n      var today = new Date();\n      if (angular.isDate($scope.date)) {\n        date = new Date($scope.date);\n        date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());\n      } else {\n        date = new Date(today.setHours(0, 0, 0, 0));\n      }\n    }\n    $scope.dateSelection(date);\n  };\n\n  $scope.close = function(evt) {\n    evt.stopPropagation();\n\n    $scope.isOpen = false;\n    $element[0].focus();\n  };\n\n  $scope.disabled = angular.isDefined($attrs.disabled) || false;\n  if ($attrs.ngDisabled) {\n    watchListeners.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(disabled) {\n      $scope.disabled = disabled;\n    }));\n  }\n\n  $scope.$watch('isOpen', function(value) {\n    if (value) {\n      if (!$scope.disabled) {\n        $timeout(function() {\n          positionPopup();\n\n          if (onOpenFocus) {\n            $scope.$broadcast('uib:datepicker.focus');\n          }\n\n          $document.on('click', documentClickBind);\n\n          var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;\n          if (appendToBody || $position.parsePlacement(placement)[2]) {\n            scrollParentEl = scrollParentEl || angular.element($position.scrollParent($element));\n            if (scrollParentEl) {\n              scrollParentEl.on('scroll', positionPopup);\n            }\n          } else {\n            scrollParentEl = null;\n          }\n\n          angular.element($window).on('resize', positionPopup);\n        }, 0, false);\n      } else {\n        $scope.isOpen = false;\n      }\n    } else {\n      $document.off('click', documentClickBind);\n      if (scrollParentEl) {\n        scrollParentEl.off('scroll', positionPopup);\n      }\n      angular.element($window).off('resize', positionPopup);\n    }\n  });\n\n  function cameltoDash(string) {\n    return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });\n  }\n\n  function parseDateString(viewValue) {\n    var date = dateParser.parse(viewValue, dateFormat, $scope.date);\n    if (isNaN(date)) {\n      for (var i = 0; i < altInputFormats.length; i++) {\n        date = dateParser.parse(viewValue, altInputFormats[i], $scope.date);\n        if (!isNaN(date)) {\n          return date;\n        }\n      }\n    }\n    return date;\n  }\n\n  function parseDate(viewValue) {\n    if (angular.isNumber(viewValue)) {\n      // presumably timestamp to date object\n      viewValue = new Date(viewValue);\n    }\n\n    if (!viewValue) {\n      return null;\n    }\n\n    if (angular.isDate(viewValue) && !isNaN(viewValue)) {\n      return viewValue;\n    }\n\n    if (angular.isString(viewValue)) {\n      var date = parseDateString(viewValue);\n      if (!isNaN(date)) {\n        return dateParser.toTimezone(date, timezone);\n      }\n    }\n\n    return ngModel.$options && ngModel.$options.allowInvalid ? viewValue : undefined;\n  }\n\n  function validator(modelValue, viewValue) {\n    var value = modelValue || viewValue;\n\n    if (!$attrs.ngRequired && !value) {\n      return true;\n    }\n\n    if (angular.isNumber(value)) {\n      value = new Date(value);\n    }\n\n    if (!value) {\n      return true;\n    }\n\n    if (angular.isDate(value) && !isNaN(value)) {\n      return true;\n    }\n\n    if (angular.isString(value)) {\n      return !isNaN(parseDateString(viewValue));\n    }\n\n    return false;\n  }\n\n  function documentClickBind(event) {\n    if (!$scope.isOpen && $scope.disabled) {\n      return;\n    }\n\n    var popup = $popup[0];\n    var dpContainsTarget = $element[0].contains(event.target);\n    // The popup node may not be an element node\n    // In some browsers (IE) only element nodes have the 'contains' function\n    var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target);\n    if ($scope.isOpen && !(dpContainsTarget || popupContainsTarget)) {\n      $scope.$apply(function() {\n        $scope.isOpen = false;\n      });\n    }\n  }\n\n  function inputKeydownBind(evt) {\n    if (evt.which === 27 && $scope.isOpen) {\n      evt.preventDefault();\n      evt.stopPropagation();\n      $scope.$apply(function() {\n        $scope.isOpen = false;\n      });\n      $element[0].focus();\n    } else if (evt.which === 40 && !$scope.isOpen) {\n      evt.preventDefault();\n      evt.stopPropagation();\n      $scope.$apply(function() {\n        $scope.isOpen = true;\n      });\n    }\n  }\n\n  function positionPopup() {\n    if ($scope.isOpen) {\n      var dpElement = angular.element($popup[0].querySelector('.uib-datepicker-popup'));\n      var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;\n      var position = $position.positionElements($element, dpElement, placement, appendToBody);\n      dpElement.css({top: position.top + 'px', left: position.left + 'px'});\n      if (dpElement.hasClass('uib-position-measure')) {\n        dpElement.removeClass('uib-position-measure');\n      }\n    }\n  }\n\n  $scope.$on('uib:datepicker.mode', function() {\n    $timeout(positionPopup, 0, false);\n  });\n}])\n\n.directive('uibDatepickerPopup', function() {\n  return {\n    require: ['ngModel', 'uibDatepickerPopup'],\n    controller: 'UibDatepickerPopupController',\n    scope: {\n      datepickerOptions: '=?',\n      isOpen: '=?',\n      currentText: '@',\n      clearText: '@',\n      closeText: '@'\n    },\n    link: function(scope, element, attrs, ctrls) {\n      var ngModel = ctrls[0],\n        ctrl = ctrls[1];\n\n      ctrl.init(ngModel);\n    }\n  };\n})\n\n.directive('uibDatepickerPopupWrap', function() {\n  return {\n    replace: true,\n    transclude: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/datepickerPopup/popup.html';\n    }\n  };\n});\n\nangular.module('ui.bootstrap.debounce', [])\n/**\n * A helper, internal service that debounces a function\n */\n  .factory('$$debounce', ['$timeout', function($timeout) {\n    return function(callback, debounceTime) {\n      var timeoutPromise;\n\n      return function() {\n        var self = this;\n        var args = Array.prototype.slice.call(arguments);\n        if (timeoutPromise) {\n          $timeout.cancel(timeoutPromise);\n        }\n\n        timeoutPromise = $timeout(function() {\n          callback.apply(self, args);\n        }, debounceTime);\n      };\n    };\n  }]);\n\nangular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])\n\n.constant('uibDropdownConfig', {\n  appendToOpenClass: 'uib-dropdown-open',\n  openClass: 'open'\n})\n\n.service('uibDropdownService', ['$document', '$rootScope', function($document, $rootScope) {\n  var openScope = null;\n\n  this.open = function(dropdownScope, element) {\n    if (!openScope) {\n      $document.on('click', closeDropdown);\n      element.on('keydown', keybindFilter);\n    }\n\n    if (openScope && openScope !== dropdownScope) {\n      openScope.isOpen = false;\n    }\n\n    openScope = dropdownScope;\n  };\n\n  this.close = function(dropdownScope, element) {\n    if (openScope === dropdownScope) {\n      openScope = null;\n      $document.off('click', closeDropdown);\n      element.off('keydown', keybindFilter);\n    }\n  };\n\n  var closeDropdown = function(evt) {\n    // This method may still be called during the same mouse event that\n    // unbound this event handler. So check openScope before proceeding.\n    if (!openScope) { return; }\n\n    if (evt && openScope.getAutoClose() === 'disabled') { return; }\n\n    if (evt && evt.which === 3) { return; }\n\n    var toggleElement = openScope.getToggleElement();\n    if (evt && toggleElement && toggleElement[0].contains(evt.target)) {\n      return;\n    }\n\n    var dropdownElement = openScope.getDropdownElement();\n    if (evt && openScope.getAutoClose() === 'outsideClick' &&\n      dropdownElement && dropdownElement[0].contains(evt.target)) {\n      return;\n    }\n\n    openScope.isOpen = false;\n\n    if (!$rootScope.$$phase) {\n      openScope.$apply();\n    }\n  };\n\n  var keybindFilter = function(evt) {\n    if (evt.which === 27) {\n      evt.stopPropagation();\n      openScope.focusToggleElement();\n      closeDropdown();\n    } else if (openScope.isKeynavEnabled() && [38, 40].indexOf(evt.which) !== -1 && openScope.isOpen) {\n      evt.preventDefault();\n      evt.stopPropagation();\n      openScope.focusDropdownEntry(evt.which);\n    }\n  };\n}])\n\n.controller('UibDropdownController', ['$scope', '$element', '$attrs', '$parse', 'uibDropdownConfig', 'uibDropdownService', '$animate', '$uibPosition', '$document', '$compile', '$templateRequest', function($scope, $element, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest) {\n  var self = this,\n    scope = $scope.$new(), // create a child scope so we are not polluting original one\n    templateScope,\n    appendToOpenClass = dropdownConfig.appendToOpenClass,\n    openClass = dropdownConfig.openClass,\n    getIsOpen,\n    setIsOpen = angular.noop,\n    toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop,\n    appendToBody = false,\n    appendTo = null,\n    keynavEnabled = false,\n    selectedOption = null,\n    body = $document.find('body');\n\n  $element.addClass('dropdown');\n\n  this.init = function() {\n    if ($attrs.isOpen) {\n      getIsOpen = $parse($attrs.isOpen);\n      setIsOpen = getIsOpen.assign;\n\n      $scope.$watch(getIsOpen, function(value) {\n        scope.isOpen = !!value;\n      });\n    }\n\n    if (angular.isDefined($attrs.dropdownAppendTo)) {\n      var appendToEl = $parse($attrs.dropdownAppendTo)(scope);\n      if (appendToEl) {\n        appendTo = angular.element(appendToEl);\n      }\n    }\n\n    appendToBody = angular.isDefined($attrs.dropdownAppendToBody);\n    keynavEnabled = angular.isDefined($attrs.keyboardNav);\n\n    if (appendToBody && !appendTo) {\n      appendTo = body;\n    }\n\n    if (appendTo && self.dropdownMenu) {\n      appendTo.append(self.dropdownMenu);\n      $element.on('$destroy', function handleDestroyEvent() {\n        self.dropdownMenu.remove();\n      });\n    }\n  };\n\n  this.toggle = function(open) {\n    scope.isOpen = arguments.length ? !!open : !scope.isOpen;\n    if (angular.isFunction(setIsOpen)) {\n      setIsOpen(scope, scope.isOpen);\n    }\n\n    return scope.isOpen;\n  };\n\n  // Allow other directives to watch status\n  this.isOpen = function() {\n    return scope.isOpen;\n  };\n\n  scope.getToggleElement = function() {\n    return self.toggleElement;\n  };\n\n  scope.getAutoClose = function() {\n    return $attrs.autoClose || 'always'; //or 'outsideClick' or 'disabled'\n  };\n\n  scope.getElement = function() {\n    return $element;\n  };\n\n  scope.isKeynavEnabled = function() {\n    return keynavEnabled;\n  };\n\n  scope.focusDropdownEntry = function(keyCode) {\n    var elems = self.dropdownMenu ? //If append to body is used.\n      angular.element(self.dropdownMenu).find('a') :\n      $element.find('ul').eq(0).find('a');\n\n    switch (keyCode) {\n      case 40: {\n        if (!angular.isNumber(self.selectedOption)) {\n          self.selectedOption = 0;\n        } else {\n          self.selectedOption = self.selectedOption === elems.length - 1 ?\n            self.selectedOption :\n            self.selectedOption + 1;\n        }\n        break;\n      }\n      case 38: {\n        if (!angular.isNumber(self.selectedOption)) {\n          self.selectedOption = elems.length - 1;\n        } else {\n          self.selectedOption = self.selectedOption === 0 ?\n            0 : self.selectedOption - 1;\n        }\n        break;\n      }\n    }\n    elems[self.selectedOption].focus();\n  };\n\n  scope.getDropdownElement = function() {\n    return self.dropdownMenu;\n  };\n\n  scope.focusToggleElement = function() {\n    if (self.toggleElement) {\n      self.toggleElement[0].focus();\n    }\n  };\n\n  scope.$watch('isOpen', function(isOpen, wasOpen) {\n    if (appendTo && self.dropdownMenu) {\n      var pos = $position.positionElements($element, self.dropdownMenu, 'bottom-left', true),\n        css,\n        rightalign;\n\n      css = {\n        top: pos.top + 'px',\n        display: isOpen ? 'block' : 'none'\n      };\n\n      rightalign = self.dropdownMenu.hasClass('dropdown-menu-right');\n      if (!rightalign) {\n        css.left = pos.left + 'px';\n        css.right = 'auto';\n      } else {\n        css.left = 'auto';\n        css.right = window.innerWidth -\n          (pos.left + $element.prop('offsetWidth')) + 'px';\n      }\n\n      // Need to adjust our positioning to be relative to the appendTo container\n      // if it's not the body element\n      if (!appendToBody) {\n        var appendOffset = $position.offset(appendTo);\n\n        css.top = pos.top - appendOffset.top + 'px';\n\n        if (!rightalign) {\n          css.left = pos.left - appendOffset.left + 'px';\n        } else {\n          css.right = window.innerWidth -\n            (pos.left - appendOffset.left + $element.prop('offsetWidth')) + 'px';\n        }\n      }\n\n      self.dropdownMenu.css(css);\n    }\n\n    var openContainer = appendTo ? appendTo : $element;\n    var hasOpenClass = openContainer.hasClass(appendTo ? appendToOpenClass : openClass);\n\n    if (hasOpenClass === !isOpen) {\n      $animate[isOpen ? 'addClass' : 'removeClass'](openContainer, appendTo ? appendToOpenClass : openClass).then(function() {\n        if (angular.isDefined(isOpen) && isOpen !== wasOpen) {\n          toggleInvoker($scope, { open: !!isOpen });\n        }\n      });\n    }\n\n    if (isOpen) {\n      if (self.dropdownMenuTemplateUrl) {\n        $templateRequest(self.dropdownMenuTemplateUrl).then(function(tplContent) {\n          templateScope = scope.$new();\n          $compile(tplContent.trim())(templateScope, function(dropdownElement) {\n            var newEl = dropdownElement;\n            self.dropdownMenu.replaceWith(newEl);\n            self.dropdownMenu = newEl;\n          });\n        });\n      }\n\n      scope.focusToggleElement();\n      uibDropdownService.open(scope, $element);\n    } else {\n      if (self.dropdownMenuTemplateUrl) {\n        if (templateScope) {\n          templateScope.$destroy();\n        }\n        var newEl = angular.element('<ul class=\"dropdown-menu\"></ul>');\n        self.dropdownMenu.replaceWith(newEl);\n        self.dropdownMenu = newEl;\n      }\n\n      uibDropdownService.close(scope, $element);\n      self.selectedOption = null;\n    }\n\n    if (angular.isFunction(setIsOpen)) {\n      setIsOpen($scope, isOpen);\n    }\n  });\n}])\n\n.directive('uibDropdown', function() {\n  return {\n    controller: 'UibDropdownController',\n    link: function(scope, element, attrs, dropdownCtrl) {\n      dropdownCtrl.init();\n    }\n  };\n})\n\n.directive('uibDropdownMenu', function() {\n  return {\n    restrict: 'A',\n    require: '?^uibDropdown',\n    link: function(scope, element, attrs, dropdownCtrl) {\n      if (!dropdownCtrl || angular.isDefined(attrs.dropdownNested)) {\n        return;\n      }\n\n      element.addClass('dropdown-menu');\n\n      var tplUrl = attrs.templateUrl;\n      if (tplUrl) {\n        dropdownCtrl.dropdownMenuTemplateUrl = tplUrl;\n      }\n\n      if (!dropdownCtrl.dropdownMenu) {\n        dropdownCtrl.dropdownMenu = element;\n      }\n    }\n  };\n})\n\n.directive('uibDropdownToggle', function() {\n  return {\n    require: '?^uibDropdown',\n    link: function(scope, element, attrs, dropdownCtrl) {\n      if (!dropdownCtrl) {\n        return;\n      }\n\n      element.addClass('dropdown-toggle');\n\n      dropdownCtrl.toggleElement = element;\n\n      var toggleDropdown = function(event) {\n        event.preventDefault();\n\n        if (!element.hasClass('disabled') && !attrs.disabled) {\n          scope.$apply(function() {\n            dropdownCtrl.toggle();\n          });\n        }\n      };\n\n      element.bind('click', toggleDropdown);\n\n      // WAI-ARIA\n      element.attr({ 'aria-haspopup': true, 'aria-expanded': false });\n      scope.$watch(dropdownCtrl.isOpen, function(isOpen) {\n        element.attr('aria-expanded', !!isOpen);\n      });\n\n      scope.$on('$destroy', function() {\n        element.unbind('click', toggleDropdown);\n      });\n    }\n  };\n});\n\nangular.module('ui.bootstrap.stackedMap', [])\n/**\n * A helper, internal data structure that acts as a map but also allows getting / removing\n * elements in the LIFO order\n */\n  .factory('$$stackedMap', function() {\n    return {\n      createNew: function() {\n        var stack = [];\n\n        return {\n          add: function(key, value) {\n            stack.push({\n              key: key,\n              value: value\n            });\n          },\n          get: function(key) {\n            for (var i = 0; i < stack.length; i++) {\n              if (key === stack[i].key) {\n                return stack[i];\n              }\n            }\n          },\n          keys: function() {\n            var keys = [];\n            for (var i = 0; i < stack.length; i++) {\n              keys.push(stack[i].key);\n            }\n            return keys;\n          },\n          top: function() {\n            return stack[stack.length - 1];\n          },\n          remove: function(key) {\n            var idx = -1;\n            for (var i = 0; i < stack.length; i++) {\n              if (key === stack[i].key) {\n                idx = i;\n                break;\n              }\n            }\n            return stack.splice(idx, 1)[0];\n          },\n          removeTop: function() {\n            return stack.splice(stack.length - 1, 1)[0];\n          },\n          length: function() {\n            return stack.length;\n          }\n        };\n      }\n    };\n  });\nangular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.position'])\n/**\n * A helper, internal data structure that stores all references attached to key\n */\n  .factory('$$multiMap', function() {\n    return {\n      createNew: function() {\n        var map = {};\n\n        return {\n          entries: function() {\n            return Object.keys(map).map(function(key) {\n              return {\n                key: key,\n                value: map[key]\n              };\n            });\n          },\n          get: function(key) {\n            return map[key];\n          },\n          hasKey: function(key) {\n            return !!map[key];\n          },\n          keys: function() {\n            return Object.keys(map);\n          },\n          put: function(key, value) {\n            if (!map[key]) {\n              map[key] = [];\n            }\n\n            map[key].push(value);\n          },\n          remove: function(key, value) {\n            var values = map[key];\n\n            if (!values) {\n              return;\n            }\n\n            var idx = values.indexOf(value);\n\n            if (idx !== -1) {\n              values.splice(idx, 1);\n            }\n\n            if (!values.length) {\n              delete map[key];\n            }\n          }\n        };\n      }\n    };\n  })\n\n/**\n * Pluggable resolve mechanism for the modal resolve resolution\n * Supports UI Router's $resolve service\n */\n  .provider('$uibResolve', function() {\n    var resolve = this;\n    this.resolver = null;\n\n    this.setResolver = function(resolver) {\n      this.resolver = resolver;\n    };\n\n    this.$get = ['$injector', '$q', function($injector, $q) {\n      var resolver = resolve.resolver ? $injector.get(resolve.resolver) : null;\n      return {\n        resolve: function(invocables, locals, parent, self) {\n          if (resolver) {\n            return resolver.resolve(invocables, locals, parent, self);\n          }\n\n          var promises = [];\n\n          angular.forEach(invocables, function(value) {\n            if (angular.isFunction(value) || angular.isArray(value)) {\n              promises.push($q.resolve($injector.invoke(value)));\n            } else if (angular.isString(value)) {\n              promises.push($q.resolve($injector.get(value)));\n            } else {\n              promises.push($q.resolve(value));\n            }\n          });\n\n          return $q.all(promises).then(function(resolves) {\n            var resolveObj = {};\n            var resolveIter = 0;\n            angular.forEach(invocables, function(value, key) {\n              resolveObj[key] = resolves[resolveIter++];\n            });\n\n            return resolveObj;\n          });\n        }\n      };\n    }];\n  })\n\n/**\n * A helper directive for the $modal service. It creates a backdrop element.\n */\n  .directive('uibModalBackdrop', ['$animate', '$injector', '$uibModalStack',\n  function($animate, $injector, $modalStack) {\n    return {\n      replace: true,\n      templateUrl: 'uib/template/modal/backdrop.html',\n      compile: function(tElement, tAttrs) {\n        tElement.addClass(tAttrs.backdropClass);\n        return linkFn;\n      }\n    };\n\n    function linkFn(scope, element, attrs) {\n      if (attrs.modalInClass) {\n        $animate.addClass(element, attrs.modalInClass);\n\n        scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {\n          var done = setIsAsync();\n          if (scope.modalOptions.animation) {\n            $animate.removeClass(element, attrs.modalInClass).then(done);\n          } else {\n            done();\n          }\n        });\n      }\n    }\n  }])\n\n  .directive('uibModalWindow', ['$uibModalStack', '$q', '$animateCss', '$document',\n  function($modalStack, $q, $animateCss, $document) {\n    return {\n      scope: {\n        index: '@'\n      },\n      replace: true,\n      transclude: true,\n      templateUrl: function(tElement, tAttrs) {\n        return tAttrs.templateUrl || 'uib/template/modal/window.html';\n      },\n      link: function(scope, element, attrs) {\n        element.addClass(attrs.windowClass || '');\n        element.addClass(attrs.windowTopClass || '');\n        scope.size = attrs.size;\n\n        scope.close = function(evt) {\n          var modal = $modalStack.getTop();\n          if (modal && modal.value.backdrop &&\n            modal.value.backdrop !== 'static' &&\n            evt.target === evt.currentTarget) {\n            evt.preventDefault();\n            evt.stopPropagation();\n            $modalStack.dismiss(modal.key, 'backdrop click');\n          }\n        };\n\n        // moved from template to fix issue #2280\n        element.on('click', scope.close);\n\n        // This property is only added to the scope for the purpose of detecting when this directive is rendered.\n        // We can detect that by using this property in the template associated with this directive and then use\n        // {@link Attribute#$observe} on it. For more details please see {@link TableColumnResize}.\n        scope.$isRendered = true;\n\n        // Deferred object that will be resolved when this modal is render.\n        var modalRenderDeferObj = $q.defer();\n        // Observe function will be called on next digest cycle after compilation, ensuring that the DOM is ready.\n        // In order to use this way of finding whether DOM is ready, we need to observe a scope property used in modal's template.\n        attrs.$observe('modalRender', function(value) {\n          if (value === 'true') {\n            modalRenderDeferObj.resolve();\n          }\n        });\n\n        modalRenderDeferObj.promise.then(function() {\n          var animationPromise = null;\n\n          if (attrs.modalInClass) {\n            animationPromise = $animateCss(element, {\n              addClass: attrs.modalInClass\n            }).start();\n\n            scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {\n              var done = setIsAsync();\n              $animateCss(element, {\n                removeClass: attrs.modalInClass\n              }).start().then(done);\n            });\n          }\n\n\n          $q.when(animationPromise).then(function() {\n            // Notify {@link $modalStack} that modal is rendered.\n            var modal = $modalStack.getTop();\n            if (modal) {\n              $modalStack.modalRendered(modal.key);\n            }\n\n            /**\n             * If something within the freshly-opened modal already has focus (perhaps via a\n             * directive that causes focus). then no need to try and focus anything.\n             */\n            if (!($document[0].activeElement && element[0].contains($document[0].activeElement))) {\n              var inputWithAutofocus = element[0].querySelector('[autofocus]');\n              /**\n               * Auto-focusing of a freshly-opened modal element causes any child elements\n               * with the autofocus attribute to lose focus. This is an issue on touch\n               * based devices which will show and then hide the onscreen keyboard.\n               * Attempts to refocus the autofocus element via JavaScript will not reopen\n               * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus\n               * the modal element if the modal does not contain an autofocus element.\n               */\n              if (inputWithAutofocus) {\n                inputWithAutofocus.focus();\n              } else {\n                element[0].focus();\n              }\n            }\n          });\n        });\n      }\n    };\n  }])\n\n  .directive('uibModalAnimationClass', function() {\n    return {\n      compile: function(tElement, tAttrs) {\n        if (tAttrs.modalAnimation) {\n          tElement.addClass(tAttrs.uibModalAnimationClass);\n        }\n      }\n    };\n  })\n\n  .directive('uibModalTransclude', function() {\n    return {\n      link: function(scope, element, attrs, controller, transclude) {\n        transclude(scope.$parent, function(clone) {\n          element.empty();\n          element.append(clone);\n        });\n      }\n    };\n  })\n\n  .factory('$uibModalStack', ['$animate', '$animateCss', '$document',\n    '$compile', '$rootScope', '$q', '$$multiMap', '$$stackedMap', '$uibPosition',\n    function($animate, $animateCss, $document, $compile, $rootScope, $q, $$multiMap, $$stackedMap, $uibPosition) {\n      var OPENED_MODAL_CLASS = 'modal-open';\n\n      var backdropDomEl, backdropScope;\n      var openedWindows = $$stackedMap.createNew();\n      var openedClasses = $$multiMap.createNew();\n      var $modalStack = {\n        NOW_CLOSING_EVENT: 'modal.stack.now-closing'\n      };\n      var topModalIndex = 0;\n      var previousTopOpenedModal = null;\n\n      //Modal focus behavior\n      var tabableSelector = 'a[href], area[href], input:not([disabled]), ' +\n        'button:not([disabled]),select:not([disabled]), textarea:not([disabled]), ' +\n        'iframe, object, embed, *[tabindex], *[contenteditable=true]';\n      var scrollbarPadding;\n\n      function isVisible(element) {\n        return !!(element.offsetWidth ||\n          element.offsetHeight ||\n          element.getClientRects().length);\n      }\n\n      function backdropIndex() {\n        var topBackdropIndex = -1;\n        var opened = openedWindows.keys();\n        for (var i = 0; i < opened.length; i++) {\n          if (openedWindows.get(opened[i]).value.backdrop) {\n            topBackdropIndex = i;\n          }\n        }\n\n        // If any backdrop exist, ensure that it's index is always\n        // right below the top modal\n        if (topBackdropIndex > -1 && topBackdropIndex < topModalIndex) {\n          topBackdropIndex = topModalIndex;\n        }\n        return topBackdropIndex;\n      }\n\n      $rootScope.$watch(backdropIndex, function(newBackdropIndex) {\n        if (backdropScope) {\n          backdropScope.index = newBackdropIndex;\n        }\n      });\n\n      function removeModalWindow(modalInstance, elementToReceiveFocus) {\n        var modalWindow = openedWindows.get(modalInstance).value;\n        var appendToElement = modalWindow.appendTo;\n\n        //clean up the stack\n        openedWindows.remove(modalInstance);\n        previousTopOpenedModal = openedWindows.top();\n        if (previousTopOpenedModal) {\n          topModalIndex = parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10);\n        }\n\n        removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {\n          var modalBodyClass = modalWindow.openedClass || OPENED_MODAL_CLASS;\n          openedClasses.remove(modalBodyClass, modalInstance);\n          var areAnyOpen = openedClasses.hasKey(modalBodyClass);\n          appendToElement.toggleClass(modalBodyClass, areAnyOpen);\n          if (!areAnyOpen && scrollbarPadding && scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {\n            if (scrollbarPadding.originalRight) {\n              appendToElement.css({paddingRight: scrollbarPadding.originalRight + 'px'});\n            } else {\n              appendToElement.css({paddingRight: ''});\n            }\n            scrollbarPadding = null;\n          }\n          toggleTopWindowClass(true);\n        }, modalWindow.closedDeferred);\n        checkRemoveBackdrop();\n\n        //move focus to specified element if available, or else to body\n        if (elementToReceiveFocus && elementToReceiveFocus.focus) {\n          elementToReceiveFocus.focus();\n        } else if (appendToElement.focus) {\n          appendToElement.focus();\n        }\n      }\n\n      // Add or remove \"windowTopClass\" from the top window in the stack\n      function toggleTopWindowClass(toggleSwitch) {\n        var modalWindow;\n\n        if (openedWindows.length() > 0) {\n          modalWindow = openedWindows.top().value;\n          modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch);\n        }\n      }\n\n      function checkRemoveBackdrop() {\n        //remove backdrop if no longer needed\n        if (backdropDomEl && backdropIndex() === -1) {\n          var backdropScopeRef = backdropScope;\n          removeAfterAnimate(backdropDomEl, backdropScope, function() {\n            backdropScopeRef = null;\n          });\n          backdropDomEl = undefined;\n          backdropScope = undefined;\n        }\n      }\n\n      function removeAfterAnimate(domEl, scope, done, closedDeferred) {\n        var asyncDeferred;\n        var asyncPromise = null;\n        var setIsAsync = function() {\n          if (!asyncDeferred) {\n            asyncDeferred = $q.defer();\n            asyncPromise = asyncDeferred.promise;\n          }\n\n          return function asyncDone() {\n            asyncDeferred.resolve();\n          };\n        };\n        scope.$broadcast($modalStack.NOW_CLOSING_EVENT, setIsAsync);\n\n        // Note that it's intentional that asyncPromise might be null.\n        // That's when setIsAsync has not been called during the\n        // NOW_CLOSING_EVENT broadcast.\n        return $q.when(asyncPromise).then(afterAnimating);\n\n        function afterAnimating() {\n          if (afterAnimating.done) {\n            return;\n          }\n          afterAnimating.done = true;\n\n          $animate.leave(domEl).then(function() {\n            domEl.remove();\n            if (closedDeferred) {\n              closedDeferred.resolve();\n            }\n          });\n\n          scope.$destroy();\n          if (done) {\n            done();\n          }\n        }\n      }\n\n      $document.on('keydown', keydownListener);\n\n      $rootScope.$on('$destroy', function() {\n        $document.off('keydown', keydownListener);\n      });\n\n      function keydownListener(evt) {\n        if (evt.isDefaultPrevented()) {\n          return evt;\n        }\n\n        var modal = openedWindows.top();\n        if (modal) {\n          switch (evt.which) {\n            case 27: {\n              if (modal.value.keyboard) {\n                evt.preventDefault();\n                $rootScope.$apply(function() {\n                  $modalStack.dismiss(modal.key, 'escape key press');\n                });\n              }\n              break;\n            }\n            case 9: {\n              var list = $modalStack.loadFocusElementList(modal);\n              var focusChanged = false;\n              if (evt.shiftKey) {\n                if ($modalStack.isFocusInFirstItem(evt, list) || $modalStack.isModalFocused(evt, modal)) {\n                  focusChanged = $modalStack.focusLastFocusableElement(list);\n                }\n              } else {\n                if ($modalStack.isFocusInLastItem(evt, list)) {\n                  focusChanged = $modalStack.focusFirstFocusableElement(list);\n                }\n              }\n\n              if (focusChanged) {\n                evt.preventDefault();\n                evt.stopPropagation();\n              }\n\n              break;\n            }\n          }\n        }\n      }\n\n      $modalStack.open = function(modalInstance, modal) {\n        var modalOpener = $document[0].activeElement,\n          modalBodyClass = modal.openedClass || OPENED_MODAL_CLASS;\n\n        toggleTopWindowClass(false);\n\n        // Store the current top first, to determine what index we ought to use\n        // for the current top modal\n        previousTopOpenedModal = openedWindows.top();\n\n        openedWindows.add(modalInstance, {\n          deferred: modal.deferred,\n          renderDeferred: modal.renderDeferred,\n          closedDeferred: modal.closedDeferred,\n          modalScope: modal.scope,\n          backdrop: modal.backdrop,\n          keyboard: modal.keyboard,\n          openedClass: modal.openedClass,\n          windowTopClass: modal.windowTopClass,\n          animation: modal.animation,\n          appendTo: modal.appendTo\n        });\n\n        openedClasses.put(modalBodyClass, modalInstance);\n\n        var appendToElement = modal.appendTo,\n            currBackdropIndex = backdropIndex();\n\n        if (!appendToElement.length) {\n          throw new Error('appendTo element not found. Make sure that the element passed is in DOM.');\n        }\n\n        if (currBackdropIndex >= 0 && !backdropDomEl) {\n          backdropScope = $rootScope.$new(true);\n          backdropScope.modalOptions = modal;\n          backdropScope.index = currBackdropIndex;\n          backdropDomEl = angular.element('<div uib-modal-backdrop=\"modal-backdrop\"></div>');\n          backdropDomEl.attr('backdrop-class', modal.backdropClass);\n          if (modal.animation) {\n            backdropDomEl.attr('modal-animation', 'true');\n          }\n          $compile(backdropDomEl)(backdropScope);\n          $animate.enter(backdropDomEl, appendToElement);\n          scrollbarPadding = $uibPosition.scrollbarPadding(appendToElement);\n          if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {\n            appendToElement.css({paddingRight: scrollbarPadding.right + 'px'});\n          }\n        }\n\n        // Set the top modal index based on the index of the previous top modal\n        topModalIndex = previousTopOpenedModal ? parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10) + 1 : 0;\n        var angularDomEl = angular.element('<div uib-modal-window=\"modal-window\"></div>');\n        angularDomEl.attr({\n          'template-url': modal.windowTemplateUrl,\n          'window-class': modal.windowClass,\n          'window-top-class': modal.windowTopClass,\n          'size': modal.size,\n          'index': topModalIndex,\n          'animate': 'animate'\n        }).html(modal.content);\n        if (modal.animation) {\n          angularDomEl.attr('modal-animation', 'true');\n        }\n\n        appendToElement.addClass(modalBodyClass);\n        $animate.enter($compile(angularDomEl)(modal.scope), appendToElement);\n\n        openedWindows.top().value.modalDomEl = angularDomEl;\n        openedWindows.top().value.modalOpener = modalOpener;\n      };\n\n      function broadcastClosing(modalWindow, resultOrReason, closing) {\n        return !modalWindow.value.modalScope.$broadcast('modal.closing', resultOrReason, closing).defaultPrevented;\n      }\n\n      $modalStack.close = function(modalInstance, result) {\n        var modalWindow = openedWindows.get(modalInstance);\n        if (modalWindow && broadcastClosing(modalWindow, result, true)) {\n          modalWindow.value.modalScope.$$uibDestructionScheduled = true;\n          modalWindow.value.deferred.resolve(result);\n          removeModalWindow(modalInstance, modalWindow.value.modalOpener);\n          return true;\n        }\n        return !modalWindow;\n      };\n\n      $modalStack.dismiss = function(modalInstance, reason) {\n        var modalWindow = openedWindows.get(modalInstance);\n        if (modalWindow && broadcastClosing(modalWindow, reason, false)) {\n          modalWindow.value.modalScope.$$uibDestructionScheduled = true;\n          modalWindow.value.deferred.reject(reason);\n          removeModalWindow(modalInstance, modalWindow.value.modalOpener);\n          return true;\n        }\n        return !modalWindow;\n      };\n\n      $modalStack.dismissAll = function(reason) {\n        var topModal = this.getTop();\n        while (topModal && this.dismiss(topModal.key, reason)) {\n          topModal = this.getTop();\n        }\n      };\n\n      $modalStack.getTop = function() {\n        return openedWindows.top();\n      };\n\n      $modalStack.modalRendered = function(modalInstance) {\n        var modalWindow = openedWindows.get(modalInstance);\n        if (modalWindow) {\n          modalWindow.value.renderDeferred.resolve();\n        }\n      };\n\n      $modalStack.focusFirstFocusableElement = function(list) {\n        if (list.length > 0) {\n          list[0].focus();\n          return true;\n        }\n        return false;\n      };\n\n      $modalStack.focusLastFocusableElement = function(list) {\n        if (list.length > 0) {\n          list[list.length - 1].focus();\n          return true;\n        }\n        return false;\n      };\n\n      $modalStack.isModalFocused = function(evt, modalWindow) {\n        if (evt && modalWindow) {\n          var modalDomEl = modalWindow.value.modalDomEl;\n          if (modalDomEl && modalDomEl.length) {\n            return (evt.target || evt.srcElement) === modalDomEl[0];\n          }\n        }\n        return false;\n      };\n\n      $modalStack.isFocusInFirstItem = function(evt, list) {\n        if (list.length > 0) {\n          return (evt.target || evt.srcElement) === list[0];\n        }\n        return false;\n      };\n\n      $modalStack.isFocusInLastItem = function(evt, list) {\n        if (list.length > 0) {\n          return (evt.target || evt.srcElement) === list[list.length - 1];\n        }\n        return false;\n      };\n\n      $modalStack.loadFocusElementList = function(modalWindow) {\n        if (modalWindow) {\n          var modalDomE1 = modalWindow.value.modalDomEl;\n          if (modalDomE1 && modalDomE1.length) {\n            var elements = modalDomE1[0].querySelectorAll(tabableSelector);\n            return elements ?\n              Array.prototype.filter.call(elements, function(element) {\n                return isVisible(element);\n              }) : elements;\n          }\n        }\n      };\n\n      return $modalStack;\n    }])\n\n  .provider('$uibModal', function() {\n    var $modalProvider = {\n      options: {\n        animation: true,\n        backdrop: true, //can also be false or 'static'\n        keyboard: true\n      },\n      $get: ['$rootScope', '$q', '$document', '$templateRequest', '$controller', '$uibResolve', '$uibModalStack',\n        function ($rootScope, $q, $document, $templateRequest, $controller, $uibResolve, $modalStack) {\n          var $modal = {};\n\n          function getTemplatePromise(options) {\n            return options.template ? $q.when(options.template) :\n              $templateRequest(angular.isFunction(options.templateUrl) ?\n                options.templateUrl() : options.templateUrl);\n          }\n\n          var promiseChain = null;\n          $modal.getPromiseChain = function() {\n            return promiseChain;\n          };\n\n          $modal.open = function(modalOptions) {\n            var modalResultDeferred = $q.defer();\n            var modalOpenedDeferred = $q.defer();\n            var modalClosedDeferred = $q.defer();\n            var modalRenderDeferred = $q.defer();\n\n            //prepare an instance of a modal to be injected into controllers and returned to a caller\n            var modalInstance = {\n              result: modalResultDeferred.promise,\n              opened: modalOpenedDeferred.promise,\n              closed: modalClosedDeferred.promise,\n              rendered: modalRenderDeferred.promise,\n              close: function (result) {\n                return $modalStack.close(modalInstance, result);\n              },\n              dismiss: function (reason) {\n                return $modalStack.dismiss(modalInstance, reason);\n              }\n            };\n\n            //merge and clean up options\n            modalOptions = angular.extend({}, $modalProvider.options, modalOptions);\n            modalOptions.resolve = modalOptions.resolve || {};\n            modalOptions.appendTo = modalOptions.appendTo || $document.find('body').eq(0);\n\n            //verify options\n            if (!modalOptions.template && !modalOptions.templateUrl) {\n              throw new Error('One of template or templateUrl options is required.');\n            }\n\n            var templateAndResolvePromise =\n              $q.all([getTemplatePromise(modalOptions), $uibResolve.resolve(modalOptions.resolve, {}, null, null)]);\n\n            function resolveWithTemplate() {\n              return templateAndResolvePromise;\n            }\n\n            // Wait for the resolution of the existing promise chain.\n            // Then switch to our own combined promise dependency (regardless of how the previous modal fared).\n            // Then add to $modalStack and resolve opened.\n            // Finally clean up the chain variable if no subsequent modal has overwritten it.\n            var samePromise;\n            samePromise = promiseChain = $q.all([promiseChain])\n              .then(resolveWithTemplate, resolveWithTemplate)\n              .then(function resolveSuccess(tplAndVars) {\n                var providedScope = modalOptions.scope || $rootScope;\n\n                var modalScope = providedScope.$new();\n                modalScope.$close = modalInstance.close;\n                modalScope.$dismiss = modalInstance.dismiss;\n\n                modalScope.$on('$destroy', function() {\n                  if (!modalScope.$$uibDestructionScheduled) {\n                    modalScope.$dismiss('$uibUnscheduledDestruction');\n                  }\n                });\n\n                var ctrlInstance, ctrlInstantiate, ctrlLocals = {};\n\n                //controllers\n                if (modalOptions.controller) {\n                  ctrlLocals.$scope = modalScope;\n                  ctrlLocals.$uibModalInstance = modalInstance;\n                  angular.forEach(tplAndVars[1], function(value, key) {\n                    ctrlLocals[key] = value;\n                  });\n\n                  // the third param will make the controller instantiate later,private api\n                  // @see https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L126\n                  ctrlInstantiate = $controller(modalOptions.controller, ctrlLocals, true);\n                  if (modalOptions.controllerAs) {\n                    ctrlInstance = ctrlInstantiate.instance;\n\n                    if (modalOptions.bindToController) {\n                      ctrlInstance.$close = modalScope.$close;\n                      ctrlInstance.$dismiss = modalScope.$dismiss;\n                      angular.extend(ctrlInstance, providedScope);\n                    }\n\n                    ctrlInstance = ctrlInstantiate();\n\n                    modalScope[modalOptions.controllerAs] = ctrlInstance;\n                  } else {\n                    ctrlInstance = ctrlInstantiate();\n                  }\n\n                  if (angular.isFunction(ctrlInstance.$onInit)) {\n                    ctrlInstance.$onInit();\n                  }\n                }\n\n                $modalStack.open(modalInstance, {\n                  scope: modalScope,\n                  deferred: modalResultDeferred,\n                  renderDeferred: modalRenderDeferred,\n                  closedDeferred: modalClosedDeferred,\n                  content: tplAndVars[0],\n                  animation: modalOptions.animation,\n                  backdrop: modalOptions.backdrop,\n                  keyboard: modalOptions.keyboard,\n                  backdropClass: modalOptions.backdropClass,\n                  windowTopClass: modalOptions.windowTopClass,\n                  windowClass: modalOptions.windowClass,\n                  windowTemplateUrl: modalOptions.windowTemplateUrl,\n                  size: modalOptions.size,\n                  openedClass: modalOptions.openedClass,\n                  appendTo: modalOptions.appendTo\n                });\n                modalOpenedDeferred.resolve(true);\n\n            }, function resolveError(reason) {\n              modalOpenedDeferred.reject(reason);\n              modalResultDeferred.reject(reason);\n            })['finally'](function() {\n              if (promiseChain === samePromise) {\n                promiseChain = null;\n              }\n            });\n\n            return modalInstance;\n          };\n\n          return $modal;\n        }\n      ]\n    };\n\n    return $modalProvider;\n  });\n\nangular.module('ui.bootstrap.paging', [])\n/**\n * Helper internal service for generating common controller code between the\n * pager and pagination components\n */\n.factory('uibPaging', ['$parse', function($parse) {\n  return {\n    create: function(ctrl, $scope, $attrs) {\n      ctrl.setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;\n      ctrl.ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl\n      ctrl._watchers = [];\n\n      ctrl.init = function(ngModelCtrl, config) {\n        ctrl.ngModelCtrl = ngModelCtrl;\n        ctrl.config = config;\n\n        ngModelCtrl.$render = function() {\n          ctrl.render();\n        };\n\n        if ($attrs.itemsPerPage) {\n          ctrl._watchers.push($scope.$parent.$watch($attrs.itemsPerPage, function(value) {\n            ctrl.itemsPerPage = parseInt(value, 10);\n            $scope.totalPages = ctrl.calculateTotalPages();\n            ctrl.updatePage();\n          }));\n        } else {\n          ctrl.itemsPerPage = config.itemsPerPage;\n        }\n\n        $scope.$watch('totalItems', function(newTotal, oldTotal) {\n          if (angular.isDefined(newTotal) || newTotal !== oldTotal) {\n            $scope.totalPages = ctrl.calculateTotalPages();\n            ctrl.updatePage();\n          }\n        });\n      };\n\n      ctrl.calculateTotalPages = function() {\n        var totalPages = ctrl.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / ctrl.itemsPerPage);\n        return Math.max(totalPages || 0, 1);\n      };\n\n      ctrl.render = function() {\n        $scope.page = parseInt(ctrl.ngModelCtrl.$viewValue, 10) || 1;\n      };\n\n      $scope.selectPage = function(page, evt) {\n        if (evt) {\n          evt.preventDefault();\n        }\n\n        var clickAllowed = !$scope.ngDisabled || !evt;\n        if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {\n          if (evt && evt.target) {\n            evt.target.blur();\n          }\n          ctrl.ngModelCtrl.$setViewValue(page);\n          ctrl.ngModelCtrl.$render();\n        }\n      };\n\n      $scope.getText = function(key) {\n        return $scope[key + 'Text'] || ctrl.config[key + 'Text'];\n      };\n\n      $scope.noPrevious = function() {\n        return $scope.page === 1;\n      };\n\n      $scope.noNext = function() {\n        return $scope.page === $scope.totalPages;\n      };\n\n      ctrl.updatePage = function() {\n        ctrl.setNumPages($scope.$parent, $scope.totalPages); // Readonly variable\n\n        if ($scope.page > $scope.totalPages) {\n          $scope.selectPage($scope.totalPages);\n        } else {\n          ctrl.ngModelCtrl.$render();\n        }\n      };\n\n      $scope.$on('$destroy', function() {\n        while (ctrl._watchers.length) {\n          ctrl._watchers.shift()();\n        }\n      });\n    }\n  };\n}]);\n\nangular.module('ui.bootstrap.pager', ['ui.bootstrap.paging'])\n\n.controller('UibPagerController', ['$scope', '$attrs', 'uibPaging', 'uibPagerConfig', function($scope, $attrs, uibPaging, uibPagerConfig) {\n  $scope.align = angular.isDefined($attrs.align) ? $scope.$parent.$eval($attrs.align) : uibPagerConfig.align;\n\n  uibPaging.create(this, $scope, $attrs);\n}])\n\n.constant('uibPagerConfig', {\n  itemsPerPage: 10,\n  previousText: '« Previous',\n  nextText: 'Next »',\n  align: true\n})\n\n.directive('uibPager', ['uibPagerConfig', function(uibPagerConfig) {\n  return {\n    scope: {\n      totalItems: '=',\n      previousText: '@',\n      nextText: '@',\n      ngDisabled: '='\n    },\n    require: ['uibPager', '?ngModel'],\n    controller: 'UibPagerController',\n    controllerAs: 'pager',\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/pager/pager.html';\n    },\n    replace: true,\n    link: function(scope, element, attrs, ctrls) {\n      var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n      if (!ngModelCtrl) {\n        return; // do nothing if no ng-model\n      }\n\n      paginationCtrl.init(ngModelCtrl, uibPagerConfig);\n    }\n  };\n}]);\n\nangular.module('ui.bootstrap.pagination', ['ui.bootstrap.paging'])\n.controller('UibPaginationController', ['$scope', '$attrs', '$parse', 'uibPaging', 'uibPaginationConfig', function($scope, $attrs, $parse, uibPaging, uibPaginationConfig) {\n  var ctrl = this;\n  // Setup configuration parameters\n  var maxSize = angular.isDefined($attrs.maxSize) ? $scope.$parent.$eval($attrs.maxSize) : uibPaginationConfig.maxSize,\n    rotate = angular.isDefined($attrs.rotate) ? $scope.$parent.$eval($attrs.rotate) : uibPaginationConfig.rotate,\n    forceEllipses = angular.isDefined($attrs.forceEllipses) ? $scope.$parent.$eval($attrs.forceEllipses) : uibPaginationConfig.forceEllipses,\n    boundaryLinkNumbers = angular.isDefined($attrs.boundaryLinkNumbers) ? $scope.$parent.$eval($attrs.boundaryLinkNumbers) : uibPaginationConfig.boundaryLinkNumbers,\n    pageLabel = angular.isDefined($attrs.pageLabel) ? function(idx) { return $scope.$parent.$eval($attrs.pageLabel, {$page: idx}); } : angular.identity;\n  $scope.boundaryLinks = angular.isDefined($attrs.boundaryLinks) ? $scope.$parent.$eval($attrs.boundaryLinks) : uibPaginationConfig.boundaryLinks;\n  $scope.directionLinks = angular.isDefined($attrs.directionLinks) ? $scope.$parent.$eval($attrs.directionLinks) : uibPaginationConfig.directionLinks;\n\n  uibPaging.create(this, $scope, $attrs);\n\n  if ($attrs.maxSize) {\n    ctrl._watchers.push($scope.$parent.$watch($parse($attrs.maxSize), function(value) {\n      maxSize = parseInt(value, 10);\n      ctrl.render();\n    }));\n  }\n\n  // Create page object used in template\n  function makePage(number, text, isActive) {\n    return {\n      number: number,\n      text: text,\n      active: isActive\n    };\n  }\n\n  function getPages(currentPage, totalPages) {\n    var pages = [];\n\n    // Default page limits\n    var startPage = 1, endPage = totalPages;\n    var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;\n\n    // recompute if maxSize\n    if (isMaxSized) {\n      if (rotate) {\n        // Current page is displayed in the middle of the visible ones\n        startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1);\n        endPage = startPage + maxSize - 1;\n\n        // Adjust if limit is exceeded\n        if (endPage > totalPages) {\n          endPage = totalPages;\n          startPage = endPage - maxSize + 1;\n        }\n      } else {\n        // Visible pages are paginated with maxSize\n        startPage = (Math.ceil(currentPage / maxSize) - 1) * maxSize + 1;\n\n        // Adjust last page if limit is exceeded\n        endPage = Math.min(startPage + maxSize - 1, totalPages);\n      }\n    }\n\n    // Add page number links\n    for (var number = startPage; number <= endPage; number++) {\n      var page = makePage(number, pageLabel(number), number === currentPage);\n      pages.push(page);\n    }\n\n    // Add links to move between page sets\n    if (isMaxSized && maxSize > 0 && (!rotate || forceEllipses || boundaryLinkNumbers)) {\n      if (startPage > 1) {\n        if (!boundaryLinkNumbers || startPage > 3) { //need ellipsis for all options unless range is too close to beginning\n        var previousPageSet = makePage(startPage - 1, '...', false);\n        pages.unshift(previousPageSet);\n      }\n        if (boundaryLinkNumbers) {\n          if (startPage === 3) { //need to replace ellipsis when the buttons would be sequential\n            var secondPageLink = makePage(2, '2', false);\n            pages.unshift(secondPageLink);\n          }\n          //add the first page\n          var firstPageLink = makePage(1, '1', false);\n          pages.unshift(firstPageLink);\n        }\n      }\n\n      if (endPage < totalPages) {\n        if (!boundaryLinkNumbers || endPage < totalPages - 2) { //need ellipsis for all options unless range is too close to end\n        var nextPageSet = makePage(endPage + 1, '...', false);\n        pages.push(nextPageSet);\n      }\n        if (boundaryLinkNumbers) {\n          if (endPage === totalPages - 2) { //need to replace ellipsis when the buttons would be sequential\n            var secondToLastPageLink = makePage(totalPages - 1, totalPages - 1, false);\n            pages.push(secondToLastPageLink);\n          }\n          //add the last page\n          var lastPageLink = makePage(totalPages, totalPages, false);\n          pages.push(lastPageLink);\n        }\n      }\n    }\n    return pages;\n  }\n\n  var originalRender = this.render;\n  this.render = function() {\n    originalRender();\n    if ($scope.page > 0 && $scope.page <= $scope.totalPages) {\n      $scope.pages = getPages($scope.page, $scope.totalPages);\n    }\n  };\n}])\n\n.constant('uibPaginationConfig', {\n  itemsPerPage: 10,\n  boundaryLinks: false,\n  boundaryLinkNumbers: false,\n  directionLinks: true,\n  firstText: 'First',\n  previousText: 'Previous',\n  nextText: 'Next',\n  lastText: 'Last',\n  rotate: true,\n  forceEllipses: false\n})\n\n.directive('uibPagination', ['$parse', 'uibPaginationConfig', function($parse, uibPaginationConfig) {\n  return {\n    scope: {\n      totalItems: '=',\n      firstText: '@',\n      previousText: '@',\n      nextText: '@',\n      lastText: '@',\n      ngDisabled:'='\n    },\n    require: ['uibPagination', '?ngModel'],\n    controller: 'UibPaginationController',\n    controllerAs: 'pagination',\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/pagination/pagination.html';\n    },\n    replace: true,\n    link: function(scope, element, attrs, ctrls) {\n      var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n      if (!ngModelCtrl) {\n         return; // do nothing if no ng-model\n      }\n\n      paginationCtrl.init(ngModelCtrl, uibPaginationConfig);\n    }\n  };\n}]);\n\n/**\n * The following features are still outstanding: animation as a\n * function, placement as a function, inside, support for more triggers than\n * just mouse enter/leave, html tooltips, and selector delegation.\n */\nangular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.stackedMap'])\n\n/**\n * The $tooltip service creates tooltip- and popover-like directives as well as\n * houses global options for them.\n */\n.provider('$uibTooltip', function() {\n  // The default options tooltip and popover.\n  var defaultOptions = {\n    placement: 'top',\n    placementClassPrefix: '',\n    animation: true,\n    popupDelay: 0,\n    popupCloseDelay: 0,\n    useContentExp: false\n  };\n\n  // Default hide triggers for each show trigger\n  var triggerMap = {\n    'mouseenter': 'mouseleave',\n    'click': 'click',\n    'outsideClick': 'outsideClick',\n    'focus': 'blur',\n    'none': ''\n  };\n\n  // The options specified to the provider globally.\n  var globalOptions = {};\n\n  /**\n   * `options({})` allows global configuration of all tooltips in the\n   * application.\n   *\n   *   var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {\n   *     // place tooltips left instead of top by default\n   *     $tooltipProvider.options( { placement: 'left' } );\n   *   });\n   */\n\tthis.options = function(value) {\n\t\tangular.extend(globalOptions, value);\n\t};\n\n  /**\n   * This allows you to extend the set of trigger mappings available. E.g.:\n   *\n   *   $tooltipProvider.setTriggers( { 'openTrigger': 'closeTrigger' } );\n   */\n  this.setTriggers = function setTriggers(triggers) {\n    angular.extend(triggerMap, triggers);\n  };\n\n  /**\n   * This is a helper function for translating camel-case to snake_case.\n   */\n  function snake_case(name) {\n    var regexp = /[A-Z]/g;\n    var separator = '-';\n    return name.replace(regexp, function(letter, pos) {\n      return (pos ? separator : '') + letter.toLowerCase();\n    });\n  }\n\n  /**\n   * Returns the actual instance of the $tooltip service.\n   * TODO support multiple triggers\n   */\n  this.$get = ['$window', '$compile', '$timeout', '$document', '$uibPosition', '$interpolate', '$rootScope', '$parse', '$$stackedMap', function($window, $compile, $timeout, $document, $position, $interpolate, $rootScope, $parse, $$stackedMap) {\n    var openedTooltips = $$stackedMap.createNew();\n    $document.on('keypress', keypressListener);\n\n    $rootScope.$on('$destroy', function() {\n      $document.off('keypress', keypressListener);\n    });\n\n    function keypressListener(e) {\n      if (e.which === 27) {\n        var last = openedTooltips.top();\n        if (last) {\n          last.value.close();\n          openedTooltips.removeTop();\n          last = null;\n        }\n      }\n    }\n\n    return function $tooltip(ttType, prefix, defaultTriggerShow, options) {\n      options = angular.extend({}, defaultOptions, globalOptions, options);\n\n      /**\n       * Returns an object of show and hide triggers.\n       *\n       * If a trigger is supplied,\n       * it is used to show the tooltip; otherwise, it will use the `trigger`\n       * option passed to the `$tooltipProvider.options` method; else it will\n       * default to the trigger supplied to this directive factory.\n       *\n       * The hide trigger is based on the show trigger. If the `trigger` option\n       * was passed to the `$tooltipProvider.options` method, it will use the\n       * mapped trigger from `triggerMap` or the passed trigger if the map is\n       * undefined; otherwise, it uses the `triggerMap` value of the show\n       * trigger; else it will just use the show trigger.\n       */\n      function getTriggers(trigger) {\n        var show = (trigger || options.trigger || defaultTriggerShow).split(' ');\n        var hide = show.map(function(trigger) {\n          return triggerMap[trigger] || trigger;\n        });\n        return {\n          show: show,\n          hide: hide\n        };\n      }\n\n      var directiveName = snake_case(ttType);\n\n      var startSym = $interpolate.startSymbol();\n      var endSym = $interpolate.endSymbol();\n      var template =\n        '<div '+ directiveName + '-popup ' +\n          'uib-title=\"' + startSym + 'title' + endSym + '\" ' +\n          (options.useContentExp ?\n            'content-exp=\"contentExp()\" ' :\n            'content=\"' + startSym + 'content' + endSym + '\" ') +\n          'placement=\"' + startSym + 'placement' + endSym + '\" ' +\n          'popup-class=\"' + startSym + 'popupClass' + endSym + '\" ' +\n          'animation=\"animation\" ' +\n          'is-open=\"isOpen\" ' +\n          'origin-scope=\"origScope\" ' +\n          'class=\"uib-position-measure\"' +\n          '>' +\n        '</div>';\n\n      return {\n        compile: function(tElem, tAttrs) {\n          var tooltipLinker = $compile(template);\n\n          return function link(scope, element, attrs, tooltipCtrl) {\n            var tooltip;\n            var tooltipLinkedScope;\n            var transitionTimeout;\n            var showTimeout;\n            var hideTimeout;\n            var positionTimeout;\n            var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;\n            var triggers = getTriggers(undefined);\n            var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);\n            var ttScope = scope.$new(true);\n            var repositionScheduled = false;\n            var isOpenParse = angular.isDefined(attrs[prefix + 'IsOpen']) ? $parse(attrs[prefix + 'IsOpen']) : false;\n            var contentParse = options.useContentExp ? $parse(attrs[ttType]) : false;\n            var observers = [];\n            var lastPlacement;\n\n            var positionTooltip = function() {\n              // check if tooltip exists and is not empty\n              if (!tooltip || !tooltip.html()) { return; }\n\n              if (!positionTimeout) {\n                positionTimeout = $timeout(function() {\n                  var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);\n                  tooltip.css({ top: ttPosition.top + 'px', left: ttPosition.left + 'px' });\n\n                  if (!tooltip.hasClass(ttPosition.placement.split('-')[0])) {\n                    tooltip.removeClass(lastPlacement.split('-')[0]);\n                    tooltip.addClass(ttPosition.placement.split('-')[0]);\n                  }\n\n                  if (!tooltip.hasClass(options.placementClassPrefix + ttPosition.placement)) {\n                    tooltip.removeClass(options.placementClassPrefix + lastPlacement);\n                    tooltip.addClass(options.placementClassPrefix + ttPosition.placement);\n                  }\n\n                  // first time through tt element will have the\n                  // uib-position-measure class or if the placement\n                  // has changed we need to position the arrow.\n                  if (tooltip.hasClass('uib-position-measure')) {\n                    $position.positionArrow(tooltip, ttPosition.placement);\n                    tooltip.removeClass('uib-position-measure');\n                  } else if (lastPlacement !== ttPosition.placement) {\n                    $position.positionArrow(tooltip, ttPosition.placement);\n                  }\n                  lastPlacement = ttPosition.placement;\n\n                  positionTimeout = null;\n                }, 0, false);\n              }\n            };\n\n            // Set up the correct scope to allow transclusion later\n            ttScope.origScope = scope;\n\n            // By default, the tooltip is not open.\n            // TODO add ability to start tooltip opened\n            ttScope.isOpen = false;\n            openedTooltips.add(ttScope, {\n              close: hide\n            });\n\n            function toggleTooltipBind() {\n              if (!ttScope.isOpen) {\n                showTooltipBind();\n              } else {\n                hideTooltipBind();\n              }\n            }\n\n            // Show the tooltip with delay if specified, otherwise show it immediately\n            function showTooltipBind() {\n              if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {\n                return;\n              }\n\n              cancelHide();\n              prepareTooltip();\n\n              if (ttScope.popupDelay) {\n                // Do nothing if the tooltip was already scheduled to pop-up.\n                // This happens if show is triggered multiple times before any hide is triggered.\n                if (!showTimeout) {\n                  showTimeout = $timeout(show, ttScope.popupDelay, false);\n                }\n              } else {\n                show();\n              }\n            }\n\n            function hideTooltipBind() {\n              cancelShow();\n\n              if (ttScope.popupCloseDelay) {\n                if (!hideTimeout) {\n                  hideTimeout = $timeout(hide, ttScope.popupCloseDelay, false);\n                }\n              } else {\n                hide();\n              }\n            }\n\n            // Show the tooltip popup element.\n            function show() {\n              cancelShow();\n              cancelHide();\n\n              // Don't show empty tooltips.\n              if (!ttScope.content) {\n                return angular.noop;\n              }\n\n              createTooltip();\n\n              // And show the tooltip.\n              ttScope.$evalAsync(function() {\n                ttScope.isOpen = true;\n                assignIsOpen(true);\n                positionTooltip();\n              });\n            }\n\n            function cancelShow() {\n              if (showTimeout) {\n                $timeout.cancel(showTimeout);\n                showTimeout = null;\n              }\n\n              if (positionTimeout) {\n                $timeout.cancel(positionTimeout);\n                positionTimeout = null;\n              }\n            }\n\n            // Hide the tooltip popup element.\n            function hide() {\n              if (!ttScope) {\n                return;\n              }\n\n              // First things first: we don't show it anymore.\n              ttScope.$evalAsync(function() {\n                if (ttScope) {\n                  ttScope.isOpen = false;\n                  assignIsOpen(false);\n                  // And now we remove it from the DOM. However, if we have animation, we\n                  // need to wait for it to expire beforehand.\n                  // FIXME: this is a placeholder for a port of the transitions library.\n                  // The fade transition in TWBS is 150ms.\n                  if (ttScope.animation) {\n                    if (!transitionTimeout) {\n                      transitionTimeout = $timeout(removeTooltip, 150, false);\n                    }\n                  } else {\n                    removeTooltip();\n                  }\n                }\n              });\n            }\n\n            function cancelHide() {\n              if (hideTimeout) {\n                $timeout.cancel(hideTimeout);\n                hideTimeout = null;\n              }\n\n              if (transitionTimeout) {\n                $timeout.cancel(transitionTimeout);\n                transitionTimeout = null;\n              }\n            }\n\n            function createTooltip() {\n              // There can only be one tooltip element per directive shown at once.\n              if (tooltip) {\n                return;\n              }\n\n              tooltipLinkedScope = ttScope.$new();\n              tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {\n                if (appendToBody) {\n                  $document.find('body').append(tooltip);\n                } else {\n                  element.after(tooltip);\n                }\n              });\n\n              prepObservers();\n            }\n\n            function removeTooltip() {\n              cancelShow();\n              cancelHide();\n              unregisterObservers();\n\n              if (tooltip) {\n                tooltip.remove();\n                tooltip = null;\n              }\n              if (tooltipLinkedScope) {\n                tooltipLinkedScope.$destroy();\n                tooltipLinkedScope = null;\n              }\n            }\n\n            /**\n             * Set the initial scope values. Once\n             * the tooltip is created, the observers\n             * will be added to keep things in sync.\n             */\n            function prepareTooltip() {\n              ttScope.title = attrs[prefix + 'Title'];\n              if (contentParse) {\n                ttScope.content = contentParse(scope);\n              } else {\n                ttScope.content = attrs[ttType];\n              }\n\n              ttScope.popupClass = attrs[prefix + 'Class'];\n              ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n              var placement = $position.parsePlacement(ttScope.placement);\n              lastPlacement = placement[1] ? placement[0] + '-' + placement[1] : placement[0];\n\n              var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n              var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n              ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n              ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n            }\n\n            function assignIsOpen(isOpen) {\n              if (isOpenParse && angular.isFunction(isOpenParse.assign)) {\n                isOpenParse.assign(scope, isOpen);\n              }\n            }\n\n            ttScope.contentExp = function() {\n              return ttScope.content;\n            };\n\n            /**\n             * Observe the relevant attributes.\n             */\n            attrs.$observe('disabled', function(val) {\n              if (val) {\n                cancelShow();\n              }\n\n              if (val && ttScope.isOpen) {\n                hide();\n              }\n            });\n\n            if (isOpenParse) {\n              scope.$watch(isOpenParse, function(val) {\n                if (ttScope && !val === ttScope.isOpen) {\n                  toggleTooltipBind();\n                }\n              });\n            }\n\n            function prepObservers() {\n              observers.length = 0;\n\n              if (contentParse) {\n                observers.push(\n                  scope.$watch(contentParse, function(val) {\n                    ttScope.content = val;\n                    if (!val && ttScope.isOpen) {\n                      hide();\n                    }\n                  })\n                );\n\n                observers.push(\n                  tooltipLinkedScope.$watch(function() {\n                    if (!repositionScheduled) {\n                      repositionScheduled = true;\n                      tooltipLinkedScope.$$postDigest(function() {\n                        repositionScheduled = false;\n                        if (ttScope && ttScope.isOpen) {\n                          positionTooltip();\n                        }\n                      });\n                    }\n                  })\n                );\n              } else {\n                observers.push(\n                  attrs.$observe(ttType, function(val) {\n                    ttScope.content = val;\n                    if (!val && ttScope.isOpen) {\n                      hide();\n                    } else {\n                      positionTooltip();\n                    }\n                  })\n                );\n              }\n\n              observers.push(\n                attrs.$observe(prefix + 'Title', function(val) {\n                  ttScope.title = val;\n                  if (ttScope.isOpen) {\n                    positionTooltip();\n                  }\n                })\n              );\n\n              observers.push(\n                attrs.$observe(prefix + 'Placement', function(val) {\n                  ttScope.placement = val ? val : options.placement;\n                  if (ttScope.isOpen) {\n                    positionTooltip();\n                  }\n                })\n              );\n            }\n\n            function unregisterObservers() {\n              if (observers.length) {\n                angular.forEach(observers, function(observer) {\n                  observer();\n                });\n                observers.length = 0;\n              }\n            }\n\n            // hide tooltips/popovers for outsideClick trigger\n            function bodyHideTooltipBind(e) {\n              if (!ttScope || !ttScope.isOpen || !tooltip) {\n                return;\n              }\n              // make sure the tooltip/popover link or tool tooltip/popover itself were not clicked\n              if (!element[0].contains(e.target) && !tooltip[0].contains(e.target)) {\n                hideTooltipBind();\n              }\n            }\n\n            var unregisterTriggers = function() {\n              triggers.show.forEach(function(trigger) {\n                if (trigger === 'outsideClick') {\n                  element.off('click', toggleTooltipBind);\n                } else {\n                  element.off(trigger, showTooltipBind);\n                  element.off(trigger, toggleTooltipBind);\n                }\n              });\n              triggers.hide.forEach(function(trigger) {\n                if (trigger === 'outsideClick') {\n                  $document.off('click', bodyHideTooltipBind);\n                } else {\n                  element.off(trigger, hideTooltipBind);\n                }\n              });\n            };\n\n            function prepTriggers() {\n              var val = attrs[prefix + 'Trigger'];\n              unregisterTriggers();\n\n              triggers = getTriggers(val);\n\n              if (triggers.show !== 'none') {\n                triggers.show.forEach(function(trigger, idx) {\n                  if (trigger === 'outsideClick') {\n                    element.on('click', toggleTooltipBind);\n                    $document.on('click', bodyHideTooltipBind);\n                  } else if (trigger === triggers.hide[idx]) {\n                    element.on(trigger, toggleTooltipBind);\n                  } else if (trigger) {\n                    element.on(trigger, showTooltipBind);\n                    element.on(triggers.hide[idx], hideTooltipBind);\n                  }\n\n                  element.on('keypress', function(e) {\n                    if (e.which === 27) {\n                      hideTooltipBind();\n                    }\n                  });\n                });\n              }\n            }\n\n            prepTriggers();\n\n            var animation = scope.$eval(attrs[prefix + 'Animation']);\n            ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;\n\n            var appendToBodyVal;\n            var appendKey = prefix + 'AppendToBody';\n            if (appendKey in attrs && attrs[appendKey] === undefined) {\n              appendToBodyVal = true;\n            } else {\n              appendToBodyVal = scope.$eval(attrs[appendKey]);\n            }\n\n            appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;\n\n            // Make sure tooltip is destroyed and removed.\n            scope.$on('$destroy', function onDestroyTooltip() {\n              unregisterTriggers();\n              removeTooltip();\n              openedTooltips.remove(ttScope);\n              ttScope = null;\n            });\n          };\n        }\n      };\n    };\n  }];\n})\n\n// This is mostly ngInclude code but with a custom scope\n.directive('uibTooltipTemplateTransclude', [\n         '$animate', '$sce', '$compile', '$templateRequest',\nfunction ($animate, $sce, $compile, $templateRequest) {\n  return {\n    link: function(scope, elem, attrs) {\n      var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);\n\n      var changeCounter = 0,\n        currentScope,\n        previousElement,\n        currentElement;\n\n      var cleanupLastIncludeContent = function() {\n        if (previousElement) {\n          previousElement.remove();\n          previousElement = null;\n        }\n\n        if (currentScope) {\n          currentScope.$destroy();\n          currentScope = null;\n        }\n\n        if (currentElement) {\n          $animate.leave(currentElement).then(function() {\n            previousElement = null;\n          });\n          previousElement = currentElement;\n          currentElement = null;\n        }\n      };\n\n      scope.$watch($sce.parseAsResourceUrl(attrs.uibTooltipTemplateTransclude), function(src) {\n        var thisChangeId = ++changeCounter;\n\n        if (src) {\n          //set the 2nd param to true to ignore the template request error so that the inner\n          //contents and scope can be cleaned up.\n          $templateRequest(src, true).then(function(response) {\n            if (thisChangeId !== changeCounter) { return; }\n            var newScope = origScope.$new();\n            var template = response;\n\n            var clone = $compile(template)(newScope, function(clone) {\n              cleanupLastIncludeContent();\n              $animate.enter(clone, elem);\n            });\n\n            currentScope = newScope;\n            currentElement = clone;\n\n            currentScope.$emit('$includeContentLoaded', src);\n          }, function() {\n            if (thisChangeId === changeCounter) {\n              cleanupLastIncludeContent();\n              scope.$emit('$includeContentError', src);\n            }\n          });\n          scope.$emit('$includeContentRequested', src);\n        } else {\n          cleanupLastIncludeContent();\n        }\n      });\n\n      scope.$on('$destroy', cleanupLastIncludeContent);\n    }\n  };\n}])\n\n/**\n * Note that it's intentional that these classes are *not* applied through $animate.\n * They must not be animated as they're expected to be present on the tooltip on\n * initialization.\n */\n.directive('uibTooltipClasses', ['$uibPosition', function($uibPosition) {\n  return {\n    restrict: 'A',\n    link: function(scope, element, attrs) {\n      // need to set the primary position so the\n      // arrow has space during position measure.\n      // tooltip.positionTooltip()\n      if (scope.placement) {\n        // // There are no top-left etc... classes\n        // // in TWBS, so we need the primary position.\n        var position = $uibPosition.parsePlacement(scope.placement);\n        element.addClass(position[0]);\n      }\n\n      if (scope.popupClass) {\n        element.addClass(scope.popupClass);\n      }\n\n      if (scope.animation()) {\n        element.addClass(attrs.tooltipAnimationClass);\n      }\n    }\n  };\n}])\n\n.directive('uibTooltipPopup', function() {\n  return {\n    replace: true,\n    scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },\n    templateUrl: 'uib/template/tooltip/tooltip-popup.html'\n  };\n})\n\n.directive('uibTooltip', [ '$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibTooltip', 'tooltip', 'mouseenter');\n}])\n\n.directive('uibTooltipTemplatePopup', function() {\n  return {\n    replace: true,\n    scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',\n      originScope: '&' },\n    templateUrl: 'uib/template/tooltip/tooltip-template-popup.html'\n  };\n})\n\n.directive('uibTooltipTemplate', ['$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibTooltipTemplate', 'tooltip', 'mouseenter', {\n    useContentExp: true\n  });\n}])\n\n.directive('uibTooltipHtmlPopup', function() {\n  return {\n    replace: true,\n    scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },\n    templateUrl: 'uib/template/tooltip/tooltip-html-popup.html'\n  };\n})\n\n.directive('uibTooltipHtml', ['$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibTooltipHtml', 'tooltip', 'mouseenter', {\n    useContentExp: true\n  });\n}]);\n\n/**\n * The following features are still outstanding: popup delay, animation as a\n * function, placement as a function, inside, support for more triggers than\n * just mouse enter/leave, and selector delegatation.\n */\nangular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])\n\n.directive('uibPopoverTemplatePopup', function() {\n  return {\n    replace: true,\n    scope: { uibTitle: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',\n      originScope: '&' },\n    templateUrl: 'uib/template/popover/popover-template.html'\n  };\n})\n\n.directive('uibPopoverTemplate', ['$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibPopoverTemplate', 'popover', 'click', {\n    useContentExp: true\n  });\n}])\n\n.directive('uibPopoverHtmlPopup', function() {\n  return {\n    replace: true,\n    scope: { contentExp: '&', uibTitle: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },\n    templateUrl: 'uib/template/popover/popover-html.html'\n  };\n})\n\n.directive('uibPopoverHtml', ['$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibPopoverHtml', 'popover', 'click', {\n    useContentExp: true\n  });\n}])\n\n.directive('uibPopoverPopup', function() {\n  return {\n    replace: true,\n    scope: { uibTitle: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },\n    templateUrl: 'uib/template/popover/popover.html'\n  };\n})\n\n.directive('uibPopover', ['$uibTooltip', function($uibTooltip) {\n  return $uibTooltip('uibPopover', 'popover', 'click');\n}]);\n\nangular.module('ui.bootstrap.progressbar', [])\n\n.constant('uibProgressConfig', {\n  animate: true,\n  max: 100\n})\n\n.controller('UibProgressController', ['$scope', '$attrs', 'uibProgressConfig', function($scope, $attrs, progressConfig) {\n  var self = this,\n      animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;\n\n  this.bars = [];\n  $scope.max = getMaxOrDefault();\n\n  this.addBar = function(bar, element, attrs) {\n    if (!animate) {\n      element.css({'transition': 'none'});\n    }\n\n    this.bars.push(bar);\n\n    bar.max = getMaxOrDefault();\n    bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';\n\n    bar.$watch('value', function(value) {\n      bar.recalculatePercentage();\n    });\n\n    bar.recalculatePercentage = function() {\n      var totalPercentage = self.bars.reduce(function(total, bar) {\n        bar.percent = +(100 * bar.value / bar.max).toFixed(2);\n        return total + bar.percent;\n      }, 0);\n\n      if (totalPercentage > 100) {\n        bar.percent -= totalPercentage - 100;\n      }\n    };\n\n    bar.$on('$destroy', function() {\n      element = null;\n      self.removeBar(bar);\n    });\n  };\n\n  this.removeBar = function(bar) {\n    this.bars.splice(this.bars.indexOf(bar), 1);\n    this.bars.forEach(function (bar) {\n      bar.recalculatePercentage();\n    });\n  };\n\n  //$attrs.$observe('maxParam', function(maxParam) {\n  $scope.$watch('maxParam', function(maxParam) {\n    self.bars.forEach(function(bar) {\n      bar.max = getMaxOrDefault();\n      bar.recalculatePercentage();\n    });\n  });\n\n  function getMaxOrDefault () {\n    return angular.isDefined($scope.maxParam) ? $scope.maxParam : progressConfig.max;\n  }\n}])\n\n.directive('uibProgress', function() {\n  return {\n    replace: true,\n    transclude: true,\n    controller: 'UibProgressController',\n    require: 'uibProgress',\n    scope: {\n      maxParam: '=?max'\n    },\n    templateUrl: 'uib/template/progressbar/progress.html'\n  };\n})\n\n.directive('uibBar', function() {\n  return {\n    replace: true,\n    transclude: true,\n    require: '^uibProgress',\n    scope: {\n      value: '=',\n      type: '@'\n    },\n    templateUrl: 'uib/template/progressbar/bar.html',\n    link: function(scope, element, attrs, progressCtrl) {\n      progressCtrl.addBar(scope, element, attrs);\n    }\n  };\n})\n\n.directive('uibProgressbar', function() {\n  return {\n    replace: true,\n    transclude: true,\n    controller: 'UibProgressController',\n    scope: {\n      value: '=',\n      maxParam: '=?max',\n      type: '@'\n    },\n    templateUrl: 'uib/template/progressbar/progressbar.html',\n    link: function(scope, element, attrs, progressCtrl) {\n      progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});\n    }\n  };\n});\n\nangular.module('ui.bootstrap.rating', [])\n\n.constant('uibRatingConfig', {\n  max: 5,\n  stateOn: null,\n  stateOff: null,\n  enableReset: true,\n  titles : ['one', 'two', 'three', 'four', 'five']\n})\n\n.controller('UibRatingController', ['$scope', '$attrs', 'uibRatingConfig', function($scope, $attrs, ratingConfig) {\n  var ngModelCtrl = { $setViewValue: angular.noop },\n    self = this;\n\n  this.init = function(ngModelCtrl_) {\n    ngModelCtrl = ngModelCtrl_;\n    ngModelCtrl.$render = this.render;\n\n    ngModelCtrl.$formatters.push(function(value) {\n      if (angular.isNumber(value) && value << 0 !== value) {\n        value = Math.round(value);\n      }\n\n      return value;\n    });\n\n    this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;\n    this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;\n    this.enableReset = angular.isDefined($attrs.enableReset) ?\n      $scope.$parent.$eval($attrs.enableReset) : ratingConfig.enableReset;\n    var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles;\n    this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ?\n      tmpTitles : ratingConfig.titles;\n\n    var ratingStates = angular.isDefined($attrs.ratingStates) ?\n      $scope.$parent.$eval($attrs.ratingStates) :\n      new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);\n    $scope.range = this.buildTemplateObjects(ratingStates);\n  };\n\n  this.buildTemplateObjects = function(states) {\n    for (var i = 0, n = states.length; i < n; i++) {\n      states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff, title: this.getTitle(i) }, states[i]);\n    }\n    return states;\n  };\n\n  this.getTitle = function(index) {\n    if (index >= this.titles.length) {\n      return index + 1;\n    }\n\n    return this.titles[index];\n  };\n\n  $scope.rate = function(value) {\n    if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {\n      var newViewValue = self.enableReset && ngModelCtrl.$viewValue === value ? 0 : value;\n      ngModelCtrl.$setViewValue(newViewValue);\n      ngModelCtrl.$render();\n    }\n  };\n\n  $scope.enter = function(value) {\n    if (!$scope.readonly) {\n      $scope.value = value;\n    }\n    $scope.onHover({value: value});\n  };\n\n  $scope.reset = function() {\n    $scope.value = ngModelCtrl.$viewValue;\n    $scope.onLeave();\n  };\n\n  $scope.onKeydown = function(evt) {\n    if (/(37|38|39|40)/.test(evt.which)) {\n      evt.preventDefault();\n      evt.stopPropagation();\n      $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));\n    }\n  };\n\n  this.render = function() {\n    $scope.value = ngModelCtrl.$viewValue;\n    $scope.title = self.getTitle($scope.value - 1);\n  };\n}])\n\n.directive('uibRating', function() {\n  return {\n    require: ['uibRating', 'ngModel'],\n    scope: {\n      readonly: '=?readOnly',\n      onHover: '&',\n      onLeave: '&'\n    },\n    controller: 'UibRatingController',\n    templateUrl: 'uib/template/rating/rating.html',\n    replace: true,\n    link: function(scope, element, attrs, ctrls) {\n      var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n      ratingCtrl.init(ngModelCtrl);\n    }\n  };\n});\n\nangular.module('ui.bootstrap.tabs', [])\n\n.controller('UibTabsetController', ['$scope', function ($scope) {\n  var ctrl = this,\n    oldIndex;\n  ctrl.tabs = [];\n\n  ctrl.select = function(index, evt) {\n    if (!destroyed) {\n      var previousIndex = findTabIndex(oldIndex);\n      var previousSelected = ctrl.tabs[previousIndex];\n      if (previousSelected) {\n        previousSelected.tab.onDeselect({\n          $event: evt\n        });\n        if (evt && evt.isDefaultPrevented()) {\n          return;\n        }\n        previousSelected.tab.active = false;\n      }\n\n      var selected = ctrl.tabs[index];\n      if (selected) {\n        selected.tab.onSelect({\n          $event: evt\n        });\n        selected.tab.active = true;\n        ctrl.active = selected.index;\n        oldIndex = selected.index;\n      } else if (!selected && angular.isNumber(oldIndex)) {\n        ctrl.active = null;\n        oldIndex = null;\n      }\n    }\n  };\n\n  ctrl.addTab = function addTab(tab) {\n    ctrl.tabs.push({\n      tab: tab,\n      index: tab.index\n    });\n    ctrl.tabs.sort(function(t1, t2) {\n      if (t1.index > t2.index) {\n        return 1;\n      }\n\n      if (t1.index < t2.index) {\n        return -1;\n      }\n\n      return 0;\n    });\n\n    if (tab.index === ctrl.active || !angular.isNumber(ctrl.active) && ctrl.tabs.length === 1) {\n      var newActiveIndex = findTabIndex(tab.index);\n      ctrl.select(newActiveIndex);\n    }\n  };\n\n  ctrl.removeTab = function removeTab(tab) {\n    var index;\n    for (var i = 0; i < ctrl.tabs.length; i++) {\n      if (ctrl.tabs[i].tab === tab) {\n        index = i;\n        break;\n      }\n    }\n\n    if (ctrl.tabs[index].index === ctrl.active) {\n      var newActiveTabIndex = index === ctrl.tabs.length - 1 ?\n        index - 1 : index + 1 % ctrl.tabs.length;\n      ctrl.select(newActiveTabIndex);\n    }\n\n    ctrl.tabs.splice(index, 1);\n  };\n\n  $scope.$watch('tabset.active', function(val) {\n    if (angular.isNumber(val) && val !== oldIndex) {\n      ctrl.select(findTabIndex(val));\n    }\n  });\n\n  var destroyed;\n  $scope.$on('$destroy', function() {\n    destroyed = true;\n  });\n\n  function findTabIndex(index) {\n    for (var i = 0; i < ctrl.tabs.length; i++) {\n      if (ctrl.tabs[i].index === index) {\n        return i;\n      }\n    }\n  }\n}])\n\n.directive('uibTabset', function() {\n  return {\n    transclude: true,\n    replace: true,\n    scope: {},\n    bindToController: {\n      active: '=?',\n      type: '@'\n    },\n    controller: 'UibTabsetController',\n    controllerAs: 'tabset',\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/tabs/tabset.html';\n    },\n    link: function(scope, element, attrs) {\n      scope.vertical = angular.isDefined(attrs.vertical) ?\n        scope.$parent.$eval(attrs.vertical) : false;\n      scope.justified = angular.isDefined(attrs.justified) ?\n        scope.$parent.$eval(attrs.justified) : false;\n      if (angular.isUndefined(attrs.active)) {\n        scope.active = 0;\n      }\n    }\n  };\n})\n\n.directive('uibTab', ['$parse', function($parse) {\n  return {\n    require: '^uibTabset',\n    replace: true,\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || 'uib/template/tabs/tab.html';\n    },\n    transclude: true,\n    scope: {\n      heading: '@',\n      index: '=?',\n      classes: '@?',\n      onSelect: '&select', //This callback is called in contentHeadingTransclude\n                          //once it inserts the tab's content into the dom\n      onDeselect: '&deselect'\n    },\n    controller: function() {\n      //Empty controller so other directives can require being 'under' a tab\n    },\n    controllerAs: 'tab',\n    link: function(scope, elm, attrs, tabsetCtrl, transclude) {\n      scope.disabled = false;\n      if (attrs.disable) {\n        scope.$parent.$watch($parse(attrs.disable), function(value) {\n          scope.disabled = !! value;\n        });\n      }\n\n      if (angular.isUndefined(attrs.index)) {\n        if (tabsetCtrl.tabs && tabsetCtrl.tabs.length) {\n          scope.index = Math.max.apply(null, tabsetCtrl.tabs.map(function(t) { return t.index; })) + 1;\n        } else {\n          scope.index = 0;\n        }\n      }\n\n      if (angular.isUndefined(attrs.classes)) {\n        scope.classes = '';\n      }\n\n      scope.select = function(evt) {\n        if (!scope.disabled) {\n          var index;\n          for (var i = 0; i < tabsetCtrl.tabs.length; i++) {\n            if (tabsetCtrl.tabs[i].tab === scope) {\n              index = i;\n              break;\n            }\n          }\n\n          tabsetCtrl.select(index, evt);\n        }\n      };\n\n      tabsetCtrl.addTab(scope);\n      scope.$on('$destroy', function() {\n        tabsetCtrl.removeTab(scope);\n      });\n\n      //We need to transclude later, once the content container is ready.\n      //when this link happens, we're inside a tab heading.\n      scope.$transcludeFn = transclude;\n    }\n  };\n}])\n\n.directive('uibTabHeadingTransclude', function() {\n  return {\n    restrict: 'A',\n    require: '^uibTab',\n    link: function(scope, elm) {\n      scope.$watch('headingElement', function updateHeadingElement(heading) {\n        if (heading) {\n          elm.html('');\n          elm.append(heading);\n        }\n      });\n    }\n  };\n})\n\n.directive('uibTabContentTransclude', function() {\n  return {\n    restrict: 'A',\n    require: '^uibTabset',\n    link: function(scope, elm, attrs) {\n      var tab = scope.$eval(attrs.uibTabContentTransclude).tab;\n\n      //Now our tab is ready to be transcluded: both the tab heading area\n      //and the tab content area are loaded.  Transclude 'em both.\n      tab.$transcludeFn(tab.$parent, function(contents) {\n        angular.forEach(contents, function(node) {\n          if (isTabHeading(node)) {\n            //Let tabHeadingTransclude know.\n            tab.headingElement = node;\n          } else {\n            elm.append(node);\n          }\n        });\n      });\n    }\n  };\n\n  function isTabHeading(node) {\n    return node.tagName && (\n      node.hasAttribute('uib-tab-heading') ||\n      node.hasAttribute('data-uib-tab-heading') ||\n      node.hasAttribute('x-uib-tab-heading') ||\n      node.tagName.toLowerCase() === 'uib-tab-heading' ||\n      node.tagName.toLowerCase() === 'data-uib-tab-heading' ||\n      node.tagName.toLowerCase() === 'x-uib-tab-heading' ||\n      node.tagName.toLowerCase() === 'uib:tab-heading'\n    );\n  }\n});\n\nangular.module('ui.bootstrap.timepicker', [])\n\n.constant('uibTimepickerConfig', {\n  hourStep: 1,\n  minuteStep: 1,\n  secondStep: 1,\n  showMeridian: true,\n  showSeconds: false,\n  meridians: null,\n  readonlyInput: false,\n  mousewheel: true,\n  arrowkeys: true,\n  showSpinners: true,\n  templateUrl: 'uib/template/timepicker/timepicker.html'\n})\n\n.controller('UibTimepickerController', ['$scope', '$element', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $element, $attrs, $parse, $log, $locale, timepickerConfig) {\n  var selected = new Date(),\n    watchers = [],\n    ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl\n    meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS,\n    padHours = angular.isDefined($attrs.padHours) ? $scope.$parent.$eval($attrs.padHours) : true;\n\n  $scope.tabindex = angular.isDefined($attrs.tabindex) ? $attrs.tabindex : 0;\n  $element.removeAttr('tabindex');\n\n  this.init = function(ngModelCtrl_, inputs) {\n    ngModelCtrl = ngModelCtrl_;\n    ngModelCtrl.$render = this.render;\n\n    ngModelCtrl.$formatters.unshift(function(modelValue) {\n      return modelValue ? new Date(modelValue) : null;\n    });\n\n    var hoursInputEl = inputs.eq(0),\n        minutesInputEl = inputs.eq(1),\n        secondsInputEl = inputs.eq(2);\n\n    var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;\n\n    if (mousewheel) {\n      this.setupMousewheelEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n    }\n\n    var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys;\n    if (arrowkeys) {\n      this.setupArrowkeyEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n    }\n\n    $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;\n    this.setupInputEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n  };\n\n  var hourStep = timepickerConfig.hourStep;\n  if ($attrs.hourStep) {\n    watchers.push($scope.$parent.$watch($parse($attrs.hourStep), function(value) {\n      hourStep = +value;\n    }));\n  }\n\n  var minuteStep = timepickerConfig.minuteStep;\n  if ($attrs.minuteStep) {\n    watchers.push($scope.$parent.$watch($parse($attrs.minuteStep), function(value) {\n      minuteStep = +value;\n    }));\n  }\n\n  var min;\n  watchers.push($scope.$parent.$watch($parse($attrs.min), function(value) {\n    var dt = new Date(value);\n    min = isNaN(dt) ? undefined : dt;\n  }));\n\n  var max;\n  watchers.push($scope.$parent.$watch($parse($attrs.max), function(value) {\n    var dt = new Date(value);\n    max = isNaN(dt) ? undefined : dt;\n  }));\n\n  var disabled = false;\n  if ($attrs.ngDisabled) {\n    watchers.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(value) {\n      disabled = value;\n    }));\n  }\n\n  $scope.noIncrementHours = function() {\n    var incrementedSelected = addMinutes(selected, hourStep * 60);\n    return disabled || incrementedSelected > max ||\n      incrementedSelected < selected && incrementedSelected < min;\n  };\n\n  $scope.noDecrementHours = function() {\n    var decrementedSelected = addMinutes(selected, -hourStep * 60);\n    return disabled || decrementedSelected < min ||\n      decrementedSelected > selected && decrementedSelected > max;\n  };\n\n  $scope.noIncrementMinutes = function() {\n    var incrementedSelected = addMinutes(selected, minuteStep);\n    return disabled || incrementedSelected > max ||\n      incrementedSelected < selected && incrementedSelected < min;\n  };\n\n  $scope.noDecrementMinutes = function() {\n    var decrementedSelected = addMinutes(selected, -minuteStep);\n    return disabled || decrementedSelected < min ||\n      decrementedSelected > selected && decrementedSelected > max;\n  };\n\n  $scope.noIncrementSeconds = function() {\n    var incrementedSelected = addSeconds(selected, secondStep);\n    return disabled || incrementedSelected > max ||\n      incrementedSelected < selected && incrementedSelected < min;\n  };\n\n  $scope.noDecrementSeconds = function() {\n    var decrementedSelected = addSeconds(selected, -secondStep);\n    return disabled || decrementedSelected < min ||\n      decrementedSelected > selected && decrementedSelected > max;\n  };\n\n  $scope.noToggleMeridian = function() {\n    if (selected.getHours() < 12) {\n      return disabled || addMinutes(selected, 12 * 60) > max;\n    }\n\n    return disabled || addMinutes(selected, -12 * 60) < min;\n  };\n\n  var secondStep = timepickerConfig.secondStep;\n  if ($attrs.secondStep) {\n    watchers.push($scope.$parent.$watch($parse($attrs.secondStep), function(value) {\n      secondStep = +value;\n    }));\n  }\n\n  $scope.showSeconds = timepickerConfig.showSeconds;\n  if ($attrs.showSeconds) {\n    watchers.push($scope.$parent.$watch($parse($attrs.showSeconds), function(value) {\n      $scope.showSeconds = !!value;\n    }));\n  }\n\n  // 12H / 24H mode\n  $scope.showMeridian = timepickerConfig.showMeridian;\n  if ($attrs.showMeridian) {\n    watchers.push($scope.$parent.$watch($parse($attrs.showMeridian), function(value) {\n      $scope.showMeridian = !!value;\n\n      if (ngModelCtrl.$error.time) {\n        // Evaluate from template\n        var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate();\n        if (angular.isDefined(hours) && angular.isDefined(minutes)) {\n          selected.setHours(hours);\n          refresh();\n        }\n      } else {\n        updateTemplate();\n      }\n    }));\n  }\n\n  // Get $scope.hours in 24H mode if valid\n  function getHoursFromTemplate() {\n    var hours = +$scope.hours;\n    var valid = $scope.showMeridian ? hours > 0 && hours < 13 :\n      hours >= 0 && hours < 24;\n    if (!valid || $scope.hours === '') {\n      return undefined;\n    }\n\n    if ($scope.showMeridian) {\n      if (hours === 12) {\n        hours = 0;\n      }\n      if ($scope.meridian === meridians[1]) {\n        hours = hours + 12;\n      }\n    }\n    return hours;\n  }\n\n  function getMinutesFromTemplate() {\n    var minutes = +$scope.minutes;\n    var valid = minutes >= 0 && minutes < 60;\n    if (!valid || $scope.minutes === '') {\n      return undefined;\n    }\n    return minutes;\n  }\n\n  function getSecondsFromTemplate() {\n    var seconds = +$scope.seconds;\n    return seconds >= 0 && seconds < 60 ? seconds : undefined;\n  }\n\n  function pad(value, noPad) {\n    if (value === null) {\n      return '';\n    }\n\n    return angular.isDefined(value) && value.toString().length < 2 && !noPad ?\n      '0' + value : value.toString();\n  }\n\n  // Respond on mousewheel spin\n  this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n    var isScrollingUp = function(e) {\n      if (e.originalEvent) {\n        e = e.originalEvent;\n      }\n      //pick correct delta variable depending on event\n      var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY;\n      return e.detail || delta > 0;\n    };\n\n    hoursInputEl.bind('mousewheel wheel', function(e) {\n      if (!disabled) {\n        $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours());\n      }\n      e.preventDefault();\n    });\n\n    minutesInputEl.bind('mousewheel wheel', function(e) {\n      if (!disabled) {\n        $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes());\n      }\n      e.preventDefault();\n    });\n\n     secondsInputEl.bind('mousewheel wheel', function(e) {\n      if (!disabled) {\n        $scope.$apply(isScrollingUp(e) ? $scope.incrementSeconds() : $scope.decrementSeconds());\n      }\n      e.preventDefault();\n    });\n  };\n\n  // Respond on up/down arrowkeys\n  this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n    hoursInputEl.bind('keydown', function(e) {\n      if (!disabled) {\n        if (e.which === 38) { // up\n          e.preventDefault();\n          $scope.incrementHours();\n          $scope.$apply();\n        } else if (e.which === 40) { // down\n          e.preventDefault();\n          $scope.decrementHours();\n          $scope.$apply();\n        }\n      }\n    });\n\n    minutesInputEl.bind('keydown', function(e) {\n      if (!disabled) {\n        if (e.which === 38) { // up\n          e.preventDefault();\n          $scope.incrementMinutes();\n          $scope.$apply();\n        } else if (e.which === 40) { // down\n          e.preventDefault();\n          $scope.decrementMinutes();\n          $scope.$apply();\n        }\n      }\n    });\n\n    secondsInputEl.bind('keydown', function(e) {\n      if (!disabled) {\n        if (e.which === 38) { // up\n          e.preventDefault();\n          $scope.incrementSeconds();\n          $scope.$apply();\n        } else if (e.which === 40) { // down\n          e.preventDefault();\n          $scope.decrementSeconds();\n          $scope.$apply();\n        }\n      }\n    });\n  };\n\n  this.setupInputEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n    if ($scope.readonlyInput) {\n      $scope.updateHours = angular.noop;\n      $scope.updateMinutes = angular.noop;\n      $scope.updateSeconds = angular.noop;\n      return;\n    }\n\n    var invalidate = function(invalidHours, invalidMinutes, invalidSeconds) {\n      ngModelCtrl.$setViewValue(null);\n      ngModelCtrl.$setValidity('time', false);\n      if (angular.isDefined(invalidHours)) {\n        $scope.invalidHours = invalidHours;\n      }\n\n      if (angular.isDefined(invalidMinutes)) {\n        $scope.invalidMinutes = invalidMinutes;\n      }\n\n      if (angular.isDefined(invalidSeconds)) {\n        $scope.invalidSeconds = invalidSeconds;\n      }\n    };\n\n    $scope.updateHours = function() {\n      var hours = getHoursFromTemplate(),\n        minutes = getMinutesFromTemplate();\n\n      ngModelCtrl.$setDirty();\n\n      if (angular.isDefined(hours) && angular.isDefined(minutes)) {\n        selected.setHours(hours);\n        selected.setMinutes(minutes);\n        if (selected < min || selected > max) {\n          invalidate(true);\n        } else {\n          refresh('h');\n        }\n      } else {\n        invalidate(true);\n      }\n    };\n\n    hoursInputEl.bind('blur', function(e) {\n      ngModelCtrl.$setTouched();\n      if (modelIsEmpty()) {\n        makeValid();\n      } else if ($scope.hours === null || $scope.hours === '') {\n        invalidate(true);\n      } else if (!$scope.invalidHours && $scope.hours < 10) {\n        $scope.$apply(function() {\n          $scope.hours = pad($scope.hours, !padHours);\n        });\n      }\n    });\n\n    $scope.updateMinutes = function() {\n      var minutes = getMinutesFromTemplate(),\n        hours = getHoursFromTemplate();\n\n      ngModelCtrl.$setDirty();\n\n      if (angular.isDefined(minutes) && angular.isDefined(hours)) {\n        selected.setHours(hours);\n        selected.setMinutes(minutes);\n        if (selected < min || selected > max) {\n          invalidate(undefined, true);\n        } else {\n          refresh('m');\n        }\n      } else {\n        invalidate(undefined, true);\n      }\n    };\n\n    minutesInputEl.bind('blur', function(e) {\n      ngModelCtrl.$setTouched();\n      if (modelIsEmpty()) {\n        makeValid();\n      } else if ($scope.minutes === null) {\n        invalidate(undefined, true);\n      } else if (!$scope.invalidMinutes && $scope.minutes < 10) {\n        $scope.$apply(function() {\n          $scope.minutes = pad($scope.minutes);\n        });\n      }\n    });\n\n    $scope.updateSeconds = function() {\n      var seconds = getSecondsFromTemplate();\n\n      ngModelCtrl.$setDirty();\n\n      if (angular.isDefined(seconds)) {\n        selected.setSeconds(seconds);\n        refresh('s');\n      } else {\n        invalidate(undefined, undefined, true);\n      }\n    };\n\n    secondsInputEl.bind('blur', function(e) {\n      if (modelIsEmpty()) {\n        makeValid();\n      } else if (!$scope.invalidSeconds && $scope.seconds < 10) {\n        $scope.$apply( function() {\n          $scope.seconds = pad($scope.seconds);\n        });\n      }\n    });\n\n  };\n\n  this.render = function() {\n    var date = ngModelCtrl.$viewValue;\n\n    if (isNaN(date)) {\n      ngModelCtrl.$setValidity('time', false);\n      $log.error('Timepicker directive: \"ng-model\" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');\n    } else {\n      if (date) {\n        selected = date;\n      }\n\n      if (selected < min || selected > max) {\n        ngModelCtrl.$setValidity('time', false);\n        $scope.invalidHours = true;\n        $scope.invalidMinutes = true;\n      } else {\n        makeValid();\n      }\n      updateTemplate();\n    }\n  };\n\n  // Call internally when we know that model is valid.\n  function refresh(keyboardChange) {\n    makeValid();\n    ngModelCtrl.$setViewValue(new Date(selected));\n    updateTemplate(keyboardChange);\n  }\n\n  function makeValid() {\n    ngModelCtrl.$setValidity('time', true);\n    $scope.invalidHours = false;\n    $scope.invalidMinutes = false;\n    $scope.invalidSeconds = false;\n  }\n\n  function updateTemplate(keyboardChange) {\n    if (!ngModelCtrl.$modelValue) {\n      $scope.hours = null;\n      $scope.minutes = null;\n      $scope.seconds = null;\n      $scope.meridian = meridians[0];\n    } else {\n      var hours = selected.getHours(),\n        minutes = selected.getMinutes(),\n        seconds = selected.getSeconds();\n\n      if ($scope.showMeridian) {\n        hours = hours === 0 || hours === 12 ? 12 : hours % 12; // Convert 24 to 12 hour system\n      }\n\n      $scope.hours = keyboardChange === 'h' ? hours : pad(hours, !padHours);\n      if (keyboardChange !== 'm') {\n        $scope.minutes = pad(minutes);\n      }\n      $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];\n\n      if (keyboardChange !== 's') {\n        $scope.seconds = pad(seconds);\n      }\n      $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];\n    }\n  }\n\n  function addSecondsToSelected(seconds) {\n    selected = addSeconds(selected, seconds);\n    refresh();\n  }\n\n  function addMinutes(selected, minutes) {\n    return addSeconds(selected, minutes*60);\n  }\n\n  function addSeconds(date, seconds) {\n    var dt = new Date(date.getTime() + seconds * 1000);\n    var newDate = new Date(date);\n    newDate.setHours(dt.getHours(), dt.getMinutes(), dt.getSeconds());\n    return newDate;\n  }\n\n  function modelIsEmpty() {\n    return ($scope.hours === null || $scope.hours === '') &&\n      ($scope.minutes === null || $scope.minutes === '') &&\n      (!$scope.showSeconds || $scope.showSeconds && ($scope.seconds === null || $scope.seconds === ''));\n  }\n\n  $scope.showSpinners = angular.isDefined($attrs.showSpinners) ?\n    $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners;\n\n  $scope.incrementHours = function() {\n    if (!$scope.noIncrementHours()) {\n      addSecondsToSelected(hourStep * 60 * 60);\n    }\n  };\n\n  $scope.decrementHours = function() {\n    if (!$scope.noDecrementHours()) {\n      addSecondsToSelected(-hourStep * 60 * 60);\n    }\n  };\n\n  $scope.incrementMinutes = function() {\n    if (!$scope.noIncrementMinutes()) {\n      addSecondsToSelected(minuteStep * 60);\n    }\n  };\n\n  $scope.decrementMinutes = function() {\n    if (!$scope.noDecrementMinutes()) {\n      addSecondsToSelected(-minuteStep * 60);\n    }\n  };\n\n  $scope.incrementSeconds = function() {\n    if (!$scope.noIncrementSeconds()) {\n      addSecondsToSelected(secondStep);\n    }\n  };\n\n  $scope.decrementSeconds = function() {\n    if (!$scope.noDecrementSeconds()) {\n      addSecondsToSelected(-secondStep);\n    }\n  };\n\n  $scope.toggleMeridian = function() {\n    var minutes = getMinutesFromTemplate(),\n        hours = getHoursFromTemplate();\n\n    if (!$scope.noToggleMeridian()) {\n      if (angular.isDefined(minutes) && angular.isDefined(hours)) {\n        addSecondsToSelected(12 * 60 * (selected.getHours() < 12 ? 60 : -60));\n      } else {\n        $scope.meridian = $scope.meridian === meridians[0] ? meridians[1] : meridians[0];\n      }\n    }\n  };\n\n  $scope.blur = function() {\n    ngModelCtrl.$setTouched();\n  };\n\n  $scope.$on('$destroy', function() {\n    while (watchers.length) {\n      watchers.shift()();\n    }\n  });\n}])\n\n.directive('uibTimepicker', ['uibTimepickerConfig', function(uibTimepickerConfig) {\n  return {\n    require: ['uibTimepicker', '?^ngModel'],\n    controller: 'UibTimepickerController',\n    controllerAs: 'timepicker',\n    replace: true,\n    scope: {},\n    templateUrl: function(element, attrs) {\n      return attrs.templateUrl || uibTimepickerConfig.templateUrl;\n    },\n    link: function(scope, element, attrs, ctrls) {\n      var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n      if (ngModelCtrl) {\n        timepickerCtrl.init(ngModelCtrl, element.find('input'));\n      }\n    }\n  };\n}]);\n\nangular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap.position'])\n\n/**\n * A helper service that can parse typeahead's syntax (string provided by users)\n * Extracted to a separate service for ease of unit testing\n */\n  .factory('uibTypeaheadParser', ['$parse', function($parse) {\n    //                      00000111000000000000022200000000000000003333333333333330000000000044000\n    var TYPEAHEAD_REGEXP = /^\\s*([\\s\\S]+?)(?:\\s+as\\s+([\\s\\S]+?))?\\s+for\\s+(?:([\\$\\w][\\$\\w\\d]*))\\s+in\\s+([\\s\\S]+?)$/;\n    return {\n      parse: function(input) {\n        var match = input.match(TYPEAHEAD_REGEXP);\n        if (!match) {\n          throw new Error(\n            'Expected typeahead specification in form of \"_modelValue_ (as _label_)? for _item_ in _collection_\"' +\n              ' but got \"' + input + '\".');\n        }\n\n        return {\n          itemName: match[3],\n          source: $parse(match[4]),\n          viewMapper: $parse(match[2] || match[1]),\n          modelMapper: $parse(match[1])\n        };\n      }\n    };\n  }])\n\n  .controller('UibTypeaheadController', ['$scope', '$element', '$attrs', '$compile', '$parse', '$q', '$timeout', '$document', '$window', '$rootScope', '$$debounce', '$uibPosition', 'uibTypeaheadParser',\n    function(originalScope, element, attrs, $compile, $parse, $q, $timeout, $document, $window, $rootScope, $$debounce, $position, typeaheadParser) {\n    var HOT_KEYS = [9, 13, 27, 38, 40];\n    var eventDebounceTime = 200;\n    var modelCtrl, ngModelOptions;\n    //SUPPORTED ATTRIBUTES (OPTIONS)\n\n    //minimal no of characters that needs to be entered before typeahead kicks-in\n    var minLength = originalScope.$eval(attrs.typeaheadMinLength);\n    if (!minLength && minLength !== 0) {\n      minLength = 1;\n    }\n\n    originalScope.$watch(attrs.typeaheadMinLength, function (newVal) {\n        minLength = !newVal && newVal !== 0 ? 1 : newVal;\n    });\n    \n    //minimal wait time after last character typed before typeahead kicks-in\n    var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;\n\n    //should it restrict model values to the ones selected from the popup only?\n    var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;\n    originalScope.$watch(attrs.typeaheadEditable, function (newVal) {\n      isEditable = newVal !== false;\n    });\n\n    //binding to a variable that indicates if matches are being retrieved asynchronously\n    var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;\n\n    //a callback executed when a match is selected\n    var onSelectCallback = $parse(attrs.typeaheadOnSelect);\n\n    //should it select highlighted popup value when losing focus?\n    var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false;\n\n    //binding to a variable that indicates if there were no results after the query is completed\n    var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop;\n\n    var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;\n\n    var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;\n\n    var appendTo = attrs.typeaheadAppendTo ?\n      originalScope.$eval(attrs.typeaheadAppendTo) : null;\n\n    var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;\n\n    //If input matches an item of the list exactly, select it automatically\n    var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false;\n\n    //binding to a variable that indicates if dropdown is open\n    var isOpenSetter = $parse(attrs.typeaheadIsOpen).assign || angular.noop;\n\n    var showHint = originalScope.$eval(attrs.typeaheadShowHint) || false;\n\n    //INTERNAL VARIABLES\n\n    //model setter executed upon match selection\n    var parsedModel = $parse(attrs.ngModel);\n    var invokeModelSetter = $parse(attrs.ngModel + '($$$p)');\n    var $setModelValue = function(scope, newValue) {\n      if (angular.isFunction(parsedModel(originalScope)) &&\n        ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) {\n        return invokeModelSetter(scope, {$$$p: newValue});\n      }\n\n      return parsedModel.assign(scope, newValue);\n    };\n\n    //expressions used by typeahead\n    var parserResult = typeaheadParser.parse(attrs.uibTypeahead);\n\n    var hasFocus;\n\n    //Used to avoid bug in iOS webview where iOS keyboard does not fire\n    //mousedown & mouseup events\n    //Issue #3699\n    var selected;\n\n    //create a child scope for the typeahead directive so we are not polluting original scope\n    //with typeahead-specific data (matches, query etc.)\n    var scope = originalScope.$new();\n    var offDestroy = originalScope.$on('$destroy', function() {\n      scope.$destroy();\n    });\n    scope.$on('$destroy', offDestroy);\n\n    // WAI-ARIA\n    var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);\n    element.attr({\n      'aria-autocomplete': 'list',\n      'aria-expanded': false,\n      'aria-owns': popupId\n    });\n\n    var inputsContainer, hintInputElem;\n    //add read-only input to show hint\n    if (showHint) {\n      inputsContainer = angular.element('<div></div>');\n      inputsContainer.css('position', 'relative');\n      element.after(inputsContainer);\n      hintInputElem = element.clone();\n      hintInputElem.attr('placeholder', '');\n      hintInputElem.attr('tabindex', '-1');\n      hintInputElem.val('');\n      hintInputElem.css({\n        'position': 'absolute',\n        'top': '0px',\n        'left': '0px',\n        'border-color': 'transparent',\n        'box-shadow': 'none',\n        'opacity': 1,\n        'background': 'none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255)',\n        'color': '#999'\n      });\n      element.css({\n        'position': 'relative',\n        'vertical-align': 'top',\n        'background-color': 'transparent'\n      });\n      inputsContainer.append(hintInputElem);\n      hintInputElem.after(element);\n    }\n\n    //pop-up element used to display matches\n    var popUpEl = angular.element('<div uib-typeahead-popup></div>');\n    popUpEl.attr({\n      id: popupId,\n      matches: 'matches',\n      active: 'activeIdx',\n      select: 'select(activeIdx, evt)',\n      'move-in-progress': 'moveInProgress',\n      query: 'query',\n      position: 'position',\n      'assign-is-open': 'assignIsOpen(isOpen)',\n      debounce: 'debounceUpdate'\n    });\n    //custom item template\n    if (angular.isDefined(attrs.typeaheadTemplateUrl)) {\n      popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);\n    }\n\n    if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) {\n      popUpEl.attr('popup-template-url', attrs.typeaheadPopupTemplateUrl);\n    }\n\n    var resetHint = function() {\n      if (showHint) {\n        hintInputElem.val('');\n      }\n    };\n\n    var resetMatches = function() {\n      scope.matches = [];\n      scope.activeIdx = -1;\n      element.attr('aria-expanded', false);\n      resetHint();\n    };\n\n    var getMatchId = function(index) {\n      return popupId + '-option-' + index;\n    };\n\n    // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.\n    // This attribute is added or removed automatically when the `activeIdx` changes.\n    scope.$watch('activeIdx', function(index) {\n      if (index < 0) {\n        element.removeAttr('aria-activedescendant');\n      } else {\n        element.attr('aria-activedescendant', getMatchId(index));\n      }\n    });\n\n    var inputIsExactMatch = function(inputValue, index) {\n      if (scope.matches.length > index && inputValue) {\n        return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase();\n      }\n\n      return false;\n    };\n\n    var getMatchesAsync = function(inputValue, evt) {\n      var locals = {$viewValue: inputValue};\n      isLoadingSetter(originalScope, true);\n      isNoResultsSetter(originalScope, false);\n      $q.when(parserResult.source(originalScope, locals)).then(function(matches) {\n        //it might happen that several async queries were in progress if a user were typing fast\n        //but we are interested only in responses that correspond to the current view value\n        var onCurrentRequest = inputValue === modelCtrl.$viewValue;\n        if (onCurrentRequest && hasFocus) {\n          if (matches && matches.length > 0) {\n            scope.activeIdx = focusFirst ? 0 : -1;\n            isNoResultsSetter(originalScope, false);\n            scope.matches.length = 0;\n\n            //transform labels\n            for (var i = 0; i < matches.length; i++) {\n              locals[parserResult.itemName] = matches[i];\n              scope.matches.push({\n                id: getMatchId(i),\n                label: parserResult.viewMapper(scope, locals),\n                model: matches[i]\n              });\n            }\n\n            scope.query = inputValue;\n            //position pop-up with matches - we need to re-calculate its position each time we are opening a window\n            //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page\n            //due to other elements being rendered\n            recalculatePosition();\n\n            element.attr('aria-expanded', true);\n\n            //Select the single remaining option if user input matches\n            if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) {\n              if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {\n                $$debounce(function() {\n                  scope.select(0, evt);\n                }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);\n              } else {\n                scope.select(0, evt);\n              }\n            }\n\n            if (showHint) {\n              var firstLabel = scope.matches[0].label;\n              if (angular.isString(inputValue) &&\n                inputValue.length > 0 &&\n                firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) {\n                hintInputElem.val(inputValue + firstLabel.slice(inputValue.length));\n              } else {\n                hintInputElem.val('');\n              }\n            }\n          } else {\n            resetMatches();\n            isNoResultsSetter(originalScope, true);\n          }\n        }\n        if (onCurrentRequest) {\n          isLoadingSetter(originalScope, false);\n        }\n      }, function() {\n        resetMatches();\n        isLoadingSetter(originalScope, false);\n        isNoResultsSetter(originalScope, true);\n      });\n    };\n\n    // bind events only if appendToBody params exist - performance feature\n    if (appendToBody) {\n      angular.element($window).on('resize', fireRecalculating);\n      $document.find('body').on('scroll', fireRecalculating);\n    }\n\n    // Declare the debounced function outside recalculating for\n    // proper debouncing\n    var debouncedRecalculate = $$debounce(function() {\n      // if popup is visible\n      if (scope.matches.length) {\n        recalculatePosition();\n      }\n\n      scope.moveInProgress = false;\n    }, eventDebounceTime);\n\n    // Default progress type\n    scope.moveInProgress = false;\n\n    function fireRecalculating() {\n      if (!scope.moveInProgress) {\n        scope.moveInProgress = true;\n        scope.$digest();\n      }\n\n      debouncedRecalculate();\n    }\n\n    // recalculate actual position and set new values to scope\n    // after digest loop is popup in right position\n    function recalculatePosition() {\n      scope.position = appendToBody ? $position.offset(element) : $position.position(element);\n      scope.position.top += element.prop('offsetHeight');\n    }\n\n    //we need to propagate user's query so we can higlight matches\n    scope.query = undefined;\n\n    //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later\n    var timeoutPromise;\n\n    var scheduleSearchWithTimeout = function(inputValue) {\n      timeoutPromise = $timeout(function() {\n        getMatchesAsync(inputValue);\n      }, waitTime);\n    };\n\n    var cancelPreviousTimeout = function() {\n      if (timeoutPromise) {\n        $timeout.cancel(timeoutPromise);\n      }\n    };\n\n    resetMatches();\n\n    scope.assignIsOpen = function (isOpen) {\n      isOpenSetter(originalScope, isOpen);\n    };\n\n    scope.select = function(activeIdx, evt) {\n      //called from within the $digest() cycle\n      var locals = {};\n      var model, item;\n\n      selected = true;\n      locals[parserResult.itemName] = item = scope.matches[activeIdx].model;\n      model = parserResult.modelMapper(originalScope, locals);\n      $setModelValue(originalScope, model);\n      modelCtrl.$setValidity('editable', true);\n      modelCtrl.$setValidity('parse', true);\n\n      onSelectCallback(originalScope, {\n        $item: item,\n        $model: model,\n        $label: parserResult.viewMapper(originalScope, locals),\n        $event: evt\n      });\n\n      resetMatches();\n\n      //return focus to the input element if a match was selected via a mouse click event\n      // use timeout to avoid $rootScope:inprog error\n      if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) {\n        $timeout(function() { element[0].focus(); }, 0, false);\n      }\n    };\n\n    //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)\n    element.on('keydown', function(evt) {\n      //typeahead is open and an \"interesting\" key was pressed\n      if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {\n        return;\n      }\n\n      /**\n       * if there's nothing selected (i.e. focusFirst) and enter or tab is hit\n       * or\n       * shift + tab is pressed to bring focus to the previous element\n       * then clear the results\n       */\n      if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13) || evt.which === 9 && !!evt.shiftKey) {\n        resetMatches();\n        scope.$digest();\n        return;\n      }\n\n      evt.preventDefault();\n      var target;\n      switch (evt.which) {\n        case 9:\n        case 13:\n          scope.$apply(function () {\n            if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {\n              $$debounce(function() {\n                scope.select(scope.activeIdx, evt);\n              }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);\n            } else {\n              scope.select(scope.activeIdx, evt);\n            }\n          });\n          break;\n        case 27:\n          evt.stopPropagation();\n\n          resetMatches();\n          originalScope.$digest();\n          break;\n        case 38:\n          scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;\n          scope.$digest();\n          target = popUpEl.find('li')[scope.activeIdx];\n          target.parentNode.scrollTop = target.offsetTop;\n          break;\n        case 40:\n          scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;\n          scope.$digest();\n          target = popUpEl.find('li')[scope.activeIdx];\n          target.parentNode.scrollTop = target.offsetTop;\n          break;\n      }\n    });\n\n    element.bind('focus', function (evt) {\n      hasFocus = true;\n      if (minLength === 0 && !modelCtrl.$viewValue) {\n        $timeout(function() {\n          getMatchesAsync(modelCtrl.$viewValue, evt);\n        }, 0);\n      }\n    });\n\n    element.bind('blur', function(evt) {\n      if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {\n        selected = true;\n        scope.$apply(function() {\n          if (angular.isObject(scope.debounceUpdate) && angular.isNumber(scope.debounceUpdate.blur)) {\n            $$debounce(function() {\n              scope.select(scope.activeIdx, evt);\n            }, scope.debounceUpdate.blur);\n          } else {\n            scope.select(scope.activeIdx, evt);\n          }\n        });\n      }\n      if (!isEditable && modelCtrl.$error.editable) {\n        modelCtrl.$setViewValue();\n        // Reset validity as we are clearing\n        modelCtrl.$setValidity('editable', true);\n        modelCtrl.$setValidity('parse', true);\n        element.val('');\n      }\n      hasFocus = false;\n      selected = false;\n    });\n\n    // Keep reference to click handler to unbind it.\n    var dismissClickHandler = function(evt) {\n      // Issue #3973\n      // Firefox treats right click as a click on document\n      if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) {\n        resetMatches();\n        if (!$rootScope.$$phase) {\n          originalScope.$digest();\n        }\n      }\n    };\n\n    $document.on('click', dismissClickHandler);\n\n    originalScope.$on('$destroy', function() {\n      $document.off('click', dismissClickHandler);\n      if (appendToBody || appendTo) {\n        $popup.remove();\n      }\n\n      if (appendToBody) {\n        angular.element($window).off('resize', fireRecalculating);\n        $document.find('body').off('scroll', fireRecalculating);\n      }\n      // Prevent jQuery cache memory leak\n      popUpEl.remove();\n\n      if (showHint) {\n          inputsContainer.remove();\n      }\n    });\n\n    var $popup = $compile(popUpEl)(scope);\n\n    if (appendToBody) {\n      $document.find('body').append($popup);\n    } else if (appendTo) {\n      angular.element(appendTo).eq(0).append($popup);\n    } else {\n      element.after($popup);\n    }\n\n    this.init = function(_modelCtrl, _ngModelOptions) {\n      modelCtrl = _modelCtrl;\n      ngModelOptions = _ngModelOptions;\n\n      scope.debounceUpdate = modelCtrl.$options && $parse(modelCtrl.$options.debounce)(originalScope);\n\n      //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM\n      //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue\n      modelCtrl.$parsers.unshift(function(inputValue) {\n        hasFocus = true;\n\n        if (minLength === 0 || inputValue && inputValue.length >= minLength) {\n          if (waitTime > 0) {\n            cancelPreviousTimeout();\n            scheduleSearchWithTimeout(inputValue);\n          } else {\n            getMatchesAsync(inputValue);\n          }\n        } else {\n          isLoadingSetter(originalScope, false);\n          cancelPreviousTimeout();\n          resetMatches();\n        }\n\n        if (isEditable) {\n          return inputValue;\n        }\n\n        if (!inputValue) {\n          // Reset in case user had typed something previously.\n          modelCtrl.$setValidity('editable', true);\n          return null;\n        }\n\n        modelCtrl.$setValidity('editable', false);\n        return undefined;\n      });\n\n      modelCtrl.$formatters.push(function(modelValue) {\n        var candidateViewValue, emptyViewValue;\n        var locals = {};\n\n        // The validity may be set to false via $parsers (see above) if\n        // the model is restricted to selected values. If the model\n        // is set manually it is considered to be valid.\n        if (!isEditable) {\n          modelCtrl.$setValidity('editable', true);\n        }\n\n        if (inputFormatter) {\n          locals.$model = modelValue;\n          return inputFormatter(originalScope, locals);\n        }\n\n        //it might happen that we don't have enough info to properly render input value\n        //we need to check for this situation and simply return model value if we can't apply custom formatting\n        locals[parserResult.itemName] = modelValue;\n        candidateViewValue = parserResult.viewMapper(originalScope, locals);\n        locals[parserResult.itemName] = undefined;\n        emptyViewValue = parserResult.viewMapper(originalScope, locals);\n\n        return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;\n      });\n    };\n  }])\n\n  .directive('uibTypeahead', function() {\n    return {\n      controller: 'UibTypeaheadController',\n      require: ['ngModel', '^?ngModelOptions', 'uibTypeahead'],\n      link: function(originalScope, element, attrs, ctrls) {\n        ctrls[2].init(ctrls[0], ctrls[1]);\n      }\n    };\n  })\n\n  .directive('uibTypeaheadPopup', ['$$debounce', function($$debounce) {\n    return {\n      scope: {\n        matches: '=',\n        query: '=',\n        active: '=',\n        position: '&',\n        moveInProgress: '=',\n        select: '&',\n        assignIsOpen: '&',\n        debounce: '&'\n      },\n      replace: true,\n      templateUrl: function(element, attrs) {\n        return attrs.popupTemplateUrl || 'uib/template/typeahead/typeahead-popup.html';\n      },\n      link: function(scope, element, attrs) {\n        scope.templateUrl = attrs.templateUrl;\n\n        scope.isOpen = function() {\n          var isDropdownOpen = scope.matches.length > 0;\n          scope.assignIsOpen({ isOpen: isDropdownOpen });\n          return isDropdownOpen;\n        };\n\n        scope.isActive = function(matchIdx) {\n          return scope.active === matchIdx;\n        };\n\n        scope.selectActive = function(matchIdx) {\n          scope.active = matchIdx;\n        };\n\n        scope.selectMatch = function(activeIdx, evt) {\n          var debounce = scope.debounce();\n          if (angular.isNumber(debounce) || angular.isObject(debounce)) {\n            $$debounce(function() {\n              scope.select({activeIdx: activeIdx, evt: evt});\n            }, angular.isNumber(debounce) ? debounce : debounce['default']);\n          } else {\n            scope.select({activeIdx: activeIdx, evt: evt});\n          }\n        };\n      }\n    };\n  }])\n\n  .directive('uibTypeaheadMatch', ['$templateRequest', '$compile', '$parse', function($templateRequest, $compile, $parse) {\n    return {\n      scope: {\n        index: '=',\n        match: '=',\n        query: '='\n      },\n      link: function(scope, element, attrs) {\n        var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'uib/template/typeahead/typeahead-match.html';\n        $templateRequest(tplUrl).then(function(tplContent) {\n          var tplEl = angular.element(tplContent.trim());\n          element.replaceWith(tplEl);\n          $compile(tplEl)(scope);\n        });\n      }\n    };\n  }])\n\n  .filter('uibTypeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {\n    var isSanitizePresent;\n    isSanitizePresent = $injector.has('$sanitize');\n\n    function escapeRegexp(queryToEscape) {\n      // Regex: capture the whole query string and replace it with the string that will be used to match\n      // the results, for example if the capture is \"a\" the result will be \\a\n      return queryToEscape.replace(/([.?*+^$[\\]\\\\(){}|-])/g, '\\\\$1');\n    }\n\n    function containsHtml(matchItem) {\n      return /<.*>/g.test(matchItem);\n    }\n\n    return function(matchItem, query) {\n      if (!isSanitizePresent && containsHtml(matchItem)) {\n        $log.warn('Unsafe use of typeahead please use ngSanitize'); // Warn the user about the danger\n      }\n      matchItem = query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem; // Replaces the capture string with a the same string inside of a \"strong\" tag\n      if (!isSanitizePresent) {\n        matchItem = $sce.trustAsHtml(matchItem); // If $sanitize is not present we pack the string in a $sce object for the ng-bind-html directive\n      }\n      return matchItem;\n    };\n  }]);\n\nangular.module(\"uib/template/accordion/accordion-group.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/accordion/accordion-group.html\",\n    \"<div class=\\\"panel\\\" ng-class=\\\"panelClass || 'panel-default'\\\">\\n\" +\n    \"  <div role=\\\"tab\\\" id=\\\"{{::headingId}}\\\" aria-selected=\\\"{{isOpen}}\\\" class=\\\"panel-heading\\\" ng-keypress=\\\"toggleOpen($event)\\\">\\n\" +\n    \"    <h4 class=\\\"panel-title\\\">\\n\" +\n    \"      <a role=\\\"button\\\" data-toggle=\\\"collapse\\\" href aria-expanded=\\\"{{isOpen}}\\\" aria-controls=\\\"{{::panelId}}\\\" tabindex=\\\"0\\\" class=\\\"accordion-toggle\\\" ng-click=\\\"toggleOpen()\\\" uib-accordion-transclude=\\\"heading\\\"><span uib-accordion-header ng-class=\\\"{'text-muted': isDisabled}\\\">{{heading}}</span></a>\\n\" +\n    \"    </h4>\\n\" +\n    \"  </div>\\n\" +\n    \"  <div id=\\\"{{::panelId}}\\\" aria-labelledby=\\\"{{::headingId}}\\\" aria-hidden=\\\"{{!isOpen}}\\\" role=\\\"tabpanel\\\" class=\\\"panel-collapse collapse\\\" uib-collapse=\\\"!isOpen\\\">\\n\" +\n    \"    <div class=\\\"panel-body\\\" ng-transclude></div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/accordion/accordion.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/accordion/accordion.html\",\n    \"<div role=\\\"tablist\\\" class=\\\"panel-group\\\" ng-transclude></div>\");\n}]);\n\nangular.module(\"uib/template/alert/alert.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/alert/alert.html\",\n    \"<div class=\\\"alert\\\" ng-class=\\\"['alert-' + (type || 'warning'), closeable ? 'alert-dismissible' : null]\\\" role=\\\"alert\\\">\\n\" +\n    \"    <button ng-show=\\\"closeable\\\" type=\\\"button\\\" class=\\\"close\\\" ng-click=\\\"close({$event: $event})\\\">\\n\" +\n    \"        <span aria-hidden=\\\"true\\\">&times;</span>\\n\" +\n    \"        <span class=\\\"sr-only\\\">Close</span>\\n\" +\n    \"    </button>\\n\" +\n    \"    <div ng-transclude></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/carousel/carousel.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/carousel/carousel.html\",\n    \"<div ng-mouseenter=\\\"pause()\\\" ng-mouseleave=\\\"play()\\\" class=\\\"carousel\\\" ng-swipe-right=\\\"prev()\\\" ng-swipe-left=\\\"next()\\\">\\n\" +\n    \"  <div class=\\\"carousel-inner\\\" ng-transclude></div>\\n\" +\n    \"  <a role=\\\"button\\\" href class=\\\"left carousel-control\\\" ng-click=\\\"prev()\\\" ng-class=\\\"{ disabled: isPrevDisabled() }\\\" ng-show=\\\"slides.length > 1\\\">\\n\" +\n    \"    <span aria-hidden=\\\"true\\\" class=\\\"glyphicon glyphicon-chevron-left\\\"></span>\\n\" +\n    \"    <span class=\\\"sr-only\\\">previous</span>\\n\" +\n    \"  </a>\\n\" +\n    \"  <a role=\\\"button\\\" href class=\\\"right carousel-control\\\" ng-click=\\\"next()\\\" ng-class=\\\"{ disabled: isNextDisabled() }\\\" ng-show=\\\"slides.length > 1\\\">\\n\" +\n    \"    <span aria-hidden=\\\"true\\\" class=\\\"glyphicon glyphicon-chevron-right\\\"></span>\\n\" +\n    \"    <span class=\\\"sr-only\\\">next</span>\\n\" +\n    \"  </a>\\n\" +\n    \"  <ol class=\\\"carousel-indicators\\\" ng-show=\\\"slides.length > 1\\\">\\n\" +\n    \"    <li ng-repeat=\\\"slide in slides | orderBy:indexOfSlide track by $index\\\" ng-class=\\\"{ active: isActive(slide) }\\\" ng-click=\\\"select(slide)\\\">\\n\" +\n    \"      <span class=\\\"sr-only\\\">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if=\\\"isActive(slide)\\\">, currently active</span></span>\\n\" +\n    \"    </li>\\n\" +\n    \"  </ol>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/carousel/slide.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/carousel/slide.html\",\n    \"<div ng-class=\\\"{\\n\" +\n    \"    'active': active\\n\" +\n    \"  }\\\" class=\\\"item text-center\\\" ng-transclude></div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/datepicker.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/datepicker/datepicker.html\",\n    \"<div class=\\\"uib-datepicker\\\" ng-switch=\\\"datepickerMode\\\" role=\\\"application\\\" ng-keydown=\\\"keydown($event)\\\">\\n\" +\n    \"  <uib-daypicker ng-switch-when=\\\"day\\\" tabindex=\\\"0\\\"></uib-daypicker>\\n\" +\n    \"  <uib-monthpicker ng-switch-when=\\\"month\\\" tabindex=\\\"0\\\"></uib-monthpicker>\\n\" +\n    \"  <uib-yearpicker ng-switch-when=\\\"year\\\" tabindex=\\\"0\\\"></uib-yearpicker>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/day.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/datepicker/day.html\",\n    \"<table class=\\\"uib-daypicker\\\" role=\\\"grid\\\" aria-labelledby=\\\"{{::uniqueId}}-title\\\" aria-activedescendant=\\\"{{activeDateId}}\\\">\\n\" +\n    \"  <thead>\\n\" +\n    \"    <tr>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-left uib-left\\\" ng-click=\\\"move(-1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-left\\\"></i></button></th>\\n\" +\n    \"      <th colspan=\\\"{{::5 + showWeeks}}\\\"><button id=\\\"{{::uniqueId}}-title\\\" role=\\\"heading\\\" aria-live=\\\"assertive\\\" aria-atomic=\\\"true\\\" type=\\\"button\\\" class=\\\"btn btn-default btn-sm uib-title\\\" ng-click=\\\"toggleMode()\\\" ng-disabled=\\\"datepickerMode === maxMode\\\" tabindex=\\\"-1\\\"><strong>{{title}}</strong></button></th>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-right uib-right\\\" ng-click=\\\"move(1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-right\\\"></i></button></th>\\n\" +\n    \"    </tr>\\n\" +\n    \"    <tr>\\n\" +\n    \"      <th ng-if=\\\"showWeeks\\\" class=\\\"text-center\\\"></th>\\n\" +\n    \"      <th ng-repeat=\\\"label in ::labels track by $index\\\" class=\\\"text-center\\\"><small aria-label=\\\"{{::label.full}}\\\">{{::label.abbr}}</small></th>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </thead>\\n\" +\n    \"  <tbody>\\n\" +\n    \"    <tr class=\\\"uib-weeks\\\" ng-repeat=\\\"row in rows track by $index\\\">\\n\" +\n    \"      <td ng-if=\\\"showWeeks\\\" class=\\\"text-center h6\\\"><em>{{ weekNumbers[$index] }}</em></td>\\n\" +\n    \"      <td ng-repeat=\\\"dt in row\\\" class=\\\"uib-day text-center\\\" role=\\\"gridcell\\\"\\n\" +\n    \"        id=\\\"{{::dt.uid}}\\\"\\n\" +\n    \"        ng-class=\\\"::dt.customClass\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-default btn-sm\\\"\\n\" +\n    \"          uib-is-class=\\\"\\n\" +\n    \"            'btn-info' for selectedDt,\\n\" +\n    \"            'active' for activeDt\\n\" +\n    \"            on dt\\\"\\n\" +\n    \"          ng-click=\\\"select(dt.date)\\\"\\n\" +\n    \"          ng-disabled=\\\"::dt.disabled\\\"\\n\" +\n    \"          tabindex=\\\"-1\\\"><span ng-class=\\\"::{'text-muted': dt.secondary, 'text-info': dt.current}\\\">{{::dt.label}}</span></button>\\n\" +\n    \"      </td>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </tbody>\\n\" +\n    \"</table>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/month.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/datepicker/month.html\",\n    \"<table class=\\\"uib-monthpicker\\\" role=\\\"grid\\\" aria-labelledby=\\\"{{::uniqueId}}-title\\\" aria-activedescendant=\\\"{{activeDateId}}\\\">\\n\" +\n    \"  <thead>\\n\" +\n    \"    <tr>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-left uib-left\\\" ng-click=\\\"move(-1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-left\\\"></i></button></th>\\n\" +\n    \"      <th><button id=\\\"{{::uniqueId}}-title\\\" role=\\\"heading\\\" aria-live=\\\"assertive\\\" aria-atomic=\\\"true\\\" type=\\\"button\\\" class=\\\"btn btn-default btn-sm uib-title\\\" ng-click=\\\"toggleMode()\\\" ng-disabled=\\\"datepickerMode === maxMode\\\" tabindex=\\\"-1\\\"><strong>{{title}}</strong></button></th>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-right uib-right\\\" ng-click=\\\"move(1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-right\\\"></i></button></th>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </thead>\\n\" +\n    \"  <tbody>\\n\" +\n    \"    <tr class=\\\"uib-months\\\" ng-repeat=\\\"row in rows track by $index\\\">\\n\" +\n    \"      <td ng-repeat=\\\"dt in row\\\" class=\\\"uib-month text-center\\\" role=\\\"gridcell\\\"\\n\" +\n    \"        id=\\\"{{::dt.uid}}\\\"\\n\" +\n    \"        ng-class=\\\"::dt.customClass\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-default\\\"\\n\" +\n    \"          uib-is-class=\\\"\\n\" +\n    \"            'btn-info' for selectedDt,\\n\" +\n    \"            'active' for activeDt\\n\" +\n    \"            on dt\\\"\\n\" +\n    \"          ng-click=\\\"select(dt.date)\\\"\\n\" +\n    \"          ng-disabled=\\\"::dt.disabled\\\"\\n\" +\n    \"          tabindex=\\\"-1\\\"><span ng-class=\\\"::{'text-info': dt.current}\\\">{{::dt.label}}</span></button>\\n\" +\n    \"      </td>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </tbody>\\n\" +\n    \"</table>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/year.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/datepicker/year.html\",\n    \"<table class=\\\"uib-yearpicker\\\" role=\\\"grid\\\" aria-labelledby=\\\"{{::uniqueId}}-title\\\" aria-activedescendant=\\\"{{activeDateId}}\\\">\\n\" +\n    \"  <thead>\\n\" +\n    \"    <tr>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-left uib-left\\\" ng-click=\\\"move(-1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-left\\\"></i></button></th>\\n\" +\n    \"      <th colspan=\\\"{{::columns - 2}}\\\"><button id=\\\"{{::uniqueId}}-title\\\" role=\\\"heading\\\" aria-live=\\\"assertive\\\" aria-atomic=\\\"true\\\" type=\\\"button\\\" class=\\\"btn btn-default btn-sm uib-title\\\" ng-click=\\\"toggleMode()\\\" ng-disabled=\\\"datepickerMode === maxMode\\\" tabindex=\\\"-1\\\"><strong>{{title}}</strong></button></th>\\n\" +\n    \"      <th><button type=\\\"button\\\" class=\\\"btn btn-default btn-sm pull-right uib-right\\\" ng-click=\\\"move(1)\\\" tabindex=\\\"-1\\\"><i class=\\\"glyphicon glyphicon-chevron-right\\\"></i></button></th>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </thead>\\n\" +\n    \"  <tbody>\\n\" +\n    \"    <tr class=\\\"uib-years\\\" ng-repeat=\\\"row in rows track by $index\\\">\\n\" +\n    \"      <td ng-repeat=\\\"dt in row\\\" class=\\\"uib-year text-center\\\" role=\\\"gridcell\\\"\\n\" +\n    \"        id=\\\"{{::dt.uid}}\\\"\\n\" +\n    \"        ng-class=\\\"::dt.customClass\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-default\\\"\\n\" +\n    \"          uib-is-class=\\\"\\n\" +\n    \"            'btn-info' for selectedDt,\\n\" +\n    \"            'active' for activeDt\\n\" +\n    \"            on dt\\\"\\n\" +\n    \"          ng-click=\\\"select(dt.date)\\\"\\n\" +\n    \"          ng-disabled=\\\"::dt.disabled\\\"\\n\" +\n    \"          tabindex=\\\"-1\\\"><span ng-class=\\\"::{'text-info': dt.current}\\\">{{::dt.label}}</span></button>\\n\" +\n    \"      </td>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </tbody>\\n\" +\n    \"</table>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/datepickerPopup/popup.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/datepickerPopup/popup.html\",\n    \"<div>\\n\" +\n    \"  <ul class=\\\"uib-datepicker-popup dropdown-menu uib-position-measure\\\" dropdown-nested ng-if=\\\"isOpen\\\" ng-keydown=\\\"keydown($event)\\\" ng-click=\\\"$event.stopPropagation()\\\">\\n\" +\n    \"    <li ng-transclude></li>\\n\" +\n    \"    <li ng-if=\\\"showButtonBar\\\" class=\\\"uib-button-bar\\\">\\n\" +\n    \"      <span class=\\\"btn-group pull-left\\\">\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-sm btn-info uib-datepicker-current\\\" ng-click=\\\"select('today', $event)\\\" ng-disabled=\\\"isDisabled('today')\\\">{{ getText('current') }}</button>\\n\" +\n    \"        <button type=\\\"button\\\" class=\\\"btn btn-sm btn-danger uib-clear\\\" ng-click=\\\"select(null, $event)\\\">{{ getText('clear') }}</button>\\n\" +\n    \"      </span>\\n\" +\n    \"      <button type=\\\"button\\\" class=\\\"btn btn-sm btn-success pull-right uib-close\\\" ng-click=\\\"close($event)\\\">{{ getText('close') }}</button>\\n\" +\n    \"    </li>\\n\" +\n    \"  </ul>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/modal/backdrop.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/modal/backdrop.html\",\n    \"<div class=\\\"modal-backdrop\\\"\\n\" +\n    \"     uib-modal-animation-class=\\\"fade\\\"\\n\" +\n    \"     modal-in-class=\\\"in\\\"\\n\" +\n    \"     ng-style=\\\"{'z-index': 1040 + (index && 1 || 0) + index*10}\\\"\\n\" +\n    \"></div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/modal/window.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/modal/window.html\",\n    \"<div modal-render=\\\"{{$isRendered}}\\\" tabindex=\\\"-1\\\" role=\\\"dialog\\\" class=\\\"modal\\\"\\n\" +\n    \"    uib-modal-animation-class=\\\"fade\\\"\\n\" +\n    \"    modal-in-class=\\\"in\\\"\\n\" +\n    \"    ng-style=\\\"{'z-index': 1050 + index*10, display: 'block'}\\\">\\n\" +\n    \"    <div class=\\\"modal-dialog {{size ? 'modal-' + size : ''}}\\\"><div class=\\\"modal-content\\\" uib-modal-transclude></div></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/pager/pager.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/pager/pager.html\",\n    \"<ul class=\\\"pager\\\">\\n\" +\n    \"  <li ng-class=\\\"{disabled: noPrevious()||ngDisabled, previous: align}\\\"><a href ng-click=\\\"selectPage(page - 1, $event)\\\">{{::getText('previous')}}</a></li>\\n\" +\n    \"  <li ng-class=\\\"{disabled: noNext()||ngDisabled, next: align}\\\"><a href ng-click=\\\"selectPage(page + 1, $event)\\\">{{::getText('next')}}</a></li>\\n\" +\n    \"</ul>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/pagination/pagination.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/pagination/pagination.html\",\n    \"<ul class=\\\"pagination\\\">\\n\" +\n    \"  <li ng-if=\\\"::boundaryLinks\\\" ng-class=\\\"{disabled: noPrevious()||ngDisabled}\\\" class=\\\"pagination-first\\\"><a href ng-click=\\\"selectPage(1, $event)\\\">{{::getText('first')}}</a></li>\\n\" +\n    \"  <li ng-if=\\\"::directionLinks\\\" ng-class=\\\"{disabled: noPrevious()||ngDisabled}\\\" class=\\\"pagination-prev\\\"><a href ng-click=\\\"selectPage(page - 1, $event)\\\">{{::getText('previous')}}</a></li>\\n\" +\n    \"  <li ng-repeat=\\\"page in pages track by $index\\\" ng-class=\\\"{active: page.active,disabled: ngDisabled&&!page.active}\\\" class=\\\"pagination-page\\\"><a href ng-click=\\\"selectPage(page.number, $event)\\\">{{page.text}}</a></li>\\n\" +\n    \"  <li ng-if=\\\"::directionLinks\\\" ng-class=\\\"{disabled: noNext()||ngDisabled}\\\" class=\\\"pagination-next\\\"><a href ng-click=\\\"selectPage(page + 1, $event)\\\">{{::getText('next')}}</a></li>\\n\" +\n    \"  <li ng-if=\\\"::boundaryLinks\\\" ng-class=\\\"{disabled: noNext()||ngDisabled}\\\" class=\\\"pagination-last\\\"><a href ng-click=\\\"selectPage(totalPages, $event)\\\">{{::getText('last')}}</a></li>\\n\" +\n    \"</ul>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-html-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/tooltip/tooltip-html-popup.html\",\n    \"<div class=\\\"tooltip\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"tooltip-arrow\\\"></div>\\n\" +\n    \"  <div class=\\\"tooltip-inner\\\" ng-bind-html=\\\"contentExp()\\\"></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/tooltip/tooltip-popup.html\",\n    \"<div class=\\\"tooltip\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"tooltip-arrow\\\"></div>\\n\" +\n    \"  <div class=\\\"tooltip-inner\\\" ng-bind=\\\"content\\\"></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-template-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/tooltip/tooltip-template-popup.html\",\n    \"<div class=\\\"tooltip\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"tooltip-arrow\\\"></div>\\n\" +\n    \"  <div class=\\\"tooltip-inner\\\"\\n\" +\n    \"    uib-tooltip-template-transclude=\\\"contentExp()\\\"\\n\" +\n    \"    tooltip-template-transclude-scope=\\\"originScope()\\\"></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover-html.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/popover/popover-html.html\",\n    \"<div class=\\\"popover\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"arrow\\\"></div>\\n\" +\n    \"\\n\" +\n    \"  <div class=\\\"popover-inner\\\">\\n\" +\n    \"      <h3 class=\\\"popover-title\\\" ng-bind=\\\"uibTitle\\\" ng-if=\\\"uibTitle\\\"></h3>\\n\" +\n    \"      <div class=\\\"popover-content\\\" ng-bind-html=\\\"contentExp()\\\"></div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover-template.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/popover/popover-template.html\",\n    \"<div class=\\\"popover\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"arrow\\\"></div>\\n\" +\n    \"\\n\" +\n    \"  <div class=\\\"popover-inner\\\">\\n\" +\n    \"      <h3 class=\\\"popover-title\\\" ng-bind=\\\"uibTitle\\\" ng-if=\\\"uibTitle\\\"></h3>\\n\" +\n    \"      <div class=\\\"popover-content\\\"\\n\" +\n    \"        uib-tooltip-template-transclude=\\\"contentExp()\\\"\\n\" +\n    \"        tooltip-template-transclude-scope=\\\"originScope()\\\"></div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/popover/popover.html\",\n    \"<div class=\\\"popover\\\"\\n\" +\n    \"  tooltip-animation-class=\\\"fade\\\"\\n\" +\n    \"  uib-tooltip-classes\\n\" +\n    \"  ng-class=\\\"{ in: isOpen() }\\\">\\n\" +\n    \"  <div class=\\\"arrow\\\"></div>\\n\" +\n    \"\\n\" +\n    \"  <div class=\\\"popover-inner\\\">\\n\" +\n    \"      <h3 class=\\\"popover-title\\\" ng-bind=\\\"uibTitle\\\" ng-if=\\\"uibTitle\\\"></h3>\\n\" +\n    \"      <div class=\\\"popover-content\\\" ng-bind=\\\"content\\\"></div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/progressbar/bar.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/progressbar/bar.html\",\n    \"<div class=\\\"progress-bar\\\" ng-class=\\\"type && 'progress-bar-' + type\\\" role=\\\"progressbar\\\" aria-valuenow=\\\"{{value}}\\\" aria-valuemin=\\\"0\\\" aria-valuemax=\\\"{{max}}\\\" ng-style=\\\"{width: (percent < 100 ? percent : 100) + '%'}\\\" aria-valuetext=\\\"{{percent | number:0}}%\\\" aria-labelledby=\\\"{{::title}}\\\" ng-transclude></div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/progressbar/progress.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/progressbar/progress.html\",\n    \"<div class=\\\"progress\\\" ng-transclude aria-labelledby=\\\"{{::title}}\\\"></div>\");\n}]);\n\nangular.module(\"uib/template/progressbar/progressbar.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/progressbar/progressbar.html\",\n    \"<div class=\\\"progress\\\">\\n\" +\n    \"  <div class=\\\"progress-bar\\\" ng-class=\\\"type && 'progress-bar-' + type\\\" role=\\\"progressbar\\\" aria-valuenow=\\\"{{value}}\\\" aria-valuemin=\\\"0\\\" aria-valuemax=\\\"{{max}}\\\" ng-style=\\\"{width: (percent < 100 ? percent : 100) + '%'}\\\" aria-valuetext=\\\"{{percent | number:0}}%\\\" aria-labelledby=\\\"{{::title}}\\\" ng-transclude></div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/rating/rating.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/rating/rating.html\",\n    \"<span ng-mouseleave=\\\"reset()\\\" ng-keydown=\\\"onKeydown($event)\\\" tabindex=\\\"0\\\" role=\\\"slider\\\" aria-valuemin=\\\"0\\\" aria-valuemax=\\\"{{range.length}}\\\" aria-valuenow=\\\"{{value}}\\\" aria-valuetext=\\\"{{title}}\\\">\\n\" +\n    \"    <span ng-repeat-start=\\\"r in range track by $index\\\" class=\\\"sr-only\\\">({{ $index < value ? '*' : ' ' }})</span>\\n\" +\n    \"    <i ng-repeat-end ng-mouseenter=\\\"enter($index + 1)\\\" ng-click=\\\"rate($index + 1)\\\" class=\\\"glyphicon\\\" ng-class=\\\"$index < value && (r.stateOn || 'glyphicon-star') || (r.stateOff || 'glyphicon-star-empty')\\\" ng-attr-title=\\\"{{r.title}}\\\"></i>\\n\" +\n    \"</span>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/tabs/tab.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/tabs/tab.html\",\n    \"<li ng-class=\\\"[{active: active, disabled: disabled}, classes]\\\" class=\\\"uib-tab nav-item\\\">\\n\" +\n    \"  <a href ng-click=\\\"select($event)\\\" class=\\\"nav-link\\\" uib-tab-heading-transclude>{{heading}}</a>\\n\" +\n    \"</li>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/tabs/tabset.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/tabs/tabset.html\",\n    \"<div>\\n\" +\n    \"  <ul class=\\\"nav nav-{{tabset.type || 'tabs'}}\\\" ng-class=\\\"{'nav-stacked': vertical, 'nav-justified': justified}\\\" ng-transclude></ul>\\n\" +\n    \"  <div class=\\\"tab-content\\\">\\n\" +\n    \"    <div class=\\\"tab-pane\\\"\\n\" +\n    \"         ng-repeat=\\\"tab in tabset.tabs\\\"\\n\" +\n    \"         ng-class=\\\"{active: tabset.active === tab.index}\\\"\\n\" +\n    \"         uib-tab-content-transclude=\\\"tab\\\">\\n\" +\n    \"    </div>\\n\" +\n    \"  </div>\\n\" +\n    \"</div>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/timepicker/timepicker.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/timepicker/timepicker.html\",\n    \"<table class=\\\"uib-timepicker\\\">\\n\" +\n    \"  <tbody>\\n\" +\n    \"    <tr class=\\\"text-center\\\" ng-show=\\\"::showSpinners\\\">\\n\" +\n    \"      <td class=\\\"uib-increment hours\\\"><a ng-click=\\\"incrementHours()\\\" ng-class=\\\"{disabled: noIncrementHours()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noIncrementHours()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-up\\\"></span></a></td>\\n\" +\n    \"      <td>&nbsp;</td>\\n\" +\n    \"      <td class=\\\"uib-increment minutes\\\"><a ng-click=\\\"incrementMinutes()\\\" ng-class=\\\"{disabled: noIncrementMinutes()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noIncrementMinutes()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-up\\\"></span></a></td>\\n\" +\n    \"      <td ng-show=\\\"showSeconds\\\">&nbsp;</td>\\n\" +\n    \"      <td ng-show=\\\"showSeconds\\\" class=\\\"uib-increment seconds\\\"><a ng-click=\\\"incrementSeconds()\\\" ng-class=\\\"{disabled: noIncrementSeconds()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noIncrementSeconds()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-up\\\"></span></a></td>\\n\" +\n    \"      <td ng-show=\\\"showMeridian\\\"></td>\\n\" +\n    \"    </tr>\\n\" +\n    \"    <tr>\\n\" +\n    \"      <td class=\\\"form-group uib-time hours\\\" ng-class=\\\"{'has-error': invalidHours}\\\">\\n\" +\n    \"        <input type=\\\"text\\\" placeholder=\\\"HH\\\" ng-model=\\\"hours\\\" ng-change=\\\"updateHours()\\\" class=\\\"form-control text-center\\\" ng-readonly=\\\"::readonlyInput\\\" maxlength=\\\"2\\\" tabindex=\\\"{{::tabindex}}\\\" ng-disabled=\\\"noIncrementHours()\\\" ng-blur=\\\"blur()\\\">\\n\" +\n    \"      </td>\\n\" +\n    \"      <td class=\\\"uib-separator\\\">:</td>\\n\" +\n    \"      <td class=\\\"form-group uib-time minutes\\\" ng-class=\\\"{'has-error': invalidMinutes}\\\">\\n\" +\n    \"        <input type=\\\"text\\\" placeholder=\\\"MM\\\" ng-model=\\\"minutes\\\" ng-change=\\\"updateMinutes()\\\" class=\\\"form-control text-center\\\" ng-readonly=\\\"::readonlyInput\\\" maxlength=\\\"2\\\" tabindex=\\\"{{::tabindex}}\\\" ng-disabled=\\\"noIncrementMinutes()\\\" ng-blur=\\\"blur()\\\">\\n\" +\n    \"      </td>\\n\" +\n    \"      <td ng-show=\\\"showSeconds\\\" class=\\\"uib-separator\\\">:</td>\\n\" +\n    \"      <td class=\\\"form-group uib-time seconds\\\" ng-class=\\\"{'has-error': invalidSeconds}\\\" ng-show=\\\"showSeconds\\\">\\n\" +\n    \"        <input type=\\\"text\\\" placeholder=\\\"SS\\\" ng-model=\\\"seconds\\\" ng-change=\\\"updateSeconds()\\\" class=\\\"form-control text-center\\\" ng-readonly=\\\"readonlyInput\\\" maxlength=\\\"2\\\" tabindex=\\\"{{::tabindex}}\\\" ng-disabled=\\\"noIncrementSeconds()\\\" ng-blur=\\\"blur()\\\">\\n\" +\n    \"      </td>\\n\" +\n    \"      <td ng-show=\\\"showMeridian\\\" class=\\\"uib-time am-pm\\\"><button type=\\\"button\\\" ng-class=\\\"{disabled: noToggleMeridian()}\\\" class=\\\"btn btn-default text-center\\\" ng-click=\\\"toggleMeridian()\\\" ng-disabled=\\\"noToggleMeridian()\\\" tabindex=\\\"{{::tabindex}}\\\">{{meridian}}</button></td>\\n\" +\n    \"    </tr>\\n\" +\n    \"    <tr class=\\\"text-center\\\" ng-show=\\\"::showSpinners\\\">\\n\" +\n    \"      <td class=\\\"uib-decrement hours\\\"><a ng-click=\\\"decrementHours()\\\" ng-class=\\\"{disabled: noDecrementHours()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noDecrementHours()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-down\\\"></span></a></td>\\n\" +\n    \"      <td>&nbsp;</td>\\n\" +\n    \"      <td class=\\\"uib-decrement minutes\\\"><a ng-click=\\\"decrementMinutes()\\\" ng-class=\\\"{disabled: noDecrementMinutes()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noDecrementMinutes()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-down\\\"></span></a></td>\\n\" +\n    \"      <td ng-show=\\\"showSeconds\\\">&nbsp;</td>\\n\" +\n    \"      <td ng-show=\\\"showSeconds\\\" class=\\\"uib-decrement seconds\\\"><a ng-click=\\\"decrementSeconds()\\\" ng-class=\\\"{disabled: noDecrementSeconds()}\\\" class=\\\"btn btn-link\\\" ng-disabled=\\\"noDecrementSeconds()\\\" tabindex=\\\"{{::tabindex}}\\\"><span class=\\\"glyphicon glyphicon-chevron-down\\\"></span></a></td>\\n\" +\n    \"      <td ng-show=\\\"showMeridian\\\"></td>\\n\" +\n    \"    </tr>\\n\" +\n    \"  </tbody>\\n\" +\n    \"</table>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/typeahead/typeahead-match.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/typeahead/typeahead-match.html\",\n    \"<a href\\n\" +\n    \"   tabindex=\\\"-1\\\"\\n\" +\n    \"   ng-bind-html=\\\"match.label | uibTypeaheadHighlight:query\\\"\\n\" +\n    \"   ng-attr-title=\\\"{{match.label}}\\\"></a>\\n\" +\n    \"\");\n}]);\n\nangular.module(\"uib/template/typeahead/typeahead-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n  $templateCache.put(\"uib/template/typeahead/typeahead-popup.html\",\n    \"<ul class=\\\"dropdown-menu\\\" ng-show=\\\"isOpen() && !moveInProgress\\\" ng-style=\\\"{top: position().top+'px', left: position().left+'px'}\\\" role=\\\"listbox\\\" aria-hidden=\\\"{{!isOpen()}}\\\">\\n\" +\n    \"    <li ng-repeat=\\\"match in matches track by $index\\\" ng-class=\\\"{active: isActive($index) }\\\" ng-mouseenter=\\\"selectActive($index)\\\" ng-click=\\\"selectMatch($index, $event)\\\" role=\\\"option\\\" id=\\\"{{::match.id}}\\\">\\n\" +\n    \"        <div uib-typeahead-match index=\\\"$index\\\" match=\\\"match\\\" query=\\\"query\\\" template-url=\\\"templateUrl\\\"></div>\\n\" +\n    \"    </li>\\n\" +\n    \"</ul>\\n\" +\n    \"\");\n}]);\nangular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibCarouselCss && angular.element(document).find('head').prepend('<style type=\"text/css\">.ng-animate.item:not(.left):not(.right){-webkit-transition:0s ease-in-out left;transition:0s ease-in-out left}</style>'); angular.$$uibCarouselCss = true; });\nangular.module('ui.bootstrap.datepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerCss && angular.element(document).find('head').prepend('<style type=\"text/css\">.uib-datepicker .uib-title{width:100%;}.uib-day button,.uib-month button,.uib-year button{min-width:100%;}.uib-left,.uib-right{width:100%}</style>'); angular.$$uibDatepickerCss = true; });\nangular.module('ui.bootstrap.position').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibPositionCss && angular.element(document).find('head').prepend('<style type=\"text/css\">.uib-position-measure{display:block !important;visibility:hidden !important;position:absolute !important;top:-9999px !important;left:-9999px !important;}.uib-position-scrollbar-measure{position:absolute !important;top:-9999px !important;width:50px !important;height:50px !important;overflow:scroll !important;}.uib-position-body-scrollbar-measure{overflow:scroll !important;}</style>'); angular.$$uibPositionCss = true; });\nangular.module('ui.bootstrap.datepickerPopup').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerpopupCss && angular.element(document).find('head').prepend('<style type=\"text/css\">.uib-datepicker-popup.dropdown-menu{display:block;float:none;margin:0;}.uib-button-bar{padding:10px 9px 2px;}</style>'); angular.$$uibDatepickerpopupCss = true; });\nangular.module('ui.bootstrap.tooltip').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTooltipCss && angular.element(document).find('head').prepend('<style type=\"text/css\">[uib-tooltip-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-popup].tooltip.right-bottom > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.right-bottom > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.right-bottom > .tooltip-arrow,[uib-popover-popup].popover.top-left > .arrow,[uib-popover-popup].popover.top-right > .arrow,[uib-popover-popup].popover.bottom-left > .arrow,[uib-popover-popup].popover.bottom-right > .arrow,[uib-popover-popup].popover.left-top > .arrow,[uib-popover-popup].popover.left-bottom > .arrow,[uib-popover-popup].popover.right-top > .arrow,[uib-popover-popup].popover.right-bottom > .arrow,[uib-popover-html-popup].popover.top-left > .arrow,[uib-popover-html-popup].popover.top-right > .arrow,[uib-popover-html-popup].popover.bottom-left > .arrow,[uib-popover-html-popup].popover.bottom-right > .arrow,[uib-popover-html-popup].popover.left-top > .arrow,[uib-popover-html-popup].popover.left-bottom > .arrow,[uib-popover-html-popup].popover.right-top > .arrow,[uib-popover-html-popup].popover.right-bottom > .arrow,[uib-popover-template-popup].popover.top-left > .arrow,[uib-popover-template-popup].popover.top-right > .arrow,[uib-popover-template-popup].popover.bottom-left > .arrow,[uib-popover-template-popup].popover.bottom-right > .arrow,[uib-popover-template-popup].popover.left-top > .arrow,[uib-popover-template-popup].popover.left-bottom > .arrow,[uib-popover-template-popup].popover.right-top > .arrow,[uib-popover-template-popup].popover.right-bottom > .arrow{top:auto;bottom:auto;left:auto;right:auto;margin:0;}[uib-popover-popup].popover,[uib-popover-html-popup].popover,[uib-popover-template-popup].popover{display:block !important;}</style>'); angular.$$uibTooltipCss = true; });\nangular.module('ui.bootstrap.timepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTimepickerCss && angular.element(document).find('head').prepend('<style type=\"text/css\">.uib-time input{width:50px;}</style>'); angular.$$uibTimepickerCss = true; });\nangular.module('ui.bootstrap.typeahead').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTypeaheadCss && angular.element(document).find('head').prepend('<style type=\"text/css\">[uib-typeahead-popup].dropdown-menu{display:block;}</style>'); angular.$$uibTypeaheadCss = true; });"
  },
  {
    "path": "html/lib/angular-bootstrap-slider/slider.js",
    "content": "(function(factory) {\n    if (typeof define === 'function' && define.amd) {\n        define(['angular', 'bootstrapSlider'], factory);\n    } else if (typeof module === 'object' && module.exports) {\n        module.exports = factory(require('angular'), require('bootstrapSlider'));\n    } else if (window) {\n        factory(window.angular, window.Slider);\n    }\n})(function (angular, Slider) {\n\nangular.module('ui.bootstrap-slider', [])\n    .directive('slider', ['$parse', '$timeout', '$rootScope', function ($parse, $timeout, $rootScope) {\n        return {\n            restrict: 'AE',\n            replace: true,\n            template: '<div><input class=\"slider-input\" type=\"text\" style=\"width:100%\" /></div>',\n            require: 'ngModel',\n            scope: {\n                max: \"=\",\n                min: \"=\",\n                step: \"=\",\n                value: \"=\",\n                ngModel: '=',\n                ngDisabled: '=',\n                range: '=',\n                sliderid: '=',\n                ticks: '=',\n                ticksLabels: '=',\n                ticksSnapBounds: '=',\n                ticksPositions: '=',\n                scale: '=',\n                focus: '=',\n                formatter: '&',\n                onStartSlide: '&',\n                onStopSlide: '&',\n                onSlide: '&'\n            },\n            link: function ($scope, element, attrs, ngModelCtrl, $compile) {\n                var ngModelDeregisterFn, ngDisabledDeregisterFn;\n\n                var slider = initSlider();\n\n                function initSlider() {\n                    var options = {};\n\n                    function setOption(key, value, defaultValue) {\n                        options[key] = value || defaultValue;\n                    }\n\n                    function setFloatOption(key, value, defaultValue) {\n                        options[key] = value || value === 0 ? parseFloat(value) : defaultValue;\n                    }\n\n                    function setBooleanOption(key, value, defaultValue) {\n                        options[key] = value ? value + '' === 'true' : defaultValue;\n                    }\n\n                    function getArrayOrValue(value) {\n                        return (angular.isString(value) && value.indexOf(\"[\") === 0) ? angular.fromJson(value) : value;\n                    }\n\n                    setOption('id', $scope.sliderid);\n                    setOption('orientation', attrs.orientation, 'horizontal');\n                    setOption('selection', attrs.selection, 'before');\n                    setOption('handle', attrs.handle, 'round');\n                    setOption('tooltip', attrs.sliderTooltip || attrs.tooltip, 'show');\n                    setOption('tooltip_position', attrs.sliderTooltipPosition, 'top');\n                    setOption('tooltipseparator', attrs.tooltipseparator, ':');\n                    setOption('ticks', $scope.ticks);\n                    setOption('ticks_labels', $scope.ticksLabels);\n                    setOption('ticks_snap_bounds', $scope.ticksSnapBounds);\n                    setOption('ticks_positions', $scope.ticksPositions);\n                    setOption('scale', $scope.scale, 'linear');\n                    setOption('focus', $scope.focus);\n\n                    setFloatOption('min', $scope.min, 0);\n                    setFloatOption('max', $scope.max, 10);\n                    setFloatOption('step', $scope.step, 1);\n                    var strNbr = options.step + '';\n                    var dotPos = strNbr.search(/[^.,]*$/);\n                    var decimals = strNbr.substring(dotPos);\n                    setFloatOption('precision', attrs.precision, decimals.length);\n\n                    setBooleanOption('tooltip_split', attrs.tooltipsplit, false);\n                    setBooleanOption('enabled', attrs.enabled, true);\n                    setBooleanOption('naturalarrowkeys', attrs.naturalarrowkeys, false);\n                    setBooleanOption('reversed', attrs.reversed, false);\n\n                    setBooleanOption('range', $scope.range, false);\n                    if (options.range) {\n                        if (angular.isArray($scope.value)) {\n                            options.value = $scope.value;\n                        }\n                        else if (angular.isString($scope.value)) {\n                            options.value = getArrayOrValue($scope.value);\n                            if (!angular.isArray(options.value)) {\n                                var value = parseFloat($scope.value);\n                                if (isNaN(value)) value = 5;\n\n                                if (value < $scope.min) {\n                                    value = $scope.min;\n                                    options.value = [value, options.max];\n                                }\n                                else if (value > $scope.max) {\n                                    value = $scope.max;\n                                    options.value = [options.min, value];\n                                }\n                                else {\n                                    options.value = [options.min, options.max];\n                                }\n                            }\n                        }\n                        else {\n                            options.value = [options.min, options.max]; // This is needed, because of value defined at $.fn.slider.defaults - default value 5 prevents creating range slider\n                        }\n                        $scope.ngModel = options.value; // needed, otherwise turns value into [null, ##]\n                    }\n                    else {\n                        setFloatOption('value', $scope.value, 5);\n                    }\n\n                    if (attrs.formatter) {\n                        options.formatter = function(value) {\n                            return $scope.formatter({value: value});\n                        }\n                    }\n\n                    // check if slider jQuery plugin exists\n                    if ('$' in window && $.fn.slider) {\n                        // adding methods to jQuery slider plugin prototype\n                        $.fn.slider.constructor.prototype.disable = function () {\n                            this.picker.off();\n                        };\n                        $.fn.slider.constructor.prototype.enable = function () {\n                            this.picker.on();\n                        };\n                    }\n\n                    // destroy previous slider to reset all options\n                    if (element[0].__slider)\n                        element[0].__slider.destroy();\n\n                    var slider = new Slider(element[0].getElementsByClassName('slider-input')[0], options);\n                    element[0].__slider = slider;\n\n                    // everything that needs slider element\n                    var updateEvent = getArrayOrValue(attrs.updateevent);\n                    if (angular.isString(updateEvent)) {\n                        // if only single event name in string\n                        updateEvent = [updateEvent];\n                    }\n                    else {\n                        // default to slide event\n                        updateEvent = ['slide'];\n                    }\n                    angular.forEach(updateEvent, function (sliderEvent) {\n                        slider.on(sliderEvent, function (ev) {\n                            ngModelCtrl.$setViewValue(ev);\n                        });\n                    });\n                    slider.on('change', function (ev) {\n                        ngModelCtrl.$setViewValue(ev.newValue);\n                    });\n\n\n                    // Event listeners\n                    var sliderEvents = {\n                        slideStart: 'onStartSlide',\n                        slide: 'onSlide',\n                        slideStop: 'onStopSlide'\n                    };\n                    angular.forEach(sliderEvents, function (sliderEventAttr, sliderEvent) {\n                        var fn = $parse(attrs[sliderEventAttr]);\n                        slider.on(sliderEvent, function (ev) {\n                            if ($scope[sliderEventAttr]) {\n                                $scope.$apply(function () {\n                                    fn($scope.$parent, { $event: ev, value: ev });\n                                });\n                            }\n                        });\n                    });\n\n                    // deregister ngDisabled watcher to prevent memory leaks\n                    if (angular.isFunction(ngDisabledDeregisterFn)) {\n                        ngDisabledDeregisterFn();\n                        ngDisabledDeregisterFn = null;\n                    }\n\n                    ngDisabledDeregisterFn = $scope.$watch('ngDisabled', function (value) {\n                        if (value) {\n                            slider.disable();\n                        }\n                        else {\n                            slider.enable();\n                        }\n                    });\n\n                    // deregister ngModel watcher to prevent memory leaks\n                    if (angular.isFunction(ngModelDeregisterFn)) ngModelDeregisterFn();\n                    ngModelDeregisterFn = $scope.$watch('ngModel', function (value) {\n                        if($scope.range){\n                            slider.setValue(value);\n                        }else{\n                            slider.setValue(parseFloat(value));\n                        }\n                        slider.relayout();\n                    }, true);\n\n                    return slider;\n                }\n\n\n                var watchers = ['min', 'max', 'step', 'range', 'scale', 'ticksLabels'];\n                angular.forEach(watchers, function (prop) {\n                    $scope.$watch(prop, function () {\n                        slider = initSlider();\n                    });\n                });\n\n                var globalEvents = ['relayout', 'refresh', 'resize'];\n                angular.forEach(globalEvents, function(event) {\n                    if(angular.isFunction(slider[event])) {\n                        $scope.$on('slider:' + event, function () {\n                            slider[event]();\n                        });\n                    }\n                });\n            }\n        };\n    }])\n;\n});"
  },
  {
    "path": "html/lib/angular-cookies/angular-cookies.js",
    "content": "/**\n * @license AngularJS v1.5.5\n * (c) 2010-2016 Google, Inc. http://angularjs.org\n * License: MIT\n */\n(function(window, angular) {'use strict';\n\n/**\n * @ngdoc module\n * @name ngCookies\n * @description\n *\n * # ngCookies\n *\n * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.\n *\n *\n * <div doc-module-components=\"ngCookies\"></div>\n *\n * See {@link ngCookies.$cookies `$cookies`} for usage.\n */\n\n\nangular.module('ngCookies', ['ng']).\n  /**\n   * @ngdoc provider\n   * @name $cookiesProvider\n   * @description\n   * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service.\n   * */\n   provider('$cookies', [function $CookiesProvider() {\n    /**\n     * @ngdoc property\n     * @name $cookiesProvider#defaults\n     * @description\n     *\n     * Object containing default options to pass when setting cookies.\n     *\n     * The object may have following properties:\n     *\n     * - **path** - `{string}` - The cookie will be available only for this path and its\n     *   sub-paths. By default, this is the URL that appears in your `<base>` tag.\n     * - **domain** - `{string}` - The cookie will be available only for this domain and\n     *   its sub-domains. For security reasons the user agent will not accept the cookie\n     *   if the current domain is not a sub-domain of this domain or equal to it.\n     * - **expires** - `{string|Date}` - String of the form \"Wdy, DD Mon YYYY HH:MM:SS GMT\"\n     *   or a Date object indicating the exact date/time this cookie will expire.\n     * - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a\n     *   secured connection.\n     *\n     * Note: By default, the address that appears in your `<base>` tag will be used as the path.\n     * This is important so that cookies will be visible for all routes when html5mode is enabled.\n     *\n     **/\n    var defaults = this.defaults = {};\n\n    function calcOptions(options) {\n      return options ? angular.extend({}, defaults, options) : defaults;\n    }\n\n    /**\n     * @ngdoc service\n     * @name $cookies\n     *\n     * @description\n     * Provides read/write access to browser's cookies.\n     *\n     * <div class=\"alert alert-info\">\n     * Up until Angular 1.3, `$cookies` exposed properties that represented the\n     * current browser cookie values. In version 1.4, this behavior has changed, and\n     * `$cookies` now provides a standard api of getters, setters etc.\n     * </div>\n     *\n     * Requires the {@link ngCookies `ngCookies`} module to be installed.\n     *\n     * @example\n     *\n     * ```js\n     * angular.module('cookiesExample', ['ngCookies'])\n     *   .controller('ExampleController', ['$cookies', function($cookies) {\n     *     // Retrieving a cookie\n     *     var favoriteCookie = $cookies.get('myFavorite');\n     *     // Setting a cookie\n     *     $cookies.put('myFavorite', 'oatmeal');\n     *   }]);\n     * ```\n     */\n    this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) {\n      return {\n        /**\n         * @ngdoc method\n         * @name $cookies#get\n         *\n         * @description\n         * Returns the value of given cookie key\n         *\n         * @param {string} key Id to use for lookup.\n         * @returns {string} Raw cookie value.\n         */\n        get: function(key) {\n          return $$cookieReader()[key];\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cookies#getObject\n         *\n         * @description\n         * Returns the deserialized value of given cookie key\n         *\n         * @param {string} key Id to use for lookup.\n         * @returns {Object} Deserialized cookie value.\n         */\n        getObject: function(key) {\n          var value = this.get(key);\n          return value ? angular.fromJson(value) : value;\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cookies#getAll\n         *\n         * @description\n         * Returns a key value object with all the cookies\n         *\n         * @returns {Object} All cookies\n         */\n        getAll: function() {\n          return $$cookieReader();\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cookies#put\n         *\n         * @description\n         * Sets a value for given cookie key\n         *\n         * @param {string} key Id for the `value`.\n         * @param {string} value Raw value to be stored.\n         * @param {Object=} options Options object.\n         *    See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}\n         */\n        put: function(key, value, options) {\n          $$cookieWriter(key, value, calcOptions(options));\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cookies#putObject\n         *\n         * @description\n         * Serializes and sets a value for given cookie key\n         *\n         * @param {string} key Id for the `value`.\n         * @param {Object} value Value to be stored.\n         * @param {Object=} options Options object.\n         *    See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}\n         */\n        putObject: function(key, value, options) {\n          this.put(key, angular.toJson(value), options);\n        },\n\n        /**\n         * @ngdoc method\n         * @name $cookies#remove\n         *\n         * @description\n         * Remove given cookie\n         *\n         * @param {string} key Id of the key-value pair to delete.\n         * @param {Object=} options Options object.\n         *    See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults}\n         */\n        remove: function(key, options) {\n          $$cookieWriter(key, undefined, calcOptions(options));\n        }\n      };\n    }];\n  }]);\n\nangular.module('ngCookies').\n/**\n * @ngdoc service\n * @name $cookieStore\n * @deprecated\n * @requires $cookies\n *\n * @description\n * Provides a key-value (string-object) storage, that is backed by session cookies.\n * Objects put or retrieved from this storage are automatically serialized or\n * deserialized by angular's toJson/fromJson.\n *\n * Requires the {@link ngCookies `ngCookies`} module to be installed.\n *\n * <div class=\"alert alert-danger\">\n * **Note:** The $cookieStore service is **deprecated**.\n * Please use the {@link ngCookies.$cookies `$cookies`} service instead.\n * </div>\n *\n * @example\n *\n * ```js\n * angular.module('cookieStoreExample', ['ngCookies'])\n *   .controller('ExampleController', ['$cookieStore', function($cookieStore) {\n *     // Put cookie\n *     $cookieStore.put('myFavorite','oatmeal');\n *     // Get cookie\n *     var favoriteCookie = $cookieStore.get('myFavorite');\n *     // Removing a cookie\n *     $cookieStore.remove('myFavorite');\n *   }]);\n * ```\n */\n factory('$cookieStore', ['$cookies', function($cookies) {\n\n    return {\n      /**\n       * @ngdoc method\n       * @name $cookieStore#get\n       *\n       * @description\n       * Returns the value of given cookie key\n       *\n       * @param {string} key Id to use for lookup.\n       * @returns {Object} Deserialized cookie value, undefined if the cookie does not exist.\n       */\n      get: function(key) {\n        return $cookies.getObject(key);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $cookieStore#put\n       *\n       * @description\n       * Sets a value for given cookie key\n       *\n       * @param {string} key Id for the `value`.\n       * @param {Object} value Value to be stored.\n       */\n      put: function(key, value) {\n        $cookies.putObject(key, value);\n      },\n\n      /**\n       * @ngdoc method\n       * @name $cookieStore#remove\n       *\n       * @description\n       * Remove given cookie\n       *\n       * @param {string} key Id of the key-value pair to delete.\n       */\n      remove: function(key) {\n        $cookies.remove(key);\n      }\n    };\n\n  }]);\n\n/**\n * @name $$cookieWriter\n * @requires $document\n *\n * @description\n * This is a private service for writing cookies\n *\n * @param {string} name Cookie name\n * @param {string=} value Cookie value (if undefined, cookie will be deleted)\n * @param {Object=} options Object with options that need to be stored for the cookie.\n */\nfunction $$CookieWriter($document, $log, $browser) {\n  var cookiePath = $browser.baseHref();\n  var rawDocument = $document[0];\n\n  function buildCookieString(name, value, options) {\n    var path, expires;\n    options = options || {};\n    expires = options.expires;\n    path = angular.isDefined(options.path) ? options.path : cookiePath;\n    if (angular.isUndefined(value)) {\n      expires = 'Thu, 01 Jan 1970 00:00:00 GMT';\n      value = '';\n    }\n    if (angular.isString(expires)) {\n      expires = new Date(expires);\n    }\n\n    var str = encodeURIComponent(name) + '=' + encodeURIComponent(value);\n    str += path ? ';path=' + path : '';\n    str += options.domain ? ';domain=' + options.domain : '';\n    str += expires ? ';expires=' + expires.toUTCString() : '';\n    str += options.secure ? ';secure' : '';\n\n    // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:\n    // - 300 cookies\n    // - 20 cookies per unique domain\n    // - 4096 bytes per cookie\n    var cookieLength = str.length + 1;\n    if (cookieLength > 4096) {\n      $log.warn(\"Cookie '\" + name +\n        \"' possibly not set or overflowed because it was too large (\" +\n        cookieLength + \" > 4096 bytes)!\");\n    }\n\n    return str;\n  }\n\n  return function(name, value, options) {\n    rawDocument.cookie = buildCookieString(name, value, options);\n  };\n}\n\n$$CookieWriter.$inject = ['$document', '$log', '$browser'];\n\nangular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() {\n  this.$get = $$CookieWriter;\n});\n\n\n})(window, window.angular);\n"
  },
  {
    "path": "html/lib/angular-ui-grid/animation.less",
    "content": "/*\n   Animation example, for spinners\n*/\n.ui-grid-animate-spin {\n  -moz-animation: ui-grid-spin 2s infinite linear;\n  -o-animation: ui-grid-spin 2s infinite linear;\n  -webkit-animation: ui-grid-spin 2s infinite linear;\n  animation: ui-grid-spin 2s infinite linear;\n  display: inline-block;\n}\n@-moz-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-webkit-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-o-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-ms-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/body.less",
    "content": "\n.ui-grid-render-container {\n  position: inherit;\n  // overflow: hidden;\n\n  .border-radius(0, @gridBorderRadius, @gridBorderRadius, 0);\n\n  // Prevent an outline from showing if we focus the render container element\n  &:focus {\n    outline: none;\n  }\n}\n\n.ui-grid-viewport {\n  // overflow: auto; // TODO(c0bra): turn back on when virtual repeater is hooked up\n  min-height: 20px;\n  position: relative;\n  overflow-y: scroll;\n  -webkit-overflow-scrolling: touch;\n\n  &:focus {\n    outline: none !important;\n  }\n}\n\n.ui-grid-canvas {\n  position: relative;\n  padding-top:1px; //to prevent canvas from absorbing the 1st rendered row's margin\n}\n\n.ui-grid-row {\n  //position: absolute;\n  // border-bottom: 1px solid @borderColor;\n\n  &:nth-child(odd) .ui-grid-cell {\n    background-color: @rowColorOdd; //rgb(253, 253, 253);\n  }\n\n  &:nth-child(even) .ui-grid-cell {\n    background-color: @rowColorEven;\n  }\n\n  &:last-child .ui-grid-cell {\n    border-bottom-color: @borderColor;\n    border-bottom-style: solid;\n\n  }\n}\n\n.ui-grid-no-row-overlay {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  margin: 10%;\n\n  .ui-grid-top-panel-background;\n  .border-radius(@gridBorderRadius);\n  border: @gridBorderWidth solid @borderColor;\n\n  font-size: 2em;\n  text-align: center;\n\n  > * {\n    position: absolute;\n    display: table;\n    margin: auto 0;\n    width: 100%;\n    top: 0;\n    bottom: 0;\n    left: 0;\n    right: 0;\n    opacity: 0.66;\n  }\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/bootstrap/bootstrap.less",
    "content": "/*!\n * Bootstrap v3.3.5 (http://getbootstrap.com)\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n */\n\n/****** NOTE: IMPORTANT INFORMATION ABOUT USING THIS FILE *********\\\n * If you are importing this file then use `@import (reference) '..../bootstrap'`\n * ENSURE that you use the (refrerence)\n * WHY? Because otherwise you will import the entire contents of less bootstrap\n *\n * How does this work?\n * All of the bootstrap less elements are namespaced under `#ui-grid-twbs`\n * This prevents the CSS generated using this file from conflicting with a project's\n * import of bootstrap.\n *\n * XXX: Why are so many of these imports commented out?\n * There are several issues with the `extend` function in less.\n * Using extend, even within an import that only has a reference will import that\n * css element. This causes bloat in the distributed css files.\n * Related Issues:\n * https://github.com/less/less.js/issues/1968\n * https://github.com/less/less.js/issues/1851\n *\n * If you comment in one of these files you may get much more than css then you want.\n * Only do this sparingly.\n */\n#ui-grid-twbs {\n  // Core variables and mixins\n  @import (reference) \"@{bootstrapDirectory}/less/variables.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/mixins.less\";\n\n  // Reset and dependencies\n  @import (reference) \"@{bootstrapDirectory}/less/normalize.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/print.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/glyphicons.less\";\n\n  // Core CSS\n  @import (reference) \"@{bootstrapDirectory}/less/scaffolding.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/code.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/tables.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/forms.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/buttons.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/type.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/grid.less\";\n\n  // Components\n  @import (reference) \"@{bootstrapDirectory}/less/component-animations.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/dropdowns.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/button-groups.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/input-groups.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/breadcrumbs.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/pagination.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/labels.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/badges.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/jumbotron.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/alerts.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/progress-bars.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/media.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/list-group.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/responsive-embed.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/wells.less\";\n  @import (reference) \"@{bootstrapDirectory}/less/close.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/navs.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/navbar.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/pager.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/thumbnails.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/panels.less\";\n\n  // Components w/ JavaScript\n  @import (reference) \"@{bootstrapDirectory}/less/tooltip.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/modals.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/popovers.less\";\n\n  // Utility classes\n  @import (reference) \"@{bootstrapDirectory}/less/utilities.less\";\n  //@import (reference) \"@{bootstrapDirectory}/less/responsive-utilities.less\";\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/cell.less",
    "content": "@import 'variables';\n\n.ui-grid-cell {\n  overflow: hidden;\n  // position: absolute;\n  // position: relative; // NOTE: removing so border is visible\n  float: left;\n  background-color: inherit;\n  border-right: @gridBorderWidth solid;\n  border-color: @borderColor;\n  box-sizing: border-box;\n\n  &:last-child {\n    border-right: 0;\n  }\n}\n\n.ui-grid-cell-contents {\n  padding: 5px;\n  -moz-box-sizing: border-box;\n  -webkit-box-sizing: border-box;\n  box-sizing: border-box;\n  white-space: nowrap;\n  -ms-text-overflow: ellipsis;\n  -o-text-overflow: ellipsis;\n  text-overflow: ellipsis;\n  overflow: hidden;\n  height: 100%;\n  // width: 100%;\n}\n\n.ui-grid-cell-contents-hidden {\n  visibility: hidden;\n  width: 0;\n  height:0;\n  display: none;\n}\n\n.ui-grid-row .ui-grid-cell.ui-grid-row-header-cell {\n  background-color: @rowHeaderCell;\n  border-bottom: solid @gridBorderWidth @borderColor;\n}\n\n"
  },
  {
    "path": "html/lib/angular-ui-grid/cellnav/less/cellNav.less",
    "content": "@import '../../../less/variables';\n@import (reference) '../../../less/bootstrap/bootstrap';\n\n// .ui-grid-cell-contents:focus {\n//   outline: 0;\n//   background-color: @focusedCell;\n// }\n\n.ui-grid-cell-focus {\n  outline: 0;\n  background-color: @focusedCell;\n}\n\n.ui-grid-focuser {\n  position: absolute;\n  left: 0px;\n  top: 0px;\n  z-index: -1;\n  width:100%;\n  height:100%;\n  #ui-grid-twbs > .form-control-focus();\n}\n\n.ui-grid-offscreen{\n  display: block;\n  position: absolute;\n  left: -10000px;\n  top: -10000px;\n  clip:rect(0px,0px,0px,0px);\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/edit/less/edit.less",
    "content": "@import '../../../less/variables';\n\ndiv.ui-grid-cell {\n  input {\n    border-radius: inherit;\n    padding: 0;\n    width: 100%;\n    color: inherit;\n    height: auto;\n    font: inherit;\n    outline: none;\n  }\n  input:focus {\n    color: inherit;\n    outline: none;\n  }\n  input[type=\"checkbox\"] {\n    margin: 9px 0 0 6px;\n    width: auto;\n  }\n  input.ng-invalid {\n    border: @invalidValueBorder;\n  }\n  input.ng-valid {\n    border: @validValueBorder;\n  }\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/elements.less",
    "content": "/*---------------------------------------------------\n    LESS Elements 0.9\n  ---------------------------------------------------\n    A set of useful LESS mixins\n    More info at: http://lesselements.com\n  ---------------------------------------------------*/\n\n.gradient(@color: #F5F5F5, @start: #EEE, @stop: #FFF) {\n  background: @color;\n  background: -webkit-gradient(linear,\n                               left bottom,\n                               left top,\n                               color-stop(0, @start),\n                               color-stop(1, @stop));\n  background: -ms-linear-gradient(bottom,\n                                  @start,\n                                  @stop);\n  background: -moz-linear-gradient(center bottom,\n                                   @start 0%,\n                                   @stop 100%);\n  background: -o-linear-gradient(@stop,\n                                 @start);\n  filter: e(%(\"progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)\",@stop,@start));\n}\n.bw-gradient(@color: #F5F5F5, @start: 0, @stop: 255) {\n  background: @color;\n  background: -webkit-gradient(linear,\n                               left bottom,\n                               left top,\n                               color-stop(0, rgb(@start,@start,@start)),\n                               color-stop(1, rgb(@stop,@stop,@stop)));\n  background: -ms-linear-gradient(bottom,\n                                  rgb(@start,@start,@start) 0%,\n                                  rgb(@stop,@stop,@stop) 100%);\n  background: -moz-linear-gradient(center bottom,\n                                   rgb(@start,@start,@start) 0%,\n                                   rgb(@stop,@stop,@stop) 100%);\n  background: -o-linear-gradient(rgb(@stop,@stop,@stop),\n                                 rgb(@start,@start,@start));\n  filter: e(%(\"progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)\",rgb(@stop,@stop,@stop),rgb(@start,@start,@start)));\n}\n.bordered(@top-color: #EEE, @right-color: #EEE, @bottom-color: #EEE, @left-color: #EEE) {\n  border-top: solid 1px @top-color;\n  border-left: solid 1px @left-color;\n  border-right: solid 1px @right-color;\n  border-bottom: solid 1px @bottom-color;\n}\n.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1) {\n  -webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);\n  -moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);\n  box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);\n}\n.rounded(@radius: 2px) {\n  -webkit-border-radius: @radius;\n  -moz-border-radius: @radius;\n  border-radius: @radius;\n}\n.border-radius(@topright: 0, @bottomright: 0, @bottomleft: 0, @topleft: 0) {\n  -webkit-border-top-right-radius: @topright;\n  -webkit-border-bottom-right-radius: @bottomright;\n  -webkit-border-bottom-left-radius: @bottomleft;\n  -webkit-border-top-left-radius: @topleft;\n  -moz-border-radius-topright: @topright;\n  -moz-border-radius-bottomright: @bottomright;\n  -moz-border-radius-bottomleft: @bottomleft;\n  -moz-border-radius-topleft: @topleft;\n  border-top-right-radius: @topright;\n  border-bottom-right-radius: @bottomright;\n  border-bottom-left-radius: @bottomleft;\n  border-top-left-radius: @topleft;\n  .background-clip(padding-box);\n}\n.opacity(@opacity: 0.5) {\n  -moz-opacity: @opacity;\n  -khtml-opacity: @opacity;\n  -webkit-opacity: @opacity;\n  opacity: @opacity;\n  @opperc: @opacity * 100;\n  -ms-filter: ~\"progid:DXImageTransform.Microsoft.Alpha(opacity=@{opperc})\";\n  filter: ~\"alpha(opacity=@{opperc})\";\n}\n.transition-duration(@duration: 0.2s) {\n  -moz-transition-duration: @duration;\n  -webkit-transition-duration: @duration;\n  -o-transition-duration: @duration;\n  transition-duration: @duration;\n}\n.transform(...) {\n  -webkit-transform: @arguments;\n  -moz-transform: @arguments;\n  -o-transform: @arguments;\n  -ms-transform: @arguments;\n  transform: @arguments;\n}\n.rotation(@deg:5deg){\n  .transform(rotate(@deg));\n}\n.scale(@ratio:1.5){\n  .transform(scale(@ratio));\n}\n.transition(@type:all, @duration:0.2s, @ease:ease-out) {\n  -webkit-transition: @type @duration @ease;\n  -moz-transition: @type @duration @ease;\n  -o-transition: @type @duration @ease;\n  transition: @type @duration @ease;\n}\n.inner-shadow(@horizontal:0, @vertical:1px, @blur:2px, @alpha: 0.4) {\n  -webkit-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);\n  -moz-box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);\n  box-shadow: inset @horizontal @vertical @blur rgba(0, 0, 0, @alpha);\n}\n.box-shadow(@arguments) {\n  -webkit-box-shadow: @arguments;\n  -moz-box-shadow: @arguments;\n  box-shadow: @arguments;\n}\n.box-sizing(@sizing: border-box) {\n  -ms-box-sizing: @sizing;\n  -moz-box-sizing: @sizing;\n  -webkit-box-sizing: @sizing;\n  box-sizing: @sizing;\n}\n.user-select(@argument: none) {\n  -webkit-user-select: @argument;\n  -moz-user-select: @argument;\n  -ms-user-select: @argument;\n  user-select: @argument;\n}\n.columns(@colwidth: 250px, @colcount: 0, @colgap: 50px, @columnRuleColor: #EEE, @columnRuleStyle: solid, @columnRuleWidth: 1px) {\n  -moz-column-width: @colwidth;\n  -moz-column-count: @colcount;\n  -moz-column-gap: @colgap;\n  -moz-column-rule-color: @columnRuleColor;\n  -moz-column-rule-style: @columnRuleStyle;\n  -moz-column-rule-width: @columnRuleWidth;\n  -webkit-column-width: @colwidth;\n  -webkit-column-count: @colcount;\n  -webkit-column-gap: @colgap;\n  -webkit-column-rule-color: @columnRuleColor;\n  -webkit-column-rule-style: @columnRuleStyle;\n  -webkit-column-rule-width: @columnRuleWidth;\n  column-width: @colwidth;\n  column-count: @colcount;\n  column-gap: @colgap;\n  column-rule-color: @columnRuleColor;\n  column-rule-style: @columnRuleStyle;\n  column-rule-width: @columnRuleWidth;\n}\n.translate(@x:0, @y:0) {\n  .transform(translate(@x, @y));\n}\n.background-clip(@argument: padding-box) {\n  -moz-background-clip: @argument;\n  -webkit-background-clip: @argument;\n  background-clip: @argument;\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/expandable/less/expandable.less",
    "content": "@import '../../../less/variables';\n\n.expandableRow {\n  .ui-grid-row {\n\n    &:nth-child(odd) .ui-grid-cell {\n      background-color: @rowColorOdd;\n    }\n\n    &:nth-child(even) .ui-grid-cell {\n      background-color: @rowColorEven;\n    }\n\n  }\n}\n\n\n.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell{\n  pointer-events: none;\n}\n.ui-grid-expandable-buttons-cell i{\n  pointer-events: all;\n}\n\n.scrollFiller {\n  float:left;\n  border:1px solid @borderColor;\n}\n\n"
  },
  {
    "path": "html/lib/angular-ui-grid/exporter/less/exporter.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-exporter-header {\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/footer.less",
    "content": "\n.ui-grid-footer-panel-background {\n  .gradient(@headerBackgroundColor, @headerGradientStart, @headerGradientStop);\n}\n\n@topPanelRadius: @gridBorderRadius - @gridBorderWidth;\n.ui-grid-footer-panel {\n  position: relative;\n  // z-index: 1;\n  // background-color: @darkGray; // #EAEAEA\n  border-bottom: 1px solid @borderColor; // #D4D4D4\n  border-top: 1px solid @borderColor;\n  overflow: hidden;  // Disable so menus show up\n  font-weight: bold;\n\n  // .gradient(@headerBackgroundColor, @headerGradientStart, @headerGradientStop);\n  .ui-grid-footer-panel-background;\n\n  .border-radius(@topPanelRadius, 0, 0, @topPanelRadius);\n}\n\n.ui-grid-grid-footer {\n  float: left;\n  width: 100%;\n}\n\n.ui-grid-footer-viewport {\n  overflow: hidden; // Disable so menus show up\n}\n\n.ui-grid-footer-canvas {\n  position: relative;\n\n  // Clearfix for floating header cells\n  &:before, &:after {\n    content: \"\";\n    display: table;\n    line-height: 0;\n  }\n\n  &:after {\n    clear:both;\n  }\n\n  // .border-radius(@gridBorderRadius, 0, 0, @gridBorderRadius);\n}\n\n.ui-grid-footer-cell-wrapper {\n  position: relative;\n  display: table;\n  box-sizing: border-box;\n  height: 100%;\n}\n\n.ui-grid-footer-cell-row {\n  display: table-row;\n}\n\n.ui-grid-footer-cell {\n  overflow: hidden;\n  // position: relative; // NOTE: removing so border is visible\n  background-color: inherit;\n  border-right: @gridBorderWidth solid;\n  border-color: @borderColor;\n  box-sizing: border-box;\n  display: table-cell;\n\n  &:last-child {\n    border-right: 0;\n  }\n}\n\ninput[type=\"text\"].ui-grid-filter-input {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 100%;\n\n  border: @gridBorderWidth solid  @borderColor;\n  .border-radius(@gridBorderRadius);\n\n  &:hover {\n    border: @gridBorderWidth solid  @borderColor;\n  }\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/goups.less",
    "content": "\n@topPanelRadius: @gridBorderRadius - @gridBorderWidth;\n\n.ui-grid-group-panel {\n  .gradient(@headerBackgroundColor, @headerGradientStart, @headerGradientStop);\n  border-bottom: 1px solid @borderColor; // #D4D4D4\n  .border-radius(@topPanelRadius, 0, 0, @topPanelRadius);\n  min-height: 30px;\n}\n  .ui-grid-group-panel .hidden {\n    display: none;\n  }\n  .ui-grid-group-panel .description {\n    margin-top: 5px;\n    margin-left: 5px;\n  }\n\n.ui-grid-group-list {\n  list-style-type: none;\n  margin: 0;\n  padding: 0;\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/grid.less",
    "content": "\n.ui-grid {\n  border: @gridBorderWidth solid @borderColor;\n  box-sizing: content-box; // If bootstrap (or another included library) makes the default sizing on element \"border-box\", then calculations get messed up\n\n  .rounded(@gridBorderRadius);\n\n  .transform(translateZ(0));\n\n}\n\n.ui-grid-vertical-bar {\n  position: absolute;\n  right: 0;\n  width: 0;\n}\n\n.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar, .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  width: @gridBorderWidth;\n}\n\n.ui-grid-scrollbar-placeholder{\n  background-color: transparent;\n}\n\n.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: @headerVerticalBarColor;\n}\n\n.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: @verticalBarColor;\n}\n\n.ui-grid-header-cell:last-child .ui-grid-vertical-bar {\n  right: -1px; // TODO(c0bra): Should this be grid width? Test column resizing with custom grid border width\n  width: @gridBorderWidth;\n  background-color: @headerVerticalBarColor;\n}\n\n// .ui-grid-vertical-bar-visible {\n//   width: 1px;\n//   background-color: @borderColor;\n// }\n\n.ui-grid-clearfix {\n  &:before, &:after {\n    content: \"\";\n    display: table;\n  }\n\n  &:after {\n    clear:both;\n  }\n}\n\n.ui-grid-invisible {\n  visibility: hidden;;\n}\n\n// Wraps the contents inside the grid directive with a relatively-positioned element so that all absolute elements are positioned relative to the grid, and not the page\n.ui-grid-contents-wrapper {\n  position: relative;\n  height: 100%;\n  width: 100%;\n}\n\n// Only display content to screen readers\n//\n// See: http://a11yproject.com/posts/how-to-hide-content/\n\n.ui-grid-sr-only {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  padding: 0;\n  overflow: hidden;\n  clip: rect(0,0,0,0);\n  border: 0;\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/grouping/less/grouping.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-tree-header-row {\n  font-weight: bold !important;\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/header.less",
    "content": "\n.ui-grid-top-panel-background {\n  .gradient(@headerBackgroundColor, @headerGradientStart, @headerGradientStop);\n}\n\n@topPanelRadius: @gridBorderRadius - @gridBorderWidth;\n\n.ui-grid-header {\n  border-bottom: 1px solid @borderColor;\n  box-sizing: border-box;\n}\n\n.ui-grid-top-panel {\n    position: relative;\n    // border-bottom: 1px solid @borderColor; // #D4D4D4\n\n    overflow: hidden;  // Disable so menus show up\n    font-weight: bold;\n\n    // .gradient(@headerBackgroundColor, @headerGradientStart, @headerGradientStop);\n    .ui-grid-top-panel-background;\n\n    .border-radius(@topPanelRadius, 0, 0, @topPanelRadius);\n}\n\n\n.ui-grid-header-viewport {\n  overflow: hidden; // Disable so menus show up\n}\n\n.ui-grid-header-canvas {\n\n  // Clearfix for floating header cells\n  &:before, &:after {\n    content: \"\";\n    display: table;\n    line-height: 0;\n  }\n\n  &:after {\n    clear:both;\n  }\n\n  // .border-radius(@gridBorderRadius, 0, 0, @gridBorderRadius);\n}\n\n.ui-grid-header-cell-wrapper {\n  position: relative;\n  display: table;\n  box-sizing: border-box;\n  height: 100%;\n}\n\n.ui-grid-header-cell-row {\n  display: table-row;\n  position: relative\n}\n\n.ui-grid-header-cell {\n  position: relative;\n  box-sizing: border-box;\n  background-color: inherit;\n  border-right: @gridBorderWidth solid;\n  border-color: @headerVerticalBarColor;\n  display: table-cell;\n\n  &:last-child {\n    border-right: 0;\n  }\n\n  .user-select(none);\n\n  // Default to width 0 so header height can calculate right. Otherwise\n  //  the header cells will flow onto the next line of the header container\n  //  and cause the header height to be calculated as twice the height\n  //  it should be. The column widths are calculated dynamically\n  width: 0;\n\n  .sortable {\n    cursor: pointer;\n  }\n\n  // Moves the sort priority number closer to the icon\n  .ui-grid-sort-priority-number {\n    margin-left: -8px;\n  }\n}\n\n// Make vertical bar in header row fill the height of the cell completely\n.ui-grid-header .ui-grid-vertical-bar {\n  top: 0;\n  bottom: 0;\n}\n\n.ui-grid-column-menu-button {\n  position: absolute;\n  right: @gridBorderWidth; // So it doesn't overlay the vertical bar\n  top: 0;\n  // bottom: 0;\n  // .ui-grid-top-panel-background;\n\n  .ui-grid-icon-angle-down {\n    vertical-align: sub;\n  }\n}\n\n.ui-grid-column-menu-button-last-col {\n  margin-right: 25px;\n}\n\n.ui-grid-column-menu {\n  position: absolute;\n}\n\n/* Slide up/down animations */\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid {\n  &.ng-hide-add, &.ng-hide-remove {\n    .transition(all, 0.05s, linear);\n    display: block !important;\n  }\n\n  &.ng-hide-add.ng-hide-add-active,\n  &.ng-hide-remove {\n    .transform(translateY(-100%));\n  }\n\n  &.ng-hide-add,\n  &.ng-hide-remove.ng-hide-remove-active {\n    .transform(translateY(0));\n  }\n}\n\n/* Slide up/down animations */\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid {\n  &.ng-hide-add, &.ng-hide-remove {\n    .transition(all, 0.05s, linear);\n    display: block !important;\n  }\n\n  &.ng-hide-add.ng-hide-add-active,\n  &.ng-hide-remove {\n    .transform(translateY(-100%));\n  }\n\n  &.ng-hide-add,\n  &.ng-hide-remove.ng-hide-remove-active {\n    .transform(translateY(0));\n  }\n}\n\n\n.ui-grid-filter-container {\n  padding: 4px 10px;\n  position: relative;\n\n  .ui-grid-filter-button {\n    position: absolute;\n    top: 0;\n    bottom: 0;\n    right: 0;\n\n    [class^=\"ui-grid-icon\"] {\n      position: absolute;\n      top: 50%;\n      line-height: 32px;\n      margin-top: -16px;\n      right: 10px;\n      opacity: 0.66;\n\n      &:hover {\n        opacity: 1;\n      }\n    }\n  }\n\n  .ui-grid-filter-button-select {\n    position: absolute;\n    top: 0;\n    bottom: 0;\n    right: 0;\n\n    [class^=\"ui-grid-icon\"] {\n      position: absolute;\n      top: 50%;\n      line-height: 32px;\n      margin-top: -16px;\n      right: 0px;\n      opacity: 0.66;\n\n      &:hover {\n        opacity: 1;\n      }\n    }\n  }\n}\n\ninput[type=\"text\"].ui-grid-filter-input {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 100%;\n\n  border: @gridBorderWidth solid  @borderColor;\n  .border-radius(@gridBorderRadius);\n\n  &:hover {\n    border: @gridBorderWidth solid  @borderColor;\n  }\n}\n\nselect.ui-grid-filter-select {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 90%;\n\n  border: @gridBorderWidth solid  @borderColor;\n  .border-radius(@gridBorderRadius);\n\n  &:hover {\n    border: @gridBorderWidth solid  @borderColor;\n  }\n\n  .ui-grid-filter-cancel-button-hidden & {\n    width: 100%;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/icons.less",
    "content": "@font-face {\n  font-family: 'ui-grid';\n  src: url('@{font-path}ui-grid.eot');\n  src: url('@{font-path}ui-grid.eot#iefix') format('embedded-opentype'),\n       url('@{font-path}ui-grid.woff') format('woff'),\n       url('@{font-path}ui-grid.ttf') format('truetype'),\n       url('@{font-path}ui-grid.svg?#ui-grid') format('svg');\n  font-weight: normal;\n  font-style: normal;\n}\n/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */\n/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */\n/*\n@media screen and (-webkit-min-device-pixel-ratio:0) {\n  @font-face {\n    font-family: 'ui-grid';\n    src: url('@{font-path}ui-grid.svg?12312827#ui-grid') format('svg');\n  }\n}\n*/\n \n [class^=\"ui-grid-icon\"]:before, [class*=\" ui-grid-icon\"]:before {\n  font-family: \"ui-grid\";\n  font-style: normal;\n  font-weight: normal;\n  speak: none;\n \n  display: inline-block;\n  text-decoration: inherit;\n  width: 1em;\n  margin-right: .2em;\n  text-align: center;\n  /* opacity: .8; */\n \n  /* For safety - reset parent styles, that can break glyph codes*/\n  font-variant: normal;\n  text-transform: none;\n     \n  /* fix buttons height, for twitter bootstrap */\n  line-height: 1em;\n \n  /* Animation center compensation - margins should be symmetric */\n  /* remove if not needed */\n  margin-left: .2em;\n \n  /* you can be more comfortable with increased icons size */\n  /* font-size: 120%; */\n \n  /* Uncomment for 3D effect */\n  /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */\n}\n\n.ui-grid-icon-blank::before {\n  width: 1em;\n  content: ' ';\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/importer/less/importer.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-importer-header {\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/main.less",
    "content": "@import (once, reference) 'bootstrap/bootstrap';\n@import 'grid';\n@import 'header';\n@import 'body';\n@import 'cell';\n@import 'footer';\n@import 'menu';\n@import 'sorting';\n@import 'icons';\n@import 'rtl';\n@import 'animation';\n@import 'elements';\n@import 'variables';"
  },
  {
    "path": "html/lib/angular-ui-grid/menu.less",
    "content": ".ui-grid-menu-button {\n  z-index: 2;\n  position: absolute;\n  right: 0;\n  top: 0;\n  background: @headerBackgroundColor;\n  border: @gridBorderWidth solid @borderColor;\n  cursor: pointer;\n  height: 31px;\n  font-weight: normal;\n}\n\n.ui-grid-menu-button .ui-grid-icon-container {\n  margin-top: 3px;\n}\n\n.ui-grid-menu-button .ui-grid-menu {\n  right: 0;\n  .ui-grid-menu-mid {\n    overflow: scroll;\n    border: @gridBorderWidth solid @borderColor;\n  }\n}\n\n.ui-grid-menu {\n  z-index: 2; // So it shows up over grid canvas\n  position: absolute;\n  padding: 0 10px 20px 10px;\n  cursor: pointer;\n  box-sizing: border-box;\n}\n\n.ui-grid-menu .ui-grid-menu-inner {\n  background: @headerBackgroundColor;\n  border: @gridBorderWidth solid @borderColor;\n  position: relative;\n  white-space: nowrap;\n\n  .rounded(@gridBorderRadius);\n  .box-shadow(e(\"0 10px 20px rgba(0, 0, 0, 0.2), inset 0 12px 12px -14px rgba(0, 0, 0, 0.2)\"));\n\n  // Small hidden close button that only appears when focused.\n  .ui-grid-menu-close-button {\n    position: absolute;\n    right: 0px;\n    top: 0px;\n    #ui-grid-twbs > .btn();\n    #ui-grid-twbs > .button-size(1px; 1px; 10px; 1; 2px);\n    #ui-grid-twbs > .button-variant(transparent, transparent, transparent);\n    > i {\n      opacity: 0.75;\n      color: black;\n    }\n  }\n}\n\n.ui-grid-menu .ui-grid-menu-inner ul {\n  margin: 0;\n  padding: 0;\n  list-style-type: none;\n\n  li {\n    padding: 0px;\n    button {\n      min-width: 100%;\n      padding: 8px;\n      text-align: left;\n      background: transparent;\n      border: none;\n\n      // Show a shadow when hovering over a menu item\n      &:hover,\n      &:focus {\n        // background-color: negation(@headerBackgroundColor, #fff);\n        .inner-shadow(@vertical: 0, @blur: 14px, @alpha: 0.2);\n      }\n      &.ui-grid-menu-item-active {\n        .inner-shadow(@vertical: 0, @blur: 14px, @alpha: 0.2);\n        background-color: @selectedColor;\n      }\n    }\n  }\n\n  // Show a bottom border on all but the last menu item\n  li:not(:last-child) > button {\n    border-bottom: @gridBorderWidth solid @borderColor;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/move-columns/less/colMovable.less",
    "content": "@import '../../../less/variables';\n\n.movingColumn {\n  position: absolute;\n  top: 0;\n  border: 1px solid @borderColor;\n  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n\n  .ui-grid-icon-angle-down {\n    display: none;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/pagination/less/pagination.less",
    "content": "@import \"../../../less/variables\";\n@import \"../../../less/elements\";\n@import (reference) \"../../../less/bootstrap/bootstrap\";\n\n.ui-grid-pager-panel {\n  position: absolute;\n  left: 0;\n  bottom: 0;\n  width: 100%;\n  padding-top: 3px;\n  padding-bottom: 3px;\n  box-sizing: content-box;\n}\n\n.ui-grid-pager-container {\n  float: left;\n}\n\n.ui-grid-pager-control {\n  margin-right: 10px;\n  margin-left: 10px;\n  min-width: 135px;\n  float: left;\n\n  button {\n    height: 25px;\n    min-width: 26px;\n    #ui-grid-twbs > .btn;\n    #ui-grid-twbs > .button-variant(@paginationButtonColor, @paginationButtonBackgroundColor, @paginationButtonBorderColor);\n  }\n\n  input {\n    #ui-grid-twbs > .form-control();\n    #ui-grid-twbs > .input-sm ();\n    display: inline;\n    height: 26px;\n    width: 50px;\n    vertical-align: top;\n  }\n\n  .ui-grid-pager-max-pages-number{\n    vertical-align: bottom;\n    > * {\n      vertical-align: middle;\n    }\n  }\n\n  .first-bar {\n    width: 10px;\n    border-left: 2px solid #4d4d4d;\n    margin-top: -6px;\n    height: 12px;\n    margin-left: -3px;\n  }\n\n  .first-bar-rtl {\n    width: 10px;\n    border-left: 2px solid #4d4d4d;\n    margin-top: -6px;\n    height: 12px;\n    margin-right: -7px;\n  }\n\n  .first-triangle {\n    width: 0;\n    height: 0;\n    border-style: solid;\n    border-width: 5px 8.7px 5px 0;\n    border-color: transparent #4d4d4d transparent transparent;\n    margin-left: 2px;\n  }\n\n  .next-triangle {\n    margin-left: 1px;\n  }\n\n  .prev-triangle {\n    margin-left: 0;\n  }\n\n  .last-triangle {\n    width: 0;\n    height: 0;\n    border-style: solid;\n    border-width: 5px 0 5px 8.7px;\n    border-color: transparent transparent transparent #4d4d4d;\n    margin-left: -1px;\n  }\n\n  .last-bar {\n    width: 10px;\n    border-left: 2px solid #4d4d4d;\n    margin-top: -6px;\n    height: 12px;\n    margin-left: 1px;\n  }\n\n  .last-bar-rtl {\n    width: 10px;\n    border-left: 2px solid #4d4d4d;\n    margin-top: -6px;\n    height: 12px;\n    margin-right: -11px;\n  }\n\n\n}\n\n.ui-grid-pager-row-count-picker {\n  float: left;\n\n  select {\n    #ui-grid-twbs > .form-control;\n    #ui-grid-twbs > .input-sm ();\n    height: 26px;\n    width: 67px;\n    display: inline;\n  }\n\n  .ui-grid-pager-row-count-label {\n    margin-top: 3px;\n  }\n}\n\n.ui-grid-pager-count-container {\n  float: right;\n  margin-top: 4px;\n  min-width: 50px;\n\n  .ui-grid-pager-count {\n    margin-right: 10px;\n    margin-left: 10px;\n    float: right;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/pinning/less/pinning.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-pinned-container {\n  position: absolute;\n  display: inline;\n  top: 0;\n\n  &.ui-grid-pinned-container-left {\n    float: left;\n    left: 0;\n  }\n\n  &.ui-grid-pinned-container-right {\n    float: right;\n    right: 0;\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-header-cell:last-child {\n    box-sizing: border-box;\n    border-right: @gridBorderWidth solid;\n    border-width: @gridBorderWidth;\n    border-right-color: darken(@headerVerticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-cell:last-child {\n    box-sizing: border-box;\n    border-right: @gridBorderWidth solid;\n    border-width: @gridBorderWidth;\n    border-right-color: darken(@verticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar, .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n    width: @gridBorderWidth;\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar {\n    background-color: @headerVerticalBarColor;\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n    background-color: darken(@verticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-left .ui-grid-header-cell:last-child .ui-grid-vertical-bar {\n    right: -1px; // TODO(c0bra): Should this be grid width? Test column resizing with custom grid border width\n    width: @gridBorderWidth;\n    background-color: darken(@headerVerticalBarColor, 15%);\n  }\n\n\n  &.ui-grid-pinned-container-right .ui-grid-header-cell:first-child {\n    box-sizing: border-box;\n    border-left: @gridBorderWidth solid;\n    border-width: @gridBorderWidth;\n    border-left-color: darken(@headerVerticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-right .ui-grid-cell:first-child {\n    box-sizing: border-box;\n    border-left: @gridBorderWidth solid;\n    border-width: @gridBorderWidth;\n    border-left-color: darken(@verticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar, .ui-grid-cell:not(:first-child) .ui-grid-vertical-bar {\n    width: @gridBorderWidth;\n  }\n\n  &.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar {\n    background-color: @headerVerticalBarColor;\n  }\n\n  &.ui-grid-pinned-container-right .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n    background-color: darken(@verticalBarColor, 15%);\n  }\n\n  &.ui-grid-pinned-container-first .ui-grid-header-cell:first-child .ui-grid-vertical-bar {\n    left: -1px; // TODO(c0bra): Should this be grid width? Test column resizing with custom grid border width\n    width: @gridBorderWidth;\n    background-color: darken(@headerVerticalBarColor, 15%);\n  }\n}\n\n.ui-grid-render-container-body {\n  // float: left;\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/resize-columns/less/column-resizer.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-column-resizer {\n  top: 0;\n  bottom: 0;\n  width: 5px;\n  position: absolute;\n  cursor: col-resize;\n\n  &.left {\n    left: 0;\n  }\n\n  &.right {\n    right: 0;\n  }\n}\n\n// Add a visual border for final column's resizer element\n.ui-grid-header-cell:last-child .ui-grid-column-resizer.right {\n  border-right: @gridBorderWidth solid @borderColor;\n}\n\n// Put visual border on left of last header cell when direction is rtl\n.ui-grid[dir=rtl]  .ui-grid-header-cell:last-child {\n  .ui-grid-column-resizer.right {\n    border-right: 0;\n  }\n\n  .ui-grid-column-resizer.left {\n    border-left: @gridBorderWidth solid @borderColor;\n  }\n}\n\n.ui-grid {\n  &.column-resizing {\n    cursor: col-resize;\n  }\n}\n\n.ui-grid.column-resizing .ui-grid-resize-overlay {\n  position: absolute;\n  top: 0;\n  height: 100%;\n  width: @gridBorderWidth;\n  background-color: darken(@verticalBarColor, 15%);\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/row-edit/less/rowEdit.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-row-saving {\n   .ui-grid-cell {\n     color: @rowSavingForeground !important;\n  }\n}\n\n.ui-grid-row-dirty {\n   .ui-grid-cell {\n     color: @rowDirtyForeground;\n  }\n}\n\n.ui-grid-row-error {\n   .ui-grid-cell {\n     color: @rowErrorForeground !important;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/rtl.less",
    "content": "/*\n* RTL Styles\n*/\n\n.ui-grid[dir=rtl] {\n\n  .ui-grid-header-cell,\n  .ui-grid-footer-cell,\n  .ui-grid-cell {\n    float: right !important;\n  }\n\n  .ui-grid-column-menu-button {\n    position: absolute;\n    left: 1px;\n    top: 0;\n    right: inherit;\n  }\n\n  .ui-grid-cell:first-child,\n  .ui-grid-header-cell:first-child,\n  .ui-grid-footer-cell:first-child {\n    border-right: 0;\n  }\n\n  .ui-grid-cell:last-child, .ui-grid-header-cell:last-child  {\n    border-right: @gridBorderWidth solid @borderColor;\n    border-left: 0;\n  }\n\n  .ui-grid-header-cell:first-child .ui-grid-vertical-bar,\n  .ui-grid-footer-cell:first-child .ui-grid-vertical-bar,\n  .ui-grid-cell:first-child .ui-grid-vertical-bar {\n    width: 0;\n  }\n\n  .ui-grid-menu-button {\n    z-index: 2;\n    position: absolute;\n    left: 0;\n    right: auto;\n    background: @headerBackgroundColor;\n    border: @gridBorderWidth solid @borderColor;\n    cursor: pointer;\n    min-height: 27px;\n    font-weight: normal;\n  }\n\n  .ui-grid-menu-button .ui-grid-menu {\n    left: 0;\n    right: auto;\n  }\n\n  // Position filter-cancel button on the left for rtl grids\n  .ui-grid-filter-container .ui-grid-filter-button {\n    right: initial;\n    left: 0;\n\n    [class^=\"ui-grid-icon\"] {\n      right: initial;\n      left: 10px;\n    }\n  }\n\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/selection/less/selection.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-row.ui-grid-row-selected > [ui-grid-row] > .ui-grid-cell {\n  background-color: @rowSelected;\n}\n\n.ui-grid-disable-selection {\n  -webkit-touch-callout: none;\n  -webkit-user-select: none;\n  -khtml-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n  cursor: default;\n}\n\n.ui-grid-selection-row-header-buttons {\n  cursor: pointer;\n  opacity: 0.1;\n\n  &.ui-grid-row-selected {\n    opacity: 1;\n  }\n\n  &.ui-grid-all-selected {\n    opacity: 1;\n  }\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/sorting.less",
    "content": "// .ui-grid-sortarrow {\n//   fill: @sortArrowBackgroundColor; \n//   stroke: @sortArrowBorderColor; \n//   stroke-linejoin:miter;\n// }\n\n// .ui-grid-sortarrow.down {\n//   -webkit-transform: rotate(180deg);\n//   -moz-transform: rotate(180deg);\n//   -ms-transform: rotate(180deg);\n//   -o-transform: rotate(180deg);\n//   transform: rotate(180deg); \n// }\n\n\n@sortArrowWidth: 20px;\n\n.ui-grid-sortarrow {\n  right: 5px;\n  position: absolute;\n  width: @sortArrowWidth;\n  top: 0;\n  bottom: 0;\n  background-position: center;\n\n  &.down {\n    .transform(rotate(180deg));\n  }\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/tree-base/less/tree-base.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-tree-row-header-buttons.ui-grid-tree-header {\n  cursor: pointer;\n  opacity: 1;\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/tree-view/less/tree-view.less",
    "content": "@import '../../../less/variables';\n\n.ui-grid-tree-header-row {\n  font-weight: bold !important;\n}\n.ui-grid-tree-header-row .ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell {\n  pointer-events: all;\n}\n"
  },
  {
    "path": "html/lib/angular-ui-grid/ui-grid.css",
    "content": "/*!\n * ui-grid - v3.1.1 - 2016-02-09\n * Copyright (c) 2016 ; License: MIT \n */\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:before,\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:before,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:before,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  content: \" \";\n  display: table;\n}\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  clear: both;\n}\n.ui-grid {\n  border: 1px solid #d4d4d4;\n  box-sizing: content-box;\n  -webkit-border-radius: 0px;\n  -moz-border-radius: 0px;\n  border-radius: 0px;\n  -webkit-transform: translateZ(0);\n  -moz-transform: translateZ(0);\n  -o-transform: translateZ(0);\n  -ms-transform: translateZ(0);\n  transform: translateZ(0);\n}\n.ui-grid-vertical-bar {\n  position: absolute;\n  right: 0;\n  width: 0;\n}\n.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,\n.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  width: 1px;\n}\n.ui-grid-scrollbar-placeholder {\n  background-color: transparent;\n}\n.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: #d4d4d4;\n}\n.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: #d4d4d4;\n}\n.ui-grid-header-cell:last-child .ui-grid-vertical-bar {\n  right: -1px;\n  width: 1px;\n  background-color: #d4d4d4;\n}\n.ui-grid-clearfix:before,\n.ui-grid-clearfix:after {\n  content: \"\";\n  display: table;\n}\n.ui-grid-clearfix:after {\n  clear: both;\n}\n.ui-grid-invisible {\n  visibility: hidden;\n}\n.ui-grid-contents-wrapper {\n  position: relative;\n  height: 100%;\n  width: 100%;\n}\n.ui-grid-sr-only {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  padding: 0;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  border: 0;\n}\n.ui-grid-top-panel-background {\n  background: #f3f3f3;\n  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(1, #ffffff));\n  background: -ms-linear-gradient(bottom, #eeeeee, #ffffff);\n  background: -moz-linear-gradient(center bottom, #eeeeee 0%, #ffffff 100%);\n  background: -o-linear-gradient(#ffffff, #eeeeee);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);\n}\n.ui-grid-header {\n  border-bottom: 1px solid #d4d4d4;\n  box-sizing: border-box;\n}\n.ui-grid-top-panel {\n  position: relative;\n  overflow: hidden;\n  font-weight: bold;\n  background: #f3f3f3;\n  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(1, #ffffff));\n  background: -ms-linear-gradient(bottom, #eeeeee, #ffffff);\n  background: -moz-linear-gradient(center bottom, #eeeeee 0%, #ffffff 100%);\n  background: -o-linear-gradient(#ffffff, #eeeeee);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);\n  -webkit-border-top-right-radius: -1px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: -1px;\n  -moz-border-radius-topright: -1px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: -1px;\n  border-top-right-radius: -1px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: -1px;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\n.ui-grid-header-viewport {\n  overflow: hidden;\n}\n.ui-grid-header-canvas:before,\n.ui-grid-header-canvas:after {\n  content: \"\";\n  display: table;\n  line-height: 0;\n}\n.ui-grid-header-canvas:after {\n  clear: both;\n}\n.ui-grid-header-cell-wrapper {\n  position: relative;\n  display: table;\n  box-sizing: border-box;\n  height: 100%;\n}\n.ui-grid-header-cell-row {\n  display: table-row;\n  position: relative;\n}\n.ui-grid-header-cell {\n  position: relative;\n  box-sizing: border-box;\n  background-color: inherit;\n  border-right: 1px solid;\n  border-color: #d4d4d4;\n  display: table-cell;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n  width: 0;\n}\n.ui-grid-header-cell:last-child {\n  border-right: 0;\n}\n.ui-grid-header-cell .sortable {\n  cursor: pointer;\n}\n.ui-grid-header-cell .ui-grid-sort-priority-number {\n  margin-left: -8px;\n}\n.ui-grid-header .ui-grid-vertical-bar {\n  top: 0;\n  bottom: 0;\n}\n.ui-grid-column-menu-button {\n  position: absolute;\n  right: 1px;\n  top: 0;\n}\n.ui-grid-column-menu-button .ui-grid-icon-angle-down {\n  vertical-align: sub;\n}\n.ui-grid-column-menu-button-last-col {\n  margin-right: 25px;\n}\n.ui-grid-column-menu {\n  position: absolute;\n}\n/* Slide up/down animations */\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove {\n  -webkit-transition: all 0.05s linear;\n  -moz-transition: all 0.05s linear;\n  -o-transition: all 0.05s linear;\n  transition: all 0.05s linear;\n  display: block !important;\n}\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove {\n  -webkit-transform: translateY(-100%);\n  -moz-transform: translateY(-100%);\n  -o-transform: translateY(-100%);\n  -ms-transform: translateY(-100%);\n  transform: translateY(-100%);\n}\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,\n.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active {\n  -webkit-transform: translateY(0);\n  -moz-transform: translateY(0);\n  -o-transform: translateY(0);\n  -ms-transform: translateY(0);\n  transform: translateY(0);\n}\n/* Slide up/down animations */\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove {\n  -webkit-transition: all 0.05s linear;\n  -moz-transition: all 0.05s linear;\n  -o-transition: all 0.05s linear;\n  transition: all 0.05s linear;\n  display: block !important;\n}\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove {\n  -webkit-transform: translateY(-100%);\n  -moz-transform: translateY(-100%);\n  -o-transform: translateY(-100%);\n  -ms-transform: translateY(-100%);\n  transform: translateY(-100%);\n}\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active {\n  -webkit-transform: translateY(0);\n  -moz-transform: translateY(0);\n  -o-transform: translateY(0);\n  -ms-transform: translateY(0);\n  transform: translateY(0);\n}\n.ui-grid-filter-container {\n  padding: 4px 10px;\n  position: relative;\n}\n.ui-grid-filter-container .ui-grid-filter-button {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  right: 0;\n}\n.ui-grid-filter-container .ui-grid-filter-button [class^=\"ui-grid-icon\"] {\n  position: absolute;\n  top: 50%;\n  line-height: 32px;\n  margin-top: -16px;\n  right: 10px;\n  opacity: 0.66;\n}\n.ui-grid-filter-container .ui-grid-filter-button [class^=\"ui-grid-icon\"]:hover {\n  opacity: 1;\n}\n.ui-grid-filter-container .ui-grid-filter-button-select {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  right: 0;\n}\n.ui-grid-filter-container .ui-grid-filter-button-select [class^=\"ui-grid-icon\"] {\n  position: absolute;\n  top: 50%;\n  line-height: 32px;\n  margin-top: -16px;\n  right: 0px;\n  opacity: 0.66;\n}\n.ui-grid-filter-container .ui-grid-filter-button-select [class^=\"ui-grid-icon\"]:hover {\n  opacity: 1;\n}\ninput[type=\"text\"].ui-grid-filter-input {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 100%;\n  border: 1px solid #d4d4d4;\n  -webkit-border-top-right-radius: 0px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: 0;\n  -moz-border-radius-topright: 0px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: 0;\n  border-top-right-radius: 0px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: 0;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\ninput[type=\"text\"].ui-grid-filter-input:hover {\n  border: 1px solid #d4d4d4;\n}\nselect.ui-grid-filter-select {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 90%;\n  border: 1px solid #d4d4d4;\n  -webkit-border-top-right-radius: 0px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: 0;\n  -moz-border-radius-topright: 0px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: 0;\n  border-top-right-radius: 0px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: 0;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\nselect.ui-grid-filter-select:hover {\n  border: 1px solid #d4d4d4;\n}\n.ui-grid-filter-cancel-button-hidden select.ui-grid-filter-select {\n  width: 100%;\n}\n.ui-grid-render-container {\n  position: inherit;\n  -webkit-border-top-right-radius: 0;\n  -webkit-border-bottom-right-radius: 0px;\n  -webkit-border-bottom-left-radius: 0px;\n  -webkit-border-top-left-radius: 0;\n  -moz-border-radius-topright: 0;\n  -moz-border-radius-bottomright: 0px;\n  -moz-border-radius-bottomleft: 0px;\n  -moz-border-radius-topleft: 0;\n  border-top-right-radius: 0;\n  border-bottom-right-radius: 0px;\n  border-bottom-left-radius: 0px;\n  border-top-left-radius: 0;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\n.ui-grid-render-container:focus {\n  outline: none;\n}\n.ui-grid-viewport {\n  min-height: 20px;\n  position: relative;\n  overflow-y: scroll;\n  -webkit-overflow-scrolling: touch;\n}\n.ui-grid-viewport:focus {\n  outline: none !important;\n}\n.ui-grid-canvas {\n  position: relative;\n  padding-top: 1px;\n}\n.ui-grid-row:nth-child(odd) .ui-grid-cell {\n  background-color: #fdfdfd;\n}\n.ui-grid-row:nth-child(even) .ui-grid-cell {\n  background-color: #f3f3f3;\n}\n.ui-grid-row:last-child .ui-grid-cell {\n  border-bottom-color: #d4d4d4;\n  border-bottom-style: solid;\n}\n.ui-grid-no-row-overlay {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  margin: 10%;\n  background: #f3f3f3;\n  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(1, #ffffff));\n  background: -ms-linear-gradient(bottom, #eeeeee, #ffffff);\n  background: -moz-linear-gradient(center bottom, #eeeeee 0%, #ffffff 100%);\n  background: -o-linear-gradient(#ffffff, #eeeeee);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);\n  -webkit-border-top-right-radius: 0px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: 0;\n  -moz-border-radius-topright: 0px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: 0;\n  border-top-right-radius: 0px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: 0;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n  border: 1px solid #d4d4d4;\n  font-size: 2em;\n  text-align: center;\n}\n.ui-grid-no-row-overlay > * {\n  position: absolute;\n  display: table;\n  margin: auto 0;\n  width: 100%;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  opacity: 0.66;\n}\n.ui-grid-cell {\n  overflow: hidden;\n  float: left;\n  background-color: inherit;\n  border-right: 1px solid;\n  border-color: #d4d4d4;\n  box-sizing: border-box;\n}\n.ui-grid-cell:last-child {\n  border-right: 0;\n}\n.ui-grid-cell-contents {\n  padding: 5px;\n  -moz-box-sizing: border-box;\n  -webkit-box-sizing: border-box;\n  box-sizing: border-box;\n  white-space: nowrap;\n  -ms-text-overflow: ellipsis;\n  -o-text-overflow: ellipsis;\n  text-overflow: ellipsis;\n  overflow: hidden;\n  height: 100%;\n}\n.ui-grid-cell-contents-hidden {\n  visibility: hidden;\n  width: 0;\n  height: 0;\n  display: none;\n}\n.ui-grid-row .ui-grid-cell.ui-grid-row-header-cell {\n  background-color: #f0f0ee;\n  border-bottom: solid 1px #d4d4d4;\n}\n.ui-grid-footer-panel-background {\n  background: #f3f3f3;\n  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(1, #ffffff));\n  background: -ms-linear-gradient(bottom, #eeeeee, #ffffff);\n  background: -moz-linear-gradient(center bottom, #eeeeee 0%, #ffffff 100%);\n  background: -o-linear-gradient(#ffffff, #eeeeee);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);\n}\n.ui-grid-footer-panel {\n  position: relative;\n  border-bottom: 1px solid #d4d4d4;\n  border-top: 1px solid #d4d4d4;\n  overflow: hidden;\n  font-weight: bold;\n  background: #f3f3f3;\n  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(1, #ffffff));\n  background: -ms-linear-gradient(bottom, #eeeeee, #ffffff);\n  background: -moz-linear-gradient(center bottom, #eeeeee 0%, #ffffff 100%);\n  background: -o-linear-gradient(#ffffff, #eeeeee);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);\n  -webkit-border-top-right-radius: -1px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: -1px;\n  -moz-border-radius-topright: -1px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: -1px;\n  border-top-right-radius: -1px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: -1px;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\n.ui-grid-grid-footer {\n  float: left;\n  width: 100%;\n}\n.ui-grid-footer-viewport {\n  overflow: hidden;\n}\n.ui-grid-footer-canvas {\n  position: relative;\n}\n.ui-grid-footer-canvas:before,\n.ui-grid-footer-canvas:after {\n  content: \"\";\n  display: table;\n  line-height: 0;\n}\n.ui-grid-footer-canvas:after {\n  clear: both;\n}\n.ui-grid-footer-cell-wrapper {\n  position: relative;\n  display: table;\n  box-sizing: border-box;\n  height: 100%;\n}\n.ui-grid-footer-cell-row {\n  display: table-row;\n}\n.ui-grid-footer-cell {\n  overflow: hidden;\n  background-color: inherit;\n  border-right: 1px solid;\n  border-color: #d4d4d4;\n  box-sizing: border-box;\n  display: table-cell;\n}\n.ui-grid-footer-cell:last-child {\n  border-right: 0;\n}\ninput[type=\"text\"].ui-grid-filter-input {\n  padding: 0;\n  margin: 0;\n  border: 0;\n  width: 100%;\n  border: 1px solid #d4d4d4;\n  -webkit-border-top-right-radius: 0px;\n  -webkit-border-bottom-right-radius: 0;\n  -webkit-border-bottom-left-radius: 0;\n  -webkit-border-top-left-radius: 0;\n  -moz-border-radius-topright: 0px;\n  -moz-border-radius-bottomright: 0;\n  -moz-border-radius-bottomleft: 0;\n  -moz-border-radius-topleft: 0;\n  border-top-right-radius: 0px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n  border-top-left-radius: 0;\n  -moz-background-clip: padding-box;\n  -webkit-background-clip: padding-box;\n  background-clip: padding-box;\n}\ninput[type=\"text\"].ui-grid-filter-input:hover {\n  border: 1px solid #d4d4d4;\n}\n.ui-grid-menu-button {\n  z-index: 2;\n  position: absolute;\n  right: 0;\n  top: 0;\n  background: #f3f3f3;\n  border: 1px solid #d4d4d4;\n  cursor: pointer;\n  height: 31px;\n  font-weight: normal;\n}\n.ui-grid-menu-button .ui-grid-icon-container {\n  margin-top: 3px;\n}\n.ui-grid-menu-button .ui-grid-menu {\n  right: 0;\n}\n.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid {\n  overflow: scroll;\n  border: 1px solid #d4d4d4;\n}\n.ui-grid-menu {\n  z-index: 2;\n  position: absolute;\n  padding: 0 10px 20px 10px;\n  cursor: pointer;\n  box-sizing: border-box;\n}\n.ui-grid-menu .ui-grid-menu-inner {\n  background: #f3f3f3;\n  border: 1px solid #d4d4d4;\n  position: relative;\n  white-space: nowrap;\n  -webkit-border-radius: 0px;\n  -moz-border-radius: 0px;\n  border-radius: 0px;\n  -webkit-box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), inset 0 12px 12px -14px rgba(0, 0, 0, 0.2);\n  -moz-box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), inset 0 12px 12px -14px rgba(0, 0, 0, 0.2);\n  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), inset 0 12px 12px -14px rgba(0, 0, 0, 0.2);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button {\n  position: absolute;\n  right: 0px;\n  top: 0px;\n  display: inline-block;\n  margin-bottom: 0;\n  font-weight: normal;\n  text-align: center;\n  vertical-align: middle;\n  touch-action: manipulation;\n  cursor: pointer;\n  background-image: none;\n  border: 1px solid transparent;\n  white-space: nowrap;\n  padding: 6px 12px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  border-radius: 4px;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n  padding: 1px 1px;\n  font-size: 10px;\n  line-height: 1;\n  border-radius: 2px;\n  color: transparent;\n  background-color: transparent;\n  border-color: transparent;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active.focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active.focus {\n  outline: thin dotted;\n  outline: 5px auto -webkit-focus-ring-color;\n  outline-offset: -2px;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:hover,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.focus {\n  color: #333333;\n  text-decoration: none;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active {\n  outline: 0;\n  background-image: none;\n  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.disabled,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button[disabled],\nfieldset[disabled] .ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button {\n  cursor: not-allowed;\n  opacity: 0.65;\n  filter: alpha(opacity=65);\n  -webkit-box-shadow: none;\n  box-shadow: none;\n}\na.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.disabled,\nfieldset[disabled] a.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button {\n  pointer-events: none;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.focus {\n  color: transparent;\n  background-color: rgba(0, 0, 0, 0);\n  border-color: rgba(0, 0, 0, 0);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:hover {\n  color: transparent;\n  background-color: rgba(0, 0, 0, 0);\n  border-color: rgba(0, 0, 0, 0);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active,\n.open > .dropdown-toggle.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button {\n  color: transparent;\n  background-color: rgba(0, 0, 0, 0);\n  border-color: rgba(0, 0, 0, 0);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active:hover,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active:hover,\n.open > .dropdown-toggle.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:hover,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active:focus,\n.open > .dropdown-toggle.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active.focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active.focus,\n.open > .dropdown-toggle.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.focus {\n  color: transparent;\n  background-color: rgba(0, 0, 0, 0);\n  border-color: rgba(0, 0, 0, 0);\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:active,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.active,\n.open > .dropdown-toggle.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button {\n  background-image: none;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.disabled:hover,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button[disabled]:hover,\nfieldset[disabled] .ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:hover,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.disabled:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button[disabled]:focus,\nfieldset[disabled] .ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button:focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.disabled.focus,\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button[disabled].focus,\nfieldset[disabled] .ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button.focus {\n  background-color: transparent;\n  border-color: transparent;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button .badge {\n  color: transparent;\n  background-color: transparent;\n}\n.ui-grid-menu .ui-grid-menu-inner .ui-grid-menu-close-button > i {\n  opacity: 0.75;\n  color: black;\n}\n.ui-grid-menu .ui-grid-menu-inner ul {\n  margin: 0;\n  padding: 0;\n  list-style-type: none;\n}\n.ui-grid-menu .ui-grid-menu-inner ul li {\n  padding: 0px;\n}\n.ui-grid-menu .ui-grid-menu-inner ul li button {\n  min-width: 100%;\n  padding: 8px;\n  text-align: left;\n  background: transparent;\n  border: none;\n}\n.ui-grid-menu .ui-grid-menu-inner ul li button:hover,\n.ui-grid-menu .ui-grid-menu-inner ul li button:focus {\n  -webkit-box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n  -moz-box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n}\n.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item-active {\n  -webkit-box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n  -moz-box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n  background-color: #cecece;\n}\n.ui-grid-menu .ui-grid-menu-inner ul li:not(:last-child) > button {\n  border-bottom: 1px solid #d4d4d4;\n}\n.ui-grid-sortarrow {\n  right: 5px;\n  position: absolute;\n  width: 20px;\n  top: 0;\n  bottom: 0;\n  background-position: center;\n}\n.ui-grid-sortarrow.down {\n  -webkit-transform: rotate(180deg);\n  -moz-transform: rotate(180deg);\n  -o-transform: rotate(180deg);\n  -ms-transform: rotate(180deg);\n  transform: rotate(180deg);\n}\n@font-face {\n  font-family: 'ui-grid';\n  src: url('ui-grid.eot');\n  src: url('ui-grid.eot#iefix') format('embedded-opentype'), url('ui-grid.woff') format('woff'), url('ui-grid.ttf') format('truetype'), url('ui-grid.svg?#ui-grid') format('svg');\n  font-weight: normal;\n  font-style: normal;\n}\n/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */\n/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */\n/*\n@media screen and (-webkit-min-device-pixel-ratio:0) {\n  @font-face {\n    font-family: 'ui-grid';\n    src: url('@{font-path}ui-grid.svg?12312827#ui-grid') format('svg');\n  }\n}\n*/\n[class^=\"ui-grid-icon\"]:before,\n[class*=\" ui-grid-icon\"]:before {\n  font-family: \"ui-grid\";\n  font-style: normal;\n  font-weight: normal;\n  speak: none;\n  display: inline-block;\n  text-decoration: inherit;\n  width: 1em;\n  margin-right: .2em;\n  text-align: center;\n  /* opacity: .8; */\n  /* For safety - reset parent styles, that can break glyph codes*/\n  font-variant: normal;\n  text-transform: none;\n  /* fix buttons height, for twitter bootstrap */\n  line-height: 1em;\n  /* Animation center compensation - margins should be symmetric */\n  /* remove if not needed */\n  margin-left: .2em;\n  /* you can be more comfortable with increased icons size */\n  /* font-size: 120%; */\n  /* Uncomment for 3D effect */\n  /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */\n}\n.ui-grid-icon-blank::before {\n  width: 1em;\n  content: ' ';\n}\n/*\n* RTL Styles\n*/\n.ui-grid[dir=rtl] .ui-grid-header-cell,\n.ui-grid[dir=rtl] .ui-grid-footer-cell,\n.ui-grid[dir=rtl] .ui-grid-cell {\n  float: right !important;\n}\n.ui-grid[dir=rtl] .ui-grid-column-menu-button {\n  position: absolute;\n  left: 1px;\n  top: 0;\n  right: inherit;\n}\n.ui-grid[dir=rtl] .ui-grid-cell:first-child,\n.ui-grid[dir=rtl] .ui-grid-header-cell:first-child,\n.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child {\n  border-right: 0;\n}\n.ui-grid[dir=rtl] .ui-grid-cell:last-child,\n.ui-grid[dir=rtl] .ui-grid-header-cell:last-child {\n  border-right: 1px solid #d4d4d4;\n  border-left: 0;\n}\n.ui-grid[dir=rtl] .ui-grid-header-cell:first-child .ui-grid-vertical-bar,\n.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child .ui-grid-vertical-bar,\n.ui-grid[dir=rtl] .ui-grid-cell:first-child .ui-grid-vertical-bar {\n  width: 0;\n}\n.ui-grid[dir=rtl] .ui-grid-menu-button {\n  z-index: 2;\n  position: absolute;\n  left: 0;\n  right: auto;\n  background: #f3f3f3;\n  border: 1px solid #d4d4d4;\n  cursor: pointer;\n  min-height: 27px;\n  font-weight: normal;\n}\n.ui-grid[dir=rtl] .ui-grid-menu-button .ui-grid-menu {\n  left: 0;\n  right: auto;\n}\n.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button {\n  right: initial;\n  left: 0;\n}\n.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button [class^=\"ui-grid-icon\"] {\n  right: initial;\n  left: 10px;\n}\n/*\n   Animation example, for spinners\n*/\n.ui-grid-animate-spin {\n  -moz-animation: ui-grid-spin 2s infinite linear;\n  -o-animation: ui-grid-spin 2s infinite linear;\n  -webkit-animation: ui-grid-spin 2s infinite linear;\n  animation: ui-grid-spin 2s infinite linear;\n  display: inline-block;\n}\n@-moz-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-webkit-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-o-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@-ms-keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@keyframes ui-grid-spin {\n  0% {\n    -moz-transform: rotate(0deg);\n    -o-transform: rotate(0deg);\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -moz-transform: rotate(359deg);\n    -o-transform: rotate(359deg);\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n/*---------------------------------------------------\n    LESS Elements 0.9\n  ---------------------------------------------------\n    A set of useful LESS mixins\n    More info at: http://lesselements.com\n  ---------------------------------------------------*/\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:before,\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:before,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:before,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  content: \" \";\n  display: table;\n}\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  clear: both;\n}\n.ui-grid-cell-focus {\n  outline: 0;\n  background-color: #b3c4c7;\n}\n.ui-grid-focuser {\n  position: absolute;\n  left: 0px;\n  top: 0px;\n  z-index: -1;\n  width: 100%;\n  height: 100%;\n}\n.ui-grid-focuser:focus {\n  border-color: #66afe9;\n  outline: 0;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n}\n.ui-grid-offscreen {\n  display: block;\n  position: absolute;\n  left: -10000px;\n  top: -10000px;\n  clip: rect(0px, 0px, 0px, 0px);\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\ndiv.ui-grid-cell input {\n  border-radius: inherit;\n  padding: 0;\n  width: 100%;\n  color: inherit;\n  height: auto;\n  font: inherit;\n  outline: none;\n}\ndiv.ui-grid-cell input:focus {\n  color: inherit;\n  outline: none;\n}\ndiv.ui-grid-cell input[type=\"checkbox\"] {\n  margin: 9px 0 0 6px;\n  width: auto;\n}\ndiv.ui-grid-cell input.ng-invalid {\n  border: 1px solid #fc8f8f;\n}\ndiv.ui-grid-cell input.ng-valid {\n  border: 1px solid #d4d4d4;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.expandableRow .ui-grid-row:nth-child(odd) .ui-grid-cell {\n  background-color: #fdfdfd;\n}\n.expandableRow .ui-grid-row:nth-child(even) .ui-grid-cell {\n  background-color: #f3f3f3;\n}\n.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell {\n  pointer-events: none;\n}\n.ui-grid-expandable-buttons-cell i {\n  pointer-events: all;\n}\n.scrollFiller {\n  float: left;\n  border: 1px solid #d4d4d4;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-tree-header-row {\n  font-weight: bold !important;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.movingColumn {\n  position: absolute;\n  top: 0;\n  border: 1px solid #d4d4d4;\n  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2);\n}\n.movingColumn .ui-grid-icon-angle-down {\n  display: none;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/*---------------------------------------------------\n    LESS Elements 0.9\n  ---------------------------------------------------\n    A set of useful LESS mixins\n    More info at: http://lesselements.com\n  ---------------------------------------------------*/\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:before,\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:before,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:before,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  content: \" \";\n  display: table;\n}\n#ui-grid-twbs #ui-grid-twbs .form-horizontal .form-group:after,\n#ui-grid-twbs #ui-grid-twbs .btn-toolbar:after,\n#ui-grid-twbs #ui-grid-twbs .btn-group-vertical > .btn-group:after {\n  clear: both;\n}\n.ui-grid-pager-panel {\n  position: absolute;\n  left: 0;\n  bottom: 0;\n  width: 100%;\n  padding-top: 3px;\n  padding-bottom: 3px;\n  box-sizing: content-box;\n}\n.ui-grid-pager-container {\n  float: left;\n}\n.ui-grid-pager-control {\n  margin-right: 10px;\n  margin-left: 10px;\n  min-width: 135px;\n  float: left;\n}\n.ui-grid-pager-control button {\n  height: 25px;\n  min-width: 26px;\n  display: inline-block;\n  margin-bottom: 0;\n  font-weight: normal;\n  text-align: center;\n  vertical-align: middle;\n  touch-action: manipulation;\n  cursor: pointer;\n  background-image: none;\n  border: 1px solid transparent;\n  white-space: nowrap;\n  padding: 6px 12px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  border-radius: 4px;\n  -webkit-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n  color: #eeeeee;\n  background-color: #f3f3f3;\n  border-color: #cccccc;\n}\n.ui-grid-pager-control button:focus,\n.ui-grid-pager-control button:active:focus,\n.ui-grid-pager-control button.active:focus,\n.ui-grid-pager-control button.focus,\n.ui-grid-pager-control button:active.focus,\n.ui-grid-pager-control button.active.focus {\n  outline: thin dotted;\n  outline: 5px auto -webkit-focus-ring-color;\n  outline-offset: -2px;\n}\n.ui-grid-pager-control button:hover,\n.ui-grid-pager-control button:focus,\n.ui-grid-pager-control button.focus {\n  color: #333333;\n  text-decoration: none;\n}\n.ui-grid-pager-control button:active,\n.ui-grid-pager-control button.active {\n  outline: 0;\n  background-image: none;\n  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n}\n.ui-grid-pager-control button.disabled,\n.ui-grid-pager-control button[disabled],\nfieldset[disabled] .ui-grid-pager-control button {\n  cursor: not-allowed;\n  opacity: 0.65;\n  filter: alpha(opacity=65);\n  -webkit-box-shadow: none;\n  box-shadow: none;\n}\na.ui-grid-pager-control button.disabled,\nfieldset[disabled] a.ui-grid-pager-control button {\n  pointer-events: none;\n}\n.ui-grid-pager-control button:focus,\n.ui-grid-pager-control button.focus {\n  color: #eeeeee;\n  background-color: #dadada;\n  border-color: #8c8c8c;\n}\n.ui-grid-pager-control button:hover {\n  color: #eeeeee;\n  background-color: #dadada;\n  border-color: #adadad;\n}\n.ui-grid-pager-control button:active,\n.ui-grid-pager-control button.active,\n.open > .dropdown-toggle.ui-grid-pager-control button {\n  color: #eeeeee;\n  background-color: #dadada;\n  border-color: #adadad;\n}\n.ui-grid-pager-control button:active:hover,\n.ui-grid-pager-control button.active:hover,\n.open > .dropdown-toggle.ui-grid-pager-control button:hover,\n.ui-grid-pager-control button:active:focus,\n.ui-grid-pager-control button.active:focus,\n.open > .dropdown-toggle.ui-grid-pager-control button:focus,\n.ui-grid-pager-control button:active.focus,\n.ui-grid-pager-control button.active.focus,\n.open > .dropdown-toggle.ui-grid-pager-control button.focus {\n  color: #eeeeee;\n  background-color: #c8c8c8;\n  border-color: #8c8c8c;\n}\n.ui-grid-pager-control button:active,\n.ui-grid-pager-control button.active,\n.open > .dropdown-toggle.ui-grid-pager-control button {\n  background-image: none;\n}\n.ui-grid-pager-control button.disabled:hover,\n.ui-grid-pager-control button[disabled]:hover,\nfieldset[disabled] .ui-grid-pager-control button:hover,\n.ui-grid-pager-control button.disabled:focus,\n.ui-grid-pager-control button[disabled]:focus,\nfieldset[disabled] .ui-grid-pager-control button:focus,\n.ui-grid-pager-control button.disabled.focus,\n.ui-grid-pager-control button[disabled].focus,\nfieldset[disabled] .ui-grid-pager-control button.focus {\n  background-color: #f3f3f3;\n  border-color: #cccccc;\n}\n.ui-grid-pager-control button .badge {\n  color: #f3f3f3;\n  background-color: #eeeeee;\n}\n.ui-grid-pager-control input {\n  display: block;\n  width: 100%;\n  height: 34px;\n  padding: 6px 12px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  color: #555555;\n  background-color: #ffffff;\n  background-image: none;\n  border: 1px solid #cccccc;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n  -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  height: 30px;\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n  display: inline;\n  height: 26px;\n  width: 50px;\n  vertical-align: top;\n}\n.ui-grid-pager-control input:focus {\n  border-color: #66afe9;\n  outline: 0;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n}\n.ui-grid-pager-control input::-moz-placeholder {\n  color: #999999;\n  opacity: 1;\n}\n.ui-grid-pager-control input:-ms-input-placeholder {\n  color: #999999;\n}\n.ui-grid-pager-control input::-webkit-input-placeholder {\n  color: #999999;\n}\n.ui-grid-pager-control input::-ms-expand {\n  border: 0;\n  background-color: transparent;\n}\n.ui-grid-pager-control input[disabled],\n.ui-grid-pager-control input[readonly],\nfieldset[disabled] .ui-grid-pager-control input {\n  background-color: #eeeeee;\n  opacity: 1;\n}\n.ui-grid-pager-control input[disabled],\nfieldset[disabled] .ui-grid-pager-control input {\n  cursor: not-allowed;\n}\ntextarea.ui-grid-pager-control input {\n  height: auto;\n}\nselect.ui-grid-pager-control input {\n  height: 30px;\n  line-height: 30px;\n}\ntextarea.ui-grid-pager-control input,\nselect[multiple].ui-grid-pager-control input {\n  height: auto;\n}\n.ui-grid-pager-control .ui-grid-pager-max-pages-number {\n  vertical-align: bottom;\n}\n.ui-grid-pager-control .ui-grid-pager-max-pages-number > * {\n  vertical-align: middle;\n}\n.ui-grid-pager-control .first-bar {\n  width: 10px;\n  border-left: 2px solid #4d4d4d;\n  margin-top: -6px;\n  height: 12px;\n  margin-left: -3px;\n}\n.ui-grid-pager-control .first-bar-rtl {\n  width: 10px;\n  border-left: 2px solid #4d4d4d;\n  margin-top: -6px;\n  height: 12px;\n  margin-right: -7px;\n}\n.ui-grid-pager-control .first-triangle {\n  width: 0;\n  height: 0;\n  border-style: solid;\n  border-width: 5px 8.7px 5px 0;\n  border-color: transparent #4d4d4d transparent transparent;\n  margin-left: 2px;\n}\n.ui-grid-pager-control .next-triangle {\n  margin-left: 1px;\n}\n.ui-grid-pager-control .prev-triangle {\n  margin-left: 0;\n}\n.ui-grid-pager-control .last-triangle {\n  width: 0;\n  height: 0;\n  border-style: solid;\n  border-width: 5px 0 5px 8.7px;\n  border-color: transparent transparent transparent #4d4d4d;\n  margin-left: -1px;\n}\n.ui-grid-pager-control .last-bar {\n  width: 10px;\n  border-left: 2px solid #4d4d4d;\n  margin-top: -6px;\n  height: 12px;\n  margin-left: 1px;\n}\n.ui-grid-pager-control .last-bar-rtl {\n  width: 10px;\n  border-left: 2px solid #4d4d4d;\n  margin-top: -6px;\n  height: 12px;\n  margin-right: -11px;\n}\n.ui-grid-pager-row-count-picker {\n  float: left;\n}\n.ui-grid-pager-row-count-picker select {\n  display: block;\n  width: 100%;\n  height: 34px;\n  padding: 6px 12px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  color: #555555;\n  background-color: #ffffff;\n  background-image: none;\n  border: 1px solid #cccccc;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);\n  -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n  height: 30px;\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n  height: 26px;\n  width: 67px;\n  display: inline;\n}\n.ui-grid-pager-row-count-picker select:focus {\n  border-color: #66afe9;\n  outline: 0;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);\n}\n.ui-grid-pager-row-count-picker select::-moz-placeholder {\n  color: #999999;\n  opacity: 1;\n}\n.ui-grid-pager-row-count-picker select:-ms-input-placeholder {\n  color: #999999;\n}\n.ui-grid-pager-row-count-picker select::-webkit-input-placeholder {\n  color: #999999;\n}\n.ui-grid-pager-row-count-picker select::-ms-expand {\n  border: 0;\n  background-color: transparent;\n}\n.ui-grid-pager-row-count-picker select[disabled],\n.ui-grid-pager-row-count-picker select[readonly],\nfieldset[disabled] .ui-grid-pager-row-count-picker select {\n  background-color: #eeeeee;\n  opacity: 1;\n}\n.ui-grid-pager-row-count-picker select[disabled],\nfieldset[disabled] .ui-grid-pager-row-count-picker select {\n  cursor: not-allowed;\n}\ntextarea.ui-grid-pager-row-count-picker select {\n  height: auto;\n}\nselect.ui-grid-pager-row-count-picker select {\n  height: 30px;\n  line-height: 30px;\n}\ntextarea.ui-grid-pager-row-count-picker select,\nselect[multiple].ui-grid-pager-row-count-picker select {\n  height: auto;\n}\n.ui-grid-pager-row-count-picker .ui-grid-pager-row-count-label {\n  margin-top: 3px;\n}\n.ui-grid-pager-count-container {\n  float: right;\n  margin-top: 4px;\n  min-width: 50px;\n}\n.ui-grid-pager-count-container .ui-grid-pager-count {\n  margin-right: 10px;\n  margin-left: 10px;\n  float: right;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-pinned-container {\n  position: absolute;\n  display: inline;\n  top: 0;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left {\n  float: left;\n  left: 0;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right {\n  float: right;\n  right: 0;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child {\n  box-sizing: border-box;\n  border-right: 1px solid;\n  border-width: 1px;\n  border-right-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:last-child {\n  box-sizing: border-box;\n  border-right: 1px solid;\n  border-width: 1px;\n  border-right-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,\n.ui-grid-pinned-container .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  width: 1px;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: #d4d4d4;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child .ui-grid-vertical-bar {\n  right: -1px;\n  width: 1px;\n  background-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:first-child {\n  box-sizing: border-box;\n  border-left: 1px solid;\n  border-width: 1px;\n  border-left-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:first-child {\n  box-sizing: border-box;\n  border-left: 1px solid;\n  border-width: 1px;\n  border-left-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar,\n.ui-grid-pinned-container .ui-grid-cell:not(:first-child) .ui-grid-vertical-bar {\n  width: 1px;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar {\n  background-color: #d4d4d4;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar {\n  background-color: #aeaeae;\n}\n.ui-grid-pinned-container.ui-grid-pinned-container-first .ui-grid-header-cell:first-child .ui-grid-vertical-bar {\n  left: -1px;\n  width: 1px;\n  background-color: #aeaeae;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-column-resizer {\n  top: 0;\n  bottom: 0;\n  width: 5px;\n  position: absolute;\n  cursor: col-resize;\n}\n.ui-grid-column-resizer.left {\n  left: 0;\n}\n.ui-grid-column-resizer.right {\n  right: 0;\n}\n.ui-grid-header-cell:last-child .ui-grid-column-resizer.right {\n  border-right: 1px solid #d4d4d4;\n}\n.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.right {\n  border-right: 0;\n}\n.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.left {\n  border-left: 1px solid #d4d4d4;\n}\n.ui-grid.column-resizing {\n  cursor: col-resize;\n}\n.ui-grid.column-resizing .ui-grid-resize-overlay {\n  position: absolute;\n  top: 0;\n  height: 100%;\n  width: 1px;\n  background-color: #aeaeae;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-row-saving .ui-grid-cell {\n  color: #848484 !important;\n}\n.ui-grid-row-dirty .ui-grid-cell {\n  color: #610b38;\n}\n.ui-grid-row-error .ui-grid-cell {\n  color: #ff0000 !important;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-row.ui-grid-row-selected > [ui-grid-row] > .ui-grid-cell {\n  background-color: #c9dde1;\n}\n.ui-grid-disable-selection {\n  -webkit-touch-callout: none;\n  -webkit-user-select: none;\n  -khtml-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n  cursor: default;\n}\n.ui-grid-selection-row-header-buttons {\n  cursor: pointer;\n  opacity: 0.1;\n}\n.ui-grid-selection-row-header-buttons.ui-grid-row-selected {\n  opacity: 1;\n}\n.ui-grid-selection-row-header-buttons.ui-grid-all-selected {\n  opacity: 1;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-tree-row-header-buttons.ui-grid-tree-header {\n  cursor: pointer;\n  opacity: 1;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n.ui-grid-tree-header-row {\n  font-weight: bold !important;\n}\n.ui-grid-tree-header-row .ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell {\n  pointer-events: all;\n}\n\n/* This file contains variable declarations (do not remove this line) */\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n/**\n* @section Grid styles\n*/\n/**\n* @section Header styles\n*/\n/** @description Colors for header gradient */\n/**\n* @section Grid body styles\n*/\n/** @description Colors used for row alternation */\n/**\n* @section Sort arrow colors\n*/\n/**\n* @section Scrollbar styles\n*/\n/**\n* @section font library path\n*/\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\ndiv.ui-grid-cell-contents.invalid {\n  border: 1px solid #fc8f8f;\n}\n\n.ui-grid-icon-plus-squared:before {\n  content: '\\c350';\n}\n/* '썐' */\n.ui-grid-icon-minus-squared:before {\n  content: '\\c351';\n}\n/* '썑' */\n.ui-grid-icon-search:before {\n  content: '\\c352';\n}\n/* '썒' */\n.ui-grid-icon-cancel:before {\n  content: '\\c353';\n}\n/* '썓' */\n.ui-grid-icon-info-circled:before {\n  content: '\\c354';\n}\n/* '썔' */\n.ui-grid-icon-lock:before {\n  content: '\\c355';\n}\n/* '썕' */\n.ui-grid-icon-lock-open:before {\n  content: '\\c356';\n}\n/* '썖' */\n.ui-grid-icon-pencil:before {\n  content: '\\c357';\n}\n/* '썗' */\n.ui-grid-icon-down-dir:before {\n  content: '\\c358';\n}\n/* '썘' */\n.ui-grid-icon-up-dir:before {\n  content: '\\c359';\n}\n/* '썙' */\n.ui-grid-icon-left-dir:before {\n  content: '\\c35a';\n}\n/* '썚' */\n.ui-grid-icon-right-dir:before {\n  content: '\\c35b';\n}\n/* '썛' */\n.ui-grid-icon-left-open:before {\n  content: '\\c35c';\n}\n/* '썜' */\n.ui-grid-icon-right-open:before {\n  content: '\\c35d';\n}\n/* '썝' */\n.ui-grid-icon-angle-down:before {\n  content: '\\c35e';\n}\n/* '썞' */\n.ui-grid-icon-filter:before {\n  content: '\\c35f';\n}\n/* '썟' */\n.ui-grid-icon-sort-alt-up:before {\n  content: '\\c360';\n}\n/* '썠' */\n.ui-grid-icon-sort-alt-down:before {\n  content: '\\c361';\n}\n/* '썡' */\n.ui-grid-icon-ok:before {\n  content: '\\c362';\n}\n/* '썢' */\n.ui-grid-icon-menu:before {\n  content: '\\c363';\n}\n/* '썣' */\n.ui-grid-icon-indent-left:before {\n  content: '\\e800';\n}\n/* '' */\n.ui-grid-icon-indent-right:before {\n  content: '\\e801';\n}\n/* '' */\n.ui-grid-icon-spin5:before {\n  content: '\\ea61';\n}\n/* '' */\n"
  },
  {
    "path": "html/lib/angular-ui-grid/ui-grid.js",
    "content": "/*!\n * ui-grid - v3.1.1 - 2016-02-09\n * Copyright (c) 2016 ; License: MIT \n */\n\n(function () {\n  'use strict';\n  angular.module('ui.grid.i18n', []);\n  angular.module('ui.grid', ['ui.grid.i18n']);\n})();\n(function () {\n  'use strict';\n  angular.module('ui.grid').constant('uiGridConstants', {\n    LOG_DEBUG_MESSAGES: true,\n    LOG_WARN_MESSAGES: true,\n    LOG_ERROR_MESSAGES: true,\n    CUSTOM_FILTERS: /CUSTOM_FILTERS/g,\n    COL_FIELD: /COL_FIELD/g,\n    MODEL_COL_FIELD: /MODEL_COL_FIELD/g,\n    TOOLTIP: /title=\\\"TOOLTIP\\\"/g,\n    DISPLAY_CELL_TEMPLATE: /DISPLAY_CELL_TEMPLATE/g,\n    TEMPLATE_REGEXP: /<.+>/,\n    FUNC_REGEXP: /(\\([^)]*\\))?$/,\n    DOT_REGEXP: /\\./g,\n    APOS_REGEXP: /'/g,\n    BRACKET_REGEXP: /^(.*)((?:\\s*\\[\\s*\\d+\\s*\\]\\s*)|(?:\\s*\\[\\s*\"(?:[^\"\\\\]|\\\\.)*\"\\s*\\]\\s*)|(?:\\s*\\[\\s*'(?:[^'\\\\]|\\\\.)*'\\s*\\]\\s*))(.*)$/,\n    COL_CLASS_PREFIX: 'ui-grid-col',\n    events: {\n      GRID_SCROLL: 'uiGridScroll',\n      COLUMN_MENU_SHOWN: 'uiGridColMenuShown',\n      ITEM_DRAGGING: 'uiGridItemDragStart', // For any item being dragged\n      COLUMN_HEADER_CLICK: 'uiGridColumnHeaderClick'\n    },\n    // copied from http://www.lsauer.com/2011/08/javascript-keymap-keycodes-in-json.html\n    keymap: {\n      TAB: 9,\n      STRG: 17,\n      CAPSLOCK: 20,\n      CTRL: 17,\n      CTRLRIGHT: 18,\n      CTRLR: 18,\n      SHIFT: 16,\n      RETURN: 13,\n      ENTER: 13,\n      BACKSPACE: 8,\n      BCKSP: 8,\n      ALT: 18,\n      ALTR: 17,\n      ALTRIGHT: 17,\n      SPACE: 32,\n      WIN: 91,\n      MAC: 91,\n      FN: null,\n      PG_UP: 33,\n      PG_DOWN: 34,\n      UP: 38,\n      DOWN: 40,\n      LEFT: 37,\n      RIGHT: 39,\n      ESC: 27,\n      DEL: 46,\n      F1: 112,\n      F2: 113,\n      F3: 114,\n      F4: 115,\n      F5: 116,\n      F6: 117,\n      F7: 118,\n      F8: 119,\n      F9: 120,\n      F10: 121,\n      F11: 122,\n      F12: 123\n    },\n    ASC: 'asc',\n    DESC: 'desc',\n    filter: {\n      STARTS_WITH: 2,\n      ENDS_WITH: 4,\n      EXACT: 8,\n      CONTAINS: 16,\n      GREATER_THAN: 32,\n      GREATER_THAN_OR_EQUAL: 64,\n      LESS_THAN: 128,\n      LESS_THAN_OR_EQUAL: 256,\n      NOT_EQUAL: 512,\n      SELECT: 'select',\n      INPUT: 'input'\n    },\n\n    aggregationTypes: {\n      sum: 2,\n      count: 4,\n      avg: 8,\n      min: 16,\n      max: 32\n    },\n\n    // TODO(c0bra): Create full list of these somehow. NOTE: do any allow a space before or after them?\n    CURRENCY_SYMBOLS: ['ƒ', '$', '£', '$', '¤', '¥', '៛', '₩', '₱', '฿', '₫'],\n\n    scrollDirection: {\n      UP: 'up',\n      DOWN: 'down',\n      LEFT: 'left',\n      RIGHT: 'right',\n      NONE: 'none'\n\n    },\n\n    dataChange: {\n      ALL: 'all',\n      EDIT: 'edit',\n      ROW: 'row',\n      COLUMN: 'column',\n      OPTIONS: 'options'\n    },\n    scrollbars: {\n      NEVER: 0,\n      ALWAYS: 1\n      //WHEN_NEEDED: 2\n    }\n  });\n\n})();\nangular.module('ui.grid').directive('uiGridCell', ['$compile', '$parse', 'gridUtil', 'uiGridConstants', function ($compile, $parse, gridUtil, uiGridConstants) {\n  var uiGridCell = {\n    priority: 0,\n    scope: false,\n    require: '?^uiGrid',\n    compile: function() {\n      return {\n        pre: function($scope, $elm, $attrs, uiGridCtrl) {\n          function compileTemplate() {\n            var compiledElementFn = $scope.col.compiledElementFn;\n\n            compiledElementFn($scope, function(clonedElement, scope) {\n              $elm.append(clonedElement);\n            });\n          }\n\n          // If the grid controller is present, use it to get the compiled cell template function\n          if (uiGridCtrl && $scope.col.compiledElementFn) {\n             compileTemplate();\n          }\n          // No controller, compile the element manually (for unit tests)\n          else {\n            if ( uiGridCtrl && !$scope.col.compiledElementFn ){\n              // gridUtil.logError('Render has been called before precompile.  Please log a ui-grid issue');  \n\n              $scope.col.getCompiledElementFn()\n                .then(function (compiledElementFn) {\n                  compiledElementFn($scope, function(clonedElement, scope) {\n                    $elm.append(clonedElement);\n                  });\n                });\n            }\n            else {\n              var html = $scope.col.cellTemplate\n                .replace(uiGridConstants.MODEL_COL_FIELD, 'row.entity.' + gridUtil.preEval($scope.col.field))\n                .replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');\n\n              var cellElement = $compile(html)($scope);\n              $elm.append(cellElement);\n            }\n          }\n        },\n        post: function($scope, $elm, $attrs, uiGridCtrl) {\n          var initColClass = $scope.col.getColClass(false);\n          $elm.addClass(initColClass);\n\n          var classAdded;\n          var updateClass = function( grid ){\n            var contents = $elm;\n            if ( classAdded ){\n              contents.removeClass( classAdded );\n              classAdded = null;\n            }\n\n            if (angular.isFunction($scope.col.cellClass)) {\n              classAdded = $scope.col.cellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);\n            }\n            else {\n              classAdded = $scope.col.cellClass;\n            }\n            contents.addClass(classAdded);\n          };\n\n          if ($scope.col.cellClass) {\n            updateClass();\n          }\n          \n          // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs\n          var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN, uiGridConstants.dataChange.EDIT]);\n          \n          // watch the col and row to see if they change - which would indicate that we've scrolled or sorted or otherwise\n          // changed the row/col that this cell relates to, and we need to re-evaluate cell classes and maybe other things\n          var cellChangeFunction = function( n, o ){\n            if ( n !== o ) {\n              if ( classAdded || $scope.col.cellClass ){\n                updateClass();\n              }\n\n              // See if the column's internal class has changed\n              var newColClass = $scope.col.getColClass(false);\n              if (newColClass !== initColClass) {\n                $elm.removeClass(initColClass);\n                $elm.addClass(newColClass);\n                initColClass = newColClass;\n              }\n            }\n          };\n\n          // TODO(c0bra): Turn this into a deep array watch\n/*        shouldn't be needed any more given track by col.name\n          var colWatchDereg = $scope.$watch( 'col', cellChangeFunction );\n*/\n          var rowWatchDereg = $scope.$watch( 'row', cellChangeFunction );\n          \n          \n          var deregisterFunction = function() {\n            dataChangeDereg();\n//            colWatchDereg();\n            rowWatchDereg(); \n          };\n          \n          $scope.$on( '$destroy', deregisterFunction );\n          $elm.on( '$destroy', deregisterFunction );\n        }\n      };\n    }\n  };\n\n  return uiGridCell;\n}]);\n\n\n(function(){\n\nangular.module('ui.grid')\n.service('uiGridColumnMenuService', [ 'i18nService', 'uiGridConstants', 'gridUtil',\nfunction ( i18nService, uiGridConstants, gridUtil ) {\n/**\n *  @ngdoc service\n *  @name ui.grid.service:uiGridColumnMenuService\n *\n *  @description Services for working with column menus, factored out\n *  to make the code easier to understand\n */\n\n  var service = {\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name initialize\n     * @description  Sets defaults, puts a reference to the $scope on\n     * the uiGridController\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     * @param {controller} uiGridCtrl the uiGridController for the grid\n     * we're on\n     *\n     */\n    initialize: function( $scope, uiGridCtrl ){\n      $scope.grid = uiGridCtrl.grid;\n\n      // Store a reference to this link/controller in the main uiGrid controller\n      // to allow showMenu later\n      uiGridCtrl.columnMenuScope = $scope;\n\n      // Save whether we're shown or not so the columns can check\n      $scope.menuShown = false;\n    },\n\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name setColMenuItemWatch\n     * @description  Setup a watch on $scope.col.menuItems, and update\n     * menuItems based on this.  $scope.col needs to be set by the column\n     * before calling the menu.\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     * @param {controller} uiGridCtrl the uiGridController for the grid\n     * we're on\n     *\n     */\n    setColMenuItemWatch: function ( $scope ){\n      var deregFunction = $scope.$watch('col.menuItems', function (n) {\n        if (typeof(n) !== 'undefined' && n && angular.isArray(n)) {\n          n.forEach(function (item) {\n            if (typeof(item.context) === 'undefined' || !item.context) {\n              item.context = {};\n            }\n            item.context.col = $scope.col;\n          });\n\n          $scope.menuItems = $scope.defaultMenuItems.concat(n);\n        }\n        else {\n          $scope.menuItems = $scope.defaultMenuItems;\n        }\n      });\n\n      $scope.$on( '$destroy', deregFunction );\n    },\n\n\n    /**\n     * @ngdoc boolean\n     * @name enableSorting\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) True by default. When enabled, this setting adds sort\n     * widgets to the column header, allowing sorting of the data in the individual column.\n     */\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name sortable\n     * @description  determines whether this column is sortable\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     *\n     */\n    sortable: function( $scope ) {\n      if ( $scope.grid.options.enableSorting && typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.enableSorting) {\n        return true;\n      }\n      else {\n        return false;\n      }\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name isActiveSort\n     * @description  determines whether the requested sort direction is current active, to\n     * allow highlighting in the menu\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     * @param {string} direction the direction that we'd have selected for us to be active\n     *\n     */\n    isActiveSort: function( $scope, direction ){\n      return (typeof($scope.col) !== 'undefined' && typeof($scope.col.sort) !== 'undefined' &&\n              typeof($scope.col.sort.direction) !== 'undefined' && $scope.col.sort.direction === direction);\n\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name suppressRemoveSort\n     * @description  determines whether we should suppress the removeSort option\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     *\n     */\n    suppressRemoveSort: function( $scope ) {\n      if ($scope.col && $scope.col.suppressRemoveSort) {\n        return true;\n      }\n      else {\n        return false;\n      }\n    },\n\n\n    /**\n     * @ngdoc boolean\n     * @name enableHiding\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) True by default. When set to false, this setting prevents a user from hiding the column\n     * using the column menu or the grid menu.\n     */\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name hideable\n     * @description  determines whether a column can be hidden, by checking the enableHiding columnDef option\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     *\n     */\n    hideable: function( $scope ) {\n      if (typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.colDef && $scope.col.colDef.enableHiding === false ) {\n        return false;\n      }\n      else {\n        return true;\n      }\n    },\n\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name getDefaultMenuItems\n     * @description  returns the default menu items for a column menu\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     *\n     */\n    getDefaultMenuItems: function( $scope ){\n      return [\n        {\n          title: i18nService.getSafeText('sort.ascending'),\n          icon: 'ui-grid-icon-sort-alt-up',\n          action: function($event) {\n            $event.stopPropagation();\n            $scope.sortColumn($event, uiGridConstants.ASC);\n          },\n          shown: function () {\n            return service.sortable( $scope );\n          },\n          active: function() {\n            return service.isActiveSort( $scope, uiGridConstants.ASC);\n          }\n        },\n        {\n          title: i18nService.getSafeText('sort.descending'),\n          icon: 'ui-grid-icon-sort-alt-down',\n          action: function($event) {\n            $event.stopPropagation();\n            $scope.sortColumn($event, uiGridConstants.DESC);\n          },\n          shown: function() {\n            return service.sortable( $scope );\n          },\n          active: function() {\n            return service.isActiveSort( $scope, uiGridConstants.DESC);\n          }\n        },\n        {\n          title: i18nService.getSafeText('sort.remove'),\n          icon: 'ui-grid-icon-cancel',\n          action: function ($event) {\n            $event.stopPropagation();\n            $scope.unsortColumn();\n          },\n          shown: function() {\n            return service.sortable( $scope ) &&\n                   typeof($scope.col) !== 'undefined' && (typeof($scope.col.sort) !== 'undefined' &&\n                   typeof($scope.col.sort.direction) !== 'undefined') && $scope.col.sort.direction !== null &&\n                  !service.suppressRemoveSort( $scope );\n          }\n        },\n        {\n          title: i18nService.getSafeText('column.hide'),\n          icon: 'ui-grid-icon-cancel',\n          shown: function() {\n            return service.hideable( $scope );\n          },\n          action: function ($event) {\n            $event.stopPropagation();\n            $scope.hideColumn();\n          }\n        }\n      ];\n    },\n\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name getColumnElementPosition\n     * @description  gets the position information needed to place the column\n     * menu below the column header\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     * @param {GridCol} column the column we want to position below\n     * @param {element} $columnElement the column element we want to position below\n     * @returns {hash} containing left, top, offset, height, width\n     *\n     */\n    getColumnElementPosition: function( $scope, column, $columnElement ){\n      var positionData = {};\n      positionData.left = $columnElement[0].offsetLeft;\n      positionData.top = $columnElement[0].offsetTop;\n      positionData.parentLeft = $columnElement[0].offsetParent.offsetLeft;\n\n      // Get the grid scrollLeft\n      positionData.offset = 0;\n      if (column.grid.options.offsetLeft) {\n        positionData.offset = column.grid.options.offsetLeft;\n      }\n\n      positionData.height = gridUtil.elementHeight($columnElement, true);\n      positionData.width = gridUtil.elementWidth($columnElement, true);\n\n      return positionData;\n    },\n\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:uiGridColumnMenuService\n     * @name repositionMenu\n     * @description  Reposition the menu below the new column.  If the menu has no child nodes\n     * (i.e. it's not currently visible) then we guess it's width at 100, we'll be called again\n     * later to fix it\n     * @param {$scope} $scope the $scope from the uiGridColumnMenu\n     * @param {GridCol} column the column we want to position below\n     * @param {hash} positionData a hash containing left, top, offset, height, width\n     * @param {element} $elm the column menu element that we want to reposition\n     * @param {element} $columnElement the column element that we want to reposition underneath\n     *\n     */\n    repositionMenu: function( $scope, column, positionData, $elm, $columnElement ) {\n      var menu = $elm[0].querySelectorAll('.ui-grid-menu');\n\n      // It's possible that the render container of the column we're attaching to is\n      // offset from the grid (i.e. pinned containers), we need to get the difference in the offsetLeft\n      // between the render container and the grid\n      var renderContainerElm = gridUtil.closestElm($columnElement, '.ui-grid-render-container');\n      var renderContainerOffset = renderContainerElm.getBoundingClientRect().left - $scope.grid.element[0].getBoundingClientRect().left;\n\n      var containerScrollLeft = renderContainerElm.querySelectorAll('.ui-grid-viewport')[0].scrollLeft;\n\n      // default value the last width for _this_ column, otherwise last width for _any_ column, otherwise default to 170\n      var myWidth = column.lastMenuWidth ? column.lastMenuWidth : ( $scope.lastMenuWidth ? $scope.lastMenuWidth : 170);\n      var paddingRight = column.lastMenuPaddingRight ? column.lastMenuPaddingRight : ( $scope.lastMenuPaddingRight ? $scope.lastMenuPaddingRight : 10);\n\n      if ( menu.length !== 0 ){\n        var mid = menu[0].querySelectorAll('.ui-grid-menu-mid');\n        if ( mid.length !== 0 && !angular.element(mid).hasClass('ng-hide') ) {\n          myWidth = gridUtil.elementWidth(menu, true);\n          $scope.lastMenuWidth = myWidth;\n          column.lastMenuWidth = myWidth;\n\n          // TODO(c0bra): use padding-left/padding-right based on document direction (ltr/rtl), place menu on proper side\n          // Get the column menu right padding\n          paddingRight = parseInt(gridUtil.getStyles(angular.element(menu)[0])['paddingRight'], 10);\n          $scope.lastMenuPaddingRight = paddingRight;\n          column.lastMenuPaddingRight = paddingRight;\n        }\n      }\n\n      var left = positionData.left + renderContainerOffset - containerScrollLeft + positionData.parentLeft + positionData.width - myWidth + paddingRight;\n      if (left < positionData.offset){\n        left = positionData.offset;\n      }\n\n      $elm.css('left', left + 'px');\n      $elm.css('top', (positionData.top + positionData.height) + 'px');\n    }\n\n  };\n\n  return service;\n}])\n\n\n.directive('uiGridColumnMenu', ['$timeout', 'gridUtil', 'uiGridConstants', 'uiGridColumnMenuService', '$document',\nfunction ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $document) {\n/**\n * @ngdoc directive\n * @name ui.grid.directive:uiGridColumnMenu\n * @description  Provides the column menu framework, leverages uiGridMenu underneath\n *\n */\n\n  var uiGridColumnMenu = {\n    priority: 0,\n    scope: true,\n    require: '^uiGrid',\n    templateUrl: 'ui-grid/uiGridColumnMenu',\n    replace: true,\n    link: function ($scope, $elm, $attrs, uiGridCtrl) {\n      uiGridColumnMenuService.initialize( $scope, uiGridCtrl );\n\n      $scope.defaultMenuItems = uiGridColumnMenuService.getDefaultMenuItems( $scope );\n\n      // Set the menu items for use with the column menu. The user can later add additional items via the watch\n      $scope.menuItems = $scope.defaultMenuItems;\n      uiGridColumnMenuService.setColMenuItemWatch( $scope );\n\n\n      /**\n       * @ngdoc method\n       * @methodOf ui.grid.directive:uiGridColumnMenu\n       * @name showMenu\n       * @description Shows the column menu.  If the menu is already displayed it\n       * calls the menu to ask it to hide (it will animate), then it repositions the menu\n       * to the right place whilst hidden (it will make an assumption on menu width),\n       * then it asks the menu to show (it will animate), then it repositions the menu again\n       * once we can calculate it's size.\n       * @param {GridCol} column the column we want to position below\n       * @param {element} $columnElement the column element we want to position below\n       */\n      $scope.showMenu = function(column, $columnElement, event) {\n        // Swap to this column\n        $scope.col = column;\n\n        // Get the position information for the column element\n        var colElementPosition = uiGridColumnMenuService.getColumnElementPosition( $scope, column, $columnElement );\n\n        if ($scope.menuShown) {\n          // we want to hide, then reposition, then show, but we want to wait for animations\n          // we set a variable, and then rely on the menu-hidden event to call the reposition and show\n          $scope.colElement = $columnElement;\n          $scope.colElementPosition = colElementPosition;\n          $scope.hideThenShow = true;\n\n          $scope.$broadcast('hide-menu', { originalEvent: event });\n        } else {\n          $scope.menuShown = true;\n          uiGridColumnMenuService.repositionMenu( $scope, column, colElementPosition, $elm, $columnElement );\n\n          $scope.colElement = $columnElement;\n          $scope.colElementPosition = colElementPosition;\n          $scope.$broadcast('show-menu', { originalEvent: event });\n\n        }\n      };\n\n\n      /**\n       * @ngdoc method\n       * @methodOf ui.grid.directive:uiGridColumnMenu\n       * @name hideMenu\n       * @description Hides the column menu.\n       * @param {boolean} broadcastTrigger true if we were triggered by a broadcast\n       * from the menu itself - in which case don't broadcast again as we'll get\n       * an infinite loop\n       */\n      $scope.hideMenu = function( broadcastTrigger ) {\n        $scope.menuShown = false;\n        if ( !broadcastTrigger ){\n          $scope.$broadcast('hide-menu');\n        }\n      };\n\n\n      $scope.$on('menu-hidden', function() {\n        if ( $scope.hideThenShow ){\n          delete $scope.hideThenShow;\n\n          uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement );\n          $scope.$broadcast('show-menu');\n\n          $scope.menuShown = true;\n        } else {\n          $scope.hideMenu( true );\n\n          if ($scope.col) {\n            //Focus on the menu button\n            gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + $scope.col.getColClass()+ ' .ui-grid-column-menu-button', $scope.col.grid, false);\n          }\n        }\n      });\n\n      $scope.$on('menu-shown', function() {\n        $timeout( function() {\n          uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement );\n          //Focus on the first item\n          gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item', true);\n          delete $scope.colElementPosition;\n          delete $scope.columnElement;\n        }, 200);\n      });\n\n\n      /* Column methods */\n      $scope.sortColumn = function (event, dir) {\n        event.stopPropagation();\n\n        $scope.grid.sortColumn($scope.col, dir, true)\n          .then(function () {\n            $scope.grid.refresh();\n            $scope.hideMenu();\n          });\n      };\n\n      $scope.unsortColumn = function () {\n        $scope.col.unsort();\n\n        $scope.grid.refresh();\n        $scope.hideMenu();\n      };\n\n      //Since we are hiding this column the default hide action will fail so we need to focus somewhere else.\n      var setFocusOnHideColumn = function(){\n        $timeout(function(){\n          // Get the UID of the first\n          var focusToGridMenu = function(){\n            return gridUtil.focus.byId('grid-menu', $scope.grid);\n          };\n\n          var thisIndex;\n          $scope.grid.columns.some(function(element, index){\n            if (angular.equals(element, $scope.col)) {\n              thisIndex = index;\n              return true;\n            }\n          });\n\n          var previousVisibleCol;\n          // Try and find the next lower or nearest column to focus on\n          $scope.grid.columns.some(function(element, index){\n            if (!element.visible){\n              return false;\n            } // This columns index is below the current column index\n            else if ( index < thisIndex){\n              previousVisibleCol = element;\n            } // This elements index is above this column index and we haven't found one that is lower\n            else if ( index > thisIndex && !previousVisibleCol) {\n              // This is the next best thing\n              previousVisibleCol = element;\n              // We've found one so use it.\n              return true;\n            } // We've reached an element with an index above this column and the previousVisibleCol variable has been set\n            else if (index > thisIndex && previousVisibleCol) {\n              // We are done.\n              return true;\n            }\n          });\n          // If found then focus on it\n          if (previousVisibleCol){\n            var colClass = previousVisibleCol.getColClass();\n            gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + colClass+ ' .ui-grid-header-cell-primary-focus', true).then(angular.noop, function(reason){\n              if (reason !== 'canceled'){ // If this is canceled then don't perform the action\n                //The fallback action is to focus on the grid menu\n                return focusToGridMenu();\n              }\n            });\n          } else {\n            // Fallback action to focus on the grid menu\n            focusToGridMenu();\n          }\n        });\n      };\n\n      $scope.hideColumn = function () {\n        $scope.col.colDef.visible = false;\n        $scope.col.visible = false;\n\n        $scope.grid.queueGridRefresh();\n        $scope.hideMenu();\n        $scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );\n        $scope.grid.api.core.raise.columnVisibilityChanged( $scope.col );\n\n        // We are hiding so the default action of focusing on the button that opened this menu will fail.\n        setFocusOnHideColumn();\n      };\n    },\n\n\n\n    controller: ['$scope', function ($scope) {\n      var self = this;\n\n      $scope.$watch('menuItems', function (n) {\n        self.menuItems = n;\n      });\n    }]\n  };\n\n  return uiGridColumnMenu;\n\n}]);\n\n})();\n\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridFilter', ['$compile', '$templateCache', 'i18nService', 'gridUtil', function ($compile, $templateCache, i18nService, gridUtil) {\n\n    return {\n      compile: function() {\n        return {\n          pre: function ($scope, $elm, $attrs, controllers) {\n            $scope.col.updateFilters = function( filterable ){\n              $elm.children().remove();\n              if ( filterable ){\n                var template = $scope.col.filterHeaderTemplate;\n\n                $elm.append($compile(template)($scope));\n              }\n            };\n\n            $scope.$on( '$destroy', function() {\n              delete $scope.col.updateFilters;\n            });\n          },\n          post: function ($scope, $elm, $attrs, controllers){\n            $scope.aria = i18nService.getSafeText('headerCell.aria');\n            $scope.removeFilter = function(colFilter, index){\n              colFilter.term = null;\n              //Set the focus to the filter input after the action disables the button\n              gridUtil.focus.bySelector($elm, '.ui-grid-filter-input-' + index);\n            };\n          }\n        };\n      }\n    };\n  }]);\n})();\n\n(function () {\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridFooterCell', ['$timeout', 'gridUtil', 'uiGridConstants', '$compile',\n  function ($timeout, gridUtil, uiGridConstants, $compile) {\n    var uiGridFooterCell = {\n      priority: 0,\n      scope: {\n        col: '=',\n        row: '=',\n        renderIndex: '='\n      },\n      replace: true,\n      require: '^uiGrid',\n      compile: function compile(tElement, tAttrs, transclude) {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            var cellFooter = $compile($scope.col.footerCellTemplate)($scope);\n            $elm.append(cellFooter);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            //$elm.addClass($scope.col.getColClass(false));\n            $scope.grid = uiGridCtrl.grid;\n\n            var initColClass = $scope.col.getColClass(false);\n            $elm.addClass(initColClass);\n\n            // apply any footerCellClass\n            var classAdded;\n            var updateClass = function( grid ){\n              var contents = $elm;\n              if ( classAdded ){\n                contents.removeClass( classAdded );\n                classAdded = null;\n              }\n  \n              if (angular.isFunction($scope.col.footerCellClass)) {\n                classAdded = $scope.col.footerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);\n              }\n              else {\n                classAdded = $scope.col.footerCellClass;\n              }\n              contents.addClass(classAdded);\n            };\n  \n            if ($scope.col.footerCellClass) {\n              updateClass();\n            }\n\n            $scope.col.updateAggregationValue();\n\n            // Watch for column changes so we can alter the col cell class properly\n/* shouldn't be needed any more, given track by col.name\n            $scope.$watch('col', function (n, o) {\n              if (n !== o) {\n                // See if the column's internal class has changed\n                var newColClass = $scope.col.getColClass(false);\n                if (newColClass !== initColClass) {\n                  $elm.removeClass(initColClass);\n                  $elm.addClass(newColClass);\n                  initColClass = newColClass;\n                }\n              }\n            });\n*/\n\n\n            // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs\n            var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN]);\n            // listen for visible rows change and update aggregation values\n            $scope.grid.api.core.on.rowsRendered( $scope, $scope.col.updateAggregationValue );\n            $scope.grid.api.core.on.rowsRendered( $scope, updateClass );\n            $scope.$on( '$destroy', dataChangeDereg );\n          }\n        };\n      }\n    };\n\n    return uiGridFooterCell;\n  }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) {\n\n    return {\n      restrict: 'EA',\n      replace: true,\n      // priority: 1000,\n      require: ['^uiGrid', '^uiGridRenderContainer'],\n      scope: true,\n      compile: function ($elm, $attrs) {\n        return {\n          pre: function ($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            $scope.grid = uiGridCtrl.grid;\n            $scope.colContainer = containerCtrl.colContainer;\n\n            containerCtrl.footer = $elm;\n\n            var footerTemplate = $scope.grid.options.footerTemplate;\n            gridUtil.getTemplate(footerTemplate)\n              .then(function (contents) {\n                var template = angular.element(contents);\n\n                var newElm = $compile(template)($scope);\n                $elm.append(newElm);\n\n                if (containerCtrl) {\n                  // Inject a reference to the footer viewport (if it exists) into the grid controller for use in the horizontal scroll handler below\n                  var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0];\n\n                  if (footerViewport) {\n                    containerCtrl.footerViewport = footerViewport;\n                  }\n                }\n              });\n          },\n\n          post: function ($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            // gridUtil.logDebug('ui-grid-footer link');\n\n            var grid = uiGridCtrl.grid;\n\n            // Don't animate footer cells\n            gridUtil.disableAnimations($elm);\n\n            containerCtrl.footer = $elm;\n\n            var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0];\n            if (footerViewport) {\n              containerCtrl.footerViewport = footerViewport;\n            }\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n(function () {\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) {\n\n    return {\n      restrict: 'EA',\n      replace: true,\n      // priority: 1000,\n      require: '^uiGrid',\n      scope: true,\n      compile: function ($elm, $attrs) {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n            $scope.grid = uiGridCtrl.grid;\n\n\n\n            var footerTemplate = $scope.grid.options.gridFooterTemplate;\n            gridUtil.getTemplate(footerTemplate)\n              .then(function (contents) {\n                var template = angular.element(contents);\n\n                var newElm = $compile(template)($scope);\n                $elm.append(newElm);\n              });\n          },\n\n          post: function ($scope, $elm, $attrs, controllers) {\n\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridGroupPanel', [\"$compile\", \"uiGridConstants\", \"gridUtil\", function($compile, uiGridConstants, gridUtil) {\n    var defaultTemplate = 'ui-grid/ui-grid-group-panel';\n\n    return {\n      restrict: 'EA',\n      replace: true,\n      require: '?^uiGrid',\n      scope: false,\n      compile: function($elm, $attrs) {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            var groupPanelTemplate = $scope.grid.options.groupPanelTemplate  || defaultTemplate;\n\n             gridUtil.getTemplate(groupPanelTemplate)\n              .then(function (contents) {\n                var template = angular.element(contents);\n                \n                var newElm = $compile(template)($scope);\n                $elm.append(newElm);\n              });\n          },\n\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            $elm.bind('$destroy', function() {\n              // scrollUnbinder();\n            });\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridHeaderCell', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'ScrollEvent', 'i18nService',\n  function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, ScrollEvent, i18nService) {\n    // Do stuff after mouse has been down this many ms on the header cell\n    var mousedownTimeout = 500;\n    var changeModeTimeout = 500;    // length of time between a touch event and a mouse event being recognised again, and vice versa\n\n    var uiGridHeaderCell = {\n      priority: 0,\n      scope: {\n        col: '=',\n        row: '=',\n        renderIndex: '='\n      },\n      require: ['^uiGrid', '^uiGridRenderContainer'],\n      replace: true,\n      compile: function() {\n        return {\n          pre: function ($scope, $elm, $attrs) {\n            var cellHeader = $compile($scope.col.headerCellTemplate)($scope);\n            $elm.append(cellHeader);\n          },\n\n          post: function ($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var renderContainerCtrl = controllers[1];\n\n            $scope.i18n = {\n              headerCell: i18nService.getSafeText('headerCell'),\n              sort: i18nService.getSafeText('sort')\n            };\n            $scope.isSortPriorityVisible = function() {\n              //show sort priority if column is sorted and there is at least one other sorted column\n              return angular.isNumber($scope.col.sort.priority) && $scope.grid.columns.some(function(element, index){\n                  return angular.isNumber(element.sort.priority) && element !== $scope.col;\n                });\n            };\n            $scope.getSortDirectionAriaLabel = function(){\n              var col = $scope.col;\n              //Trying to recreate this sort of thing but it was getting messy having it in the template.\n              //Sort direction {{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending':'none')}}. {{col.sort.priority ? {{columnPriorityText}} {{col.sort.priority}} : ''}\n              var sortDirectionText = col.sort.direction === uiGridConstants.ASC ? $scope.i18n.sort.ascending : ( col.sort.direction === uiGridConstants.DESC ? $scope.i18n.sort.descending : $scope.i18n.sort.none);\n              var label = sortDirectionText;\n\n              if ($scope.isSortPriorityVisible()) {\n                label = label + '. ' + $scope.i18n.headerCell.priority + ' ' + col.sort.priority;\n              }\n              return label;\n            };\n\n            $scope.grid = uiGridCtrl.grid;\n\n            $scope.renderContainer = uiGridCtrl.grid.renderContainers[renderContainerCtrl.containerId];\n\n            var initColClass = $scope.col.getColClass(false);\n            $elm.addClass(initColClass);\n\n            // Hide the menu by default\n            $scope.menuShown = false;\n\n            // Put asc and desc sort directions in scope\n            $scope.asc = uiGridConstants.ASC;\n            $scope.desc = uiGridConstants.DESC;\n\n            // Store a reference to menu element\n            var $colMenu = angular.element( $elm[0].querySelectorAll('.ui-grid-header-cell-menu') );\n\n            var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') );\n\n\n            // apply any headerCellClass\n            var classAdded;\n            var previousMouseX;\n\n            // filter watchers\n            var filterDeregisters = [];\n\n\n            /*\n             * Our basic approach here for event handlers is that we listen for a down event (mousedown or touchstart).\n             * Once we have a down event, we need to work out whether we have a click, a drag, or a\n             * hold.  A click would sort the grid (if sortable).  A drag would be used by moveable, so\n             * we ignore it.  A hold would open the menu.\n             *\n             * So, on down event, we put in place handlers for move and up events, and a timer.  If the\n             * timer expires before we see a move or up, then we have a long press and hence a column menu open.\n             * If the up happens before the timer, then we have a click, and we sort if the column is sortable.\n             * If a move happens before the timer, then we are doing column move, so we do nothing, the moveable feature\n             * will handle it.\n             *\n             * To deal with touch enabled devices that also have mice, we only create our handlers when\n             * we get the down event, and we create the corresponding handlers - if we're touchstart then\n             * we get touchmove and touchend, if we're mousedown then we get mousemove and mouseup.\n             *\n             * We also suppress the click action whilst this is happening - otherwise after the mouseup there\n             * will be a click event and that can cause the column menu to close\n             *\n             */\n\n            $scope.downFn = function( event ){\n              event.stopPropagation();\n\n              if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) {\n                event = event.originalEvent;\n              }\n\n              // Don't show the menu if it's not the left button\n              if (event.button && event.button !== 0) {\n                return;\n              }\n              previousMouseX = event.pageX;\n\n              $scope.mousedownStartTime = (new Date()).getTime();\n              $scope.mousedownTimeout = $timeout(function() { }, mousedownTimeout);\n\n              $scope.mousedownTimeout.then(function () {\n                if ( $scope.colMenu ) {\n                  uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm, event);\n                }\n              });\n\n              uiGridCtrl.fireEvent(uiGridConstants.events.COLUMN_HEADER_CLICK, {event: event, columnName: $scope.col.colDef.name});\n\n              $scope.offAllEvents();\n              if ( event.type === 'touchstart'){\n                $document.on('touchend', $scope.upFn);\n                $document.on('touchmove', $scope.moveFn);\n              } else if ( event.type === 'mousedown' ){\n                $document.on('mouseup', $scope.upFn);\n                $document.on('mousemove', $scope.moveFn);\n              }\n            };\n\n            $scope.upFn = function( event ){\n              event.stopPropagation();\n              $timeout.cancel($scope.mousedownTimeout);\n              $scope.offAllEvents();\n              $scope.onDownEvents(event.type);\n\n              var mousedownEndTime = (new Date()).getTime();\n              var mousedownTime = mousedownEndTime - $scope.mousedownStartTime;\n\n              if (mousedownTime > mousedownTimeout) {\n                // long click, handled above with mousedown\n              }\n              else {\n                // short click\n                if ( $scope.sortable ){\n                  $scope.handleClick(event);\n                }\n              }\n            };\n\n            $scope.moveFn = function( event ){\n              // Chrome is known to fire some bogus move events.\n              var changeValue = event.pageX - previousMouseX;\n              if ( changeValue === 0 ){ return; }\n\n              // we're a move, so do nothing and leave for column move (if enabled) to take over\n              $timeout.cancel($scope.mousedownTimeout);\n              $scope.offAllEvents();\n              $scope.onDownEvents(event.type);\n            };\n\n            $scope.clickFn = function ( event ){\n              event.stopPropagation();\n              $contentsElm.off('click', $scope.clickFn);\n            };\n\n\n            $scope.offAllEvents = function(){\n              $contentsElm.off('touchstart', $scope.downFn);\n              $contentsElm.off('mousedown', $scope.downFn);\n\n              $document.off('touchend', $scope.upFn);\n              $document.off('mouseup', $scope.upFn);\n\n              $document.off('touchmove', $scope.moveFn);\n              $document.off('mousemove', $scope.moveFn);\n\n              $contentsElm.off('click', $scope.clickFn);\n            };\n\n            $scope.onDownEvents = function( type ){\n              // If there is a previous event, then wait a while before\n              // activating the other mode - i.e. if the last event was a touch event then\n              // don't enable mouse events for a wee while (500ms or so)\n              // Avoids problems with devices that emulate mouse events when you have touch events\n\n              switch (type){\n                case 'touchmove':\n                case 'touchend':\n                  $contentsElm.on('click', $scope.clickFn);\n                  $contentsElm.on('touchstart', $scope.downFn);\n                  $timeout(function(){\n                    $contentsElm.on('mousedown', $scope.downFn);\n                  }, changeModeTimeout);\n                  break;\n                case 'mousemove':\n                case 'mouseup':\n                  $contentsElm.on('click', $scope.clickFn);\n                  $contentsElm.on('mousedown', $scope.downFn);\n                  $timeout(function(){\n                    $contentsElm.on('touchstart', $scope.downFn);\n                  }, changeModeTimeout);\n                  break;\n                default:\n                  $contentsElm.on('click', $scope.clickFn);\n                  $contentsElm.on('touchstart', $scope.downFn);\n                  $contentsElm.on('mousedown', $scope.downFn);\n              }\n            };\n\n\n            var updateHeaderOptions = function( grid ){\n              var contents = $elm;\n              if ( classAdded ){\n                contents.removeClass( classAdded );\n                classAdded = null;\n              }\n\n              if (angular.isFunction($scope.col.headerCellClass)) {\n                classAdded = $scope.col.headerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);\n              }\n              else {\n                classAdded = $scope.col.headerCellClass;\n              }\n              contents.addClass(classAdded);\n\n              $timeout(function (){\n                var rightMostContainer = $scope.grid.renderContainers['right'] ? $scope.grid.renderContainers['right'] : $scope.grid.renderContainers['body'];\n                $scope.isLastCol = ( $scope.col === rightMostContainer.visibleColumnCache[ rightMostContainer.visibleColumnCache.length - 1 ] );\n              });\n\n              // Figure out whether this column is sortable or not\n              if (uiGridCtrl.grid.options.enableSorting && $scope.col.enableSorting) {\n                $scope.sortable = true;\n              }\n              else {\n                $scope.sortable = false;\n              }\n\n              // Figure out whether this column is filterable or not\n              var oldFilterable = $scope.filterable;\n              if (uiGridCtrl.grid.options.enableFiltering && $scope.col.enableFiltering) {\n                $scope.filterable = true;\n              }\n              else {\n                $scope.filterable = false;\n              }\n\n              if ( oldFilterable !== $scope.filterable){\n                if ( typeof($scope.col.updateFilters) !== 'undefined' ){\n                  $scope.col.updateFilters($scope.filterable);\n                }\n\n                // if column is filterable add a filter watcher\n                if ($scope.filterable) {\n                  $scope.col.filters.forEach( function(filter, i) {\n                    filterDeregisters.push($scope.$watch('col.filters[' + i + '].term', function(n, o) {\n                      if (n !== o) {\n                        uiGridCtrl.grid.api.core.raise.filterChanged();\n                        uiGridCtrl.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );\n                        uiGridCtrl.grid.queueGridRefresh();\n                      }\n                    }));\n                  });\n                  $scope.$on('$destroy', function() {\n                    filterDeregisters.forEach( function(filterDeregister) {\n                      filterDeregister();\n                    });\n                  });\n                } else {\n                  filterDeregisters.forEach( function(filterDeregister) {\n                    filterDeregister();\n                  });\n                }\n\n              }\n\n              // figure out whether we support column menus\n              if ($scope.col.grid.options && $scope.col.grid.options.enableColumnMenus !== false &&\n                      $scope.col.colDef && $scope.col.colDef.enableColumnMenu !== false){\n                $scope.colMenu = true;\n              } else {\n                $scope.colMenu = false;\n              }\n\n              /**\n              * @ngdoc property\n              * @name enableColumnMenu\n              * @propertyOf ui.grid.class:GridOptions.columnDef\n              * @description if column menus are enabled, controls the column menus for this specific\n              * column (i.e. if gridOptions.enableColumnMenus, then you can control column menus\n              * using this option. If gridOptions.enableColumnMenus === false then you get no column\n              * menus irrespective of the value of this option ).  Defaults to true.\n              *\n              */\n              /**\n              * @ngdoc property\n              * @name enableColumnMenus\n              * @propertyOf ui.grid.class:GridOptions.columnDef\n              * @description Override for column menus everywhere - if set to false then you get no\n              * column menus.  Defaults to true.\n              *\n              */\n\n              $scope.offAllEvents();\n\n              if ($scope.sortable || $scope.colMenu) {\n                $scope.onDownEvents();\n\n                $scope.$on('$destroy', function () {\n                  $scope.offAllEvents();\n                });\n              }\n            };\n\n/*\n            $scope.$watch('col', function (n, o) {\n              if (n !== o) {\n                // See if the column's internal class has changed\n                var newColClass = $scope.col.getColClass(false);\n                if (newColClass !== initColClass) {\n                  $elm.removeClass(initColClass);\n                  $elm.addClass(newColClass);\n                  initColClass = newColClass;\n                }\n              }\n            });\n*/\n            updateHeaderOptions();\n\n            // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs\n            var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateHeaderOptions, [uiGridConstants.dataChange.COLUMN]);\n\n            $scope.$on( '$destroy', dataChangeDereg );\n\n            $scope.handleClick = function(event) {\n              // If the shift key is being held down, add this column to the sort\n              var add = false;\n              if (event.shiftKey) {\n                add = true;\n              }\n\n              // Sort this column then rebuild the grid's rows\n              uiGridCtrl.grid.sortColumn($scope.col, add)\n                .then(function () {\n                  if (uiGridCtrl.columnMenuScope) { uiGridCtrl.columnMenuScope.hideMenu(); }\n                  uiGridCtrl.grid.refresh();\n                });\n            };\n\n\n            $scope.toggleMenu = function(event) {\n              event.stopPropagation();\n\n              // If the menu is already showing...\n              if (uiGridCtrl.columnMenuScope.menuShown) {\n                // ... and we're the column the menu is on...\n                if (uiGridCtrl.columnMenuScope.col === $scope.col) {\n                  // ... hide it\n                  uiGridCtrl.columnMenuScope.hideMenu();\n                }\n                // ... and we're NOT the column the menu is on\n                else {\n                  // ... move the menu to our column\n                  uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm);\n                }\n              }\n              // If the menu is NOT showing\n              else {\n                // ... show it on our column\n                uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm);\n              }\n            };\n          }\n        };\n      }\n    };\n\n    return uiGridHeaderCell;\n  }]);\n\n})();\n\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridHeader', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', 'ScrollEvent',\n    function($templateCache, $compile, uiGridConstants, gridUtil, $timeout, ScrollEvent) {\n    var defaultTemplate = 'ui-grid/ui-grid-header';\n    var emptyTemplate = 'ui-grid/ui-grid-no-header';\n\n    return {\n      restrict: 'EA',\n      // templateUrl: 'ui-grid/ui-grid-header',\n      replace: true,\n      // priority: 1000,\n      require: ['^uiGrid', '^uiGridRenderContainer'],\n      scope: true,\n      compile: function($elm, $attrs) {\n        return {\n          pre: function ($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            $scope.grid = uiGridCtrl.grid;\n            $scope.colContainer = containerCtrl.colContainer;\n\n            updateHeaderReferences();\n            \n            var headerTemplate;\n            if (!$scope.grid.options.showHeader) {\n              headerTemplate = emptyTemplate;\n            }\n            else {\n              headerTemplate = ($scope.grid.options.headerTemplate) ? $scope.grid.options.headerTemplate : defaultTemplate;            \n            }\n\n            gridUtil.getTemplate(headerTemplate)\n              .then(function (contents) {\n                var template = angular.element(contents);\n                \n                var newElm = $compile(template)($scope);\n                $elm.replaceWith(newElm);\n\n                // And update $elm to be the new element\n                $elm = newElm;\n\n                updateHeaderReferences();\n\n                if (containerCtrl) {\n                  // Inject a reference to the header viewport (if it exists) into the grid controller for use in the horizontal scroll handler below\n                  var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0];\n\n\n                  if (headerViewport) {\n                    containerCtrl.headerViewport = headerViewport;\n                    angular.element(headerViewport).on('scroll', scrollHandler);\n                    $scope.$on('$destroy', function () {\n                      angular.element(headerViewport).off('scroll', scrollHandler);\n                    });\n                  }\n                }\n\n                $scope.grid.queueRefresh();\n              });\n\n            function updateHeaderReferences() {\n              containerCtrl.header = containerCtrl.colContainer.header = $elm;\n\n              var headerCanvases = $elm[0].getElementsByClassName('ui-grid-header-canvas');\n\n              if (headerCanvases.length > 0) {\n                containerCtrl.headerCanvas = containerCtrl.colContainer.headerCanvas = headerCanvases[0];\n              }\n              else {\n                containerCtrl.headerCanvas = null;\n              }\n            }\n\n            function scrollHandler(evt) {\n              if (uiGridCtrl.grid.isScrollingHorizontally) {\n                return;\n              }\n              var newScrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.headerViewport, uiGridCtrl.grid);\n              var horizScrollPercentage = containerCtrl.colContainer.scrollHorizontal(newScrollLeft);\n\n              var scrollEvent = new ScrollEvent(uiGridCtrl.grid, null, containerCtrl.colContainer, ScrollEvent.Sources.ViewPortScroll);\n              scrollEvent.newScrollLeft = newScrollLeft;\n              if ( horizScrollPercentage > -1 ){\n                scrollEvent.x = { percentage: horizScrollPercentage };\n              }\n\n              uiGridCtrl.grid.scrollContainers(null, scrollEvent);\n            }\n          },\n\n          post: function ($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            // gridUtil.logDebug('ui-grid-header link');\n\n            var grid = uiGridCtrl.grid;\n\n            // Don't animate header cells\n            gridUtil.disableAnimations($elm);\n\n            function updateColumnWidths() {\n              // this styleBuilder always runs after the renderContainer, so we can rely on the column widths\n              // already being populated correctly\n\n              var columnCache = containerCtrl.colContainer.visibleColumnCache;\n              \n              // Build the CSS\n              // uiGridCtrl.grid.columns.forEach(function (column) {\n              var ret = '';\n              var canvasWidth = 0;\n              columnCache.forEach(function (column) {\n                ret = ret + column.getColClassDefinition();\n                canvasWidth += column.drawnWidth;\n              });\n\n              containerCtrl.colContainer.canvasWidth = canvasWidth;\n              \n              // Return the styles back to buildStyles which pops them into the `customStyles` scope variable\n              return ret;\n            }\n            \n            containerCtrl.header = $elm;\n            \n            var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0];\n            if (headerViewport) {\n              containerCtrl.headerViewport = headerViewport;\n            }\n\n            //todo: remove this if by injecting gridCtrl into unit tests\n            if (uiGridCtrl) {\n              uiGridCtrl.grid.registerStyleComputation({\n                priority: 15,\n                func: updateColumnWidths\n              });\n            }\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n\n(function(){\n\nangular.module('ui.grid')\n.service('uiGridGridMenuService', [ 'gridUtil', 'i18nService', 'uiGridConstants', function( gridUtil, i18nService, uiGridConstants ) {\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.gridMenuService\n   *\n   *  @description Methods for working with the grid menu\n   */\n\n  var service = {\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.gridMenuService\n     * @name initialize\n     * @description Sets up the gridMenu. Most importantly, sets our\n     * scope onto the grid object as grid.gridMenuScope, allowing us\n     * to operate when passed only the grid.  Second most importantly,\n     * we register the 'addToGridMenu' and 'removeFromGridMenu' methods\n     * on the core api.\n     * @param {$scope} $scope the scope of this gridMenu\n     * @param {Grid} grid the grid to which this gridMenu is associated\n     */\n    initialize: function( $scope, grid ){\n      grid.gridMenuScope = $scope;\n      $scope.grid = grid;\n      $scope.registeredMenuItems = [];\n\n      // not certain this is needed, but would be bad to create a memory leak\n      $scope.$on('$destroy', function() {\n        if ( $scope.grid && $scope.grid.gridMenuScope ){\n          $scope.grid.gridMenuScope = null;\n        }\n        if ( $scope.grid ){\n          $scope.grid = null;\n        }\n        if ( $scope.registeredMenuItems ){\n          $scope.registeredMenuItems = null;\n        }\n      });\n\n      $scope.registeredMenuItems = [];\n\n      /**\n       * @ngdoc function\n       * @name addToGridMenu\n       * @methodOf ui.grid.core.api:PublicApi\n       * @description add items to the grid menu.  Used by features\n       * to add their menu items if they are enabled, can also be used by\n       * end users to add menu items.  This method has the advantage of allowing\n       * remove again, which can simplify management of which items are included\n       * in the menu when.  (Noting that in most cases the shown and active functions\n       * provide a better way to handle visibility of menu items)\n       * @param {Grid} grid the grid on which we are acting\n       * @param {array} items menu items in the format as described in the tutorial, with\n       * the added note that if you want to use remove you must also specify an `id` field,\n       * which is provided when you want to remove an item.  The id should be unique.\n       *\n       */\n      grid.api.registerMethod( 'core', 'addToGridMenu', service.addToGridMenu );\n\n      /**\n       * @ngdoc function\n       * @name removeFromGridMenu\n       * @methodOf ui.grid.core.api:PublicApi\n       * @description Remove an item from the grid menu based on a provided id. Assumes\n       * that the id is unique, removes only the last instance of that id. Does nothing if\n       * the specified id is not found\n       * @param {Grid} grid the grid on which we are acting\n       * @param {string} id the id we'd like to remove from the menu\n       *\n       */\n      grid.api.registerMethod( 'core', 'removeFromGridMenu', service.removeFromGridMenu );\n    },\n\n\n    /**\n     * @ngdoc function\n     * @name addToGridMenu\n     * @propertyOf ui.grid.gridMenuService\n     * @description add items to the grid menu.  Used by features\n     * to add their menu items if they are enabled, can also be used by\n     * end users to add menu items.  This method has the advantage of allowing\n     * remove again, which can simplify management of which items are included\n     * in the menu when.  (Noting that in most cases the shown and active functions\n     * provide a better way to handle visibility of menu items)\n     * @param {Grid} grid the grid on which we are acting\n     * @param {array} items menu items in the format as described in the tutorial, with\n     * the added note that if you want to use remove you must also specify an `id` field,\n     * which is provided when you want to remove an item.  The id should be unique.\n     *\n     */\n    addToGridMenu: function( grid, menuItems ) {\n      if ( !angular.isArray( menuItems ) ) {\n        gridUtil.logError( 'addToGridMenu: menuItems must be an array, and is not, not adding any items');\n      } else {\n        if ( grid.gridMenuScope ){\n          grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems ? grid.gridMenuScope.registeredMenuItems : [];\n          grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems.concat( menuItems );\n        } else {\n          gridUtil.logError( 'Asked to addToGridMenu, but gridMenuScope not present.  Timing issue?  Please log issue with ui-grid');\n        }\n      }\n    },\n\n\n    /**\n     * @ngdoc function\n     * @name removeFromGridMenu\n     * @methodOf ui.grid.gridMenuService\n     * @description Remove an item from the grid menu based on a provided id.  Assumes\n     * that the id is unique, removes only the last instance of that id.  Does nothing if\n     * the specified id is not found.  If there is no gridMenuScope or registeredMenuItems\n     * then do nothing silently - the desired result is those menu items not be present and they\n     * aren't.\n     * @param {Grid} grid the grid on which we are acting\n     * @param {string} id the id we'd like to remove from the menu\n     *\n     */\n    removeFromGridMenu: function( grid, id ){\n      var foundIndex = -1;\n\n      if ( grid && grid.gridMenuScope ){\n        grid.gridMenuScope.registeredMenuItems.forEach( function( value, index ) {\n          if ( value.id === id ){\n            if (foundIndex > -1) {\n              gridUtil.logError( 'removeFromGridMenu: found multiple items with the same id, removing only the last' );\n            } else {\n\n              foundIndex = index;\n            }\n          }\n        });\n      }\n\n      if ( foundIndex > -1 ){\n        grid.gridMenuScope.registeredMenuItems.splice( foundIndex, 1 );\n      }\n    },\n\n\n    /**\n     * @ngdoc array\n     * @name gridMenuCustomItems\n     * @propertyOf ui.grid.class:GridOptions\n     * @description (optional) An array of menu items that should be added to\n     * the gridMenu.  Follow the format documented in the tutorial for column\n     * menu customisation.  The context provided to the action function will\n     * include context.grid.  An alternative if working with dynamic menus is to use the\n     * provided api - core.addToGridMenu and core.removeFromGridMenu, which handles\n     * some of the management of items for you.\n     *\n     */\n    /**\n     * @ngdoc boolean\n     * @name gridMenuShowHideColumns\n     * @propertyOf ui.grid.class:GridOptions\n     * @description true by default, whether the grid menu should allow hide/show\n     * of columns\n     *\n     */\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.gridMenuService\n     * @name getMenuItems\n     * @description Decides the menu items to show in the menu.  This is a\n     * combination of:\n     *\n     * - the default menu items that are always included,\n     * - any menu items that have been provided through the addMenuItem api. These\n     *   are typically added by features within the grid\n     * - any menu items included in grid.options.gridMenuCustomItems.  These can be\n     *   changed dynamically, as they're always recalculated whenever we show the\n     *   menu\n     * @param {$scope} $scope the scope of this gridMenu, from which we can find all\n     * the information that we need\n     * @returns {array} an array of menu items that can be shown\n     */\n    getMenuItems: function( $scope ) {\n      var menuItems = [\n        // this is where we add any menu items we want to always include\n      ];\n\n      if ( $scope.grid.options.gridMenuCustomItems ){\n        if ( !angular.isArray( $scope.grid.options.gridMenuCustomItems ) ){\n          gridUtil.logError( 'gridOptions.gridMenuCustomItems must be an array, and is not');\n        } else {\n          menuItems = menuItems.concat( $scope.grid.options.gridMenuCustomItems );\n        }\n      }\n\n      var clearFilters = [{\n        title: i18nService.getSafeText('gridMenu.clearAllFilters'),\n        action: function ($event) {\n          $scope.grid.clearAllFilters(undefined, true, undefined);\n        },\n        shown: function() {\n          return $scope.grid.options.enableFiltering;\n        },\n        order: 100\n      }];\n      menuItems = menuItems.concat( clearFilters );\n\n      menuItems = menuItems.concat( $scope.registeredMenuItems );\n\n      if ( $scope.grid.options.gridMenuShowHideColumns !== false ){\n        menuItems = menuItems.concat( service.showHideColumns( $scope ) );\n      }\n\n      menuItems.sort(function(a, b){\n        return a.order - b.order;\n      });\n\n      return menuItems;\n    },\n\n\n    /**\n     * @ngdoc array\n     * @name gridMenuTitleFilter\n     * @propertyOf ui.grid.class:GridOptions\n     * @description (optional) A function that takes a title string\n     * (usually the col.displayName), and converts it into a display value.  The function\n     * must return either a string or a promise.\n     *\n     * Used for internationalization of the grid menu column names - for angular-translate\n     * you can pass $translate as the function, for i18nService you can pass getSafeText as the\n     * function\n     * @example\n     * <pre>\n     *   gridOptions = {\n     *     gridMenuTitleFilter: $translate\n     *   }\n     * </pre>\n     */\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.gridMenuService\n     * @name showHideColumns\n     * @description Adds two menu items for each of the columns in columnDefs.  One\n     * menu item for hide, one menu item for show.  Each is visible when appropriate\n     * (show when column is not visible, hide when column is visible).  Each toggles\n     * the visible property on the columnDef using toggleColumnVisibility\n     * @param {$scope} $scope of a gridMenu, which contains a reference to the grid\n     */\n    showHideColumns: function( $scope ){\n      var showHideColumns = [];\n      if ( !$scope.grid.options.columnDefs || $scope.grid.options.columnDefs.length === 0 || $scope.grid.columns.length === 0 ) {\n        return showHideColumns;\n      }\n\n      // add header for columns\n      showHideColumns.push({\n        title: i18nService.getSafeText('gridMenu.columns'),\n        order: 300\n      });\n\n      $scope.grid.options.gridMenuTitleFilter = $scope.grid.options.gridMenuTitleFilter ? $scope.grid.options.gridMenuTitleFilter : function( title ) { return title; };\n\n      $scope.grid.options.columnDefs.forEach( function( colDef, index ){\n        if ( colDef.enableHiding !== false ){\n          // add hide menu item - shows an OK icon as we only show when column is already visible\n          var menuItem = {\n            icon: 'ui-grid-icon-ok',\n            action: function($event) {\n              $event.stopPropagation();\n              service.toggleColumnVisibility( this.context.gridCol );\n            },\n            shown: function() {\n              return this.context.gridCol.colDef.visible === true || this.context.gridCol.colDef.visible === undefined;\n            },\n            context: { gridCol: $scope.grid.getColumn(colDef.name || colDef.field) },\n            leaveOpen: true,\n            order: 301 + index * 2\n          };\n          service.setMenuItemTitle( menuItem, colDef, $scope.grid );\n          showHideColumns.push( menuItem );\n\n          // add show menu item - shows no icon as we only show when column is invisible\n          menuItem = {\n            icon: 'ui-grid-icon-cancel',\n            action: function($event) {\n              $event.stopPropagation();\n              service.toggleColumnVisibility( this.context.gridCol );\n            },\n            shown: function() {\n              return !(this.context.gridCol.colDef.visible === true || this.context.gridCol.colDef.visible === undefined);\n            },\n            context: { gridCol: $scope.grid.getColumn(colDef.name || colDef.field) },\n            leaveOpen: true,\n            order: 301 + index * 2 + 1\n          };\n          service.setMenuItemTitle( menuItem, colDef, $scope.grid );\n          showHideColumns.push( menuItem );\n        }\n      });\n      return showHideColumns;\n    },\n\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.gridMenuService\n     * @name setMenuItemTitle\n     * @description Handles the response from gridMenuTitleFilter, adding it directly to the menu\n     * item if it returns a string, otherwise waiting for the promise to resolve or reject then\n     * putting the result into the title\n     * @param {object} menuItem the menuItem we want to put the title on\n     * @param {object} colDef the colDef from which we can get displayName, name or field\n     * @param {Grid} grid the grid, from which we can get the options.gridMenuTitleFilter\n     *\n     */\n    setMenuItemTitle: function( menuItem, colDef, grid ){\n      var title = grid.options.gridMenuTitleFilter( colDef.displayName || gridUtil.readableColumnName(colDef.name) || colDef.field );\n\n      if ( typeof(title) === 'string' ){\n        menuItem.title = title;\n      } else if ( title.then ){\n        // must be a promise\n        menuItem.title = \"\";\n        title.then( function( successValue ) {\n          menuItem.title = successValue;\n        }, function( errorValue ) {\n          menuItem.title = errorValue;\n        });\n      } else {\n        gridUtil.logError('Expected gridMenuTitleFilter to return a string or a promise, it has returned neither, bad config');\n        menuItem.title = 'badconfig';\n      }\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.gridMenuService\n     * @name toggleColumnVisibility\n     * @description Toggles the visibility of an individual column.  Expects to be\n     * provided a context that has on it a gridColumn, which is the column that\n     * we'll operate upon.  We change the visibility, and refresh the grid as appropriate\n     * @param {GridCol} gridCol the column that we want to toggle\n     *\n     */\n    toggleColumnVisibility: function( gridCol ) {\n      gridCol.colDef.visible = !( gridCol.colDef.visible === true || gridCol.colDef.visible === undefined );\n\n      gridCol.grid.refresh();\n      gridCol.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );\n      gridCol.grid.api.core.raise.columnVisibilityChanged( gridCol );\n    }\n  };\n\n  return service;\n}])\n\n\n\n.directive('uiGridMenuButton', ['gridUtil', 'uiGridConstants', 'uiGridGridMenuService', 'i18nService',\nfunction (gridUtil, uiGridConstants, uiGridGridMenuService, i18nService) {\n\n  return {\n    priority: 0,\n    scope: true,\n    require: ['^uiGrid'],\n    templateUrl: 'ui-grid/ui-grid-menu-button',\n    replace: true,\n\n    link: function ($scope, $elm, $attrs, controllers) {\n      var uiGridCtrl = controllers[0];\n\n      // For the aria label\n      $scope.i18n = {\n        aria: i18nService.getSafeText('gridMenu.aria')\n      };\n\n      uiGridGridMenuService.initialize($scope, uiGridCtrl.grid);\n\n      $scope.shown = false;\n\n      $scope.toggleMenu = function () {\n        if ( $scope.shown ){\n          $scope.$broadcast('hide-menu');\n          $scope.shown = false;\n        } else {\n          $scope.menuItems = uiGridGridMenuService.getMenuItems( $scope );\n          $scope.$broadcast('show-menu');\n          $scope.shown = true;\n        }\n      };\n\n      $scope.$on('menu-hidden', function() {\n        $scope.shown = false;\n        gridUtil.focus.bySelector($elm, '.ui-grid-icon-container');\n      });\n    }\n  };\n\n}]);\n\n})();\n\n(function(){\n\n/**\n * @ngdoc directive\n * @name ui.grid.directive:uiGridMenu\n * @element style\n * @restrict A\n *\n * @description\n * Allows us to interpolate expressions in `<style>` elements. Angular doesn't do this by default as it can/will/might? break in IE8.\n *\n * @example\n <doc:example module=\"app\">\n <doc:source>\n <script>\n var app = angular.module('app', ['ui.grid']);\n\n app.controller('MainCtrl', ['$scope', function ($scope) {\n\n }]);\n </script>\n\n <div ng-controller=\"MainCtrl\">\n   <div ui-grid-menu shown=\"true\"  ></div>\n </div>\n </doc:source>\n <doc:scenario>\n </doc:scenario>\n </doc:example>\n */\nangular.module('ui.grid')\n\n.directive('uiGridMenu', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'i18nService',\nfunction ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18nService) {\n  var uiGridMenu = {\n    priority: 0,\n    scope: {\n      // shown: '&',\n      menuItems: '=',\n      autoHide: '=?'\n    },\n    require: '?^uiGrid',\n    templateUrl: 'ui-grid/uiGridMenu',\n    replace: false,\n    link: function ($scope, $elm, $attrs, uiGridCtrl) {\n      var gridMenuMaxHeight;\n\n      $scope.dynamicStyles = '';\n\n      if (uiGridCtrl) {\n        // magic number of 30 because the grid menu displays somewhat below\n        // the top of the grid. It is approximately 30px.\n        gridMenuMaxHeight = uiGridCtrl.grid.gridHeight - 30;\n        $scope.dynamicStyles = [\n          '.grid' + uiGridCtrl.grid.id + ' .ui-grid-menu-mid {',\n            'max-height: ' + gridMenuMaxHeight + 'px;',\n          '}'\n        ].join(' ');\n      }\n\n      $scope.i18n = {\n        close: i18nService.getSafeText('columnMenu.close')\n      };\n\n    // *** Show/Hide functions ******\n      $scope.showMenu = function(event, args) {\n        if ( !$scope.shown ){\n\n          /*\n           * In order to animate cleanly we remove the ng-if, wait a digest cycle, then\n           * animate the removal of the ng-hide.  We can't successfully (so far as I can tell)\n           * animate removal of the ng-if, as the menu items aren't there yet.  And we don't want\n           * to rely on ng-show only, as that leaves elements in the DOM that are needlessly evaluated\n           * on scroll events.\n           *\n           * Note when testing animation that animations don't run on the tutorials.  When debugging it looks\n           * like they do, but angular has a default $animate provider that is just a stub, and that's what's\n           * being called.  ALso don't be fooled by the fact that your browser has actually loaded the\n           * angular-translate.js, it's not using it.  You need to test animations in an external application.\n           */\n          $scope.shown = true;\n\n          $timeout( function() {\n            $scope.shownMid = true;\n            $scope.$emit('menu-shown');\n          });\n        } else if ( !$scope.shownMid ) {\n          // we're probably doing a hide then show, so we don't need to wait for ng-if\n          $scope.shownMid = true;\n          $scope.$emit('menu-shown');\n        }\n\n        var docEventType = 'click';\n        if (args && args.originalEvent && args.originalEvent.type && args.originalEvent.type === 'touchstart') {\n          docEventType = args.originalEvent.type;\n        }\n\n        // Turn off an existing document click handler\n        angular.element(document).off('click touchstart', applyHideMenu);\n        $elm.off('keyup', checkKeyUp);\n        $elm.off('keydown', checkKeyDown);\n\n        // Turn on the document click handler, but in a timeout so it doesn't apply to THIS click if there is one\n        $timeout(function() {\n          angular.element(document).on(docEventType, applyHideMenu);\n          $elm.on('keyup', checkKeyUp);\n          $elm.on('keydown', checkKeyDown);\n\n        });\n        //automatically set the focus to the first button element in the now open menu.\n        gridUtil.focus.bySelector($elm, 'button[type=button]', true);\n      };\n\n\n      $scope.hideMenu = function(event) {\n        if ( $scope.shown ){\n          /*\n           * In order to animate cleanly we animate the addition of ng-hide, then use a $timeout to\n           * set the ng-if (shown = false) after the animation runs.  In theory we can cascade off the\n           * callback on the addClass method, but it is very unreliable with unit tests for no discernable reason.\n           *\n           * The user may have clicked on the menu again whilst\n           * we're waiting, so we check that the mid isn't shown before applying the ng-if.\n           */\n          $scope.shownMid = false;\n          $timeout( function() {\n            if ( !$scope.shownMid ){\n              $scope.shown = false;\n              $scope.$emit('menu-hidden');\n            }\n          }, 200);\n        }\n\n        angular.element(document).off('click touchstart', applyHideMenu);\n        $elm.off('keyup', checkKeyUp);\n        $elm.off('keydown', checkKeyDown);\n      };\n\n      $scope.$on('hide-menu', function (event, args) {\n        $scope.hideMenu(event, args);\n      });\n\n      $scope.$on('show-menu', function (event, args) {\n        $scope.showMenu(event, args);\n      });\n\n\n    // *** Auto hide when click elsewhere ******\n      var applyHideMenu = function(){\n        if ($scope.shown) {\n          $scope.$apply(function () {\n            $scope.hideMenu();\n          });\n        }\n      };\n\n      // close menu on ESC and keep tab cyclical\n      var checkKeyUp = function(event) {\n        if (event.keyCode === 27) {\n          $scope.hideMenu();\n        }\n      };\n\n      var checkKeyDown = function(event) {\n        var setFocus = function(elm) {\n          elm.focus();\n          event.preventDefault();\n          return false;\n        };\n        if (event.keyCode === 9) {\n          var firstMenuItem, lastMenuItem;\n          var menuItemButtons = $elm[0].querySelectorAll('button:not(.ng-hide)');\n          if (menuItemButtons.length > 0) {\n            firstMenuItem = menuItemButtons[0];\n            lastMenuItem = menuItemButtons[menuItemButtons.length - 1];\n            if (event.target === lastMenuItem && !event.shiftKey) {\n              setFocus(firstMenuItem);\n            } else if (event.target === firstMenuItem && event.shiftKey) {\n              setFocus(lastMenuItem);\n            }\n          }\n        }\n      };\n\n      if (typeof($scope.autoHide) === 'undefined' || $scope.autoHide === undefined) {\n        $scope.autoHide = true;\n      }\n\n      if ($scope.autoHide) {\n        angular.element($window).on('resize', applyHideMenu);\n      }\n\n      $scope.$on('$destroy', function () {\n        angular.element(document).off('click touchstart', applyHideMenu);\n      });\n\n\n      $scope.$on('$destroy', function() {\n        angular.element($window).off('resize', applyHideMenu);\n      });\n\n      if (uiGridCtrl) {\n       $scope.$on('$destroy', uiGridCtrl.grid.api.core.on.scrollBegin($scope, applyHideMenu ));\n      }\n\n      $scope.$on('$destroy', $scope.$on(uiGridConstants.events.ITEM_DRAGGING, applyHideMenu ));\n    }\n  };\n\n  return uiGridMenu;\n}])\n\n.directive('uiGridMenuItem', ['gridUtil', '$compile', 'i18nService', function (gridUtil, $compile, i18nService) {\n  var uiGridMenuItem = {\n    priority: 0,\n    scope: {\n      name: '=',\n      active: '=',\n      action: '=',\n      icon: '=',\n      shown: '=',\n      context: '=',\n      templateUrl: '=',\n      leaveOpen: '=',\n      screenReaderOnly: '='\n    },\n    require: ['?^uiGrid'],\n    templateUrl: 'ui-grid/uiGridMenuItem',\n    replace: false,\n    compile: function() {\n      return {\n        pre: function ($scope, $elm) {\n          if ($scope.templateUrl) {\n            gridUtil.getTemplate($scope.templateUrl)\n                .then(function (contents) {\n                  var template = angular.element(contents);\n\n                  var newElm = $compile(template)($scope);\n                  $elm.replaceWith(newElm);\n                });\n          }\n        },\n        post: function ($scope, $elm, $attrs, controllers) {\n          var uiGridCtrl = controllers[0];\n\n          // TODO(c0bra): validate that shown and active are functions if they're defined. An exception is already thrown above this though\n          // if (typeof($scope.shown) !== 'undefined' && $scope.shown && typeof($scope.shown) !== 'function') {\n          //   throw new TypeError(\"$scope.shown is defined but not a function\");\n          // }\n          if (typeof($scope.shown) === 'undefined' || $scope.shown === null) {\n            $scope.shown = function() { return true; };\n          }\n\n          $scope.itemShown = function () {\n            var context = {};\n            if ($scope.context) {\n              context.context = $scope.context;\n            }\n\n            if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) {\n              context.grid = uiGridCtrl.grid;\n            }\n\n            return $scope.shown.call(context);\n          };\n\n          $scope.itemAction = function($event,title) {\n            gridUtil.logDebug('itemAction');\n            $event.stopPropagation();\n\n            if (typeof($scope.action) === 'function') {\n              var context = {};\n\n              if ($scope.context) {\n                context.context = $scope.context;\n              }\n\n              // Add the grid to the function call context if the uiGrid controller is present\n              if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) {\n                context.grid = uiGridCtrl.grid;\n              }\n\n              $scope.action.call(context, $event, title);\n\n              if ( !$scope.leaveOpen ){\n                $scope.$emit('hide-menu');\n              } else {\n                /*\n                 * XXX: Fix after column refactor\n                 * Ideally the focus would remain on the item.\n                 * However, since there are two menu items that have their 'show' property toggled instead. This is a quick fix.\n                 */\n                gridUtil.focus.bySelector(angular.element(gridUtil.closestElm($elm, \".ui-grid-menu-items\")), 'button[type=button]', true);\n              }\n            }\n          };\n\n          $scope.i18n = i18nService.get();\n        }\n      };\n    }\n  };\n\n  return uiGridMenuItem;\n}]);\n\n})();\n\n(function(){\n  'use strict';\n  /**\n   * @ngdoc overview\n   * @name ui.grid.directive:uiGridOneBind\n   * @summary A group of directives that provide a one time bind to a dom element.\n   * @description A group of directives that provide a one time bind to a dom element.\n   * As one time bindings are not supported in Angular 1.2.* this directive provdes this capability.\n   * This is done to reduce the number of watchers on the dom.\n   * <br/>\n   * <h2>Short Example ({@link ui.grid.directive:uiGridOneBindSrc ui-grid-one-bind-src})</h2>\n   * <pre>\n        <div ng-init=\"imageName = 'myImageDir.jpg'\">\n          <img ui-grid-one-bind-src=\"imageName\"></img>\n        </div>\n     </pre>\n   * Will become:\n   * <pre>\n       <div ng-init=\"imageName = 'myImageDir.jpg'\">\n         <img ui-grid-one-bind-src=\"imageName\" src=\"myImageDir.jpg\"></img>\n       </div>\n     </pre>\n     </br>\n     <h2>Short Example ({@link ui.grid.directive:uiGridOneBindText ui-grid-one-bind-text})</h2>\n   * <pre>\n        <div ng-init=\"text='Add this text'\" ui-grid-one-bind-text=\"text\"></div>\n     </pre>\n   * Will become:\n   * <pre>\n   <div ng-init=\"text='Add this text'\" ui-grid-one-bind-text=\"text\">Add this text</div>\n     </pre>\n     </br>\n   * <b>Note:</b> This behavior is slightly different for the {@link ui.grid.directive:uiGridOneBindIdGrid uiGridOneBindIdGrid}\n   * and {@link ui.grid.directive:uiGridOneBindAriaLabelledbyGrid uiGridOneBindAriaLabelledbyGrid} directives.\n   *\n   */\n  //https://github.com/joshkurz/Black-Belt-AngularJS-Directives/blob/master/directives/Optimization/oneBind.js\n  var oneBinders = angular.module('ui.grid');\n  angular.forEach([\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindSrc\n       * @memberof ui.grid.directive:uiGridOneBind\n       * @element img\n       * @restrict A\n       * @param {String} uiGridOneBindSrc The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the src dom tag.\n       *\n       */\n      {tag: 'Src', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindText\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindText The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the text dom tag.\n       */\n      {tag: 'Text', method: 'text'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindHref\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindHref The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the href dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Href', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindClass\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindClass The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @param {Object} uiGridOneBindClass The object that you want to bind. At least one of the values in the object must be something other than null or undefined for the watcher to be removed.\n       *                                    this is to prevent the watcher from being removed before the scope is initialized.\n       * @param {Array} uiGridOneBindClass An array of classes to bind to this element.\n       * @description One time binding for the class dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Class', method: 'addClass'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindHtml\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindHtml The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the html method on a dom element. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Html', method: 'html'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAlt\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindAlt The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the alt dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Alt', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindStyle\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindStyle The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the style dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Style', method: 'css'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindValue\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindValue The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Value', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindId\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindId The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Id', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindIdGrid\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindIdGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the id dom tag.\n       * <h1>Important Note!</h1>\n       * If the id tag passed as a parameter does <b>not</b> contain the grid id as a substring\n       * then the directive will search the scope and the parent controller (if it is a uiGridController) for the grid.id value.\n       * If this value is found then it is appended to the begining of the id tag. If the grid is not found then the directive throws an error.\n       * This is done in order to ensure uniqueness of id tags across the grid.\n       * This is to prevent two grids in the same document having duplicate id tags.\n       */\n      {tag: 'Id', directiveName:'IdGrid', method: 'attr', appendGridId: true},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindTitle\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindTitle The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the title dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       */\n      {tag: 'Title', method: 'attr'},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAriaLabel\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindAriaLabel The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the aria-label dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       *<br/>\n       * <pre>\n            <div ng-init=\"text='Add this text'\" ui-grid-one-bind-aria-label=\"text\"></div>\n         </pre>\n       * Will become:\n       * <pre>\n            <div ng-init=\"text='Add this text'\" ui-grid-one-bind-aria-label=\"text\" aria-label=\"Add this text\"></div>\n         </pre>\n       */\n      {tag: 'Label', method: 'attr', aria:true},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAriaLabelledby\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindAriaLabelledby The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       *<br/>\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-labelledby=\"anId\"></div>\n         </pre>\n       * Will become:\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-labelledby=\"anId\" aria-labelledby=\"gridID32\"></div>\n         </pre>\n       */\n      {tag: 'Labelledby', method: 'attr', aria:true},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAriaLabelledbyGrid\n       * @element div\n       * @restrict A\n       * @param {String} uiGridOneBindAriaLabelledbyGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the\n       * grid id to each one.\n       *<br/>\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-labelledby-grid=\"anId\"></div>\n         </pre>\n       * Will become ([grid.id] will be replaced by the actual grid id):\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-labelledby-grid=\"anId\" aria-labelledby-Grid=\"[grid.id]-gridID32\"></div>\n         </pre>\n       */\n      {tag: 'Labelledby', directiveName:'LabelledbyGrid', appendGridId:true, method: 'attr', aria:true},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAriaDescribedby\n       * @element ANY\n       * @restrict A\n       * @param {String} uiGridOneBindAriaDescribedby The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the aria-describedby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       *<br/>\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-describedby=\"anId\"></div>\n         </pre>\n       * Will become:\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-describedby=\"anId\" aria-describedby=\"gridID32\"></div>\n         </pre>\n       */\n      {tag: 'Describedby', method: 'attr', aria:true},\n      /**\n       * @ngdoc directive\n       * @name ui.grid.directive:uiGridOneBindAriaDescribedbyGrid\n       * @element ANY\n       * @restrict A\n       * @param {String} uiGridOneBindAriaDescribedbyGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.\n       * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.\n       * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the\n       * grid id to each one.\n       *<br/>\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-describedby-grid=\"anId\"></div>\n         </pre>\n       * Will become ([grid.id] will be replaced by the actual grid id):\n       * <pre>\n            <div ng-init=\"anId = 'gridID32'\" ui-grid-one-bind-aria-describedby-grid=\"anId\" aria-describedby=\"[grid.id]-gridID32\"></div>\n         </pre>\n       */\n      {tag: 'Describedby', directiveName:'DescribedbyGrid', appendGridId:true, method: 'attr', aria:true}],\n    function(v){\n\n      var baseDirectiveName = 'uiGridOneBind';\n      //If it is an aria tag then append the aria label seperately\n      //This is done because the aria tags are formatted aria-* and the directive name can't have a '-' character in it.\n      //If the diretiveName has to be overridden then it does so here. This is because the tag being modified and the directive sometimes don't match up.\n      var directiveName = (v.aria ? baseDirectiveName + 'Aria' : baseDirectiveName) + (v.directiveName ? v.directiveName : v.tag);\n      oneBinders.directive(directiveName, ['gridUtil', function(gridUtil){\n        return {\n          restrict: 'A',\n          require: ['?uiGrid','?^uiGrid'],\n          link: function(scope, iElement, iAttrs, controllers){\n            /* Appends the grid id to the beginnig of the value. */\n            var appendGridId = function(val){\n              var grid; //Get an instance of the grid if its available\n              //If its available in the scope then we don't need to try to find it elsewhere\n              if (scope.grid) {\n                grid = scope.grid;\n              }\n              //Another possible location to try to find the grid\n              else if (scope.col && scope.col.grid){\n                grid = scope.col.grid;\n              }\n              //Last ditch effort: Search through the provided controllers.\n              else if (!controllers.some( //Go through the controllers till one has the element we need\n                function(controller){\n                  if (controller && controller.grid) {\n                    grid = controller.grid;\n                    return true; //We've found the grid\n                  }\n              })){\n                //We tried our best to find it for you\n                gridUtil.logError(\"[\"+directiveName+\"] A valid grid could not be found to bind id. Are you using this directive \" +\n                                 \"within the correct scope? Trying to generate id: [gridID]-\" + val);\n                throw new Error(\"No valid grid could be found\");\n              }\n\n              if (grid){\n                var idRegex = new RegExp(grid.id.toString());\n                //If the grid id hasn't been appended already in the template declaration\n                if (!idRegex.test(val)){\n                  val = grid.id.toString() + '-' + val;\n                }\n              }\n              return val;\n            };\n\n            // The watch returns a function to remove itself.\n            var rmWatcher = scope.$watch(iAttrs[directiveName], function(newV){\n              if (newV){\n                //If we are trying to add an id element then we also apply the grid id if it isn't already there\n                if (v.appendGridId) {\n                  var newIdString = null;\n                  //Append the id to all of the new ids.\n                  angular.forEach( newV.split(' '), function(s){\n                    newIdString = (newIdString ? (newIdString + ' ') : '') +  appendGridId(s);\n                  });\n                  newV = newIdString;\n                }\n\n                // Append this newValue to the dom element.\n                switch (v.method) {\n                  case 'attr': //The attr method takes two paraams the tag and the value\n                    if (v.aria) {\n                      //If it is an aria element then append the aria prefix\n                      iElement[v.method]('aria-' + v.tag.toLowerCase(),newV);\n                    } else {\n                      iElement[v.method](v.tag.toLowerCase(),newV);\n                    }\n                    break;\n                  case 'addClass':\n                    //Pulled from https://github.com/Pasvaz/bindonce/blob/master/bindonce.js\n                    if (angular.isObject(newV) && !angular.isArray(newV)) {\n                      var results = [];\n                      var nonNullFound = false; //We don't want to remove the binding unless the key is actually defined\n                      angular.forEach(newV, function (value, index) {\n                        if (value !== null && typeof(value) !== \"undefined\"){\n                          nonNullFound = true; //A non null value for a key was found so the object must have been initialized\n                          if (value) {results.push(index);}\n                        }\n                      });\n                      //A non null value for a key wasn't found so assume that the scope values haven't been fully initialized\n                      if (!nonNullFound){\n                        return; // If not initialized then the watcher should not be removed yet.\n                      }\n                      newV = results;\n                    }\n\n                    if (newV) {\n                      iElement.addClass(angular.isArray(newV) ? newV.join(' ') : newV);\n                    } else {\n                      return;\n                    }\n                    break;\n                  default:\n                    iElement[v.method](newV);\n                    break;\n                }\n\n                //Removes the watcher on itself after the bind\n                rmWatcher();\n              }\n            // True ensures that equality is determined using angular.equals instead of ===\n            }, true); //End rm watchers\n          } //End compile function\n        }; //End directive return\n      } // End directive function\n    ]); //End directive\n  }); // End angular foreach\n})();\n\n(function () {\n  'use strict';\n\n  var module = angular.module('ui.grid');\n\n  module.directive('uiGridRenderContainer', ['$timeout', '$document', 'uiGridConstants', 'gridUtil', 'ScrollEvent',\n    function($timeout, $document, uiGridConstants, gridUtil, ScrollEvent) {\n    return {\n      replace: true,\n      transclude: true,\n      templateUrl: 'ui-grid/uiGridRenderContainer',\n      require: ['^uiGrid', 'uiGridRenderContainer'],\n      scope: {\n        containerId: '=',\n        rowContainerName: '=',\n        colContainerName: '=',\n        bindScrollHorizontal: '=',\n        bindScrollVertical: '=',\n        enableVerticalScrollbar: '=',\n        enableHorizontalScrollbar: '='\n      },\n      controller: 'uiGridRenderContainer as RenderContainer',\n      compile: function () {\n        return {\n          pre: function prelink($scope, $elm, $attrs, controllers) {\n\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n            var grid = $scope.grid = uiGridCtrl.grid;\n\n            // Verify that the render container for this element exists\n            if (!$scope.rowContainerName) {\n              throw \"No row render container name specified\";\n            }\n            if (!$scope.colContainerName) {\n              throw \"No column render container name specified\";\n            }\n\n            if (!grid.renderContainers[$scope.rowContainerName]) {\n              throw \"Row render container '\" + $scope.rowContainerName + \"' is not registered.\";\n            }\n            if (!grid.renderContainers[$scope.colContainerName]) {\n              throw \"Column render container '\" + $scope.colContainerName + \"' is not registered.\";\n            }\n\n            var rowContainer = $scope.rowContainer = grid.renderContainers[$scope.rowContainerName];\n            var colContainer = $scope.colContainer = grid.renderContainers[$scope.colContainerName];\n\n            containerCtrl.containerId = $scope.containerId;\n            containerCtrl.rowContainer = rowContainer;\n            containerCtrl.colContainer = colContainer;\n          },\n          post: function postlink($scope, $elm, $attrs, controllers) {\n\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            var grid = uiGridCtrl.grid;\n            var rowContainer = containerCtrl.rowContainer;\n            var colContainer = containerCtrl.colContainer;\n            var scrollTop = null;\n            var scrollLeft = null;\n\n\n            var renderContainer = grid.renderContainers[$scope.containerId];\n\n            // Put the container name on this element as a class\n            $elm.addClass('ui-grid-render-container-' + $scope.containerId);\n\n            // Scroll the render container viewport when the mousewheel is used\n            gridUtil.on.mousewheel($elm, function (event) {\n              var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.RenderContainerMouseWheel);\n              if (event.deltaY !== 0) {\n                var scrollYAmount = event.deltaY * -1 * event.deltaFactor;\n\n                scrollTop = containerCtrl.viewport[0].scrollTop;\n\n                // Get the scroll percentage\n                scrollEvent.verticalScrollLength = rowContainer.getVerticalScrollLength();\n                var scrollYPercentage = (scrollTop + scrollYAmount) / scrollEvent.verticalScrollLength;\n\n                // If we should be scrolled 100%, make sure the scrollTop matches the maximum scroll length\n                //   Viewports that have \"overflow: hidden\" don't let the mousewheel scroll all the way to the bottom without this check\n                if (scrollYPercentage >= 1 && scrollTop < scrollEvent.verticalScrollLength) {\n                  containerCtrl.viewport[0].scrollTop = scrollEvent.verticalScrollLength;\n                }\n\n                // Keep scrollPercentage within the range 0-1.\n                if (scrollYPercentage < 0) { scrollYPercentage = 0; }\n                else if (scrollYPercentage > 1) { scrollYPercentage = 1; }\n\n                scrollEvent.y = { percentage: scrollYPercentage, pixels: scrollYAmount };\n              }\n              if (event.deltaX !== 0) {\n                var scrollXAmount = event.deltaX * event.deltaFactor;\n\n                // Get the scroll percentage\n                scrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.viewport, grid);\n                scrollEvent.horizontalScrollLength = (colContainer.getCanvasWidth() - colContainer.getViewportWidth());\n                var scrollXPercentage = (scrollLeft + scrollXAmount) / scrollEvent.horizontalScrollLength;\n\n                // Keep scrollPercentage within the range 0-1.\n                if (scrollXPercentage < 0) { scrollXPercentage = 0; }\n                else if (scrollXPercentage > 1) { scrollXPercentage = 1; }\n\n                scrollEvent.x = { percentage: scrollXPercentage, pixels: scrollXAmount };\n              }\n\n              // Let the parent container scroll if the grid is already at the top/bottom\n              if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||\n                  (event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) {\n                //parent controller scrolls\n              }\n              else {\n                event.preventDefault();\n                event.stopPropagation();\n                scrollEvent.fireThrottledScrollingEvent('', scrollEvent);\n              }\n\n            });\n\n            $elm.bind('$destroy', function() {\n              $elm.unbind('keydown');\n\n              ['touchstart', 'touchmove', 'touchend','keydown', 'wheel', 'mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'].forEach(function (eventName) {\n                $elm.unbind(eventName);\n              });\n            });\n\n            // TODO(c0bra): Handle resizing the inner canvas based on the number of elements\n            function update() {\n              var ret = '';\n\n              var canvasWidth = colContainer.canvasWidth;\n              var viewportWidth = colContainer.getViewportWidth();\n\n              var canvasHeight = rowContainer.getCanvasHeight();\n\n              //add additional height for scrollbar on left and right container\n              //if ($scope.containerId !== 'body') {\n              //  canvasHeight -= grid.scrollbarHeight;\n              //}\n\n              var viewportHeight = rowContainer.getViewportHeight();\n              //shorten the height to make room for a scrollbar placeholder\n              if (colContainer.needsHScrollbarPlaceholder()) {\n                viewportHeight -= grid.scrollbarHeight;\n              }\n\n              var headerViewportWidth,\n                  footerViewportWidth;\n              headerViewportWidth = footerViewportWidth = colContainer.getHeaderViewportWidth();\n\n              // Set canvas dimensions\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-canvas { width: ' + canvasWidth + 'px; height: ' + canvasHeight + 'px; }';\n\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }';\n\n              if (renderContainer.explicitHeaderCanvasHeight) {\n                ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: ' + renderContainer.explicitHeaderCanvasHeight + 'px; }';\n              }\n              else {\n                ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: inherit; }';\n              }\n\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-viewport { width: ' + viewportWidth + 'px; height: ' + viewportHeight + 'px; }';\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-viewport { width: ' + headerViewportWidth + 'px; }';\n\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-footer-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }';\n              ret += '\\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-footer-viewport { width: ' + footerViewportWidth + 'px; }';\n\n              return ret;\n            }\n\n            uiGridCtrl.grid.registerStyleComputation({\n              priority: 6,\n              func: update\n            });\n          }\n        };\n      }\n    };\n\n  }]);\n\n  module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) {\n\n  }]);\n\n})();\n\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridRow', ['gridUtil', function(gridUtil) {\n    return {\n      replace: true,\n      // priority: 2001,\n      // templateUrl: 'ui-grid/ui-grid-row',\n      require: ['^uiGrid', '^uiGridRenderContainer'],\n      scope: {\n         row: '=uiGridRow',\n         //rowRenderIndex is added to scope to give the true visual index of the row to any directives that need it\n         rowRenderIndex: '='\n      },\n      compile: function() {\n        return {\n          pre: function($scope, $elm, $attrs, controllers) {\n            var uiGridCtrl = controllers[0];\n            var containerCtrl = controllers[1];\n\n            var grid = uiGridCtrl.grid;\n\n            $scope.grid = uiGridCtrl.grid;\n            $scope.colContainer = containerCtrl.colContainer;\n\n            // Function for attaching the template to this scope\n            var clonedElement, cloneScope;\n            function compileTemplate() {\n              $scope.row.getRowTemplateFn.then(function (compiledElementFn) {\n                // var compiledElementFn = $scope.row.compiledElementFn;\n\n                // Create a new scope for the contents of this row, so we can destroy it later if need be\n                var newScope = $scope.$new();\n\n                compiledElementFn(newScope, function (newElm, scope) {\n                  // If we already have a cloned element, we need to remove it and destroy its scope\n                  if (clonedElement) {\n                    clonedElement.remove();\n                    cloneScope.$destroy();\n                  }\n\n                  // Empty the row and append the new element\n                  $elm.empty().append(newElm);\n\n                  // Save the new cloned element and scope\n                  clonedElement = newElm;\n                  cloneScope = newScope;\n                });\n              });\n            }\n\n            // Initially attach the compiled template to this scope\n            compileTemplate();\n\n            // If the row's compiled element function changes, we need to replace this element's contents with the new compiled template\n            $scope.$watch('row.getRowTemplateFn', function (newFunc, oldFunc) {\n              if (newFunc !== oldFunc) {\n                compileTemplate();\n              }\n            });\n          },\n          post: function($scope, $elm, $attrs, controllers) {\n\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n(function(){\n// 'use strict';\n\n  /**\n   * @ngdoc directive\n   * @name ui.grid.directive:uiGridStyle\n   * @element style\n   * @restrict A\n   *\n   * @description\n   * Allows us to interpolate expressions in `<style>` elements. Angular doesn't do this by default as it can/will/might? break in IE8.\n   *\n   * @example\n   <doc:example module=\"app\">\n   <doc:source>\n   <script>\n   var app = angular.module('app', ['ui.grid']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n          $scope.myStyle = '.blah { border: 1px solid }';\n        }]);\n   </script>\n\n   <div ng-controller=\"MainCtrl\">\n   <style ui-grid-style>{{ myStyle }}</style>\n   <span class=\"blah\">I am in a box.</span>\n   </div>\n   </doc:source>\n   <doc:scenario>\n      it('should apply the right class to the element', function () {\n        element(by.css('.blah')).getCssValue('border-top-width')\n          .then(function(c) {\n            expect(c).toContain('1px');\n          });\n      });\n   </doc:scenario>\n   </doc:example>\n   */\n\n\n  angular.module('ui.grid').directive('uiGridStyle', ['gridUtil', '$interpolate', function(gridUtil, $interpolate) {\n    return {\n      // restrict: 'A',\n      // priority: 1000,\n      // require: '?^uiGrid',\n      link: function($scope, $elm, $attrs, uiGridCtrl) {\n        // gridUtil.logDebug('ui-grid-style link');\n        // if (uiGridCtrl === undefined) {\n        //    gridUtil.logWarn('[ui-grid-style link] uiGridCtrl is undefined!');\n        // }\n\n        var interpolateFn = $interpolate($elm.text(), true);\n\n        if (interpolateFn) {\n          $scope.$watch(interpolateFn, function(value) {\n            $elm.text(value);\n          });\n        }\n\n          // uiGridCtrl.recalcRowStyles = function() {\n          //   var offset = (scope.options.offsetTop || 0) - (scope.options.excessRows * scope.options.rowHeight);\n          //   var rowHeight = scope.options.rowHeight;\n\n          //   var ret = '';\n          //   var rowStyleCount = uiGridCtrl.minRowsToRender() + (scope.options.excessRows * 2);\n          //   for (var i = 1; i <= rowStyleCount; i++) {\n          //     ret = ret + ' .grid' + scope.gridId + ' .ui-grid-row:nth-child(' + i + ') { top: ' + offset + 'px; }';\n          //     offset = offset + rowHeight;\n          //   }\n\n          //   scope.rowStyles = ret;\n          // };\n\n          // uiGridCtrl.styleComputions.push(uiGridCtrl.recalcRowStyles);\n\n      }\n    };\n  }]);\n\n})();\n\n(function(){\n  'use strict';\n\n  angular.module('ui.grid').directive('uiGridViewport', ['gridUtil','ScrollEvent','uiGridConstants', '$log',\n    function(gridUtil, ScrollEvent, uiGridConstants, $log) {\n      return {\n        replace: true,\n        scope: {},\n        controllerAs: 'Viewport',\n        templateUrl: 'ui-grid/uiGridViewport',\n        require: ['^uiGrid', '^uiGridRenderContainer'],\n        link: function($scope, $elm, $attrs, controllers) {\n          // gridUtil.logDebug('viewport post-link');\n\n          var uiGridCtrl = controllers[0];\n          var containerCtrl = controllers[1];\n\n          $scope.containerCtrl = containerCtrl;\n\n          var rowContainer = containerCtrl.rowContainer;\n          var colContainer = containerCtrl.colContainer;\n\n          var grid = uiGridCtrl.grid;\n\n          $scope.grid = uiGridCtrl.grid;\n\n          // Put the containers in scope so we can get rows and columns from them\n          $scope.rowContainer = containerCtrl.rowContainer;\n          $scope.colContainer = containerCtrl.colContainer;\n\n          // Register this viewport with its container\n          containerCtrl.viewport = $elm;\n\n\n          $elm.on('scroll', scrollHandler);\n\n          var ignoreScroll = false;\n\n          function scrollHandler(evt) {\n            //Leaving in this commented code in case it can someday be used\n            //It does improve performance, but because the horizontal scroll is normalized,\n            //  using this code will lead to the column header getting slightly out of line with columns\n            //\n            //if (ignoreScroll && (grid.isScrollingHorizontally || grid.isScrollingHorizontally)) {\n            //  //don't ask for scrollTop if we just set it\n            //  ignoreScroll = false;\n            //  return;\n            //}\n            //ignoreScroll = true;\n\n            var newScrollTop = $elm[0].scrollTop;\n            var newScrollLeft = gridUtil.normalizeScrollLeft($elm, grid);\n\n            var vertScrollPercentage = rowContainer.scrollVertical(newScrollTop);\n            var horizScrollPercentage = colContainer.scrollHorizontal(newScrollLeft);\n\n            var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.ViewPortScroll);\n            scrollEvent.newScrollLeft = newScrollLeft;\n            scrollEvent.newScrollTop = newScrollTop;\n            if ( horizScrollPercentage > -1 ){\n              scrollEvent.x = { percentage: horizScrollPercentage };\n            }\n\n            if ( vertScrollPercentage > -1 ){\n              scrollEvent.y = { percentage: vertScrollPercentage };\n            }\n\n            grid.scrollContainers($scope.$parent.containerId, scrollEvent);\n          }\n\n          if ($scope.$parent.bindScrollVertical) {\n            grid.addVerticalScrollSync($scope.$parent.containerId, syncVerticalScroll);\n          }\n\n          if ($scope.$parent.bindScrollHorizontal) {\n            grid.addHorizontalScrollSync($scope.$parent.containerId, syncHorizontalScroll);\n            grid.addHorizontalScrollSync($scope.$parent.containerId + 'header', syncHorizontalHeader);\n            grid.addHorizontalScrollSync($scope.$parent.containerId + 'footer', syncHorizontalFooter);\n          }\n\n          function syncVerticalScroll(scrollEvent){\n            containerCtrl.prevScrollArgs = scrollEvent;\n            var newScrollTop = scrollEvent.getNewScrollTop(rowContainer,containerCtrl.viewport);\n            $elm[0].scrollTop = newScrollTop;\n\n          }\n\n          function syncHorizontalScroll(scrollEvent){\n            containerCtrl.prevScrollArgs = scrollEvent;\n            var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);\n            $elm[0].scrollLeft =  gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);\n          }\n\n          function syncHorizontalHeader(scrollEvent){\n            var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);\n            if (containerCtrl.headerViewport) {\n              containerCtrl.headerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);\n            }\n          }\n\n          function syncHorizontalFooter(scrollEvent){\n            var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);\n            if (containerCtrl.footerViewport) {\n              containerCtrl.footerViewport.scrollLeft =  gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);\n            }\n          }\n\n\n        },\n        controller: ['$scope', function ($scope) {\n          this.rowStyle = function (index) {\n            var rowContainer = $scope.rowContainer;\n            var colContainer = $scope.colContainer;\n\n            var styles = {};\n\n            if (index === 0 && rowContainer.currentTopRow !== 0) {\n              // The row offset-top is just the height of the rows above the current top-most row, which are no longer rendered\n              var hiddenRowWidth = (rowContainer.currentTopRow) * rowContainer.grid.options.rowHeight;\n\n              // return { 'margin-top': hiddenRowWidth + 'px' };\n              styles['margin-top'] = hiddenRowWidth + 'px';\n            }\n\n            if (colContainer.currentFirstColumn !== 0) {\n              if (colContainer.grid.isRTL()) {\n                styles['margin-right'] = colContainer.columnOffset + 'px';\n              }\n              else {\n                styles['margin-left'] = colContainer.columnOffset + 'px';\n              }\n            }\n\n            return styles;\n          };\n        }]\n      };\n    }\n  ]);\n\n})();\n\n(function() {\n\nangular.module('ui.grid')\n.directive('uiGridVisible', function uiGridVisibleAction() {\n  return function ($scope, $elm, $attr) {\n    $scope.$watch($attr.uiGridVisible, function (visible) {\n        // $elm.css('visibility', visible ? 'visible' : 'hidden');\n        $elm[visible ? 'removeClass' : 'addClass']('ui-grid-invisible');\n    });\n  };\n});\n\n})();\n(function () {\n  'use strict';\n\n  angular.module('ui.grid').controller('uiGridController', ['$scope', '$element', '$attrs', 'gridUtil', '$q', 'uiGridConstants',\n                    '$templateCache', 'gridClassFactory', '$timeout', '$parse', '$compile',\n    function ($scope, $elm, $attrs, gridUtil, $q, uiGridConstants,\n              $templateCache, gridClassFactory, $timeout, $parse, $compile) {\n      // gridUtil.logDebug('ui-grid controller');\n\n      var self = this;\n\n      self.grid = gridClassFactory.createGrid($scope.uiGrid);\n\n      //assign $scope.$parent if appScope not already assigned\n      self.grid.appScope = self.grid.appScope || $scope.$parent;\n\n      $elm.addClass('grid' + self.grid.id);\n      self.grid.rtl = gridUtil.getStyles($elm[0])['direction'] === 'rtl';\n\n\n      // angular.extend(self.grid.options, );\n\n      //all properties of grid are available on scope\n      $scope.grid = self.grid;\n\n      if ($attrs.uiGridColumns) {\n        $attrs.$observe('uiGridColumns', function(value) {\n          self.grid.options.columnDefs = value;\n          self.grid.buildColumns()\n            .then(function(){\n              self.grid.preCompileCellTemplates();\n\n              self.grid.refreshCanvas(true);\n            });\n        });\n      }\n\n\n      // if fastWatch is set we watch only the length and the reference, not every individual object\n      var deregFunctions = [];\n      if (self.grid.options.fastWatch) {\n        self.uiGrid = $scope.uiGrid;\n        if (angular.isString($scope.uiGrid.data)) {\n          deregFunctions.push( $scope.$parent.$watch($scope.uiGrid.data, dataWatchFunction) );\n          deregFunctions.push( $scope.$parent.$watch(function() {\n            if ( self.grid.appScope[$scope.uiGrid.data] ){\n              return self.grid.appScope[$scope.uiGrid.data].length;\n            } else {\n              return undefined;\n            }\n          }, dataWatchFunction) );\n        } else {\n          deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.data; }, dataWatchFunction) );\n          deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.data.length; }, function(){ dataWatchFunction($scope.uiGrid.data); }) );\n        }\n        deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) );\n        deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.columnDefs.length; }, function(){ columnDefsWatchFunction($scope.uiGrid.columnDefs); }) );\n      } else {\n        if (angular.isString($scope.uiGrid.data)) {\n          deregFunctions.push( $scope.$parent.$watchCollection($scope.uiGrid.data, dataWatchFunction) );\n        } else {\n          deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.data; }, dataWatchFunction) );\n        }\n        deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) );\n      }\n\n\n      function columnDefsWatchFunction(n, o) {\n        if (n && n !== o) {\n          self.grid.options.columnDefs = $scope.uiGrid.columnDefs;\n          self.grid.buildColumns({ orderByColumnDefs: true })\n            .then(function(){\n\n              self.grid.preCompileCellTemplates();\n\n              self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.COLUMN);\n            });\n        }\n      }\n\n      var mostRecentData;\n\n      function dataWatchFunction(newData) {\n        // gridUtil.logDebug('dataWatch fired');\n        var promises = [];\n\n        if ( self.grid.options.fastWatch ){\n          if (angular.isString($scope.uiGrid.data)) {\n            newData = self.grid.appScope[$scope.uiGrid.data];\n          } else {\n            newData = $scope.uiGrid.data;\n          }\n        }\n\n        mostRecentData = newData;\n\n        if (newData) {\n          // columns length is greater than the number of row header columns, which don't count because they're created automatically\n          var hasColumns = self.grid.columns.length > (self.grid.rowHeaderColumns ? self.grid.rowHeaderColumns.length : 0);\n\n          if (\n            // If we have no columns\n            !hasColumns &&\n            // ... and we don't have a ui-grid-columns attribute, which would define columns for us\n            !$attrs.uiGridColumns &&\n            // ... and we have no pre-defined columns\n            self.grid.options.columnDefs.length === 0 &&\n            // ... but we DO have data\n            newData.length > 0\n          ) {\n            // ... then build the column definitions from the data that we have\n            self.grid.buildColumnDefsFromData(newData);\n          }\n\n          // If we haven't built columns before and either have some columns defined or some data defined\n          if (!hasColumns && (self.grid.options.columnDefs.length > 0 || newData.length > 0)) {\n            // Build the column set, then pre-compile the column cell templates\n            promises.push(self.grid.buildColumns()\n              .then(function() {\n                self.grid.preCompileCellTemplates();\n              }));\n          }\n\n          $q.all(promises).then(function() {\n            // use most recent data, rather than the potentially outdated data passed into watcher handler\n            self.grid.modifyRows(mostRecentData)\n              .then(function () {\n                // if (self.viewport) {\n                  self.grid.redrawInPlace(true);\n                // }\n\n                $scope.$evalAsync(function() {\n                  self.grid.refreshCanvas(true);\n                  self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.ROW);\n                });\n              });\n          });\n        }\n      }\n\n      var styleWatchDereg = $scope.$watch(function () { return self.grid.styleComputations; }, function() {\n        self.grid.refreshCanvas(true);\n      });\n\n      $scope.$on('$destroy', function() {\n        deregFunctions.forEach( function( deregFn ){ deregFn(); });\n        styleWatchDereg();\n      });\n\n      self.fireEvent = function(eventName, args) {\n        // Add the grid to the event arguments if it's not there\n        if (typeof(args) === 'undefined' || args === undefined) {\n          args = {};\n        }\n\n        if (typeof(args.grid) === 'undefined' || args.grid === undefined) {\n          args.grid = self.grid;\n        }\n\n        $scope.$broadcast(eventName, args);\n      };\n\n      self.innerCompile = function innerCompile(elm) {\n        $compile(elm)($scope);\n      };\n\n    }]);\n\n/**\n *  @ngdoc directive\n *  @name ui.grid.directive:uiGrid\n *  @element div\n *  @restrict EA\n *  @param {Object} uiGrid Options for the grid to use\n *\n *  @description Create a very basic grid.\n *\n *  @example\n    <example module=\"app\">\n      <file name=\"app.js\">\n        var app = angular.module('app', ['ui.grid']);\n\n        app.controller('MainCtrl', ['$scope', function ($scope) {\n          $scope.data = [\n            { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n          ];\n        }]);\n      </file>\n      <file name=\"index.html\">\n        <div ng-controller=\"MainCtrl\">\n          <div ui-grid=\"{ data: data }\"></div>\n        </div>\n      </file>\n    </example>\n */\nangular.module('ui.grid').directive('uiGrid', uiGridDirective);\n\nuiGridDirective.$inject = ['$compile', '$templateCache', '$timeout', '$window', 'gridUtil', 'uiGridConstants'];\nfunction uiGridDirective($compile, $templateCache, $timeout, $window, gridUtil, uiGridConstants) {\n  return {\n    templateUrl: 'ui-grid/ui-grid',\n    scope: {\n      uiGrid: '='\n    },\n    replace: true,\n    transclude: true,\n    controller: 'uiGridController',\n    compile: function () {\n      return {\n        post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          var grid = uiGridCtrl.grid;\n          // Initialize scrollbars (TODO: move to controller??)\n          uiGridCtrl.scrollbars = [];\n          grid.element = $elm;\n\n\n          // See if the grid has a rendered width, if not, wait a bit and try again\n          var sizeCheckInterval = 100; // ms\n          var maxSizeChecks = 20; // 2 seconds total\n          var sizeChecks = 0;\n\n          // Setup (event listeners) the grid\n          setup();\n\n          // And initialize it\n          init();\n\n          // Mark rendering complete so API events can happen\n          grid.renderingComplete();\n\n          // If the grid doesn't have size currently, wait for a bit to see if it gets size\n          checkSize();\n\n          /*-- Methods --*/\n\n          function checkSize() {\n            // If the grid has no width and we haven't checked more than <maxSizeChecks> times, check again in <sizeCheckInterval> milliseconds\n            if ($elm[0].offsetWidth <= 0 && sizeChecks < maxSizeChecks) {\n              setTimeout(checkSize, sizeCheckInterval);\n              sizeChecks++;\n            }\n            else {\n              $timeout(init);\n            }\n          }\n\n          // Setup event listeners and watchers\n          function setup() {\n            // Bind to window resize events\n            angular.element($window).on('resize', gridResize);\n\n            // Unbind from window resize events when the grid is destroyed\n            $elm.on('$destroy', function () {\n              angular.element($window).off('resize', gridResize);\n            });\n\n            // If we add a left container after render, we need to watch and react\n            $scope.$watch(function () { return grid.hasLeftContainer();}, function (newValue, oldValue) {\n              if (newValue === oldValue) {\n                return;\n              }\n              grid.refreshCanvas(true);\n            });\n\n            // If we add a right container after render, we need to watch and react\n            $scope.$watch(function () { return grid.hasRightContainer();}, function (newValue, oldValue) {\n              if (newValue === oldValue) {\n                return;\n              }\n              grid.refreshCanvas(true);\n            });\n          }\n\n          // Initialize the directive\n          function init() {\n            grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm);\n\n            // Default canvasWidth to the grid width, in case we don't get any column definitions to calculate it from\n            grid.canvasWidth = uiGridCtrl.grid.gridWidth;\n\n            grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);\n\n            // If the grid isn't tall enough to fit a single row, it's kind of useless. Resize it to fit a minimum number of rows\n            if (grid.gridHeight <= grid.options.rowHeight && grid.options.enableMinHeightCheck) {\n              autoAdjustHeight();\n            }\n\n            // Run initial canvas refresh\n            grid.refreshCanvas(true);\n          }\n\n          // Set the grid's height ourselves in the case that its height would be unusably small\n          function autoAdjustHeight() {\n            // Figure out the new height\n            var contentHeight = grid.options.minRowsToShow * grid.options.rowHeight;\n            var headerHeight = grid.options.showHeader ? grid.options.headerRowHeight : 0;\n            var footerHeight = grid.calcFooterHeight();\n\n            var scrollbarHeight = 0;\n            if (grid.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) {\n              scrollbarHeight = gridUtil.getScrollbarWidth();\n            }\n\n            var maxNumberOfFilters = 0;\n            // Calculates the maximum number of filters in the columns\n            angular.forEach(grid.options.columnDefs, function(col) {\n              if (col.hasOwnProperty('filter')) {\n                if (maxNumberOfFilters < 1) {\n                    maxNumberOfFilters = 1;\n                }\n              }\n              else if (col.hasOwnProperty('filters')) {\n                if (maxNumberOfFilters < col.filters.length) {\n                    maxNumberOfFilters = col.filters.length;\n                }\n              }\n            });\n\n            if (grid.options.enableFiltering  && !maxNumberOfFilters) {\n              var allColumnsHaveFilteringTurnedOff = grid.options.columnDefs.length && grid.options.columnDefs.every(function(col) {\n                return col.enableFiltering === false;\n              });\n\n              if (!allColumnsHaveFilteringTurnedOff) {\n                maxNumberOfFilters = 1;\n              }\n            }\n\n            var filterHeight = maxNumberOfFilters * headerHeight;\n\n            var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight + filterHeight;\n\n            $elm.css('height', newHeight + 'px');\n\n            grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);\n          }\n\n          // Resize the grid on window resize events\n          function gridResize($event) {\n            grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm);\n            grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);\n\n            grid.refreshCanvas(true);\n          }\n        }\n      };\n    }\n  };\n}\n\n})();\n\n(function(){\n  'use strict';\n\n  // TODO: rename this file to ui-grid-pinned-container.js\n\n  angular.module('ui.grid').directive('uiGridPinnedContainer', ['gridUtil', function (gridUtil) {\n    return {\n      restrict: 'EA',\n      replace: true,\n      template: '<div class=\"ui-grid-pinned-container\"><div ui-grid-render-container container-id=\"side\" row-container-name=\"\\'body\\'\" col-container-name=\"side\" bind-scroll-vertical=\"true\" class=\"{{ side }} ui-grid-render-container-{{ side }}\"></div></div>',\n      scope: {\n        side: '=uiGridPinnedContainer'\n      },\n      require: '^uiGrid',\n      compile: function compile() {\n        return {\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            // gridUtil.logDebug('ui-grid-pinned-container ' + $scope.side + ' link');\n\n            var grid = uiGridCtrl.grid;\n\n            var myWidth = 0;\n\n            $elm.addClass('ui-grid-pinned-container-' + $scope.side);\n\n            // Monkey-patch the viewport width function\n            if ($scope.side === 'left' || $scope.side === 'right') {\n              grid.renderContainers[$scope.side].getViewportWidth = monkeyPatchedGetViewportWidth;\n            }\n\n            function monkeyPatchedGetViewportWidth() {\n              /*jshint validthis: true */\n              var self = this;\n\n              var viewportWidth = 0;\n              self.visibleColumnCache.forEach(function (column) {\n                viewportWidth += column.drawnWidth;\n              });\n\n              var adjustment = self.getViewportAdjustment();\n\n              viewportWidth = viewportWidth + adjustment.width;\n\n              return viewportWidth;\n            }\n\n            function updateContainerWidth() {\n              if ($scope.side === 'left' || $scope.side === 'right') {\n                var cols = grid.renderContainers[$scope.side].visibleColumnCache;\n                var width = 0;\n                for (var i = 0; i < cols.length; i++) {\n                  var col = cols[i];\n                  width += col.drawnWidth || col.width || 0;\n                }\n\n                return width;\n              }\n            }\n\n            function updateContainerDimensions() {\n              var ret = '';\n\n              // Column containers\n              if ($scope.side === 'left' || $scope.side === 'right') {\n                myWidth = updateContainerWidth();\n\n                // gridUtil.logDebug('myWidth', myWidth);\n\n                // TODO(c0bra): Subtract sum of col widths from grid viewport width and update it\n                $elm.attr('style', null);\n\n             //   var myHeight = grid.renderContainers.body.getViewportHeight(); // + grid.horizontalScrollbarHeight;\n\n                ret += '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ', .grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ' .ui-grid-render-container-' + $scope.side + ' .ui-grid-viewport { width: ' + myWidth + 'px; } ';\n              }\n\n              return ret;\n            }\n\n            grid.renderContainers.body.registerViewportAdjuster(function (adjustment) {\n              myWidth = updateContainerWidth();\n\n              // Subtract our own width\n              adjustment.width -= myWidth;\n              adjustment.side = $scope.side;\n\n              return adjustment;\n            });\n\n            // Register style computation to adjust for columns in `side`'s render container\n            grid.registerStyleComputation({\n              priority: 15,\n              func: updateContainerDimensions\n            });\n          }\n        };\n      }\n    };\n  }]);\n})();\n\n(function(){\n\nangular.module('ui.grid')\n.factory('Grid', ['$q', '$compile', '$parse', 'gridUtil', 'uiGridConstants', 'GridOptions', 'GridColumn', 'GridRow', 'GridApi', 'rowSorter', 'rowSearcher', 'GridRenderContainer', '$timeout','ScrollEvent',\n    function($q, $compile, $parse, gridUtil, uiGridConstants, GridOptions, GridColumn, GridRow, GridApi, rowSorter, rowSearcher, GridRenderContainer, $timeout, ScrollEvent) {\n\n  /**\n   * @ngdoc object\n   * @name ui.grid.core.api:PublicApi\n   * @description Public Api for the core grid features\n   *\n   */\n\n  /**\n   * @ngdoc function\n   * @name ui.grid.class:Grid\n   * @description Grid is the main viewModel.  Any properties or methods needed to maintain state are defined in\n   * this prototype.  One instance of Grid is created per Grid directive instance.\n   * @param {object} options Object map of options to pass into the grid. An 'id' property is expected.\n   */\n  var Grid = function Grid(options) {\n    var self = this;\n    // Get the id out of the options, then remove it\n    if (options !== undefined && typeof(options.id) !== 'undefined' && options.id) {\n      if (!/^[_a-zA-Z0-9-]+$/.test(options.id)) {\n        throw new Error(\"Grid id '\" + options.id + '\" is invalid. It must follow CSS selector syntax rules.');\n      }\n    }\n    else {\n      throw new Error('No ID provided. An ID must be given when creating a grid.');\n    }\n\n    self.id = options.id;\n    delete options.id;\n\n    // Get default options\n    self.options = GridOptions.initialize( options );\n\n    /**\n     * @ngdoc object\n     * @name appScope\n     * @propertyOf ui.grid.class:Grid\n     * @description reference to the application scope (the parent scope of the ui-grid element).  Assigned in ui-grid controller\n     * <br/>\n     * use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference\n     */\n    self.appScope = self.options.appScopeProvider;\n\n    self.headerHeight = self.options.headerRowHeight;\n\n\n    /**\n     * @ngdoc object\n     * @name footerHeight\n     * @propertyOf ui.grid.class:Grid\n     * @description returns the total footer height gridFooter + columnFooter\n     */\n    self.footerHeight = self.calcFooterHeight();\n\n\n    /**\n     * @ngdoc object\n     * @name columnFooterHeight\n     * @propertyOf ui.grid.class:Grid\n     * @description returns the total column footer height\n     */\n    self.columnFooterHeight = self.calcColumnFooterHeight();\n\n    self.rtl = false;\n    self.gridHeight = 0;\n    self.gridWidth = 0;\n    self.columnBuilders = [];\n    self.rowBuilders = [];\n    self.rowsProcessors = [];\n    self.columnsProcessors = [];\n    self.styleComputations = [];\n    self.viewportAdjusters = [];\n    self.rowHeaderColumns = [];\n    self.dataChangeCallbacks = {};\n    self.verticalScrollSyncCallBackFns = {};\n    self.horizontalScrollSyncCallBackFns = {};\n\n    // self.visibleRowCache = [];\n\n    // Set of 'render' containers for self grid, which can render sets of rows\n    self.renderContainers = {};\n\n    // Create a\n    self.renderContainers.body = new GridRenderContainer('body', self);\n\n    self.cellValueGetterCache = {};\n\n    // Cached function to use with custom row templates\n    self.getRowTemplateFn = null;\n\n\n    //representation of the rows on the grid.\n    //these are wrapped references to the actual data rows (options.data)\n    self.rows = [];\n\n    //represents the columns on the grid\n    self.columns = [];\n\n    /**\n     * @ngdoc boolean\n     * @name isScrollingVertically\n     * @propertyOf ui.grid.class:Grid\n     * @description set to true when Grid is scrolling vertically. Set to false via debounced method\n     */\n    self.isScrollingVertically = false;\n\n    /**\n     * @ngdoc boolean\n     * @name isScrollingHorizontally\n     * @propertyOf ui.grid.class:Grid\n     * @description set to true when Grid is scrolling horizontally. Set to false via debounced method\n     */\n    self.isScrollingHorizontally = false;\n\n    /**\n     * @ngdoc property\n     * @name scrollDirection\n     * @propertyOf ui.grid.class:Grid\n     * @description set one of the uiGridConstants.scrollDirection values (UP, DOWN, LEFT, RIGHT, NONE), which tells\n     * us which direction we are scrolling. Set to NONE via debounced method\n     */\n    self.scrollDirection = uiGridConstants.scrollDirection.NONE;\n\n    //if true, grid will not respond to any scroll events\n    self.disableScrolling = false;\n\n\n    function vertical (scrollEvent) {\n      self.isScrollingVertically = false;\n      self.api.core.raise.scrollEnd(scrollEvent);\n      self.scrollDirection = uiGridConstants.scrollDirection.NONE;\n    }\n\n    var debouncedVertical = gridUtil.debounce(vertical, self.options.scrollDebounce);\n    var debouncedVerticalMinDelay = gridUtil.debounce(vertical, 0);\n\n    function horizontal (scrollEvent) {\n      self.isScrollingHorizontally = false;\n      self.api.core.raise.scrollEnd(scrollEvent);\n      self.scrollDirection = uiGridConstants.scrollDirection.NONE;\n    }\n\n    var debouncedHorizontal = gridUtil.debounce(horizontal, self.options.scrollDebounce);\n    var debouncedHorizontalMinDelay = gridUtil.debounce(horizontal, 0);\n\n\n    /**\n     * @ngdoc function\n     * @name flagScrollingVertically\n     * @methodOf ui.grid.class:Grid\n     * @description sets isScrollingVertically to true and sets it to false in a debounced function\n     */\n    self.flagScrollingVertically = function(scrollEvent) {\n      if (!self.isScrollingVertically && !self.isScrollingHorizontally) {\n        self.api.core.raise.scrollBegin(scrollEvent);\n      }\n      self.isScrollingVertically = true;\n      if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) {\n        debouncedVerticalMinDelay(scrollEvent);\n      }\n      else {\n        debouncedVertical(scrollEvent);\n      }\n    };\n\n    /**\n     * @ngdoc function\n     * @name flagScrollingHorizontally\n     * @methodOf ui.grid.class:Grid\n     * @description sets isScrollingHorizontally to true and sets it to false in a debounced function\n     */\n    self.flagScrollingHorizontally = function(scrollEvent) {\n      if (!self.isScrollingVertically && !self.isScrollingHorizontally) {\n        self.api.core.raise.scrollBegin(scrollEvent);\n      }\n      self.isScrollingHorizontally = true;\n      if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) {\n        debouncedHorizontalMinDelay(scrollEvent);\n      }\n      else {\n        debouncedHorizontal(scrollEvent);\n      }\n    };\n\n    self.scrollbarHeight = 0;\n    self.scrollbarWidth = 0;\n    if (self.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) {\n      self.scrollbarHeight = gridUtil.getScrollbarWidth();\n    }\n\n    if (self.options.enableVerticalScrollbar === uiGridConstants.scrollbars.ALWAYS) {\n      self.scrollbarWidth = gridUtil.getScrollbarWidth();\n    }\n\n\n\n    self.api = new GridApi(self);\n\n    /**\n     * @ngdoc function\n     * @name refresh\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Refresh the rendered grid on screen.\n     * The refresh method re-runs both the columnProcessors and the\n     * rowProcessors, as well as calling refreshCanvas to update all\n     * the grid sizing.  In general you should prefer to use queueGridRefresh\n     * instead, which is basically a debounced version of refresh.\n     *\n     * If you only want to resize the grid, not regenerate all the rows\n     * and columns, you should consider directly calling refreshCanvas instead.\n     *\n     */\n    self.api.registerMethod( 'core', 'refresh', this.refresh );\n\n    /**\n     * @ngdoc function\n     * @name queueGridRefresh\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Request a refresh of the rendered grid on screen, if multiple\n     * calls to queueGridRefresh are made within a digest cycle only one will execute.\n     * The refresh method re-runs both the columnProcessors and the\n     * rowProcessors, as well as calling refreshCanvas to update all\n     * the grid sizing.  In general you should prefer to use queueGridRefresh\n     * instead, which is basically a debounced version of refresh.\n     *\n     */\n    self.api.registerMethod( 'core', 'queueGridRefresh', this.queueGridRefresh );\n\n    /**\n     * @ngdoc function\n     * @name refreshRows\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Runs only the rowProcessors, columns remain as they were.\n     * It then calls redrawInPlace and refreshCanvas, which adjust the grid sizing.\n     * @returns {promise} promise that is resolved when render completes?\n     *\n     */\n    self.api.registerMethod( 'core', 'refreshRows', this.refreshRows );\n\n    /**\n     * @ngdoc function\n     * @name queueRefresh\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Requests execution of refreshCanvas, if multiple requests are made\n     * during a digest cycle only one will run.  RefreshCanvas updates the grid sizing.\n     * @returns {promise} promise that is resolved when render completes?\n     *\n     */\n    self.api.registerMethod( 'core', 'queueRefresh', this.queueRefresh );\n\n    /**\n     * @ngdoc function\n     * @name handleWindowResize\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Trigger a grid resize, normally this would be picked\n     * up by a watch on window size, but in some circumstances it is necessary\n     * to call this manually\n     * @returns {promise} promise that is resolved when render completes?\n     *\n     */\n    self.api.registerMethod( 'core', 'handleWindowResize', this.handleWindowResize );\n\n\n    /**\n     * @ngdoc function\n     * @name addRowHeaderColumn\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description adds a row header column to the grid\n     * @param {object} column def\n     *\n     */\n    self.api.registerMethod( 'core', 'addRowHeaderColumn', this.addRowHeaderColumn );\n\n    /**\n     * @ngdoc function\n     * @name scrollToIfNecessary\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Scrolls the grid to make a certain row and column combo visible,\n     *   in the case that it is not completely visible on the screen already.\n     * @param {GridRow} gridRow row to make visible\n     * @param {GridCol} gridCol column to make visible\n     * @returns {promise} a promise that is resolved when scrolling is complete\n     *\n     */\n    self.api.registerMethod( 'core', 'scrollToIfNecessary', function(gridRow, gridCol) { return self.scrollToIfNecessary(gridRow, gridCol);} );\n\n    /**\n     * @ngdoc function\n     * @name scrollTo\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Scroll the grid such that the specified\n     * row and column is in view\n     * @param {object} rowEntity gridOptions.data[] array instance to make visible\n     * @param {object} colDef to make visible\n     * @returns {promise} a promise that is resolved after any scrolling is finished\n     */\n    self.api.registerMethod( 'core', 'scrollTo', function (rowEntity, colDef) { return self.scrollTo(rowEntity, colDef);}  );\n\n    /**\n     * @ngdoc function\n     * @name registerRowsProcessor\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description\n     * Register a \"rows processor\" function. When the rows are updated,\n     * the grid calls each registered \"rows processor\", which has a chance\n     * to alter the set of rows (sorting, etc) as long as the count is not\n     * modified.\n     *\n     * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which\n     * is run in the context of the grid (i.e. this for the function will be the grid), and must\n     * return the updated rows list, which is passed to the next processor in the chain\n     * @param {number} priority the priority of this processor.  In general we try to do them in 100s to leave room\n     * for other people to inject rows processors at intermediate priorities.  Lower priority rowsProcessors run earlier.\n     *\n     * At present allRowsVisible is running at 50, sort manipulations running at 60-65, filter is running at 100,\n     * sort is at 200, grouping and treeview at 400-410, selectable rows at 500, pagination at 900 (pagination will generally want to be last)\n     */\n    self.api.registerMethod( 'core', 'registerRowsProcessor', this.registerRowsProcessor  );\n\n    /**\n     * @ngdoc function\n     * @name registerColumnsProcessor\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description\n     * Register a \"columns processor\" function. When the columns are updated,\n     * the grid calls each registered \"columns processor\", which has a chance\n     * to alter the set of columns as long as the count is not\n     * modified.\n     *\n     * @param {function(renderedColumnsToProcess, rows )} processorFunction columns processor function, which\n     * is run in the context of the grid (i.e. this for the function will be the grid), and must\n     * return the updated columns list, which is passed to the next processor in the chain\n     * @param {number} priority the priority of this processor.  In general we try to do them in 100s to leave room\n     * for other people to inject columns processors at intermediate priorities.  Lower priority columnsProcessors run earlier.\n     *\n     * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)\n     */\n    self.api.registerMethod( 'core', 'registerColumnsProcessor', this.registerColumnsProcessor  );\n\n\n\n    /**\n     * @ngdoc function\n     * @name sortHandleNulls\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description A null handling method that can be used when building custom sort\n     * functions\n     * @example\n     * <pre>\n     *   mySortFn = function(a, b) {\n     *   var nulls = $scope.gridApi.core.sortHandleNulls(a, b);\n     *   if ( nulls !== null ){\n     *     return nulls;\n     *   } else {\n     *     // your code for sorting here\n     *   };\n     * </pre>\n     * @param {object} a sort value a\n     * @param {object} b sort value b\n     * @returns {number} null if there were no nulls/undefineds, otherwise returns\n     * a sort value that should be passed back from the sort function\n     *\n     */\n    self.api.registerMethod( 'core', 'sortHandleNulls', rowSorter.handleNulls );\n\n\n    /**\n     * @ngdoc function\n     * @name sortChanged\n     * @methodOf  ui.grid.core.api:PublicApi\n     * @description The sort criteria on one or more columns has\n     * changed.  Provides as parameters the grid and the output of\n     * getColumnSorting, which is an array of gridColumns\n     * that have sorting on them, sorted in priority order.\n     *\n     * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed.\n     * @param {Function} callBack Will be called when the event is emited. The function passes back the grid and an array of \n     * columns with sorts on them, in priority order.\n     *\n     * @example\n     * <pre>\n     *      gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){\n     *        // do something\n     *      });\n     * </pre>\n     */\n    self.api.registerEvent( 'core', 'sortChanged' );\n\n      /**\n     * @ngdoc function\n     * @name columnVisibilityChanged\n     * @methodOf  ui.grid.core.api:PublicApi\n     * @description The visibility of a column has changed,\n     * the column itself is passed out as a parameter of the event.\n     *\n     * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed.\n     * @param {Function} callBack Will be called when the event is emited. The function passes back the GridCol that has changed.\n     *\n     * @example\n     * <pre>\n     *      gridApi.core.on.columnVisibilityChanged( $scope, function (column) {\n     *        // do something\n     *      } );\n     * </pre>\n     */\n    self.api.registerEvent( 'core', 'columnVisibilityChanged' );\n\n    /**\n     * @ngdoc method\n     * @name notifyDataChange\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Notify the grid that a data or config change has occurred,\n     * where that change isn't something the grid was otherwise noticing.  This\n     * might be particularly relevant where you've changed values within the data\n     * and you'd like cell classes to be re-evaluated, or changed config within\n     * the columnDef and you'd like headerCellClasses to be re-evaluated.\n     * @param {string} type one of the\n     * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN), which tells\n     * us which refreshes to fire.\n     *\n     */\n    self.api.registerMethod( 'core', 'notifyDataChange', this.notifyDataChange );\n\n    /**\n     * @ngdoc method\n     * @name clearAllFilters\n     * @methodOf ui.grid.core.api:PublicApi\n     * @description Clears all filters and optionally refreshes the visible rows.\n     * @param {object} refreshRows Defaults to true.\n     * @param {object} clearConditions Defaults to false.\n     * @param {object} clearFlags Defaults to false.\n     * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing.\n     */\n    self.api.registerMethod('core', 'clearAllFilters', this.clearAllFilters);\n\n    self.registerDataChangeCallback( self.columnRefreshCallback, [uiGridConstants.dataChange.COLUMN]);\n    self.registerDataChangeCallback( self.processRowsCallback, [uiGridConstants.dataChange.EDIT]);\n    self.registerDataChangeCallback( self.updateFooterHeightCallback, [uiGridConstants.dataChange.OPTIONS]);\n\n    self.registerStyleComputation({\n      priority: 10,\n      func: self.getFooterStyles\n    });\n  };\n\n   Grid.prototype.calcFooterHeight = function () {\n     if (!this.hasFooter()) {\n       return 0;\n     }\n\n     var height = 0;\n     if (this.options.showGridFooter) {\n       height += this.options.gridFooterHeight;\n     }\n\n     height += this.calcColumnFooterHeight();\n\n     return height;\n   };\n\n   Grid.prototype.calcColumnFooterHeight = function () {\n     var height = 0;\n\n     if (this.options.showColumnFooter) {\n       height += this.options.columnFooterHeight;\n     }\n\n     return height;\n   };\n\n   Grid.prototype.getFooterStyles = function () {\n     var style = '.grid' + this.id + ' .ui-grid-footer-aggregates-row { height: ' + this.options.columnFooterHeight + 'px; }';\n     style += ' .grid' + this.id + ' .ui-grid-footer-info { height: ' + this.options.gridFooterHeight + 'px; }';\n     return style;\n   };\n\n  Grid.prototype.hasFooter = function () {\n   return this.options.showGridFooter || this.options.showColumnFooter;\n  };\n\n  /**\n   * @ngdoc function\n   * @name isRTL\n   * @methodOf ui.grid.class:Grid\n   * @description Returns true if grid is RightToLeft\n   */\n  Grid.prototype.isRTL = function () {\n    return this.rtl;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name registerColumnBuilder\n   * @methodOf ui.grid.class:Grid\n   * @description When the build creates columns from column definitions, the columnbuilders will be called to add\n   * additional properties to the column.\n   * @param {function(colDef, col, gridOptions)} columnBuilder function to be called\n   */\n  Grid.prototype.registerColumnBuilder = function registerColumnBuilder(columnBuilder) {\n    this.columnBuilders.push(columnBuilder);\n  };\n\n  /**\n   * @ngdoc function\n   * @name buildColumnDefsFromData\n   * @methodOf ui.grid.class:Grid\n   * @description Populates columnDefs from the provided data\n   * @param {function(colDef, col, gridOptions)} rowBuilder function to be called\n   */\n  Grid.prototype.buildColumnDefsFromData = function (dataRows){\n    this.options.columnDefs =  gridUtil.getColumnsFromData(dataRows, this.options.excludeProperties);\n  };\n\n  /**\n   * @ngdoc function\n   * @name registerRowBuilder\n   * @methodOf ui.grid.class:Grid\n   * @description When the build creates rows from gridOptions.data, the rowBuilders will be called to add\n   * additional properties to the row.\n   * @param {function(row, gridOptions)} rowBuilder function to be called\n   */\n  Grid.prototype.registerRowBuilder = function registerRowBuilder(rowBuilder) {\n    this.rowBuilders.push(rowBuilder);\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name registerDataChangeCallback\n   * @methodOf ui.grid.class:Grid\n   * @description When a data change occurs, the data change callbacks of the specified type\n   * will be called.  The rules are:\n   *\n   * - when the data watch fires, that is considered a ROW change (the data watch only notices\n   *   added or removed rows)\n   * - when the api is called to inform us of a change, the declared type of that change is used\n   * - when a cell edit completes, the EDIT callbacks are triggered\n   * - when the columnDef watch fires, the COLUMN callbacks are triggered\n   * - when the options watch fires, the OPTIONS callbacks are triggered\n   *\n   * For a given event:\n   * - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks\n   * - ROW calls ROW and ALL callbacks\n   * - EDIT calls EDIT and ALL callbacks\n   * - COLUMN calls COLUMN and ALL callbacks\n   * - OPTIONS calls OPTIONS and ALL callbacks\n   *\n   * @param {function(grid)} callback function to be called\n   * @param {array} types the types of data change you want to be informed of.  Values from\n   * the uiGridConstants.dataChange values ( ALL, EDIT, ROW, COLUMN, OPTIONS ).  Optional and defaults to\n   * ALL\n   * @returns {function} deregister function - a function that can be called to deregister this callback\n   */\n  Grid.prototype.registerDataChangeCallback = function registerDataChangeCallback(callback, types, _this) {\n    var uid = gridUtil.nextUid();\n    if ( !types ){\n      types = [uiGridConstants.dataChange.ALL];\n    }\n    if ( !Array.isArray(types)){\n      gridUtil.logError(\"Expected types to be an array or null in registerDataChangeCallback, value passed was: \" + types );\n    }\n    this.dataChangeCallbacks[uid] = { callback: callback, types: types, _this:_this };\n\n    var self = this;\n    var deregisterFunction = function() {\n      delete self.dataChangeCallbacks[uid];\n    };\n    return deregisterFunction;\n  };\n\n  /**\n   * @ngdoc function\n   * @name callDataChangeCallbacks\n   * @methodOf ui.grid.class:Grid\n   * @description Calls the callbacks based on the type of data change that\n   * has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the\n   * event type is matching, or if the type is ALL.\n   * @param {number} type the type of event that occurred - one of the\n   * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS)\n   */\n  Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) {\n    angular.forEach( this.dataChangeCallbacks, function( callback, uid ){\n      if ( callback.types.indexOf( uiGridConstants.dataChange.ALL ) !== -1 ||\n           callback.types.indexOf( type ) !== -1 ||\n           type === uiGridConstants.dataChange.ALL ) {\n        if (callback._this) {\n           callback.callback.apply(callback._this,this);\n        }\n        else {\n          callback.callback( this );\n        }\n      }\n    }, this);\n  };\n\n  /**\n   * @ngdoc function\n   * @name notifyDataChange\n   * @methodOf ui.grid.class:Grid\n   * @description Notifies us that a data change has occurred, used in the public\n   * api for users to tell us when they've changed data or some other event that\n   * our watches cannot pick up\n   * @param {string} type the type of event that occurred - one of the\n   * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN)\n   */\n  Grid.prototype.notifyDataChange = function notifyDataChange(type) {\n    var constants = uiGridConstants.dataChange;\n    if ( type === constants.ALL ||\n         type === constants.COLUMN ||\n         type === constants.EDIT ||\n         type === constants.ROW ||\n         type === constants.OPTIONS ){\n      this.callDataChangeCallbacks( type );\n    } else {\n      gridUtil.logError(\"Notified of a data change, but the type was not recognised, so no action taken, type was: \" + type);\n    }\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name columnRefreshCallback\n   * @methodOf ui.grid.class:Grid\n   * @description refreshes the grid when a column refresh\n   * is notified, which triggers handling of the visible flag.\n   * This is called on uiGridConstants.dataChange.COLUMN, and is\n   * registered as a dataChangeCallback in grid.js\n   * @param {string} name column name\n   */\n  Grid.prototype.columnRefreshCallback = function columnRefreshCallback( grid ){\n    grid.buildColumns();\n    grid.queueGridRefresh();\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name processRowsCallback\n   * @methodOf ui.grid.class:Grid\n   * @description calls the row processors, specifically\n   * intended to reset the sorting when an edit is called,\n   * registered as a dataChangeCallback on uiGridConstants.dataChange.EDIT\n   * @param {string} name column name\n   */\n  Grid.prototype.processRowsCallback = function processRowsCallback( grid ){\n    grid.queueGridRefresh();\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name updateFooterHeightCallback\n   * @methodOf ui.grid.class:Grid\n   * @description recalculates the footer height,\n   * registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS\n   * @param {string} name column name\n   */\n  Grid.prototype.updateFooterHeightCallback = function updateFooterHeightCallback( grid ){\n    grid.footerHeight = grid.calcFooterHeight();\n    grid.columnFooterHeight = grid.calcColumnFooterHeight();\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name getColumn\n   * @methodOf ui.grid.class:Grid\n   * @description returns a grid column for the column name\n   * @param {string} name column name\n   */\n  Grid.prototype.getColumn = function getColumn(name) {\n    var columns = this.columns.filter(function (column) {\n      return column.colDef.name === name;\n    });\n    return columns.length > 0 ? columns[0] : null;\n  };\n\n  /**\n   * @ngdoc function\n   * @name getColDef\n   * @methodOf ui.grid.class:Grid\n   * @description returns a grid colDef for the column name\n   * @param {string} name column.field\n   */\n  Grid.prototype.getColDef = function getColDef(name) {\n    var colDefs = this.options.columnDefs.filter(function (colDef) {\n      return colDef.name === name;\n    });\n    return colDefs.length > 0 ? colDefs[0] : null;\n  };\n\n  /**\n   * @ngdoc function\n   * @name assignTypes\n   * @methodOf ui.grid.class:Grid\n   * @description uses the first row of data to assign colDef.type for any types not defined.\n   */\n  /**\n   * @ngdoc property\n   * @name type\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description the type of the column, used in sorting.  If not provided then the\n   * grid will guess the type.  Add this only if the grid guessing is not to your\n   * satisfaction.  One of:\n   * - 'string'\n   * - 'boolean'\n   * - 'number'\n   * - 'date'\n   * - 'object'\n   * - 'numberStr'\n   * Note that if you choose date, your dates should be in a javascript date type\n   *\n   */\n  Grid.prototype.assignTypes = function(){\n    var self = this;\n    self.options.columnDefs.forEach(function (colDef, index) {\n\n      //Assign colDef type if not specified\n      if (!colDef.type) {\n        var col = new GridColumn(colDef, index, self);\n        var firstRow = self.rows.length > 0 ? self.rows[0] : null;\n        if (firstRow) {\n          colDef.type = gridUtil.guessType(self.getCellValue(firstRow, col));\n        }\n        else {\n          colDef.type = 'string';\n        }\n      }\n    });\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name isRowHeaderColumn\n   * @methodOf ui.grid.class:Grid\n   * @description returns true if the column is a row Header\n   * @param {object} column column\n   */\n  Grid.prototype.isRowHeaderColumn = function isRowHeaderColumn(column) {\n    return this.rowHeaderColumns.indexOf(column) !== -1;\n  };\n\n  /**\n  * @ngdoc function\n  * @name addRowHeaderColumn\n  * @methodOf ui.grid.class:Grid\n  * @description adds a row header column to the grid\n  * @param {object} column def\n  */\n  Grid.prototype.addRowHeaderColumn = function addRowHeaderColumn(colDef) {\n    var self = this;\n    var rowHeaderCol = new GridColumn(colDef, gridUtil.nextUid(), self);\n    rowHeaderCol.isRowHeader = true;\n    if (self.isRTL()) {\n      self.createRightContainer();\n      rowHeaderCol.renderContainer = 'right';\n    }\n    else {\n      self.createLeftContainer();\n      rowHeaderCol.renderContainer = 'left';\n    }\n\n    // relies on the default column builder being first in array, as it is instantiated\n    // as part of grid creation\n    self.columnBuilders[0](colDef,rowHeaderCol,self.options)\n      .then(function(){\n        rowHeaderCol.enableFiltering = false;\n        rowHeaderCol.enableSorting = false;\n        rowHeaderCol.enableHiding = false;\n        self.rowHeaderColumns.push(rowHeaderCol);\n        self.buildColumns()\n          .then( function() {\n            self.preCompileCellTemplates();\n            self.queueGridRefresh();\n          });\n      });\n  };\n\n  /**\n   * @ngdoc function\n   * @name getOnlyDataColumns\n   * @methodOf ui.grid.class:Grid\n   * @description returns all columns except for rowHeader columns\n   */\n  Grid.prototype.getOnlyDataColumns = function getOnlyDataColumns() {\n    var self = this;\n    var cols = [];\n    self.columns.forEach(function (col) {\n      if (self.rowHeaderColumns.indexOf(col) === -1) {\n        cols.push(col);\n      }\n    });\n    return cols;\n  };\n\n  /**\n   * @ngdoc function\n   * @name buildColumns\n   * @methodOf ui.grid.class:Grid\n   * @description creates GridColumn objects from the columnDefinition.  Calls each registered\n   * columnBuilder to further process the column\n   * @param {object} options  An object contains options to use when building columns\n   *\n   * * **orderByColumnDefs**: defaults to **false**. When true, `buildColumns` will reorder existing columns according to the order within the column definitions.\n   *\n   * @returns {Promise} a promise to load any needed column resources\n   */\n  Grid.prototype.buildColumns = function buildColumns(opts) {\n    var options = {\n      orderByColumnDefs: false\n    };\n\n    angular.extend(options, opts);\n\n    // gridUtil.logDebug('buildColumns');\n    var self = this;\n    var builderPromises = [];\n    var headerOffset = self.rowHeaderColumns.length;\n    var i;\n\n    // Remove any columns for which a columnDef cannot be found\n    // Deliberately don't use forEach, as it doesn't like splice being called in the middle\n    // Also don't cache columns.length, as it will change during this operation\n    for (i = 0; i < self.columns.length; i++){\n      if (!self.getColDef(self.columns[i].name)) {\n        self.columns.splice(i, 1);\n        i--;\n      }\n    }\n\n    //add row header columns to the grid columns array _after_ columns without columnDefs have been removed\n    self.rowHeaderColumns.forEach(function (rowHeaderColumn) {\n      self.columns.unshift(rowHeaderColumn);\n    });\n\n\n    // look at each column def, and update column properties to match.  If the column def\n    // doesn't have a column, then splice in a new gridCol\n    self.options.columnDefs.forEach(function (colDef, index) {\n      self.preprocessColDef(colDef);\n      var col = self.getColumn(colDef.name);\n\n      if (!col) {\n        col = new GridColumn(colDef, gridUtil.nextUid(), self);\n        self.columns.splice(index + headerOffset, 0, col);\n      }\n      else {\n        // tell updateColumnDef that the column was pre-existing\n        col.updateColumnDef(colDef, false);\n      }\n\n      self.columnBuilders.forEach(function (builder) {\n        builderPromises.push(builder.call(self, colDef, col, self.options));\n      });\n    });\n\n    /*** Reorder columns if necessary ***/\n    if (!!options.orderByColumnDefs) {\n      // Create a shallow copy of the columns as a cache\n      var columnCache = self.columns.slice(0);\n\n      // We need to allow for the \"row headers\" when mapping from the column defs array to the columns array\n      //   If we have a row header in columns[0] and don't account for it   we'll overwrite it with the column in columnDefs[0]\n\n      // Go through all the column defs, use the shorter of columns length and colDefs.length because if a user has given two columns the same name then\n      // columns will be shorter than columnDefs.  In this situation we'll avoid an error, but the user will still get an unexpected result\n      var len = Math.min(self.options.columnDefs.length, self.columns.length);\n      for (i = 0; i < len; i++) {\n        // If the column at this index has a different name than the column at the same index in the column defs...\n        if (self.columns[i + headerOffset].name !== self.options.columnDefs[i].name) {\n          // Replace the one in the cache with the appropriate column\n          columnCache[i + headerOffset] = self.getColumn(self.options.columnDefs[i].name);\n        }\n        else {\n          // Otherwise just copy over the one from the initial columns\n          columnCache[i + headerOffset] = self.columns[i + headerOffset];\n        }\n      }\n\n      // Empty out the columns array, non-destructively\n      self.columns.length = 0;\n\n      // And splice in the updated, ordered columns from the cache\n      Array.prototype.splice.apply(self.columns, [0, 0].concat(columnCache));\n    }\n\n    return $q.all(builderPromises).then(function(){\n      if (self.rows.length > 0){\n        self.assignTypes();\n      }\n    });\n  };\n\n/**\n * @ngdoc function\n * @name preCompileCellTemplates\n * @methodOf ui.grid.class:Grid\n * @description precompiles all cell templates\n */\n  Grid.prototype.preCompileCellTemplates = function() {\n    var self = this;\n\n    var preCompileTemplate = function( col ) {\n      var html = col.cellTemplate.replace(uiGridConstants.MODEL_COL_FIELD, self.getQualifiedColField(col));\n      html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');\n\n      var compiledElementFn = $compile(html);\n      col.compiledElementFn = compiledElementFn;\n\n      if (col.compiledElementFnDefer) {\n        col.compiledElementFnDefer.resolve(col.compiledElementFn);\n      }\n    };\n\n    this.columns.forEach(function (col) {\n      if ( col.cellTemplate ){\n        preCompileTemplate( col );\n      } else if ( col.cellTemplatePromise ){\n        col.cellTemplatePromise.then( function() {\n          preCompileTemplate( col );\n        });\n      }\n    });\n  };\n\n  /**\n   * @ngdoc function\n   * @name getGridQualifiedColField\n   * @methodOf ui.grid.class:Grid\n   * @description Returns the $parse-able accessor for a column within its $scope\n   * @param {GridColumn} col col object\n   */\n  Grid.prototype.getQualifiedColField = function (col) {\n    return 'row.entity.' + gridUtil.preEval(col.field);\n  };\n\n  /**\n   * @ngdoc function\n   * @name createLeftContainer\n   * @methodOf ui.grid.class:Grid\n   * @description creates the left render container if it doesn't already exist\n   */\n  Grid.prototype.createLeftContainer = function() {\n    if (!this.hasLeftContainer()) {\n      this.renderContainers.left = new GridRenderContainer('left', this, { disableColumnOffset: true });\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name createRightContainer\n   * @methodOf ui.grid.class:Grid\n   * @description creates the right render container if it doesn't already exist\n   */\n  Grid.prototype.createRightContainer = function() {\n    if (!this.hasRightContainer()) {\n      this.renderContainers.right = new GridRenderContainer('right', this, { disableColumnOffset: true });\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name hasLeftContainer\n   * @methodOf ui.grid.class:Grid\n   * @description returns true if leftContainer exists\n   */\n  Grid.prototype.hasLeftContainer = function() {\n    return this.renderContainers.left !== undefined;\n  };\n\n  /**\n   * @ngdoc function\n   * @name hasRightContainer\n   * @methodOf ui.grid.class:Grid\n   * @description returns true if rightContainer exists\n   */\n  Grid.prototype.hasRightContainer = function() {\n    return this.renderContainers.right !== undefined;\n  };\n\n\n      /**\n   * undocumented function\n   * @name preprocessColDef\n   * @methodOf ui.grid.class:Grid\n   * @description defaults the name property from field to maintain backwards compatibility with 2.x\n   * validates that name or field is present\n   */\n  Grid.prototype.preprocessColDef = function preprocessColDef(colDef) {\n    var self = this;\n\n    if (!colDef.field && !colDef.name) {\n      throw new Error('colDef.name or colDef.field property is required');\n    }\n\n    //maintain backwards compatibility with 2.x\n    //field was required in 2.x.  now name is required\n    if (colDef.name === undefined && colDef.field !== undefined) {\n      // See if the column name already exists:\n      var newName = colDef.field,\n        counter = 2;\n      while (self.getColumn(newName)) {\n        newName = colDef.field + counter.toString();\n        counter++;\n      }\n      colDef.name = newName;\n    }\n  };\n\n  // Return a list of items that exist in the `n` array but not the `o` array. Uses optional property accessors passed as third & fourth parameters\n  Grid.prototype.newInN = function newInN(o, n, oAccessor, nAccessor) {\n    var self = this;\n\n    var t = [];\n    for (var i = 0; i < n.length; i++) {\n      var nV = nAccessor ? n[i][nAccessor] : n[i];\n\n      var found = false;\n      for (var j = 0; j < o.length; j++) {\n        var oV = oAccessor ? o[j][oAccessor] : o[j];\n        if (self.options.rowEquality(nV, oV)) {\n          found = true;\n          break;\n        }\n      }\n      if (!found) {\n        t.push(nV);\n      }\n    }\n\n    return t;\n  };\n\n  /**\n   * @ngdoc function\n   * @name getRow\n   * @methodOf ui.grid.class:Grid\n   * @description returns the GridRow that contains the rowEntity\n   * @param {object} rowEntity the gridOptions.data array element instance\n   * @param {array} rows [optional] the rows to look in - if not provided then\n   * looks in grid.rows\n   */\n  Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {\n    var self = this;\n\n    lookInRows = typeof(lookInRows) === 'undefined' ? self.rows : lookInRows;\n\n    var rows = lookInRows.filter(function (row) {\n      return self.options.rowEquality(row.entity, rowEntity);\n    });\n    return rows.length > 0 ? rows[0] : null;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name modifyRows\n   * @methodOf ui.grid.class:Grid\n   * @description creates or removes GridRow objects from the newRawData array.  Calls each registered\n   * rowBuilder to further process the row\n   * @param {array} newRawData Modified set of data\n   *\n   * This method aims to achieve three things:\n   * 1. the resulting rows array is in the same order as the newRawData, we'll call\n   * rowsProcessors immediately after to sort the data anyway\n   * 2. if we have row hashing available, we try to use the rowHash to find the row\n   * 3. no memory leaks - rows that are no longer in newRawData need to be garbage collected\n   *\n   * The basic logic flow makes use of the newRawData, oldRows and oldHash, and creates\n   * the newRows and newHash\n   *\n   * ```\n   * newRawData.forEach newEntity\n   *   if (hashing enabled)\n   *     check oldHash for newEntity\n   *   else\n   *     look for old row directly in oldRows\n   *   if !oldRowFound     // must be a new row\n   *     create newRow\n   *   append to the newRows and add to newHash\n   *   run the processors\n   * ```\n   *\n   * Rows are identified using the hashKey if configured.  If not configured, then rows\n   * are identified using the gridOptions.rowEquality function\n   *\n   * This method is useful when trying to select rows immediately after loading data without\n   * using a $timeout/$interval, e.g.:\n   *\n   *   $scope.gridOptions.data =  someData;\n   *   $scope.gridApi.grid.modifyRows($scope.gridOptions.data);\n   *   $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);\n   *\n   * OR to persist row selection after data update (e.g. rows selected, new data loaded, want\n   * originally selected rows to be re-selected))\n   */\n  Grid.prototype.modifyRows = function modifyRows(newRawData) {\n    var self = this;\n    var oldRows = self.rows.slice(0);\n    var oldRowHash = self.rowHashMap || self.createRowHashMap();\n    self.rowHashMap = self.createRowHashMap();\n    self.rows.length = 0;\n\n    newRawData.forEach( function( newEntity, i ) {\n      var newRow;\n      if ( self.options.enableRowHashing ){\n        // if hashing is enabled, then this row will be in the hash if we already know about it\n        newRow = oldRowHash.get( newEntity );\n      } else {\n        // otherwise, manually search the oldRows to see if we can find this row\n        newRow = self.getRow(newEntity, oldRows);\n      }\n\n      // if we didn't find the row, it must be new, so create it\n      if ( !newRow ){\n        newRow = self.processRowBuilders(new GridRow(newEntity, i, self));\n      }\n\n      self.rows.push( newRow );\n      self.rowHashMap.put( newEntity, newRow );\n    });\n\n    self.assignTypes();\n\n    var p1 = $q.when(self.processRowsProcessors(self.rows))\n      .then(function (renderableRows) {\n        return self.setVisibleRows(renderableRows);\n      });\n\n    var p2 = $q.when(self.processColumnsProcessors(self.columns))\n      .then(function (renderableColumns) {\n        return self.setVisibleColumns(renderableColumns);\n      });\n\n    return $q.all([p1, p2]);\n  };\n\n\n  /**\n   * Private Undocumented Method\n   * @name addRows\n   * @methodOf ui.grid.class:Grid\n   * @description adds the newRawData array of rows to the grid and calls all registered\n   * rowBuilders. this keyword will reference the grid\n   */\n  Grid.prototype.addRows = function addRows(newRawData) {\n    var self = this;\n\n    var existingRowCount = self.rows.length;\n    for (var i = 0; i < newRawData.length; i++) {\n      var newRow = self.processRowBuilders(new GridRow(newRawData[i], i + existingRowCount, self));\n\n      if (self.options.enableRowHashing) {\n        var found = self.rowHashMap.get(newRow.entity);\n        if (found) {\n          found.row = newRow;\n        }\n      }\n\n      self.rows.push(newRow);\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name processRowBuilders\n   * @methodOf ui.grid.class:Grid\n   * @description processes all RowBuilders for the gridRow\n   * @param {GridRow} gridRow reference to gridRow\n   * @returns {GridRow} the gridRow with all additional behavior added\n   */\n  Grid.prototype.processRowBuilders = function processRowBuilders(gridRow) {\n    var self = this;\n\n    self.rowBuilders.forEach(function (builder) {\n      builder.call(self, gridRow, self.options);\n    });\n\n    return gridRow;\n  };\n\n  /**\n   * @ngdoc function\n   * @name registerStyleComputation\n   * @methodOf ui.grid.class:Grid\n   * @description registered a styleComputation function\n   *\n   * If the function returns a value it will be appended into the grid's `<style>` block\n   * @param {function($scope)} styleComputation function\n   */\n  Grid.prototype.registerStyleComputation = function registerStyleComputation(styleComputationInfo) {\n    this.styleComputations.push(styleComputationInfo);\n  };\n\n\n  // NOTE (c0bra): We already have rowBuilders. I think these do exactly the same thing...\n  // Grid.prototype.registerRowFilter = function(filter) {\n  //   // TODO(c0bra): validate filter?\n\n  //   this.rowFilters.push(filter);\n  // };\n\n  // Grid.prototype.removeRowFilter = function(filter) {\n  //   var idx = this.rowFilters.indexOf(filter);\n\n  //   if (typeof(idx) !== 'undefined' && idx !== undefined) {\n  //     this.rowFilters.slice(idx, 1);\n  //   }\n  // };\n\n  // Grid.prototype.processRowFilters = function(rows) {\n  //   var self = this;\n  //   self.rowFilters.forEach(function (filter) {\n  //     filter.call(self, rows);\n  //   });\n  // };\n\n\n  /**\n   * @ngdoc function\n   * @name registerRowsProcessor\n   * @methodOf ui.grid.class:Grid\n   * @description\n   *\n   * Register a \"rows processor\" function. When the rows are updated,\n   * the grid calls each registered \"rows processor\", which has a chance\n   * to alter the set of rows (sorting, etc) as long as the count is not\n   * modified.\n   *\n   * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which\n   * is run in the context of the grid (i.e. this for the function will be the grid), and must\n   * return the updated rows list, which is passed to the next processor in the chain\n   * @param {number} priority the priority of this processor.  In general we try to do them in 100s to leave room\n   * for other people to inject rows processors at intermediate priorities.  Lower priority rowsProcessors run earlier.\n   *\n   * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)\n   *\n   */\n  Grid.prototype.registerRowsProcessor = function registerRowsProcessor(processor, priority) {\n    if (!angular.isFunction(processor)) {\n      throw 'Attempt to register non-function rows processor: ' + processor;\n    }\n\n    this.rowsProcessors.push({processor: processor, priority: priority});\n    this.rowsProcessors.sort(function sortByPriority( a, b ){\n      return a.priority - b.priority;\n    });\n  };\n\n  /**\n   * @ngdoc function\n   * @name removeRowsProcessor\n   * @methodOf ui.grid.class:Grid\n   * @param {function(renderableRows)} rows processor function\n   * @description Remove a registered rows processor\n   */\n  Grid.prototype.removeRowsProcessor = function removeRowsProcessor(processor) {\n    var idx = -1;\n    this.rowsProcessors.forEach(function(rowsProcessor, index){\n      if ( rowsProcessor.processor === processor ){\n        idx = index;\n      }\n    });\n\n    if ( idx !== -1 ) {\n      this.rowsProcessors.splice(idx, 1);\n    }\n  };\n\n  /**\n   * Private Undocumented Method\n   * @name processRowsProcessors\n   * @methodOf ui.grid.class:Grid\n   * @param {Array[GridRow]} The array of \"renderable\" rows\n   * @param {Array[GridColumn]} The array of columns\n   * @description Run all the registered rows processors on the array of renderable rows\n   */\n  Grid.prototype.processRowsProcessors = function processRowsProcessors(renderableRows) {\n    var self = this;\n\n    // Create a shallow copy of the rows so that we can safely sort them without altering the original grid.rows sort order\n    var myRenderableRows = renderableRows.slice(0);\n\n    // Return myRenderableRows with no processing if we have no rows processors\n    if (self.rowsProcessors.length === 0) {\n      return $q.when(myRenderableRows);\n    }\n\n    // Counter for iterating through rows processors\n    var i = 0;\n\n    // Promise for when we're done with all the processors\n    var finished = $q.defer();\n\n    // This function will call the processor in self.rowsProcessors at index 'i', and then\n    //   when done will call the next processor in the list, using the output from the processor\n    //   at i as the argument for 'renderedRowsToProcess' on the next iteration.\n    //\n    //   If we're at the end of the list of processors, we resolve our 'finished' callback with\n    //   the result.\n    function startProcessor(i, renderedRowsToProcess) {\n      // Get the processor at 'i'\n      var processor = self.rowsProcessors[i].processor;\n\n      // Call the processor, passing in the rows to process and the current columns\n      //   (note: it's wrapped in $q.when() in case the processor does not return a promise)\n      return $q.when( processor.call(self, renderedRowsToProcess, self.columns) )\n        .then(function handleProcessedRows(processedRows) {\n          // Check for errors\n          if (!processedRows) {\n            throw \"Processor at index \" + i + \" did not return a set of renderable rows\";\n          }\n\n          if (!angular.isArray(processedRows)) {\n            throw \"Processor at index \" + i + \" did not return an array\";\n          }\n\n          // Processor is done, increment the counter\n          i++;\n\n          // If we're not done with the processors, call the next one\n          if (i <= self.rowsProcessors.length - 1) {\n            return startProcessor(i, processedRows);\n          }\n          // We're done! Resolve the 'finished' promise\n          else {\n            finished.resolve(processedRows);\n          }\n        });\n    }\n\n    // Start on the first processor\n    startProcessor(0, myRenderableRows);\n\n    return finished.promise;\n  };\n\n  Grid.prototype.setVisibleRows = function setVisibleRows(rows) {\n    var self = this;\n\n    // Reset all the render container row caches\n    for (var i in self.renderContainers) {\n      var container = self.renderContainers[i];\n\n      container.canvasHeightShouldUpdate = true;\n\n      if ( typeof(container.visibleRowCache) === 'undefined' ){\n        container.visibleRowCache = [];\n      } else {\n        container.visibleRowCache.length = 0;\n      }\n    }\n\n    // rows.forEach(function (row) {\n    for (var ri = 0; ri < rows.length; ri++) {\n      var row = rows[ri];\n\n      var targetContainer = (typeof(row.renderContainer) !== 'undefined' && row.renderContainer) ? row.renderContainer : 'body';\n\n      // If the row is visible\n      if (row.visible) {\n        self.renderContainers[targetContainer].visibleRowCache.push(row);\n      }\n    }\n    self.api.core.raise.rowsRendered(this.api);\n  };\n\n  /**\n   * @ngdoc function\n   * @name registerColumnsProcessor\n   * @methodOf ui.grid.class:Grid\n   * @param {function(renderedColumnsToProcess, rows)} columnProcessor column processor function, which\n   * is run in the context of the grid (i.e. this for the function will be the grid), and\n   * which must return an updated renderedColumnsToProcess which can be passed to the next processor\n   * in the chain\n   * @param {number} priority the priority of this processor.  In general we try to do them in 100s to leave room\n   * for other people to inject columns processors at intermediate priorities.  Lower priority columnsProcessors run earlier.\n   *\n   * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)\n   * @description\n\n     Register a \"columns processor\" function. When the columns are updated,\n     the grid calls each registered \"columns processor\", which has a chance\n     to alter the set of columns, as long as the count is not modified.\n   */\n  Grid.prototype.registerColumnsProcessor = function registerColumnsProcessor(processor, priority) {\n    if (!angular.isFunction(processor)) {\n      throw 'Attempt to register non-function rows processor: ' + processor;\n    }\n\n    this.columnsProcessors.push({processor: processor, priority: priority});\n    this.columnsProcessors.sort(function sortByPriority( a, b ){\n      return a.priority - b.priority;\n    });\n  };\n\n  Grid.prototype.removeColumnsProcessor = function removeColumnsProcessor(processor) {\n    var idx = this.columnsProcessors.indexOf(processor);\n\n    if (typeof(idx) !== 'undefined' && idx !== undefined) {\n      this.columnsProcessors.splice(idx, 1);\n    }\n  };\n\n  Grid.prototype.processColumnsProcessors = function processColumnsProcessors(renderableColumns) {\n    var self = this;\n\n    // Create a shallow copy of the rows so that we can safely sort them without altering the original grid.rows sort order\n    var myRenderableColumns = renderableColumns.slice(0);\n\n    // Return myRenderableRows with no processing if we have no rows processors\n    if (self.columnsProcessors.length === 0) {\n      return $q.when(myRenderableColumns);\n    }\n\n    // Counter for iterating through rows processors\n    var i = 0;\n\n    // Promise for when we're done with all the processors\n    var finished = $q.defer();\n\n    // This function will call the processor in self.rowsProcessors at index 'i', and then\n    //   when done will call the next processor in the list, using the output from the processor\n    //   at i as the argument for 'renderedRowsToProcess' on the next iteration.\n    //\n    //   If we're at the end of the list of processors, we resolve our 'finished' callback with\n    //   the result.\n    function startProcessor(i, renderedColumnsToProcess) {\n      // Get the processor at 'i'\n      var processor = self.columnsProcessors[i].processor;\n\n      // Call the processor, passing in the rows to process and the current columns\n      //   (note: it's wrapped in $q.when() in case the processor does not return a promise)\n      return $q.when( processor.call(self, renderedColumnsToProcess, self.rows) )\n        .then(function handleProcessedRows(processedColumns) {\n          // Check for errors\n          if (!processedColumns) {\n            throw \"Processor at index \" + i + \" did not return a set of renderable rows\";\n          }\n\n          if (!angular.isArray(processedColumns)) {\n            throw \"Processor at index \" + i + \" did not return an array\";\n          }\n\n          // Processor is done, increment the counter\n          i++;\n\n          // If we're not done with the processors, call the next one\n          if (i <= self.columnsProcessors.length - 1) {\n            return startProcessor(i, myRenderableColumns);\n          }\n          // We're done! Resolve the 'finished' promise\n          else {\n            finished.resolve(myRenderableColumns);\n          }\n        });\n    }\n\n    // Start on the first processor\n    startProcessor(0, myRenderableColumns);\n\n    return finished.promise;\n  };\n\n  Grid.prototype.setVisibleColumns = function setVisibleColumns(columns) {\n    // gridUtil.logDebug('setVisibleColumns');\n\n    var self = this;\n\n    // Reset all the render container row caches\n    for (var i in self.renderContainers) {\n      var container = self.renderContainers[i];\n\n      container.visibleColumnCache.length = 0;\n    }\n\n    for (var ci = 0; ci < columns.length; ci++) {\n      var column = columns[ci];\n\n      // If the column is visible\n      if (column.visible) {\n        // If the column has a container specified\n        if (typeof(column.renderContainer) !== 'undefined' && column.renderContainer) {\n          self.renderContainers[column.renderContainer].visibleColumnCache.push(column);\n        }\n        // If not, put it into the body container\n        else {\n          self.renderContainers.body.visibleColumnCache.push(column);\n        }\n      }\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name handleWindowResize\n   * @methodOf ui.grid.class:Grid\n   * @description Triggered when the browser window resizes; automatically resizes the grid\n   * @returns {Promise} A resolved promise once the window resize has completed.\n   */\n  Grid.prototype.handleWindowResize = function handleWindowResize($event) {\n    var self = this;\n\n    self.gridWidth = gridUtil.elementWidth(self.element);\n    self.gridHeight = gridUtil.elementHeight(self.element);\n\n    return self.queueRefresh();\n  };\n\n  /**\n   * @ngdoc function\n   * @name queueRefresh\n   * @methodOf ui.grid.class:Grid\n   * @description queues a grid refreshCanvas, a way of debouncing all the refreshes we might otherwise issue\n   */\n  Grid.prototype.queueRefresh = function queueRefresh() {\n    var self = this;\n\n    if (self.refreshCanceller) {\n      $timeout.cancel(self.refreshCanceller);\n    }\n\n    self.refreshCanceller = $timeout(function () {\n      self.refreshCanvas(true);\n    });\n\n    self.refreshCanceller.then(function () {\n      self.refreshCanceller = null;\n    });\n\n    return self.refreshCanceller;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name queueGridRefresh\n   * @methodOf ui.grid.class:Grid\n   * @description queues a grid refresh, a way of debouncing all the refreshes we might otherwise issue\n   */\n  Grid.prototype.queueGridRefresh = function queueGridRefresh() {\n    var self = this;\n\n    if (self.gridRefreshCanceller) {\n      $timeout.cancel(self.gridRefreshCanceller);\n    }\n\n    self.gridRefreshCanceller = $timeout(function () {\n      self.refresh(true);\n    });\n\n    self.gridRefreshCanceller.then(function () {\n      self.gridRefreshCanceller = null;\n    });\n\n    return self.gridRefreshCanceller;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name updateCanvasHeight\n   * @methodOf ui.grid.class:Grid\n   * @description flags all render containers to update their canvas height\n   */\n  Grid.prototype.updateCanvasHeight = function updateCanvasHeight() {\n    var self = this;\n\n    for (var containerId in self.renderContainers) {\n      if (self.renderContainers.hasOwnProperty(containerId)) {\n        var container = self.renderContainers[containerId];\n        container.canvasHeightShouldUpdate = true;\n      }\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name buildStyles\n   * @methodOf ui.grid.class:Grid\n   * @description calls each styleComputation function\n   */\n  // TODO: this used to take $scope, but couldn't see that it was used\n  Grid.prototype.buildStyles = function buildStyles() {\n    // gridUtil.logDebug('buildStyles');\n\n    var self = this;\n\n    self.customStyles = '';\n\n    self.styleComputations\n      .sort(function(a, b) {\n        if (a.priority === null) { return 1; }\n        if (b.priority === null) { return -1; }\n        if (a.priority === null && b.priority === null) { return 0; }\n        return a.priority - b.priority;\n      })\n      .forEach(function (compInfo) {\n        // this used to provide $scope as a second parameter, but I couldn't find any\n        // style builders that used it, so removed it as part of moving to grid from controller\n        var ret = compInfo.func.call(self);\n\n        if (angular.isString(ret)) {\n          self.customStyles += '\\n' + ret;\n        }\n      });\n  };\n\n\n  Grid.prototype.minColumnsToRender = function minColumnsToRender() {\n    var self = this;\n    var viewport = this.getViewportWidth();\n\n    var min = 0;\n    var totalWidth = 0;\n    self.columns.forEach(function(col, i) {\n      if (totalWidth < viewport) {\n        totalWidth += col.drawnWidth;\n        min++;\n      }\n      else {\n        var currWidth = 0;\n        for (var j = i; j >= i - min; j--) {\n          currWidth += self.columns[j].drawnWidth;\n        }\n        if (currWidth < viewport) {\n          min++;\n        }\n      }\n    });\n\n    return min;\n  };\n\n  Grid.prototype.getBodyHeight = function getBodyHeight() {\n    // Start with the viewportHeight\n    var bodyHeight = this.getViewportHeight();\n\n    // Add the horizontal scrollbar height if there is one\n    //if (typeof(this.horizontalScrollbarHeight) !== 'undefined' && this.horizontalScrollbarHeight !== undefined && this.horizontalScrollbarHeight > 0) {\n    //  bodyHeight = bodyHeight + this.horizontalScrollbarHeight;\n    //}\n\n    return bodyHeight;\n  };\n\n  // NOTE: viewport drawable height is the height of the grid minus the header row height (including any border)\n  // TODO(c0bra): account for footer height\n  Grid.prototype.getViewportHeight = function getViewportHeight() {\n    var self = this;\n\n    var viewPortHeight = this.gridHeight - this.headerHeight - this.footerHeight;\n\n    // Account for native horizontal scrollbar, if present\n    //if (typeof(this.horizontalScrollbarHeight) !== 'undefined' && this.horizontalScrollbarHeight !== undefined && this.horizontalScrollbarHeight > 0) {\n    //  viewPortHeight = viewPortHeight - this.horizontalScrollbarHeight;\n    //}\n\n    var adjustment = self.getViewportAdjustment();\n\n    viewPortHeight = viewPortHeight + adjustment.height;\n\n    //gridUtil.logDebug('viewPortHeight', viewPortHeight);\n\n    return viewPortHeight;\n  };\n\n  Grid.prototype.getViewportWidth = function getViewportWidth() {\n    var self = this;\n\n    var viewPortWidth = this.gridWidth;\n\n    //if (typeof(this.verticalScrollbarWidth) !== 'undefined' && this.verticalScrollbarWidth !== undefined && this.verticalScrollbarWidth > 0) {\n    //  viewPortWidth = viewPortWidth - this.verticalScrollbarWidth;\n    //}\n\n    var adjustment = self.getViewportAdjustment();\n\n    viewPortWidth = viewPortWidth + adjustment.width;\n\n    //gridUtil.logDebug('getviewPortWidth', viewPortWidth);\n\n    return viewPortWidth;\n  };\n\n  Grid.prototype.getHeaderViewportWidth = function getHeaderViewportWidth() {\n    var viewPortWidth = this.getViewportWidth();\n\n    //if (typeof(this.verticalScrollbarWidth) !== 'undefined' && this.verticalScrollbarWidth !== undefined && this.verticalScrollbarWidth > 0) {\n    //  viewPortWidth = viewPortWidth + this.verticalScrollbarWidth;\n    //}\n\n    return viewPortWidth;\n  };\n\n  Grid.prototype.addVerticalScrollSync = function (containerId, callBackFn) {\n    this.verticalScrollSyncCallBackFns[containerId] = callBackFn;\n  };\n\n  Grid.prototype.addHorizontalScrollSync = function (containerId, callBackFn) {\n    this.horizontalScrollSyncCallBackFns[containerId] = callBackFn;\n  };\n\n/**\n * Scroll needed containers by calling their ScrollSyncs\n * @param sourceContainerId the containerId that has already set it's top/left.\n *         can be empty string which means all containers need to set top/left\n * @param scrollEvent\n */\n  Grid.prototype.scrollContainers = function (sourceContainerId, scrollEvent) {\n\n    if (scrollEvent.y) {\n      //default for no container Id (ex. mousewheel means that all containers must set scrollTop/Left)\n      var verts = ['body','left', 'right'];\n\n      this.flagScrollingVertically(scrollEvent);\n\n      if (sourceContainerId === 'body') {\n        verts = ['left', 'right'];\n      }\n      else if (sourceContainerId === 'left') {\n        verts = ['body', 'right'];\n      }\n      else if (sourceContainerId === 'right') {\n        verts = ['body', 'left'];\n      }\n\n      for (var i = 0; i < verts.length; i++) {\n        var id = verts[i];\n        if (this.verticalScrollSyncCallBackFns[id]) {\n          this.verticalScrollSyncCallBackFns[id](scrollEvent);\n        }\n      }\n\n    }\n\n    if (scrollEvent.x) {\n      //default for no container Id (ex. mousewheel means that all containers must set scrollTop/Left)\n      var horizs = ['body','bodyheader', 'bodyfooter'];\n\n      this.flagScrollingHorizontally(scrollEvent);\n      if (sourceContainerId === 'body') {\n        horizs = ['bodyheader', 'bodyfooter'];\n      }\n\n      for (var j = 0; j < horizs.length; j++) {\n        var idh = horizs[j];\n        if (this.horizontalScrollSyncCallBackFns[idh]) {\n          this.horizontalScrollSyncCallBackFns[idh](scrollEvent);\n        }\n      }\n\n    }\n\n  };\n\n  Grid.prototype.registerViewportAdjuster = function registerViewportAdjuster(func) {\n    this.viewportAdjusters.push(func);\n  };\n\n  Grid.prototype.removeViewportAdjuster = function registerViewportAdjuster(func) {\n    var idx = this.viewportAdjusters.indexOf(func);\n\n    if (typeof(idx) !== 'undefined' && idx !== undefined) {\n      this.viewportAdjusters.splice(idx, 1);\n    }\n  };\n\n  Grid.prototype.getViewportAdjustment = function getViewportAdjustment() {\n    var self = this;\n\n    var adjustment = { height: 0, width: 0 };\n\n    self.viewportAdjusters.forEach(function (func) {\n      adjustment = func.call(this, adjustment);\n    });\n\n    return adjustment;\n  };\n\n  Grid.prototype.getVisibleRowCount = function getVisibleRowCount() {\n    // var count = 0;\n\n    // this.rows.forEach(function (row) {\n    //   if (row.visible) {\n    //     count++;\n    //   }\n    // });\n\n    // return this.visibleRowCache.length;\n    return this.renderContainers.body.visibleRowCache.length;\n  };\n\n   Grid.prototype.getVisibleRows = function getVisibleRows() {\n    return this.renderContainers.body.visibleRowCache;\n   };\n\n  Grid.prototype.getVisibleColumnCount = function getVisibleColumnCount() {\n    // var count = 0;\n\n    // this.rows.forEach(function (row) {\n    //   if (row.visible) {\n    //     count++;\n    //   }\n    // });\n\n    // return this.visibleRowCache.length;\n    return this.renderContainers.body.visibleColumnCache.length;\n  };\n\n\n  Grid.prototype.searchRows = function searchRows(renderableRows) {\n    return rowSearcher.search(this, renderableRows, this.columns);\n  };\n\n  Grid.prototype.sortByColumn = function sortByColumn(renderableRows) {\n    return rowSorter.sort(this, renderableRows, this.columns);\n  };\n\n  /**\n   * @ngdoc function\n   * @name getCellValue\n   * @methodOf ui.grid.class:Grid\n   * @description Gets the value of a cell for a particular row and column\n   * @param {GridRow} row Row to access\n   * @param {GridColumn} col Column to access\n   */\n  Grid.prototype.getCellValue = function getCellValue(row, col){\n    if ( typeof(row.entity[ '$$' + col.uid ]) !== 'undefined' ) {\n      return row.entity[ '$$' + col.uid].rendered;\n    } else if (this.options.flatEntityAccess && typeof(col.field) !== 'undefined' ){\n      return row.entity[col.field];\n    } else {\n      if (!col.cellValueGetterCache) {\n        col.cellValueGetterCache = $parse(row.getEntityQualifiedColField(col));\n      }\n\n      return col.cellValueGetterCache(row);\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name getCellDisplayValue\n   * @methodOf ui.grid.class:Grid\n   * @description Gets the displayed value of a cell after applying any the `cellFilter`\n   * @param {GridRow} row Row to access\n   * @param {GridColumn} col Column to access\n   */\n  Grid.prototype.getCellDisplayValue = function getCellDisplayValue(row, col) {\n    if ( !col.cellDisplayGetterCache ) {\n      var custom_filter = col.cellFilter ? \" | \" + col.cellFilter : \"\";\n\n      if (typeof(row.entity['$$' + col.uid]) !== 'undefined') {\n        col.cellDisplayGetterCache = $parse(row.entity['$$' + col.uid].rendered + custom_filter);\n      } else if (this.options.flatEntityAccess && typeof(col.field) !== 'undefined') {\n        col.cellDisplayGetterCache = $parse(row.entity[col.field] + custom_filter);\n      } else {\n        col.cellDisplayGetterCache = $parse(row.getEntityQualifiedColField(col) + custom_filter);\n      }\n    }\n\n    return col.cellDisplayGetterCache(row);\n  };\n\n\n  Grid.prototype.getNextColumnSortPriority = function getNextColumnSortPriority() {\n    var self = this,\n        p = 0;\n\n    self.columns.forEach(function (col) {\n      if (col.sort && col.sort.priority !== undefined && col.sort.priority >= p) {\n        p = col.sort.priority + 1;\n      }\n    });\n\n    return p;\n  };\n\n  /**\n   * @ngdoc function\n   * @name resetColumnSorting\n   * @methodOf ui.grid.class:Grid\n   * @description Return the columns that the grid is currently being sorted by\n   * @param {GridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset\n   */\n  Grid.prototype.resetColumnSorting = function resetColumnSorting(excludeCol) {\n    var self = this;\n\n    self.columns.forEach(function (col) {\n      if (col !== excludeCol && !col.suppressRemoveSort) {\n        col.sort = {};\n      }\n    });\n  };\n\n  /**\n   * @ngdoc function\n   * @name getColumnSorting\n   * @methodOf ui.grid.class:Grid\n   * @description Return the columns that the grid is currently being sorted by\n   * @returns {Array[GridColumn]} An array of GridColumn objects\n   */\n  Grid.prototype.getColumnSorting = function getColumnSorting() {\n    var self = this;\n\n    var sortedCols = [], myCols;\n\n    // Iterate through all the columns, sorted by priority\n    // Make local copy of column list, because sorting is in-place and we do not want to\n    // change the original sequence of columns\n    myCols = self.columns.slice(0);\n    myCols.sort(rowSorter.prioritySort).forEach(function (col) {\n      if (col.sort && typeof(col.sort.direction) !== 'undefined' && col.sort.direction && (col.sort.direction === uiGridConstants.ASC || col.sort.direction === uiGridConstants.DESC)) {\n        sortedCols.push(col);\n      }\n    });\n\n    return sortedCols;\n  };\n\n  /**\n   * @ngdoc function\n   * @name sortColumn\n   * @methodOf ui.grid.class:Grid\n   * @description Set the sorting on a given column, optionally resetting any existing sorting on the Grid.\n   * Emits the sortChanged event whenever the sort criteria are changed.\n   * @param {GridColumn} column Column to set the sorting on\n   * @param {uiGridConstants.ASC|uiGridConstants.DESC} [direction] Direction to sort by, either descending or ascending.\n   *   If not provided, the column will iterate through the sort directions\n   *   specified in the {@link ui.grid.class:GridOptions.columnDef#sortDirectionCycle sortDirectionCycle} attribute.\n   * @param {boolean} [add] Add this column to the sorting. If not provided or set to `false`, the Grid will reset any existing sorting and sort\n   *   by this column only\n   * @returns {Promise} A resolved promise that supplies the column.\n   */\n\n  Grid.prototype.sortColumn = function sortColumn(column, directionOrAdd, add) {\n    var self = this,\n        direction = null;\n\n    if (typeof(column) === 'undefined' || !column) {\n      throw new Error('No column parameter provided');\n    }\n\n    // Second argument can either be a direction or whether to add this column to the existing sort.\n    //   If it's a boolean, it's an add, otherwise, it's a direction\n    if (typeof(directionOrAdd) === 'boolean') {\n      add = directionOrAdd;\n    }\n    else {\n      direction = directionOrAdd;\n    }\n\n    if (!add) {\n      self.resetColumnSorting(column);\n      column.sort.priority = undefined;\n      // Get the actual priority since there may be columns which have suppressRemoveSort set\n      column.sort.priority = self.getNextColumnSortPriority();\n    }\n    else if (!column.sort.priority){\n      column.sort.priority = self.getNextColumnSortPriority();\n    }\n\n    if (!direction) {\n      // Find the current position in the cycle (or -1).\n      var i = column.sortDirectionCycle.indexOf(column.sort.direction ? column.sort.direction : null);\n      // Proceed to the next position in the cycle (or start at the beginning).\n      i = (i+1) % column.sortDirectionCycle.length;\n      // If suppressRemoveSort is set, and the next position in the cycle would\n      // remove the sort, skip it.\n      if (column.colDef && column.suppressRemoveSort && !column.sortDirectionCycle[i]) {\n        i = (i+1) % column.sortDirectionCycle.length;\n      }\n\n      if (column.sortDirectionCycle[i]) {\n        column.sort.direction = column.sortDirectionCycle[i];\n      } else {\n        column.sort = {};\n      }\n    }\n    else {\n      column.sort.direction = direction;\n    }\n\n    self.api.core.raise.sortChanged( self, self.getColumnSorting() );\n\n    return $q.when(column);\n  };\n\n  /**\n   * communicate to outside world that we are done with initial rendering\n   */\n  Grid.prototype.renderingComplete = function(){\n    if (angular.isFunction(this.options.onRegisterApi)) {\n      this.options.onRegisterApi(this.api);\n    }\n    this.api.core.raise.renderingComplete( this.api );\n  };\n\n  Grid.prototype.createRowHashMap = function createRowHashMap() {\n    var self = this;\n\n    var hashMap = new RowHashMap();\n    hashMap.grid = self;\n\n    return hashMap;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name refresh\n   * @methodOf ui.grid.class:Grid\n   * @description Refresh the rendered grid on screen.\n   * @param {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed.\n   */\n  Grid.prototype.refresh = function refresh(rowsAltered) {\n    var self = this;\n\n    var p1 = self.processRowsProcessors(self.rows).then(function (renderableRows) {\n      self.setVisibleRows(renderableRows);\n    });\n\n    var p2 = self.processColumnsProcessors(self.columns).then(function (renderableColumns) {\n      self.setVisibleColumns(renderableColumns);\n    });\n\n    return $q.all([p1, p2]).then(function () {\n      self.redrawInPlace(rowsAltered);\n\n      self.refreshCanvas(true);\n    });\n  };\n\n  /**\n   * @ngdoc function\n   * @name refreshRows\n   * @methodOf ui.grid.class:Grid\n   * @description Refresh the rendered rows on screen?  Note: not functional at present\n   * @returns {promise} promise that is resolved when render completes?\n   *\n   */\n  Grid.prototype.refreshRows = function refreshRows() {\n    var self = this;\n\n    return self.processRowsProcessors(self.rows)\n      .then(function (renderableRows) {\n        self.setVisibleRows(renderableRows);\n\n        self.redrawInPlace();\n\n        self.refreshCanvas( true );\n      });\n  };\n\n  /**\n   * @ngdoc function\n   * @name refreshCanvas\n   * @methodOf ui.grid.class:Grid\n   * @description Builds all styles and recalculates much of the grid sizing\n   * @param {object} buildStyles optional parameter.  Use TBD\n   * @returns {promise} promise that is resolved when the canvas\n   * has been refreshed\n   *\n   */\n  Grid.prototype.refreshCanvas = function(buildStyles) {\n    var self = this;\n\n    if (buildStyles) {\n      self.buildStyles();\n    }\n\n    var p = $q.defer();\n\n    // Get all the header heights\n    var containerHeadersToRecalc = [];\n    for (var containerId in self.renderContainers) {\n      if (self.renderContainers.hasOwnProperty(containerId)) {\n        var container = self.renderContainers[containerId];\n\n        // Skip containers that have no canvasWidth set yet\n        if (container.canvasWidth === null || isNaN(container.canvasWidth)) {\n          continue;\n        }\n\n        if (container.header || container.headerCanvas) {\n          container.explicitHeaderHeight = container.explicitHeaderHeight || null;\n          container.explicitHeaderCanvasHeight = container.explicitHeaderCanvasHeight || null;\n\n          containerHeadersToRecalc.push(container);\n        }\n      }\n    }\n\n    /*\n     *\n     * Here we loop through the headers, measuring each element as well as any header \"canvas\" it has within it.\n     *\n     * If any header is less than the largest header height, it will be resized to that so that we don't have headers\n     * with different heights, which looks like a rendering problem\n     *\n     * We'll do the same thing with the header canvases, and give the header CELLS an explicit height if their canvas\n     * is smaller than the largest canvas height. That was header cells without extra controls like filtering don't\n     * appear shorter than other cells.\n     *\n     */\n    if (containerHeadersToRecalc.length > 0) {\n      // Build the styles without the explicit header heights\n      if (buildStyles) {\n        self.buildStyles();\n      }\n\n      // Putting in a timeout as it's not calculating after the grid element is rendered and filled out\n      $timeout(function() {\n        // var oldHeaderHeight = self.grid.headerHeight;\n        // self.grid.headerHeight = gridUtil.outerElementHeight(self.header);\n\n        var rebuildStyles = false;\n\n        // Get all the header heights\n        var maxHeaderHeight = 0;\n        var maxHeaderCanvasHeight = 0;\n        var i, container;\n        var getHeight = function(oldVal, newVal){\n          if ( oldVal !== newVal){\n            rebuildStyles = true;\n          }\n          return newVal;\n        };\n        for (i = 0; i < containerHeadersToRecalc.length; i++) {\n          container = containerHeadersToRecalc[i];\n\n          // Skip containers that have no canvasWidth set yet\n          if (container.canvasWidth === null || isNaN(container.canvasWidth)) {\n            continue;\n          }\n\n          if (container.header) {\n            var headerHeight = container.headerHeight = getHeight(container.headerHeight, parseInt(gridUtil.outerElementHeight(container.header), 10));\n\n            // Get the \"inner\" header height, that is the height minus the top and bottom borders, if present. We'll use it to make sure all the headers have a consistent height\n            var topBorder = gridUtil.getBorderSize(container.header, 'top');\n            var bottomBorder = gridUtil.getBorderSize(container.header, 'bottom');\n            var innerHeaderHeight = parseInt(headerHeight - topBorder - bottomBorder, 10);\n\n            innerHeaderHeight  = innerHeaderHeight < 0 ? 0 : innerHeaderHeight;\n\n            container.innerHeaderHeight = innerHeaderHeight;\n\n            // If the header doesn't have an explicit height set, save the largest header height for use later\n            //   Explicit header heights are based off of the max we are calculating here. We never want to base the max on something we're setting explicitly\n            if (!container.explicitHeaderHeight && innerHeaderHeight > maxHeaderHeight) {\n              maxHeaderHeight = innerHeaderHeight;\n            }\n          }\n\n          if (container.headerCanvas) {\n            var headerCanvasHeight = container.headerCanvasHeight = getHeight(container.headerCanvasHeight, parseInt(gridUtil.outerElementHeight(container.headerCanvas), 10));\n\n\n            // If the header doesn't have an explicit canvas height, save the largest header canvas height for use later\n            //   Explicit header heights are based off of the max we are calculating here. We never want to base the max on something we're setting explicitly\n            if (!container.explicitHeaderCanvasHeight && headerCanvasHeight > maxHeaderCanvasHeight) {\n              maxHeaderCanvasHeight = headerCanvasHeight;\n            }\n          }\n        }\n\n        // Go through all the headers\n        for (i = 0; i < containerHeadersToRecalc.length; i++) {\n          container = containerHeadersToRecalc[i];\n\n          /* If:\n              1. We have a max header height\n              2. This container has a header height defined\n              3. And either this container has an explicit header height set, OR its header height is less than the max\n\n              then:\n\n              Give this container's header an explicit height so it will line up with the tallest header\n          */\n          if (\n            maxHeaderHeight > 0 && typeof(container.headerHeight) !== 'undefined' && container.headerHeight !== null &&\n            (container.explicitHeaderHeight || container.headerHeight < maxHeaderHeight)\n          ) {\n            container.explicitHeaderHeight = getHeight(container.explicitHeaderHeight, maxHeaderHeight);\n          }\n\n          // Do the same as above except for the header canvas\n          if (\n            maxHeaderCanvasHeight > 0 && typeof(container.headerCanvasHeight) !== 'undefined' && container.headerCanvasHeight !== null &&\n            (container.explicitHeaderCanvasHeight || container.headerCanvasHeight < maxHeaderCanvasHeight)\n          ) {\n            container.explicitHeaderCanvasHeight = getHeight(container.explicitHeaderCanvasHeight, maxHeaderCanvasHeight);\n          }\n        }\n\n        // Rebuild styles if the header height has changed\n        //   The header height is used in body/viewport calculations and those are then used in other styles so we need it to be available\n        if (buildStyles && rebuildStyles) {\n          self.buildStyles();\n        }\n\n        p.resolve();\n      });\n    }\n    else {\n      // Timeout still needs to be here to trigger digest after styles have been rebuilt\n      $timeout(function() {\n        p.resolve();\n      });\n    }\n\n    return p.promise;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name redrawCanvas\n   * @methodOf ui.grid.class:Grid\n   * @description Redraw the rows and columns based on our current scroll position\n   * @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be recalculated\n   *\n   */\n  Grid.prototype.redrawInPlace = function redrawInPlace(rowsAdded) {\n    // gridUtil.logDebug('redrawInPlace');\n\n    var self = this;\n\n    for (var i in self.renderContainers) {\n      var container = self.renderContainers[i];\n\n      // gridUtil.logDebug('redrawing container', i);\n\n      if (rowsAdded) {\n        container.adjustRows(container.prevScrollTop, null);\n        container.adjustColumns(container.prevScrollLeft, null);\n      }\n      else {\n        container.adjustRows(null, container.prevScrolltopPercentage);\n        container.adjustColumns(null, container.prevScrollleftPercentage);\n      }\n    }\n  };\n\n    /**\n     * @ngdoc function\n     * @name hasLeftContainerColumns\n     * @methodOf ui.grid.class:Grid\n     * @description returns true if leftContainer has columns\n     */\n    Grid.prototype.hasLeftContainerColumns = function () {\n      return this.hasLeftContainer() && this.renderContainers.left.renderedColumns.length > 0;\n    };\n\n    /**\n     * @ngdoc function\n     * @name hasRightContainerColumns\n     * @methodOf ui.grid.class:Grid\n     * @description returns true if rightContainer has columns\n     */\n    Grid.prototype.hasRightContainerColumns = function () {\n      return this.hasRightContainer() && this.renderContainers.right.renderedColumns.length > 0;\n    };\n\n    /**\n     * @ngdoc method\n     * @methodOf  ui.grid.class:Grid\n     * @name scrollToIfNecessary\n     * @description Scrolls the grid to make a certain row and column combo visible,\n     *   in the case that it is not completely visible on the screen already.\n     * @param {GridRow} gridRow row to make visible\n     * @param {GridCol} gridCol column to make visible\n     * @returns {promise} a promise that is resolved when scrolling is complete\n     */\n    Grid.prototype.scrollToIfNecessary = function (gridRow, gridCol) {\n      var self = this;\n\n      var scrollEvent = new ScrollEvent(self, 'uiGrid.scrollToIfNecessary');\n\n      // Alias the visible row and column caches\n      var visRowCache = self.renderContainers.body.visibleRowCache;\n      var visColCache = self.renderContainers.body.visibleColumnCache;\n\n      /*-- Get the top, left, right, and bottom \"scrolled\" edges of the grid --*/\n\n      // The top boundary is the current Y scroll position PLUS the header height, because the header can obscure rows when the grid is scrolled downwards\n      var topBound = self.renderContainers.body.prevScrollTop + self.headerHeight;\n\n      // Don't the let top boundary be less than 0\n      topBound = (topBound < 0) ? 0 : topBound;\n\n      // The left boundary is the current X scroll position\n      var leftBound = self.renderContainers.body.prevScrollLeft;\n\n      // The bottom boundary is the current Y scroll position, plus the height of the grid, but minus the header height.\n      //   Basically this is the viewport height added on to the scroll position\n      var bottomBound = self.renderContainers.body.prevScrollTop + self.gridHeight - self.renderContainers.body.headerHeight - self.footerHeight -  self.scrollbarWidth;\n\n      // If there's a horizontal scrollbar, remove its height from the bottom boundary, otherwise we'll be letting it obscure rows\n      //if (self.horizontalScrollbarHeight) {\n      //  bottomBound = bottomBound - self.horizontalScrollbarHeight;\n      //}\n\n      // The right position is the current X scroll position minus the grid width\n      var rightBound = self.renderContainers.body.prevScrollLeft + Math.ceil(self.renderContainers.body.getViewportWidth());\n\n      // If there's a vertical scrollbar, subtract it from the right boundary or we'll allow it to obscure cells\n      //if (self.verticalScrollbarWidth) {\n      //  rightBound = rightBound - self.verticalScrollbarWidth;\n      //}\n\n      // We were given a row to scroll to\n      if (gridRow !== null) {\n        // This is the index of the row we want to scroll to, within the list of rows that can be visible\n        var seekRowIndex = visRowCache.indexOf(gridRow);\n\n        // Total vertical scroll length of the grid\n        var scrollLength = (self.renderContainers.body.getCanvasHeight() - self.renderContainers.body.getViewportHeight());\n\n        // Add the height of the native horizontal scrollbar to the scroll length, if it's there. Otherwise it will mask over the final row\n        //if (self.horizontalScrollbarHeight && self.horizontalScrollbarHeight > 0) {\n        //  scrollLength = scrollLength + self.horizontalScrollbarHeight;\n        //}\n\n        // This is the minimum amount of pixels we need to scroll vertical in order to see this row.\n        var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight + self.headerHeight);\n\n        // Don't let the pixels required to see the row be less than zero\n        pixelsToSeeRow = (pixelsToSeeRow < 0) ? 0 : pixelsToSeeRow;\n\n        var scrollPixels, percentage;\n\n        // If the scroll position we need to see the row is LESS than the top boundary, i.e. obscured above the top of the self...\n        if (pixelsToSeeRow < topBound) {\n          // Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\\\n          //   to get the full position we need\n          scrollPixels = self.renderContainers.body.prevScrollTop - (topBound - pixelsToSeeRow);\n\n          // Turn the scroll position into a percentage and make it an argument for a scroll event\n          percentage = scrollPixels / scrollLength;\n          scrollEvent.y = { percentage: percentage  };\n        }\n        // Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...\n        else if (pixelsToSeeRow > bottomBound) {\n          // Get the different between the bottom boundary and the required scroll position and add it to the current scroll position\n          //   to get the full position we need\n          scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop;\n\n          // Turn the scroll position into a percentage and make it an argument for a scroll event\n          percentage = scrollPixels / scrollLength;\n          scrollEvent.y = { percentage: percentage  };\n        }\n      }\n\n      // We were given a column to scroll to\n      if (gridCol !== null) {\n        // This is the index of the row we want to scroll to, within the list of rows that can be visible\n        var seekColumnIndex = visColCache.indexOf(gridCol);\n\n        // Total vertical scroll length of the grid\n        var horizScrollLength = (self.renderContainers.body.getCanvasWidth() - self.renderContainers.body.getViewportWidth());\n\n        // Add the height of the native horizontal scrollbar to the scroll length, if it's there. Otherwise it will mask over the final row\n        // if (self.verticalScrollbarWidth && self.verticalScrollbarWidth > 0) {\n        //   horizScrollLength = horizScrollLength + self.verticalScrollbarWidth;\n        // }\n\n        // This is the minimum amount of pixels we need to scroll vertical in order to see this column\n        var columnLeftEdge = 0;\n        for (var i = 0; i < seekColumnIndex; i++) {\n          var col = visColCache[i];\n          columnLeftEdge += col.drawnWidth;\n        }\n        columnLeftEdge = (columnLeftEdge < 0) ? 0 : columnLeftEdge;\n\n        var columnRightEdge = columnLeftEdge + gridCol.drawnWidth;\n\n        // Don't let the pixels required to see the column be less than zero\n        columnRightEdge = (columnRightEdge < 0) ? 0 : columnRightEdge;\n\n        var horizScrollPixels, horizPercentage;\n\n        // If the scroll position we need to see the row is LESS than the top boundary, i.e. obscured above the top of the self...\n        if (columnLeftEdge < leftBound) {\n          // Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\\\n          //   to get the full position we need\n          horizScrollPixels = self.renderContainers.body.prevScrollLeft - (leftBound - columnLeftEdge);\n\n          // Turn the scroll position into a percentage and make it an argument for a scroll event\n          horizPercentage = horizScrollPixels / horizScrollLength;\n          horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;\n          scrollEvent.x = { percentage: horizPercentage  };\n        }\n        // Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...\n        else if (columnRightEdge > rightBound) {\n          // Get the different between the bottom boundary and the required scroll position and add it to the current scroll position\n          //   to get the full position we need\n          horizScrollPixels = columnRightEdge - rightBound + self.renderContainers.body.prevScrollLeft;\n\n          // Turn the scroll position into a percentage and make it an argument for a scroll event\n          horizPercentage = horizScrollPixels / horizScrollLength;\n          horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;\n          scrollEvent.x = { percentage: horizPercentage  };\n        }\n      }\n\n      var deferred = $q.defer();\n\n      // If we need to scroll on either the x or y axes, fire a scroll event\n      if (scrollEvent.y || scrollEvent.x) {\n        scrollEvent.withDelay = false;\n        self.scrollContainers('',scrollEvent);\n        var dereg = self.api.core.on.scrollEnd(null,function() {\n          deferred.resolve(scrollEvent);\n          dereg();\n        });\n      }\n      else {\n        deferred.resolve();\n      }\n\n      return deferred.promise;\n    };\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.class:Grid\n     * @name scrollTo\n     * @description Scroll the grid such that the specified\n     * row and column is in view\n     * @param {object} rowEntity gridOptions.data[] array instance to make visible\n     * @param {object} colDef to make visible\n     * @returns {promise} a promise that is resolved after any scrolling is finished\n     */\n    Grid.prototype.scrollTo = function (rowEntity, colDef) {\n      var gridRow = null, gridCol = null;\n\n      if (rowEntity !== null && typeof(rowEntity) !== 'undefined' ) {\n        gridRow = this.getRow(rowEntity);\n      }\n\n      if (colDef !== null && typeof(colDef) !== 'undefined' ) {\n        gridCol = this.getColumn(colDef.name ? colDef.name : colDef.field);\n      }\n      return this.scrollToIfNecessary(gridRow, gridCol);\n    };\n\n  /**\n   * @ngdoc function\n   * @name clearAllFilters\n   * @methodOf ui.grid.class:Grid\n   * @description Clears all filters and optionally refreshes the visible rows.\n   * @param {object} refreshRows Defaults to true.\n   * @param {object} clearConditions Defaults to false.\n   * @param {object} clearFlags Defaults to false.\n   * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing.\n   */\n  Grid.prototype.clearAllFilters = function clearAllFilters(refreshRows, clearConditions, clearFlags) {\n    // Default `refreshRows` to true because it will be the most commonly desired behaviour.\n    if (refreshRows === undefined) {\n      refreshRows = true;\n    }\n    if (clearConditions === undefined) {\n      clearConditions = false;\n    }\n    if (clearFlags === undefined) {\n      clearFlags = false;\n    }\n\n    this.columns.forEach(function(column) {\n      column.filters.forEach(function(filter) {\n        filter.term = undefined;\n\n        if (clearConditions) {\n          filter.condition = undefined;\n        }\n\n        if (clearFlags) {\n          filter.flags = undefined;\n        }\n      });\n    });\n\n    if (refreshRows) {\n      return this.refreshRows();\n    }\n  };\n\n\n      // Blatantly stolen from Angular as it isn't exposed (yet? 2.0?)\n  function RowHashMap() {}\n\n  RowHashMap.prototype = {\n    /**\n     * Store key value pair\n     * @param key key to store can be any type\n     * @param value value to store can be any type\n     */\n    put: function(key, value) {\n      this[this.grid.options.rowIdentity(key)] = value;\n    },\n\n    /**\n     * @param key\n     * @returns {Object} the value for the key\n     */\n    get: function(key) {\n      return this[this.grid.options.rowIdentity(key)];\n    },\n\n    /**\n     * Remove the key/value pair\n     * @param key\n     */\n    remove: function(key) {\n      var value = this[key = this.grid.options.rowIdentity(key)];\n      delete this[key];\n      return value;\n    }\n  };\n\n\n\n  return Grid;\n\n}]);\n\n})();\n\n(function () {\n\n  angular.module('ui.grid')\n    .factory('GridApi', ['$q', '$rootScope', 'gridUtil', 'uiGridConstants', 'GridRow', 'uiGridGridMenuService',\n      function ($q, $rootScope, gridUtil, uiGridConstants, GridRow, uiGridGridMenuService) {\n        /**\n         * @ngdoc function\n         * @name ui.grid.class:GridApi\n         * @description GridApi provides the ability to register public methods events inside the grid and allow\n         * for other components to use the api via featureName.raise.methodName and featureName.on.eventName(function(args){}.\n         * <br/>\n         * To listen to events, you must add a callback to gridOptions.onRegisterApi\n         * <pre>\n         *   $scope.gridOptions.onRegisterApi = function(gridApi){\n         *      gridApi.cellNav.on.navigate($scope,function(newRowCol, oldRowCol){\n         *          $log.log('navigation event');\n         *      });\n         *   };\n         * </pre>\n         * @param {object} grid grid that owns api\n         */\n        var GridApi = function GridApi(grid) {\n          this.grid = grid;\n          this.listeners = [];\n          \n          /**\n           * @ngdoc function\n           * @name renderingComplete\n           * @methodOf  ui.grid.core.api:PublicApi\n           * @description Rendering is complete, called at the same\n           * time as `onRegisterApi`, but provides a way to obtain\n           * that same event within features without stopping end\n           * users from getting at the onRegisterApi method.\n           * \n           * Included in gridApi so that it's always there - otherwise\n           * there is still a timing problem with when a feature can\n           * call this. \n           * \n           * @param {GridApi} gridApi the grid api, as normally \n           * returned in the onRegisterApi method\n           * \n           * @example\n           * <pre>\n           *      gridApi.core.on.renderingComplete( grid );\n           * </pre>\n           */\n          this.registerEvent( 'core', 'renderingComplete' );\n\n          /**\n           * @ngdoc event\n           * @name filterChanged\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised after the filter is changed.  The nature\n           * of the watch expression doesn't allow notification of what changed,\n           * so the receiver of this event will need to re-extract the filter \n           * conditions from the columns.\n           * \n           */\n          this.registerEvent( 'core', 'filterChanged' );\n\n          /**\n           * @ngdoc function\n           * @name setRowInvisible\n           * @methodOf  ui.grid.core.api:PublicApi\n           * @description Sets an override on the row to make it always invisible,\n           * which will override any filtering or other visibility calculations.  \n           * If the row is currently visible then sets it to invisible and calls\n           * both grid refresh and emits the rowsVisibleChanged event\n           * @param {object} rowEntity gridOptions.data[] array instance\n           */\n          this.registerMethod( 'core', 'setRowInvisible', GridRow.prototype.setRowInvisible );\n      \n          /**\n           * @ngdoc function\n           * @name clearRowInvisible\n           * @methodOf  ui.grid.core.api:PublicApi\n           * @description Clears any override on visibility for the row so that it returns to \n           * using normal filtering and other visibility calculations.  \n           * If the row is currently invisible then sets it to visible and calls\n           * both grid refresh and emits the rowsVisibleChanged event\n           * TODO: if a filter is active then we can't just set it to visible?\n           * @param {object} rowEntity gridOptions.data[] array instance\n           */\n          this.registerMethod( 'core', 'clearRowInvisible', GridRow.prototype.clearRowInvisible );\n      \n          /**\n           * @ngdoc function\n           * @name getVisibleRows\n           * @methodOf  ui.grid.core.api:PublicApi\n           * @description Returns all visible rows\n           * @param {Grid} grid the grid you want to get visible rows from\n           * @returns {array} an array of gridRow\n           */\n          this.registerMethod( 'core', 'getVisibleRows', this.grid.getVisibleRows );\n          \n          /**\n           * @ngdoc event\n           * @name rowsVisibleChanged\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised after the rows that are visible\n           * change.  The filtering is zero-based, so it isn't possible\n           * to say which rows changed (unlike in the selection feature).\n           * We can plausibly know which row was changed when setRowInvisible\n           * is called, but in that situation the user already knows which row\n           * they changed.  When a filter runs we don't know what changed,\n           * and that is the one that would have been useful.\n           *\n           */\n          this.registerEvent( 'core', 'rowsVisibleChanged' );\n\n          /**\n           * @ngdoc event\n           * @name rowsRendered\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised after the cache of visible rows is changed.\n           */\n          this.registerEvent( 'core', 'rowsRendered' );\n\n\n          /**\n           * @ngdoc event\n           * @name scrollBegin\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised when scroll begins.  Is throttled, so won't be raised too frequently\n           */\n          this.registerEvent( 'core', 'scrollBegin' );\n\n          /**\n           * @ngdoc event\n           * @name scrollEnd\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised when scroll has finished.  Is throttled, so won't be raised too frequently\n           */\n          this.registerEvent( 'core', 'scrollEnd' );\n\n          /**\n           * @ngdoc event\n           * @name canvasHeightChanged\n           * @eventOf  ui.grid.core.api:PublicApi\n           * @description  is raised when the canvas height has changed\n           * <br/>\n           * arguments: oldHeight, newHeight\n           */\n          this.registerEvent( 'core', 'canvasHeightChanged');\n        };\n\n        /**\n         * @ngdoc function\n         * @name ui.grid.class:suppressEvents\n         * @methodOf ui.grid.class:GridApi\n         * @description Used to execute a function while disabling the specified event listeners.\n         * Disables the listenerFunctions, executes the callbackFn, and then enables\n         * the listenerFunctions again\n         * @param {object} listenerFuncs listenerFunc or array of listenerFuncs to suppress. These must be the same\n         * functions that were used in the .on.eventName method\n         * @param {object} callBackFn function to execute\n         * @example\n         * <pre>\n         *    var navigate = function (newRowCol, oldRowCol){\n         *       //do something on navigate\n         *    }\n         *\n         *    gridApi.cellNav.on.navigate(scope,navigate);\n         *\n         *\n         *    //call the scrollTo event and suppress our navigate listener\n         *    //scrollTo will still raise the event for other listeners\n         *    gridApi.suppressEvents(navigate, function(){\n         *       gridApi.cellNav.scrollTo(aRow, aCol);\n         *    });\n         *\n         * </pre>\n         */\n        GridApi.prototype.suppressEvents = function (listenerFuncs, callBackFn) {\n          var self = this;\n          var listeners = angular.isArray(listenerFuncs) ? listenerFuncs : [listenerFuncs];\n\n          //find all registered listeners\n          var foundListeners = self.listeners.filter(function(listener) {\n            return listeners.some(function(l) {\n              return listener.handler === l;\n            });\n          });\n\n          //deregister all the listeners\n          foundListeners.forEach(function(l){\n            l.dereg();\n          });\n\n          callBackFn();\n\n          //reregister all the listeners\n          foundListeners.forEach(function(l){\n              l.dereg = registerEventWithAngular(l.eventId, l.handler, self.grid, l._this);\n          });\n\n        };\n\n        /**\n         * @ngdoc function\n         * @name registerEvent\n         * @methodOf ui.grid.class:GridApi\n         * @description Registers a new event for the given feature.  The event will get a\n         * .raise and .on prepended to it\n         * <br>\n         * .raise.eventName() - takes no arguments\n         * <br/>\n         * <br/>\n         * .on.eventName(scope, callBackFn, _this)\n         * <br/>\n         * scope - a scope reference to add a deregister call to the scopes .$on('destroy').  Scope is optional and can be a null value,\n         * but in this case you must deregister it yourself via the returned deregister function\n         * <br/>\n         * callBackFn - The function to call\n         * <br/>\n         * _this - optional this context variable for callbackFn. If omitted, grid.api will be used for the context\n         * <br/>\n         * .on.eventName returns a dereg funtion that will remove the listener.  It's not necessary to use it as the listener\n         * will be removed when the scope is destroyed.\n         * @param {string} featureName name of the feature that raises the event\n         * @param {string} eventName  name of the event\n         */\n        GridApi.prototype.registerEvent = function (featureName, eventName) {\n          var self = this;\n          if (!self[featureName]) {\n            self[featureName] = {};\n          }\n\n          var feature = self[featureName];\n          if (!feature.on) {\n            feature.on = {};\n            feature.raise = {};\n          }\n\n          var eventId = self.grid.id + featureName + eventName;\n\n          // gridUtil.logDebug('Creating raise event method ' + featureName + '.raise.' + eventName);\n          feature.raise[eventName] = function () {\n            $rootScope.$emit.apply($rootScope, [eventId].concat(Array.prototype.slice.call(arguments)));\n          };\n\n          // gridUtil.logDebug('Creating on event method ' + featureName + '.on.' + eventName);\n          feature.on[eventName] = function (scope, handler, _this) {\n            if ( scope !== null && typeof(scope.$on) === 'undefined' ){\n              gridUtil.logError('asked to listen on ' + featureName + '.on.' + eventName + ' but scope wasn\\'t passed in the input parameters.  It is legitimate to pass null, but you\\'ve passed something else, so you probably forgot to provide scope rather than did it deliberately, not registering');\n              return;\n            }\n            var deregAngularOn = registerEventWithAngular(eventId, handler, self.grid, _this);\n\n            //track our listener so we can turn off and on\n            var listener = {handler: handler, dereg: deregAngularOn, eventId: eventId, scope: scope, _this:_this};\n            self.listeners.push(listener);\n\n            var removeListener = function(){\n              listener.dereg();\n              var index = self.listeners.indexOf(listener);\n              self.listeners.splice(index,1);\n            };\n\n            //destroy tracking when scope is destroyed\n            if (scope) {\n              scope.$on('$destroy', function() {\n                removeListener();\n              });\n            }\n\n\n            return removeListener;\n          };\n        };\n\n        function registerEventWithAngular(eventId, handler, grid, _this) {\n          return $rootScope.$on(eventId, function (event) {\n            var args = Array.prototype.slice.call(arguments);\n            args.splice(0, 1); //remove evt argument\n            handler.apply(_this ? _this : grid.api, args);\n          });\n        }\n\n        /**\n         * @ngdoc function\n         * @name registerEventsFromObject\n         * @methodOf ui.grid.class:GridApi\n         * @description Registers features and events from a simple objectMap.\n         * eventObjectMap must be in this format (multiple features allowed)\n         * <pre>\n         * {featureName:\n         *        {\n         *          eventNameOne:function(args){},\n         *          eventNameTwo:function(args){}\n         *        }\n         *  }\n         * </pre>\n         * @param {object} eventObjectMap map of feature/event names\n         */\n        GridApi.prototype.registerEventsFromObject = function (eventObjectMap) {\n          var self = this;\n          var features = [];\n          angular.forEach(eventObjectMap, function (featProp, featPropName) {\n            var feature = {name: featPropName, events: []};\n            angular.forEach(featProp, function (prop, propName) {\n              feature.events.push(propName);\n            });\n            features.push(feature);\n          });\n\n          features.forEach(function (feature) {\n            feature.events.forEach(function (event) {\n              self.registerEvent(feature.name, event);\n            });\n          });\n\n        };\n\n        /**\n         * @ngdoc function\n         * @name registerMethod\n         * @methodOf ui.grid.class:GridApi\n         * @description Registers a new event for the given feature\n         * @param {string} featureName name of the feature\n         * @param {string} methodName  name of the method\n         * @param {object} callBackFn function to execute\n         * @param {object} _this binds callBackFn 'this' to _this.  Defaults to gridApi.grid\n         */\n        GridApi.prototype.registerMethod = function (featureName, methodName, callBackFn, _this) {\n          if (!this[featureName]) {\n            this[featureName] = {};\n          }\n\n          var feature = this[featureName];\n\n          feature[methodName] = gridUtil.createBoundedWrapper(_this || this.grid, callBackFn);\n        };\n\n        /**\n         * @ngdoc function\n         * @name registerMethodsFromObject\n         * @methodOf ui.grid.class:GridApi\n         * @description Registers features and methods from a simple objectMap.\n         * eventObjectMap must be in this format (multiple features allowed)\n         * <br>\n         * {featureName:\n         *        {\n         *          methodNameOne:function(args){},\n         *          methodNameTwo:function(args){}\n         *        }\n         * @param {object} eventObjectMap map of feature/event names\n         * @param {object} _this binds this to _this for all functions.  Defaults to gridApi.grid\n         */\n        GridApi.prototype.registerMethodsFromObject = function (methodMap, _this) {\n          var self = this;\n          var features = [];\n          angular.forEach(methodMap, function (featProp, featPropName) {\n            var feature = {name: featPropName, methods: []};\n            angular.forEach(featProp, function (prop, propName) {\n              feature.methods.push({name: propName, fn: prop});\n            });\n            features.push(feature);\n          });\n\n          features.forEach(function (feature) {\n            feature.methods.forEach(function (method) {\n              self.registerMethod(feature.name, method.name, method.fn, _this);\n            });\n          });\n\n        };\n        \n        return GridApi;\n\n      }]);\n\n})();\n\n(function(){\n\nangular.module('ui.grid')\n.factory('GridColumn', ['gridUtil', 'uiGridConstants', 'i18nService', function(gridUtil, uiGridConstants, i18nService) {\n\n  /**\n   * ******************************************************************************************\n   * PaulL1: Ugly hack here in documentation.  These properties are clearly properties of GridColumn,\n   * and need to be noted as such for those extending and building ui-grid itself.\n   * However, from an end-developer perspective, they interact with all these through columnDefs,\n   * and they really need to be documented there.  I feel like they're relatively static, and\n   * I can't find an elegant way for ngDoc to reference to both....so I've duplicated each\n   * comment block.  Ugh.\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name name\n   * @propertyOf ui.grid.class:GridColumn\n   * @description (mandatory) each column should have a name, although for backward\n   * compatibility with 2.x name can be omitted if field is present\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name name\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description (mandatory) each column should have a name, although for backward\n   * compatibility with 2.x name can be omitted if field is present\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name displayName\n   * @propertyOf ui.grid.class:GridColumn\n   * @description Column name that will be shown in the header.  If displayName is not\n   * provided then one is generated using the name.\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name displayName\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description Column name that will be shown in the header.  If displayName is not\n   * provided then one is generated using the name.\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name field\n   * @propertyOf ui.grid.class:GridColumn\n   * @description field must be provided if you wish to bind to a\n   * property in the data source.  Should be an angular expression that evaluates against grid.options.data\n   * array element.  Can be a complex expression: <code>employee.address.city</code>, or can be a function: <code>employee.getFullAddress()</code>.\n   * See the angular docs on binding expressions.\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name field\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description field must be provided if you wish to bind to a\n   * property in the data source.  Should be an angular expression that evaluates against grid.options.data\n   * array element.  Can be a complex expression: <code>employee.address.city</code>, or can be a function: <code>employee.getFullAddress()</code>.    * See the angular docs on binding expressions.    *\n   */\n\n  /**\n   * @ngdoc property\n   * @name filter\n   * @propertyOf ui.grid.class:GridColumn\n   * @description Filter on this column.\n   * @example\n   * <pre>{ term: 'text', condition: uiGridConstants.filter.STARTS_WITH, placeholder: 'type to filter...', ariaLabel: 'Filter for text', flags: { caseSensitive: false }, type: uiGridConstants.filter.SELECT, [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ] }</pre>\n   *\n   */\n\n  /**\n   * @ngdoc object\n   * @name ui.grid.class:GridColumn\n   * @description Represents the viewModel for each column.  Any state or methods needed for a Grid Column\n   * are defined on this prototype\n   * @param {ColumnDef} colDef the column def to associate with this column\n   * @param {number} uid the unique and immutable uid we'd like to allocate to this column\n   * @param {Grid} grid the grid we'd like to create this column in\n   */\n  function GridColumn(colDef, uid, grid) {\n    var self = this;\n\n    self.grid = grid;\n    self.uid = uid;\n\n    self.updateColumnDef(colDef, true);\n\n    self.aggregationValue = undefined;\n\n    // The footer cell registers to listen for the rowsRendered event, and calls this.  Needed to be\n    // in something with a scope so that the dereg would get called\n    self.updateAggregationValue = function() {\n\n     // gridUtil.logDebug('getAggregationValue for Column ' + self.colDef.name);\n\n      /**\n       * @ngdoc property\n       * @name aggregationType\n       * @propertyOf ui.grid.class:GridOptions.columnDef\n       * @description The aggregation that you'd like to show in the columnFooter for this\n       * column.  Valid values are in uiGridConstants, and currently include `uiGridConstants.aggregationTypes.count`,\n       * `uiGridConstants.aggregationTypes.sum`, `uiGridConstants.aggregationTypes.avg`, `uiGridConstants.aggregationTypes.min`,\n       * `uiGridConstants.aggregationTypes.max`.\n       *\n       * You can also provide a function as the aggregation type, in this case your function needs to accept the full\n       * set of visible rows, and return a value that should be shown\n       */\n      if (!self.aggregationType) {\n        self.aggregationValue = undefined;\n        return;\n      }\n\n      var result = 0;\n      var visibleRows = self.grid.getVisibleRows();\n\n      var cellValues = function(){\n        var values = [];\n        visibleRows.forEach(function (row) {\n          var cellValue = self.grid.getCellValue(row, self);\n          var cellNumber = Number(cellValue);\n          if (!isNaN(cellNumber)) {\n            values.push(cellNumber);\n          }\n        });\n        return values;\n      };\n\n      if (angular.isFunction(self.aggregationType)) {\n        self.aggregationValue = self.aggregationType(visibleRows, self);\n      }\n      else if (self.aggregationType === uiGridConstants.aggregationTypes.count) {\n        self.aggregationValue = self.grid.getVisibleRowCount();\n      }\n      else if (self.aggregationType === uiGridConstants.aggregationTypes.sum) {\n        cellValues().forEach(function (value) {\n          result += value;\n        });\n        self.aggregationValue = result;\n      }\n      else if (self.aggregationType === uiGridConstants.aggregationTypes.avg) {\n        cellValues().forEach(function (value) {\n          result += value;\n        });\n        result = result / cellValues().length;\n        self.aggregationValue = result;\n      }\n      else if (self.aggregationType === uiGridConstants.aggregationTypes.min) {\n        self.aggregationValue = Math.min.apply(null, cellValues());\n      }\n      else if (self.aggregationType === uiGridConstants.aggregationTypes.max) {\n        self.aggregationValue = Math.max.apply(null, cellValues());\n      }\n      else {\n        self.aggregationValue = '\\u00A0';\n      }\n    };\n\n//     var throttledUpdateAggregationValue = gridUtil.throttle(updateAggregationValue, self.grid.options.aggregationCalcThrottle, { trailing: true, context: self.name });\n\n    /**\n     * @ngdoc function\n     * @name getAggregationValue\n     * @methodOf ui.grid.class:GridColumn\n     * @description gets the aggregation value based on the aggregation type for this column.\n     * Debounced using scrollDebounce option setting\n     */\n    this.getAggregationValue =  function() {\n//      if (!self.grid.isScrollingVertically && !self.grid.isScrollingHorizontally) {\n//        throttledUpdateAggregationValue();\n//      }\n\n      return self.aggregationValue;\n    };\n  }\n\n  /**\n   * @ngdoc function\n   * @name hideColumn\n   * @methodOf ui.grid.class:GridColumn\n   * @description Hides the column by setting colDef.visible = false\n   */\n  GridColumn.prototype.hideColumn = function() {\n    this.colDef.visible = false;\n  };\n  \n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:GridColumn\n   * @name setPropertyOrDefault\n   * @description Sets a property on the column using the passed in columnDef, and\n   * setting the defaultValue if the value cannot be found on the colDef\n   * @param {ColumnDef} colDef the column def to look in for the property value\n   * @param {string} propName the property name we'd like to set\n   * @param {object} defaultValue the value to use if the colDef doesn't provide the setting\n   */\n  GridColumn.prototype.setPropertyOrDefault = function (colDef, propName, defaultValue) {\n    var self = this;\n\n    // Use the column definition filter if we were passed it\n    if (typeof(colDef[propName]) !== 'undefined' && colDef[propName]) {\n      self[propName] = colDef[propName];\n    }\n    // Otherwise use our own if it's set\n    else if (typeof(self[propName]) !== 'undefined') {\n      self[propName] = self[propName];\n    }\n    // Default to empty object for the filter\n    else {\n      self[propName] = defaultValue ? defaultValue : {};\n    }\n  };\n\n\n\n  /**\n   * @ngdoc property\n   * @name width\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description sets the column width.  Can be either\n   * a number or a percentage, or an * for auto.\n   * @example\n   * <pre>  $scope.gridOptions.columnDefs = [ { field: 'field1', width: 100},\n   *                                          { field: 'field2', width: '20%'},\n   *                                          { field: 'field3', width: '*' }]; </pre>\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name minWidth\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description sets the minimum column width.  Should be a number.\n   * @example\n   * <pre>  $scope.gridOptions.columnDefs = [ { field: 'field1', minWidth: 100}]; </pre>\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name maxWidth\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description sets the maximum column width.  Should be a number.\n   * @example\n   * <pre>  $scope.gridOptions.columnDefs = [ { field: 'field1', maxWidth: 100}]; </pre>\n   *\n   */\n\n  /**\n   * @ngdoc property\n   * @name visible\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description sets whether or not the column is visible\n   * </br>Default is true\n   * @example\n   * <pre>  $scope.gridOptions.columnDefs = [\n   *     { field: 'field1', visible: true},\n   *     { field: 'field2', visible: false }\n   *   ]; </pre>\n   *\n   */\n\n /**\n  * @ngdoc property\n  * @name sort\n  * @propertyOf ui.grid.class:GridOptions.columnDef\n  * @description An object of sort information, attributes are:\n  *\n  * - direction: values are uiGridConstants.ASC or uiGridConstants.DESC\n  * - ignoreSort: if set to true this sort is ignored (used by tree to manipulate the sort functionality)\n  * - priority: says what order to sort the columns in (lower priority gets sorted first).\n  * @example\n  * <pre>\n  *   $scope.gridOptions.columnDefs = [{\n  *     field: 'field1',\n  *     sort: {\n  *       direction: uiGridConstants.ASC,\n  *       ignoreSort: true,\n  *       priority: 0\n  *      }\n  *   }];\n  * </pre>\n  */\n\n\n  /**\n   * @ngdoc property\n   * @name sortingAlgorithm\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description Algorithm to use for sorting this column. Takes 'a' and 'b' parameters\n   * like any normal sorting function with additional 'rowA', 'rowB', and 'direction' parameters\n   * that are the row objects and the current direction of the sort respectively.\n   *\n   */\n\n  /**\n   * @ngdoc array\n   * @name filters\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description Specify multiple filter fields.\n   * @example\n   * <pre>$scope.gridOptions.columnDefs = [\n   *   {\n   *     field: 'field1', filters: [\n   *       {\n   *         term: 'aa',\n   *         condition: uiGridConstants.filter.STARTS_WITH,\n   *         placeholder: 'starts with...',\n   *         ariaLabel: 'Filter for field1',\n   *         flags: { caseSensitive: false },\n   *         type: uiGridConstants.filter.SELECT,\n   *         selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ]\n   *       },\n   *       {\n   *         condition: uiGridConstants.filter.ENDS_WITH,\n   *         placeholder: 'ends with...'\n   *       }\n   *     ]\n   *   }\n   * ]; </pre>\n   *\n   *\n   */\n\n  /**\n   * @ngdoc array\n   * @name filters\n   * @propertyOf ui.grid.class:GridColumn\n   * @description Filters for this column. Includes 'term' property bound to filter input elements.\n   * @example\n   * <pre>[\n   *   {\n   *     term: 'foo', // ngModel for <input>\n   *     condition: uiGridConstants.filter.STARTS_WITH,\n   *     placeholder: 'starts with...',\n   *     ariaLabel: 'Filter for foo',\n   *     flags: { caseSensitive: false },\n   *     type: uiGridConstants.filter.SELECT,\n   *     selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ]\n   *   },\n   *   {\n   *     term: 'baz',\n   *     condition: uiGridConstants.filter.ENDS_WITH,\n   *     placeholder: 'ends with...'\n   *   }\n   * ] </pre>\n   *\n   *\n   */\n\n  /**\n   * @ngdoc array\n   * @name menuItems\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description used to add menu items to a column.  Refer to the tutorial on this\n   * functionality.  A number of settings are supported:\n   *\n   * - title: controls the title that is displayed in the menu\n   * - icon: the icon shown alongside that title\n   * - action: the method to call when the menu is clicked\n   * - shown: a function to evaluate to determine whether or not to show the item\n   * - active: a function to evaluate to determine whether or not the item is currently selected\n   * - context: context to pass to the action function, available in this.context in your handler\n   * - leaveOpen: if set to true, the menu should stay open after the action, defaults to false\n   * @example\n   * <pre>  $scope.gridOptions.columnDefs = [\n   *   { field: 'field1', menuItems: [\n   *     {\n   *       title: 'Outer Scope Alert',\n   *       icon: 'ui-grid-icon-info-circled',\n   *       action: function($event) {\n   *         this.context.blargh(); // $scope.blargh() would work too, this is just an example\n   *       },\n   *       shown: function() { return true; },\n   *       active: function() { return true; },\n   *       context: $scope\n   *     },\n   *     {\n   *       title: 'Grid ID',\n   *       action: function() {\n   *         alert('Grid ID: ' + this.grid.id);\n   *       }\n   *     }\n   *   ] }]; </pre>\n   *\n   */\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:GridColumn\n   * @name updateColumnDef\n   * @description Moves settings from the columnDef down onto the column,\n   * and sets properties as appropriate\n   * @param {ColumnDef} colDef the column def to look in for the property value\n   * @param {boolean} isNew whether the column is being newly created, if not\n   * we're updating an existing column, and some items such as the sort shouldn't\n   * be copied down\n   */\n  GridColumn.prototype.updateColumnDef = function(colDef, isNew) {\n    var self = this;\n\n    self.colDef = colDef;\n\n    if (colDef.name === undefined) {\n      throw new Error('colDef.name is required for column at index ' + self.grid.options.columnDefs.indexOf(colDef));\n    }\n\n    self.displayName = (colDef.displayName === undefined) ? gridUtil.readableColumnName(colDef.name) : colDef.displayName;\n\n    if (!angular.isNumber(self.width) || !self.hasCustomWidth || colDef.allowCustomWidthOverride) {\n      var colDefWidth = colDef.width;\n      var parseErrorMsg = \"Cannot parse column width '\" + colDefWidth + \"' for column named '\" + colDef.name + \"'\";\n      self.hasCustomWidth = false;\n\n      if (!angular.isString(colDefWidth) && !angular.isNumber(colDefWidth)) {\n        self.width = '*';\n      } else if (angular.isString(colDefWidth)) {\n        // See if it ends with a percent\n        if (gridUtil.endsWith(colDefWidth, '%')) {\n          // If so we should be able to parse the non-percent-sign part to a number\n          var percentStr = colDefWidth.replace(/%/g, '');\n          var percent = parseInt(percentStr, 10);\n          if (isNaN(percent)) {\n            throw new Error(parseErrorMsg);\n          }\n          self.width = colDefWidth;\n        }\n        // And see if it's a number string\n        else if (colDefWidth.match(/^(\\d+)$/)) {\n          self.width = parseInt(colDefWidth.match(/^(\\d+)$/)[1], 10);\n        }\n        // Otherwise it should be a string of asterisks\n        else if (colDefWidth.match(/^\\*+$/)) {\n          self.width = colDefWidth;\n        }\n        // No idea, throw an Error\n        else {\n          throw new Error(parseErrorMsg);\n        }\n      }\n      // Is a number, use it as the width\n      else {\n        self.width = colDefWidth;\n      }\n    }\n\n    ['minWidth', 'maxWidth'].forEach(function (name) {\n      var minOrMaxWidth = colDef[name];\n      var parseErrorMsg = \"Cannot parse column \" + name + \" '\" + minOrMaxWidth + \"' for column named '\" + colDef.name + \"'\";\n\n      if (!angular.isString(minOrMaxWidth) && !angular.isNumber(minOrMaxWidth)) {\n        //Sets default minWidth and maxWidth values\n        self[name] = ((name === 'minWidth') ? 30 : 9000);\n      } else if (angular.isString(minOrMaxWidth)) {\n        if (minOrMaxWidth.match(/^(\\d+)$/)) {\n          self[name] = parseInt(minOrMaxWidth.match(/^(\\d+)$/)[1], 10);\n        } else {\n          throw new Error(parseErrorMsg);\n        }\n      } else {\n        self[name] = minOrMaxWidth;\n      }\n    });\n\n    //use field if it is defined; name if it is not\n    self.field = (colDef.field === undefined) ? colDef.name : colDef.field;\n\n    if ( typeof( self.field ) !== 'string' ){\n      gridUtil.logError( 'Field is not a string, this is likely to break the code, Field is: ' + self.field );\n    }\n\n    self.name = colDef.name;\n\n    // Use colDef.displayName as long as it's not undefined, otherwise default to the field name\n    self.displayName = (colDef.displayName === undefined) ? gridUtil.readableColumnName(colDef.name) : colDef.displayName;\n\n    //self.originalIndex = index;\n\n    self.aggregationType = angular.isDefined(colDef.aggregationType) ? colDef.aggregationType : null;\n    self.footerCellTemplate = angular.isDefined(colDef.footerCellTemplate) ? colDef.footerCellTemplate : null;\n\n    /**\n     * @ngdoc property\n     * @name cellTooltip\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description Whether or not to show a tooltip when a user hovers over the cell.\n     * If set to false, no tooltip.  If true, the cell value is shown in the tooltip (useful\n     * if you have long values in your cells), if a function then that function is called\n     * passing in the row and the col `cellTooltip( row, col )`, and the return value is shown in the tooltip,\n     * if it is a static string then displays that static string.\n     *\n     * Defaults to false\n     *\n     */\n    if ( typeof(colDef.cellTooltip) === 'undefined' || colDef.cellTooltip === false ) {\n      self.cellTooltip = false;\n    } else if ( colDef.cellTooltip === true ){\n      self.cellTooltip = function(row, col) {\n        return self.grid.getCellValue( row, col );\n      };\n    } else if (typeof(colDef.cellTooltip) === 'function' ){\n      self.cellTooltip = colDef.cellTooltip;\n    } else {\n      self.cellTooltip = function ( row, col ){\n        return col.colDef.cellTooltip;\n      };\n    }\n\n    /**\n     * @ngdoc property\n     * @name headerTooltip\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description Whether or not to show a tooltip when a user hovers over the header cell.\n     * If set to false, no tooltip.  If true, the displayName is shown in the tooltip (useful\n     * if you have long values in your headers), if a function then that function is called\n     * passing in the row and the col `headerTooltip( col )`, and the return value is shown in the tooltip,\n     * if a static string then shows that static string.\n     *\n     * Defaults to false\n     *\n     */\n    if ( typeof(colDef.headerTooltip) === 'undefined' || colDef.headerTooltip === false ) {\n      self.headerTooltip = false;\n    } else if ( colDef.headerTooltip === true ){\n      self.headerTooltip = function(col) {\n        return col.displayName;\n      };\n    } else if (typeof(colDef.headerTooltip) === 'function' ){\n      self.headerTooltip = colDef.headerTooltip;\n    } else {\n      self.headerTooltip = function ( col ) {\n        return col.colDef.headerTooltip;\n      };\n    }\n\n\n    /**\n     * @ngdoc property\n     * @name footerCellClass\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description footerCellClass can be a string specifying the class to append to a cell\n     * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name\n     *\n     */\n    self.footerCellClass = colDef.footerCellClass;\n\n    /**\n     * @ngdoc property\n     * @name cellClass\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description cellClass can be a string specifying the class to append to a cell\n     * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name\n     *\n     */\n    self.cellClass = colDef.cellClass;\n\n    /**\n     * @ngdoc property\n     * @name headerCellClass\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description headerCellClass can be a string specifying the class to append to a cell\n     * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name\n     *\n     */\n    self.headerCellClass = colDef.headerCellClass;\n\n    /**\n     * @ngdoc property\n     * @name cellFilter\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description cellFilter is a filter to apply to the content of each cell\n     * @example\n     * <pre>\n     *   gridOptions.columnDefs[0].cellFilter = 'date'\n     *\n     */\n    self.cellFilter = colDef.cellFilter ? colDef.cellFilter : \"\";\n\n    /**\n     * @ngdoc boolean\n     * @name sortCellFiltered\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) False by default. When `true` uiGrid will apply the cellFilter before\n     * sorting the data. Note that when using this option uiGrid will assume that the displayed value is\n     * a string, and use the {@link ui.grid.class:RowSorter#sortAlpha sortAlpha} `sortFn`. It is possible\n     * to return a non-string value from an angularjs filter, in which case you should define a {@link ui.grid.class:GridOptions.columnDef#sortingAlgorithm sortingAlgorithm}\n     * for the column which hanldes the returned type. You may specify one of the `sortingAlgorithms`\n     * found in the {@link ui.grid.RowSorter rowSorter} service.\n     */\n    self.sortCellFiltered = colDef.sortCellFiltered ? true : false;\n\n    /**\n     * @ngdoc boolean\n     * @name filterCellFiltered\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) False by default. When `true` uiGrid will apply the cellFilter before\n     * applying \"search\" `filters`.\n     */\n    self.filterCellFiltered = colDef.filterCellFiltered ? true : false;\n\n    /**\n     * @ngdoc property\n     * @name headerCellFilter\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description headerCellFilter is a filter to apply to the content of the column header\n     * @example\n     * <pre>\n     *   gridOptions.columnDefs[0].headerCellFilter = 'translate'\n     *\n     */\n    self.headerCellFilter = colDef.headerCellFilter ? colDef.headerCellFilter : \"\";\n\n    /**\n     * @ngdoc property\n     * @name footerCellFilter\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description footerCellFilter is a filter to apply to the content of the column footer\n     * @example\n     * <pre>\n     *   gridOptions.columnDefs[0].footerCellFilter = 'date'\n     *\n     */\n    self.footerCellFilter = colDef.footerCellFilter ? colDef.footerCellFilter : \"\";\n\n    self.visible = gridUtil.isNullOrUndefined(colDef.visible) || colDef.visible;\n\n    self.headerClass = colDef.headerClass;\n    //self.cursor = self.sortable ? 'pointer' : 'default';\n\n    // Turn on sorting by default\n    self.enableSorting = typeof(colDef.enableSorting) !== 'undefined' ? colDef.enableSorting : true;\n    self.sortingAlgorithm = colDef.sortingAlgorithm;\n\n    /**\n     * @ngdoc property\n     * @name sortDirectionCycle\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) An array of sort directions, specifying the order that they\n     * should cycle through as the user repeatedly clicks on the column heading.\n     * The default is `[null, uiGridConstants.ASC, uiGridConstants.DESC]`. Null\n     * refers to the unsorted state. This does not affect the initial sort\n     * direction; use the {@link ui.grid.class:GridOptions.columnDef#sort sort}\n     * property for that. If\n     * {@link ui.grid.class:GridOptions.columnDef#suppressRemoveSort suppressRemoveSort}\n     * is also set, the unsorted state will be skipped even if it is listed here.\n     * Each direction may not appear in the list more than once (e.g. `[ASC,\n     * DESC, DESC]` is not allowed), and the list may not be empty.\n     */\n    self.sortDirectionCycle = typeof(colDef.sortDirectionCycle) !== 'undefined' ?\n      colDef.sortDirectionCycle :\n      [null, uiGridConstants.ASC, uiGridConstants.DESC];\n\n    /**\n     * @ngdoc boolean\n     * @name suppressRemoveSort\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description (optional) False by default. When enabled, this setting hides the removeSort option\n     * in the menu, and prevents users from manually removing the sort\n     */\n    if ( typeof(self.suppressRemoveSort) === 'undefined'){\n      self.suppressRemoveSort = typeof(colDef.suppressRemoveSort) !== 'undefined' ? colDef.suppressRemoveSort : false;\n    }\n\n    /**\n     * @ngdoc property\n     * @name enableFiltering\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description turn off filtering for an individual column, where\n     * you've turned on filtering for the overall grid\n     * @example\n     * <pre>\n     *   gridOptions.columnDefs[0].enableFiltering = false;\n     *\n     */\n    // Turn on filtering by default (it's disabled by default at the Grid level)\n    self.enableFiltering = typeof(colDef.enableFiltering) !== 'undefined' ? colDef.enableFiltering : true;\n\n    // self.menuItems = colDef.menuItems;\n    self.setPropertyOrDefault(colDef, 'menuItems', []);\n\n    // Use the column definition sort if we were passed it, but only if this is a newly added column\n    if ( isNew ){\n      self.setPropertyOrDefault(colDef, 'sort');\n    }\n\n    // Set up default filters array for when one is not provided.\n    //   In other words, this (in column def):\n    //\n    //       filter: { term: 'something', flags: {}, condition: [CONDITION] }\n    //\n    //   is just shorthand for this:\n    //\n    //       filters: [{ term: 'something', flags: {}, condition: [CONDITION] }]\n    //\n    var defaultFilters = [];\n    if (colDef.filter) {\n      defaultFilters.push(colDef.filter);\n    }\n    else if ( colDef.filters ){\n      defaultFilters = colDef.filters;\n    } else {\n      // Add an empty filter definition object, which will\n      // translate to a guessed condition and no pre-populated\n      // value for the filter <input>.\n      defaultFilters.push({});\n    }\n\n    /**\n     * @ngdoc property\n     * @name filter\n     * @propertyOf ui.grid.class:GridOptions.columnDef\n     * @description Specify a single filter field on this column.\n     *\n     * A filter consists of a condition, a term, and a placeholder:\n     *\n     * - condition defines how rows are chosen as matching the filter term. This can be set to\n     * one of the constants in uiGridConstants.filter, or you can supply a custom filter function\n     * that gets passed the following arguments: [searchTerm, cellValue, row, column].\n     * - term: If set, the filter field will be pre-populated\n     * with this value.\n     * - placeholder: String that will be set to the `<input>.placeholder` attribute.\n     * - ariaLabel: String that will be set to the `<input>.ariaLabel` attribute. This is what is read as a label to screen reader users.\n     * - noTerm: set this to true if you have defined a custom function in condition, and\n     * your custom function doesn't require a term (so it can run even when the term is null)\n     * - flags: only flag currently available is `caseSensitive`, set to false if you don't want\n     * case sensitive matching\n     * - type: defaults to uiGridConstants.filter.INPUT, which gives a text box.  If set to uiGridConstants.filter.SELECT\n     * then a select box will be shown with options selectOptions\n     * - selectOptions: options in the format `[ { value: 1, label: 'male' }]`.  No i18n filter is provided, you need\n     * to perform the i18n on the values before you provide them\n     * - disableCancelFilterButton: defaults to false. If set to true then the 'x' button that cancels/clears the filter\n     * will not be shown.\n     * @example\n     * <pre>$scope.gridOptions.columnDefs = [\n     *   {\n     *     field: 'field1',\n     *     filter: {\n     *       term: 'xx',\n     *       condition: uiGridConstants.filter.STARTS_WITH,\n     *       placeholder: 'starts with...',\n     *       ariaLabel: 'Starts with filter for field1',\n     *       flags: { caseSensitive: false },\n     *       type: uiGridConstants.filter.SELECT,\n     *       selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ],\n     *       disableCancelFilterButton: true\n     *     }\n     *   }\n     * ]; </pre>\n     *\n     */\n\n    /*\n\n\n    /*\n\n      self.filters = [\n        {\n          term: 'search term'\n          condition: uiGridConstants.filter.CONTAINS,\n          placeholder: 'my placeholder',\n          ariaLabel: 'Starts with filter for field1',\n          flags: {\n            caseSensitive: true\n          }\n        }\n      ]\n\n    */\n\n    // Only set filter if this is a newly added column, if we're updating an existing\n    // column then we don't want to put the default filter back if the user may have already\n    // removed it.\n    // However, we do want to keep the settings if they change, just not the term\n    if ( isNew ) {\n      self.setPropertyOrDefault(colDef, 'filter');\n      self.setPropertyOrDefault(colDef, 'filters', defaultFilters);\n    } else if ( self.filters.length === defaultFilters.length ) {\n      self.filters.forEach( function( filter, index ){\n        if (typeof(defaultFilters[index].placeholder) !== 'undefined') {\n          filter.placeholder = defaultFilters[index].placeholder;\n        }\n        if (typeof(defaultFilters[index].ariaLabel) !== 'undefined') {\n          filter.ariaLabel = defaultFilters[index].ariaLabel;\n        }\n        if (typeof(defaultFilters[index].flags) !== 'undefined') {\n          filter.flags = defaultFilters[index].flags;\n        }\n        if (typeof(defaultFilters[index].type) !== 'undefined') {\n          filter.type = defaultFilters[index].type;\n        }\n        if (typeof(defaultFilters[index].selectOptions) !== 'undefined') {\n          filter.selectOptions = defaultFilters[index].selectOptions;\n        }\n      });\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name unsort\n   * @methodOf ui.grid.class:GridColumn\n   * @description Removes column from the grid sorting\n   */\n  GridColumn.prototype.unsort = function () {\n    this.sort = {};\n    this.grid.api.core.raise.sortChanged( this.grid, this.grid.getColumnSorting() );\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name getColClass\n   * @methodOf ui.grid.class:GridColumn\n   * @description Returns the class name for the column\n   * @param {bool} prefixDot  if true, will return .className instead of className\n   */\n  GridColumn.prototype.getColClass = function (prefixDot) {\n    var cls = uiGridConstants.COL_CLASS_PREFIX + this.uid;\n\n    return prefixDot ? '.' + cls : cls;\n  };\n\n    /**\n     * @ngdoc function\n     * @name isPinnedLeft\n     * @methodOf ui.grid.class:GridColumn\n     * @description Returns true if column is in the left render container\n     */\n    GridColumn.prototype.isPinnedLeft = function () {\n      return this.renderContainer === 'left';\n    };\n\n    /**\n     * @ngdoc function\n     * @name isPinnedRight\n     * @methodOf ui.grid.class:GridColumn\n     * @description Returns true if column is in the right render container\n     */\n    GridColumn.prototype.isPinnedRight = function () {\n      return this.renderContainer === 'right';\n    };\n\n\n    /**\n   * @ngdoc function\n   * @name getColClassDefinition\n   * @methodOf ui.grid.class:GridColumn\n   * @description Returns the class definition for th column\n   */\n  GridColumn.prototype.getColClassDefinition = function () {\n    return ' .grid' + this.grid.id + ' ' + this.getColClass(true) + ' { min-width: ' + this.drawnWidth + 'px; max-width: ' + this.drawnWidth + 'px; }';\n  };\n\n  /**\n   * @ngdoc function\n   * @name getRenderContainer\n   * @methodOf ui.grid.class:GridColumn\n   * @description Returns the render container object that this column belongs to.\n   *\n   * Columns will be default be in the `body` render container if they aren't allocated to one specifically.\n   */\n  GridColumn.prototype.getRenderContainer = function getRenderContainer() {\n    var self = this;\n\n    var containerId = self.renderContainer;\n\n    if (containerId === null || containerId === '' || containerId === undefined) {\n      containerId = 'body';\n    }\n\n    return self.grid.renderContainers[containerId];\n  };\n\n  /**\n   * @ngdoc function\n   * @name showColumn\n   * @methodOf ui.grid.class:GridColumn\n   * @description Makes the column visible by setting colDef.visible = true\n   */\n  GridColumn.prototype.showColumn = function() {\n      this.colDef.visible = true;\n  };\n\n\n  /**\n   * @ngdoc property\n   * @name aggregationHideLabel\n   * @propertyOf ui.grid.class:GridOptions.columnDef\n   * @description defaults to false, if set to true hides the label text\n   * in the aggregation footer, so only the value is displayed.\n   *\n   */\n  /**\n   * @ngdoc function\n   * @name getAggregationText\n   * @methodOf ui.grid.class:GridColumn\n   * @description Gets the aggregation label from colDef.aggregationLabel if\n   * specified or by using i18n, including deciding whether or not to display\n   * based on colDef.aggregationHideLabel.\n   *\n   * @param {string} label the i18n lookup value to use for the column label\n   *\n   */\n  GridColumn.prototype.getAggregationText = function () {\n    var self = this;\n    if ( self.colDef.aggregationHideLabel ){\n      return '';\n    }\n    else if ( self.colDef.aggregationLabel ) {\n      return self.colDef.aggregationLabel;\n    }\n    else {\n      switch ( self.colDef.aggregationType ){\n        case uiGridConstants.aggregationTypes.count:\n          return i18nService.getSafeText('aggregation.count');\n        case uiGridConstants.aggregationTypes.sum:\n          return i18nService.getSafeText('aggregation.sum');\n        case uiGridConstants.aggregationTypes.avg:\n          return i18nService.getSafeText('aggregation.avg');\n        case uiGridConstants.aggregationTypes.min:\n          return i18nService.getSafeText('aggregation.min');\n        case uiGridConstants.aggregationTypes.max:\n          return i18nService.getSafeText('aggregation.max');\n        default:\n          return '';\n      }\n    }\n  };\n\n  GridColumn.prototype.getCellTemplate = function () {\n    var self = this;\n\n    return self.cellTemplatePromise;\n  };\n\n  GridColumn.prototype.getCompiledElementFn = function () {\n    var self = this;\n\n    return self.compiledElementFnDefer.promise;\n  };\n\n  return GridColumn;\n}]);\n\n})();\n\n  (function(){\n\nangular.module('ui.grid')\n.factory('GridOptions', ['gridUtil','uiGridConstants', function(gridUtil,uiGridConstants) {\n\n  /**\n   * @ngdoc function\n   * @name ui.grid.class:GridOptions\n   * @description Default GridOptions class.  GridOptions are defined by the application developer and overlaid\n   * over this object.  Setting gridOptions within your controller is the most common method for an application\n   * developer to configure the behaviour of their ui-grid\n   *\n   * @example To define your gridOptions within your controller:\n   * <pre>$scope.gridOptions = {\n   *   data: $scope.myData,\n   *   columnDefs: [\n   *     { name: 'field1', displayName: 'pretty display name' },\n   *     { name: 'field2', visible: false }\n   *  ]\n   * };</pre>\n   *\n   * You can then use this within your html template, when you define your grid:\n   * <pre>&lt;div ui-grid=\"gridOptions\"&gt;&lt;/div&gt;</pre>\n   *\n   * To provide default options for all of the grids within your application, use an angular\n   * decorator to modify the GridOptions factory.\n   * <pre>\n   * app.config(function($provide){\n   *   $provide.decorator('GridOptions',function($delegate){\n   *     var gridOptions;\n   *     gridOptions = angular.copy($delegate);\n   *     gridOptions.initialize = function(options) {\n   *       var initOptions;\n   *       initOptions = $delegate.initialize(options);\n   *       initOptions.enableColumnMenus = false;\n   *       return initOptions;\n   *     };\n   *     return gridOptions;\n   *   });\n   * });\n   * </pre>\n   */\n  return {\n    initialize: function( baseOptions ){\n      /**\n       * @ngdoc function\n       * @name onRegisterApi\n       * @propertyOf ui.grid.class:GridOptions\n       * @description A callback that returns the gridApi once the grid is instantiated, which is\n       * then used to interact with the grid programatically.\n       *\n       * Note that the gridApi.core.renderingComplete event is identical to this\n       * callback, but has the advantage that it can be called from multiple places\n       * if needed\n       *\n       * @example\n       * <pre>\n       *   $scope.gridOptions.onRegisterApi = function ( gridApi ) {\n       *     $scope.gridApi = gridApi;\n       *     $scope.gridApi.selection.selectAllRows( $scope.gridApi.grid );\n       *   };\n       * </pre>\n       *\n       */\n      baseOptions.onRegisterApi = baseOptions.onRegisterApi || angular.noop();\n\n      /**\n       * @ngdoc object\n       * @name data\n       * @propertyOf ui.grid.class:GridOptions\n       * @description (mandatory) Array of data to be rendered into the grid, providing the data source or data binding for\n       * the grid.\n       *\n       * Most commonly the data is an array of objects, where each object has a number of attributes.\n       * Each attribute automatically becomes a column in your grid.  This array could, for example, be sourced from\n       * an angularJS $resource query request.  The array can also contain complex objects, refer the binding tutorial\n       * for examples of that.\n       *\n       * The most flexible usage is to set your data on $scope:\n       *\n       * `$scope.data = data;`\n       *\n       * And then direct the grid to resolve whatever is in $scope.data:\n       *\n       * `$scope.gridOptions.data = 'data';`\n       *\n       * This is the most flexible approach as it allows you to replace $scope.data whenever you feel like it without\n       * getting pointer issues.\n       *\n       * Alternatively you can directly set the data array:\n       *\n       * `$scope.gridOptions.data = [ ];`\n       * or\n       *\n       * `$http.get('/data/100.json')\n       * .success(function(data) {\n       *   $scope.myData = data;\n       *   $scope.gridOptions.data = $scope.myData;\n       *  });`\n       *\n       * Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some other\n       * array, you need to update $scope.gridOptions.data to point to that new array as well.\n       *\n       */\n      baseOptions.data = baseOptions.data || [];\n\n      /**\n       * @ngdoc array\n       * @name columnDefs\n       * @propertyOf  ui.grid.class:GridOptions\n       * @description Array of columnDef objects.  Only required property is name.\n       * The individual options available in columnDefs are documented in the\n       * {@link ui.grid.class:GridOptions.columnDef columnDef} section\n       * </br>_field property can be used in place of name for backwards compatibility with 2.x_\n       *  @example\n       *\n       * <pre>var columnDefs = [{name:'field1'}, {name:'field2'}];</pre>\n       *\n       */\n      baseOptions.columnDefs = baseOptions.columnDefs || [];\n\n      /**\n       * @ngdoc object\n       * @name ui.grid.class:GridOptions.columnDef\n       * @description Definition / configuration of an individual column, which would typically be\n       * one of many column definitions within the gridOptions.columnDefs array\n       * @example\n       * <pre>{name:'field1', field: 'field1', filter: { term: 'xxx' }}</pre>\n       *\n       */\n\n\n      /**\n       * @ngdoc array\n       * @name excludeProperties\n       * @propertyOf  ui.grid.class:GridOptions\n       * @description Array of property names in data to ignore when auto-generating column names.  Provides the\n       * inverse of columnDefs - columnDefs is a list of columns to include, excludeProperties is a list of columns\n       * to exclude.\n       *\n       * If columnDefs is defined, this will be ignored.\n       *\n       * Defaults to ['$$hashKey']\n       */\n\n      baseOptions.excludeProperties = baseOptions.excludeProperties || ['$$hashKey'];\n\n      /**\n       * @ngdoc boolean\n       * @name enableRowHashing\n       * @propertyOf ui.grid.class:GridOptions\n       * @description True by default. When enabled, this setting allows uiGrid to add\n       * `$$hashKey`-type properties (similar to Angular) to elements in the `data` array. This allows\n       * the grid to maintain state while vastly speeding up the process of altering `data` by adding/moving/removing rows.\n       *\n       * Note that this DOES add properties to your data that you may not want, but they are stripped out when using `angular.toJson()`. IF\n       * you do not want this at all you can disable this setting but you will take a performance hit if you are using large numbers of rows\n       * and are altering the data set often.\n       */\n      baseOptions.enableRowHashing = baseOptions.enableRowHashing !== false;\n\n      /**\n       * @ngdoc function\n       * @name rowIdentity\n       * @methodOf ui.grid.class:GridOptions\n       * @description This function is used to get and, if necessary, set the value uniquely identifying this row (i.e. if an identity is not present it will set one).\n       *\n       * By default it returns the `$$hashKey` property if it exists. If it doesn't it uses gridUtil.nextUid() to generate one\n       */\n      baseOptions.rowIdentity = baseOptions.rowIdentity || function rowIdentity(row) {\n        return gridUtil.hashKey(row);\n      };\n\n      /**\n       * @ngdoc function\n       * @name getRowIdentity\n       * @methodOf ui.grid.class:GridOptions\n       * @description This function returns the identity value uniquely identifying this row, if one is not present it does not set it.\n       *\n       * By default it returns the `$$hashKey` property but can be overridden to use any property or set of properties you want.\n       */\n      baseOptions.getRowIdentity = baseOptions.getRowIdentity || function getRowIdentity(row) {\n        return row.$$hashKey;\n      };\n\n      /**\n       * @ngdoc property\n       * @name flatEntityAccess\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Set to true if your columns are all related directly to fields in a flat object structure - i.e.\n       * each of your columns associate directly with a property on each of the entities in your data array.\n       *\n       * In that situation we can avoid all the logic associated with complex binding to functions or to properties of sub-objects,\n       * which can provide a significant speed improvement with large data sets when filtering or sorting.\n       *\n       * By default false\n       */\n      baseOptions.flatEntityAccess = baseOptions.flatEntityAccess === true;\n\n      /**\n       * @ngdoc property\n       * @name showHeader\n       * @propertyOf ui.grid.class:GridOptions\n       * @description True by default. When set to false, this setting will replace the\n       * standard header template with '<div></div>', resulting in no header being shown.\n       */\n      baseOptions.showHeader = typeof(baseOptions.showHeader) !== \"undefined\" ? baseOptions.showHeader : true;\n\n      /* (NOTE): Don't show this in the docs. We only use it internally\n       * @ngdoc property\n       * @name headerRowHeight\n       * @propertyOf ui.grid.class:GridOptions\n       * @description The height of the header in pixels, defaults to 30\n       *\n       */\n      if (!baseOptions.showHeader) {\n        baseOptions.headerRowHeight = 0;\n      }\n      else {\n        baseOptions.headerRowHeight = typeof(baseOptions.headerRowHeight) !== \"undefined\" ? baseOptions.headerRowHeight : 30;\n      }\n\n      /**\n       * @ngdoc property\n       * @name rowHeight\n       * @propertyOf ui.grid.class:GridOptions\n       * @description The height of the row in pixels, defaults to 30\n       *\n       */\n      baseOptions.rowHeight = baseOptions.rowHeight || 30;\n\n      /**\n       * @ngdoc integer\n       * @name minRowsToShow\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Minimum number of rows to show when the grid doesn't have a defined height. Defaults to \"10\".\n       */\n      baseOptions.minRowsToShow = typeof(baseOptions.minRowsToShow) !== \"undefined\" ? baseOptions.minRowsToShow : 10;\n\n      /**\n       * @ngdoc property\n       * @name showGridFooter\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Whether or not to show the footer, defaults to false\n       * The footer display Total Rows and Visible Rows (filtered rows)\n       */\n      baseOptions.showGridFooter = baseOptions.showGridFooter === true;\n\n      /**\n       * @ngdoc property\n       * @name showColumnFooter\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Whether or not to show the column footer, defaults to false\n       * The column footer displays column aggregates\n       */\n      baseOptions.showColumnFooter = baseOptions.showColumnFooter === true;\n\n      /**\n       * @ngdoc property\n       * @name columnFooterHeight\n       * @propertyOf ui.grid.class:GridOptions\n       * @description The height of the footer rows (column footer and grid footer) in pixels\n       *\n       */\n      baseOptions.columnFooterHeight = typeof(baseOptions.columnFooterHeight) !== \"undefined\" ? baseOptions.columnFooterHeight : 30;\n      baseOptions.gridFooterHeight = typeof(baseOptions.gridFooterHeight) !== \"undefined\" ? baseOptions.gridFooterHeight : 30;\n\n      baseOptions.columnWidth = typeof(baseOptions.columnWidth) !== \"undefined\" ? baseOptions.columnWidth : 50;\n\n      /**\n       * @ngdoc property\n       * @name maxVisibleColumnCount\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Defaults to 200\n       *\n       */\n      baseOptions.maxVisibleColumnCount = typeof(baseOptions.maxVisibleColumnCount) !== \"undefined\" ? baseOptions.maxVisibleColumnCount : 200;\n\n      /**\n       * @ngdoc property\n       * @name virtualizationThreshold\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Turn virtualization on when number of data elements goes over this number, defaults to 20\n       */\n      baseOptions.virtualizationThreshold = typeof(baseOptions.virtualizationThreshold) !== \"undefined\" ? baseOptions.virtualizationThreshold : 20;\n\n      /**\n       * @ngdoc property\n       * @name columnVirtualizationThreshold\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Turn virtualization on when number of columns goes over this number, defaults to 10\n       */\n      baseOptions.columnVirtualizationThreshold = typeof(baseOptions.columnVirtualizationThreshold) !== \"undefined\" ? baseOptions.columnVirtualizationThreshold : 10;\n\n      /**\n       * @ngdoc property\n       * @name excessRows\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Extra rows to to render outside of the viewport, which helps with smoothness of scrolling.\n       * Defaults to 4\n       */\n      baseOptions.excessRows = typeof(baseOptions.excessRows) !== \"undefined\" ? baseOptions.excessRows : 4;\n      /**\n       * @ngdoc property\n       * @name scrollThreshold\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Defaults to 4\n       */\n      baseOptions.scrollThreshold = typeof(baseOptions.scrollThreshold) !== \"undefined\" ? baseOptions.scrollThreshold : 4;\n\n      /**\n       * @ngdoc property\n       * @name excessColumns\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Extra columns to to render outside of the viewport, which helps with smoothness of scrolling.\n       * Defaults to 4\n       */\n      baseOptions.excessColumns = typeof(baseOptions.excessColumns) !== \"undefined\" ? baseOptions.excessColumns : 4;\n      /**\n       * @ngdoc property\n       * @name horizontalScrollThreshold\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Defaults to 4\n       */\n      baseOptions.horizontalScrollThreshold = typeof(baseOptions.horizontalScrollThreshold) !== \"undefined\" ? baseOptions.horizontalScrollThreshold : 2;\n\n\n      /**\n       * @ngdoc property\n       * @name aggregationCalcThrottle\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms\n       */\n      baseOptions.aggregationCalcThrottle = typeof(baseOptions.aggregationCalcThrottle) !== \"undefined\" ? baseOptions.aggregationCalcThrottle : 500;\n\n      /**\n       * @ngdoc property\n       * @name wheelScrollThrottle\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Default time in milliseconds to throttle scroll events to, defaults to 70ms\n       */\n      baseOptions.wheelScrollThrottle = typeof(baseOptions.wheelScrollThrottle) !== \"undefined\" ? baseOptions.wheelScrollThrottle : 70;\n\n\n      /**\n       * @ngdoc property\n       * @name scrollDebounce\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Default time in milliseconds to debounce scroll events, defaults to 300ms\n       */\n      baseOptions.scrollDebounce = typeof(baseOptions.scrollDebounce) !== \"undefined\" ? baseOptions.scrollDebounce : 300;\n\n      /**\n       * @ngdoc boolean\n       * @name enableSorting\n       * @propertyOf ui.grid.class:GridOptions\n       * @description True by default. When enabled, this setting adds sort\n       * widgets to the column headers, allowing sorting of the data for the entire grid.\n       * Sorting can then be disabled on individual columns using the columnDefs.\n       */\n      baseOptions.enableSorting = baseOptions.enableSorting !== false;\n\n      /**\n       * @ngdoc boolean\n       * @name enableFiltering\n       * @propertyOf ui.grid.class:GridOptions\n       * @description False by default. When enabled, this setting adds filter\n       * boxes to each column header, allowing filtering within the column for the entire grid.\n       * Filtering can then be disabled on individual columns using the columnDefs.\n       */\n      baseOptions.enableFiltering = baseOptions.enableFiltering === true;\n\n      /**\n       * @ngdoc boolean\n       * @name enableColumnMenus\n       * @propertyOf ui.grid.class:GridOptions\n       * @description True by default. When enabled, this setting displays a column\n       * menu within each column.\n       */\n      baseOptions.enableColumnMenus = baseOptions.enableColumnMenus !== false;\n\n      /**\n       * @ngdoc boolean\n       * @name enableVerticalScrollbar\n       * @propertyOf ui.grid.class:GridOptions\n       * @description uiGridConstants.scrollbars.ALWAYS by default. This settings controls the vertical scrollbar for the grid.\n       * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER\n       */\n      baseOptions.enableVerticalScrollbar = typeof(baseOptions.enableVerticalScrollbar) !== \"undefined\" ? baseOptions.enableVerticalScrollbar : uiGridConstants.scrollbars.ALWAYS;\n\n      /**\n       * @ngdoc boolean\n       * @name enableHorizontalScrollbar\n       * @propertyOf ui.grid.class:GridOptions\n       * @description uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid.\n       * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER\n       */\n      baseOptions.enableHorizontalScrollbar = typeof(baseOptions.enableHorizontalScrollbar) !== \"undefined\" ? baseOptions.enableHorizontalScrollbar : uiGridConstants.scrollbars.ALWAYS;\n\n      /**\n       * @ngdoc boolean\n       * @name enableMinHeightCheck\n       * @propertyOf ui.grid.class:GridOptions\n       * @description True by default. When enabled, a newly initialized grid will check to see if it is tall enough to display\n       * at least one row of data.  If the grid is not tall enough, it will resize the DOM element to display minRowsToShow number\n       * of rows.\n       */\n       baseOptions.enableMinHeightCheck = baseOptions.enableMinHeightCheck !== false;\n\n      /**\n       * @ngdoc boolean\n       * @name minimumColumnSize\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Columns can't be smaller than this, defaults to 10 pixels\n       */\n      baseOptions.minimumColumnSize = typeof(baseOptions.minimumColumnSize) !== \"undefined\" ? baseOptions.minimumColumnSize : 10;\n\n      /**\n       * @ngdoc function\n       * @name rowEquality\n       * @methodOf ui.grid.class:GridOptions\n       * @description By default, rows are compared using object equality.  This option can be overridden\n       * to compare on any data item property or function\n       * @param {object} entityA First Data Item to compare\n       * @param {object} entityB Second Data Item to compare\n       */\n      baseOptions.rowEquality = baseOptions.rowEquality || function(entityA, entityB) {\n        return entityA === entityB;\n      };\n\n      /**\n       * @ngdoc string\n       * @name headerTemplate\n       * @propertyOf ui.grid.class:GridOptions\n       * @description Null by default. When provided, this setting uses a custom header\n       * template, rather than the default template. Can be set to either the name of a template file:\n       * <pre>  $scope.gridOptions.headerTemplate = 'header_template.html';</pre>\n       * inline html\n       * <pre>  $scope.gridOptions.headerTemplate = '<div class=\"ui-grid-top-panel\" style=\"text-align: center\">I am a Custom Grid Header</div>'</pre>\n       * or the id of a precompiled template (TBD how to use this).\n       * </br>Refer to the custom header tutorial for more information.\n       * If you want no header at all, you can set to an empty div:\n       * <pre>  $scope.gridOptions.headerTemplate = '<div></div>';</pre>\n       *\n       * If you want to only have a static header, then you can set to static content.  If\n       * you want to tailor the existing column headers, then you should look at the\n       * current 'ui-grid-header.html' template in github as your starting point.\n       *\n       */\n      baseOptions.headerTemplate = baseOptions.headerTemplate || null;\n\n      /**\n       * @ngdoc string\n       * @name footerTemplate\n       * @propertyOf ui.grid.class:GridOptions\n       * @description (optional) ui-grid/ui-grid-footer by default.  This footer shows the per-column\n       * aggregation totals.\n       * When provided, this setting uses a custom footer template. Can be set to either the name of a template file 'footer_template.html', inline html\n       * <pre>'<div class=\"ui-grid-bottom-panel\" style=\"text-align: center\">I am a Custom Grid Footer</div>'</pre>, or the id\n       * of a precompiled template (TBD how to use this).  Refer to the custom footer tutorial for more information.\n       */\n      baseOptions.footerTemplate = baseOptions.footerTemplate || 'ui-grid/ui-grid-footer';\n\n      /**\n       * @ngdoc string\n       * @name gridFooterTemplate\n       * @propertyOf ui.grid.class:GridOptions\n       * @description (optional) ui-grid/ui-grid-grid-footer by default. This template by default shows the\n       * total items at the bottom of the grid, and the selected items if selection is enabled.\n       */\n      baseOptions.gridFooterTemplate = baseOptions.gridFooterTemplate || 'ui-grid/ui-grid-grid-footer';\n\n      /**\n       * @ngdoc string\n       * @name rowTemplate\n       * @propertyOf ui.grid.class:GridOptions\n       * @description 'ui-grid/ui-grid-row' by default. When provided, this setting uses a\n       * custom row template.  Can be set to either the name of a template file:\n       * <pre> $scope.gridOptions.rowTemplate = 'row_template.html';</pre>\n       * inline html\n       * <pre>  $scope.gridOptions.rowTemplate = '<div style=\"background-color: aquamarine\" ng-click=\"grid.appScope.fnOne(row)\" ng-repeat=\"col in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ui-grid-cell></div>';</pre>\n       * or the id of a precompiled template (TBD how to use this) can be provided.\n       * </br>Refer to the custom row template tutorial for more information.\n       */\n      baseOptions.rowTemplate = baseOptions.rowTemplate || 'ui-grid/ui-grid-row';\n\n      /**\n       * @ngdoc object\n       * @name appScopeProvider\n       * @propertyOf ui.grid.class:GridOptions\n       * @description by default, the parent scope of the ui-grid element will be assigned to grid.appScope\n       * this property allows you to assign any reference you want to grid.appScope\n       */\n      baseOptions.appScopeProvider = baseOptions.appScopeProvider || null;\n\n      return baseOptions;\n    }\n  };\n\n\n}]);\n\n})();\n\n(function(){\n\nangular.module('ui.grid')\n\n  /**\n   * @ngdoc function\n   * @name ui.grid.class:GridRenderContainer\n   * @description The grid has render containers, allowing the ability to have pinned columns.  If the grid\n   * is right-to-left then there may be a right render container, if left-to-right then there may\n   * be a left render container.  There is always a body render container.\n   * @param {string} name The name of the render container ('body', 'left', or 'right')\n   * @param {Grid} grid the grid the render container is in\n   * @param {object} options the render container options\n   */\n.factory('GridRenderContainer', ['gridUtil', 'uiGridConstants', function(gridUtil, uiGridConstants) {\n  function GridRenderContainer(name, grid, options) {\n    var self = this;\n\n    // if (gridUtil.type(grid) !== 'Grid') {\n    //   throw new Error('Grid argument is not a Grid object');\n    // }\n\n    self.name = name;\n\n    self.grid = grid;\n\n    // self.rowCache = [];\n    // self.columnCache = [];\n\n    self.visibleRowCache = [];\n    self.visibleColumnCache = [];\n\n    self.renderedRows = [];\n    self.renderedColumns = [];\n\n    self.prevScrollTop = 0;\n    self.prevScrolltopPercentage = 0;\n    self.prevRowScrollIndex = 0;\n\n    self.prevScrollLeft = 0;\n    self.prevScrollleftPercentage = 0;\n    self.prevColumnScrollIndex = 0;\n\n    self.columnStyles = \"\";\n\n    self.viewportAdjusters = [];\n\n    /**\n     *  @ngdoc boolean\n     *  @name hasHScrollbar\n     *  @propertyOf  ui.grid.class:GridRenderContainer\n     *  @description flag to signal that container has a horizontal scrollbar\n     */\n    self.hasHScrollbar = false;\n\n    /**\n     *  @ngdoc boolean\n     *  @name hasVScrollbar\n     *  @propertyOf  ui.grid.class:GridRenderContainer\n     *  @description flag to signal that container has a vertical scrollbar\n     */\n    self.hasVScrollbar = false;\n\n    /**\n     *  @ngdoc boolean\n     *  @name canvasHeightShouldUpdate\n     *  @propertyOf  ui.grid.class:GridRenderContainer\n     *  @description flag to signal that container should recalculate the canvas size\n     */\n    self.canvasHeightShouldUpdate = true;\n\n    /**\n     *  @ngdoc boolean\n     *  @name canvasHeight\n     *  @propertyOf  ui.grid.class:GridRenderContainer\n     *  @description last calculated canvas height value\n     */\n    self.$$canvasHeight = 0;\n\n    if (options && angular.isObject(options)) {\n      angular.extend(self, options);\n    }\n\n    grid.registerStyleComputation({\n      priority: 5,\n      func: function () {\n        self.updateColumnWidths();\n        return self.columnStyles;\n      }\n    });\n  }\n\n\n  GridRenderContainer.prototype.reset = function reset() {\n    // this.rowCache.length = 0;\n    // this.columnCache.length = 0;\n\n    this.visibleColumnCache.length = 0;\n    this.visibleRowCache.length = 0;\n\n    this.renderedRows.length = 0;\n    this.renderedColumns.length = 0;\n  };\n\n  // TODO(c0bra): calculate size?? Should this be in a stackable directive?\n\n\n  GridRenderContainer.prototype.containsColumn = function (col) {\n     return this.visibleColumnCache.indexOf(col) !== -1;\n  };\n\n  GridRenderContainer.prototype.minRowsToRender = function minRowsToRender() {\n    var self = this;\n    var minRows = 0;\n    var rowAddedHeight = 0;\n    var viewPortHeight = self.getViewportHeight();\n    for (var i = self.visibleRowCache.length - 1; rowAddedHeight < viewPortHeight && i >= 0; i--) {\n      rowAddedHeight += self.visibleRowCache[i].height;\n      minRows++;\n    }\n    return minRows;\n  };\n\n  GridRenderContainer.prototype.minColumnsToRender = function minColumnsToRender() {\n    var self = this;\n    var viewportWidth = this.getViewportWidth();\n\n    var min = 0;\n    var totalWidth = 0;\n    // self.columns.forEach(function(col, i) {\n    for (var i = 0; i < self.visibleColumnCache.length; i++) {\n      var col = self.visibleColumnCache[i];\n\n      if (totalWidth < viewportWidth) {\n        totalWidth += col.drawnWidth ? col.drawnWidth : 0;\n        min++;\n      }\n      else {\n        var currWidth = 0;\n        for (var j = i; j >= i - min; j--) {\n          currWidth += self.visibleColumnCache[j].drawnWidth ? self.visibleColumnCache[j].drawnWidth : 0;\n        }\n        if (currWidth < viewportWidth) {\n          min++;\n        }\n      }\n    }\n\n    return min;\n  };\n\n  GridRenderContainer.prototype.getVisibleRowCount = function getVisibleRowCount() {\n    return this.visibleRowCache.length;\n  };\n\n  /**\n   * @ngdoc function\n   * @name registerViewportAdjuster\n   * @methodOf ui.grid.class:GridRenderContainer\n   * @description Registers an adjuster to the render container's available width or height.  Adjusters are used\n   * to tell the render container that there is something else consuming space, and to adjust it's size\n   * appropriately.\n   * @param {function} func the adjuster function we want to register\n   */\n\n  GridRenderContainer.prototype.registerViewportAdjuster = function registerViewportAdjuster(func) {\n    this.viewportAdjusters.push(func);\n  };\n\n  /**\n   * @ngdoc function\n   * @name removeViewportAdjuster\n   * @methodOf ui.grid.class:GridRenderContainer\n   * @description Removes an adjuster, should be used when your element is destroyed\n   * @param {function} func the adjuster function we want to remove\n   */\n  GridRenderContainer.prototype.removeViewportAdjuster = function removeViewportAdjuster(func) {\n    var idx = this.viewportAdjusters.indexOf(func);\n\n    if (idx > -1) {\n      this.viewportAdjusters.splice(idx, 1);\n    }\n  };\n\n  /**\n   * @ngdoc function\n   * @name getViewportAdjustment\n   * @methodOf ui.grid.class:GridRenderContainer\n   * @description Gets the adjustment based on the viewportAdjusters.\n   * @returns {object} a hash of { height: x, width: y }.  Usually the values will be negative\n   */\n  GridRenderContainer.prototype.getViewportAdjustment = function getViewportAdjustment() {\n    var self = this;\n\n    var adjustment = { height: 0, width: 0 };\n\n    self.viewportAdjusters.forEach(function (func) {\n      adjustment = func.call(this, adjustment);\n    });\n\n    return adjustment;\n  };\n\n  GridRenderContainer.prototype.getMargin = function getMargin(side) {\n    var self = this;\n\n    var amount = 0;\n\n    self.viewportAdjusters.forEach(function (func) {\n      var adjustment = func.call(this, { height: 0, width: 0 });\n\n      if (adjustment.side && adjustment.side === side) {\n        amount += adjustment.width * -1;\n      }\n    });\n\n    return amount;\n  };\n\n  GridRenderContainer.prototype.getViewportHeight = function getViewportHeight() {\n    var self = this;\n\n    var headerHeight = (self.headerHeight) ? self.headerHeight : self.grid.headerHeight;\n\n    var viewPortHeight = self.grid.gridHeight - headerHeight - self.grid.footerHeight;\n\n\n    var adjustment = self.getViewportAdjustment();\n\n    viewPortHeight = viewPortHeight + adjustment.height;\n\n    return viewPortHeight;\n  };\n\n  GridRenderContainer.prototype.getViewportWidth = function getViewportWidth() {\n    var self = this;\n\n    var viewportWidth = self.grid.gridWidth;\n\n    //if (typeof(self.grid.verticalScrollbarWidth) !== 'undefined' && self.grid.verticalScrollbarWidth !== undefined && self.grid.verticalScrollbarWidth > 0) {\n    //  viewPortWidth = viewPortWidth - self.grid.verticalScrollbarWidth;\n    //}\n\n    // var viewportWidth = 0;\\\n    // self.visibleColumnCache.forEach(function (column) {\n    //   viewportWidth += column.drawnWidth;\n    // });\n\n    var adjustment = self.getViewportAdjustment();\n\n    viewportWidth = viewportWidth + adjustment.width;\n\n    return viewportWidth;\n  };\n\n  GridRenderContainer.prototype.getHeaderViewportWidth = function getHeaderViewportWidth() {\n    var self = this;\n\n    var viewportWidth = this.getViewportWidth();\n\n    //if (typeof(self.grid.verticalScrollbarWidth) !== 'undefined' && self.grid.verticalScrollbarWidth !== undefined && self.grid.verticalScrollbarWidth > 0) {\n    //  viewPortWidth = viewPortWidth + self.grid.verticalScrollbarWidth;\n    //}\n\n    // var adjustment = self.getViewportAdjustment();\n    // viewPortWidth = viewPortWidth + adjustment.width;\n\n    return viewportWidth;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name getCanvasHeight\n   * @methodOf ui.grid.class:GridRenderContainer\n   * @description Returns the total canvas height.   Only recalculates if canvasHeightShouldUpdate = false\n   * @returns {number} total height of all the visible rows in the container\n   */\n  GridRenderContainer.prototype.getCanvasHeight = function getCanvasHeight() {\n    var self = this;\n\n    if (!self.canvasHeightShouldUpdate) {\n      return self.$$canvasHeight;\n    }\n\n    var oldCanvasHeight = self.$$canvasHeight;\n\n    self.$$canvasHeight =  0;\n\n    self.visibleRowCache.forEach(function(row){\n      self.$$canvasHeight += row.height;\n    });\n\n\n    self.canvasHeightShouldUpdate = false;\n\n    self.grid.api.core.raise.canvasHeightChanged(oldCanvasHeight, self.$$canvasHeight);\n\n    return self.$$canvasHeight;\n  };\n\n  GridRenderContainer.prototype.getVerticalScrollLength = function getVerticalScrollLength() {\n    return this.getCanvasHeight() - this.getViewportHeight() + this.grid.scrollbarHeight;\n  };\n\n  GridRenderContainer.prototype.getCanvasWidth = function getCanvasWidth() {\n    var self = this;\n\n    var ret = self.canvasWidth;\n\n    return ret;\n  };\n\n  GridRenderContainer.prototype.setRenderedRows = function setRenderedRows(newRows) {\n    this.renderedRows.length = newRows.length;\n    for (var i = 0; i < newRows.length; i++) {\n      this.renderedRows[i] = newRows[i];\n    }\n  };\n\n  GridRenderContainer.prototype.setRenderedColumns = function setRenderedColumns(newColumns) {\n    var self = this;\n\n    // OLD:\n    this.renderedColumns.length = newColumns.length;\n    for (var i = 0; i < newColumns.length; i++) {\n      this.renderedColumns[i] = newColumns[i];\n    }\n\n    this.updateColumnOffset();\n  };\n\n  GridRenderContainer.prototype.updateColumnOffset = function updateColumnOffset() {\n    // Calculate the width of the columns on the left side that are no longer rendered.\n    //  That will be the offset for the columns as we scroll horizontally.\n    var hiddenColumnsWidth = 0;\n    for (var i = 0; i < this.currentFirstColumn; i++) {\n      hiddenColumnsWidth += this.visibleColumnCache[i].drawnWidth;\n    }\n\n    this.columnOffset = hiddenColumnsWidth;\n  };\n\n  GridRenderContainer.prototype.scrollVertical = function (newScrollTop) {\n    var vertScrollPercentage = -1;\n\n    if (newScrollTop !== this.prevScrollTop) {\n      var yDiff = newScrollTop - this.prevScrollTop;\n\n      if (yDiff > 0 ) { this.grid.scrollDirection = uiGridConstants.scrollDirection.DOWN; }\n      if (yDiff < 0 ) { this.grid.scrollDirection = uiGridConstants.scrollDirection.UP; }\n\n      var vertScrollLength = this.getVerticalScrollLength();\n\n      vertScrollPercentage = newScrollTop / vertScrollLength;\n\n      // console.log('vert', vertScrollPercentage, newScrollTop, vertScrollLength);\n\n      if (vertScrollPercentage > 1) { vertScrollPercentage = 1; }\n      if (vertScrollPercentage < 0) { vertScrollPercentage = 0; }\n\n      this.adjustScrollVertical(newScrollTop, vertScrollPercentage);\n      return vertScrollPercentage;\n    }\n  };\n\n  GridRenderContainer.prototype.scrollHorizontal = function(newScrollLeft){\n    var horizScrollPercentage = -1;\n\n    // Handle RTL here\n\n    if (newScrollLeft !== this.prevScrollLeft) {\n      var xDiff = newScrollLeft - this.prevScrollLeft;\n\n      if (xDiff > 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.RIGHT; }\n      if (xDiff < 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.LEFT; }\n\n      var horizScrollLength = (this.canvasWidth - this.getViewportWidth());\n      if (horizScrollLength !== 0) {\n        horizScrollPercentage = newScrollLeft / horizScrollLength;\n      }\n      else {\n        horizScrollPercentage = 0;\n      }\n\n      this.adjustScrollHorizontal(newScrollLeft, horizScrollPercentage);\n      return horizScrollPercentage;\n    }\n  };\n\n  GridRenderContainer.prototype.adjustScrollVertical = function adjustScrollVertical(scrollTop, scrollPercentage, force) {\n    if (this.prevScrollTop === scrollTop && !force) {\n      return;\n    }\n\n    if (typeof(scrollTop) === 'undefined' || scrollTop === undefined || scrollTop === null) {\n      scrollTop = (this.getCanvasHeight() - this.getViewportHeight()) * scrollPercentage;\n    }\n\n    this.adjustRows(scrollTop, scrollPercentage, false);\n\n    this.prevScrollTop = scrollTop;\n    this.prevScrolltopPercentage = scrollPercentage;\n\n    this.grid.queueRefresh();\n  };\n\n  GridRenderContainer.prototype.adjustScrollHorizontal = function adjustScrollHorizontal(scrollLeft, scrollPercentage, force) {\n    if (this.prevScrollLeft === scrollLeft && !force) {\n      return;\n    }\n\n    if (typeof(scrollLeft) === 'undefined' || scrollLeft === undefined || scrollLeft === null) {\n      scrollLeft = (this.getCanvasWidth() - this.getViewportWidth()) * scrollPercentage;\n    }\n\n    this.adjustColumns(scrollLeft, scrollPercentage);\n\n    this.prevScrollLeft = scrollLeft;\n    this.prevScrollleftPercentage = scrollPercentage;\n\n    this.grid.queueRefresh();\n  };\n\n  GridRenderContainer.prototype.adjustRows = function adjustRows(scrollTop, scrollPercentage, postDataLoaded) {\n    var self = this;\n\n    var minRows = self.minRowsToRender();\n\n    var rowCache = self.visibleRowCache;\n\n    var maxRowIndex = rowCache.length - minRows;\n\n    // console.log('scroll%1', scrollPercentage);\n\n    // Calculate the scroll percentage according to the scrollTop location, if no percentage was provided\n    if ((typeof(scrollPercentage) === 'undefined' || scrollPercentage === null) && scrollTop) {\n      scrollPercentage = scrollTop / self.getVerticalScrollLength();\n    }\n\n    var rowIndex = Math.ceil(Math.min(maxRowIndex, maxRowIndex * scrollPercentage));\n\n    // console.log('maxRowIndex / scroll%', maxRowIndex, scrollPercentage, rowIndex);\n\n    // Define a max row index that we can't scroll past\n    if (rowIndex > maxRowIndex) {\n      rowIndex = maxRowIndex;\n    }\n\n    var newRange = [];\n    if (rowCache.length > self.grid.options.virtualizationThreshold) {\n      if (!(typeof(scrollTop) === 'undefined' || scrollTop === null)) {\n        // Have we hit the threshold going down?\n        if ( !self.grid.suppressParentScrollDown && self.prevScrollTop < scrollTop && rowIndex < self.prevRowScrollIndex + self.grid.options.scrollThreshold && rowIndex < maxRowIndex) {\n          return;\n        }\n        //Have we hit the threshold going up?\n        if ( !self.grid.suppressParentScrollUp && self.prevScrollTop > scrollTop && rowIndex > self.prevRowScrollIndex - self.grid.options.scrollThreshold && rowIndex < maxRowIndex) {\n          return;\n        }\n      }\n      var rangeStart = {};\n      var rangeEnd = {};\n\n      rangeStart = Math.max(0, rowIndex - self.grid.options.excessRows);\n      rangeEnd = Math.min(rowCache.length, rowIndex + minRows + self.grid.options.excessRows);\n\n      newRange = [rangeStart, rangeEnd];\n    }\n    else {\n      var maxLen = self.visibleRowCache.length;\n      newRange = [0, Math.max(maxLen, minRows + self.grid.options.excessRows)];\n    }\n\n    self.updateViewableRowRange(newRange);\n\n    self.prevRowScrollIndex = rowIndex;\n  };\n\n  GridRenderContainer.prototype.adjustColumns = function adjustColumns(scrollLeft, scrollPercentage) {\n    var self = this;\n\n    var minCols = self.minColumnsToRender();\n\n    var columnCache = self.visibleColumnCache;\n    var maxColumnIndex = columnCache.length - minCols;\n\n    // Calculate the scroll percentage according to the scrollLeft location, if no percentage was provided\n    if ((typeof(scrollPercentage) === 'undefined' || scrollPercentage === null) && scrollLeft) {\n      var horizScrollLength = (self.getCanvasWidth() - self.getViewportWidth());\n      scrollPercentage = scrollLeft / horizScrollLength;\n    }\n\n    var colIndex = Math.ceil(Math.min(maxColumnIndex, maxColumnIndex * scrollPercentage));\n\n    // Define a max row index that we can't scroll past\n    if (colIndex > maxColumnIndex) {\n      colIndex = maxColumnIndex;\n    }\n\n    var newRange = [];\n    if (columnCache.length > self.grid.options.columnVirtualizationThreshold && self.getCanvasWidth() > self.getViewportWidth()) {\n      /* Commented the following lines because otherwise the moved column wasn't visible immediately on the new position\n       * in the case of many columns with horizontal scroll, one had to scroll left or right and then return in order to see it\n      // Have we hit the threshold going down?\n      if (self.prevScrollLeft < scrollLeft && colIndex < self.prevColumnScrollIndex + self.grid.options.horizontalScrollThreshold && colIndex < maxColumnIndex) {\n        return;\n      }\n      //Have we hit the threshold going up?\n      if (self.prevScrollLeft > scrollLeft && colIndex > self.prevColumnScrollIndex - self.grid.options.horizontalScrollThreshold && colIndex < maxColumnIndex) {\n        return;\n      }*/\n\n      var rangeStart = Math.max(0, colIndex - self.grid.options.excessColumns);\n      var rangeEnd = Math.min(columnCache.length, colIndex + minCols + self.grid.options.excessColumns);\n\n      newRange = [rangeStart, rangeEnd];\n    }\n    else {\n      var maxLen = self.visibleColumnCache.length;\n\n      newRange = [0, Math.max(maxLen, minCols + self.grid.options.excessColumns)];\n    }\n\n    self.updateViewableColumnRange(newRange);\n\n    self.prevColumnScrollIndex = colIndex;\n  };\n\n  // Method for updating the visible rows\n  GridRenderContainer.prototype.updateViewableRowRange = function updateViewableRowRange(renderedRange) {\n    // Slice out the range of rows from the data\n    // var rowArr = uiGridCtrl.grid.rows.slice(renderedRange[0], renderedRange[1]);\n    var rowArr = this.visibleRowCache.slice(renderedRange[0], renderedRange[1]);\n\n    // Define the top-most rendered row\n    this.currentTopRow = renderedRange[0];\n\n    this.setRenderedRows(rowArr);\n  };\n\n  // Method for updating the visible columns\n  GridRenderContainer.prototype.updateViewableColumnRange = function updateViewableColumnRange(renderedRange) {\n    // Slice out the range of rows from the data\n    // var columnArr = uiGridCtrl.grid.columns.slice(renderedRange[0], renderedRange[1]);\n    var columnArr = this.visibleColumnCache.slice(renderedRange[0], renderedRange[1]);\n\n    // Define the left-most rendered columns\n    this.currentFirstColumn = renderedRange[0];\n\n    this.setRenderedColumns(columnArr);\n  };\n\n  GridRenderContainer.prototype.headerCellWrapperStyle = function () {\n    var self = this;\n\n    if (self.currentFirstColumn !== 0) {\n      var offset = self.columnOffset;\n\n      if (self.grid.isRTL()) {\n        return { 'margin-right': offset + 'px' };\n      }\n      else {\n        return { 'margin-left': offset + 'px' };\n      }\n    }\n\n    return null;\n  };\n\n    /**\n     *  @ngdoc boolean\n     *  @name updateColumnWidths\n     *  @propertyOf  ui.grid.class:GridRenderContainer\n     *  @description Determine the appropriate column width of each column across all render containers.\n     *\n     *  Column width is easy when each column has a specified width.  When columns are variable width (i.e.\n     *  have an * or % of the viewport) then we try to calculate so that things fit in.  The problem is that\n     *  we have multiple render containers, and we don't want one render container to just take the whole viewport\n     *  when it doesn't need to - we want things to balance out across the render containers.\n     *\n     *  To do this, we use this method to calculate all the renderContainers, recognising that in a given render\n     *  cycle it'll get called once per render container, so it needs to return the same values each time.\n     *\n     *  The constraints on this method are therefore:\n     *  - must return the same value when called multiple times, to do this it needs to rely on properties of the\n     *    columns, but not properties that change when this is called (so it shouldn't rely on drawnWidth)\n     *\n     *  The general logic of this method is:\n     *  - calculate our total available width\n     *  - look at all the columns across all render containers, and work out which have widths and which have\n     *    constraints such as % or * or something else\n     *  - for those with *, count the total number of * we see and add it onto a running total, add this column to an * array\n     *  - for those with a %, allocate the % as a percentage of the viewport, having consideration of min and max\n     *  - for those with manual width (in pixels) we set the drawnWidth to the specified width\n     *  - we end up with an asterisks array still to process\n     *  - we look at our remaining width.  If it's greater than zero, we divide it up among the asterisk columns, then process\n     *    them for min and max width constraints\n     *  - if it's zero or less, we set the asterisk columns to their minimum widths\n     *  - we use parseInt quite a bit, as we try to make all our column widths integers\n     */\n  GridRenderContainer.prototype.updateColumnWidths = function () {\n    var self = this;\n\n    var asterisksArray = [],\n        asteriskNum = 0,\n        usedWidthSum = 0,\n        ret = '';\n\n    // Get the width of the viewport\n    var availableWidth = self.grid.getViewportWidth() - self.grid.scrollbarWidth;\n\n    // get all the columns across all render containers, we have to calculate them all or one render container\n    // could consume the whole viewport\n    var columnCache = [];\n    angular.forEach(self.grid.renderContainers, function( container, name){\n      columnCache = columnCache.concat(container.visibleColumnCache);\n    });\n\n    // look at each column, process any manual values or %, put the * into an array to look at later\n    columnCache.forEach(function(column, i) {\n      var width = 0;\n      // Skip hidden columns\n      if (!column.visible) { return; }\n\n      if (angular.isNumber(column.width)) {\n        // pixel width, set to this value\n        width = parseInt(column.width, 10);\n        usedWidthSum = usedWidthSum + width;\n        column.drawnWidth = width;\n\n      } else if (gridUtil.endsWith(column.width, \"%\")) {\n        // percentage width, set to percentage of the viewport\n        width = parseInt(parseInt(column.width.replace(/%/g, ''), 10) / 100 * availableWidth);\n\n        if ( width > column.maxWidth ){\n          width = column.maxWidth;\n        }\n\n        if ( width < column.minWidth ){\n          width = column.minWidth;\n        }\n\n        usedWidthSum = usedWidthSum + width;\n        column.drawnWidth = width;\n      } else if (angular.isString(column.width) && column.width.indexOf('*') !== -1) {\n        // is an asterisk column, the gridColumn already checked the string consists only of '****'\n        asteriskNum = asteriskNum + column.width.length;\n        asterisksArray.push(column);\n      }\n    });\n\n    // Get the remaining width (available width subtracted by the used widths sum)\n    var remainingWidth = availableWidth - usedWidthSum;\n\n    var i, column, colWidth;\n\n    if (asterisksArray.length > 0) {\n      // the width that each asterisk value would be assigned (this can be negative)\n      var asteriskVal = remainingWidth / asteriskNum;\n\n      asterisksArray.forEach(function( column ){\n        var width = parseInt(column.width.length * asteriskVal, 10);\n\n        if ( width > column.maxWidth ){\n          width = column.maxWidth;\n        }\n\n        if ( width < column.minWidth ){\n          width = column.minWidth;\n        }\n\n        usedWidthSum = usedWidthSum + width;\n        column.drawnWidth = width;\n      });\n    }\n\n    // If the grid width didn't divide evenly into the column widths and we have pixels left over, or our\n    // calculated widths would have the grid narrower than the available space,\n    // dole the remainder out one by one to make everything fit\n    var processColumnUpwards = function(column){\n      if ( column.drawnWidth < column.maxWidth && leftoverWidth > 0) {\n        column.drawnWidth++;\n        usedWidthSum++;\n        leftoverWidth--;\n        columnsToChange = true;\n      }\n    };\n\n    var leftoverWidth = availableWidth - usedWidthSum;\n    var columnsToChange = true;\n\n    while (leftoverWidth > 0 && columnsToChange) {\n      columnsToChange = false;\n      asterisksArray.forEach(processColumnUpwards);\n    }\n\n    // We can end up with too much width even though some columns aren't at their max width, in this situation\n    // we can trim the columns a little\n    var processColumnDownwards = function(column){\n      if ( column.drawnWidth > column.minWidth && excessWidth > 0) {\n        column.drawnWidth--;\n        usedWidthSum--;\n        excessWidth--;\n        columnsToChange = true;\n      }\n    };\n\n    var excessWidth =  usedWidthSum - availableWidth;\n    columnsToChange = true;\n\n    while (excessWidth > 0 && columnsToChange) {\n      columnsToChange = false;\n      asterisksArray.forEach(processColumnDownwards);\n    }\n\n\n    // all that was across all the renderContainers, now we need to work out what that calculation decided for\n    // our renderContainer\n    var canvasWidth = 0;\n    self.visibleColumnCache.forEach(function(column){\n      if ( column.visible ){\n        canvasWidth = canvasWidth + column.drawnWidth;\n      }\n    });\n\n    // Build the CSS\n    columnCache.forEach(function (column) {\n      ret = ret + column.getColClassDefinition();\n    });\n\n    self.canvasWidth = canvasWidth;\n\n    // Return the styles back to buildStyles which pops them into the `customStyles` scope variable\n    // return ret;\n\n    // Set this render container's column styles so they can be used in style computation\n    this.columnStyles = ret;\n  };\n\n  GridRenderContainer.prototype.needsHScrollbarPlaceholder = function () {\n    return this.grid.options.enableHorizontalScrollbar && !this.hasHScrollbar && !this.grid.disableScrolling;\n  };\n\n  GridRenderContainer.prototype.getViewportStyle = function () {\n    var self = this;\n    var styles = {};\n\n    self.hasHScrollbar = false;\n    self.hasVScrollbar = false;\n\n    if (self.grid.disableScrolling) {\n      styles['overflow-x'] = 'hidden';\n      styles['overflow-y'] = 'hidden';\n      return styles;\n    }\n\n    if (self.name === 'body') {\n      self.hasHScrollbar = self.grid.options.enableHorizontalScrollbar !== uiGridConstants.scrollbars.NEVER;\n      if (!self.grid.isRTL()) {\n        if (!self.grid.hasRightContainerColumns()) {\n          self.hasVScrollbar = self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER;\n        }\n      }\n      else {\n        if (!self.grid.hasLeftContainerColumns()) {\n          self.hasVScrollbar = self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER;\n        }\n      }\n    }\n    else if (self.name === 'left') {\n      self.hasVScrollbar = self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;\n    }\n    else {\n      self.hasVScrollbar = !self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;\n    }\n\n    styles['overflow-x'] = self.hasHScrollbar ? 'scroll' : 'hidden';\n    styles['overflow-y'] = self.hasVScrollbar ? 'scroll' : 'hidden';\n\n\n    return styles;\n\n\n  };\n\n  return GridRenderContainer;\n}]);\n\n})();\n\n(function(){\n\nangular.module('ui.grid')\n.factory('GridRow', ['gridUtil', function(gridUtil) {\n\n   /**\n   * @ngdoc function\n   * @name ui.grid.class:GridRow\n   * @description GridRow is the viewModel for one logical row on the grid.  A grid Row is not necessarily a one-to-one\n   * relation to gridOptions.data.\n   * @param {object} entity the array item from GridOptions.data\n   * @param {number} index the current position of the row in the array\n   * @param {Grid} reference to the parent grid\n   */\n  function GridRow(entity, index, grid) {\n\n     /**\n      *  @ngdoc object\n      *  @name grid\n      *  @propertyOf  ui.grid.class:GridRow\n      *  @description A reference back to the grid\n      */\n     this.grid = grid;\n\n     /**\n      *  @ngdoc object\n      *  @name entity\n      *  @propertyOf  ui.grid.class:GridRow\n      *  @description A reference to an item in gridOptions.data[]\n      */\n    this.entity = entity;\n\n     /**\n      *  @ngdoc object\n      *  @name uid\n      *  @propertyOf  ui.grid.class:GridRow\n      *  @description  UniqueId of row\n      */\n     this.uid = gridUtil.nextUid();\n\n     /**\n      *  @ngdoc object\n      *  @name visible\n      *  @propertyOf  ui.grid.class:GridRow\n      *  @description If true, the row will be rendered\n      */\n    // Default to true\n    this.visible = true;\n\n\n    this.$$height = grid.options.rowHeight;\n\n  }\n\n    /**\n     *  @ngdoc object\n     *  @name height\n     *  @propertyOf  ui.grid.class:GridRow\n     *  @description height of each individual row. changing the height will flag all\n     *  row renderContainers to recalculate their canvas height\n     */\n    Object.defineProperty(GridRow.prototype, 'height', {\n      get: function() {\n        return this.$$height;\n      },\n      set: function(height) {\n        if (height !== this.$$height) {\n          this.grid.updateCanvasHeight();\n          this.$$height = height;\n        }\n      }\n    });\n\n  /**\n   * @ngdoc function\n   * @name getQualifiedColField\n   * @methodOf ui.grid.class:GridRow\n   * @description returns the qualified field name as it exists on scope\n   * ie: row.entity.fieldA\n   * @param {GridCol} col column instance\n   * @returns {string} resulting name that can be evaluated on scope\n   */\n    GridRow.prototype.getQualifiedColField = function(col) {\n      return 'row.' + this.getEntityQualifiedColField(col);\n    };\n\n    /**\n     * @ngdoc function\n     * @name getEntityQualifiedColField\n     * @methodOf ui.grid.class:GridRow\n     * @description returns the qualified field name minus the row path\n     * ie: entity.fieldA\n     * @param {GridCol} col column instance\n     * @returns {string} resulting name that can be evaluated against a row\n     */\n  GridRow.prototype.getEntityQualifiedColField = function(col) {\n    return gridUtil.preEval('entity.' + col.field);\n  };\n  \n  \n  /**\n   * @ngdoc function\n   * @name setRowInvisible\n   * @methodOf  ui.grid.class:GridRow\n   * @description Sets an override on the row that forces it to always\n   * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility.\n   * \n   * This method can be called from the api, passing in the gridRow we want\n   * altered.  It should really work by calling gridRow.setRowInvisible, but that's\n   * not the way I coded it, and too late to change now.  Changed to just call\n   * the internal function row.setThisRowInvisible().\n   * \n   * @param {GridRow} row the row we want to set to invisible\n   * \n   */\n  GridRow.prototype.setRowInvisible = function ( row ) {\n    if (row && row.setThisRowInvisible){\n      row.setThisRowInvisible( 'user' );\n    }\n  };\n  \n  \n  /**\n   * @ngdoc function\n   * @name clearRowInvisible\n   * @methodOf  ui.grid.class:GridRow\n   * @description Clears an override on the row that forces it to always\n   * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility.\n   * \n   * This method can be called from the api, passing in the gridRow we want\n   * altered.  It should really work by calling gridRow.clearRowInvisible, but that's\n   * not the way I coded it, and too late to change now.  Changed to just call\n   * the internal function row.clearThisRowInvisible().\n   * \n   * @param {GridRow} row the row we want to clear the invisible flag\n   * \n   */\n  GridRow.prototype.clearRowInvisible = function ( row ) {\n    if (row && row.clearThisRowInvisible){\n      row.clearThisRowInvisible( 'user' );\n    }\n  };\n  \n  \n  /**\n   * @ngdoc function\n   * @name setThisRowInvisible\n   * @methodOf  ui.grid.class:GridRow\n   * @description Sets an override on the row that forces it to always\n   * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility\n   *\n   * @param {string} reason the reason (usually the module) for the row to be invisible.\n   * E.g. grouping, user, filter\n   * @param {boolean} fromRowsProcessor whether we were called from a rowsProcessor, passed through to evaluateRowVisibility\n   */\n  GridRow.prototype.setThisRowInvisible = function ( reason, fromRowsProcessor ) {\n    if ( !this.invisibleReason ){\n      this.invisibleReason = {};\n    }\n    this.invisibleReason[reason] = true;\n    this.evaluateRowVisibility( fromRowsProcessor);\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name clearRowInvisible\n   * @methodOf ui.grid.class:GridRow\n   * @description Clears any override on the row visibility, returning it \n   * to normal visibility calculations.  Emits the rowsVisibleChanged\n   * event\n   * \n   * @param {string} reason the reason (usually the module) for the row to be invisible.\n   * E.g. grouping, user, filter\n   * @param {boolean} fromRowsProcessor whether we were called from a rowsProcessor, passed through to evaluateRowVisibility\n   */\n  GridRow.prototype.clearThisRowInvisible = function ( reason, fromRowsProcessor ) {\n    if (typeof(this.invisibleReason) !== 'undefined' ) {\n      delete this.invisibleReason[reason];\n    }\n    this.evaluateRowVisibility( fromRowsProcessor );\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name evaluateRowVisibility\n   * @methodOf ui.grid.class:GridRow\n   * @description Determines whether the row should be visible based on invisibleReason, \n   * and if it changes the row visibility, then emits the rowsVisibleChanged event.\n   * \n   * Queues a grid refresh, but doesn't call it directly to avoid hitting lots of grid refreshes.\n   * @param {boolean} fromRowProcessor if true, then it won't raise events or queue the refresh, the\n   * row processor does that already\n   */\n  GridRow.prototype.evaluateRowVisibility = function ( fromRowProcessor ) {\n    var newVisibility = true;\n    if ( typeof(this.invisibleReason) !== 'undefined' ){\n      angular.forEach(this.invisibleReason, function( value, key ){\n        if ( value ){\n          newVisibility = false;\n        }\n      });\n    }\n    \n    if ( typeof(this.visible) === 'undefined' || this.visible !== newVisibility ){\n      this.visible = newVisibility;\n      if ( !fromRowProcessor ){\n        this.grid.queueGridRefresh();\n        this.grid.api.core.raise.rowsVisibleChanged(this);\n      }\n    }\n  };\n  \n\n  return GridRow;\n}]);\n\n})();\n\n(function(){\n  'use strict';\n  /**\n   * @ngdoc object\n   * @name ui.grid.class:GridRowColumn\n   * @param {GridRow} row The row for this pair\n   * @param {GridColumn} column The column for this pair\n   * @description A row and column pair that represents the intersection of these two entities.\n   * Must be instantiated as a constructor using the `new` keyword.\n   */\n  angular.module('ui.grid')\n  .factory('GridRowColumn', ['$parse', '$filter',\n    function GridRowColumnFactory($parse, $filter){\n      var GridRowColumn = function GridRowColumn(row, col) {\n        if ( !(this instanceof GridRowColumn)){\n          throw \"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword\";\n        }\n\n        /**\n         * @ngdoc object\n         * @name row\n         * @propertyOf ui.grid.class:GridRowColumn\n         * @description {@link ui.grid.class:GridRow }\n         */\n        this.row = row;\n        /**\n         * @ngdoc object\n         * @name col\n         * @propertyOf ui.grid.class:GridRowColumn\n         * @description {@link ui.grid.class:GridColumn }\n         */\n        this.col = col;\n      };\n\n      /**\n       * @ngdoc function\n       * @name getIntersectionValueRaw\n       * @methodOf ui.grid.class:GridRowColumn\n       * @description Gets the intersection of where the row and column meet.\n       * @returns {String|Number|Object} The value from the grid data that this GridRowColumn points too.\n       *          If the column has a cellFilter this will NOT return the filtered value.\n       */\n      GridRowColumn.prototype.getIntersectionValueRaw = function(){\n        var getter = $parse(this.row.getEntityQualifiedColField(this.col));\n        var context = this.row;\n        return getter(context);\n      };\n      /**\n       * @ngdoc function\n       * @name getIntersectionValueFiltered\n       * @methodOf ui.grid.class:GridRowColumn\n       * @description Gets the intersection of where the row and column meet.\n       * @returns {String|Number|Object} The value from the grid data that this GridRowColumn points too.\n       *          If the column has a cellFilter this will also apply the filter to it and return the value that the filter displays.\n       */\n      GridRowColumn.prototype.getIntersectionValueFiltered = function(){\n        var value = this.getIntersectionValueRaw();\n        if (this.col.cellFilter && this.col.cellFilter !== ''){\n          var getFilterIfExists = function(filterName){\n            try {\n              return $filter(filterName);\n            } catch (e){\n              return null;\n            }\n          };\n          var filter = getFilterIfExists(this.col.cellFilter);\n          if (filter) { // Check if this is filter name or a filter string\n            value = filter(value);\n          } else { // We have the template version of a filter so we need to parse it apart\n            // Get the filter params out using a regex\n            // Test out this regex here https://regex101.com/r/rC5eR5/2\n            var re = /([^:]*):([^:]*):?([\\s\\S]+)?/;\n            var matches;\n            if ((matches = re.exec(this.col.cellFilter)) !== null) {\n                // View your result using the matches-variable.\n                // eg matches[0] etc.\n                value = $filter(matches[1])(value, matches[2], matches[3]);\n            }\n          }\n        }\n        return value;\n      };\n      return GridRowColumn;\n    }\n  ]);\n})();\n\n(function () {\n  angular.module('ui.grid')\n    .factory('ScrollEvent', ['gridUtil', function (gridUtil) {\n\n      /**\n       * @ngdoc function\n       * @name ui.grid.class:ScrollEvent\n       * @description Model for all scrollEvents\n       * @param {Grid} grid that owns the scroll event\n       * @param {GridRenderContainer} sourceRowContainer that owns the scroll event. Can be null\n       * @param {GridRenderContainer} sourceColContainer that owns the scroll event. Can be null\n       * @param {string} source the source of the event - from uiGridConstants.scrollEventSources or a string value of directive/service/factory.functionName\n       */\n      function ScrollEvent(grid, sourceRowContainer, sourceColContainer, source) {\n        var self = this;\n        if (!grid) {\n          throw new Error(\"grid argument is required\");\n        }\n\n        /**\n         *  @ngdoc object\n         *  @name grid\n         *  @propertyOf  ui.grid.class:ScrollEvent\n         *  @description A reference back to the grid\n         */\n         self.grid = grid;\n\n\n\n        /**\n         *  @ngdoc object\n         *  @name source\n         *  @propertyOf  ui.grid.class:ScrollEvent\n         *  @description the source of the scroll event. limited to values from uiGridConstants.scrollEventSources\n         */\n        self.source = source;\n\n\n        /**\n         *  @ngdoc object\n         *  @name noDelay\n         *  @propertyOf  ui.grid.class:ScrollEvent\n         *  @description most scroll events from the mouse or trackpad require delay to operate properly\n         *  set to false to eliminate delay.  Useful for scroll events that the grid causes, such as scrolling to make a row visible.\n         */\n        self.withDelay = true;\n\n        self.sourceRowContainer = sourceRowContainer;\n        self.sourceColContainer = sourceColContainer;\n\n        self.newScrollLeft = null;\n        self.newScrollTop = null;\n        self.x = null;\n        self.y = null;\n\n        self.verticalScrollLength = -9999999;\n        self.horizontalScrollLength = -999999;\n\n\n        /**\n         *  @ngdoc function\n         *  @name fireThrottledScrollingEvent\n         *  @methodOf  ui.grid.class:ScrollEvent\n         *  @description fires a throttled event using grid.api.core.raise.scrollEvent\n         */\n        self.fireThrottledScrollingEvent = gridUtil.throttle(function(sourceContainerId) {\n          self.grid.scrollContainers(sourceContainerId, self);\n        }, self.grid.options.wheelScrollThrottle, {trailing: true});\n\n      }\n\n\n      /**\n       *  @ngdoc function\n       *  @name getNewScrollLeft\n       *  @methodOf  ui.grid.class:ScrollEvent\n       *  @description returns newScrollLeft property if available; calculates a new value if it isn't\n       */\n      ScrollEvent.prototype.getNewScrollLeft = function(colContainer, viewport){\n        var self = this;\n\n        if (!self.newScrollLeft){\n          var scrollWidth = (colContainer.getCanvasWidth() - colContainer.getViewportWidth());\n\n          var oldScrollLeft = gridUtil.normalizeScrollLeft(viewport, self.grid);\n\n          var scrollXPercentage;\n          if (typeof(self.x.percentage) !== 'undefined' && self.x.percentage !== undefined) {\n            scrollXPercentage = self.x.percentage;\n          }\n          else if (typeof(self.x.pixels) !== 'undefined' && self.x.pixels !== undefined) {\n            scrollXPercentage = self.x.percentage = (oldScrollLeft + self.x.pixels) / scrollWidth;\n          }\n          else {\n            throw new Error(\"No percentage or pixel value provided for scroll event X axis\");\n          }\n\n          return Math.max(0, scrollXPercentage * scrollWidth);\n        }\n\n        return self.newScrollLeft;\n      };\n\n\n      /**\n       *  @ngdoc function\n       *  @name getNewScrollTop\n       *  @methodOf  ui.grid.class:ScrollEvent\n       *  @description returns newScrollTop property if available; calculates a new value if it isn't\n       */\n      ScrollEvent.prototype.getNewScrollTop = function(rowContainer, viewport){\n        var self = this;\n\n\n        if (!self.newScrollTop){\n          var scrollLength = rowContainer.getVerticalScrollLength();\n\n          var oldScrollTop = viewport[0].scrollTop;\n\n          var scrollYPercentage;\n          if (typeof(self.y.percentage) !== 'undefined' && self.y.percentage !== undefined) {\n            scrollYPercentage = self.y.percentage;\n          }\n          else if (typeof(self.y.pixels) !== 'undefined' && self.y.pixels !== undefined) {\n            scrollYPercentage = self.y.percentage = (oldScrollTop + self.y.pixels) / scrollLength;\n          }\n          else {\n            throw new Error(\"No percentage or pixel value provided for scroll event Y axis\");\n          }\n\n          return Math.max(0, scrollYPercentage * scrollLength);\n        }\n\n        return self.newScrollTop;\n      };\n\n      ScrollEvent.prototype.atTop = function(scrollTop) {\n        return (this.y && (this.y.percentage === 0 || this.verticalScrollLength < 0) && scrollTop === 0);\n      };\n\n      ScrollEvent.prototype.atBottom = function(scrollTop) {\n        return (this.y && (this.y.percentage === 1 || this.verticalScrollLength === 0) && scrollTop > 0);\n      };\n\n      ScrollEvent.prototype.atLeft = function(scrollLeft) {\n        return (this.x && (this.x.percentage === 0 || this.horizontalScrollLength < 0) && scrollLeft === 0);\n      };\n\n      ScrollEvent.prototype.atRight = function(scrollLeft) {\n        return (this.x && (this.x.percentage === 1 || this.horizontalScrollLength ===0) && scrollLeft > 0);\n      };\n\n\n      ScrollEvent.Sources = {\n        ViewPortScroll: 'ViewPortScroll',\n        RenderContainerMouseWheel: 'RenderContainerMouseWheel',\n        RenderContainerTouchMove: 'RenderContainerTouchMove',\n        Other: 99\n      };\n\n      return ScrollEvent;\n    }]);\n\n\n\n})();\n\n(function () {\n  'use strict';\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.service:gridClassFactory\n   *\n   *  @description factory to return dom specific instances of a grid\n   *\n   */\n  angular.module('ui.grid').service('gridClassFactory', ['gridUtil', '$q', '$compile', '$templateCache', 'uiGridConstants', 'Grid', 'GridColumn', 'GridRow',\n    function (gridUtil, $q, $compile, $templateCache, uiGridConstants, Grid, GridColumn, GridRow) {\n\n      var service = {\n        /**\n         * @ngdoc method\n         * @name createGrid\n         * @methodOf ui.grid.service:gridClassFactory\n         * @description Creates a new grid instance. Each instance will have a unique id\n         * @param {object} options An object map of options to pass into the created grid instance.\n         * @returns {Grid} grid\n         */\n        createGrid : function(options) {\n          options = (typeof(options) !== 'undefined') ? options : {};\n          options.id = gridUtil.newId();\n          var grid = new Grid(options);\n\n          // NOTE/TODO: rowTemplate should always be defined...\n          if (grid.options.rowTemplate) {\n            var rowTemplateFnPromise = $q.defer();\n            grid.getRowTemplateFn = rowTemplateFnPromise.promise;\n            \n            gridUtil.getTemplate(grid.options.rowTemplate)\n              .then(\n                function (template) {\n                  var rowTemplateFn = $compile(template);\n                  rowTemplateFnPromise.resolve(rowTemplateFn);\n                },\n                function (res) {\n                  // Todo handle response error here?\n                  throw new Error(\"Couldn't fetch/use row template '\" + grid.options.rowTemplate + \"'\");\n                });\n          }\n\n          grid.registerColumnBuilder(service.defaultColumnBuilder);\n\n          // Row builder for custom row templates\n          grid.registerRowBuilder(service.rowTemplateAssigner);\n\n          // Reset all rows to visible initially\n          grid.registerRowsProcessor(function allRowsVisible(rows) {\n            rows.forEach(function (row) {\n              row.evaluateRowVisibility( true );\n            }, 50);\n\n            return rows;\n          });\n\n          grid.registerColumnsProcessor(function allColumnsVisible(columns) {\n            columns.forEach(function (column) {\n              column.visible = true;\n            });\n\n            return columns;\n          }, 50);\n\n          grid.registerColumnsProcessor(function(renderableColumns) {\n              renderableColumns.forEach(function (column) {\n                  if (column.colDef.visible === false) {\n                      column.visible = false;\n                  }\n              });\n\n              return renderableColumns;\n          }, 50);\n\n\n          grid.registerRowsProcessor(grid.searchRows, 100);\n\n          // Register the default row processor, it sorts rows by selected columns\n          if (grid.options.externalSort && angular.isFunction(grid.options.externalSort)) {\n            grid.registerRowsProcessor(grid.options.externalSort, 200);\n          }\n          else {\n            grid.registerRowsProcessor(grid.sortByColumn, 200);\n          }\n\n          return grid;\n        },\n\n        /**\n         * @ngdoc function\n         * @name defaultColumnBuilder\n         * @methodOf ui.grid.service:gridClassFactory\n         * @description Processes designTime column definitions and applies them to col for the\n         *              core grid features\n         * @param {object} colDef reference to column definition\n         * @param {GridColumn} col reference to gridCol\n         * @param {object} gridOptions reference to grid options\n         */\n        defaultColumnBuilder: function (colDef, col, gridOptions) {\n\n          var templateGetPromises = [];\n\n          // Abstracts the standard template processing we do for every template type.\n          var processTemplate = function( templateType, providedType, defaultTemplate, filterType, tooltipType ) {\n            if ( !colDef[templateType] ){\n              col[providedType] = defaultTemplate;\n            } else {\n              col[providedType] = colDef[templateType];\n            }\n \n             templateGetPromises.push(gridUtil.getTemplate(col[providedType])\n                .then(\n                function (template) {\n                  if ( angular.isFunction(template) ) { template = template(); }\n                  var tooltipCall = ( tooltipType === 'cellTooltip' ) ? 'col.cellTooltip(row,col)' : 'col.headerTooltip(col)';\n                  if ( tooltipType && col[tooltipType] === false ){\n                    template = template.replace(uiGridConstants.TOOLTIP, '');\n                  } else if ( tooltipType && col[tooltipType] ){\n                    template = template.replace(uiGridConstants.TOOLTIP, 'title=\"{{' + tooltipCall + ' CUSTOM_FILTERS }}\"');\n                  }\n\n                  if ( filterType ){\n                    col[templateType] = template.replace(uiGridConstants.CUSTOM_FILTERS, function() {\n                      return col[filterType] ? \"|\" + col[filterType] : \"\";\n                    });\n                  } else {\n                    col[templateType] = template;\n                  }\n                },\n                function (res) {\n                  throw new Error(\"Couldn't fetch/use colDef.\" + templateType + \" '\" + colDef[templateType] + \"'\");\n                })\n            );\n\n          };\n\n\n          /**\n           * @ngdoc property\n           * @name cellTemplate\n           * @propertyOf ui.grid.class:GridOptions.columnDef\n           * @description a custom template for each cell in this column.  The default\n           * is ui-grid/uiGridCell.  If you are using the cellNav feature, this template\n           * must contain a div that can receive focus.\n           *\n           */\n          processTemplate( 'cellTemplate', 'providedCellTemplate', 'ui-grid/uiGridCell', 'cellFilter', 'cellTooltip' );\n          col.cellTemplatePromise = templateGetPromises[0];\n\n          /**\n           * @ngdoc property\n           * @name headerCellTemplate\n           * @propertyOf ui.grid.class:GridOptions.columnDef\n           * @description a custom template for the header for this column.  The default\n           * is ui-grid/uiGridHeaderCell\n           *\n           */\n          processTemplate( 'headerCellTemplate', 'providedHeaderCellTemplate', 'ui-grid/uiGridHeaderCell', 'headerCellFilter', 'headerTooltip' );\n\n          /**\n           * @ngdoc property\n           * @name footerCellTemplate\n           * @propertyOf ui.grid.class:GridOptions.columnDef\n           * @description a custom template for the footer for this column.  The default\n           * is ui-grid/uiGridFooterCell\n           *\n           */\n          processTemplate( 'footerCellTemplate', 'providedFooterCellTemplate', 'ui-grid/uiGridFooterCell', 'footerCellFilter' );\n\n          /**\n           * @ngdoc property\n           * @name filterHeaderTemplate\n           * @propertyOf ui.grid.class:GridOptions.columnDef\n           * @description a custom template for the filter input.  The default is ui-grid/ui-grid-filter\n           *\n           */\n          processTemplate( 'filterHeaderTemplate', 'providedFilterHeaderTemplate', 'ui-grid/ui-grid-filter' );\n\n          // Create a promise for the compiled element function\n          col.compiledElementFnDefer = $q.defer();\n\n          return $q.all(templateGetPromises);\n        },\n        \n\n        rowTemplateAssigner: function rowTemplateAssigner(row) {\n          var grid = this;\n\n          // Row has no template assigned to it\n          if (!row.rowTemplate) {\n            // Use the default row template from the grid\n            row.rowTemplate = grid.options.rowTemplate;\n\n            // Use the grid's function for fetching the compiled row template function\n            row.getRowTemplateFn = grid.getRowTemplateFn;\n          }\n          // Row has its own template assigned\n          else {\n            // Create a promise for the compiled row template function\n            var perRowTemplateFnPromise = $q.defer();\n            row.getRowTemplateFn = perRowTemplateFnPromise.promise;\n\n            // Get the row template\n            gridUtil.getTemplate(row.rowTemplate)\n              .then(function (template) {\n                // Compile the template\n                var rowTemplateFn = $compile(template);\n                \n                // Resolve the compiled template function promise\n                perRowTemplateFnPromise.resolve(rowTemplateFn);\n              },\n              function (res) {\n                // Todo handle response error here?\n                throw new Error(\"Couldn't fetch/use row template '\" + row.rowTemplate + \"'\");\n              });\n          }\n\n          return row.getRowTemplateFn;\n        }\n      };\n\n      //class definitions (moved to separate factories)\n\n      return service;\n    }]);\n\n})();\n\n(function() {\n\nvar module = angular.module('ui.grid');\n\nfunction escapeRegExp(str) {\n  return str.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\");\n}\n\n\n/**\n *  @ngdoc service\n *  @name ui.grid.service:rowSearcher\n *\n *  @description Service for searching/filtering rows based on column value conditions.\n */\nmodule.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil, uiGridConstants) {\n  var defaultCondition = uiGridConstants.filter.CONTAINS;\n\n  var rowSearcher = {};\n\n  /**\n   * @ngdoc function\n   * @name getTerm\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Get the term from a filter\n   * Trims leading and trailing whitespace\n   * @param {object} filter object to use\n   * @returns {object} Parsed term\n   */\n  rowSearcher.getTerm = function getTerm(filter) {\n    if (typeof(filter.term) === 'undefined') { return filter.term; }\n    \n    var term = filter.term;\n\n    // Strip leading and trailing whitespace if the term is a string\n    if (typeof(term) === 'string') {\n      term = term.trim();\n    }\n\n    return term;\n  };\n\n  /**\n   * @ngdoc function\n   * @name stripTerm\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Remove leading and trailing asterisk (*) from the filter's term\n   * @param {object} filter object to use\n   * @returns {uiGridConstants.filter<int>} Value representing the condition constant value\n   */\n  rowSearcher.stripTerm = function stripTerm(filter) {\n    var term = rowSearcher.getTerm(filter);\n\n    if (typeof(term) === 'string') {\n      return escapeRegExp(term.replace(/(^\\*|\\*$)/g, ''));\n    }\n    else {\n      return term;\n    }\n  };\n  \n\n  /**\n   * @ngdoc function\n   * @name guessCondition\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Guess the condition for a filter based on its term\n   * <br>\n   * Defaults to STARTS_WITH. Uses CONTAINS for strings beginning and ending with *s (*bob*).\n   * Uses STARTS_WITH for strings ending with * (bo*). Uses ENDS_WITH for strings starting with * (*ob).\n   * @param {object} filter object to use\n   * @returns {uiGridConstants.filter<int>} Value representing the condition constant value\n   */\n  rowSearcher.guessCondition = function guessCondition(filter) {\n    if (typeof(filter.term) === 'undefined' || !filter.term) {\n      return defaultCondition;\n    }\n\n    var term = rowSearcher.getTerm(filter);\n    \n    if (/\\*/.test(term)) {\n      var regexpFlags = '';\n      if (!filter.flags || !filter.flags.caseSensitive) {\n        regexpFlags += 'i';\n      }\n\n      var reText = term.replace(/(\\\\)?\\*/g, function ($0, $1) { return $1 ? $0 : '[\\\\s\\\\S]*?'; });\n      return new RegExp('^' + reText + '$', regexpFlags);\n    }\n    // Otherwise default to default condition\n    else {\n      return defaultCondition;\n    }\n  };\n  \n  \n  /**\n   * @ngdoc function\n   * @name setupFilters\n   * @methodOf ui.grid.service:rowSearcher\n   * @description For a given columns filters (either col.filters, or [col.filter] can be passed in),\n   * do all the parsing and pre-processing and store that data into a new filters object.  The object\n   * has the condition, the flags, the stripped term, and a parsed reg exp if there was one.\n   * \n   * We could use a forEach in here, since it's much less performance sensitive, but since we're using \n   * for loops everywhere else in this module...\n   * \n   * @param {array} filters the filters from the column (col.filters or [col.filter])\n   * @returns {array} An array of parsed/preprocessed filters\n   */\n  rowSearcher.setupFilters = function setupFilters( filters ){\n    var newFilters = [];\n    \n    var filtersLength = filters.length;\n    for ( var i = 0; i < filtersLength; i++ ){\n      var filter = filters[i];\n      \n      if ( filter.noTerm || !gridUtil.isNullOrUndefined(filter.term) ){\n        var newFilter = {};\n        \n        var regexpFlags = '';\n        if (!filter.flags || !filter.flags.caseSensitive) {\n          regexpFlags += 'i';\n        }\n    \n        if ( !gridUtil.isNullOrUndefined(filter.term) ){\n          // it is possible to have noTerm.  We don't need to copy that across, it was just a flag to avoid\n          // getting the filter ignored if the filter was a function that didn't use a term\n          newFilter.term = rowSearcher.stripTerm(filter);\n        }\n        \n        if ( filter.condition ){\n          newFilter.condition = filter.condition;\n        } else {\n          newFilter.condition = rowSearcher.guessCondition(filter);\n        }\n\n        newFilter.flags = angular.extend( { caseSensitive: false, date: false }, filter.flags );\n\n        if (newFilter.condition === uiGridConstants.filter.STARTS_WITH) {\n          newFilter.startswithRE = new RegExp('^' + newFilter.term, regexpFlags);\n        }\n        \n         if (newFilter.condition === uiGridConstants.filter.ENDS_WITH) {\n          newFilter.endswithRE = new RegExp(newFilter.term + '$', regexpFlags);\n        }\n\n        if (newFilter.condition === uiGridConstants.filter.CONTAINS) {\n          newFilter.containsRE = new RegExp(newFilter.term, regexpFlags);\n        }\n\n        if (newFilter.condition === uiGridConstants.filter.EXACT) {\n          newFilter.exactRE = new RegExp('^' + newFilter.term + '$', regexpFlags);\n        }\n        \n        newFilters.push(newFilter);\n      }\n    }\n    return newFilters;\n  };\n  \n\n  /**\n   * @ngdoc function\n   * @name runColumnFilter\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Runs a single pre-parsed filter against a cell, returning true\n   * if the cell matches that one filter.\n   * \n   * @param {Grid} grid the grid we're working against\n   * @param {GridRow} row the row we're matching against\n   * @param {GridCol} column the column that we're working against\n   * @param {object} filter the specific, preparsed, filter that we want to test\n   * @returns {boolean} true if we match (row stays visible)\n   */\n  rowSearcher.runColumnFilter = function runColumnFilter(grid, row, column, filter) {\n    // Cache typeof condition\n    var conditionType = typeof(filter.condition);\n\n    // Term to search for.\n    var term = filter.term;\n\n    // Get the column value for this row\n    var value;\n    if ( column.filterCellFiltered ){\n      value = grid.getCellDisplayValue(row, column);\n    } else {\n      value = grid.getCellValue(row, column);\n    }\n\n\n    // If the filter's condition is a RegExp, then use it\n    if (filter.condition instanceof RegExp) {\n      return filter.condition.test(value);\n    }\n\n    // If the filter's condition is a function, run it\n    if (conditionType === 'function') {\n      return filter.condition(term, value, row, column);\n    }\n\n    if (filter.startswithRE) {\n      return filter.startswithRE.test(value);\n    }\n\n    if (filter.endswithRE) {\n      return filter.endswithRE.test(value);\n    }\n\n    if (filter.containsRE) {\n      return filter.containsRE.test(value);\n    }\n\n    if (filter.exactRE) {\n      return filter.exactRE.test(value);\n    }\n\n    if (filter.condition === uiGridConstants.filter.NOT_EQUAL) {\n      var regex = new RegExp('^' + term + '$');\n      return !regex.exec(value);\n    }\n\n    if (typeof(value) === 'number' && typeof(term) === 'string' ){\n      // if the term has a decimal in it, it comes through as '9\\.4', we need to take out the \\\n      // the same for negative numbers\n      // TODO: I suspect the right answer is to look at escapeRegExp at the top of this code file, maybe it's not needed?\n      var tempFloat = parseFloat(term.replace(/\\\\\\./,'.').replace(/\\\\\\-/,'-'));\n      if (!isNaN(tempFloat)) {\n        term = tempFloat;\n      }\n    }\n\n    if (filter.flags.date === true) {\n      value = new Date(value);\n      // If the term has a dash in it, it comes through as '\\-' -- we need to take out the '\\'.\n      term = new Date(term.replace(/\\\\/g, ''));\n    }\n\n    if (filter.condition === uiGridConstants.filter.GREATER_THAN) {\n      return (value > term);\n    }\n\n    if (filter.condition === uiGridConstants.filter.GREATER_THAN_OR_EQUAL) {\n      return (value >= term);\n    }\n\n    if (filter.condition === uiGridConstants.filter.LESS_THAN) {\n      return (value < term);\n    }\n\n    if (filter.condition === uiGridConstants.filter.LESS_THAN_OR_EQUAL) {\n      return (value <= term);\n    }\n\n    return true;\n  };\n\n\n  /**\n   * @ngdoc boolean\n   * @name useExternalFiltering\n   * @propertyOf ui.grid.class:GridOptions\n   * @description False by default. When enabled, this setting suppresses the internal filtering.\n   * All UI logic will still operate, allowing filter conditions to be set and modified.\n   * \n   * The external filter logic can listen for the `filterChange` event, which fires whenever\n   * a filter has been adjusted.\n   */\n  /**\n   * @ngdoc function\n   * @name searchColumn\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Process provided filters on provided column against a given row. If the row meets \n   * the conditions on all the filters, return true.\n   * @param {Grid} grid Grid to search in\n   * @param {GridRow} row Row to search on\n   * @param {GridCol} column Column with the filters to use\n   * @param {array} filters array of pre-parsed/preprocessed filters to apply\n   * @returns {boolean} Whether the column matches or not.\n   */\n  rowSearcher.searchColumn = function searchColumn(grid, row, column, filters) {\n    if (grid.options.useExternalFiltering) {\n      return true;\n    }\n\n    var filtersLength = filters.length;\n    for (var i = 0; i < filtersLength; i++) {\n      var filter = filters[i];\n\n      var ret = rowSearcher.runColumnFilter(grid, row, column, filter);\n      if (!ret) {\n        return false;\n      }\n    }\n\n    return true;\n  };\n\n\n  /**\n   * @ngdoc function\n   * @name search\n   * @methodOf ui.grid.service:rowSearcher\n   * @description Run a search across the given rows and columns, marking any rows that don't \n   * match the stored col.filters or col.filter as invisible.\n   * @param {Grid} grid Grid instance to search inside\n   * @param {Array[GridRow]} rows GridRows to filter\n   * @param {Array[GridColumn]} columns GridColumns with filters to process\n   */\n  rowSearcher.search = function search(grid, rows, columns) {\n    /*\n     * Added performance optimisations into this code base, as this logic creates deeply nested\n     * loops and is therefore very performance sensitive.  In particular, avoiding forEach as\n     * this impacts some browser optimisers (particularly Chrome), using iterators instead\n     */\n\n    // Don't do anything if we weren't passed any rows\n    if (!rows) {\n      return;\n    }\n\n    // don't filter if filtering currently disabled\n    if (!grid.options.enableFiltering){\n      return rows;\n    }\n\n    // Build list of filters to apply\n    var filterData = [];\n\n    var colsLength = columns.length;\n\n    var hasTerm = function( filters ) {\n      var hasTerm = false;\n\n      filters.forEach( function (filter) {\n        if ( !gridUtil.isNullOrUndefined(filter.term) && filter.term !== '' || filter.noTerm ){\n          hasTerm = true;\n        }\n      });\n\n      return hasTerm;\n    };\n\n    for (var i = 0; i < colsLength; i++) {\n      var col = columns[i];\n\n      if (typeof(col.filters) !== 'undefined' && hasTerm(col.filters) ) {\n        filterData.push( { col: col, filters: rowSearcher.setupFilters(col.filters) } );\n      }\n    }\n\n    if (filterData.length > 0) {\n      // define functions outside the loop, performance optimisation\n      var foreachRow = function(grid, row, col, filters){\n        if ( row.visible && !rowSearcher.searchColumn(grid, row, col, filters) ) {\n          row.visible = false;\n        }\n      };\n\n      var foreachFilterCol = function(grid, filterData){\n        var rowsLength = rows.length;\n        for ( var i = 0; i < rowsLength; i++){\n          foreachRow(grid, rows[i], filterData.col, filterData.filters);  \n        }\n      };\n\n      // nested loop itself - foreachFilterCol, which in turn calls foreachRow\n      var filterDataLength = filterData.length;\n      for ( var j = 0; j < filterDataLength; j++){\n        foreachFilterCol( grid, filterData[j] );  \n      }\n\n      if (grid.api.core.raise.rowsVisibleChanged) {\n        grid.api.core.raise.rowsVisibleChanged();\n      }\n\n      // drop any invisible rows\n      // keeping these, as needed with filtering for trees - we have to come back and make parent nodes visible if child nodes are selected in the filter\n      // rows = rows.filter(function(row){ return row.visible; });\n\n    }\n\n    return rows;\n  };\n\n  return rowSearcher;\n}]);\n\n})();\n\n(function() {\n\nvar module = angular.module('ui.grid');\n\n/**\n * @ngdoc object\n * @name ui.grid.class:RowSorter\n * @description RowSorter provides the default sorting mechanisms,\n * including guessing column types and applying appropriate sort\n * algorithms\n *\n */\n\nmodule.service('rowSorter', ['$parse', 'uiGridConstants', function ($parse, uiGridConstants) {\n  var currencyRegexStr =\n    '(' +\n    uiGridConstants.CURRENCY_SYMBOLS\n      .map(function (a) { return '\\\\' + a; }) // Escape all the currency symbols ($ at least will jack up this regex)\n      .join('|') + // Join all the symbols together with |s\n    ')?';\n\n  // /^[-+]?[£$¤¥]?[\\d,.]+%?$/\n  var numberStrRegex = new RegExp('^[-+]?' + currencyRegexStr + '[\\\\d,.]+' + currencyRegexStr + '%?$');\n\n  var rowSorter = {\n    // Cache of sorting functions. Once we create them, we don't want to keep re-doing it\n    //   this takes a piece of data from the cell and tries to determine its type and what sorting\n    //   function to use for it\n    colSortFnCache: {}\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name guessSortFn\n   * @description Assigns a sort function to use based on the itemType in the column\n   * @param {string} itemType one of 'number', 'boolean', 'string', 'date', 'object'.  And\n   * error will be thrown for any other type.\n   * @returns {function} a sort function that will sort that type\n   */\n  rowSorter.guessSortFn = function guessSortFn(itemType) {\n    switch (itemType) {\n      case \"number\":\n        return rowSorter.sortNumber;\n      case \"numberStr\":\n        return rowSorter.sortNumberStr;\n      case \"boolean\":\n        return rowSorter.sortBool;\n      case \"string\":\n        return rowSorter.sortAlpha;\n      case \"date\":\n        return rowSorter.sortDate;\n      case \"object\":\n        return rowSorter.basicSort;\n      default:\n        throw new Error('No sorting function found for type:' + itemType);\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name handleNulls\n   * @description Sorts nulls and undefined to the bottom (top when\n   * descending).  Called by each of the internal sorters before\n   * attempting to sort.  Note that this method is available on the core api\n   * via gridApi.core.sortHandleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} null if there were no nulls/undefineds, otherwise returns\n   * a sort value that should be passed back from the sort function\n   */\n  rowSorter.handleNulls = function handleNulls(a, b) {\n    // We want to allow zero values and false values to be evaluated in the sort function\n    if ((!a && a !== 0 && a !== false) || (!b && b !== 0 && b !== false)) {\n      // We want to force nulls and such to the bottom when we sort... which effectively is \"greater than\"\n      if ((!a && a !== 0 && a !== false) && (!b && b !== 0 && b !== false)) {\n        return 0;\n      }\n      else if (!a && a !== 0 && a !== false) {\n        return 1;\n      }\n      else if (!b && b !== 0 && b !== false) {\n        return -1;\n      }\n    }\n    return null;\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name basicSort\n   * @description Sorts any values that provide the < method, including strings\n   * or numbers.  Handles nulls and undefined through calling handleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.basicSort = function basicSort(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      if (a === b) {\n        return 0;\n      }\n      if (a < b) {\n        return -1;\n      }\n      return 1;\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sortNumber\n   * @description Sorts numerical values.  Handles nulls and undefined through calling handleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.sortNumber = function sortNumber(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      return a - b;\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sortNumberStr\n   * @description Sorts numerical values that are stored in a string (i.e. parses them to numbers first).\n   * Handles nulls and undefined through calling handleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.sortNumberStr = function sortNumberStr(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      var numA, // The parsed number form of 'a'\n          numB, // The parsed number form of 'b'\n          badA = false,\n          badB = false;\n\n      // Try to parse 'a' to a float\n      numA = parseFloat(a.replace(/[^0-9.-]/g, ''));\n\n      // If 'a' couldn't be parsed to float, flag it as bad\n      if (isNaN(numA)) {\n          badA = true;\n      }\n\n      // Try to parse 'b' to a float\n      numB = parseFloat(b.replace(/[^0-9.-]/g, ''));\n\n      // If 'b' couldn't be parsed to float, flag it as bad\n      if (isNaN(numB)) {\n          badB = true;\n      }\n\n      // We want bad ones to get pushed to the bottom... which effectively is \"greater than\"\n      if (badA && badB) {\n          return 0;\n      }\n\n      if (badA) {\n          return 1;\n      }\n\n      if (badB) {\n          return -1;\n      }\n\n      return numA - numB;\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sortAlpha\n   * @description Sorts string values. Handles nulls and undefined through calling handleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.sortAlpha = function sortAlpha(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      var strA = a.toString().toLowerCase(),\n          strB = b.toString().toLowerCase();\n\n      return strA === strB ? 0 : strA.localeCompare(strB);\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sortDate\n   * @description Sorts date values. Handles nulls and undefined through calling handleNulls.\n   * Handles date strings by converting to Date object if not already an instance of Date\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.sortDate = function sortDate(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      if (!(a instanceof Date)) {\n        a = new Date(a);\n      }\n      if (!(b instanceof Date)){\n        b = new Date(b);\n      }\n      var timeA = a.getTime(),\n          timeB = b.getTime();\n\n      return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sortBool\n   * @description Sorts boolean values, true is considered larger than false.\n   * Handles nulls and undefined through calling handleNulls\n   * @param {object} a sort value a\n   * @param {object} b sort value b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.sortBool = function sortBool(a, b) {\n    var nulls = rowSorter.handleNulls(a, b);\n    if ( nulls !== null ){\n      return nulls;\n    } else {\n      if (a && b) {\n        return 0;\n      }\n\n      if (!a && !b) {\n        return 0;\n      }\n      else {\n        return a ? 1 : -1;\n      }\n    }\n  };\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name getSortFn\n   * @description Get the sort function for the column.  Looks first in\n   * rowSorter.colSortFnCache using the column name, failing that it\n   * looks at col.sortingAlgorithm (and puts it in the cache), failing that\n   * it guesses the sort algorithm based on the data type.\n   *\n   * The cache currently seems a bit pointless, as none of the work we do is\n   * processor intensive enough to need caching.  Presumably in future we might\n   * inspect the row data itself to guess the sort function, and in that case\n   * it would make sense to have a cache, the infrastructure is in place to allow\n   * that.\n   *\n   * @param {Grid} grid the grid to consider\n   * @param {GridCol} col the column to find a function for\n   * @param {array} rows an array of grid rows.  Currently unused, but presumably in future\n   * we might inspect the rows themselves to decide what sort of data might be there\n   * @returns {function} the sort function chosen for the column\n   */\n  rowSorter.getSortFn = function getSortFn(grid, col, rows) {\n    var sortFn, item;\n\n    // See if we already figured out what to use to sort the column and have it in the cache\n    if (rowSorter.colSortFnCache[col.colDef.name]) {\n      sortFn = rowSorter.colSortFnCache[col.colDef.name];\n    }\n    // If the column has its OWN sorting algorithm, use that\n    else if (col.sortingAlgorithm !== undefined) {\n      sortFn = col.sortingAlgorithm;\n      rowSorter.colSortFnCache[col.colDef.name] = col.sortingAlgorithm;\n    }\n    // Always default to sortAlpha when sorting after a cellFilter\n    else if ( col.sortCellFiltered && col.cellFilter ){\n      sortFn = rowSorter.sortAlpha;\n      rowSorter.colSortFnCache[col.colDef.name] = sortFn;\n    }\n    // Try and guess what sort function to use\n    else {\n      // Guess the sort function\n      sortFn = rowSorter.guessSortFn(col.colDef.type);\n\n      // If we found a sort function, cache it\n      if (sortFn) {\n        rowSorter.colSortFnCache[col.colDef.name] = sortFn;\n      }\n      else {\n        // We assign the alpha sort because anything that is null/undefined will never get passed to\n        // the actual sorting function. It will get caught in our null check and returned to be sorted\n        // down to the bottom\n        sortFn = rowSorter.sortAlpha;\n      }\n    }\n\n    return sortFn;\n  };\n\n\n\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name prioritySort\n   * @description Used where multiple columns are present in the sort criteria,\n   * we determine which column should take precedence in the sort by sorting\n   * the columns based on their sort.priority\n   *\n   * @param {gridColumn} a column a\n   * @param {gridColumn} b column b\n   * @returns {number} normal sort function, returns -ve, 0, +ve\n   */\n  rowSorter.prioritySort = function (a, b) {\n    // Both columns have a sort priority\n    if (a.sort.priority !== undefined && b.sort.priority !== undefined) {\n      // A is higher priority\n      if (a.sort.priority < b.sort.priority) {\n        return -1;\n      }\n      // Equal\n      else if (a.sort.priority === b.sort.priority) {\n        return 0;\n      }\n      // B is higher\n      else {\n        return 1;\n      }\n    }\n    // Only A has a priority\n    else if (a.sort.priority || a.sort.priority === undefined) {\n      return -1;\n    }\n    // Only B has a priority\n    else if (b.sort.priority || b.sort.priority === undefined) {\n      return 1;\n    }\n    // Neither has a priority\n    else {\n      return 0;\n    }\n  };\n\n\n  /**\n   * @ngdoc object\n   * @name useExternalSorting\n   * @propertyOf ui.grid.class:GridOptions\n   * @description Prevents the internal sorting from executing.  Events will\n   * still be fired when the sort changes, and the sort information on\n   * the columns will be updated, allowing an external sorter (for example,\n   * server sorting) to be implemented.  Defaults to false.\n   *\n   */\n  /**\n   * @ngdoc method\n   * @methodOf ui.grid.class:RowSorter\n   * @name sort\n   * @description sorts the grid\n   * @param {Object} grid the grid itself\n   * @param {array} rows the rows to be sorted\n   * @param {array} columns the columns in which to look\n   * for sort criteria\n   * @returns {array} sorted rows\n   */\n  rowSorter.sort = function rowSorterSort(grid, rows, columns) {\n    // first make sure we are even supposed to do work\n    if (!rows) {\n      return;\n    }\n\n    if (grid.options.useExternalSorting){\n      return rows;\n    }\n\n    // Build the list of columns to sort by\n    var sortCols = [];\n    columns.forEach(function (col) {\n      if (col.sort && !col.sort.ignoreSort && col.sort.direction && (col.sort.direction === uiGridConstants.ASC || col.sort.direction === uiGridConstants.DESC)) {\n        sortCols.push(col);\n      }\n    });\n\n    // Sort the \"sort columns\" by their sort priority\n    sortCols = sortCols.sort(rowSorter.prioritySort);\n\n    // Now rows to sort by, maintain original order\n    if (sortCols.length === 0) {\n      return rows;\n    }\n\n    // Re-usable variables\n    var col, direction;\n\n    // put a custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)\n    var setIndex = function( row, idx ){\n      row.entity.$$uiGridIndex = idx;\n    };\n    rows.forEach(setIndex);\n\n    // IE9-11 HACK.... the 'rows' variable would be empty where we call rowSorter.getSortFn(...) below. We have to use a separate reference\n    // var d = data.slice(0);\n    var r = rows.slice(0);\n\n    // Now actually sort the data\n    var rowSortFn = function (rowA, rowB) {\n      var tem = 0,\n          idx = 0,\n          sortFn;\n\n      while (tem === 0 && idx < sortCols.length) {\n        // grab the metadata for the rest of the logic\n        col = sortCols[idx];\n        direction = sortCols[idx].sort.direction;\n\n        sortFn = rowSorter.getSortFn(grid, col, r);\n\n        var propA, propB;\n\n        if ( col.sortCellFiltered ){\n          propA = grid.getCellDisplayValue(rowA, col);\n          propB = grid.getCellDisplayValue(rowB, col);\n        } else {\n          propA = grid.getCellValue(rowA, col);\n          propB = grid.getCellValue(rowB, col);\n        }\n\n        tem = sortFn(propA, propB, rowA, rowB, direction);\n\n        idx++;\n      }\n\n      // Chrome doesn't implement a stable sort function.  If our sort returns 0\n      // (i.e. the items are equal), and we're at the last sort column in the list,\n      // then return the previous order using our custom\n      // index variable\n      if (tem === 0 ) {\n        return rowA.entity.$$uiGridIndex - rowB.entity.$$uiGridIndex;\n      }\n\n      // Made it this far, we don't have to worry about null & undefined\n      if (direction === uiGridConstants.ASC) {\n        return tem;\n      } else {\n        return 0 - tem;\n      }\n    };\n\n    var newRows = rows.sort(rowSortFn);\n\n    // remove the custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)\n    var clearIndex = function( row, idx ){\n       delete row.entity.$$uiGridIndex;\n    };\n    rows.forEach(clearIndex);\n\n    return newRows;\n  };\n\n  return rowSorter;\n}]);\n\n})();\n\n(function() {\n\nvar module = angular.module('ui.grid');\n\nvar bindPolyfill;\nif (typeof Function.prototype.bind !== \"function\") {\n  bindPolyfill = function() {\n    var slice = Array.prototype.slice;\n    return function(context) {\n      var fn = this,\n        args = slice.call(arguments, 1);\n      if (args.length) {\n        return function() {\n          return arguments.length ? fn.apply(context, args.concat(slice.call(arguments))) : fn.apply(context, args);\n        };\n      }\n      return function() {\n        return arguments.length ? fn.apply(context, arguments) : fn.call(context);\n      };\n    };\n  };\n}\n\nfunction  getStyles (elem) {\n  var e = elem;\n  if (typeof(e.length) !== 'undefined' && e.length) {\n    e = elem[0];\n  }\n\n  return e.ownerDocument.defaultView.getComputedStyle(e, null);\n}\n\nvar rnumnonpx = new RegExp( \"^(\" + (/[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/).source + \")(?!px)[a-z%]+$\", \"i\" ),\n    // swappable if display is none or starts with table except \"table\", \"table-cell\", or \"table-caption\"\n    // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display\n    rdisplayswap = /^(block|none|table(?!-c[ea]).+)/,\n    cssShow = { position: \"absolute\", visibility: \"hidden\", display: \"block\" };\n\nfunction augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {\n  var i = extra === ( isBorderBox ? 'border' : 'content' ) ?\n          // If we already have the right measurement, avoid augmentation\n          4 :\n          // Otherwise initialize for horizontal or vertical properties\n          name === 'width' ? 1 : 0,\n\n          val = 0;\n\n  var sides = ['Top', 'Right', 'Bottom', 'Left'];\n\n  for ( ; i < 4; i += 2 ) {\n    var side = sides[i];\n    // dump('side', side);\n\n    // both box models exclude margin, so add it if we want it\n    if ( extra === 'margin' ) {\n      var marg = parseFloat(styles[extra + side]);\n      if (!isNaN(marg)) {\n        val += marg;\n      }\n    }\n    // dump('val1', val);\n\n    if ( isBorderBox ) {\n      // border-box includes padding, so remove it if we want content\n      if ( extra === 'content' ) {\n        var padd = parseFloat(styles['padding' + side]);\n        if (!isNaN(padd)) {\n          val -= padd;\n          // dump('val2', val);\n        }\n      }\n\n      // at this point, extra isn't border nor margin, so remove border\n      if ( extra !== 'margin' ) {\n        var bordermarg = parseFloat(styles['border' + side + 'Width']);\n        if (!isNaN(bordermarg)) {\n          val -= bordermarg;\n          // dump('val3', val);\n        }\n      }\n    }\n    else {\n      // at this point, extra isn't content, so add padding\n      var nocontentPad = parseFloat(styles['padding' + side]);\n      if (!isNaN(nocontentPad)) {\n        val += nocontentPad;\n        // dump('val4', val);\n      }\n\n      // at this point, extra isn't content nor padding, so add border\n      if ( extra !== 'padding') {\n        var nocontentnopad = parseFloat(styles['border' + side + 'Width']);\n        if (!isNaN(nocontentnopad)) {\n          val += nocontentnopad;\n          // dump('val5', val);\n        }\n      }\n    }\n  }\n\n  // dump('augVal', val);\n\n  return val;\n}\n\nfunction getWidthOrHeight( elem, name, extra ) {\n  // Start with offset property, which is equivalent to the border-box value\n  var valueIsBorderBox = true,\n          val, // = name === 'width' ? elem.offsetWidth : elem.offsetHeight,\n          styles = getStyles(elem),\n          isBorderBox = styles['boxSizing'] === 'border-box';\n\n  // some non-html elements return undefined for offsetWidth, so check for null/undefined\n  // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285\n  // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668\n  if ( val <= 0 || val == null ) {\n    // Fall back to computed then uncomputed css if necessary\n    val = styles[name];\n    if ( val < 0 || val == null ) {\n      val = elem.style[ name ];\n    }\n\n    // Computed unit is not pixels. Stop here and return.\n    if ( rnumnonpx.test(val) ) {\n      return val;\n    }\n\n    // we need the check for style in case a browser which returns unreliable values\n    // for getComputedStyle silently falls back to the reliable elem.style\n    valueIsBorderBox = isBorderBox &&\n            ( true || val === elem.style[ name ] ); // use 'true' instead of 'support.boxSizingReliable()'\n\n    // Normalize \"\", auto, and prepare for extra\n    val = parseFloat( val ) || 0;\n  }\n\n  // use the active box-sizing model to add/subtract irrelevant styles\n  var ret = ( val +\n    augmentWidthOrHeight(\n      elem,\n      name,\n      extra || ( isBorderBox ? \"border\" : \"content\" ),\n      valueIsBorderBox,\n      styles\n    )\n  );\n\n  // dump('ret', ret, val);\n  return ret;\n}\n\nfunction getLineHeight(elm) {\n  elm = angular.element(elm)[0];\n  var parent = elm.parentElement;\n\n  if (!parent) {\n    parent = document.getElementsByTagName('body')[0];\n  }\n\n  return parseInt( getStyles(parent).fontSize ) || parseInt( getStyles(elm).fontSize ) || 16;\n}\n\nvar uid = ['0', '0', '0', '0'];\nvar uidPrefix = 'uiGrid-';\n\n/**\n *  @ngdoc service\n *  @name ui.grid.service:GridUtil\n *\n *  @description Grid utility functions\n */\nmodule.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateCache', '$timeout', '$interval', '$injector', '$q', '$interpolate', 'uiGridConstants',\n  function ($log, $window, $document, $http, $templateCache, $timeout, $interval, $injector, $q, $interpolate, uiGridConstants) {\n  var s = {\n\n    augmentWidthOrHeight: augmentWidthOrHeight,\n\n    getStyles: getStyles,\n\n    /**\n     * @ngdoc method\n     * @name createBoundedWrapper\n     * @methodOf ui.grid.service:GridUtil\n     *\n     * @param {object} Object to bind 'this' to\n     * @param {method} Method to bind\n     * @returns {Function} The wrapper that performs the binding\n     *\n     * @description\n     * Binds given method to given object.\n     *\n     * By means of a wrapper, ensures that ``method`` is always bound to\n     * ``object`` regardless of its calling environment.\n     * Iow, inside ``method``, ``this`` always points to ``object``.\n     *\n     * See http://alistapart.com/article/getoutbindingsituations\n     *\n     */\n    createBoundedWrapper: function(object, method) {\n        return function() {\n            return method.apply(object, arguments);\n        };\n    },\n\n\n    /**\n     * @ngdoc method\n     * @name readableColumnName\n     * @methodOf ui.grid.service:GridUtil\n     *\n     * @param {string} columnName Column name as a string\n     * @returns {string} Column name appropriately capitalized and split apart\n     *\n       @example\n       <example module=\"app\">\n        <file name=\"app.js\">\n          var app = angular.module('app', ['ui.grid']);\n\n          app.controller('MainCtrl', ['$scope', 'gridUtil', function ($scope, gridUtil) {\n            $scope.name = 'firstName';\n            $scope.columnName = function(name) {\n              return gridUtil.readableColumnName(name);\n            };\n          }]);\n        </file>\n        <file name=\"index.html\">\n          <div ng-controller=\"MainCtrl\">\n            <strong>Column name:</strong> <input ng-model=\"name\" />\n            <br>\n            <strong>Output:</strong> <span ng-bind=\"columnName(name)\"></span>\n          </div>\n        </file>\n      </example>\n     */\n    readableColumnName: function (columnName) {\n      // Convert underscores to spaces\n      if (typeof(columnName) === 'undefined' || columnName === undefined || columnName === null) { return columnName; }\n\n      if (typeof(columnName) !== 'string') {\n        columnName = String(columnName);\n      }\n\n      return columnName.replace(/_+/g, ' ')\n        // Replace a completely all-capsed word with a first-letter-capitalized version\n        .replace(/^[A-Z]+$/, function (match) {\n          return angular.lowercase(angular.uppercase(match.charAt(0)) + match.slice(1));\n        })\n        // Capitalize the first letter of words\n        .replace(/([\\w\\u00C0-\\u017F]+)/g, function (match) {\n          return angular.uppercase(match.charAt(0)) + match.slice(1);\n        })\n        // Put a space in between words that have partial capilizations (i.e. 'firstName' becomes 'First Name')\n        // .replace(/([A-Z]|[A-Z]\\w+)([A-Z])/g, \"$1 $2\");\n        // .replace(/(\\w+?|\\w)([A-Z])/g, \"$1 $2\");\n        .replace(/(\\w+?(?=[A-Z]))/g, '$1 ');\n    },\n\n    /**\n     * @ngdoc method\n     * @name getColumnsFromData\n     * @methodOf ui.grid.service:GridUtil\n     * @description Return a list of column names, given a data set\n     *\n     * @param {string} data Data array for grid\n     * @returns {Object} Column definitions with field accessor and column name\n     *\n     * @example\n       <pre>\n         var data = [\n           { firstName: 'Bob', lastName: 'Jones' },\n           { firstName: 'Frank', lastName: 'Smith' }\n         ];\n\n         var columnDefs = GridUtil.getColumnsFromData(data, excludeProperties);\n\n         columnDefs == [\n          {\n            field: 'firstName',\n            name: 'First Name'\n          },\n          {\n            field: 'lastName',\n            name: 'Last Name'\n          }\n         ];\n       </pre>\n     */\n    getColumnsFromData: function (data, excludeProperties) {\n      var columnDefs = [];\n\n      if (!data || typeof(data[0]) === 'undefined' || data[0] === undefined) { return []; }\n      if (angular.isUndefined(excludeProperties)) { excludeProperties = []; }\n\n      var item = data[0];\n\n      angular.forEach(item,function (prop, propName) {\n        if ( excludeProperties.indexOf(propName) === -1){\n          columnDefs.push({\n            name: propName\n          });\n        }\n      });\n\n      return columnDefs;\n    },\n\n    /**\n     * @ngdoc method\n     * @name newId\n     * @methodOf ui.grid.service:GridUtil\n     * @description Return a unique ID string\n     *\n     * @returns {string} Unique string\n     *\n     * @example\n       <pre>\n        var id = GridUtil.newId();\n\n        # 1387305700482;\n       </pre>\n     */\n    newId: (function() {\n      var seedId = new Date().getTime();\n      return function() {\n          return seedId += 1;\n      };\n    })(),\n\n\n    /**\n     * @ngdoc method\n     * @name getTemplate\n     * @methodOf ui.grid.service:GridUtil\n     * @description Get's template from cache / element / url\n     *\n     * @param {string|element|promise} Either a string representing the template id, a string representing the template url,\n     *   an jQuery/Angualr element, or a promise that returns the template contents to use.\n     * @returns {object} a promise resolving to template contents\n     *\n     * @example\n     <pre>\n     GridUtil.getTemplate(url).then(function (contents) {\n          alert(contents);\n        })\n     </pre>\n     */\n    getTemplate: function (template) {\n      // Try to fetch the template out of the templateCache\n      if ($templateCache.get(template)) {\n        return s.postProcessTemplate($templateCache.get(template));\n      }\n\n      // See if the template is itself a promise\n      if (template.hasOwnProperty('then')) {\n        return template.then(s.postProcessTemplate);\n      }\n\n      // If the template is an element, return the element\n      try {\n        if (angular.element(template).length > 0) {\n          return $q.when(template).then(s.postProcessTemplate);\n        }\n      }\n      catch (err){\n        //do nothing; not valid html\n      }\n\n      s.logDebug('fetching url', template);\n\n      // Default to trying to fetch the template as a url with $http\n      return $http({ method: 'GET', url: template})\n        .then(\n          function (result) {\n            var templateHtml = result.data.trim();\n            //put in templateCache for next call\n            $templateCache.put(template, templateHtml);\n            return templateHtml;\n          },\n          function (err) {\n            throw new Error(\"Could not get template \" + template + \": \" + err);\n          }\n        )\n        .then(s.postProcessTemplate);\n    },\n\n    //\n    postProcessTemplate: function (template) {\n      var startSym = $interpolate.startSymbol(),\n          endSym = $interpolate.endSymbol();\n\n      // If either of the interpolation symbols have been changed, we need to alter this template\n      if (startSym !== '{{' || endSym !== '}}') {\n        template = template.replace(/\\{\\{/g, startSym);\n        template = template.replace(/\\}\\}/g, endSym);\n      }\n\n      return $q.when(template);\n    },\n\n    /**\n     * @ngdoc method\n     * @name guessType\n     * @methodOf ui.grid.service:GridUtil\n     * @description guesses the type of an argument\n     *\n     * @param {string/number/bool/object} item variable to examine\n     * @returns {string} one of the following\n     * - 'string'\n     * - 'boolean'\n     * - 'number'\n     * - 'date'\n     * - 'object'\n     */\n    guessType : function (item) {\n      var itemType = typeof(item);\n\n      // Check for numbers and booleans\n      switch (itemType) {\n        case \"number\":\n        case \"boolean\":\n        case \"string\":\n          return itemType;\n        default:\n          if (angular.isDate(item)) {\n            return \"date\";\n          }\n          return \"object\";\n      }\n    },\n\n\n  /**\n    * @ngdoc method\n    * @name elementWidth\n    * @methodOf ui.grid.service:GridUtil\n    *\n    * @param {element} element DOM element\n    * @param {string} [extra] Optional modifier for calculation. Use 'margin' to account for margins on element\n    *\n    * @returns {number} Element width in pixels, accounting for any borders, etc.\n    */\n    elementWidth: function (elem) {\n\n    },\n\n    /**\n    * @ngdoc method\n    * @name elementHeight\n    * @methodOf ui.grid.service:GridUtil\n    *\n    * @param {element} element DOM element\n    * @param {string} [extra] Optional modifier for calculation. Use 'margin' to account for margins on element\n    *\n    * @returns {number} Element height in pixels, accounting for any borders, etc.\n    */\n    elementHeight: function (elem) {\n\n    },\n\n    // Thanks to http://stackoverflow.com/a/13382873/888165\n    getScrollbarWidth: function() {\n        var outer = document.createElement(\"div\");\n        outer.style.visibility = \"hidden\";\n        outer.style.width = \"100px\";\n        outer.style.msOverflowStyle = \"scrollbar\"; // needed for WinJS apps\n\n        document.body.appendChild(outer);\n\n        var widthNoScroll = outer.offsetWidth;\n        // force scrollbars\n        outer.style.overflow = \"scroll\";\n\n        // add innerdiv\n        var inner = document.createElement(\"div\");\n        inner.style.width = \"100%\";\n        outer.appendChild(inner);\n\n        var widthWithScroll = inner.offsetWidth;\n\n        // remove divs\n        outer.parentNode.removeChild(outer);\n\n        return widthNoScroll - widthWithScroll;\n    },\n\n    swap: function( elem, options, callback, args ) {\n      var ret, name,\n              old = {};\n\n      // Remember the old values, and insert the new ones\n      for ( name in options ) {\n        old[ name ] = elem.style[ name ];\n        elem.style[ name ] = options[ name ];\n      }\n\n      ret = callback.apply( elem, args || [] );\n\n      // Revert the old values\n      for ( name in options ) {\n        elem.style[ name ] = old[ name ];\n      }\n\n      return ret;\n    },\n\n    fakeElement: function( elem, options, callback, args ) {\n      var ret, name,\n          newElement = angular.element(elem).clone()[0];\n\n      for ( name in options ) {\n        newElement.style[ name ] = options[ name ];\n      }\n\n      angular.element(document.body).append(newElement);\n\n      ret = callback.call( newElement, newElement );\n\n      angular.element(newElement).remove();\n\n      return ret;\n    },\n\n    /**\n    * @ngdoc method\n    * @name normalizeWheelEvent\n    * @methodOf ui.grid.service:GridUtil\n    *\n    * @param {event} event A mouse wheel event\n    *\n    * @returns {event} A normalized event\n    *\n    * @description\n    * Given an event from this list:\n    *\n    * `wheel, mousewheel, DomMouseScroll, MozMousePixelScroll`\n    *\n    * \"normalize\" it\n    * so that it stays consistent no matter what browser it comes from (i.e. scale it correctly and make sure the direction is right.)\n    */\n    normalizeWheelEvent: function (event) {\n      // var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'];\n      // var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'];\n      var lowestDelta, lowestDeltaXY;\n\n      var orgEvent   = event || window.event,\n          args       = [].slice.call(arguments, 1),\n          delta      = 0,\n          deltaX     = 0,\n          deltaY     = 0,\n          absDelta   = 0,\n          absDeltaXY = 0,\n          fn;\n\n      // event = $.event.fix(orgEvent);\n      // event.type = 'mousewheel';\n\n      // NOTE: jQuery masks the event and stores it in the event as originalEvent\n      if (orgEvent.originalEvent) {\n        orgEvent = orgEvent.originalEvent;\n      }\n\n      // Old school scrollwheel delta\n      if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }\n      if ( orgEvent.detail )     { delta = orgEvent.detail * -1; }\n\n      // At a minimum, setup the deltaY to be delta\n      deltaY = delta;\n\n      // Firefox < 17 related to DOMMouseScroll event\n      if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {\n          deltaY = 0;\n          deltaX = delta * -1;\n      }\n\n      // New school wheel delta (wheel event)\n      if ( orgEvent.deltaY ) {\n          deltaY = orgEvent.deltaY * -1;\n          delta  = deltaY;\n      }\n      if ( orgEvent.deltaX ) {\n          deltaX = orgEvent.deltaX;\n          delta  = deltaX * -1;\n      }\n\n      // Webkit\n      if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }\n      if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX; }\n\n      // Look for lowest delta to normalize the delta values\n      absDelta = Math.abs(delta);\n      if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; }\n      absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX));\n      if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; }\n\n      // Get a whole value for the deltas\n      fn     = delta > 0 ? 'floor' : 'ceil';\n      delta  = Math[fn](delta  / lowestDelta);\n      deltaX = Math[fn](deltaX / lowestDeltaXY);\n      deltaY = Math[fn](deltaY / lowestDeltaXY);\n\n      return {\n        delta: delta,\n        deltaX: deltaX,\n        deltaY: deltaY\n      };\n    },\n\n    // Stolen from Modernizr\n    // TODO: make this, and everythign that flows from it, robust\n    //http://www.stucox.com/blog/you-cant-detect-a-touchscreen/\n    isTouchEnabled: function() {\n      var bool;\n\n      if (('ontouchstart' in $window) || $window.DocumentTouch && $document instanceof DocumentTouch) {\n        bool = true;\n      }\n\n      return bool;\n    },\n\n    isNullOrUndefined: function(obj) {\n      if (obj === undefined || obj === null) {\n        return true;\n      }\n      return false;\n    },\n\n    endsWith: function(str, suffix) {\n      if (!str || !suffix || typeof str !== \"string\") {\n        return false;\n      }\n      return str.indexOf(suffix, str.length - suffix.length) !== -1;\n    },\n\n    arrayContainsObjectWithProperty: function(array, propertyName, propertyValue) {\n        var found = false;\n        angular.forEach(array, function (object) {\n            if (object[propertyName] === propertyValue) {\n                found = true;\n            }\n        });\n        return found;\n    },\n\n    //// Shim requestAnimationFrame\n    //requestAnimationFrame: $window.requestAnimationFrame && $window.requestAnimationFrame.bind($window) ||\n    //                       $window.webkitRequestAnimationFrame && $window.webkitRequestAnimationFrame.bind($window) ||\n    //                       function(fn) {\n    //                         return $timeout(fn, 10, false);\n    //                       },\n\n    numericAndNullSort: function (a, b) {\n      if (a === null) { return 1; }\n      if (b === null) { return -1; }\n      if (a === null && b === null) { return 0; }\n      return a - b;\n    },\n\n    // Disable ngAnimate animations on an element\n    disableAnimations: function (element) {\n      var $animate;\n      try {\n        $animate = $injector.get('$animate');\n        // See: http://brianhann.com/angular-1-4-breaking-changes-to-be-aware-of/#animate\n        if (angular.version.major > 1 || (angular.version.major === 1 && angular.version.minor >= 4)) {\n          $animate.enabled(element, false);\n        } else {\n          $animate.enabled(false, element);\n        }\n      }\n      catch (e) {}\n    },\n\n    enableAnimations: function (element) {\n      var $animate;\n      try {\n        $animate = $injector.get('$animate');\n        // See: http://brianhann.com/angular-1-4-breaking-changes-to-be-aware-of/#animate\n        if (angular.version.major > 1 || (angular.version.major === 1 && angular.version.minor >= 4)) {\n          $animate.enabled(element, true);\n        } else {\n          $animate.enabled(true, element);\n        }\n        return $animate;\n      }\n      catch (e) {}\n    },\n\n    // Blatantly stolen from Angular as it isn't exposed (yet. 2.0 maybe?)\n    nextUid: function nextUid() {\n      var index = uid.length;\n      var digit;\n\n      while (index) {\n        index--;\n        digit = uid[index].charCodeAt(0);\n        if (digit === 57 /*'9'*/) {\n          uid[index] = 'A';\n          return uidPrefix + uid.join('');\n        }\n        if (digit === 90  /*'Z'*/) {\n          uid[index] = '0';\n        } else {\n          uid[index] = String.fromCharCode(digit + 1);\n          return uidPrefix + uid.join('');\n        }\n      }\n      uid.unshift('0');\n\n      return uidPrefix + uid.join('');\n    },\n\n    // Blatantly stolen from Angular as it isn't exposed (yet. 2.0 maybe?)\n    hashKey: function hashKey(obj) {\n      var objType = typeof obj,\n          key;\n\n      if (objType === 'object' && obj !== null) {\n        if (typeof (key = obj.$$hashKey) === 'function') {\n          // must invoke on object to keep the right this\n          key = obj.$$hashKey();\n        }\n        else if (typeof(obj.$$hashKey) !== 'undefined' && obj.$$hashKey) {\n          key = obj.$$hashKey;\n        }\n        else if (key === undefined) {\n          key = obj.$$hashKey = s.nextUid();\n        }\n      }\n      else {\n        key = obj;\n      }\n\n      return objType + ':' + key;\n    },\n\n    resetUids: function () {\n      uid = ['0', '0', '0'];\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil\n     * @name logError\n     * @description wraps the $log method, allowing us to choose different\n     * treatment within ui-grid if we so desired.  At present we only log\n     * error messages if uiGridConstants.LOG_ERROR_MESSAGES is set to true\n     * @param {string} logMessage message to be logged to the console\n     *\n     */\n    logError: function( logMessage ){\n      if ( uiGridConstants.LOG_ERROR_MESSAGES ){\n        $log.error( logMessage );\n      }\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil\n     * @name logWarn\n     * @description wraps the $log method, allowing us to choose different\n     * treatment within ui-grid if we so desired.  At present we only log\n     * warning messages if uiGridConstants.LOG_WARN_MESSAGES is set to true\n     * @param {string} logMessage message to be logged to the console\n     *\n     */\n    logWarn: function( logMessage ){\n      if ( uiGridConstants.LOG_WARN_MESSAGES ){\n        $log.warn( logMessage );\n      }\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil\n     * @name logDebug\n     * @description wraps the $log method, allowing us to choose different\n     * treatment within ui-grid if we so desired.  At present we only log\n     * debug messages if uiGridConstants.LOG_DEBUG_MESSAGES is set to true\n     *\n     */\n    logDebug: function() {\n      if ( uiGridConstants.LOG_DEBUG_MESSAGES ){\n        $log.debug.apply($log, arguments);\n      }\n    }\n\n  };\n\n  /**\n   * @ngdoc object\n   * @name focus\n   * @propertyOf ui.grid.service:GridUtil\n   * @description Provies a set of methods to set the document focus inside the grid.\n   * See {@link ui.grid.service:GridUtil.focus} for more information.\n   */\n\n  /**\n   * @ngdoc object\n   * @name ui.grid.service:GridUtil.focus\n   * @description Provies a set of methods to set the document focus inside the grid.\n   * Timeouts are utilized to ensure that the focus is invoked after any other event has been triggered.\n   * e.g. click events that need to run before the focus or\n   * inputs elements that are in a disabled state but are enabled when those events\n   * are triggered.\n   */\n  s.focus = {\n    queue: [],\n    //http://stackoverflow.com/questions/25596399/set-element-focus-in-angular-way\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil.focus\n     * @name byId\n     * @description Sets the focus of the document to the given id value.\n     * If provided with the grid object it will automatically append the grid id.\n     * This is done to encourage unique dom id's as it allows for multiple grids on a\n     * page.\n     * @param {String} id the id of the dom element to set the focus on\n     * @param {Object=} Grid the grid object for this grid instance. See: {@link ui.grid.class:Grid}\n     * @param {Number} Grid.id the unique id for this grid. Already set on an initialized grid object.\n     * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.\n     * then the promise will fail with the `'canceled'` reason.\n     */\n    byId: function (id, Grid) {\n      this._purgeQueue();\n      var promise = $timeout(function() {\n        var elementID = (Grid && Grid.id ? Grid.id + '-' : '') + id;\n        var element = $window.document.getElementById(elementID);\n        if (element) {\n          element.focus();\n        } else {\n          s.logWarn('[focus.byId] Element id ' + elementID + ' was not found.');\n        }\n      });\n      this.queue.push(promise);\n      return promise;\n    },\n\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil.focus\n     * @name byElement\n     * @description Sets the focus of the document to the given dom element.\n     * @param {(element|angular.element)} element the DOM element to set the focus on\n     * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.\n     * then the promise will fail with the `'canceled'` reason.\n     */\n    byElement: function(element){\n      if (!angular.isElement(element)){\n        s.logWarn(\"Trying to focus on an element that isn\\'t an element.\");\n        return $q.reject('not-element');\n      }\n      element = angular.element(element);\n      this._purgeQueue();\n      var promise = $timeout(function(){\n        if (element){\n          element[0].focus();\n        }\n      });\n      this.queue.push(promise);\n      return promise;\n    },\n    /**\n     * @ngdoc method\n     * @methodOf ui.grid.service:GridUtil.focus\n     * @name bySelector\n     * @description Sets the focus of the document to the given dom element.\n     * @param {(element|angular.element)} parentElement the parent/ancestor of the dom element that you are selecting using the query selector\n     * @param {String} querySelector finds the dom element using the {@link http://www.w3schools.com/jsref/met_document_queryselector.asp querySelector}\n     * @param {boolean} [aSync=false] If true then the selector will be querried inside of a timeout. Otherwise the selector will be querried imidately\n     * then the focus will be called.\n     * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.\n     * then the promise will fail with the `'canceled'` reason.\n     */\n    bySelector: function(parentElement, querySelector, aSync){\n      var self = this;\n      if (!angular.isElement(parentElement)){\n        throw new Error(\"The parent element is not an element.\");\n      }\n      // Ensure that this is an angular element.\n      // It is fine if this is already an angular element.\n      parentElement = angular.element(parentElement);\n      var focusBySelector = function(){\n        var element = parentElement[0].querySelector(querySelector);\n        return self.byElement(element);\n      };\n      this._purgeQueue();\n      if (aSync){ //Do this asynchronysly\n        var promise = $timeout(focusBySelector);\n        this.queue.push($timeout(focusBySelector));\n        return promise;\n      } else {\n        return focusBySelector();\n      }\n    },\n    _purgeQueue: function(){\n      this.queue.forEach(function(element){\n        $timeout.cancel(element);\n      });\n      this.queue = [];\n    }\n  };\n\n\n  ['width', 'height'].forEach(function (name) {\n    var capsName = angular.uppercase(name.charAt(0)) + name.substr(1);\n    s['element' + capsName] = function (elem, extra) {\n      var e = elem;\n      if (e && typeof(e.length) !== 'undefined' && e.length) {\n        e = elem[0];\n      }\n\n      if (e) {\n        var styles = getStyles(e);\n        return e.offsetWidth === 0 && rdisplayswap.test(styles.display) ?\n                  s.swap(e, cssShow, function() {\n                    return getWidthOrHeight(e, name, extra );\n                  }) :\n                  getWidthOrHeight( e, name, extra );\n      }\n      else {\n        return null;\n      }\n    };\n\n    s['outerElement' + capsName] = function (elem, margin) {\n      return elem ? s['element' + capsName].call(this, elem, margin ? 'margin' : 'border') : null;\n    };\n  });\n\n  // http://stackoverflow.com/a/24107550/888165\n  s.closestElm = function closestElm(el, selector) {\n    if (typeof(el.length) !== 'undefined' && el.length) {\n      el = el[0];\n    }\n\n    var matchesFn;\n\n    // find vendor prefix\n    ['matches','webkitMatchesSelector','mozMatchesSelector','msMatchesSelector','oMatchesSelector'].some(function(fn) {\n        if (typeof document.body[fn] === 'function') {\n            matchesFn = fn;\n            return true;\n        }\n        return false;\n    });\n\n    // traverse parents\n    var parent;\n    while (el !== null) {\n      parent = el.parentElement;\n      if (parent !== null && parent[matchesFn](selector)) {\n          return parent;\n      }\n      el = parent;\n    }\n\n    return null;\n  };\n\n  s.type = function (obj) {\n    var text = Function.prototype.toString.call(obj.constructor);\n    return text.match(/function (.*?)\\(/)[1];\n  };\n\n  s.getBorderSize = function getBorderSize(elem, borderType) {\n    if (typeof(elem.length) !== 'undefined' && elem.length) {\n      elem = elem[0];\n    }\n\n    var styles = getStyles(elem);\n\n    // If a specific border is supplied, like 'top', read the 'borderTop' style property\n    if (borderType) {\n      borderType = 'border' + borderType.charAt(0).toUpperCase() + borderType.slice(1);\n    }\n    else {\n      borderType = 'border';\n    }\n\n    borderType += 'Width';\n\n    var val = parseInt(styles[borderType], 10);\n\n    if (isNaN(val)) {\n      return 0;\n    }\n    else {\n      return val;\n    }\n  };\n\n  // http://stackoverflow.com/a/22948274/888165\n  // TODO: Opera? Mobile?\n  s.detectBrowser = function detectBrowser() {\n    var userAgent = $window.navigator.userAgent;\n\n    var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer|trident\\//i};\n\n    for (var key in browsers) {\n      if (browsers[key].test(userAgent)) {\n        return key;\n      }\n    }\n\n    return 'unknown';\n  };\n\n  // Borrowed from https://github.com/othree/jquery.rtl-scroll-type\n  // Determine the scroll \"type\" this browser is using for RTL\n  s.rtlScrollType = function rtlScrollType() {\n    if (rtlScrollType.type) {\n      return rtlScrollType.type;\n    }\n\n    var definer = angular.element('<div dir=\"rtl\" style=\"font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll\">A</div>')[0],\n        type = 'reverse';\n\n    document.body.appendChild(definer);\n\n    if (definer.scrollLeft > 0) {\n      type = 'default';\n    }\n    else {\n      definer.scrollLeft = 1;\n      if (definer.scrollLeft === 0) {\n        type = 'negative';\n      }\n    }\n\n    angular.element(definer).remove();\n    rtlScrollType.type = type;\n\n    return type;\n  };\n\n    /**\n     * @ngdoc method\n     * @name normalizeScrollLeft\n     * @methodOf ui.grid.service:GridUtil\n     *\n     * @param {element} element The element to get the `scrollLeft` from.\n     * @param {grid} grid -  grid used to normalize (uses the rtl property)\n     *\n     * @returns {number} A normalized scrollLeft value for the current browser.\n     *\n     * @description\n     * Browsers currently handle RTL in different ways, resulting in inconsistent scrollLeft values. This method normalizes them\n     */\n  s.normalizeScrollLeft = function normalizeScrollLeft(element, grid) {\n    if (typeof(element.length) !== 'undefined' && element.length) {\n      element = element[0];\n    }\n\n    var scrollLeft = element.scrollLeft;\n\n    if (grid.isRTL()) {\n      switch (s.rtlScrollType()) {\n        case 'default':\n          return element.scrollWidth - scrollLeft - element.clientWidth;\n        case 'negative':\n          return Math.abs(scrollLeft);\n        case 'reverse':\n          return scrollLeft;\n      }\n    }\n\n    return scrollLeft;\n  };\n\n  /**\n  * @ngdoc method\n  * @name denormalizeScrollLeft\n  * @methodOf ui.grid.service:GridUtil\n  *\n  * @param {element} element The element to normalize the `scrollLeft` value for\n  * @param {number} scrollLeft The `scrollLeft` value to denormalize.\n  * @param {grid} grid The grid that owns the scroll event.\n  *\n  * @returns {number} A normalized scrollLeft value for the current browser.\n  *\n  * @description\n  * Browsers currently handle RTL in different ways, resulting in inconsistent scrollLeft values. This method denormalizes a value for the current browser.\n  */\n  s.denormalizeScrollLeft = function denormalizeScrollLeft(element, scrollLeft, grid) {\n    if (typeof(element.length) !== 'undefined' && element.length) {\n      element = element[0];\n    }\n\n    if (grid.isRTL()) {\n      switch (s.rtlScrollType()) {\n        case 'default':\n          // Get the max scroll for the element\n          var maxScrollLeft = element.scrollWidth - element.clientWidth;\n\n          // Subtract the current scroll amount from the max scroll\n          return maxScrollLeft - scrollLeft;\n        case 'negative':\n          return scrollLeft * -1;\n        case 'reverse':\n          return scrollLeft;\n      }\n    }\n\n    return scrollLeft;\n  };\n\n    /**\n     * @ngdoc method\n     * @name preEval\n     * @methodOf ui.grid.service:GridUtil\n     *\n     * @param {string} path Path to evaluate\n     *\n     * @returns {string} A path that is normalized.\n     *\n     * @description\n     * Takes a field path and converts it to bracket notation to allow for special characters in path\n     * @example\n     * <pre>\n     * gridUtil.preEval('property') == 'property'\n     * gridUtil.preEval('nested.deep.prop-erty') = \"nested['deep']['prop-erty']\"\n     * </pre>\n     */\n  s.preEval = function (path) {\n    var m = uiGridConstants.BRACKET_REGEXP.exec(path);\n    if (m) {\n      return (m[1] ? s.preEval(m[1]) : m[1]) + m[2] + (m[3] ? s.preEval(m[3]) : m[3]);\n    } else {\n      path = path.replace(uiGridConstants.APOS_REGEXP, '\\\\\\'');\n      var parts = path.split(uiGridConstants.DOT_REGEXP);\n      var preparsed = [parts.shift()];    // first item must be var notation, thus skip\n      angular.forEach(parts, function (part) {\n        preparsed.push(part.replace(uiGridConstants.FUNC_REGEXP, '\\']$1'));\n      });\n      return preparsed.join('[\\'');\n    }\n  };\n\n  /**\n   * @ngdoc method\n   * @name debounce\n   * @methodOf ui.grid.service:GridUtil\n   *\n   * @param {function} func function to debounce\n   * @param {number} wait milliseconds to delay\n   * @param {boolean} immediate execute before delay\n   *\n   * @returns {function} A function that can be executed as debounced function\n   *\n   * @description\n   * Copied from https://github.com/shahata/angular-debounce\n   * Takes a function, decorates it to execute only 1 time after multiple calls, and returns the decorated function\n   * @example\n   * <pre>\n   * var debouncedFunc =  gridUtil.debounce(function(){alert('debounced');}, 500);\n   * debouncedFunc();\n   * debouncedFunc();\n   * debouncedFunc();\n   * </pre>\n   */\n  s.debounce =  function (func, wait, immediate) {\n    var timeout, args, context, result;\n    function debounce() {\n      /* jshint validthis:true */\n      context = this;\n      args = arguments;\n      var later = function () {\n        timeout = null;\n        if (!immediate) {\n          result = func.apply(context, args);\n        }\n      };\n      var callNow = immediate && !timeout;\n      if (timeout) {\n        $timeout.cancel(timeout);\n      }\n      timeout = $timeout(later, wait, false);\n      if (callNow) {\n        result = func.apply(context, args);\n      }\n      return result;\n    }\n    debounce.cancel = function () {\n      $timeout.cancel(timeout);\n      timeout = null;\n    };\n    return debounce;\n  };\n\n  /**\n   * @ngdoc method\n   * @name throttle\n   * @methodOf ui.grid.service:GridUtil\n   *\n   * @param {function} func function to throttle\n   * @param {number} wait milliseconds to delay after first trigger\n   * @param {Object} params to use in throttle.\n   *\n   * @returns {function} A function that can be executed as throttled function\n   *\n   * @description\n   * Adapted from debounce function (above)\n   * Potential keys for Params Object are:\n   *    trailing (bool) - whether to trigger after throttle time ends if called multiple times\n   * Updated to use $interval rather than $timeout, as protractor (e2e tests) is able to work with $interval,\n   * but not with $timeout\n   *\n   * Note that when using throttle, you need to use throttle to create a new function upfront, then use the function\n   * return from that call each time you need to call throttle.  If you call throttle itself repeatedly, the lastCall\n   * variable will get overwritten and the throttling won't work\n   *\n   * @example\n   * <pre>\n   * var throttledFunc =  gridUtil.throttle(function(){console.log('throttled');}, 500, {trailing: true});\n   * throttledFunc(); //=> logs throttled\n   * throttledFunc(); //=> queues attempt to log throttled for ~500ms (since trailing param is truthy)\n   * throttledFunc(); //=> updates arguments to keep most-recent request, but does not do anything else.\n   * </pre>\n   */\n  s.throttle = function(func, wait, options){\n    options = options || {};\n    var lastCall = 0, queued = null, context, args;\n\n    function runFunc(endDate){\n      lastCall = +new Date();\n      func.apply(context, args);\n      $interval(function(){ queued = null; }, 0, 1, false);\n    }\n\n    return function(){\n      /* jshint validthis:true */\n      context = this;\n      args = arguments;\n      if (queued === null){\n        var sinceLast = +new Date() - lastCall;\n        if (sinceLast > wait){\n          runFunc();\n        }\n        else if (options.trailing){\n          queued = $interval(runFunc, wait - sinceLast, 1, false);\n        }\n      }\n    };\n  };\n\n  s.on = {};\n  s.off = {};\n  s._events = {};\n\n  s.addOff = function (eventName) {\n    s.off[eventName] = function (elm, fn) {\n      var idx = s._events[eventName].indexOf(fn);\n      if (idx > 0) {\n        s._events[eventName].removeAt(idx);\n      }\n    };\n  };\n\n  var mouseWheeltoBind = ( 'onwheel' in document || document.documentMode >= 9 ) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],\n      nullLowestDeltaTimeout,\n      lowestDelta;\n\n  s.on.mousewheel = function (elm, fn) {\n    if (!elm || !fn) { return; }\n\n    var $elm = angular.element(elm);\n\n    // Store the line height and page height for this particular element\n    $elm.data('mousewheel-line-height', getLineHeight($elm));\n    $elm.data('mousewheel-page-height', s.elementHeight($elm));\n    if (!$elm.data('mousewheel-callbacks')) { $elm.data('mousewheel-callbacks', {}); }\n\n    var cbs = $elm.data('mousewheel-callbacks');\n    cbs[fn] = (Function.prototype.bind || bindPolyfill).call(mousewheelHandler, $elm[0], fn);\n\n    // Bind all the mousew heel events\n    for ( var i = mouseWheeltoBind.length; i; ) {\n      $elm.on(mouseWheeltoBind[--i], cbs[fn]);\n    }\n  };\n  s.off.mousewheel = function (elm, fn) {\n    var $elm = angular.element(elm);\n\n    var cbs = $elm.data('mousewheel-callbacks');\n    var handler = cbs[fn];\n\n    if (handler) {\n      for ( var i = mouseWheeltoBind.length; i; ) {\n        $elm.off(mouseWheeltoBind[--i], handler);\n      }\n    }\n\n    delete cbs[fn];\n\n    if (Object.keys(cbs).length === 0) {\n      $elm.removeData('mousewheel-line-height');\n      $elm.removeData('mousewheel-page-height');\n      $elm.removeData('mousewheel-callbacks');\n    }\n  };\n\n  function mousewheelHandler(fn, event) {\n    var $elm = angular.element(this);\n\n    var delta      = 0,\n        deltaX     = 0,\n        deltaY     = 0,\n        absDelta   = 0,\n        offsetX    = 0,\n        offsetY    = 0;\n\n    // jQuery masks events\n    if (event.originalEvent) { event = event.originalEvent; }\n\n    if ( 'detail'      in event ) { deltaY = event.detail * -1;      }\n    if ( 'wheelDelta'  in event ) { deltaY = event.wheelDelta;       }\n    if ( 'wheelDeltaY' in event ) { deltaY = event.wheelDeltaY;      }\n    if ( 'wheelDeltaX' in event ) { deltaX = event.wheelDeltaX * -1; }\n\n    // Firefox < 17 horizontal scrolling related to DOMMouseScroll event\n    if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {\n      deltaX = deltaY * -1;\n      deltaY = 0;\n    }\n\n    // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy\n    delta = deltaY === 0 ? deltaX : deltaY;\n\n    // New school wheel delta (wheel event)\n    if ( 'deltaY' in event ) {\n      deltaY = event.deltaY * -1;\n      delta  = deltaY;\n    }\n    if ( 'deltaX' in event ) {\n      deltaX = event.deltaX;\n      if ( deltaY === 0 ) { delta  = deltaX * -1; }\n    }\n\n    // No change actually happened, no reason to go any further\n    if ( deltaY === 0 && deltaX === 0 ) { return; }\n\n    // Need to convert lines and pages to pixels if we aren't already in pixels\n    // There are three delta modes:\n    //   * deltaMode 0 is by pixels, nothing to do\n    //   * deltaMode 1 is by lines\n    //   * deltaMode 2 is by pages\n    if ( event.deltaMode === 1 ) {\n        var lineHeight = $elm.data('mousewheel-line-height');\n        delta  *= lineHeight;\n        deltaY *= lineHeight;\n        deltaX *= lineHeight;\n    }\n    else if ( event.deltaMode === 2 ) {\n        var pageHeight = $elm.data('mousewheel-page-height');\n        delta  *= pageHeight;\n        deltaY *= pageHeight;\n        deltaX *= pageHeight;\n    }\n\n    // Store lowest absolute delta to normalize the delta values\n    absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );\n\n    if ( !lowestDelta || absDelta < lowestDelta ) {\n      lowestDelta = absDelta;\n\n      // Adjust older deltas if necessary\n      if ( shouldAdjustOldDeltas(event, absDelta) ) {\n        lowestDelta /= 40;\n      }\n    }\n\n    // Get a whole, normalized value for the deltas\n    delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);\n    deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);\n    deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);\n\n    event.deltaMode = 0;\n\n    // Normalise offsetX and offsetY properties\n    // if ($elm[0].getBoundingClientRect ) {\n    //   var boundingRect = $(elm)[0].getBoundingClientRect();\n    //   offsetX = event.clientX - boundingRect.left;\n    //   offsetY = event.clientY - boundingRect.top;\n    // }\n\n    // event.deltaX = deltaX;\n    // event.deltaY = deltaY;\n    // event.deltaFactor = lowestDelta;\n\n    var newEvent = {\n      originalEvent: event,\n      deltaX: deltaX,\n      deltaY: deltaY,\n      deltaFactor: lowestDelta,\n      preventDefault: function () { event.preventDefault(); },\n      stopPropagation: function () { event.stopPropagation(); }\n    };\n\n    // Clearout lowestDelta after sometime to better\n    // handle multiple device types that give\n    // a different lowestDelta\n    // Ex: trackpad = 3 and mouse wheel = 120\n    if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }\n    nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);\n\n    fn.call($elm[0], newEvent);\n  }\n\n  function nullLowestDelta() {\n    lowestDelta = null;\n  }\n\n  function shouldAdjustOldDeltas(orgEvent, absDelta) {\n    // If this is an older event and the delta is divisable by 120,\n    // then we are assuming that the browser is treating this as an\n    // older mouse wheel event and that we should divide the deltas\n    // by 40 to try and get a more usable deltaFactor.\n    // Side note, this actually impacts the reported scroll distance\n    // in older browsers and can cause scrolling to be slower than native.\n    // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.\n    return orgEvent.type === 'mousewheel' && absDelta % 120 === 0;\n  }\n\n  return s;\n}]);\n\n// Add 'px' to the end of a number string if it doesn't have it already\nmodule.filter('px', function() {\n  return function(str) {\n    if (str.match(/^[\\d\\.]+$/)) {\n      return str + 'px';\n    }\n    else {\n      return str;\n    }\n  };\n});\n\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      var lang = {\n              aggregate: {\n                  label: 'položky'\n              },\n              groupPanel: {\n                  description: 'Přesuňte záhlaví zde pro vytvoření skupiny dle sloupce.'\n              },\n              search: {\n                  placeholder: 'Hledat...',\n                  showingItems: 'Zobrazuji položky:',\n                  selectedItems: 'Vybrané položky:',\n                  totalItems: 'Celkem položek:',\n                  size: 'Velikost strany:',\n                  first: 'První strana',\n                  next: 'Další strana',\n                  previous: 'Předchozí strana',\n                  last: 'Poslední strana'\n              },\n              menu: {\n                  text: 'Vyberte sloupec:'\n              },\n              sort: {\n                  ascending: 'Seřadit od A-Z',\n                  descending: 'Seřadit od Z-A',\n                  remove: 'Odebrat seřazení'\n              },\n              column: {\n                  hide: 'Schovat sloupec'\n              },\n              aggregation: {\n                  count: 'celkem řádků: ',\n                  sum: 'celkem: ',\n                  avg: 'avg: ',\n                  min: 'min.: ',\n                  max: 'max.: '\n              },\n              pinning: {\n                  pinLeft: 'Zamknout vlevo',\n                  pinRight: 'Zamknout vpravo',\n                  unpin: 'Odemknout'\n              },\n              gridMenu: {\n                  columns: 'Sloupce:',\n                  importerTitle: 'Importovat soubor',\n                  exporterAllAsCsv: 'Exportovat všechna data do csv',\n                  exporterVisibleAsCsv: 'Exportovat viditelná data do csv',\n                  exporterSelectedAsCsv: 'Exportovat vybraná data do csv',\n                  exporterAllAsPdf: 'Exportovat všechna data do pdf',\n                  exporterVisibleAsPdf: 'Exportovat viditelná data do pdf',\n                  exporterSelectedAsPdf: 'Exportovat vybraná data do pdf',\n                  clearAllFilters: 'Odstranit všechny filtry'\n              },\n              importer: {\n                  noHeaders: 'Názvy sloupců se nepodařilo získat, obsahuje soubor záhlaví?',\n                  noObjects: 'Data se nepodařilo zpracovat, obsahuje soubor řádky mimo záhlaví?',\n                  invalidCsv: 'Soubor nelze zpracovat, jedná se o CSV?',\n                  invalidJson: 'Soubor nelze zpracovat, je to JSON?',\n                  jsonNotArray: 'Soubor musí obsahovat json. Ukončuji..'\n              },\n              pagination: {\n                  sizes: 'položek na stránku',\n                  totalItems: 'položek'\n              },\n              grouping: {\n                  group: 'Seskupit',\n                  ungroup: 'Odebrat seskupení',\n                  aggregate_count: 'Agregace: Count',\n                  aggregate_sum: 'Agregace: Sum',\n                  aggregate_max: 'Agregace: Max',\n                  aggregate_min: 'Agregace: Min',\n                  aggregate_avg: 'Agregace: Avg',\n                  aggregate_remove: 'Agregace: Odebrat'\n              }\n          };\n\n          // support varianty of different czech keys.\n          $delegate.add('cs', lang);\n          $delegate.add('cz', lang);\n          $delegate.add('cs-cz', lang);\n          $delegate.add('cs-CZ', lang);\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function(){\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('da', {\n        aggregate:{\n          label: 'artikler'\n        },\n        groupPanel:{\n          description: 'Grupér rækker udfra en kolonne ved at trække dens overskift hertil.'\n        },\n        search:{\n          placeholder: 'Søg...',\n          showingItems: 'Viste rækker:',\n          selectedItems: 'Valgte rækker:',\n          totalItems: 'Rækker totalt:',\n          size: 'Side størrelse:',\n          first: 'Første side',\n          next: 'Næste side',\n          previous: 'Forrige side',\n          last: 'Sidste side'\n        },\n        menu:{\n          text: 'Vælg kolonner:'\n        },\n        sort: {\n          ascending: 'Sorter stigende',\n          descending: 'Sorter faldende',\n          none: 'Sorter ingen',\n          remove: 'Fjern sortering'\n        },\n        column: {\n          hide: 'Skjul kolonne'\n        },\n        aggregation: {\n          count: 'antal rækker: ',\n          sum: 'sum: ',\n          avg: 'gns: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        gridMenu: {\n          columns: 'Columns:',\n          importerTitle: 'Import file',\n          exporterAllAsCsv: 'Export all data as csv',\n          exporterVisibleAsCsv: 'Export visible data as csv',\n          exporterSelectedAsCsv: 'Export selected data as csv',\n          exporterAllAsPdf: 'Export all data as pdf',\n          exporterVisibleAsPdf: 'Export visible data as pdf',\n          exporterSelectedAsPdf: 'Export selected data as pdf',\n          clearAllFilters: 'Clear all filters'\n        },\n        importer: {\n          noHeaders: 'Column names were unable to be derived, does the file have a header?',\n          noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',\n          invalidCsv: 'File was unable to be processed, is it valid CSV?',\n          invalidJson: 'File was unable to be processed, is it valid Json?',\n          jsonNotArray: 'Imported json file must contain an array, aborting.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function ($provide) {\n    $provide.decorator('i18nService', ['$delegate', function ($delegate) {\n      $delegate.add('de', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filter für Spalte',\n            removeFilter: 'Filter löschen',\n            columnMenuButtonLabel: 'Spaltenmenü'\n          },\n          priority: 'Priorität:',\n          filterLabel: \"Filter für Spalte: \"\n        },\n        aggregate: {\n          label: 'Eintrag'\n        },\n        groupPanel: {\n          description: 'Ziehen Sie eine Spaltenüberschrift hierhin, um nach dieser Spalte zu gruppieren.'\n        },\n        search: {\n          placeholder: 'Suche...',\n          showingItems: 'Zeige Einträge:',\n          selectedItems: 'Ausgewählte Einträge:',\n          totalItems: 'Einträge gesamt:',\n          size: 'Einträge pro Seite:',\n          first: 'Erste Seite',\n          next: 'Nächste Seite',\n          previous: 'Vorherige Seite',\n          last: 'Letzte Seite'\n        },\n        menu: {\n          text: 'Spalten auswählen:'\n        },\n        sort: {\n          ascending: 'aufsteigend sortieren',\n          descending: 'absteigend sortieren',\n          none: 'keine Sortierung',\n          remove: 'Sortierung zurücksetzen'\n        },\n        column: {\n          hide: 'Spalte ausblenden'\n        },\n        aggregation: {\n          count: 'Zeilen insgesamt: ',\n          sum: 'gesamt: ',\n          avg: 'Durchschnitt: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n            pinLeft: 'Links anheften',\n            pinRight: 'Rechts anheften',\n            unpin: 'Lösen'\n        },\n        columnMenu: {\n          close: 'Schließen'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Tabellenmenü'\n          },\n          columns: 'Spalten:',\n          importerTitle: 'Datei importieren',\n          exporterAllAsCsv: 'Alle Daten als CSV exportieren',\n          exporterVisibleAsCsv: 'sichtbare Daten als CSV exportieren',\n          exporterSelectedAsCsv: 'markierte Daten als CSV exportieren',\n          exporterAllAsPdf: 'Alle Daten als PDF exportieren',\n          exporterVisibleAsPdf: 'sichtbare Daten als PDF exportieren',\n          exporterSelectedAsPdf: 'markierte Daten als CSV exportieren',\n          clearAllFilters: 'Alle Filter zurücksetzen'\n        },\n        importer: {\n          noHeaders: 'Es konnten keine Spaltennamen ermittelt werden. Sind in der Datei Spaltendefinitionen enthalten?',\n          noObjects: 'Es konnten keine Zeileninformationen gelesen werden, Sind in der Datei außer den Spaltendefinitionen auch Daten enthalten?',\n          invalidCsv: 'Die Datei konnte nicht eingelesen werden, ist es eine gültige CSV-Datei?',\n          invalidJson: 'Die Datei konnte nicht eingelesen werden. Enthält sie gültiges JSON?',\n          jsonNotArray: 'Die importierte JSON-Datei muß ein Array enthalten. Breche Import ab.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Zum Anfang',\n            pageBack: 'Seite zurück',\n            pageSelected: 'Ausgwählte Seite',\n            pageForward: 'Seite vor',\n            pageToLast: 'Zum Ende'\n          },\n          sizes: 'Einträge pro Seite',\n          totalItems: 'Einträge',\n          through: 'bis',\n          of: 'von'\n        },\n        grouping: {\n            group: 'Gruppieren',\n            ungroup: 'Gruppierung aufheben',\n            aggregate_count: 'Agg: Anzahl',\n            aggregate_sum: 'Agg: Summe',\n            aggregate_max: 'Agg: Maximum',\n            aggregate_min: 'Agg: Minimum',\n            aggregate_avg: 'Agg: Mittelwert',\n            aggregate_remove: 'Aggregation entfernen'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('en', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filter for column',\n            removeFilter: 'Remove Filter',\n            columnMenuButtonLabel: 'Column Menu'\n          },\n          priority: 'Priority:',\n          filterLabel: \"Filter for column: \"\n        },\n        aggregate: {\n          label: 'items'\n        },\n        groupPanel: {\n          description: 'Drag a column header here and drop it to group by that column.'\n        },\n        search: {\n          placeholder: 'Search...',\n          showingItems: 'Showing Items:',\n          selectedItems: 'Selected Items:',\n          totalItems: 'Total Items:',\n          size: 'Page Size:',\n          first: 'First Page',\n          next: 'Next Page',\n          previous: 'Previous Page',\n          last: 'Last Page'\n        },\n        menu: {\n          text: 'Choose Columns:'\n        },\n        sort: {\n          ascending: 'Sort Ascending',\n          descending: 'Sort Descending',\n          none: 'Sort None',\n          remove: 'Remove Sort'\n        },\n        column: {\n          hide: 'Hide Column'\n        },\n        aggregation: {\n          count: 'total rows: ',\n          sum: 'total: ',\n          avg: 'avg: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Pin Left',\n          pinRight: 'Pin Right',\n          unpin: 'Unpin'\n        },\n        columnMenu: {\n          close: 'Close'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Grid Menu'\n          },\n          columns: 'Columns:',\n          importerTitle: 'Import file',\n          exporterAllAsCsv: 'Export all data as csv',\n          exporterVisibleAsCsv: 'Export visible data as csv',\n          exporterSelectedAsCsv: 'Export selected data as csv',\n          exporterAllAsPdf: 'Export all data as pdf',\n          exporterVisibleAsPdf: 'Export visible data as pdf',\n          exporterSelectedAsPdf: 'Export selected data as pdf',\n          clearAllFilters: 'Clear all filters'\n        },\n        importer: {\n          noHeaders: 'Column names were unable to be derived, does the file have a header?',\n          noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',\n          invalidCsv: 'File was unable to be processed, is it valid CSV?',\n          invalidJson: 'File was unable to be processed, is it valid Json?',\n          jsonNotArray: 'Imported json file must contain an array, aborting.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Page to first',\n            pageBack: 'Page back',\n            pageSelected: 'Selected page',\n            pageForward: 'Page forward',\n            pageToLast: 'Page to last'\n          },\n          sizes: 'items per page',\n          totalItems: 'items',\n          through: 'through',\n          of: 'of'\n        },\n        grouping: {\n          group: 'Group',\n          ungroup: 'Ungroup',\n          aggregate_count: 'Agg: Count',\n          aggregate_sum: 'Agg: Sum',\n          aggregate_max: 'Agg: Max',\n          aggregate_min: 'Agg: Min',\n          aggregate_avg: 'Agg: Avg',\n          aggregate_remove: 'Agg: Remove'\n        },\n        validate: {\n          error: 'Error:',\n          minLength: 'Value should be at least THRESHOLD characters long.',\n          maxLength: 'Value should be at most THRESHOLD characters long.',\n          required: 'A value is needed.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('es', {\n        aggregate: {\n          label: 'Artículos'\n        },\n        groupPanel: {\n          description: 'Arrastre un encabezado de columna aquí y suéltelo para agrupar por esa columna.'\n        },\n        search: {\n          placeholder: 'Buscar...',\n          showingItems: 'Artículos Mostrados:',\n          selectedItems: 'Artículos Seleccionados:',\n          totalItems: 'Artículos Totales:',\n          size: 'Tamaño de Página:',\n          first: 'Primera Página',\n          next: 'Página Siguiente',\n          previous: 'Página Anterior',\n          last: 'Última Página'\n        },\n        menu: {\n          text: 'Elegir columnas:'\n        },\n        sort: {\n          ascending: 'Orden Ascendente',\n          descending: 'Orden Descendente',\n          remove: 'Sin Ordenar'\n        },\n        column: {\n          hide: 'Ocultar la columna'\n        },\n        aggregation: {\n          count: 'filas totales: ',\n          sum: 'total: ',\n          avg: 'media: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Fijar a la Izquierda',\n          pinRight: 'Fijar a la Derecha',\n          unpin: 'Quitar Fijación'\n        },\n        gridMenu: {\n          columns: 'Columnas:',\n          importerTitle: 'Importar archivo',\n          exporterAllAsCsv: 'Exportar todo como csv',\n          exporterVisibleAsCsv: 'Exportar vista como csv',\n          exporterSelectedAsCsv: 'Exportar selección como csv',\n          exporterAllAsPdf: 'Exportar todo como pdf',\n          exporterVisibleAsPdf: 'Exportar vista como pdf',\n          exporterSelectedAsPdf: 'Exportar selección como pdf',\n          clearAllFilters: 'Limpiar todos los filtros'\n        },\n        importer: {\n          noHeaders: 'No fue posible derivar los nombres de las columnas, ¿tiene encabezados el archivo?',\n          noObjects: 'No fue posible obtener registros, ¿contiene datos el archivo, aparte de los encabezados?',\n          invalidCsv: 'No fue posible procesar el archivo, ¿es un CSV válido?',\n          invalidJson: 'No fue posible procesar el archivo, ¿es un Json válido?',\n          jsonNotArray: 'El archivo json importado debe contener un array, abortando.'\n        },\n        pagination: {\n          sizes: 'registros por página',\n          totalItems: 'registros',\n          of: 'de'\n        },\n        grouping: {\n          group: 'Agrupar',\n          ungroup: 'Desagrupar',\n          aggregate_count: 'Agr: Cont',\n          aggregate_sum: 'Agr: Sum',\n          aggregate_max: 'Agr: Máx',\n          aggregate_min: 'Agr: Min',\n          aggregate_avg: 'Agr: Prom',\n          aggregate_remove: 'Agr: Quitar'\n        }\n      });\n      return $delegate;\n    }]);\n}]);\n})();\n\n/**\n * Translated by: R. Salarmehr\n *                M. Hosseynzade\n *                Using Vajje.com online dictionary.\n */\n(function () {\n  angular.module('ui.grid').config(['$provide', function ($provide) {\n    $provide.decorator('i18nService', ['$delegate', function ($delegate) {\n      $delegate.add('fa', {\n        aggregate: {\n          label: 'قلم'\n        },\n        groupPanel: {\n          description: 'عنوان یک ستون را بگیر و به گروهی از آن ستون رها کن.'\n        },\n        search: {\n          placeholder: 'جستجو...',\n          showingItems: 'نمایش اقلام:',\n          selectedItems: 'قلم\\u200cهای انتخاب شده:',\n          totalItems: 'مجموع اقلام:',\n          size: 'اندازه\\u200cی صفحه:',\n          first: 'اولین صفحه',\n          next: 'صفحه\\u200cی\\u200cبعدی',\n          previous: 'صفحه\\u200cی\\u200c قبلی',\n          last: 'آخرین صفحه'\n        },\n        menu: {\n          text: 'ستون\\u200cهای انتخابی:'\n        },\n        sort: {\n          ascending: 'ترتیب صعودی',\n          descending: 'ترتیب نزولی',\n          remove: 'حذف مرتب کردن'\n        },\n        column: {\n          hide: 'پنهان\\u200cکردن ستون'\n        },\n        aggregation: {\n          count: 'تعداد: ',\n          sum: 'مجموع: ',\n          avg: 'میانگین: ',\n          min: 'کمترین: ',\n          max: 'بیشترین: '\n        },\n        pinning: {\n          pinLeft: 'پین کردن سمت چپ',\n          pinRight: 'پین کردن سمت راست',\n          unpin: 'حذف پین'\n        },\n        gridMenu: {\n          columns: 'ستون\\u200cها:',\n          importerTitle: 'وارد کردن فایل',\n          exporterAllAsCsv: 'خروجی تمام داده\\u200cها در فایل csv',\n          exporterVisibleAsCsv: 'خروجی داده\\u200cهای قابل مشاهده در فایل csv',\n          exporterSelectedAsCsv: 'خروجی داده\\u200cهای انتخاب\\u200cشده در فایل csv',\n          exporterAllAsPdf: 'خروجی تمام داده\\u200cها در فایل pdf',\n          exporterVisibleAsPdf: 'خروجی داده\\u200cهای قابل مشاهده در فایل pdf',\n          exporterSelectedAsPdf: 'خروجی داده\\u200cهای انتخاب\\u200cشده در فایل pdf',\n          clearAllFilters: 'پاک کردن تمام فیلتر'\n        },\n        importer: {\n          noHeaders: 'نام ستون قابل استخراج نیست. آیا فایل عنوان دارد؟',\n          noObjects: 'اشیا قابل استخراج نیستند. آیا به جز عنوان\\u200cها در فایل داده وجود دارد؟',\n          invalidCsv: 'فایل قابل پردازش نیست. آیا فرمت  csv  معتبر است؟',\n          invalidJson: 'فایل قابل پردازش نیست. آیا فرمت json   معتبر است؟',\n          jsonNotArray: 'فایل json وارد شده باید حاوی آرایه باشد. عملیات ساقط شد.'\n        },\n        pagination: {\n          sizes: 'اقلام در هر صفحه',\n          totalItems: 'اقلام',\n          of: 'از'\n        },\n        grouping: {\n          group: 'گروه\\u200cبندی',\n          ungroup: 'حذف گروه\\u200cبندی',\n          aggregate_count: 'Agg: تعداد',\n          aggregate_sum: 'Agg: جمع',\n          aggregate_max: 'Agg: بیشینه',\n          aggregate_min: 'Agg: کمینه',\n          aggregate_avg: 'Agg: میانگین',\n          aggregate_remove: 'Agg: حذف'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('fi', {\n        aggregate: {\n          label: 'rivit'\n        },\n        groupPanel: {\n          description: 'Raahaa ja pudota otsikko tähän ryhmittääksesi sarakkeen mukaan.'\n        },\n        search: {\n          placeholder: 'Hae...',\n          showingItems: 'Näytetään rivejä:',\n          selectedItems: 'Valitut rivit:',\n          totalItems: 'Rivejä yht.:',\n          size: 'Näytä:',\n          first: 'Ensimmäinen sivu',\n          next: 'Seuraava sivu',\n          previous: 'Edellinen sivu',\n          last: 'Viimeinen sivu'\n        },\n        menu: {\n          text: 'Valitse sarakkeet:'\n        },\n        sort: {\n          ascending: 'Järjestä nouseva',\n          descending: 'Järjestä laskeva',\n          remove: 'Poista järjestys'\n        },\n        column: {\n          hide: 'Piilota sarake'\n        },\n        aggregation: {\n          count: 'Rivejä yht.: ',\n          sum: 'Summa: ',\n          avg: 'K.a.: ',\n          min: 'Min: ',\n          max: 'Max: '\n        },\n        pinning: {\n         pinLeft: 'Lukitse vasemmalle',\n          pinRight: 'Lukitse oikealle',\n          unpin: 'Poista lukitus'\n        },\n        gridMenu: {\n          columns: 'Sarakkeet:',\n          importerTitle: 'Tuo tiedosto',\n          exporterAllAsCsv: 'Vie tiedot csv-muodossa',\n          exporterVisibleAsCsv: 'Vie näkyvä tieto csv-muodossa',\n          exporterSelectedAsCsv: 'Vie valittu tieto csv-muodossa',\n          exporterAllAsPdf: 'Vie tiedot pdf-muodossa',\n          exporterVisibleAsPdf: 'Vie näkyvä tieto pdf-muodossa',\n          exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa',\n          clearAllFilters: 'Puhdista kaikki suodattimet'\n        },\n        importer: {\n          noHeaders: 'Sarakkeen nimiä ei voitu päätellä, onko tiedostossa otsikkoriviä?',\n          noObjects: 'Tietoja ei voitu lukea, onko tiedostossa muuta kuin otsikkot?',\n          invalidCsv: 'Tiedostoa ei voitu käsitellä, oliko se CSV-muodossa?',\n          invalidJson: 'Tiedostoa ei voitu käsitellä, oliko se JSON-muodossa?',\n          jsonNotArray: 'Tiedosto ei sisältänyt taulukkoa, lopetetaan.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('fr', {\n        aggregate: {\n          label: 'éléments'\n        },\n        groupPanel: {\n          description: 'Faites glisser une en-tête de colonne ici pour créer un groupe de colonnes.'\n        },\n        search: {\n          placeholder: 'Recherche...',\n          showingItems: 'Affichage des éléments :',\n          selectedItems: 'Éléments sélectionnés :',\n          totalItems: 'Nombre total d\\'éléments:',\n          size: 'Taille de page:',\n          first: 'Première page',\n          next: 'Page Suivante',\n          previous: 'Page précédente',\n          last: 'Dernière page'\n        },\n        menu: {\n          text: 'Choisir des colonnes :'\n        },\n        sort: {\n          ascending: 'Trier par ordre croissant',\n          descending: 'Trier par ordre décroissant',\n          remove: 'Enlever le tri'\n        },\n        column: {\n          hide: 'Cacher la colonne'\n        },\n        aggregation: {\n          count: 'lignes totales: ',\n          sum: 'total: ',\n          avg: 'moy: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Épingler à gauche',\n          pinRight: 'Épingler à droite',\n          unpin: 'Détacher'\n        },\n        gridMenu: {\n          columns: 'Colonnes:',\n          importerTitle: 'Importer un fichier',\n          exporterAllAsCsv: 'Exporter toutes les données en CSV',\n          exporterVisibleAsCsv: 'Exporter les données visibles en CSV',\n          exporterSelectedAsCsv: 'Exporter les données sélectionnées en CSV',\n          exporterAllAsPdf: 'Exporter toutes les données en PDF',\n          exporterVisibleAsPdf: 'Exporter les données visibles en PDF',\n          exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF',\n          clearAllFilters: 'Nettoyez tous les filtres'\n        },\n        importer: {\n          noHeaders: 'Impossible de déterminer le nom des colonnes, le fichier possède-t-il une en-tête ?',\n          noObjects: 'Aucun objet trouvé, le fichier possède-t-il des données autres que l\\'en-tête ?',\n          invalidCsv: 'Le fichier n\\'a pas pu être traité, le CSV est-il valide ?',\n          invalidJson: 'Le fichier n\\'a pas pu être traité, le JSON est-il valide ?',\n          jsonNotArray: 'Le fichier JSON importé doit contenir un tableau, abandon.'\n        },\n        pagination: {\n          sizes: 'éléments par page',\n          totalItems: 'éléments',\n          of: 'sur'\n        },\n        grouping: {\n          group: 'Grouper',\n          ungroup: 'Dégrouper',\n          aggregate_count: 'Agg: Compte',\n          aggregate_sum: 'Agg: Somme',\n          aggregate_max: 'Agg: Max',\n          aggregate_min: 'Agg: Min',\n          aggregate_avg: 'Agg: Moy',\n          aggregate_remove: 'Agg: Retirer'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function ($provide) {\n    $provide.decorator('i18nService', ['$delegate', function ($delegate) {\n      $delegate.add('he', {\n        aggregate: {\n          label: 'items'\n        },\n        groupPanel: {\n          description: 'גרור עמודה לכאן ושחרר בכדי לקבץ עמודה זו.'\n        },\n        search: {\n          placeholder: 'חפש...',\n          showingItems: 'מציג:',\n          selectedItems: 'סה\"כ נבחרו:',\n          totalItems: 'סה\"כ רשומות:',\n          size: 'תוצאות בדף:',\n          first: 'דף ראשון',\n          next: 'דף הבא',\n          previous: 'דף קודם',\n          last: 'דף אחרון'\n        },\n        menu: {\n          text: 'בחר עמודות:'\n        },\n        sort: {\n          ascending: 'סדר עולה',\n          descending: 'סדר יורד',\n          remove: 'בטל'\n        },\n        column: {\n          hide: 'טור הסתר'\n        },\n        aggregation: {\n          count: 'total rows: ',\n          sum: 'total: ',\n          avg: 'avg: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        gridMenu: {\n          columns: 'Columns:',\n          importerTitle: 'Import file',\n          exporterAllAsCsv: 'Export all data as csv',\n          exporterVisibleAsCsv: 'Export visible data as csv',\n          exporterSelectedAsCsv: 'Export selected data as csv',\n          exporterAllAsPdf: 'Export all data as pdf',\n          exporterVisibleAsPdf: 'Export visible data as pdf',\n          exporterSelectedAsPdf: 'Export selected data as pdf',\n          clearAllFilters: 'Clean all filters'\n        },\n        importer: {\n          noHeaders: 'Column names were unable to be derived, does the file have a header?',\n          noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',\n          invalidCsv: 'File was unable to be processed, is it valid CSV?',\n          invalidJson: 'File was unable to be processed, is it valid Json?',\n          jsonNotArray: 'Imported json file must contain an array, aborting.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('hy', {\n        aggregate: {\n          label: 'տվյալներ'\n        },\n        groupPanel: {\n          description: 'Ըստ սյան խմբավորելու համար քաշեք և գցեք վերնագիրն այստեղ։'\n        },\n        search: {\n          placeholder: 'Փնտրում...',\n          showingItems: 'Ցուցադրված տվյալներ՝',\n          selectedItems: 'Ընտրված:',\n          totalItems: 'Ընդամենը՝',\n          size: 'Տողերի քանակը էջում՝',\n          first: 'Առաջին էջ',\n          next: 'Հաջորդ էջ',\n          previous: 'Նախորդ էջ',\n          last: 'Վերջին էջ'\n        },\n        menu: {\n          text: 'Ընտրել սյուները:'\n        },\n        sort: {\n          ascending: 'Աճման կարգով',\n          descending: 'Նվազման կարգով',\n          remove: 'Հանել '\n        },\n        column: {\n          hide: 'Թաքցնել սյունը'\n        },\n        aggregation: {\n          count: 'ընդամենը տող՝ ',\n          sum: 'ընդամենը՝ ',\n          avg: 'միջին՝ ',\n          min: 'մին՝ ',\n          max: 'մաքս՝ '\n        },\n        pinning: {\n          pinLeft: 'Կպցնել ձախ կողմում',\n          pinRight: 'Կպցնել աջ կողմում',\n          unpin: 'Արձակել'\n        },\n        gridMenu: {\n          columns: 'Սյուներ:',\n          importerTitle: 'Ներմուծել ֆայլ',\n          exporterAllAsCsv: 'Արտահանել ամբողջը CSV',\n          exporterVisibleAsCsv: 'Արտահանել երևացող տվյալները CSV',\n          exporterSelectedAsCsv: 'Արտահանել ընտրված տվյալները CSV',\n          exporterAllAsPdf: 'Արտահանել PDF',\n          exporterVisibleAsPdf: 'Արտահանել երևացող տվյալները PDF',\n          exporterSelectedAsPdf: 'Արտահանել ընտրված տվյալները PDF',\n          clearAllFilters: 'Մաքրել բոլոր ֆիլտրերը'\n        },\n        importer: {\n          noHeaders: 'Հնարավոր չեղավ որոշել սյան վերնագրերը։ Արդյո՞ք ֆայլը ունի վերնագրեր։',\n          noObjects: 'Հնարավոր չեղավ կարդալ տվյալները։ Արդյո՞ք ֆայլում կան տվյալներ։',\n          invalidCsv: 'Հնարավոր չեղավ մշակել ֆայլը։ Արդյո՞ք այն վավեր CSV է։',\n          invalidJson: 'Հնարավոր չեղավ մշակել ֆայլը։ Արդյո՞ք այն վավեր Json է։',\n          jsonNotArray: 'Ներմուծված json ֆայլը պետք է պարունակի զանգված, կասեցվում է։'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('it', {\n        aggregate: {\n          label: 'elementi'\n        },\n        groupPanel: {\n          description: 'Trascina un\\'intestazione all\\'interno del gruppo della colonna.'\n        },\n        search: {\n          placeholder: 'Ricerca...',\n          showingItems: 'Mostra:',\n          selectedItems: 'Selezionati:',\n          totalItems: 'Totali:',\n          size: 'Tot Pagine:',\n          first: 'Prima',\n          next: 'Prossima',\n          previous: 'Precedente',\n          last: 'Ultima'\n        },\n        menu: {\n          text: 'Scegli le colonne:'\n        },\n        sort: {\n          ascending: 'Asc.',\n          descending: 'Desc.',\n          remove: 'Annulla ordinamento'\n        },\n        column: {\n          hide: 'Nascondi'\n        },\n        aggregation: {\n          count: 'righe totali: ',\n          sum: 'tot: ',\n          avg: 'media: ',\n          min: 'minimo: ',\n          max: 'massimo: '\n        },\n        pinning: {\n         pinLeft: 'Blocca a sx',\n          pinRight: 'Blocca a dx',\n          unpin: 'Blocca in alto'\n        },\n        gridMenu: {\n          columns: 'Colonne:',\n          importerTitle: 'Importa',\n          exporterAllAsCsv: 'Esporta tutti i dati in CSV',\n          exporterVisibleAsCsv: 'Esporta i dati visibili in CSV',\n          exporterSelectedAsCsv: 'Esporta i dati selezionati in CSV',\n          exporterAllAsPdf: 'Esporta tutti i dati in PDF',\n          exporterVisibleAsPdf: 'Esporta i dati visibili in PDF',\n          exporterSelectedAsPdf: 'Esporta i dati selezionati in PDF',\n          clearAllFilters: 'Pulire tutti i filtri'\n        },\n        importer: {\n          noHeaders: 'Impossibile reperire i nomi delle colonne, sicuro che siano indicati all\\'interno del file?',\n          noObjects: 'Impossibile reperire gli oggetti, sicuro che siano indicati all\\'interno del file?',\n          invalidCsv: 'Impossibile elaborare il file, sicuro che sia un CSV?',\n          invalidJson: 'Impossibile elaborare il file, sicuro che sia un JSON valido?',\n          jsonNotArray: 'Errore! Il file JSON da importare deve contenere un array.'\n        },\n        grouping: {\n          group: 'Raggruppa',\n          ungroup: 'Separa',\n          aggregate_count: 'Agg: N. Elem.',\n          aggregate_sum: 'Agg: Somma',\n          aggregate_max: 'Agg: Massimo',\n          aggregate_min: 'Agg: Minimo',\n          aggregate_avg: 'Agg: Media',\n          aggregate_remove: 'Agg: Rimuovi'\n        },\n        validate: {\n          error: 'Errore:',\n          minLength: 'Lunghezza minima pari a THRESHOLD caratteri.',\n          maxLength: 'Lunghezza massima pari a THRESHOLD caratteri.',\n          required: 'Necessario inserire un valore.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function() {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('ja', {\n        aggregate: {\n          label: '項目'\n        },\n        groupPanel: {\n          description: 'ここに列ヘッダをドラッグアンドドロップして、その列でグループ化します。'\n        },\n        search: {\n          placeholder: '検索...',\n          showingItems: '表示中の項目:',\n          selectedItems: '選択した項目:',\n          totalItems: '項目の総数:',\n          size: 'ページサイズ:',\n          first: '最初のページ',\n          next: '次のページ',\n          previous: '前のページ',\n          last: '前のページ'\n        },\n        menu: {\n          text: '列の選択:'\n        },\n        sort: {\n          ascending: '昇順に並べ替え',\n          descending: '降順に並べ替え',\n          remove: '並べ替えの解除'\n        },\n        column: {\n          hide: '列の非表示'\n        },\n        aggregation: {\n          count: '合計行数: ',\n          sum: '合計: ',\n          avg: '平均: ',\n          min: '最小: ',\n          max: '最大: '\n        },\n        pinning: {\n          pinLeft: '左に固定',\n          pinRight: '右に固定',\n          unpin: '固定解除'\n        },\n        gridMenu: {\n          columns: '列:',\n          importerTitle: 'ファイルのインポート',\n          exporterAllAsCsv: 'すべてのデータをCSV形式でエクスポート',\n          exporterVisibleAsCsv: '表示中のデータをCSV形式でエクスポート',\n          exporterSelectedAsCsv: '選択したデータをCSV形式でエクスポート',\n          exporterAllAsPdf: 'すべてのデータをPDF形式でエクスポート',\n          exporterVisibleAsPdf: '表示中のデータをPDF形式でエクスポート',\n          exporterSelectedAsPdf: '選択したデータをPDF形式でエクスポート',\n          clearAllFilters: 'すべてのフィルタを清掃してください'\n        },\n        importer: {\n          noHeaders: '列名を取得できません。ファイルにヘッダが含まれていることを確認してください。',\n          noObjects: 'オブジェクトを取得できません。ファイルにヘッダ以外のデータが含まれていることを確認してください。',\n          invalidCsv: 'ファイルを処理できません。ファイルが有効なCSV形式であることを確認してください。',\n          invalidJson: 'ファイルを処理できません。ファイルが有効なJSON形式であることを確認してください。',\n          jsonNotArray: 'インポートしたJSONファイルには配列が含まれている必要があります。処理を中止します。'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: '最初のページ',\n            pageBack: '前のページ',\n            pageSelected: '現在のページ',\n            pageForward: '次のページ',\n            pageToLast: '最後のページ'\n          },\n          sizes: '項目/ページ',\n          totalItems: '項目',\n          through: 'から',\n          of: '項目/全'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('ko', {\n        aggregate: {\n          label: '아이템'\n        },\n        groupPanel: {\n          description: '컬럼으로 그룹핑하기 위해서는 컬럼 헤더를 끌어 떨어뜨려 주세요.'\n        },\n        search: {\n          placeholder: '검색...',\n          showingItems: '항목 보여주기:',\n          selectedItems: '선택 항목:',\n          totalItems: '전체 항목:',\n          size: '페이지 크기:',\n          first: '첫번째 페이지',\n          next: '다음 페이지',\n          previous: '이전 페이지',\n          last: '마지막 페이지'\n        },\n        menu: {\n          text: '컬럼을 선택하세요:'\n        },\n        sort: {\n          ascending: '오름차순 정렬',\n          descending: '내림차순 정렬',\n          remove: '소팅 제거'\n        },\n        column: {\n          hide: '컬럼 제거'\n        },\n        aggregation: {\n          count: '전체 갯수: ',\n          sum: '전체: ',\n          avg: '평균: ',\n          min: '최소: ',\n          max: '최대: '\n        },\n        pinning: {\n         pinLeft: '왼쪽 핀',\n          pinRight: '오른쪽 핀',\n          unpin: '핀 제거'\n        },\n        gridMenu: {\n          columns: '컬럼:',\n          importerTitle: '파일 가져오기',\n          exporterAllAsCsv: 'csv로 모든 데이터 내보내기',\n          exporterVisibleAsCsv: 'csv로 보이는 데이터 내보내기',\n          exporterSelectedAsCsv: 'csv로 선택된 데이터 내보내기',\n          exporterAllAsPdf: 'pdf로 모든 데이터 내보내기',\n          exporterVisibleAsPdf: 'pdf로 보이는 데이터 내보내기',\n          exporterSelectedAsPdf: 'pdf로 선택 데이터 내보내기',\n          clearAllFilters: '모든 필터를 청소'\n        },\n        importer: {\n          noHeaders: '컬럼명이 지정되어 있지 않습니다. 파일에 헤더가 명시되어 있는지 확인해 주세요.',\n          noObjects: '데이터가 지정되어 있지 않습니다. 데이터가 파일에 있는지 확인해 주세요.',\n          invalidCsv: '파일을 처리할 수 없습니다. 올바른 csv인지 확인해 주세요.',\n          invalidJson: '파일을 처리할 수 없습니다. 올바른 json인지 확인해 주세요.',\n          jsonNotArray: 'json 파일은 배열을 포함해야 합니다.'\n        },\n        pagination: {\n          sizes: '페이지당 항목',\n          totalItems: '전체 항목'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('nl', {\n        aggregate: {\n          label: 'items'\n        },\n        groupPanel: {\n          description: 'Sleep hier een kolomnaam heen om op te groeperen.'\n        },\n        search: {\n          placeholder: 'Zoeken...',\n          showingItems: 'Getoonde items:',\n          selectedItems: 'Geselecteerde items:',\n          totalItems: 'Totaal aantal items:',\n          size: 'Items per pagina:',\n          first: 'Eerste pagina',\n          next: 'Volgende pagina',\n          previous: 'Vorige pagina',\n          last: 'Laatste pagina'\n        },\n        menu: {\n          text: 'Kies kolommen:'\n        },\n        sort: {\n          ascending: 'Sorteer oplopend',\n          descending: 'Sorteer aflopend',\n          remove: 'Verwijder sortering'\n        },\n        column: {\n          hide: 'Verberg kolom'\n        },\n        aggregation: {\n          count: 'Aantal rijen: ',\n          sum: 'Som: ',\n          avg: 'Gemiddelde: ',\n          min: 'Min: ',\n          max: 'Max: '\n        },\n        pinning: {\n          pinLeft: 'Zet links vast',\n          pinRight: 'Zet rechts vast',\n          unpin: 'Maak los'\n        },\n        gridMenu: {\n          columns: 'Kolommen:',\n          importerTitle: 'Importeer bestand',\n          exporterAllAsCsv: 'Exporteer alle data als csv',\n          exporterVisibleAsCsv: 'Exporteer zichtbare data als csv',\n          exporterSelectedAsCsv: 'Exporteer geselecteerde data als csv',\n          exporterAllAsPdf: 'Exporteer alle data als pdf',\n          exporterVisibleAsPdf: 'Exporteer zichtbare data als pdf',\n          exporterSelectedAsPdf: 'Exporteer geselecteerde data als pdf',\n          clearAllFilters: 'Reinig alle filters'\n        },\n        importer: {\n          noHeaders: 'Kolomnamen kunnen niet worden afgeleid. Heeft het bestand een header?',\n          noObjects: 'Objecten kunnen niet worden afgeleid. Bevat het bestand data naast de headers?',\n          invalidCsv: 'Het bestand kan niet verwerkt worden. Is het een valide csv bestand?',\n          invalidJson: 'Het bestand kan niet verwerkt worden. Is het valide json?',\n          jsonNotArray: 'Het json bestand moet een array bevatten. De actie wordt geannuleerd.'\n        },\n        pagination: {\n            sizes: 'items per pagina',\n            totalItems: 'items',\n            of: 'van de'\n        },\n        grouping: {\n            group: 'Groepeer',\n            ungroup: 'Groepering opheffen',\n            aggregate_count: 'Agg: Aantal',\n            aggregate_sum: 'Agg: Som',\n            aggregate_max: 'Agg: Max',\n            aggregate_min: 'Agg: Min',\n            aggregate_avg: 'Agg: Gem',\n            aggregate_remove: 'Agg: Verwijder'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('pl', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filter dla kolumny',\n            removeFilter: 'Usuń filter',\n            columnMenuButtonLabel: 'Menu kolumny'\n          },\n          priority: 'Prioritet:',\n          filterLabel: \"Filtr dla kolumny: \"\n        },\n        aggregate: {\n          label: 'pozycji'\n        },\n        groupPanel: {\n          description: 'Przeciągnij nagłówek kolumny tutaj, aby pogrupować według niej.'\n        },\n        search: {\n          placeholder: 'Szukaj...',\n          showingItems: 'Widoczne pozycje:',\n          selectedItems: 'Zaznaczone pozycje:',\n          totalItems: 'Wszystkich pozycji:',\n          size: 'Rozmiar strony:',\n          first: 'Pierwsza strona',\n          next: 'Następna strona',\n          previous: 'Poprzednia strona',\n          last: 'Ostatnia strona'\n        },\n        menu: {\n          text: 'Wybierz kolumny:'\n        },\n        sort: {\n          ascending: 'Sortuj rosnąco',\n          descending: 'Sortuj malejąco',\n          none: 'Brak sortowania',\n          remove: 'Wyłącz sortowanie'\n        },\n        column: {\n          hide: 'Ukryj kolumne'\n        },\n        aggregation: {\n          count: 'Razem pozycji: ',\n            sum: 'Razem: ',\n            avg: 'Średnia: ',\n            min: 'Min: ',\n            max: 'Max: '\n        },\n        pinning: {\n          pinLeft: 'Przypnij do lewej',\n          pinRight: 'Przypnij do prawej',\n          unpin: 'Odepnij'\n        },\n        columnMenu: {\n          close: 'Zamknij'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Menu Grida'\n          },\n          columns: 'Kolumny:',\n          importerTitle: 'Importuj plik',\n          exporterAllAsCsv: 'Eksportuj wszystkie dane do csv',\n          exporterVisibleAsCsv: 'Eksportuj widoczne dane do csv',\n          exporterSelectedAsCsv: 'Eksportuj zaznaczone dane do csv',\n          exporterAllAsPdf: 'Eksportuj wszystkie dane do pdf',\n          exporterVisibleAsPdf: 'Eksportuj widoczne dane do pdf',\n          exporterSelectedAsPdf: 'Eksportuj zaznaczone dane do pdf',\n          clearAllFilters: 'Wyczyść filtry'\n        },\n        importer: {\n          noHeaders: 'Nie udało się wczytać nazw kolumn. Czy plik posiada nagłówek?',\n          noObjects: 'Nie udalo się wczytać pozycji. Czy plik zawiera dane??',\n          invalidCsv: 'Nie udało się przetworzyć pliku, jest to prawidlowy plik CSV??',\n          invalidJson: 'Nie udało się przetworzyć pliku, jest to prawidlowy plik Json?',\n          jsonNotArray: 'Importowany plik json musi zawierać tablicę, importowanie przerwane.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Pierwsza strona',\n            pageBack: 'Poprzednia strona',\n            pageSelected: 'Wybrana strona',\n            pageForward: 'Następna strona',\n            pageToLast: 'Ostatnia strona'\n          },\n          sizes: 'pozycji na stronę',\n          totalItems: 'pozycji',\n          through: 'do',\n          of: 'z'\n        },\n        grouping: {\n          group: 'Grupuj',\n          ungroup: 'Rozgrupuj',\n          aggregate_count: 'Zbiorczo: Razem',\n          aggregate_sum: 'Zbiorczo: Suma',\n          aggregate_max: 'Zbiorczo: Max',\n          aggregate_min: 'Zbiorczo: Min',\n          aggregate_avg: 'Zbiorczo: Średnia',\n          aggregate_remove: 'Zbiorczo: Usuń'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('pt-br', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filtro por coluna',\n            removeFilter: 'Remover filtro',\n            columnMenuButtonLabel: 'Menu coluna'\n          },\n          priority: 'Prioridade:',\n          filterLabel: \"Filtro por coluna: \"\n        },\n        aggregate: {\n          label: 'itens'\n        },\n        groupPanel: {\n          description: 'Arraste e solte uma coluna aqui para agrupar por essa coluna'\n        },\n        search: {\n          placeholder: 'Procurar...',\n          showingItems: 'Mostrando os Itens:',\n          selectedItems: 'Items Selecionados:',\n          totalItems: 'Total de Itens:',\n          size: 'Tamanho da Página:',\n          first: 'Primeira Página',\n          next: 'Próxima Página',\n          previous: 'Página Anterior',\n          last: 'Última Página'\n        },\n        menu: {\n          text: 'Selecione as colunas:'\n        },\n        sort: {\n          ascending: 'Ordenar Ascendente',\n          descending: 'Ordenar Descendente',\n          none: 'Nenhuma Ordem',\n          remove: 'Remover Ordenação'\n        },\n        column: {\n          hide: 'Esconder coluna'\n        },\n        aggregation: {\n          count: 'total de linhas: ',\n          sum: 'total: ',\n          avg: 'med: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Fixar Esquerda',\n          pinRight: 'Fixar Direita',\n          unpin: 'Desprender'\n        },\n        columnMenu: {\n          close: 'Fechar'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Menu Grid'\n          },\n          columns: 'Colunas:',\n          importerTitle: 'Importar arquivo',\n          exporterAllAsCsv: 'Exportar todos os dados como csv',\n          exporterVisibleAsCsv: 'Exportar dados visíveis como csv',\n          exporterSelectedAsCsv: 'Exportar dados selecionados como csv',\n          exporterAllAsPdf: 'Exportar todos os dados como pdf',\n          exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',\n          exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',\n          clearAllFilters: 'Limpar todos os filtros'\n        },\n        importer: {\n          noHeaders: 'Nomes de colunas não puderam ser derivados. O arquivo tem um cabeçalho?',\n          noObjects: 'Objetos não puderam ser derivados. Havia dados no arquivo, além dos cabeçalhos?',\n          invalidCsv: 'Arquivo não pode ser processado. É um CSV válido?',\n          invalidJson: 'Arquivo não pode ser processado. É um Json válido?',\n          jsonNotArray: 'Arquivo json importado tem que conter um array. Abortando.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Primeira página',\n            pageBack: 'Página anterior',\n            pageSelected: 'Página Selecionada',\n            pageForward: 'Proxima',\n            pageToLast: 'Anterior'\n          },\n          sizes: 'itens por página',\n          totalItems: 'itens',\n          through: 'através dos',\n          of: 'de'\n        },\n        grouping: {\n          group: 'Agrupar',\n          ungroup: 'Desagrupar',\n          aggregate_count: 'Agr: Contar',\n          aggregate_sum: 'Agr: Soma',\n          aggregate_max: 'Agr: Max',\n          aggregate_min: 'Agr: Min',\n          aggregate_avg: 'Agr: Med',\n          aggregate_remove: 'Agr: Remover'\n        }\n      });\n      return $delegate;\n    }]);\n}]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('pt', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filtro por coluna',\n            removeFilter: 'Remover filtro',\n            columnMenuButtonLabel: 'Menu coluna'\n          },\n          priority: 'Prioridade:',\n          filterLabel: \"Filtro por coluna: \"\n        },\n        aggregate: {\n          label: 'itens'\n        },\n        groupPanel: {\n          description: 'Arraste e solte uma coluna aqui para agrupar por essa coluna'\n        },\n        search: {\n          placeholder: 'Procurar...',\n          showingItems: 'Mostrando os Itens:',\n          selectedItems: 'Itens Selecionados:',\n          totalItems: 'Total de Itens:',\n          size: 'Tamanho da Página:',\n          first: 'Primeira Página',\n          next: 'Próxima Página',\n          previous: 'Página Anterior',\n          last: 'Última Página'\n        },\n        menu: {\n          text: 'Selecione as colunas:'\n        },\n        sort: {\n          ascending: 'Ordenar Ascendente',\n          descending: 'Ordenar Descendente',\n          none: 'Nenhuma Ordem',\n          remove: 'Remover Ordenação'\n        },\n        column: {\n          hide: 'Esconder coluna'\n        },\n        aggregation: {\n          count: 'total de linhas: ',\n          sum: 'total: ',\n          avg: 'med: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Fixar Esquerda',\n          pinRight: 'Fixar Direita',\n          unpin: 'Desprender'\n        },\n        columnMenu: {\n          close: 'Fechar'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Menu Grid'\n          },\n          columns: 'Colunas:',\n          importerTitle: 'Importar ficheiro',\n          exporterAllAsCsv: 'Exportar todos os dados como csv',\n          exporterVisibleAsCsv: 'Exportar dados visíveis como csv',\n          exporterSelectedAsCsv: 'Exportar dados selecionados como csv',\n          exporterAllAsPdf: 'Exportar todos os dados como pdf',\n          exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',\n          exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',\n          clearAllFilters: 'Limpar todos os filtros'\n        },\n        importer: {\n          noHeaders: 'Nomes de colunas não puderam ser derivados. O ficheiro tem um cabeçalho?',\n          noObjects: 'Objetos não puderam ser derivados. Havia dados no ficheiro, além dos cabeçalhos?',\n          invalidCsv: 'Ficheiro não pode ser processado. É um CSV válido?',\n          invalidJson: 'Ficheiro não pode ser processado. É um Json válido?',\n          jsonNotArray: 'Ficheiro json importado tem que conter um array. Interrompendo.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Primeira página',\n            pageBack: 'Página anterior',\n            pageSelected: 'Página Selecionada',\n            pageForward: 'Próxima',\n            pageToLast: 'Anterior'\n          },\n          sizes: 'itens por página',\n          totalItems: 'itens',\n          through: 'através dos',\n          of: 'de'\n        },\n        grouping: {\n          group: 'Agrupar',\n          ungroup: 'Desagrupar',\n          aggregate_count: 'Agr: Contar',\n          aggregate_sum: 'Agr: Soma',\n          aggregate_max: 'Agr: Max',\n          aggregate_min: 'Agr: Min',\n          aggregate_avg: 'Agr: Med',\n          aggregate_remove: 'Agr: Remover'\n        }\n      });\n      return $delegate;\n    }]);\n}]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('ro', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Filtru pentru coloana',\n            removeFilter: 'Sterge filtru',\n            columnMenuButtonLabel: 'Column Menu'\n          },\n          priority: 'Prioritate:',\n          filterLabel: \"Filtru pentru coloana:\"\n        },\n        aggregate: {\n          label: 'Elemente'\n        },\n        groupPanel: {\n          description: 'Trage un cap de coloana aici pentru a grupa elementele dupa coloana respectiva'\n        },\n        search: {\n          placeholder: 'Cauta...',\n          showingItems: 'Arata elementele:',\n          selectedItems: 'Elementele selectate:',\n          totalItems: 'Total elemente:',\n          size: 'Marime pagina:',\n          first: 'Prima pagina',\n          next: 'Pagina urmatoare',\n          previous: 'Pagina anterioara',\n          last: 'Ultima pagina'\n        },\n        menu: {\n          text: 'Alege coloane:'\n        },\n        sort: {\n          ascending: 'Ordoneaza crescator',\n          descending: 'Ordoneaza descrescator',\n          none: 'Fara ordonare',\n          remove: 'Sterge ordonarea'\n        },\n        column: {\n          hide: 'Ascunde coloana'\n        },\n        aggregation: {\n          count: 'total linii: ',\n          sum: 'total: ',\n          avg: 'medie: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        pinning: {\n          pinLeft: 'Pin la stanga',\n          pinRight: 'Pin la dreapta',\n          unpin: 'Sterge pinul'\n        },\n        columnMenu: {\n          close: 'Inchide'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Grid Menu'\n          },\n          columns: 'Coloane:',\n          importerTitle: 'Incarca fisier',\n          exporterAllAsCsv: 'Exporta toate datele ca csv',\n          exporterVisibleAsCsv: 'Exporta datele vizibile ca csv',\n          exporterSelectedAsCsv: 'Exporta datele selectate ca csv',\n          exporterAllAsPdf: 'Exporta toate datele ca pdf',\n          exporterVisibleAsPdf: 'Exporta datele vizibile ca pdf',\n          exporterSelectedAsPdf: 'Exporta datele selectate ca csv pdf',\n          clearAllFilters: 'Sterge toate filtrele'\n        },\n        importer: {\n          noHeaders: 'Numele coloanelor nu a putut fi incarcat, acest fisier are un header?',\n          noObjects: 'Datele nu au putut fi incarcate, exista date in fisier in afara numelor de coloane?',\n          invalidCsv: 'Fisierul nu a putut fi procesat, ati incarcat un CSV valid ?',\n          invalidJson: 'Fisierul nu a putut fi procesat, ati incarcat un Json valid?',\n          jsonNotArray: 'Json-ul incarcat trebuie sa contina un array, inchidere.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Prima pagina',\n            pageBack: 'O pagina inapoi',\n            pageSelected: 'Pagina selectata',\n            pageForward: 'O pagina inainte',\n            pageToLast: 'Ultima pagina'\n          },\n          sizes: 'Elemente per pagina',\n          totalItems: 'elemente',\n          through: 'prin',\n          of: 'of'\n        },\n        grouping: {\n          group: 'Grupeaza',\n          ungroup: 'Opreste gruparea',\n          aggregate_count: 'Agg: Count',\n          aggregate_sum: 'Agg: Sum',\n          aggregate_max: 'Agg: Max',\n          aggregate_min: 'Agg: Min',\n          aggregate_avg: 'Agg: Avg',\n          aggregate_remove: 'Agg: Remove'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('ru', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Фильтр столбца',\n            removeFilter: 'Удалить фильтр',\n            columnMenuButtonLabel: 'Меню столбца'\n          },\n          priority: 'Приоритет:',\n          filterLabel: \"Фильтр столбца: \"\n        },\n        aggregate: {\n          label: 'элементы'\n        },\n        groupPanel: {\n          description: 'Для группировки по столбцу перетащите сюда его название.'\n        },\n        search: {\n          placeholder: 'Поиск...',\n          showingItems: 'Показать элементы:',\n          selectedItems: 'Выбранные элементы:',\n          totalItems: 'Всего элементов:',\n          size: 'Размер страницы:',\n          first: 'Первая страница',\n          next: 'Следующая страница',\n          previous: 'Предыдущая страница',\n          last: 'Последняя страница'\n        },\n        menu: {\n          text: 'Выбрать столбцы:'\n        },\n        sort: {\n          ascending: 'По возрастанию',\n          descending: 'По убыванию',\n          none: 'Без сортировки',\n          remove: 'Убрать сортировку'\n        },\n        column: {\n          hide: 'Спрятать столбец'\n        },\n        aggregation: {\n          count: 'всего строк: ',\n          sum: 'итого: ',\n          avg: 'среднее: ',\n          min: 'мин: ',\n          max: 'макс: '\n        },\n\t\t\t\tpinning: {\n\t\t\t\t\tpinLeft: 'Закрепить слева',\n\t\t\t\t\tpinRight: 'Закрепить справа',\n\t\t\t\t\tunpin: 'Открепить'\n\t\t\t\t},\n        columnMenu: {\n          close: 'Закрыть'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Меню'\n          },\n          columns: 'Столбцы:',\n          importerTitle: 'Импортировать файл',\n          exporterAllAsCsv: 'Экспортировать всё в CSV',\n          exporterVisibleAsCsv: 'Экспортировать видимые данные в CSV',\n          exporterSelectedAsCsv: 'Экспортировать выбранные данные в CSV',\n          exporterAllAsPdf: 'Экспортировать всё в PDF',\n          exporterVisibleAsPdf: 'Экспортировать видимые данные в PDF',\n          exporterSelectedAsPdf: 'Экспортировать выбранные данные в PDF',\n          clearAllFilters: 'Очистите все фильтры'\n        },\n        importer: {\n          noHeaders: 'Не удалось получить названия столбцов, есть ли в файле заголовок?',\n          noObjects: 'Не удалось получить данные, есть ли в файле строки кроме заголовка?',\n          invalidCsv: 'Не удалось обработать файл, это правильный CSV-файл?',\n          invalidJson: 'Не удалось обработать файл, это правильный JSON?',\n          jsonNotArray: 'Импортируемый JSON-файл должен содержать массив, операция отменена.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'Первая страница',\n            pageBack: 'Предыдущая страница',\n            pageSelected: 'Выбранная страница',\n            pageForward: 'Следующая страница',\n            pageToLast: 'Последняя страница'\n          },\n          sizes: 'строк на страницу',\n          totalItems: 'строк',\n          through: 'по',\n          of: 'из'\n        },\n        grouping: {\n          group: 'Группировать',\n          ungroup: 'Разгруппировать',\n          aggregate_count: 'Группировать: Count',\n          aggregate_sum: 'Для группы: Сумма',\n          aggregate_max: 'Для группы: Максимум',\n          aggregate_min: 'Для группы: Минимум',\n          aggregate_avg: 'Для группы: Среднее',\n          aggregate_remove: 'Для группы: Пусто'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('sk', {\n        aggregate: {\n          label: 'items'\n        },\n        groupPanel: {\n          description: 'Pretiahni sem názov stĺpca pre zoskupenie podľa toho stĺpca.'\n        },\n        search: {\n          placeholder: 'Hľadaj...',\n          showingItems: 'Zobrazujem položky:',\n          selectedItems: 'Vybraté položky:',\n          totalItems: 'Počet položiek:',\n          size: 'Počet:',\n          first: 'Prvá strana',\n          next: 'Ďalšia strana',\n          previous: 'Predchádzajúca strana',\n          last: 'Posledná strana'\n        },\n        menu: {\n          text: 'Vyberte stĺpce:'\n        },\n        sort: {\n          ascending: 'Zotriediť vzostupne',\n          descending: 'Zotriediť zostupne',\n          remove: 'Vymazať triedenie'\n        },\n        aggregation: {\n          count: 'total rows: ',\n          sum: 'total: ',\n          avg: 'avg: ',\n          min: 'min: ',\n          max: 'max: '\n        },\n        gridMenu: {\n          columns: 'Columns:',\n          importerTitle: 'Import file',\n          exporterAllAsCsv: 'Export all data as csv',\n          exporterVisibleAsCsv: 'Export visible data as csv',\n          exporterSelectedAsCsv: 'Export selected data as csv',\n          exporterAllAsPdf: 'Export all data as pdf',\n          exporterVisibleAsPdf: 'Export visible data as pdf',\n          exporterSelectedAsPdf: 'Export selected data as pdf',\n          clearAllFilters: 'Clear all filters'\n        },\n        importer: {\n          noHeaders: 'Column names were unable to be derived, does the file have a header?',\n          noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',\n          invalidCsv: 'File was unable to be processed, is it valid CSV?',\n          invalidJson: 'File was unable to be processed, is it valid Json?',\n          jsonNotArray: 'Imported json file must contain an array, aborting.'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('sv', {\n        aggregate: {\n          label: 'Artiklar'\n        },\n        groupPanel: {\n          description: 'Dra en kolumnrubrik hit och släpp den för att gruppera efter den kolumnen.'\n        },\n        search: {\n          placeholder: 'Sök...',\n          showingItems: 'Visar artiklar:',\n          selectedItems: 'Valda artiklar:',\n          totalItems: 'Antal artiklar:',\n          size: 'Sidstorlek:',\n          first: 'Första sidan',\n          next: 'Nästa sida',\n          previous: 'Föregående sida',\n          last: 'Sista sidan'\n        },\n        menu: {\n          text: 'Välj kolumner:'\n        },\n        sort: {\n          ascending: 'Sortera stigande',\n          descending: 'Sortera fallande',\n          remove: 'Inaktivera sortering'\n        },\n        column: {\n          hide: 'Göm kolumn'\n        },\n        aggregation: {\n          count: 'Antal rader: ',\n          sum: 'Summa: ',\n          avg: 'Genomsnitt: ',\n          min: 'Min: ',\n          max: 'Max: '\n        },\n        pinning: {\n          pinLeft: 'Fäst vänster',\n          pinRight: 'Fäst höger',\n          unpin: 'Lösgör'\n        },\n        gridMenu: {\n          columns: 'Kolumner:',\n          importerTitle: 'Importera fil',\n          exporterAllAsCsv: 'Exportera all data som CSV',\n          exporterVisibleAsCsv: 'Exportera synlig data som CSV',\n          exporterSelectedAsCsv: 'Exportera markerad data som CSV',\n          exporterAllAsPdf: 'Exportera all data som PDF',\n          exporterVisibleAsPdf: 'Exportera synlig data som PDF',\n          exporterSelectedAsPdf: 'Exportera markerad data som PDF',\n          clearAllFilters: 'Rengör alla filter'\n        },\n        importer: {\n          noHeaders: 'Kolumnnamn kunde inte härledas. Har filen ett sidhuvud?',\n          noObjects: 'Objekt kunde inte härledas. Har filen data undantaget sidhuvud?',\n          invalidCsv: 'Filen kunde inte behandlas, är den en giltig CSV?',\n          invalidJson: 'Filen kunde inte behandlas, är den en giltig JSON?',\n          jsonNotArray: 'Importerad JSON-fil måste innehålla ett fält. Import avbruten.'\n        },\n        pagination: {\n          sizes: 'Artiklar per sida',\n          totalItems: 'Artiklar'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('ta', {\n        aggregate: {\n          label: 'உருப்படிகள்'\n        },\n        groupPanel: {\n          description: 'ஒரு பத்தியை குழுவாக அமைக்க அப்பத்தியின் தலைப்பை இங்கே  இழுத்து வரவும் '\n        },\n        search: {\n          placeholder: 'தேடல் ...',\n          showingItems: 'உருப்படிகளை காண்பித்தல்:',\n          selectedItems: 'தேர்ந்தெடுக்கப்பட்ட  உருப்படிகள்:',\n          totalItems: 'மொத்த உருப்படிகள்:',\n          size: 'பக்க அளவு: ',\n          first: 'முதல் பக்கம்',\n          next: 'அடுத்த பக்கம்',\n          previous: 'முந்தைய பக்கம் ',\n          last: 'இறுதி பக்கம்'\n        },\n        menu: {\n          text: 'பத்திகளை தேர்ந்தெடு:'\n        },\n        sort: {\n          ascending: 'மேலிருந்து கீழாக',\n          descending: 'கீழிருந்து மேலாக',\n          remove: 'வரிசையை நீக்கு'\n        },\n        column: {\n          hide: 'பத்தியை மறைத்து வை '\n        },\n        aggregation: {\n          count: 'மொத்த வரிகள்:',\n          sum: 'மொத்தம்: ',\n          avg: 'சராசரி: ',\n          min: 'குறைந்தபட்ச: ',\n          max: 'அதிகபட்ச: '\n        },\n        pinning: {\n         pinLeft: 'இடதுபுறமாக தைக்க ',\n          pinRight: 'வலதுபுறமாக தைக்க',\n          unpin: 'பிரி'\n        },\n        gridMenu: {\n          columns: 'பத்திகள்:',\n          importerTitle: 'கோப்பு : படித்தல்',\n          exporterAllAsCsv: 'எல்லா தரவுகளையும் கோப்பாக்கு: csv',\n          exporterVisibleAsCsv: 'இருக்கும் தரவுகளை கோப்பாக்கு: csv',\n          exporterSelectedAsCsv: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: csv',\n          exporterAllAsPdf: 'எல்லா தரவுகளையும் கோப்பாக்கு: pdf',\n          exporterVisibleAsPdf: 'இருக்கும் தரவுகளை கோப்பாக்கு: pdf',\n          exporterSelectedAsPdf: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: pdf',\n          clearAllFilters: 'Clear all filters'\n        },\n        importer: {\n          noHeaders: 'பத்தியின் தலைப்புகளை பெற இயலவில்லை, கோப்பிற்கு தலைப்பு உள்ளதா?',\n          noObjects: 'இலக்குகளை உருவாக்க முடியவில்லை, கோப்பில் தலைப்புகளை தவிர தரவு ஏதேனும் உள்ளதா? ',\n          invalidCsv:\t'சரிவர நடைமுறை படுத்த இயலவில்லை, கோப்பு சரிதானா? - csv',\n          invalidJson: 'சரிவர நடைமுறை படுத்த இயலவில்லை, கோப்பு சரிதானா? - json',\n          jsonNotArray: 'படித்த கோப்பில் வரிசைகள் உள்ளது, நடைமுறை ரத்து செய் : json'\n        },\n        pagination: {\n          sizes\t\t: 'உருப்படிகள் / பக்கம்',\n          totalItems\t: 'உருப்படிகள் '\n        },\n        grouping: {\n          group\t: 'குழு',\n          ungroup : 'பிரி',\n          aggregate_count\t: 'மதிப்பீட்டு : எண்ணு',\n          aggregate_sum : 'மதிப்பீட்டு : கூட்டல்',\n          aggregate_max\t: 'மதிப்பீட்டு : அதிகபட்சம்',\n          aggregate_min\t: 'மதிப்பீட்டு : குறைந்தபட்சம்',\n          aggregate_avg\t: 'மதிப்பீட்டு : சராசரி',\n          aggregate_remove : 'மதிப்பீட்டு : நீக்கு'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function () {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('tr', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: 'Sütun için filtre',\n            removeFilter: 'Filtreyi Kaldır',\n            columnMenuButtonLabel: 'Sütun Menüsü'\n          },\n          priority: 'Öncelik:',\n          filterLabel: \"Sütun için filtre: \"\n        },\n        aggregate: {\n          label: 'kayıtlar'\n        },\n        groupPanel: {\n          description: 'Sütuna göre gruplamak için sütun başlığını buraya sürükleyin ve bırakın.'\n        },\n        search: {\n          placeholder: 'Arama...',\n          showingItems: 'Gösterilen Kayıt:',\n          selectedItems: 'Seçili Kayıt:',\n          totalItems: 'Toplam Kayıt:',\n          size: 'Sayfa Boyutu:',\n          first: 'İlk Sayfa',\n          next: 'Sonraki Sayfa',\n          previous: 'Önceki Sayfa',\n          last: 'Son Sayfa'\n        },\n        menu: {\n          text: 'Sütunları Seç:'\n        },\n        sort: {\n          ascending: 'Artan Sırada Sırala',\n          descending: 'Azalan Sırada Sırala',\n          none: 'Sıralama Yapma',\n          remove: 'Sıralamayı Kaldır'\n        },\n        column: {\n          hide: 'Sütunu Gizle'\n        },\n        aggregation: {\n          count: 'toplam satır: ',\n          sum: 'toplam: ',\n          avg: 'ort: ',\n          min: 'min: ',\n          max: 'maks: '\n        },\n        pinning: {\n          pinLeft: 'Sola Sabitle',\n          pinRight: 'Sağa Sabitle',\n          unpin: 'Sabitlemeyi Kaldır'\n        },\n        columnMenu: {\n          close: 'Kapat'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: 'Tablo Menü'\n          },\n          columns: 'Sütunlar:',\n          importerTitle: 'Dosya içeri aktar',\n          exporterAllAsCsv: 'Bütün veriyi CSV olarak dışarı aktar',\n          exporterVisibleAsCsv: 'Görünen veriyi CSV olarak dışarı aktar',\n          exporterSelectedAsCsv: 'Seçili veriyi CSV olarak dışarı aktar',\n          exporterAllAsPdf: 'Bütün veriyi PDF olarak dışarı aktar',\n          exporterVisibleAsPdf: 'Görünen veriyi PDF olarak dışarı aktar',\n          exporterSelectedAsPdf: 'Seçili veriyi PDF olarak dışarı aktar',\n          clearAllFilters: 'Bütün filtreleri kaldır'\n        },\n        importer: {\n          noHeaders: 'Sütun isimleri üretilemiyor, dosyanın bir başlığı var mı?',\n          noObjects: 'Nesneler üretilemiyor, dosyada başlıktan başka bir veri var mı?',\n          invalidCsv: 'Dosya işlenemedi, geçerli bir CSV dosyası mı?',\n          invalidJson: 'Dosya işlenemedi, geçerli bir Json dosyası mı?',\n          jsonNotArray: 'Alınan Json dosyasında bir dizi bulunmalıdır, işlem iptal ediliyor.'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: 'İlk sayfaya',\n            pageBack: 'Geri git',\n            pageSelected: 'Seçili sayfa',\n            pageForward: 'İleri git',\n            pageToLast: 'Sona git'\n          },\n          sizes: 'Sayfadaki nesne sayısı',\n          totalItems: 'kayıtlar',\n          through: '', //note(fsw) : turkish dont have this preposition \n          of: '' //note(fsw) : turkish dont have this preposition\n        },\n        grouping: {\n          group: 'Grupla',\n          ungroup: 'Gruplama',\n          aggregate_count: 'Yekun: Sayı',\n          aggregate_sum: 'Yekun: Toplam',\n          aggregate_max: 'Yekun: Maks',\n          aggregate_min: 'Yekun: Min',\n          aggregate_avg: 'Yekun: Ort',\n          aggregate_remove: 'Yekun: Sil'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n/**\n * @ngdoc overview\n * @name ui.grid.i18n\n * @description\n *\n *  # ui.grid.i18n\n * This module provides i18n functions to ui.grid and any application that wants to use it\n\n *\n * <div doc-module-components=\"ui.grid.i18n\"></div>\n */\n\n(function () {\n  var DIRECTIVE_ALIASES = ['uiT', 'uiTranslate'];\n  var FILTER_ALIASES = ['t', 'uiTranslate'];\n\n  var module = angular.module('ui.grid.i18n');\n\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.i18n.constant:i18nConstants\n   *\n   *  @description constants available in i18n module\n   */\n  module.constant('i18nConstants', {\n    MISSING: '[MISSING]',\n    UPDATE_EVENT: '$uiI18n',\n\n    LOCALE_DIRECTIVE_ALIAS: 'uiI18n',\n    // default to english\n    DEFAULT_LANG: 'en'\n  });\n\n//    module.config(['$provide', function($provide) {\n//        $provide.decorator('i18nService', ['$delegate', function($delegate) {}])}]);\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.i18n.service:i18nService\n   *\n   *  @description Services for i18n\n   */\n  module.service('i18nService', ['$log', 'i18nConstants', '$rootScope',\n    function ($log, i18nConstants, $rootScope) {\n\n      var langCache = {\n        _langs: {},\n        current: null,\n        get: function (lang) {\n          return this._langs[lang.toLowerCase()];\n        },\n        add: function (lang, strings) {\n          var lower = lang.toLowerCase();\n          if (!this._langs[lower]) {\n            this._langs[lower] = {};\n          }\n          angular.extend(this._langs[lower], strings);\n        },\n        getAllLangs: function () {\n          var langs = [];\n          if (!this._langs) {\n            return langs;\n          }\n\n          for (var key in this._langs) {\n            langs.push(key);\n          }\n\n          return langs;\n        },\n        setCurrent: function (lang) {\n          this.current = lang.toLowerCase();\n        },\n        getCurrentLang: function () {\n          return this.current;\n        }\n      };\n\n      var service = {\n\n        /**\n         * @ngdoc service\n         * @name add\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description  Adds the languages and strings to the cache. Decorate this service to\n         * add more translation strings\n         * @param {string} lang language to add\n         * @param {object} stringMaps of strings to add grouped by property names\n         * @example\n         * <pre>\n         *      i18nService.add('en', {\n         *         aggregate: {\n         *                 label1: 'items',\n         *                 label2: 'some more items'\n         *                 }\n         *         },\n         *         groupPanel: {\n         *              description: 'Drag a column header here and drop it to group by that column.'\n         *           }\n         *      }\n         * </pre>\n         */\n        add: function (langs, stringMaps) {\n          if (typeof(langs) === 'object') {\n            angular.forEach(langs, function (lang) {\n              if (lang) {\n                langCache.add(lang, stringMaps);\n              }\n            });\n          } else {\n            langCache.add(langs, stringMaps);\n          }\n        },\n\n        /**\n         * @ngdoc service\n         * @name getAllLangs\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description  return all currently loaded languages\n         * @returns {array} string\n         */\n        getAllLangs: function () {\n          return langCache.getAllLangs();\n        },\n\n        /**\n         * @ngdoc service\n         * @name get\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description  return all currently loaded languages\n         * @param {string} lang to return.  If not specified, returns current language\n         * @returns {object} the translation string maps for the language\n         */\n        get: function (lang) {\n          var language = lang ? lang : service.getCurrentLang();\n          return langCache.get(language);\n        },\n\n        /**\n         * @ngdoc service\n         * @name getSafeText\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description  returns the text specified in the path or a Missing text if text is not found\n         * @param {string} path property path to use for retrieving text from string map\n         * @param {string} lang to return.  If not specified, returns current language\n         * @returns {object} the translation for the path\n         * @example\n         * <pre>\n         * i18nService.getSafeText('sort.ascending')\n         * </pre>\n         */\n        getSafeText: function (path, lang) {\n          var language = lang ? lang : service.getCurrentLang();\n          var trans = langCache.get(language);\n\n          if (!trans) {\n            return i18nConstants.MISSING;\n          }\n\n          var paths = path.split('.');\n          var current = trans;\n\n          for (var i = 0; i < paths.length; ++i) {\n            if (current[paths[i]] === undefined || current[paths[i]] === null) {\n              return i18nConstants.MISSING;\n            } else {\n              current = current[paths[i]];\n            }\n          }\n\n          return current;\n\n        },\n\n        /**\n         * @ngdoc service\n         * @name setCurrentLang\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description sets the current language to use in the application\n         * $broadcasts the Update_Event on the $rootScope\n         * @param {string} lang to set\n         * @example\n         * <pre>\n         * i18nService.setCurrentLang('fr');\n         * </pre>\n         */\n\n        setCurrentLang: function (lang) {\n          if (lang) {\n            langCache.setCurrent(lang);\n            $rootScope.$broadcast(i18nConstants.UPDATE_EVENT);\n          }\n        },\n\n        /**\n         * @ngdoc service\n         * @name getCurrentLang\n         * @methodOf ui.grid.i18n.service:i18nService\n         * @description returns the current language used in the application\n         */\n        getCurrentLang: function () {\n          var lang = langCache.getCurrentLang();\n          if (!lang) {\n            lang = i18nConstants.DEFAULT_LANG;\n            langCache.setCurrent(lang);\n          }\n          return lang;\n        }\n\n      };\n\n      return service;\n\n    }]);\n\n  var localeDirective = function (i18nService, i18nConstants) {\n    return {\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs) {\n            var alias = i18nConstants.LOCALE_DIRECTIVE_ALIAS;\n            // check for watchable property\n            var lang = $scope.$eval($attrs[alias]);\n            if (lang) {\n              $scope.$watch($attrs[alias], function () {\n                i18nService.setCurrentLang(lang);\n              });\n            } else if ($attrs.$$observers) {\n              $attrs.$observe(alias, function () {\n                i18nService.setCurrentLang($attrs[alias] || i18nConstants.DEFAULT_LANG);\n              });\n            }\n          }\n        };\n      }\n    };\n  };\n\n  module.directive('uiI18n', ['i18nService', 'i18nConstants', localeDirective]);\n\n  // directive syntax\n  var uitDirective = function ($parse, i18nService, i18nConstants) {\n    return {\n      restrict: 'EA',\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs) {\n            var alias1 = DIRECTIVE_ALIASES[0],\n              alias2 = DIRECTIVE_ALIASES[1];\n            var token = $attrs[alias1] || $attrs[alias2] || $elm.html();\n            var missing = i18nConstants.MISSING + token;\n            var observer;\n            if ($attrs.$$observers) {\n              var prop = $attrs[alias1] ? alias1 : alias2;\n              observer = $attrs.$observe(prop, function (result) {\n                if (result) {\n                  $elm.html($parse(result)(i18nService.getCurrentLang()) || missing);\n                }\n              });\n            }\n            var getter = $parse(token);\n            var listener = $scope.$on(i18nConstants.UPDATE_EVENT, function (evt) {\n              if (observer) {\n                observer($attrs[alias1] || $attrs[alias2]);\n              } else {\n                // set text based on i18n current language\n                $elm.html(getter(i18nService.get()) || missing);\n              }\n            });\n            $scope.$on('$destroy', listener);\n\n            $elm.html(getter(i18nService.get()) || missing);\n          }\n        };\n      }\n    };\n  };\n\n  angular.forEach( DIRECTIVE_ALIASES, function ( alias ) {\n    module.directive( alias, ['$parse', 'i18nService', 'i18nConstants', uitDirective] );\n  } );\n\n  // optional filter syntax\n  var uitFilter = function ($parse, i18nService, i18nConstants) {\n    return function (data) {\n      var getter = $parse(data);\n      // set text based on i18n current language\n      return getter(i18nService.get()) || i18nConstants.MISSING + data;\n    };\n  };\n\n  angular.forEach( FILTER_ALIASES, function ( alias ) {\n    module.filter( alias, ['$parse', 'i18nService', 'i18nConstants', uitFilter] );\n  } );\n\n\n})();\n(function() {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('zh-cn', {\n        headerCell: {\n          aria: {\n            defaultFilterLabel: '列过滤器',\n            removeFilter: '移除过滤器',\n            columnMenuButtonLabel: '列菜单'\n          },\n          priority: '优先级:',\n          filterLabel: \"列过滤器: \"\n        },\n        aggregate: {\n          label: '行'\n        },\n        groupPanel: {\n          description: '拖曳表头到此处进行分组'\n        },\n        search: {\n          placeholder: '查找',\n          showingItems: '已显示行数：',\n          selectedItems: '已选择行数：',\n          totalItems: '总行数：',\n          size: '每页显示行数：',\n          first: '首页',\n          next: '下一页',\n          previous: '上一页',\n          last: '末页'\n        },\n        menu: {\n          text: '选择列：'\n        },\n        sort: {\n          ascending: '升序',\n          descending: '降序',\n          none: '无序',\n          remove: '取消排序'\n        },\n        column: {\n          hide: '隐藏列'\n        },\n        aggregation: {\n          count: '计数：',\n          sum: '求和：',\n          avg: '均值：',\n          min: '最小值：',\n          max: '最大值：'\n        },\n        pinning: {\n          pinLeft: '左侧固定',\n          pinRight: '右侧固定',\n          unpin: '取消固定'\n        },\n        columnMenu: {\n          close: '关闭'\n        },\n        gridMenu: {\n          aria: {\n            buttonLabel: '表格菜单'\n          },\n          columns: '列：',\n          importerTitle: '导入文件',\n          exporterAllAsCsv: '导出全部数据到CSV',\n          exporterVisibleAsCsv: '导出可见数据到CSV',\n          exporterSelectedAsCsv: '导出已选数据到CSV',\n          exporterAllAsPdf: '导出全部数据到PDF',\n          exporterVisibleAsPdf: '导出可见数据到PDF',\n          exporterSelectedAsPdf: '导出已选数据到PDF',\n          clearAllFilters: '清除所有过滤器'\n        },\n        importer: {\n          noHeaders: '无法获取列名，确定文件包含表头？',\n          noObjects: '无法获取数据，确定文件包含数据？',\n          invalidCsv: '无法处理文件，确定是合法的CSV文件？',\n          invalidJson: '无法处理文件，确定是合法的JSON文件？',\n          jsonNotArray: '导入的文件不是JSON数组！'\n        },\n        pagination: {\n          aria: {\n            pageToFirst: '第一页',\n            pageBack: '上一页',\n            pageSelected: '当前页',\n            pageForward: '下一页',\n            pageToLast: '最后一页'\n          },\n          sizes: '行每页',\n          totalItems: '行',\n          through: '至',\n          of: '共'\n        },\n        grouping: {\n          group: '分组',\n          ungroup: '取消分组',\n          aggregate_count: '合计: 计数',\n          aggregate_sum: '合计: 求和',\n          aggregate_max: '合计: 最大',\n          aggregate_min: '合计: 最小',\n          aggregate_avg: '合计: 平均',\n          aggregate_remove: '合计: 移除'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function() {\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('i18nService', ['$delegate', function($delegate) {\n      $delegate.add('zh-tw', {\n        aggregate: {\n          label: '行'\n        },\n        groupPanel: {\n          description: '拖曳表頭到此處進行分組'\n        },\n        search: {\n          placeholder: '查找',\n          showingItems: '已顯示行數：',\n          selectedItems: '已選擇行數：',\n          totalItems: '總行數：',\n          size: '每頁顯示行數：',\n          first: '首頁',\n          next: '下壹頁',\n          previous: '上壹頁',\n          last: '末頁'\n        },\n        menu: {\n          text: '選擇列：'\n        },\n        sort: {\n          ascending: '升序',\n          descending: '降序',\n          remove: '取消排序'\n        },\n        column: {\n          hide: '隱藏列'\n        },\n        aggregation: {\n          count: '計數：',\n          sum: '求和：',\n          avg: '均值：',\n          min: '最小值：',\n          max: '最大值：'\n        },\n        pinning: {\n          pinLeft: '左側固定',\n          pinRight: '右側固定',\n          unpin: '取消固定'\n        },\n        gridMenu: {\n          columns: '列：',\n          importerTitle: '導入文件',\n          exporterAllAsCsv: '導出全部數據到CSV',\n          exporterVisibleAsCsv: '導出可見數據到CSV',\n          exporterSelectedAsCsv: '導出已選數據到CSV',\n          exporterAllAsPdf: '導出全部數據到PDF',\n          exporterVisibleAsPdf: '導出可見數據到PDF',\n          exporterSelectedAsPdf: '導出已選數據到PDF',\n          clearAllFilters: '清除所有过滤器'\n        },\n        importer: {\n          noHeaders: '無法獲取列名，確定文件包含表頭？',\n          noObjects: '無法獲取數據，確定文件包含數據？',\n          invalidCsv: '無法處理文件，確定是合法的CSV文件？',\n          invalidJson: '無法處理文件，確定是合法的JSON文件？',\n          jsonNotArray: '導入的文件不是JSON數組！'\n        },\n        pagination: {\n          sizes: '行每頁',\n          totalItems: '行'\n        }\n      });\n      return $delegate;\n    }]);\n  }]);\n})();\n\n(function() {\n  'use strict';\n  /**\n   *  @ngdoc overview\n   *  @name ui.grid.autoResize\n   *\n   *  @description\n   *\n   *  #ui.grid.autoResize\n   *\n   *  <div class=\"alert alert-warning\" role=\"alert\"><strong>Beta</strong> This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs.</div>\n   *\n   *  This module provides auto-resizing functionality to UI-Grid.\n   */\n  var module = angular.module('ui.grid.autoResize', ['ui.grid']);\n\n\n  module.directive('uiGridAutoResize', ['$timeout', 'gridUtil', function ($timeout, gridUtil) {\n    return {\n      require: 'uiGrid',\n      scope: false,\n      link: function ($scope, $elm, $attrs, uiGridCtrl) {\n        var prevGridWidth, prevGridHeight;\n\n        function getDimensions() {\n          prevGridHeight = gridUtil.elementHeight($elm);\n          prevGridWidth = gridUtil.elementWidth($elm);\n        }\n\n        // Initialize the dimensions\n        getDimensions();\n\n        var resizeTimeoutId;\n        function startTimeout() {\n          clearTimeout(resizeTimeoutId);\n\n          resizeTimeoutId = setTimeout(function () {\n            var newGridHeight = gridUtil.elementHeight($elm);\n            var newGridWidth = gridUtil.elementWidth($elm);\n\n            if (newGridHeight !== prevGridHeight || newGridWidth !== prevGridWidth) {\n              uiGridCtrl.grid.gridHeight = newGridHeight;\n              uiGridCtrl.grid.gridWidth = newGridWidth;\n\n              $scope.$apply(function () {\n                uiGridCtrl.grid.refresh()\n                  .then(function () {\n                    getDimensions();\n\n                    startTimeout();\n                  });\n              });\n            }\n            else {\n              startTimeout();\n            }\n          }, 250);\n        }\n\n        startTimeout();\n\n        $scope.$on('$destroy', function() {\n          clearTimeout(resizeTimeoutId);\n        });\n      }\n    };\n  }]);\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   *  @ngdoc overview\n   *  @name ui.grid.cellNav\n   *\n   *  @description\n\n      #ui.grid.cellNav\n\n      <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n\n      This module provides auto-resizing functionality to UI-Grid.\n   */\n  var module = angular.module('ui.grid.cellNav', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.cellNav.constant:uiGridCellNavConstants\n   *\n   *  @description constants available in cellNav\n   */\n  module.constant('uiGridCellNavConstants', {\n    FEATURE_NAME: 'gridCellNav',\n    CELL_NAV_EVENT: 'cellNav',\n    direction: {LEFT: 0, RIGHT: 1, UP: 2, DOWN: 3, PG_UP: 4, PG_DOWN: 5},\n    EVENT_TYPE: {\n      KEYDOWN: 0,\n      CLICK: 1,\n      CLEAR: 2\n    }\n  });\n\n\n  module.factory('uiGridCellNavFactory', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', 'GridRowColumn', '$q',\n    function (gridUtil, uiGridConstants, uiGridCellNavConstants, GridRowColumn, $q) {\n      /**\n       *  @ngdoc object\n       *  @name ui.grid.cellNav.object:CellNav\n       *  @description returns a CellNav prototype function\n       *  @param {object} rowContainer container for rows\n       *  @param {object} colContainer parent column container\n       *  @param {object} leftColContainer column container to the left of parent\n       *  @param {object} rightColContainer column container to the right of parent\n       */\n      var UiGridCellNav = function UiGridCellNav(rowContainer, colContainer, leftColContainer, rightColContainer) {\n        this.rows = rowContainer.visibleRowCache;\n        this.columns = colContainer.visibleColumnCache;\n        this.leftColumns = leftColContainer ? leftColContainer.visibleColumnCache : [];\n        this.rightColumns = rightColContainer ? rightColContainer.visibleColumnCache : [];\n        this.bodyContainer = rowContainer;\n      };\n\n      /** returns focusable columns of all containers */\n      UiGridCellNav.prototype.getFocusableCols = function () {\n        var allColumns = this.leftColumns.concat(this.columns, this.rightColumns);\n\n        return allColumns.filter(function (col) {\n          return col.colDef.allowCellFocus;\n        });\n      };\n\n      /**\n       *  @ngdoc object\n       *  @name ui.grid.cellNav.api:GridRow\n       *\n       *  @description GridRow settings for cellNav feature, these are available to be\n       *  set only internally (for example, by other features)\n       */\n\n      /**\n       *  @ngdoc object\n       *  @name allowCellFocus\n       *  @propertyOf  ui.grid.cellNav.api:GridRow\n       *  @description Enable focus on a cell within this row.  If set to false then no cells\n       *  in this row can be focused - group header rows as an example would set this to false.\n       *  <br/>Defaults to true\n       */\n      /** returns focusable rows */\n      UiGridCellNav.prototype.getFocusableRows = function () {\n        return this.rows.filter(function(row) {\n          return row.allowCellFocus !== false;\n        });\n      };\n\n      UiGridCellNav.prototype.getNextRowCol = function (direction, curRow, curCol) {\n        switch (direction) {\n          case uiGridCellNavConstants.direction.LEFT:\n            return this.getRowColLeft(curRow, curCol);\n          case uiGridCellNavConstants.direction.RIGHT:\n            return this.getRowColRight(curRow, curCol);\n          case uiGridCellNavConstants.direction.UP:\n            return this.getRowColUp(curRow, curCol);\n          case uiGridCellNavConstants.direction.DOWN:\n            return this.getRowColDown(curRow, curCol);\n          case uiGridCellNavConstants.direction.PG_UP:\n            return this.getRowColPageUp(curRow, curCol);\n          case uiGridCellNavConstants.direction.PG_DOWN:\n            return this.getRowColPageDown(curRow, curCol);\n        }\n\n      };\n\n      UiGridCellNav.prototype.initializeSelection = function () {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        if (focusableCols.length === 0 || focusableRows.length === 0) {\n          return null;\n        }\n\n        var curRowIndex = 0;\n        var curColIndex = 0;\n        return new GridRowColumn(focusableRows[0], focusableCols[0]); //return same row\n      };\n\n      UiGridCellNav.prototype.getRowColLeft = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 1\n        if (curColIndex === -1) {\n          curColIndex = 1;\n        }\n\n        var nextColIndex = curColIndex === 0 ? focusableCols.length - 1 : curColIndex - 1;\n\n        //get column to left\n        if (nextColIndex > curColIndex) {\n          // On the first row\n          // if (curRowIndex === 0 && curColIndex === 0) {\n          //   return null;\n          // }\n          if (curRowIndex === 0) {\n            return new GridRowColumn(curRow, focusableCols[nextColIndex]); //return same row\n          }\n          else {\n            //up one row and far right column\n            return new GridRowColumn(focusableRows[curRowIndex - 1], focusableCols[nextColIndex]);\n          }\n        }\n        else {\n          return new GridRowColumn(curRow, focusableCols[nextColIndex]);\n        }\n      };\n\n\n\n      UiGridCellNav.prototype.getRowColRight = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 0\n        if (curColIndex === -1) {\n          curColIndex = 0;\n        }\n        var nextColIndex = curColIndex === focusableCols.length - 1 ? 0 : curColIndex + 1;\n\n        if (nextColIndex < curColIndex) {\n          if (curRowIndex === focusableRows.length - 1) {\n            return new GridRowColumn(curRow, focusableCols[nextColIndex]); //return same row\n          }\n          else {\n            //down one row and far left column\n            return new GridRowColumn(focusableRows[curRowIndex + 1], focusableCols[nextColIndex]);\n          }\n        }\n        else {\n          return new GridRowColumn(curRow, focusableCols[nextColIndex]);\n        }\n      };\n\n      UiGridCellNav.prototype.getRowColDown = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 0\n        if (curColIndex === -1) {\n          curColIndex = 0;\n        }\n\n        if (curRowIndex === focusableRows.length - 1) {\n          return new GridRowColumn(curRow, focusableCols[curColIndex]); //return same row\n        }\n        else {\n          //down one row\n          return new GridRowColumn(focusableRows[curRowIndex + 1], focusableCols[curColIndex]);\n        }\n      };\n\n      UiGridCellNav.prototype.getRowColPageDown = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 0\n        if (curColIndex === -1) {\n          curColIndex = 0;\n        }\n\n        var pageSize = this.bodyContainer.minRowsToRender();\n        if (curRowIndex >= focusableRows.length - pageSize) {\n          return new GridRowColumn(focusableRows[focusableRows.length - 1], focusableCols[curColIndex]); //return last row\n        }\n        else {\n          //down one page\n          return new GridRowColumn(focusableRows[curRowIndex + pageSize], focusableCols[curColIndex]);\n        }\n      };\n\n      UiGridCellNav.prototype.getRowColUp = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 0\n        if (curColIndex === -1) {\n          curColIndex = 0;\n        }\n\n        if (curRowIndex === 0) {\n          return new GridRowColumn(curRow, focusableCols[curColIndex]); //return same row\n        }\n        else {\n          //up one row\n          return new GridRowColumn(focusableRows[curRowIndex - 1], focusableCols[curColIndex]);\n        }\n      };\n\n      UiGridCellNav.prototype.getRowColPageUp = function (curRow, curCol) {\n        var focusableCols = this.getFocusableCols();\n        var focusableRows = this.getFocusableRows();\n        var curColIndex = focusableCols.indexOf(curCol);\n        var curRowIndex = focusableRows.indexOf(curRow);\n\n        //could not find column in focusable Columns so set it to 0\n        if (curColIndex === -1) {\n          curColIndex = 0;\n        }\n\n        var pageSize = this.bodyContainer.minRowsToRender();\n        if (curRowIndex - pageSize < 0) {\n          return new GridRowColumn(focusableRows[0], focusableCols[curColIndex]); //return first row\n        }\n        else {\n          //up one page\n          return new GridRowColumn(focusableRows[curRowIndex - pageSize], focusableCols[curColIndex]);\n        }\n      };\n      return UiGridCellNav;\n    }]);\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.cellNav.service:uiGridCellNavService\n   *\n   *  @description Services for cell navigation features. If you don't like the key maps we use,\n   *  or the direction cells navigation, override with a service decorator (see angular docs)\n   */\n  module.service('uiGridCellNavService', ['gridUtil', 'uiGridConstants', 'uiGridCellNavConstants', '$q', 'uiGridCellNavFactory', 'GridRowColumn', 'ScrollEvent',\n    function (gridUtil, uiGridConstants, uiGridCellNavConstants, $q, UiGridCellNav, GridRowColumn, ScrollEvent) {\n\n      var service = {\n\n        initializeGrid: function (grid) {\n          grid.registerColumnBuilder(service.cellNavColumnBuilder);\n\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.cellNav:Grid.cellNav\n           * @description cellNav properties added to grid class\n           */\n          grid.cellNav = {};\n          grid.cellNav.lastRowCol = null;\n          grid.cellNav.focusedCells = [];\n\n          service.defaultGridOptions(grid.options);\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.cellNav.api:PublicApi\n           *\n           *  @description Public Api for cellNav feature\n           */\n          var publicApi = {\n            events: {\n              cellNav: {\n                /**\n                 * @ngdoc event\n                 * @name navigate\n                 * @eventOf  ui.grid.cellNav.api:PublicApi\n                 * @description raised when the active cell is changed\n                 * <pre>\n                 *      gridApi.cellNav.on.navigate(scope,function(newRowcol, oldRowCol){})\n                 * </pre>\n                 * @param {object} newRowCol new position\n                 * @param {object} oldRowCol old position\n                 */\n                navigate: function (newRowCol, oldRowCol) {},\n                /**\n                 * @ngdoc event\n                 * @name viewPortKeyDown\n                 * @eventOf  ui.grid.cellNav.api:PublicApi\n                 * @description  is raised when the viewPort receives a keyDown event. Cells never get focus in uiGrid\n                 * due to the difficulties of setting focus on a cell that is not visible in the viewport.  Use this\n                 * event whenever you need a keydown event on a cell\n                 * <br/>\n                 * @param {object} event keydown event\n                 * @param {object} rowCol current rowCol position\n                 */\n                viewPortKeyDown: function (event, rowCol) {},\n\n                /**\n                 * @ngdoc event\n                 * @name viewPortKeyPress\n                 * @eventOf  ui.grid.cellNav.api:PublicApi\n                 * @description  is raised when the viewPort receives a keyPress event. Cells never get focus in uiGrid\n                 * due to the difficulties of setting focus on a cell that is not visible in the viewport.  Use this\n                 * event whenever you need a keypress event on a cell\n                 * <br/>\n                 * @param {object} event keypress event\n                 * @param {object} rowCol current rowCol position\n                 */\n                viewPortKeyPress: function (event, rowCol) {}\n              }\n            },\n            methods: {\n              cellNav: {\n                /**\n                 * @ngdoc function\n                 * @name scrollToFocus\n                 * @methodOf  ui.grid.cellNav.api:PublicApi\n                 * @description brings the specified row and column into view, and sets focus\n                 * to that cell\n                 * @param {object} rowEntity gridOptions.data[] array instance to make visible and set focus\n                 * @param {object} colDef to make visible and set focus\n                 * @returns {promise} a promise that is resolved after any scrolling is finished\n                 */\n                scrollToFocus: function (rowEntity, colDef) {\n                  return service.scrollToFocus(grid, rowEntity, colDef);\n                },\n\n                /**\n                 * @ngdoc function\n                 * @name getFocusedCell\n                 * @methodOf  ui.grid.cellNav.api:PublicApi\n                 * @description returns the current (or last if Grid does not have focus) focused row and column\n                 * <br> value is null if no selection has occurred\n                 */\n                getFocusedCell: function () {\n                  return grid.cellNav.lastRowCol;\n                },\n\n                /**\n                 * @ngdoc function\n                 * @name getCurrentSelection\n                 * @methodOf  ui.grid.cellNav.api:PublicApi\n                 * @description returns an array containing the current selection\n                 * <br> array is empty if no selection has occurred\n                 */\n                getCurrentSelection: function () {\n                  return grid.cellNav.focusedCells;\n                },\n\n                /**\n                 * @ngdoc function\n                 * @name rowColSelectIndex\n                 * @methodOf  ui.grid.cellNav.api:PublicApi\n                 * @description returns the index in the order in which the GridRowColumn was selected, returns -1 if the GridRowColumn\n                 * isn't selected\n                 * @param {object} rowCol the rowCol to evaluate\n                 */\n                rowColSelectIndex: function (rowCol) {\n                  //return gridUtil.arrayContainsObjectWithProperty(grid.cellNav.focusedCells, 'col.uid', rowCol.col.uid) &&\n                  var index = -1;\n                  for (var i = 0; i < grid.cellNav.focusedCells.length; i++) {\n                    if (grid.cellNav.focusedCells[i].col.uid === rowCol.col.uid &&\n                      grid.cellNav.focusedCells[i].row.uid === rowCol.row.uid) {\n                      index = i;\n                      break;\n                    }\n                  }\n                  return index;\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.cellNav.api:GridOptions\n           *\n           *  @description GridOptions for cellNav feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name modifierKeysToMultiSelectCells\n           *  @propertyOf  ui.grid.cellNav.api:GridOptions\n           *  @description Enable multiple cell selection only when using the ctrlKey or shiftKey.\n           *  <br/>Defaults to false\n           */\n          gridOptions.modifierKeysToMultiSelectCells = gridOptions.modifierKeysToMultiSelectCells === true;\n\n        },\n\n        /**\n         * @ngdoc service\n         * @name decorateRenderContainers\n         * @methodOf ui.grid.cellNav.service:uiGridCellNavService\n         * @description  decorates grid renderContainers with cellNav functions\n         */\n        decorateRenderContainers: function (grid) {\n\n          var rightContainer = grid.hasRightContainer() ? grid.renderContainers.right : null;\n          var leftContainer = grid.hasLeftContainer() ? grid.renderContainers.left : null;\n\n          if (leftContainer !== null) {\n            grid.renderContainers.left.cellNav = new UiGridCellNav(grid.renderContainers.body, leftContainer, rightContainer, grid.renderContainers.body);\n          }\n          if (rightContainer !== null) {\n            grid.renderContainers.right.cellNav = new UiGridCellNav(grid.renderContainers.body, rightContainer, grid.renderContainers.body, leftContainer);\n          }\n\n          grid.renderContainers.body.cellNav = new UiGridCellNav(grid.renderContainers.body, grid.renderContainers.body, leftContainer, rightContainer);\n        },\n\n        /**\n         * @ngdoc service\n         * @name getDirection\n         * @methodOf ui.grid.cellNav.service:uiGridCellNavService\n         * @description  determines which direction to for a given keyDown event\n         * @returns {uiGridCellNavConstants.direction} direction\n         */\n        getDirection: function (evt) {\n          if (evt.keyCode === uiGridConstants.keymap.LEFT ||\n            (evt.keyCode === uiGridConstants.keymap.TAB && evt.shiftKey)) {\n            return uiGridCellNavConstants.direction.LEFT;\n          }\n          if (evt.keyCode === uiGridConstants.keymap.RIGHT ||\n            evt.keyCode === uiGridConstants.keymap.TAB) {\n            return uiGridCellNavConstants.direction.RIGHT;\n          }\n\n          if (evt.keyCode === uiGridConstants.keymap.UP ||\n            (evt.keyCode === uiGridConstants.keymap.ENTER && evt.shiftKey) ) {\n            return uiGridCellNavConstants.direction.UP;\n          }\n\n          if (evt.keyCode === uiGridConstants.keymap.PG_UP){\n            return uiGridCellNavConstants.direction.PG_UP;\n          }\n\n          if (evt.keyCode === uiGridConstants.keymap.DOWN ||\n            evt.keyCode === uiGridConstants.keymap.ENTER && !(evt.ctrlKey || evt.altKey)) {\n            return uiGridCellNavConstants.direction.DOWN;\n          }\n\n          if (evt.keyCode === uiGridConstants.keymap.PG_DOWN){\n            return uiGridCellNavConstants.direction.PG_DOWN;\n          }\n\n          return null;\n        },\n\n        /**\n         * @ngdoc service\n         * @name cellNavColumnBuilder\n         * @methodOf ui.grid.cellNav.service:uiGridCellNavService\n         * @description columnBuilder function that adds cell navigation properties to grid column\n         * @returns {promise} promise that will load any needed templates when resolved\n         */\n        cellNavColumnBuilder: function (colDef, col, gridOptions) {\n          var promises = [];\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.cellNav.api:ColumnDef\n           *\n           *  @description Column Definitions for cellNav feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name allowCellFocus\n           *  @propertyOf  ui.grid.cellNav.api:ColumnDef\n           *  @description Enable focus on a cell within this column.\n           *  <br/>Defaults to true\n           */\n          colDef.allowCellFocus = colDef.allowCellFocus === undefined ? true : colDef.allowCellFocus;\n\n          return $q.all(promises);\n        },\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.cellNav.service:uiGridCellNavService\n         * @name scrollToFocus\n         * @description Scroll the grid such that the specified\n         * row and column is in view, and set focus to the cell in that row and column\n         * @param {Grid} grid the grid you'd like to act upon, usually available\n         * from gridApi.grid\n         * @param {object} rowEntity gridOptions.data[] array instance to make visible and set focus to\n         * @param {object} colDef to make visible and set focus to\n         * @returns {promise} a promise that is resolved after any scrolling is finished\n         */\n        scrollToFocus: function (grid, rowEntity, colDef) {\n          var gridRow = null, gridCol = null;\n\n          if (typeof(rowEntity) !== 'undefined' && rowEntity !== null) {\n            gridRow = grid.getRow(rowEntity);\n          }\n\n          if (typeof(colDef) !== 'undefined' && colDef !== null) {\n            gridCol = grid.getColumn(colDef.name ? colDef.name : colDef.field);\n          }\n          return grid.api.core.scrollToIfNecessary(gridRow, gridCol).then(function () {\n            var rowCol = { row: gridRow, col: gridCol };\n\n            // Broadcast the navigation\n            if (gridRow !== null && gridCol !== null) {\n              grid.cellNav.broadcastCellNav(rowCol);\n            }\n          });\n\n\n\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.cellNav.service:uiGridCellNavService\n         * @name getLeftWidth\n         * @description Get the current drawn width of the columns in the\n         * grid up to the numbered column, and add an apportionment for the\n         * column that we're on.  So if we are on column 0, we want to scroll\n         * 0% (i.e. exclude this column from calc).  If we're on the last column\n         * we want to scroll to 100% (i.e. include this column in the calc). So\n         * we include (thisColIndex / totalNumberCols) % of this column width\n         * @param {Grid} grid the grid you'd like to act upon, usually available\n         * from gridApi.grid\n         * @param {gridCol} upToCol the column to total up to and including\n         */\n        getLeftWidth: function (grid, upToCol) {\n          var width = 0;\n\n          if (!upToCol) {\n            return width;\n          }\n\n          var lastIndex = grid.renderContainers.body.visibleColumnCache.indexOf( upToCol );\n\n          // total column widths up-to but not including the passed in column\n          grid.renderContainers.body.visibleColumnCache.forEach( function( col, index ) {\n            if ( index < lastIndex ){\n              width += col.drawnWidth;\n            }\n          });\n\n          // pro-rata the final column based on % of total columns.\n          var percentage = lastIndex === 0 ? 0 : (lastIndex + 1) / grid.renderContainers.body.visibleColumnCache.length;\n          width += upToCol.drawnWidth * percentage;\n\n          return width;\n        }\n      };\n\n      return service;\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.cellNav.directive:uiCellNav\n   *  @element div\n   *  @restrict EA\n   *\n   *  @description Adds cell navigation features to the grid columns\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.cellNav']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name'},\n        {name: 'title'}\n      ];\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-cellnav></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn', '$timeout', '$compile',\n    function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants, GridRowColumn, $timeout, $compile) {\n      return {\n        replace: true,\n        priority: -150,\n        require: '^uiGrid',\n        scope: false,\n        controller: function () {},\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n              var _scope = $scope;\n\n              var grid = uiGridCtrl.grid;\n              uiGridCellNavService.initializeGrid(grid);\n\n              uiGridCtrl.cellNav = {};\n\n              //Ensure that the object has all of the methods we expect it to\n              uiGridCtrl.cellNav.makeRowCol = function (obj) {\n                if (!(obj instanceof GridRowColumn)) {\n                  obj = new GridRowColumn(obj.row, obj.col);\n                }\n                return obj;\n              };\n\n              uiGridCtrl.cellNav.getActiveCell = function () {\n                var elms = $elm[0].getElementsByClassName('ui-grid-cell-focus');\n                if (elms.length > 0){\n                  return elms[0];\n                }\n\n                return undefined;\n              };\n\n              uiGridCtrl.cellNav.broadcastCellNav = grid.cellNav.broadcastCellNav = function (newRowCol, modifierDown, originEvt) {\n                modifierDown = !(modifierDown === undefined || !modifierDown);\n\n                newRowCol = uiGridCtrl.cellNav.makeRowCol(newRowCol);\n\n                uiGridCtrl.cellNav.broadcastFocus(newRowCol, modifierDown, originEvt);\n                _scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT, newRowCol, modifierDown, originEvt);\n              };\n\n              uiGridCtrl.cellNav.clearFocus = grid.cellNav.clearFocus = function () {\n                grid.cellNav.focusedCells = [];\n                _scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT);\n              };\n\n              uiGridCtrl.cellNav.broadcastFocus = function (rowCol, modifierDown, originEvt) {\n                modifierDown = !(modifierDown === undefined || !modifierDown);\n\n                rowCol = uiGridCtrl.cellNav.makeRowCol(rowCol);\n\n                var row = rowCol.row,\n                  col = rowCol.col;\n\n                var rowColSelectIndex = uiGridCtrl.grid.api.cellNav.rowColSelectIndex(rowCol);\n\n                if (grid.cellNav.lastRowCol === null || rowColSelectIndex === -1) {\n                  var newRowCol = new GridRowColumn(row, col);\n\n                  if (grid.cellNav.lastRowCol === null || grid.cellNav.lastRowCol.row !== newRowCol.row || grid.cellNav.lastRowCol.col !== newRowCol.col){\n                    grid.api.cellNav.raise.navigate(newRowCol, grid.cellNav.lastRowCol);\n                    grid.cellNav.lastRowCol = newRowCol;  \n                  }\n                  if (uiGridCtrl.grid.options.modifierKeysToMultiSelectCells && modifierDown) {\n                    grid.cellNav.focusedCells.push(rowCol);\n                  } else {\n                    grid.cellNav.focusedCells = [rowCol];\n                  }\n                } else if (grid.options.modifierKeysToMultiSelectCells && modifierDown &&\n                  rowColSelectIndex >= 0) {\n\n                  grid.cellNav.focusedCells.splice(rowColSelectIndex, 1);\n                }\n              };\n\n              uiGridCtrl.cellNav.handleKeyDown = function (evt) {\n                var direction = uiGridCellNavService.getDirection(evt);\n                if (direction === null) {\n                  return null;\n                }\n\n                var containerId = 'body';\n                if (evt.uiGridTargetRenderContainerId) {\n                  containerId = evt.uiGridTargetRenderContainerId;\n                }\n\n                // Get the last-focused row+col combo\n                var lastRowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();\n                if (lastRowCol) {\n                  // Figure out which new row+combo we're navigating to\n                  var rowCol = uiGridCtrl.grid.renderContainers[containerId].cellNav.getNextRowCol(direction, lastRowCol.row, lastRowCol.col);\n                  var focusableCols = uiGridCtrl.grid.renderContainers[containerId].cellNav.getFocusableCols();\n                  var rowColSelectIndex = uiGridCtrl.grid.api.cellNav.rowColSelectIndex(rowCol);\n                  // Shift+tab on top-left cell should exit cellnav on render container\n                  if (\n                    // Navigating left\n                    direction === uiGridCellNavConstants.direction.LEFT &&\n                    // New col is last col (i.e. wrap around)\n                    rowCol.col === focusableCols[focusableCols.length - 1] &&\n                    // Staying on same row, which means we're at first row\n                    rowCol.row === lastRowCol.row &&\n                    evt.keyCode === uiGridConstants.keymap.TAB &&\n                    evt.shiftKey\n                  ) {\n                    grid.cellNav.focusedCells.splice(rowColSelectIndex, 1);\n                    uiGridCtrl.cellNav.clearFocus();\n                    return true;\n                  }\n                  // Tab on bottom-right cell should exit cellnav on render container\n                  else if (\n                    direction === uiGridCellNavConstants.direction.RIGHT &&\n                    // New col is first col (i.e. wrap around)\n                    rowCol.col === focusableCols[0] &&\n                    // Staying on same row, which means we're at first row\n                    rowCol.row === lastRowCol.row &&\n                    evt.keyCode === uiGridConstants.keymap.TAB &&\n                    !evt.shiftKey\n                  ) {\n                    grid.cellNav.focusedCells.splice(rowColSelectIndex, 1);\n                    uiGridCtrl.cellNav.clearFocus();\n                    return true;\n                  }\n\n                  // Scroll to the new cell, if it's not completely visible within the render container's viewport\n                  grid.scrollToIfNecessary(rowCol.row, rowCol.col).then(function () {\n                    uiGridCtrl.cellNav.broadcastCellNav(rowCol);\n                  });\n\n\n                  evt.stopPropagation();\n                  evt.preventDefault();\n\n                  return false;\n                }\n              };\n            },\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n              var _scope = $scope;\n              var grid = uiGridCtrl.grid;\n\n              function addAriaLiveRegion(){\n                // Thanks to google docs for the inspiration behind how to do this\n                // XXX: Why is this entire mess nessasary?\n                // Because browsers take a lot of coercing to get them to read out live regions\n                //http://www.paciellogroup.com/blog/2012/06/html5-accessibility-chops-aria-rolealert-browser-support/\n                var ariaNotifierDomElt = '<div ' +\n                                           'id=\"' + grid.id +'-aria-speakable\" ' +\n                                           'class=\"ui-grid-a11y-ariascreenreader-speakable ui-grid-offscreen\" ' +\n                                           'aria-live=\"assertive\" ' +\n                                           'role=\"region\" ' +\n                                           'aria-atomic=\"true\" ' +\n                                           'aria-hidden=\"false\" ' +\n                                           'aria-relevant=\"additions\" ' +\n                                           '>' +\n                                           '&nbsp;' +\n                                         '</div>';\n\n                var ariaNotifier = $compile(ariaNotifierDomElt)($scope);\n                $elm.prepend(ariaNotifier);\n                $scope.$on(uiGridCellNavConstants.CELL_NAV_EVENT, function (evt, rowCol, modifierDown, originEvt) {\n                  /*\n                   * If the cell nav event was because of a focus event then we don't want to\n                   * change the notifier text.\n                   * Reasoning: Voice Over fires a focus events when moving arround the grid.\n                   * If the screen reader is handing the grid nav properly then we don't need to\n                   * use the alert to notify the user of the movement.\n                   * In all other cases we do want a notification event.\n                   */\n                  if (originEvt && originEvt.type === 'focus'){return;}\n\n                  function setNotifyText(text){\n                    if (text === ariaNotifier.text()){return;}\n                    ariaNotifier[0].style.clip = 'rect(0px,0px,0px,0px)';\n                    /*\n                     * This is how google docs handles clearing the div. Seems to work better than setting the text of the div to ''\n                     */\n                    ariaNotifier[0].innerHTML = \"\";\n                    ariaNotifier[0].style.visibility = 'hidden';\n                    ariaNotifier[0].style.visibility = 'visible';\n                    if (text !== ''){\n                      ariaNotifier[0].style.clip = 'auto';\n                      /*\n                       * The space after the text is something that google docs does.\n                       */\n                      ariaNotifier[0].appendChild(document.createTextNode(text + \" \"));\n                      ariaNotifier[0].style.visibility = 'hidden';\n                      ariaNotifier[0].style.visibility = 'visible';\n                    }\n                  }\n\n                  var values = [];\n                  var currentSelection = grid.api.cellNav.getCurrentSelection();\n                  for (var i = 0; i < currentSelection.length; i++) {\n                    values.push(currentSelection[i].getIntersectionValueFiltered());\n                  }\n                  var cellText = values.toString();\n                  setNotifyText(cellText);\n\n                });\n              }\n              addAriaLiveRegion();\n            }\n          };\n        }\n      };\n    }]);\n\n  module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile','uiGridCellNavConstants',\n    function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile, uiGridCellNavConstants) {\n      return {\n        replace: true,\n        priority: -99999, //this needs to run very last\n        require: ['^uiGrid', 'uiGridRenderContainer', '?^uiGridCellnav'],\n        scope: false,\n        compile: function () {\n          return {\n            post: function ($scope, $elm, $attrs, controllers) {\n              var uiGridCtrl = controllers[0],\n                 renderContainerCtrl = controllers[1],\n                 uiGridCellnavCtrl = controllers[2];\n\n              // Skip attaching cell-nav specific logic if the directive is not attached above us\n              if (!uiGridCtrl.grid.api.cellNav) { return; }\n\n              var containerId = renderContainerCtrl.containerId;\n\n              var grid = uiGridCtrl.grid;\n\n              //run each time a render container is created\n              uiGridCellNavService.decorateRenderContainers(grid);\n\n              // focusser only created for body\n              if (containerId !== 'body') {\n                return;\n              }\n\n\n\n              if (uiGridCtrl.grid.options.modifierKeysToMultiSelectCells){\n                $elm.attr('aria-multiselectable', true);\n              } else {\n                $elm.attr('aria-multiselectable', false);\n              }\n\n              //add an element with no dimensions that can be used to set focus and capture keystrokes\n              var focuser = $compile('<div class=\"ui-grid-focuser\" role=\"region\" aria-live=\"assertive\" aria-atomic=\"false\" tabindex=\"0\" aria-controls=\"' + grid.id +'-aria-speakable '+ grid.id + '-grid-container' +'\" aria-owns=\"' + grid.id + '-grid-container' + '\"></div>')($scope);\n              $elm.append(focuser);\n\n              focuser.on('focus', function (evt) {\n                evt.uiGridTargetRenderContainerId = containerId;\n                var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();\n                if (rowCol === null) {\n                  rowCol = uiGridCtrl.grid.renderContainers[containerId].cellNav.getNextRowCol(uiGridCellNavConstants.direction.DOWN, null, null);\n                  if (rowCol.row && rowCol.col) {\n                    uiGridCtrl.cellNav.broadcastCellNav(rowCol);\n                  }\n                }\n              });\n\n              uiGridCellnavCtrl.setAriaActivedescendant = function(id){\n                $elm.attr('aria-activedescendant', id);\n              };\n\n              uiGridCellnavCtrl.removeAriaActivedescendant = function(id){\n                if ($elm.attr('aria-activedescendant') === id){\n                  $elm.attr('aria-activedescendant', '');\n                }\n              };\n\n\n              uiGridCtrl.focus = function () {\n                gridUtil.focus.byElement(focuser[0]);\n                //allow for first time grid focus\n              };\n\n              var viewPortKeyDownWasRaisedForRowCol = null;\n              // Bind to keydown events in the render container\n              focuser.on('keydown', function (evt) {\n                evt.uiGridTargetRenderContainerId = containerId;\n                var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();\n                var result = uiGridCtrl.cellNav.handleKeyDown(evt);\n                if (result === null) {\n                  uiGridCtrl.grid.api.cellNav.raise.viewPortKeyDown(evt, rowCol);\n                  viewPortKeyDownWasRaisedForRowCol = rowCol;\n                }\n              });\n              //Bind to keypress events in the render container\n              //keypress events are needed by edit function so the key press\n              //that initiated an edit is not lost\n              //must fire the event in a timeout so the editor can\n              //initialize and subscribe to the event on another event loop\n              focuser.on('keypress', function (evt) {\n                if (viewPortKeyDownWasRaisedForRowCol) {\n                  $timeout(function () {\n                    uiGridCtrl.grid.api.cellNav.raise.viewPortKeyPress(evt, viewPortKeyDownWasRaisedForRowCol);\n                  },4);\n\n                  viewPortKeyDownWasRaisedForRowCol = null;\n                }\n              });\n\n              $scope.$on('$destroy', function(){\n                //Remove all event handlers associated with this focuser.\n                focuser.off();\n              });\n\n            }\n          };\n        }\n      };\n    }]);\n\n  module.directive('uiGridViewport', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants','$log','$compile',\n    function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants, $log, $compile) {\n      return {\n        replace: true,\n        priority: -99999, //this needs to run very last\n        require: ['^uiGrid', '^uiGridRenderContainer', '?^uiGridCellnav'],\n        scope: false,\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            },\n            post: function ($scope, $elm, $attrs, controllers) {\n              var uiGridCtrl = controllers[0],\n                renderContainerCtrl = controllers[1];\n\n              // Skip attaching cell-nav specific logic if the directive is not attached above us\n              if (!uiGridCtrl.grid.api.cellNav) { return; }\n\n              var containerId = renderContainerCtrl.containerId;\n              //no need to process for other containers\n              if (containerId !== 'body') {\n                return;\n              }\n\n              var grid = uiGridCtrl.grid;\n\n              grid.api.core.on.scrollBegin($scope, function (args) {\n\n                // Skip if there's no currently-focused cell\n                var lastRowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();\n                if (lastRowCol === null) {\n                  return;\n                }\n\n                //if not in my container, move on\n                //todo: worry about horiz scroll\n                if (!renderContainerCtrl.colContainer.containsColumn(lastRowCol.col)) {\n                  return;\n                }\n\n                uiGridCtrl.cellNav.clearFocus();\n\n              });\n\n              grid.api.core.on.scrollEnd($scope, function (args) {\n                // Skip if there's no currently-focused cell\n                var lastRowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell();\n                if (lastRowCol === null) {\n                  return;\n                }\n\n                //if not in my container, move on\n                //todo: worry about horiz scroll\n                if (!renderContainerCtrl.colContainer.containsColumn(lastRowCol.col)) {\n                  return;\n                }\n\n                uiGridCtrl.cellNav.broadcastCellNav(lastRowCol);\n\n              });\n\n              grid.api.cellNav.on.navigate($scope, function () {\n                //focus again because it can be lost\n                 uiGridCtrl.focus();\n              });\n\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.cellNav.directive:uiGridCell\n   *  @element div\n   *  @restrict A\n   *  @description Stacks on top of ui.grid.uiGridCell to provide cell navigation\n   */\n  module.directive('uiGridCell', ['$timeout', '$document', 'uiGridCellNavService', 'gridUtil', 'uiGridCellNavConstants', 'uiGridConstants', 'GridRowColumn',\n    function ($timeout, $document, uiGridCellNavService, gridUtil, uiGridCellNavConstants, uiGridConstants, GridRowColumn) {\n      return {\n        priority: -150, // run after default uiGridCell directive and ui.grid.edit uiGridCell\n        restrict: 'A',\n        require: ['^uiGrid', '?^uiGridCellnav'],\n        scope: false,\n        link: function ($scope, $elm, $attrs, controllers) {\n          var uiGridCtrl = controllers[0],\n              uiGridCellnavCtrl = controllers[1];\n          // Skip attaching cell-nav specific logic if the directive is not attached above us\n          if (!uiGridCtrl.grid.api.cellNav) { return; }\n\n          if (!$scope.col.colDef.allowCellFocus) {\n            return;\n          }\n\n          //Convinience local variables\n          var grid = uiGridCtrl.grid;\n          $scope.focused = false;\n\n          // Make this cell focusable but only with javascript/a mouse click\n          $elm.attr('tabindex', -1);\n\n          // When a cell is clicked, broadcast a cellNav event saying that this row+col combo is now focused\n          $elm.find('div').on('click', function (evt) {\n            uiGridCtrl.cellNav.broadcastCellNav(new GridRowColumn($scope.row, $scope.col), evt.ctrlKey || evt.metaKey, evt);\n\n            evt.stopPropagation();\n            $scope.$apply();\n          });\n\n\n          /*\n           * XXX Hack for screen readers.\n           * This allows the grid to focus using only the screen reader cursor.\n           * Since the focus event doesn't include key press information we can't use it\n           * as our primary source of the event.\n           */\n          $elm.on('mousedown', preventMouseDown);\n\n          //turn on and off for edit events\n          if (uiGridCtrl.grid.api.edit) {\n            uiGridCtrl.grid.api.edit.on.beginCellEdit($scope, function () {\n              $elm.off('mousedown', preventMouseDown);\n            });\n\n            uiGridCtrl.grid.api.edit.on.afterCellEdit($scope, function () {\n              $elm.on('mousedown', preventMouseDown);\n            });\n\n            uiGridCtrl.grid.api.edit.on.cancelCellEdit($scope, function () {\n              $elm.on('mousedown', preventMouseDown);\n            });\n          }\n\n          function preventMouseDown(evt) {\n            //Prevents the foucus event from firing if the click event is already going to fire.\n            //If both events fire it will cause bouncing behavior.\n            evt.preventDefault();\n          }\n\n          //You can only focus on elements with a tabindex value\n          $elm.on('focus', function (evt) {\n            uiGridCtrl.cellNav.broadcastCellNav(new GridRowColumn($scope.row, $scope.col), false, evt);\n            evt.stopPropagation();\n            $scope.$apply();\n          });\n\n          // This event is fired for all cells.  If the cell matches, then focus is set\n          $scope.$on(uiGridCellNavConstants.CELL_NAV_EVENT, function (evt, rowCol, modifierDown) {\n            var isFocused = grid.cellNav.focusedCells.some(function(focusedRowCol, index){\n              return (focusedRowCol.row === $scope.row && focusedRowCol.col === $scope.col);\n            });\n            if (isFocused){\n              setFocused();\n            } else {\n              clearFocus();\n            }\n          });\n\n          function setFocused() {\n            if (!$scope.focused){\n              var div = $elm.find('div');\n              div.addClass('ui-grid-cell-focus');\n              $elm.attr('aria-selected', true);\n              uiGridCellnavCtrl.setAriaActivedescendant($elm.attr('id'));\n              $scope.focused = true;\n            }\n          }\n\n          function clearFocus() {\n            if ($scope.focused){\n              var div = $elm.find('div');\n              div.removeClass('ui-grid-cell-focus');\n              $elm.attr('aria-selected', false);\n              uiGridCellnavCtrl.removeAriaActivedescendant($elm.attr('id'));\n              $scope.focused = false;\n            }\n          }\n\n          $scope.$on('$destroy', function () {\n            //.off withouth paramaters removes all handlers\n            $elm.find('div').off();\n            $elm.off();\n          });\n        }\n      };\n    }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.edit\n   * @description\n   *\n   * # ui.grid.edit\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module provides cell editing capability to ui.grid. The goal was to emulate keying data in a spreadsheet via\n   * a keyboard.\n   * <br/>\n   * <br/>\n   * To really get the full spreadsheet-like data entry, the ui.grid.cellNav module should be used. This will allow the\n   * user to key data and then tab, arrow, or enter to the cells beside or below.\n   *\n   * <div doc-module-components=\"ui.grid.edit\"></div>\n   */\n\n  var module = angular.module('ui.grid.edit', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.edit.constant:uiGridEditConstants\n   *\n   *  @description constants available in edit module\n   */\n  module.constant('uiGridEditConstants', {\n    EDITABLE_CELL_TEMPLATE: /EDITABLE_CELL_TEMPLATE/g,\n    //must be lowercase because template bulder converts to lower\n    EDITABLE_CELL_DIRECTIVE: /editable_cell_directive/g,\n    events: {\n      BEGIN_CELL_EDIT: 'uiGridEventBeginCellEdit',\n      END_CELL_EDIT: 'uiGridEventEndCellEdit',\n      CANCEL_CELL_EDIT: 'uiGridEventCancelCellEdit'\n    }\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.edit.service:uiGridEditService\n   *\n   *  @description Services for editing features\n   */\n  module.service('uiGridEditService', ['$q', 'uiGridConstants', 'gridUtil',\n    function ($q, uiGridConstants, gridUtil) {\n\n      var service = {\n\n        initializeGrid: function (grid) {\n\n          service.defaultGridOptions(grid.options);\n\n          grid.registerColumnBuilder(service.editColumnBuilder);\n          grid.edit = {};\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.edit.api:PublicApi\n           *\n           *  @description Public Api for edit feature\n           */\n          var publicApi = {\n            events: {\n              edit: {\n                /**\n                 * @ngdoc event\n                 * @name afterCellEdit\n                 * @eventOf  ui.grid.edit.api:PublicApi\n                 * @description raised when cell editing is complete\n                 * <pre>\n                 *      gridApi.edit.on.afterCellEdit(scope,function(rowEntity, colDef){})\n                 * </pre>\n                 * @param {object} rowEntity the options.data element that was edited\n                 * @param {object} colDef the column that was edited\n                 * @param {object} newValue new value\n                 * @param {object} oldValue old value\n                 */\n                afterCellEdit: function (rowEntity, colDef, newValue, oldValue) {\n                },\n                /**\n                 * @ngdoc event\n                 * @name beginCellEdit\n                 * @eventOf  ui.grid.edit.api:PublicApi\n                 * @description raised when cell editing starts on a cell\n                 * <pre>\n                 *      gridApi.edit.on.beginCellEdit(scope,function(rowEntity, colDef){})\n                 * </pre>\n                 * @param {object} rowEntity the options.data element that was edited\n                 * @param {object} colDef the column that was edited\n                 * @param {object} triggerEvent the event that triggered the edit.  Useful to prevent losing keystrokes on some\n                 *                 complex editors\n                 */\n                beginCellEdit: function (rowEntity, colDef, triggerEvent) {\n                },\n                /**\n                 * @ngdoc event\n                 * @name cancelCellEdit\n                 * @eventOf  ui.grid.edit.api:PublicApi\n                 * @description raised when cell editing is cancelled on a cell\n                 * <pre>\n                 *      gridApi.edit.on.cancelCellEdit(scope,function(rowEntity, colDef){})\n                 * </pre>\n                 * @param {object} rowEntity the options.data element that was edited\n                 * @param {object} colDef the column that was edited\n                 */\n                cancelCellEdit: function (rowEntity, colDef) {\n                }\n              }\n            },\n            methods: {\n              edit: { }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n          //grid.api.registerMethodsFromObject(publicApi.methods);\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.edit.api:GridOptions\n           *\n           *  @description Options for configuring the edit feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableCellEdit\n           *  @propertyOf  ui.grid.edit.api:GridOptions\n           *  @description If defined, sets the default value for the editable flag on each individual colDefs\n           *  if their individual enableCellEdit configuration is not defined. Defaults to undefined.\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name cellEditableCondition\n           *  @propertyOf  ui.grid.edit.api:GridOptions\n           *  @description If specified, either a value or function to be used by all columns before editing.\n           *  If falsy, then editing of cell is not allowed.\n           *  @example\n           *  <pre>\n           *  function($scope){\n           *    //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed\n           *    return true;\n           *  }\n           *  </pre>\n           */\n          gridOptions.cellEditableCondition = gridOptions.cellEditableCondition === undefined ? true : gridOptions.cellEditableCondition;\n\n          /**\n           *  @ngdoc object\n           *  @name editableCellTemplate\n           *  @propertyOf  ui.grid.edit.api:GridOptions\n           *  @description If specified, cellTemplate to use as the editor for all columns.\n           *  <br/> defaults to 'ui-grid/cellTextEditor'\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableCellEditOnFocus\n           *  @propertyOf  ui.grid.edit.api:GridOptions\n           *  @description If true, then editor is invoked as soon as cell receives focus. Default false.\n           *  <br/>_requires cellNav feature and the edit feature to be enabled_\n           */\n            //enableCellEditOnFocus can only be used if cellnav module is used\n          gridOptions.enableCellEditOnFocus = gridOptions.enableCellEditOnFocus === undefined ? false : gridOptions.enableCellEditOnFocus;\n        },\n\n        /**\n         * @ngdoc service\n         * @name editColumnBuilder\n         * @methodOf ui.grid.edit.service:uiGridEditService\n         * @description columnBuilder function that adds edit properties to grid column\n         * @returns {promise} promise that will load any needed templates when resolved\n         */\n        editColumnBuilder: function (colDef, col, gridOptions) {\n\n          var promises = [];\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.edit.api:ColumnDef\n           *\n           *  @description Column Definition for edit feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableCellEdit\n           *  @propertyOf  ui.grid.edit.api:ColumnDef\n           *  @description enable editing on column\n           */\n          colDef.enableCellEdit = colDef.enableCellEdit === undefined ? (gridOptions.enableCellEdit === undefined ?\n            (colDef.type !== 'object') : gridOptions.enableCellEdit) : colDef.enableCellEdit;\n\n          /**\n           *  @ngdoc object\n           *  @name cellEditableCondition\n           *  @propertyOf  ui.grid.edit.api:ColumnDef\n           *  @description If specified, either a value or function evaluated before editing cell.  If falsy, then editing of cell is not allowed.\n           *  @example\n           *  <pre>\n           *  function($scope){\n           *    //use $scope.row.entity and $scope.col.colDef to determine if editing is allowed\n           *    return true;\n           *  }\n           *  </pre>\n           */\n          colDef.cellEditableCondition = colDef.cellEditableCondition === undefined ? gridOptions.cellEditableCondition :  colDef.cellEditableCondition;\n\n          /**\n           *  @ngdoc object\n           *  @name editableCellTemplate\n           *  @propertyOf  ui.grid.edit.api:ColumnDef\n           *  @description cell template to be used when editing this column. Can be Url or text template\n           *  <br/>Defaults to gridOptions.editableCellTemplate\n           */\n          if (colDef.enableCellEdit) {\n            colDef.editableCellTemplate = colDef.editableCellTemplate || gridOptions.editableCellTemplate || 'ui-grid/cellEditor';\n\n            promises.push(gridUtil.getTemplate(colDef.editableCellTemplate)\n              .then(\n              function (template) {\n                col.editableCellTemplate = template;\n              },\n              function (res) {\n                // Todo handle response error here?\n                throw new Error(\"Couldn't fetch/use colDef.editableCellTemplate '\" + colDef.editableCellTemplate + \"'\");\n              }));\n          }\n\n          /**\n           *  @ngdoc object\n           *  @name enableCellEditOnFocus\n           *  @propertyOf  ui.grid.edit.api:ColumnDef\n           *  @requires ui.grid.cellNav\n           *  @description If true, then editor is invoked as soon as cell receives focus. Default false.\n           *  <br>_requires both the cellNav feature and the edit feature to be enabled_\n           */\n            //enableCellEditOnFocus can only be used if cellnav module is used\n          colDef.enableCellEditOnFocus = colDef.enableCellEditOnFocus === undefined ? gridOptions.enableCellEditOnFocus : colDef.enableCellEditOnFocus;\n\n\n          /**\n           *  @ngdoc string\n           *  @name editModelField\n           *  @propertyOf  ui.grid.edit.api:ColumnDef\n           *  @description a bindable string value that is used when binding to edit controls instead of colDef.field\n           *  <br/> example: You have a complex property on and object like state:{abbrev:'MS',name:'Mississippi'}.  The\n           *  grid should display state.name in the cell and sort/filter based on the state.name property but the editor\n           *  requires the full state object.\n           *  <br/>colDef.field = 'state.name'\n           *  <br/>colDef.editModelField = 'state'\n           */\n          //colDef.editModelField\n\n          return $q.all(promises);\n        },\n\n        /**\n         * @ngdoc service\n         * @name isStartEditKey\n         * @methodOf ui.grid.edit.service:uiGridEditService\n         * @description  Determines if a keypress should start editing.  Decorate this service to override with your\n         * own key events.  See service decorator in angular docs.\n         * @param {Event} evt keydown event\n         * @returns {boolean} true if an edit should start\n         */\n        isStartEditKey: function (evt) {\n          if (evt.metaKey ||\n              evt.keyCode === uiGridConstants.keymap.ESC ||\n              evt.keyCode === uiGridConstants.keymap.SHIFT ||\n              evt.keyCode === uiGridConstants.keymap.CTRL ||\n              evt.keyCode === uiGridConstants.keymap.ALT ||\n              evt.keyCode === uiGridConstants.keymap.WIN ||\n              evt.keyCode === uiGridConstants.keymap.CAPSLOCK ||\n\n             evt.keyCode === uiGridConstants.keymap.LEFT ||\n            (evt.keyCode === uiGridConstants.keymap.TAB && evt.shiftKey) ||\n\n            evt.keyCode === uiGridConstants.keymap.RIGHT ||\n            evt.keyCode === uiGridConstants.keymap.TAB ||\n\n            evt.keyCode === uiGridConstants.keymap.UP ||\n            (evt.keyCode === uiGridConstants.keymap.ENTER && evt.shiftKey) ||\n\n            evt.keyCode === uiGridConstants.keymap.DOWN ||\n            evt.keyCode === uiGridConstants.keymap.ENTER) {\n            return false;\n\n          }\n          return true;\n        }\n\n\n      };\n\n      return service;\n\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridEdit\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds editing features to the ui-grid directive.\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.edit']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name', enableCellEdit: true},\n        {name: 'title', enableCellEdit: true}\n      ];\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-edit></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridEdit', ['gridUtil', 'uiGridEditService', function (gridUtil, uiGridEditService) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            uiGridEditService.initializeGrid(uiGridCtrl.grid);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridRenderContainer\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds keydown listeners to renderContainer element so we can capture when to begin edits\n   *\n   */\n  module.directive('uiGridViewport', [ 'uiGridEditConstants',\n    function ( uiGridEditConstants) {\n      return {\n        replace: true,\n        priority: -99998, //run before cellNav\n        require: ['^uiGrid', '^uiGridRenderContainer'],\n        scope: false,\n        compile: function () {\n          return {\n            post: function ($scope, $elm, $attrs, controllers) {\n              var uiGridCtrl = controllers[0];\n\n              // Skip attaching if edit and cellNav is not enabled\n              if (!uiGridCtrl.grid.api.edit || !uiGridCtrl.grid.api.cellNav) { return; }\n\n              var containerId =  controllers[1].containerId;\n              //no need to process for other containers\n              if (containerId !== 'body') {\n                return;\n              }\n\n              //refocus on the grid\n              $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {\n                uiGridCtrl.focus();\n              });\n              $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () {\n                uiGridCtrl.focus();\n              });\n\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridCell\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Stacks on top of ui.grid.uiGridCell to provide in-line editing capabilities to the cell\n   *  Editing Actions.\n   *\n   *  Binds edit start events to the uiGridCell element.  When the events fire, the gridCell element is appended\n   *  with the columnDef.editableCellTemplate element ('cellEditor.html' by default).\n   *\n   *  The editableCellTemplate should respond to uiGridEditConstants.events.BEGIN\\_CELL\\_EDIT angular event\n   *  and do the initial steps needed to edit the cell (setfocus on input element, etc).\n   *\n   *  When the editableCellTemplate recognizes that the editing is ended (blur event, Enter key, etc.)\n   *  it should emit the uiGridEditConstants.events.END\\_CELL\\_EDIT event.\n   *\n   *  If editableCellTemplate recognizes that the editing has been cancelled (esc key)\n   *  it should emit the uiGridEditConstants.events.CANCEL\\_CELL\\_EDIT event.  The original value\n   *  will be set back on the model by the uiGridCell directive.\n   *\n   *  Events that invoke editing:\n   *    - dblclick\n   *    - F2 keydown (when using cell selection)\n   *\n   *  Events that end editing:\n   *    - Dependent on the specific editableCellTemplate\n   *    - Standards should be blur and enter keydown\n   *\n   *  Events that cancel editing:\n   *    - Dependent on the specific editableCellTemplate\n   *    - Standards should be Esc keydown\n   *\n   *  Grid Events that end editing:\n   *    - uiGridConstants.events.GRID_SCROLL\n   *\n   */\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.edit.api:GridRow\n   *\n   *  @description GridRow options for edit feature, these are available to be\n   *  set internally only, by other features\n   */\n\n  /**\n   *  @ngdoc object\n   *  @name enableCellEdit\n   *  @propertyOf  ui.grid.edit.api:GridRow\n   *  @description enable editing on row, grouping for example might disable editing on group header rows\n   */\n\n  module.directive('uiGridCell',\n    ['$compile', '$injector', '$timeout', 'uiGridConstants', 'uiGridEditConstants', 'gridUtil', '$parse', 'uiGridEditService', '$rootScope', '$q',\n      function ($compile, $injector, $timeout, uiGridConstants, uiGridEditConstants, gridUtil, $parse, uiGridEditService, $rootScope, $q) {\n        var touchstartTimeout = 500;\n        if ($injector.has('uiGridCellNavService')) {\n          var uiGridCellNavService = $injector.get('uiGridCellNavService');\n        }\n\n        return {\n          priority: -100, // run after default uiGridCell directive\n          restrict: 'A',\n          scope: false,\n          require: '?^uiGrid',\n          link: function ($scope, $elm, $attrs, uiGridCtrl) {\n            var html;\n            var origCellValue;\n            var inEdit = false;\n            var cellModel;\n            var cancelTouchstartTimeout;\n\n            var editCellScope;\n\n            if (!$scope.col.colDef.enableCellEdit) {\n              return;\n            }\n\n            var cellNavNavigateDereg = function() {};\n            var viewPortKeyDownDereg = function() {};\n\n\n            var setEditable = function() {\n              if ($scope.col.colDef.enableCellEdit && $scope.row.enableCellEdit !== false) {\n                if (!$scope.beginEditEventsWired) { //prevent multiple attachments\n                  registerBeginEditEvents();\n                }\n              } else {\n                if ($scope.beginEditEventsWired) {\n                  cancelBeginEditEvents();\n                }\n              }\n            };\n\n            setEditable();\n\n            var rowWatchDereg = $scope.$watch('row', function (n, o) {\n              if (n !== o) {\n                setEditable();\n              }\n            });\n\n\n            $scope.$on( '$destroy', rowWatchDereg );\n\n            function registerBeginEditEvents() {\n              $elm.on('dblclick', beginEdit);\n\n              // Add touchstart handling. If the users starts a touch and it doesn't end after X milliseconds, then start the edit\n              $elm.on('touchstart', touchStart);\n\n              if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {\n\n                viewPortKeyDownDereg = uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) {\n                  if (rowCol === null) {\n                    return;\n                  }\n\n                  if (rowCol.row === $scope.row && rowCol.col === $scope.col && !$scope.col.colDef.enableCellEditOnFocus) {\n                    //important to do this before scrollToIfNecessary\n                    beginEditKeyDown(evt);\n                  }\n                });\n\n                cellNavNavigateDereg = uiGridCtrl.grid.api.cellNav.on.navigate($scope, function (newRowCol, oldRowCol) {\n                  if ($scope.col.colDef.enableCellEditOnFocus) {\n                    // Don't begin edit if the cell hasn't changed\n                    if ((!oldRowCol || newRowCol.row !== oldRowCol.row || newRowCol.col !== oldRowCol.col) &&\n                      newRowCol.row === $scope.row && newRowCol.col === $scope.col) {\n                      $timeout(function () {\n                        beginEdit();\n                      });\n                    }\n                  }\n                });\n              }\n\n              $scope.beginEditEventsWired = true;\n\n            }\n\n            function touchStart(event) {\n              // jQuery masks events\n              if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) {\n                event = event.originalEvent;\n              }\n\n              // Bind touchend handler\n              $elm.on('touchend', touchEnd);\n\n              // Start a timeout\n              cancelTouchstartTimeout = $timeout(function() { }, touchstartTimeout);\n\n              // Timeout's done! Start the edit\n              cancelTouchstartTimeout.then(function () {\n                // Use setTimeout to start the edit because beginEdit expects to be outside of $digest\n                setTimeout(beginEdit, 0);\n\n                // Undbind the touchend handler, we don't need it anymore\n                $elm.off('touchend', touchEnd);\n              });\n            }\n\n            // Cancel any touchstart timeout\n            function touchEnd(event) {\n              $timeout.cancel(cancelTouchstartTimeout);\n              $elm.off('touchend', touchEnd);\n            }\n\n            function cancelBeginEditEvents() {\n              $elm.off('dblclick', beginEdit);\n              $elm.off('keydown', beginEditKeyDown);\n              $elm.off('touchstart', touchStart);\n              cellNavNavigateDereg();\n              viewPortKeyDownDereg();\n              $scope.beginEditEventsWired = false;\n            }\n\n            function beginEditKeyDown(evt) {\n              if (uiGridEditService.isStartEditKey(evt)) {\n                beginEdit(evt);\n              }\n            }\n\n            function shouldEdit(col, row) {\n              return !row.isSaving &&\n                ( angular.isFunction(col.colDef.cellEditableCondition) ?\n                    col.colDef.cellEditableCondition($scope) :\n                    col.colDef.cellEditableCondition );\n            }\n\n\n            function beginEdit(triggerEvent) {\n              //we need to scroll the cell into focus before invoking the editor\n              $scope.grid.api.core.scrollToIfNecessary($scope.row, $scope.col)\n                .then(function () {\n                  beginEditAfterScroll(triggerEvent);\n                });\n            }\n\n            /**\n             *  @ngdoc property\n             *  @name editDropdownOptionsArray\n             *  @propertyOf ui.grid.edit.api:ColumnDef\n             *  @description an array of values in the format\n             *  [ {id: xxx, value: xxx} ], which is populated\n             *  into the edit dropdown\n             *\n             */\n            /**\n             *  @ngdoc property\n             *  @name editDropdownIdLabel\n             *  @propertyOf ui.grid.edit.api:ColumnDef\n             *  @description the label for the \"id\" field\n             *  in the editDropdownOptionsArray.  Defaults\n             *  to 'id'\n             *  @example\n             *  <pre>\n             *    $scope.gridOptions = {\n             *      columnDefs: [\n             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',\n             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],\n             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }\n             *      ],\n             *  </pre>\n             *\n             */\n            /**\n             *  @ngdoc property\n             *  @name editDropdownRowEntityOptionsArrayPath\n             *  @propertyOf ui.grid.edit.api:ColumnDef\n             *  @description a path to a property on row.entity containing an\n             *  array of values in the format\n             *  [ {id: xxx, value: xxx} ], which will be used to populate\n             *  the edit dropdown.  This can be used when the dropdown values are dependent on\n             *  the backing row entity.\n             *  If this property is set then editDropdownOptionsArray will be ignored.\n             *  @example\n             *  <pre>\n             *    $scope.gridOptions = {\n             *      columnDefs: [\n             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',\n             *          editDropdownRowEntityOptionsArrayPath: 'foo.bars[0].baz',\n             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }\n             *      ],\n             *  </pre>\n             *\n             */\n            /**\n             *  @ngdoc service\n             *  @name editDropdownOptionsFunction\n             *  @methodOf ui.grid.edit.api:ColumnDef\n             *  @description a function returning an array of values in the format\n             *  [ {id: xxx, value: xxx} ], which will be used to populate\n             *  the edit dropdown.  This can be used when the dropdown values are dependent on\n             *  the backing row entity with some kind of algorithm.\n             *  If this property is set then both editDropdownOptionsArray and \n             *  editDropdownRowEntityOptionsArrayPath will be ignored.\n             *  @param {object} rowEntity the options.data element that the returned array refers to\n             *  @param {object} colDef the column that implements this dropdown\n             *  @returns {object} an array of values in the format\n             *  [ {id: xxx, value: xxx} ] used to populate the edit dropdown\n             *  @example\n             *  <pre>\n             *    $scope.gridOptions = {\n             *      columnDefs: [\n             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',\n             *          editDropdownOptionsFunction: function(rowEntity, colDef) {\n             *            if (rowEntity.foo === 'bar') {\n             *              return [{id: 'bar1', value: 'BAR 1'},\n             *                      {id: 'bar2', value: 'BAR 2'},\n             *                      {id: 'bar3', value: 'BAR 3'}];\n             *            } else {\n             *              return [{id: 'foo1', value: 'FOO 1'},\n             *                      {id: 'foo2', value: 'FOO 2'}];\n             *            }\n             *          },\n             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }\n             *      ],\n             *  </pre>\n             *\n             */\n            /**\n             *  @ngdoc property\n             *  @name editDropdownValueLabel\n             *  @propertyOf ui.grid.edit.api:ColumnDef\n             *  @description the label for the \"value\" field\n             *  in the editDropdownOptionsArray.  Defaults\n             *  to 'value'\n             *  @example\n             *  <pre>\n             *    $scope.gridOptions = {\n             *      columnDefs: [\n             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',\n             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],\n             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }\n             *      ],\n             *  </pre>\n             *\n             */\n            /**\n             *  @ngdoc property\n             *  @name editDropdownFilter\n             *  @propertyOf ui.grid.edit.api:ColumnDef\n             *  @description A filter that you would like to apply to the values in the options list\n             *  of the dropdown.  For example if you were using angular-translate you might set this\n             *  to `'translate'`\n             *  @example\n             *  <pre>\n             *    $scope.gridOptions = {\n             *      columnDefs: [\n             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',\n             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],\n             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status', editDropdownFilter: 'translate' }\n             *      ],\n             *  </pre>\n             *\n             */\n            function beginEditAfterScroll(triggerEvent) {\n              // If we are already editing, then just skip this so we don't try editing twice...\n              if (inEdit) {\n                return;\n              }\n\n              if (!shouldEdit($scope.col, $scope.row)) {\n                return;\n              }\n\n\n              cellModel = $parse($scope.row.getQualifiedColField($scope.col));\n              //get original value from the cell\n              origCellValue = cellModel($scope);\n\n              html = $scope.col.editableCellTemplate;\n\n              if ($scope.col.colDef.editModelField) {\n                html = html.replace(uiGridConstants.MODEL_COL_FIELD, gridUtil.preEval('row.entity.' + $scope.col.colDef.editModelField));\n              }\n              else {\n                html = html.replace(uiGridConstants.MODEL_COL_FIELD, $scope.row.getQualifiedColField($scope.col));\n              }\n\n              html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');\n\n              var optionFilter = $scope.col.colDef.editDropdownFilter ? '|' + $scope.col.colDef.editDropdownFilter : '';\n              html = html.replace(uiGridConstants.CUSTOM_FILTERS, optionFilter);\n\n              var inputType = 'text';\n              switch ($scope.col.colDef.type){\n                case 'boolean':\n                  inputType = 'checkbox';\n                  break;\n                case 'number':\n                  inputType = 'number';\n                  break;\n                case 'date':\n                  inputType = 'date';\n                  break;\n              }\n              html = html.replace('INPUT_TYPE', inputType);\n\n              // In order to fill dropdown options we use:\n              // - A function/promise or\n              // - An array inside of row entity if no function exists or\n              // - A single array for the whole column if none of the previous exists.\n              var editDropdownOptionsFunction = $scope.col.colDef.editDropdownOptionsFunction;\n              if (editDropdownOptionsFunction) {\n                $q.when(editDropdownOptionsFunction($scope.row.entity, $scope.col.colDef))\n                        .then(function(result) {\n                  $scope.editDropdownOptionsArray = result;\n                });\n              } else {\n                var editDropdownRowEntityOptionsArrayPath = $scope.col.colDef.editDropdownRowEntityOptionsArrayPath;\n                if (editDropdownRowEntityOptionsArrayPath) {\n                  $scope.editDropdownOptionsArray =  resolveObjectFromPath($scope.row.entity, editDropdownRowEntityOptionsArrayPath);\n                }\n                else {\n                  $scope.editDropdownOptionsArray = $scope.col.colDef.editDropdownOptionsArray;\n                }\n              }\n              $scope.editDropdownIdLabel = $scope.col.colDef.editDropdownIdLabel ? $scope.col.colDef.editDropdownIdLabel : 'id';\n              $scope.editDropdownValueLabel = $scope.col.colDef.editDropdownValueLabel ? $scope.col.colDef.editDropdownValueLabel : 'value';\n\n              var cellElement;\n              var createEditor = function(){\n                inEdit = true;\n                cancelBeginEditEvents();\n                var cellElement = angular.element(html);\n                $elm.append(cellElement);\n                editCellScope = $scope.$new();\n                $compile(cellElement)(editCellScope);\n                var gridCellContentsEl = angular.element($elm.children()[0]);\n                gridCellContentsEl.addClass('ui-grid-cell-contents-hidden');\n              };\n              if (!$rootScope.$$phase) {\n                $scope.$apply(createEditor);\n              } else {\n                createEditor();\n              }\n\n              //stop editing when grid is scrolled\n              var deregOnGridScroll = $scope.col.grid.api.core.on.scrollBegin($scope, function () {\n                if ($scope.grid.disableScrolling) {\n                  return;\n                }\n                endEdit();\n                $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);\n                deregOnGridScroll();\n                deregOnEndCellEdit();\n                deregOnCancelCellEdit();\n              });\n\n              //end editing\n              var deregOnEndCellEdit = $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () {\n                endEdit();\n                $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue);\n                deregOnEndCellEdit();\n                deregOnGridScroll();\n                deregOnCancelCellEdit();\n              });\n\n              //cancel editing\n              var deregOnCancelCellEdit = $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () {\n                cancelEdit();\n                deregOnCancelCellEdit();\n                deregOnGridScroll();\n                deregOnEndCellEdit();\n              });\n\n              $scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT, triggerEvent);\n              $timeout(function () {\n                //execute in a timeout to give any complex editor templates a cycle to completely render\n                $scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef, triggerEvent);\n              });\n            }\n\n            function endEdit() {\n              $scope.grid.disableScrolling = false;\n              if (!inEdit) {\n                return;\n              }\n\n              //sometimes the events can't keep up with the keyboard and grid focus is lost, so always focus\n              //back to grid here. The focus call needs to be before the $destroy and removal of the control,\n              //otherwise ng-model-options of UpdateOn: 'blur' will not work.\n              if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {\n                uiGridCtrl.focus();\n              }\n\n              var gridCellContentsEl = angular.element($elm.children()[0]);\n              //remove edit element\n              editCellScope.$destroy();\n              angular.element($elm.children()[1]).remove();\n              gridCellContentsEl.removeClass('ui-grid-cell-contents-hidden');\n              inEdit = false;\n              registerBeginEditEvents();\n              $scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.EDIT );\n            }\n\n            function cancelEdit() {\n              $scope.grid.disableScrolling = false;\n              if (!inEdit) {\n                return;\n              }\n              cellModel.assign($scope, origCellValue);\n              $scope.$apply();\n\n              $scope.grid.api.edit.raise.cancelCellEdit($scope.row.entity, $scope.col.colDef);\n              endEdit();\n            }\n\n            // resolves a string path against the given object\n            // shamelessly borrowed from\n            // http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key\n            function resolveObjectFromPath(object, path) {\n              path = path.replace(/\\[(\\w+)\\]/g, '.$1'); // convert indexes to properties\n              path = path.replace(/^\\./, '');           // strip a leading dot\n              var a = path.split('.');\n              while (a.length) {\n                  var n = a.shift();\n                  if (n in object) {\n                      object = object[n];\n                  } else {\n                      return;\n                  }\n              }\n              return object;\n            }\n\n          }\n        };\n      }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridEditor\n   *  @element div\n   *  @restrict A\n   *\n   *  @description input editor directive for editable fields.\n   *  Provides EndEdit and CancelEdit events\n   *\n   *  Events that end editing:\n   *     blur and enter keydown\n   *\n   *  Events that cancel editing:\n   *    - Esc keydown\n   *\n   */\n  module.directive('uiGridEditor',\n    ['gridUtil', 'uiGridConstants', 'uiGridEditConstants','$timeout', 'uiGridEditService',\n      function (gridUtil, uiGridConstants, uiGridEditConstants, $timeout, uiGridEditService) {\n        return {\n          scope: true,\n          require: ['?^uiGrid', '?^uiGridRenderContainer', 'ngModel'],\n          compile: function () {\n            return {\n              pre: function ($scope, $elm, $attrs) {\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n                var uiGridCtrl, renderContainerCtrl, ngModel;\n                if (controllers[0]) { uiGridCtrl = controllers[0]; }\n                if (controllers[1]) { renderContainerCtrl = controllers[1]; }\n                if (controllers[2]) { ngModel = controllers[2]; }\n\n                //set focus at start of edit\n                $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function (evt,triggerEvent) {\n                  $timeout(function () {\n                    $elm[0].focus();\n                    //only select text if it is not being replaced below in the cellNav viewPortKeyPress\n                    if ($elm[0].select && $scope.col.colDef.enableCellEditOnFocus || !(uiGridCtrl && uiGridCtrl.grid.api.cellNav)) {\n                      $elm[0].select();\n                    }\n                    else {\n                      //some browsers (Chrome) stupidly, imo, support the w3 standard that number, email, ...\n                      //fields should not allow setSelectionRange.  We ignore the error for those browsers\n                      //https://www.w3.org/Bugs/Public/show_bug.cgi?id=24796\n                      try {\n                        $elm[0].setSelectionRange($elm[0].value.length, $elm[0].value.length);\n                      }\n                      catch (ex) {\n                        //ignore\n                      }\n                    }\n                  });\n\n                  //set the keystroke that started the edit event\n                  //we must do this because the BeginEdit is done in a different event loop than the intitial\n                  //keydown event\n                  //fire this event for the keypress that is received\n                  if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {\n                    var viewPortKeyDownUnregister = uiGridCtrl.grid.api.cellNav.on.viewPortKeyPress($scope, function (evt, rowCol) {\n                      if (uiGridEditService.isStartEditKey(evt)) {\n                        ngModel.$setViewValue(String.fromCharCode( typeof evt.which === 'number' ? evt.which : evt.keyCode), evt);\n                        ngModel.$render();\n                      }\n                      viewPortKeyDownUnregister();\n                    });\n                  }\n\n                  $elm.on('blur', function (evt) {\n                    $scope.stopEdit(evt);\n                  });\n                });\n\n\n                $scope.deepEdit = false;\n\n                $scope.stopEdit = function (evt) {\n                  if ($scope.inputForm && !$scope.inputForm.$valid) {\n                    evt.stopPropagation();\n                    $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);\n                  }\n                  else {\n                    $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);\n                  }\n                  $scope.deepEdit = false;\n                };\n\n\n                $elm.on('click', function (evt) {\n                  if ($elm[0].type !== 'checkbox') {\n                    $scope.deepEdit = true;\n                    $timeout(function () {\n                      $scope.grid.disableScrolling = true;\n                    });\n                  }\n                });\n\n                $elm.on('keydown', function (evt) {\n                  switch (evt.keyCode) {\n                    case uiGridConstants.keymap.ESC:\n                      evt.stopPropagation();\n                      $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);\n                      break;\n                  }\n\n                  if ($scope.deepEdit &&\n                    (evt.keyCode === uiGridConstants.keymap.LEFT ||\n                     evt.keyCode === uiGridConstants.keymap.RIGHT ||\n                     evt.keyCode === uiGridConstants.keymap.UP ||\n                     evt.keyCode === uiGridConstants.keymap.DOWN)) {\n                    evt.stopPropagation();\n                  }\n                  // Pass the keydown event off to the cellNav service, if it exists\n                  else if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {\n                    evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId;\n                    if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) {\n                      $scope.stopEdit(evt);\n                    }\n                  }\n                  else {\n                    //handle enter and tab for editing not using cellNav\n                    switch (evt.keyCode) {\n                      case uiGridConstants.keymap.ENTER: // Enter (Leave Field)\n                      case uiGridConstants.keymap.TAB:\n                        evt.stopPropagation();\n                        evt.preventDefault();\n                        $scope.stopEdit(evt);\n                        break;\n                    }\n                  }\n\n                  return true;\n                });\n              }\n            };\n          }\n        };\n      }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:input\n   *  @element input\n   *  @restrict E\n   *\n   *  @description directive to provide binding between input[date] value and ng-model for angular 1.2\n   *  It is similar to input[date] directive of angular 1.3\n   *\n   *  Supported date format for input is 'yyyy-MM-dd'\n   *  The directive will set the $valid property of input element and the enclosing form to false if\n   *  model is invalid date or value of input is entered wrong.\n   *\n   */\n    module.directive('uiGridEditor', ['$filter', function ($filter) {\n      function parseDateString(dateString) {\n        if (typeof(dateString) === 'undefined' || dateString === '') {\n          return null;\n        }\n        var parts = dateString.split('-');\n        if (parts.length !== 3) {\n          return null;\n        }\n        var year = parseInt(parts[0], 10);\n        var month = parseInt(parts[1], 10);\n        var day = parseInt(parts[2], 10);\n\n        if (month < 1 || year < 1 || day < 1) {\n          return null;\n        }\n        return new Date(year, (month - 1), day);\n      }\n      return {\n        priority: -100, // run after default uiGridEditor directive\n        require: '?ngModel',\n        link: function (scope, element, attrs, ngModel) {\n\n          if (angular.version.minor === 2 && attrs.type && attrs.type === 'date' && ngModel) {\n\n            ngModel.$formatters.push(function (modelValue) {\n              ngModel.$setValidity(null,(!modelValue || !isNaN(modelValue.getTime())));\n              return $filter('date')(modelValue, 'yyyy-MM-dd');\n            });\n\n            ngModel.$parsers.push(function (viewValue) {\n              if (viewValue && viewValue.length > 0) {\n                var dateValue = parseDateString(viewValue);\n                ngModel.$setValidity(null, (dateValue && !isNaN(dateValue.getTime())));\n                return dateValue;\n              }\n              else {\n                ngModel.$setValidity(null, true);\n                return null;\n              }\n            });\n          }\n        }\n      };\n    }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridEditDropdown\n   *  @element div\n   *  @restrict A\n   *\n   *  @description dropdown editor for editable fields.\n   *  Provides EndEdit and CancelEdit events\n   *\n   *  Events that end editing:\n   *     blur and enter keydown, and any left/right nav\n   *\n   *  Events that cancel editing:\n   *    - Esc keydown\n   *\n   */\n  module.directive('uiGridEditDropdown',\n    ['uiGridConstants', 'uiGridEditConstants',\n      function (uiGridConstants, uiGridEditConstants) {\n        return {\n          require: ['?^uiGrid', '?^uiGridRenderContainer'],\n          scope: true,\n          compile: function () {\n            return {\n              pre: function ($scope, $elm, $attrs) {\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n                var uiGridCtrl = controllers[0];\n                var renderContainerCtrl = controllers[1];\n\n                //set focus at start of edit\n                $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {\n                  $elm[0].focus();\n                  $elm[0].style.width = ($elm[0].parentElement.offsetWidth - 1) + 'px';\n                  $elm.on('blur', function (evt) {\n                    $scope.stopEdit(evt);\n                  });\n                });\n\n\n                $scope.stopEdit = function (evt) {\n                  // no need to validate a dropdown - invalid values shouldn't be\n                  // available in the list\n                  $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);\n                };\n\n                $elm.on('keydown', function (evt) {\n                  switch (evt.keyCode) {\n                    case uiGridConstants.keymap.ESC:\n                      evt.stopPropagation();\n                      $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);\n                      break;\n                  }\n                  if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {\n                    evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId;\n                    if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) {\n                      $scope.stopEdit(evt);\n                    }\n                  }\n                  else {\n                    //handle enter and tab for editing not using cellNav\n                    switch (evt.keyCode) {\n                      case uiGridConstants.keymap.ENTER: // Enter (Leave Field)\n                      case uiGridConstants.keymap.TAB:\n                        evt.stopPropagation();\n                        evt.preventDefault();\n                        $scope.stopEdit(evt);\n                        break;\n                    }\n                  }\n                  return true;\n                });\n              }\n            };\n          }\n        };\n      }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.edit.directive:uiGridEditFileChooser\n   *  @element div\n   *  @restrict A\n   *\n   *  @description input editor directive for editable fields.\n   *  Provides EndEdit and CancelEdit events\n   *\n   *  Events that end editing:\n   *     blur and enter keydown\n   *\n   *  Events that cancel editing:\n   *    - Esc keydown\n   *\n   */\n  module.directive('uiGridEditFileChooser',\n    ['gridUtil', 'uiGridConstants', 'uiGridEditConstants','$timeout',\n      function (gridUtil, uiGridConstants, uiGridEditConstants, $timeout) {\n        return {\n          scope: true,\n          require: ['?^uiGrid', '?^uiGridRenderContainer'],\n          compile: function () {\n            return {\n              pre: function ($scope, $elm, $attrs) {\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n                var uiGridCtrl, renderContainerCtrl;\n                if (controllers[0]) { uiGridCtrl = controllers[0]; }\n                if (controllers[1]) { renderContainerCtrl = controllers[1]; }\n                var grid = uiGridCtrl.grid;\n\n                var handleFileSelect = function( event ){\n                  var target = event.srcElement || event.target;\n\n                  if (target && target.files && target.files.length > 0) {\n                    /**\n                     *  @ngdoc property\n                     *  @name editFileChooserCallback\n                     *  @propertyOf  ui.grid.edit.api:ColumnDef\n                     *  @description A function that should be called when any files have been chosen\n                     *  by the user.  You should use this to process the files appropriately for your\n                     *  application.\n                     *\n                     *  It passes the gridCol, the gridRow (from which you can get gridRow.entity),\n                     *  and the files.  The files are in the format as returned from the file chooser,\n                     *  an array of files, with each having useful information such as:\n                     *  - `files[0].lastModifiedDate`\n                     *  - `files[0].name`\n                     *  - `files[0].size`  (appears to be in bytes)\n                     *  - `files[0].type`  (MIME type by the looks)\n                     *\n                     *  Typically you would do something with these files - most commonly you would\n                     *  use the filename or read the file itself in.  The example function does both.\n                     *\n                     *  @example\n                     *  <pre>\n                     *  editFileChooserCallBack: function(gridRow, gridCol, files ){\n                     *    // ignore all but the first file, it can only choose one anyway\n                     *    // set the filename into this column\n                     *    gridRow.entity.filename = file[0].name;\n                     *\n                     *    // read the file and set it into a hidden column, which we may do stuff with later\n                     *    var setFile = function(fileContent){\n                     *      gridRow.entity.file = fileContent.currentTarget.result;\n                     *    };\n                     *    var reader = new FileReader();\n                     *    reader.onload = setFile;\n                     *    reader.readAsText( files[0] );\n                     *  }\n                     *  </pre>\n                     */\n                    if ( typeof($scope.col.colDef.editFileChooserCallback) === 'function' ) {\n                      $scope.col.colDef.editFileChooserCallback($scope.row, $scope.col, target.files);\n                    } else {\n                      gridUtil.logError('You need to set colDef.editFileChooserCallback to use the file chooser');\n                    }\n\n                    target.form.reset();\n                    $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);\n                  } else {\n                    $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);\n                  }\n                };\n\n                $elm[0].addEventListener('change', handleFileSelect, false);  // TODO: why the false on the end?  Google\n\n                $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {\n                  $elm[0].focus();\n                  $elm[0].select();\n\n                  $elm.on('blur', function (evt) {\n                    $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);\n                  });\n                });\n              }\n            };\n          }\n        };\n      }]);\n\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.expandable\n   * @description\n   *\n   * # ui.grid.expandable\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Alpha</strong> This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>\n   *\n   * This module provides the ability to create subgrids with the ability to expand a row\n   * to show the subgrid.\n   *\n   * <div doc-module-components=\"ui.grid.expandable\"></div>\n   */\n  var module = angular.module('ui.grid.expandable', ['ui.grid']);\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.expandable.service:uiGridExpandableService\n   *\n   *  @description Services for the expandable grid\n   */\n  module.service('uiGridExpandableService', ['gridUtil', '$compile', function (gridUtil, $compile) {\n    var service = {\n      initializeGrid: function (grid) {\n\n        grid.expandable = {};\n        grid.expandable.expandedAll = false;\n\n        /**\n         *  @ngdoc object\n         *  @name enableExpandable\n         *  @propertyOf  ui.grid.expandable.api:GridOptions\n         *  @description Whether or not to use expandable feature, allows you to turn off expandable on specific grids\n         *  within your application, or in specific modes on _this_ grid. Defaults to true.\n         *  @example\n         *  <pre>\n         *    $scope.gridOptions = {\n         *      enableExpandable: false\n         *    }\n         *  </pre>\n         */\n        grid.options.enableExpandable = grid.options.enableExpandable !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name expandableRowHeight\n         *  @propertyOf  ui.grid.expandable.api:GridOptions\n         *  @description Height in pixels of the expanded subgrid.  Defaults to\n         *  150\n         *  @example\n         *  <pre>\n         *    $scope.gridOptions = {\n         *      expandableRowHeight: 150\n         *    }\n         *  </pre>\n         */\n        grid.options.expandableRowHeight = grid.options.expandableRowHeight || 150;\n\n        /**\n         *  @ngdoc object\n         *  @name\n         *  @propertyOf  ui.grid.expandable.api:GridOptions\n         *  @description Width in pixels of the expandable column. Defaults to 40\n         *  @example\n         *  <pre>\n         *    $scope.gridOptions = {\n         *      expandableRowHeaderWidth: 40\n         *    }\n         *  </pre>\n         */\n        grid.options.expandableRowHeaderWidth = grid.options.expandableRowHeaderWidth || 40;\n\n        /**\n         *  @ngdoc object\n         *  @name expandableRowTemplate\n         *  @propertyOf  ui.grid.expandable.api:GridOptions\n         *  @description Mandatory. The template for your expanded row\n         *  @example\n         *  <pre>\n         *    $scope.gridOptions = {\n         *      expandableRowTemplate: 'expandableRowTemplate.html'\n         *    }\n         *  </pre>\n         */\n        if ( grid.options.enableExpandable && !grid.options.expandableRowTemplate ){\n          gridUtil.logError( 'You have not set the expandableRowTemplate, disabling expandable module' );\n          grid.options.enableExpandable = false;\n        }\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.expandable.api:PublicApi\n         *\n         *  @description Public Api for expandable feature\n         */\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.expandable.api:GridRow\n         *\n         *  @description Additional properties added to GridRow when using the expandable module\n         */\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.expandable.api:GridOptions\n         *\n         *  @description Options for configuring the expandable feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n        var publicApi = {\n          events: {\n            expandable: {\n              /**\n               * @ngdoc event\n               * @name rowExpandedStateChanged\n               * @eventOf  ui.grid.expandable.api:PublicApi\n               * @description raised when cell editing is complete\n               * <pre>\n               *      gridApi.expandable.on.rowExpandedStateChanged(scope,function(row){})\n               * </pre>\n               * @param {GridRow} row the row that was expanded\n               */\n              rowExpandedBeforeStateChanged: function(scope,row){\n              },\n              rowExpandedStateChanged: function (scope, row) {\n              }\n            }\n          },\n\n          methods: {\n            expandable: {\n              /**\n               * @ngdoc method\n               * @name toggleRowExpansion\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Toggle a specific row\n               * <pre>\n               *      gridApi.expandable.toggleRowExpansion(rowEntity);\n               * </pre>\n               * @param {object} rowEntity the data entity for the row you want to expand\n               */\n              toggleRowExpansion: function (rowEntity) {\n                var row = grid.getRow(rowEntity);\n                if (row !== null) {\n                  service.toggleRowExpansion(grid, row);\n                }\n              },\n\n              /**\n               * @ngdoc method\n               * @name expandAllRows\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Expand all subgrids.\n               * <pre>\n               *      gridApi.expandable.expandAllRows();\n               * </pre>\n               */\n              expandAllRows: function() {\n                service.expandAllRows(grid);\n              },\n\n              /**\n               * @ngdoc method\n               * @name collapseAllRows\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Collapse all subgrids.\n               * <pre>\n               *      gridApi.expandable.collapseAllRows();\n               * </pre>\n               */\n              collapseAllRows: function() {\n                service.collapseAllRows(grid);\n              },\n\n              /**\n               * @ngdoc method\n               * @name toggleAllRows\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Toggle all subgrids.\n               * <pre>\n               *      gridApi.expandable.toggleAllRows();\n               * </pre>\n               */\n              toggleAllRows: function() {\n                service.toggleAllRows(grid);\n              },\n              /**\n               * @ngdoc function\n               * @name expandRow\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Expand the data row\n               * @param {object} rowEntity gridOptions.data[] array instance\n               */\n              expandRow: function (rowEntity) {\n                var row = grid.getRow(rowEntity);\n                if (row !== null && !row.isExpanded) {\n                  service.toggleRowExpansion(grid, row);\n                }\n              },\n              /**\n               * @ngdoc function\n               * @name collapseRow\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description Collapse the data row\n               * @param {object} rowEntity gridOptions.data[] array instance\n               */\n              collapseRow: function (rowEntity) {\n                var row = grid.getRow(rowEntity);\n                if (row !== null && row.isExpanded) {\n                  service.toggleRowExpansion(grid, row);\n                }\n              },\n              /**\n               * @ngdoc function\n               * @name getExpandedRows\n               * @methodOf  ui.grid.expandable.api:PublicApi\n               * @description returns all expandedRow's entity references\n               */\n              getExpandedRows: function () {\n                return service.getExpandedRows(grid).map(function (gridRow) {\n                  return gridRow.entity;\n                });\n              }\n            }\n          }\n        };\n        grid.api.registerEventsFromObject(publicApi.events);\n        grid.api.registerMethodsFromObject(publicApi.methods);\n      },\n\n      toggleRowExpansion: function (grid, row) {\n        // trigger the \"before change\" event. Can change row height dynamically this way.\n        grid.api.expandable.raise.rowExpandedBeforeStateChanged(row);\n        /**\n         *  @ngdoc object\n         *  @name isExpanded\n         *  @propertyOf  ui.grid.expandable.api:GridRow\n         *  @description Whether or not the row is currently expanded.\n         *  @example\n         *  <pre>\n         *    $scope.api.expandable.on.rowExpandedStateChanged($scope, function (row) {\n         *      if (row.isExpanded) {\n         *        //...\n         *      }\n         *    });\n         *  </pre>\n         */\n        row.isExpanded = !row.isExpanded;\n        if (angular.isUndefined(row.expandedRowHeight)){\n          row.expandedRowHeight = grid.options.expandableRowHeight;\n        }\n\n        if (row.isExpanded) {\n          row.height = row.grid.options.rowHeight + row.expandedRowHeight;\n        }\n        else {\n          row.height = row.grid.options.rowHeight;\n          grid.expandable.expandedAll = false;\n        }\n        grid.api.expandable.raise.rowExpandedStateChanged(row);\n      },\n\n      expandAllRows: function(grid, $scope) {\n        grid.renderContainers.body.visibleRowCache.forEach( function(row) {\n          if (!row.isExpanded) {\n            service.toggleRowExpansion(grid, row);\n          }\n        });\n        grid.expandable.expandedAll = true;\n        grid.queueGridRefresh();\n      },\n\n      collapseAllRows: function(grid) {\n        grid.renderContainers.body.visibleRowCache.forEach( function(row) {\n          if (row.isExpanded) {\n            service.toggleRowExpansion(grid, row);\n          }\n        });\n        grid.expandable.expandedAll = false;\n        grid.queueGridRefresh();\n      },\n\n      toggleAllRows: function(grid) {\n        if (grid.expandable.expandedAll) {\n          service.collapseAllRows(grid);\n        }\n        else {\n          service.expandAllRows(grid);\n        }\n      },\n\n      getExpandedRows: function (grid) {\n        return grid.rows.filter(function (row) {\n          return row.isExpanded;\n        });\n      }\n    };\n    return service;\n  }]);\n\n  /**\n   *  @ngdoc object\n   *  @name enableExpandableRowHeader\n   *  @propertyOf  ui.grid.expandable.api:GridOptions\n   *  @description Show a rowHeader to provide the expandable buttons.  If set to false then implies\n   *  you're going to use a custom method for expanding and collapsing the subgrids. Defaults to true.\n   *  @example\n   *  <pre>\n   *    $scope.gridOptions = {\n   *      enableExpandableRowHeader: false\n   *    }\n   *  </pre>\n   */\n  module.directive('uiGridExpandable', ['uiGridExpandableService', '$templateCache',\n    function (uiGridExpandableService, $templateCache) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n              if ( uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) {\n                var expandableRowHeaderColDef = {\n                  name: 'expandableButtons',\n                  displayName: '',\n                  exporterSuppressExport: true,\n                  enableColumnResizing: false,\n                  enableColumnMenu: false,\n                  width: uiGridCtrl.grid.options.expandableRowHeaderWidth || 40\n                };\n                expandableRowHeaderColDef.cellTemplate = $templateCache.get('ui-grid/expandableRowHeader');\n                expandableRowHeaderColDef.headerCellTemplate = $templateCache.get('ui-grid/expandableTopRowHeader');\n                uiGridCtrl.grid.addRowHeaderColumn(expandableRowHeaderColDef);\n              }\n              uiGridExpandableService.initializeGrid(uiGridCtrl.grid);\n            },\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.expandable.directive:uiGrid\n   *  @description stacks on the uiGrid directive to register child grid with parent row when child is created\n   */\n  module.directive('uiGrid', ['uiGridExpandableService', '$templateCache',\n    function (uiGridExpandableService, $templateCache) {\n      return {\n        replace: true,\n        priority: 599,\n        require: '^uiGrid',\n        scope: false,\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n              uiGridCtrl.grid.api.core.on.renderingComplete($scope, function() {\n                //if a parent grid row is on the scope, then add the parentRow property to this childGrid\n                if ($scope.row && $scope.row.grid && $scope.row.grid.options && $scope.row.grid.options.enableExpandable) {\n\n                  /**\n                   *  @ngdoc directive\n                   *  @name ui.grid.expandable.class:Grid\n                   *  @description Additional Grid properties added by expandable module\n                   */\n\n                  /**\n                   *  @ngdoc object\n                   *  @name parentRow\n                   *  @propertyOf ui.grid.expandable.class:Grid\n                   *  @description reference to the expanded parent row that owns this grid\n                   */\n                  uiGridCtrl.grid.parentRow = $scope.row;\n\n                  //todo: adjust height on parent row when child grid height changes. we need some sort of gridHeightChanged event\n                 // uiGridCtrl.grid.core.on.canvasHeightChanged($scope, function(oldHeight, newHeight) {\n                 //   uiGridCtrl.grid.parentRow = newHeight;\n                 // });\n                }\n\n              });\n            },\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.expandable.directive:uiGridExpandableRow\n   *  @description directive to render the expandable row template\n   */\n  module.directive('uiGridExpandableRow',\n  ['uiGridExpandableService', '$timeout', '$compile', 'uiGridConstants','gridUtil','$interval', '$log',\n    function (uiGridExpandableService, $timeout, $compile, uiGridConstants, gridUtil, $interval, $log) {\n\n      return {\n        replace: false,\n        priority: 0,\n        scope: false,\n\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n              gridUtil.getTemplate($scope.grid.options.expandableRowTemplate).then(\n                function (template) {\n                  if ($scope.grid.options.expandableRowScope) {\n                    var expandableRowScope = $scope.grid.options.expandableRowScope;\n                    for (var property in expandableRowScope) {\n                      if (expandableRowScope.hasOwnProperty(property)) {\n                        $scope[property] = expandableRowScope[property];\n                      }\n                    }\n                  }\n                  var expandedRowElement = $compile(template)($scope);\n                  $elm.append(expandedRowElement);\n                  $scope.row.expandedRendered = true;\n              });\n            },\n\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n              $scope.$on('$destroy', function() {\n                $scope.row.expandedRendered = false;\n              });\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.expandable.directive:uiGridRow\n   *  @description stacks on the uiGridRow directive to add support for expandable rows\n   */\n  module.directive('uiGridRow',\n    ['$compile', 'gridUtil', '$templateCache',\n      function ($compile, gridUtil, $templateCache) {\n        return {\n          priority: -200,\n          scope: false,\n          compile: function ($elm, $attrs) {\n            return {\n              pre: function ($scope, $elm, $attrs, controllers) {\n\n                $scope.expandableRow = {};\n\n                $scope.expandableRow.shouldRenderExpand = function () {\n                  var ret = $scope.colContainer.name === 'body' &&  $scope.grid.options.enableExpandable !== false && $scope.row.isExpanded && (!$scope.grid.isScrollingVertically || $scope.row.expandedRendered);\n                  return ret;\n                };\n\n                $scope.expandableRow.shouldRenderFiller = function () {\n                  var ret = $scope.row.isExpanded && ( $scope.colContainer.name !== 'body' || ($scope.grid.isScrollingVertically && !$scope.row.expandedRendered));\n                  return ret;\n                };\n\n /*\n  * Commented out @PaulL1.  This has no purpose that I can see, and causes #2964.  If this code needs to be reinstated for some\n  * reason it needs to use drawnWidth, not width, and needs to check column visibility.  It should really use render container\n  * visible column cache also instead of checking column.renderContainer.\n                  function updateRowContainerWidth() {\n                      var grid = $scope.grid;\n                      var colWidth = 0;\n                      grid.columns.forEach( function (column) {\n                          if (column.renderContainer === 'left') {\n                            colWidth += column.width;\n                          }\n                      });\n                      colWidth = Math.floor(colWidth);\n                      return '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.colContainer.name + ', .grid' + grid.id +\n                          ' .ui-grid-pinned-container-' + $scope.colContainer.name + ' .ui-grid-render-container-' + $scope.colContainer.name +\n                          ' .ui-grid-viewport .ui-grid-canvas .ui-grid-row { width: ' + colWidth + 'px; }';\n                  }\n\n                  if ($scope.colContainer.name === 'left') {\n                      $scope.grid.registerStyleComputation({\n                          priority: 15,\n                          func: updateRowContainerWidth\n                      });\n                  }*/\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n              }\n            };\n          }\n        };\n      }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.expandable.directive:uiGridViewport\n   *  @description stacks on the uiGridViewport directive to append the expandable row html elements to the\n   *  default gridRow template\n   */\n  module.directive('uiGridViewport',\n    ['$compile', 'gridUtil', '$templateCache',\n      function ($compile, gridUtil, $templateCache) {\n        return {\n          priority: -200,\n          scope: false,\n          compile: function ($elm, $attrs) {\n            var rowRepeatDiv = angular.element($elm.children().children()[0]);\n            var expandedRowFillerElement = $templateCache.get('ui-grid/expandableScrollFiller');\n            var expandedRowElement = $templateCache.get('ui-grid/expandableRow');\n            rowRepeatDiv.append(expandedRowElement);\n            rowRepeatDiv.append(expandedRowFillerElement);\n            return {\n              pre: function ($scope, $elm, $attrs, controllers) {\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n              }\n            };\n          }\n        };\n      }]);\n\n})();\n\n/* global console */\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.exporter\n   * @description\n   *\n   * # ui.grid.exporter\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module provides the ability to export data from the grid.\n   *\n   * Data can be exported in a range of formats, and all data, visible\n   * data, or selected rows can be exported, with all columns or visible\n   * columns.\n   *\n   * No UI is provided, the caller should provide their own UI/buttons\n   * as appropriate, or enable the gridMenu\n   *\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.exporter\"></div>\n   */\n\n  var module = angular.module('ui.grid.exporter', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.exporter.constant:uiGridExporterConstants\n   *\n   *  @description constants available in exporter module\n   */\n  /**\n   * @ngdoc property\n   * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants\n   * @name ALL\n   * @description export all data, including data not visible.  Can\n   * be set for either rowTypes or colTypes\n   */\n  /**\n   * @ngdoc property\n   * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants\n   * @name VISIBLE\n   * @description export only visible data, including data not visible.  Can\n   * be set for either rowTypes or colTypes\n   */\n  /**\n   * @ngdoc property\n   * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants\n   * @name SELECTED\n   * @description export all data, including data not visible.  Can\n   * be set only for rowTypes, selection of only some columns is\n   * not supported\n   */\n  module.constant('uiGridExporterConstants', {\n    featureName: 'exporter',\n    ALL: 'all',\n    VISIBLE: 'visible',\n    SELECTED: 'selected',\n    CSV_CONTENT: 'CSV_CONTENT',\n    BUTTON_LABEL: 'BUTTON_LABEL',\n    FILE_NAME: 'FILE_NAME'\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.exporter.service:uiGridExporterService\n   *\n   *  @description Services for exporter feature\n   */\n  module.service('uiGridExporterService', ['$q', 'uiGridExporterConstants', 'gridUtil', '$compile', '$interval', 'i18nService',\n    function ($q, uiGridExporterConstants, gridUtil, $compile, $interval, i18nService) {\n\n      var service = {\n\n        delay: 100,\n\n        initializeGrid: function (grid) {\n\n          //add feature namespace and any properties to grid for needed state\n          grid.exporter = {};\n          this.defaultGridOptions(grid.options);\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.exporter.api:PublicApi\n           *\n           *  @description Public Api for exporter feature\n           */\n          var publicApi = {\n            events: {\n              exporter: {\n              }\n            },\n            methods: {\n              exporter: {\n                /**\n                 * @ngdoc function\n                 * @name csvExport\n                 * @methodOf  ui.grid.exporter.api:PublicApi\n                 * @description Exports rows from the grid in csv format,\n                 * the data exported is selected based on the provided options\n                 * @param {string} rowTypes which rows to export, valid values are\n                 * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n                 * uiGridExporterConstants.SELECTED\n                 * @param {string} colTypes which columns to export, valid values are\n                 * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE\n                 */\n                csvExport: function (rowTypes, colTypes) {\n                  service.csvExport(grid, rowTypes, colTypes);\n                },\n                /**\n                 * @ngdoc function\n                 * @name pdfExport\n                 * @methodOf  ui.grid.exporter.api:PublicApi\n                 * @description Exports rows from the grid in pdf format,\n                 * the data exported is selected based on the provided options\n                 * Note that this function has a dependency on pdfMake, all\n                 * going well this has been installed for you.\n                 * The resulting pdf opens in a new browser window.\n                 * @param {string} rowTypes which rows to export, valid values are\n                 * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n                 * uiGridExporterConstants.SELECTED\n                 * @param {string} colTypes which columns to export, valid values are\n                 * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE\n                 */\n                pdfExport: function (rowTypes, colTypes) {\n                  service.pdfExport(grid, rowTypes, colTypes);\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n          if (grid.api.core.addToGridMenu){\n            service.addToMenu( grid );\n          } else {\n            // order of registration is not guaranteed, register in a little while\n            $interval( function() {\n              if (grid.api.core.addToGridMenu){\n                service.addToMenu( grid );\n              }\n            }, this.delay, 1);\n          }\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n          //default option to true unless it was explicitly set to false\n          /**\n           * @ngdoc object\n           * @name ui.grid.exporter.api:GridOptions\n           *\n           * @description GridOptions for exporter feature, these are available to be\n           * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n          /**\n           * @ngdoc object\n           * @name ui.grid.exporter.api:ColumnDef\n           * @description ColumnDef settings for exporter\n           */\n          /**\n           * @ngdoc object\n           * @name exporterSuppressMenu\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Don't show the export menu button, implying the user\n           * will roll their own UI for calling the exporter\n           * <br/>Defaults to false\n           */\n          gridOptions.exporterSuppressMenu = gridOptions.exporterSuppressMenu === true;\n          /**\n           * @ngdoc object\n           * @name exporterMenuLabel\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The text to show on the exporter menu button\n           * link\n           * <br/>Defaults to 'Export'\n           */\n          gridOptions.exporterMenuLabel = gridOptions.exporterMenuLabel ? gridOptions.exporterMenuLabel : 'Export';\n          /**\n           * @ngdoc object\n           * @name exporterSuppressColumns\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Columns that should not be exported.  The selectionRowHeader is already automatically\n           * suppressed, but if you had a button column or some other \"system\" column that shouldn't be shown in the\n           * output then add it in this list.  You should provide an array of column names.\n           * <br/>Defaults to: []\n           * <pre>\n           *   gridOptions.exporterSuppressColumns = [ 'buttons' ];\n           * </pre>\n           */\n          gridOptions.exporterSuppressColumns = gridOptions.exporterSuppressColumns ? gridOptions.exporterSuppressColumns : [];\n          /**\n           * @ngdoc object\n           * @name exporterCsvColumnSeparator\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The character to use as column separator\n           * link\n           * <br/>Defaults to ','\n           */\n          gridOptions.exporterCsvColumnSeparator = gridOptions.exporterCsvColumnSeparator ? gridOptions.exporterCsvColumnSeparator : ',';\n          /**\n           * @ngdoc object\n           * @name exporterCsvFilename\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The default filename to use when saving the downloaded csv.\n           * This will only work in some browsers.\n           * <br/>Defaults to 'download.csv'\n           */\n          gridOptions.exporterCsvFilename = gridOptions.exporterCsvFilename ? gridOptions.exporterCsvFilename : 'download.csv';\n          /**\n           * @ngdoc object\n           * @name exporterPdfFilename\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The default filename to use when saving the downloaded pdf, only used in IE (other browsers open pdfs in a new window)\n           * <br/>Defaults to 'download.pdf'\n           */\n          gridOptions.exporterPdfFilename = gridOptions.exporterPdfFilename ? gridOptions.exporterPdfFilename : 'download.pdf';\n          /**\n           * @ngdoc object\n           * @name exporterOlderExcelCompatibility\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Some versions of excel don't like the utf-16 BOM on the front, and it comes\n           * through as ï»¿ in the first column header.  Setting this option to false will suppress this, at the\n           * expense of proper utf-16 handling in applications that do recognise the BOM\n           * <br/>Defaults to false\n           */\n          gridOptions.exporterOlderExcelCompatibility = gridOptions.exporterOlderExcelCompatibility === true;\n          /**\n           * @ngdoc object\n           * @name exporterPdfDefaultStyle\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The default style in pdfMake format\n           * <br/>Defaults to:\n           * <pre>\n           *   {\n           *     fontSize: 11\n           *   }\n           * </pre>\n           */\n          gridOptions.exporterPdfDefaultStyle = gridOptions.exporterPdfDefaultStyle ? gridOptions.exporterPdfDefaultStyle : { fontSize: 11 };\n          /**\n           * @ngdoc object\n           * @name exporterPdfTableStyle\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The table style in pdfMake format\n           * <br/>Defaults to:\n           * <pre>\n           *   {\n           *     margin: [0, 5, 0, 15]\n           *   }\n           * </pre>\n           */\n          gridOptions.exporterPdfTableStyle = gridOptions.exporterPdfTableStyle ? gridOptions.exporterPdfTableStyle : { margin: [0, 5, 0, 15] };\n          /**\n           * @ngdoc object\n           * @name exporterPdfTableHeaderStyle\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The tableHeader style in pdfMake format\n           * <br/>Defaults to:\n           * <pre>\n           *   {\n           *     bold: true,\n           *     fontSize: 12,\n           *     color: 'black'\n           *   }\n           * </pre>\n           */\n          gridOptions.exporterPdfTableHeaderStyle = gridOptions.exporterPdfTableHeaderStyle ? gridOptions.exporterPdfTableHeaderStyle : { bold: true, fontSize: 12, color: 'black' };\n          /**\n           * @ngdoc object\n           * @name exporterPdfHeader\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The header section for pdf exports.  Can be\n           * simple text:\n           * <pre>\n           *   gridOptions.exporterPdfHeader = 'My Header';\n           * </pre>\n           * Can be a more complex object in pdfMake format:\n           * <pre>\n           *   gridOptions.exporterPdfHeader = {\n           *     columns: [\n           *       'Left part',\n           *       { text: 'Right part', alignment: 'right' }\n           *     ]\n           *   };\n           * </pre>\n           * Or can be a function, allowing page numbers and the like\n           * <pre>\n           *   gridOptions.exporterPdfHeader: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; };\n           * </pre>\n           */\n          gridOptions.exporterPdfHeader = gridOptions.exporterPdfHeader ? gridOptions.exporterPdfHeader : null;\n          /**\n           * @ngdoc object\n           * @name exporterPdfFooter\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The header section for pdf exports.  Can be\n           * simple text:\n           * <pre>\n           *   gridOptions.exporterPdfFooter = 'My Footer';\n           * </pre>\n           * Can be a more complex object in pdfMake format:\n           * <pre>\n           *   gridOptions.exporterPdfFooter = {\n           *     columns: [\n           *       'Left part',\n           *       { text: 'Right part', alignment: 'right' }\n           *     ]\n           *   };\n           * </pre>\n           * Or can be a function, allowing page numbers and the like\n           * <pre>\n           *   gridOptions.exporterPdfFooter: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; };\n           * </pre>\n           */\n          gridOptions.exporterPdfFooter = gridOptions.exporterPdfFooter ? gridOptions.exporterPdfFooter : null;\n          /**\n           * @ngdoc object\n           * @name exporterPdfOrientation\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The orientation, should be a valid pdfMake value,\n           * 'landscape' or 'portrait'\n           * <br/>Defaults to landscape\n           */\n          gridOptions.exporterPdfOrientation = gridOptions.exporterPdfOrientation ? gridOptions.exporterPdfOrientation : 'landscape';\n          /**\n           * @ngdoc object\n           * @name exporterPdfPageSize\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The orientation, should be a valid pdfMake\n           * paper size, usually 'A4' or 'LETTER'\n           * {@link https://github.com/bpampuch/pdfmake/blob/master/src/standardPageSizes.js pdfMake page sizes}\n           * <br/>Defaults to A4\n           */\n          gridOptions.exporterPdfPageSize = gridOptions.exporterPdfPageSize ? gridOptions.exporterPdfPageSize : 'A4';\n          /**\n           * @ngdoc object\n           * @name exporterPdfMaxGridWidth\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description The maxium grid width - the current grid width\n           * will be scaled to match this, with any fixed width columns\n           * being adjusted accordingly.\n           * <br/>Defaults to 720 (for A4 landscape), use 670 for LETTER\n           */\n          gridOptions.exporterPdfMaxGridWidth = gridOptions.exporterPdfMaxGridWidth ? gridOptions.exporterPdfMaxGridWidth : 720;\n          /**\n           * @ngdoc object\n           * @name exporterPdfTableLayout\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description A tableLayout in pdfMake format,\n           * controls gridlines and the like.  We use the default\n           * layout usually.\n           * <br/>Defaults to null, which means no layout\n           */\n\n          /**\n           * @ngdoc object\n           * @name exporterMenuAllData\n           * @porpertyOf  ui.grid.exporter.api:GridOptions\n           * @description Add export all data as cvs/pdf menu items to the ui-grid grid menu, if it's present.  Defaults to true.\n           */\n          gridOptions.exporterMenuAllData = gridOptions.exporterMenuAllData !== undefined ? gridOptions.exporterMenuAllData : true;\n\n          /**\n           * @ngdoc object\n           * @name exporterMenuVisibleData\n           * @porpertyOf  ui.grid.exporter.api:GridOptions\n           * @description Add export visible data as cvs/pdf menu items to the ui-grid grid menu, if it's present.  Defaults to true.\n           */\n          gridOptions.exporterMenuVisibleData = gridOptions.exporterMenuVisibleData !== undefined ? gridOptions.exporterMenuVisibleData : true;\n\n          /**\n           * @ngdoc object\n           * @name exporterMenuSelectedData\n           * @porpertyOf  ui.grid.exporter.api:GridOptions\n           * @description Add export selected data as cvs/pdf menu items to the ui-grid grid menu, if it's present.  Defaults to true.\n           */\n          gridOptions.exporterMenuSelectedData = gridOptions.exporterMenuSelectedData !== undefined ? gridOptions.exporterMenuSelectedData : true;\n\n          /**\n           * @ngdoc object\n           * @name exporterMenuCsv\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Add csv export menu items to the ui-grid grid menu, if it's present.  Defaults to true.\n           */\n          gridOptions.exporterMenuCsv = gridOptions.exporterMenuCsv !== undefined ? gridOptions.exporterMenuCsv : true;\n\n          /**\n           * @ngdoc object\n           * @name exporterMenuPdf\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Add pdf export menu items to the ui-grid grid menu, if it's present.  Defaults to true.\n           */\n          gridOptions.exporterMenuPdf = gridOptions.exporterMenuPdf !== undefined ? gridOptions.exporterMenuPdf : true;\n\n          /**\n           * @ngdoc object\n           * @name exporterPdfCustomFormatter\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description A custom callback routine that changes the pdf document, adding any\n           * custom styling or content that is supported by pdfMake.  Takes in the complete docDefinition, and\n           * must return an updated docDefinition ready for pdfMake.\n           * @example\n           * In this example we add a style to the style array, so that we can use it in our\n           * footer definition.\n           * <pre>\n           *   gridOptions.exporterPdfCustomFormatter = function ( docDefinition ) {\n           *     docDefinition.styles.footerStyle = { bold: true, fontSize: 10 };\n           *     return docDefinition;\n           *   }\n           *\n           *   gridOptions.exporterPdfFooter = { text: 'My footer', style: 'footerStyle' }\n           * </pre>\n           */\n          gridOptions.exporterPdfCustomFormatter = ( gridOptions.exporterPdfCustomFormatter && typeof( gridOptions.exporterPdfCustomFormatter ) === 'function' ) ? gridOptions.exporterPdfCustomFormatter : function ( docDef ) { return docDef; };\n\n          /**\n           * @ngdoc object\n           * @name exporterHeaderFilterUseName\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description Defaults to false, which leads to `displayName` being passed into the headerFilter.\n           * If set to true, then will pass `name` instead.\n           *\n           *\n           * @example\n           * <pre>\n           *   gridOptions.exporterHeaderFilterUseName = true;\n           * </pre>\n           */\n          gridOptions.exporterHeaderFilterUseName = gridOptions.exporterHeaderFilterUseName === true;\n\n          /**\n           * @ngdoc object\n           * @name exporterHeaderFilter\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description A function to apply to the header displayNames before exporting.  Useful for internationalisation,\n           * for example if you were using angular-translate you'd set this to `$translate.instant`.  Note that this\n           * call must be synchronous, it cannot be a call that returns a promise.\n           *\n           * Behaviour can be changed to pass in `name` instead of `displayName` through use of `exporterHeaderFilterUseName: true`.\n           *\n           * @example\n           * <pre>\n           *   gridOptions.exporterHeaderFilter = function( displayName ){ return 'col: ' + name; };\n           * </pre>\n           * OR\n           * <pre>\n           *   gridOptions.exporterHeaderFilter = $translate.instant;\n           * </pre>\n           */\n\n          /**\n           * @ngdoc function\n           * @name exporterFieldCallback\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description A function to call for each field before exporting it.  Allows\n           * massaging of raw data into a display format, for example if you have applied\n           * filters to convert codes into decodes, or you require\n           * a specific date format in the exported content.\n           *\n           * The method is called once for each field exported, and provides the grid, the\n           * gridCol and the GridRow for you to use as context in massaging the data.\n           *\n           * @param {Grid} grid provides the grid in case you have need of it\n           * @param {GridRow} row the row from which the data comes\n           * @param {GridCol} col the column from which the data comes\n           * @param {object} value the value for your massaging\n           * @returns {object} you must return the massaged value ready for exporting\n           *\n           * @example\n           * <pre>\n           *   gridOptions.exporterFieldCallback = function ( grid, row, col, value ){\n           *     if ( col.name === 'status' ){\n           *       value = decodeStatus( value );\n           *     }\n           *     return value;\n           *   }\n           * </pre>\n           */\n          gridOptions.exporterFieldCallback = gridOptions.exporterFieldCallback ? gridOptions.exporterFieldCallback : function( grid, row, col, value ) { return value; };\n\n          /**\n           * @ngdoc function\n           * @name exporterAllDataFn\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description This promise is needed when exporting all rows,\n           * and the data need to be provided by server side. Default is null.\n           * @returns {Promise} a promise to load all data from server\n           *\n           * @example\n           * <pre>\n           *   gridOptions.exporterAllDataFn = function () {\n           *     return $http.get('/data/100.json')\n           *   }\n           * </pre>\n           */\n          gridOptions.exporterAllDataFn = gridOptions.exporterAllDataFn ? gridOptions.exporterAllDataFn : null;\n\n          /**\n           * @ngdoc function\n           * @name exporterAllDataPromise\n           * @propertyOf  ui.grid.exporter.api:GridOptions\n           * @description DEPRECATED - exporterAllDataFn used to be\n           * called this, but it wasn't a promise, it was a function that returned\n           * a promise.  Deprecated, but supported for backward compatibility, use\n           * exporterAllDataFn instead.\n           * @returns {Promise} a promise to load all data from server\n           *\n           * @example\n           * <pre>\n           *   gridOptions.exporterAllDataFn = function () {\n           *     return $http.get('/data/100.json')\n           *   }\n           * </pre>\n           */\n          if ( gridOptions.exporterAllDataFn == null && gridOptions.exporterAllDataPromise ) {\n            gridOptions.exporterAllDataFn = gridOptions.exporterAllDataPromise;\n          }\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name addToMenu\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Adds export items to the grid menu,\n         * allowing the user to select export options\n         * @param {Grid} grid the grid from which data should be exported\n         */\n        addToMenu: function ( grid ) {\n          grid.api.core.addToGridMenu( grid, [\n            {\n              title: i18nService.getSafeText('gridMenu.exporterAllAsCsv'),\n              action: function ($event) {\n                this.grid.api.exporter.csvExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuAllData;\n              },\n              order: 200\n            },\n            {\n              title: i18nService.getSafeText('gridMenu.exporterVisibleAsCsv'),\n              action: function ($event) {\n                this.grid.api.exporter.csvExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuVisibleData;\n              },\n              order: 201\n            },\n            {\n              title: i18nService.getSafeText('gridMenu.exporterSelectedAsCsv'),\n              action: function ($event) {\n                this.grid.api.exporter.csvExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuCsv && this.grid.options.exporterMenuSelectedData &&\n                       ( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );\n              },\n              order: 202\n            },\n            {\n              title: i18nService.getSafeText('gridMenu.exporterAllAsPdf'),\n              action: function ($event) {\n                this.grid.api.exporter.pdfExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuAllData;\n              },\n              order: 203\n            },\n            {\n              title: i18nService.getSafeText('gridMenu.exporterVisibleAsPdf'),\n              action: function ($event) {\n                this.grid.api.exporter.pdfExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuVisibleData;\n              },\n              order: 204\n            },\n            {\n              title: i18nService.getSafeText('gridMenu.exporterSelectedAsPdf'),\n              action: function ($event) {\n                this.grid.api.exporter.pdfExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE );\n              },\n              shown: function() {\n                return this.grid.options.exporterMenuPdf && this.grid.options.exporterMenuSelectedData &&\n                       ( this.grid.api.selection && this.grid.api.selection.getSelectedRows().length > 0 );\n              },\n              order: 205\n            }\n          ]);\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name csvExport\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Exports rows from the grid in csv format,\n         * the data exported is selected based on the provided options\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {string} rowTypes which rows to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         * @param {string} colTypes which columns to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         */\n        csvExport: function (grid, rowTypes, colTypes) {\n          var self = this;\n          this.loadAllDataIfNeeded(grid, rowTypes, colTypes).then(function() {\n            var exportColumnHeaders = grid.options.showHeader ? self.getColumnHeaders(grid, colTypes) : [];\n            var exportData = self.getData(grid, rowTypes, colTypes);\n            var csvContent = self.formatAsCsv(exportColumnHeaders, exportData, grid.options.exporterCsvColumnSeparator);\n\n            self.downloadFile (grid.options.exporterCsvFilename, csvContent, grid.options.exporterOlderExcelCompatibility);\n          });\n        },\n\n        /**\n         * @ngdoc function\n         * @name loadAllDataIfNeeded\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description When using server side pagination, use exporterAllDataFn to\n         * load all data before continuing processing.\n         * When using client side pagination, return a resolved promise so processing\n         * continues immediately\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {string} rowTypes which rows to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         * @param {string} colTypes which columns to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         */\n        loadAllDataIfNeeded: function (grid, rowTypes, colTypes) {\n          if ( rowTypes === uiGridExporterConstants.ALL && grid.rows.length !== grid.options.totalItems && grid.options.exporterAllDataFn) {\n            return grid.options.exporterAllDataFn()\n              .then(function() {\n                grid.modifyRows(grid.options.data);\n              });\n          } else {\n            var deferred = $q.defer();\n            deferred.resolve();\n            return deferred.promise;\n          }\n        },\n\n        /**\n         * @ngdoc property\n         * @propertyOf ui.grid.exporter.api:ColumnDef\n         * @name exporterSuppressExport\n         * @description Suppresses export for this column.  Used by selection and expandable.\n         */\n\n        /**\n         * @ngdoc function\n         * @name getColumnHeaders\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Gets the column headers from the grid to use\n         * as a title row for the exported file, all headers have\n         * headerCellFilters applied as appropriate.\n         *\n         * Column headers are an array of objects, each object has\n         * name, displayName, width and align attributes.  Only name is\n         * used for csv, all attributes are used for pdf.\n         *\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {string} colTypes which columns to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         */\n        getColumnHeaders: function (grid, colTypes) {\n          var headers = [];\n          var columns;\n\n          if ( colTypes === uiGridExporterConstants.ALL ){\n            columns = grid.columns;\n          } else {\n            var leftColumns = grid.renderContainers.left ? grid.renderContainers.left.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n            var bodyColumns = grid.renderContainers.body ? grid.renderContainers.body.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n            var rightColumns = grid.renderContainers.right ? grid.renderContainers.right.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n\n            columns = leftColumns.concat(bodyColumns,rightColumns);\n          }\n\n          columns.forEach( function( gridCol, index ) {\n            if ( gridCol.colDef.exporterSuppressExport !== true &&\n                 grid.options.exporterSuppressColumns.indexOf( gridCol.name ) === -1 ){\n              headers.push({\n                name: gridCol.field,\n                displayName: grid.options.exporterHeaderFilter ? ( grid.options.exporterHeaderFilterUseName ? grid.options.exporterHeaderFilter(gridCol.name) : grid.options.exporterHeaderFilter(gridCol.displayName) ) : gridCol.displayName,\n                width: gridCol.drawnWidth ? gridCol.drawnWidth : gridCol.width,\n                align: gridCol.colDef.type === 'number' ? 'right' : 'left'\n              });\n            }\n          });\n\n          return headers;\n        },\n\n\n        /**\n         * @ngdoc property\n         * @propertyOf ui.grid.exporter.api:ColumnDef\n         * @name exporterPdfAlign\n         * @description the alignment you'd like for this specific column when\n         * exported into a pdf.  Can be 'left', 'right', 'center' or any other\n         * valid pdfMake alignment option.\n         */\n\n\n        /**\n         * @ngdoc object\n         * @name ui.grid.exporter.api:GridRow\n         * @description GridRow settings for exporter\n         */\n        /**\n         * @ngdoc object\n         * @name exporterEnableExporting\n         * @propertyOf  ui.grid.exporter.api:GridRow\n         * @description If set to false, then don't export this row, notwithstanding visible or\n         * other settings\n         * <br/>Defaults to true\n         */\n\n        /**\n         * @ngdoc function\n         * @name getData\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Gets data from the grid based on the provided options,\n         * all cells have cellFilters applied as appropriate.  Any rows marked\n         * `exporterEnableExporting: false` will not be exported\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {string} rowTypes which rows to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         * @param {string} colTypes which columns to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         * @param {boolean} applyCellFilters whether or not to get the display value or the raw value of the data\n         */\n        getData: function (grid, rowTypes, colTypes, applyCellFilters) {\n          var data = [];\n          var rows;\n          var columns;\n\n          switch ( rowTypes ) {\n            case uiGridExporterConstants.ALL:\n              rows = grid.rows;\n              break;\n            case uiGridExporterConstants.VISIBLE:\n              rows = grid.getVisibleRows();\n              break;\n            case uiGridExporterConstants.SELECTED:\n              if ( grid.api.selection ){\n                rows = grid.api.selection.getSelectedGridRows();\n              } else {\n                gridUtil.logError('selection feature must be enabled to allow selected rows to be exported');\n              }\n              break;\n          }\n\n          if ( colTypes === uiGridExporterConstants.ALL ){\n            columns = grid.columns;\n          } else {\n            var leftColumns = grid.renderContainers.left ? grid.renderContainers.left.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n            var bodyColumns = grid.renderContainers.body ? grid.renderContainers.body.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n            var rightColumns = grid.renderContainers.right ? grid.renderContainers.right.visibleColumnCache.filter( function( column ){ return column.visible; } ) : [];\n\n            columns = leftColumns.concat(bodyColumns,rightColumns);\n          }\n\n          rows.forEach( function( row, index ) {\n\n            if (row.exporterEnableExporting !== false) {\n              var extractedRow = [];\n\n\n              columns.forEach( function( gridCol, index ) {\n              if ( (gridCol.visible || colTypes === uiGridExporterConstants.ALL ) &&\n                   gridCol.colDef.exporterSuppressExport !== true &&\n                   grid.options.exporterSuppressColumns.indexOf( gridCol.name ) === -1 ){\n                  var cellValue = applyCellFilters ? grid.getCellDisplayValue( row, gridCol ) : grid.getCellValue( row, gridCol );\n                  var extractedField = { value: grid.options.exporterFieldCallback( grid, row, gridCol, cellValue ) };\n                  if ( gridCol.colDef.exporterPdfAlign ) {\n                    extractedField.alignment = gridCol.colDef.exporterPdfAlign;\n                  }\n                  extractedRow.push(extractedField);\n                }\n              });\n\n              data.push(extractedRow);\n            }\n          });\n\n          return data;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name formatAsCSV\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Formats the column headers and data as a CSV,\n         * and sends that data to the user\n         * @param {array} exportColumnHeaders an array of column headers,\n         * where each header is an object with name, width and maybe alignment\n         * @param {array} exportData an array of rows, where each row is\n         * an array of column data\n         * @returns {string} csv the formatted csv as a string\n         */\n        formatAsCsv: function (exportColumnHeaders, exportData, separator) {\n          var self = this;\n\n          var bareHeaders = exportColumnHeaders.map(function(header){return { value: header.displayName };});\n\n          var csv = bareHeaders.length > 0 ? (self.formatRowAsCsv(this, separator)(bareHeaders) + '\\n') : '';\n\n          csv += exportData.map(this.formatRowAsCsv(this, separator)).join('\\n');\n\n          return csv;\n        },\n\n        /**\n         * @ngdoc function\n         * @name formatRowAsCsv\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Renders a single field as a csv field, including\n         * quotes around the value\n         * @param {exporterService} exporter pass in exporter\n         * @param {array} row the row to be turned into a csv string\n         * @returns {string} a csv-ified version of the row\n         */\n        formatRowAsCsv: function (exporter, separator) {\n          return function (row) {\n            return row.map(exporter.formatFieldAsCsv).join(separator);\n          };\n        },\n\n        /**\n         * @ngdoc function\n         * @name formatFieldAsCsv\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Renders a single field as a csv field, including\n         * quotes around the value\n         * @param {field} field the field to be turned into a csv string,\n         * may be of any type\n         * @returns {string} a csv-ified version of the field\n         */\n        formatFieldAsCsv: function (field) {\n          if (field.value == null) { // we want to catch anything null-ish, hence just == not ===\n            return '';\n          }\n          if (typeof(field.value) === 'number') {\n            return field.value;\n          }\n          if (typeof(field.value) === 'boolean') {\n            return (field.value ? 'TRUE' : 'FALSE') ;\n          }\n          if (typeof(field.value) === 'string') {\n            return '\"' + field.value.replace(/\"/g,'\"\"') + '\"';\n          }\n\n          return JSON.stringify(field.value);\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name isIE\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Checks whether current browser is IE and returns it's version if it is\n        */\n        isIE: function () {\n          var match = navigator.userAgent.search(/(?:Edge|MSIE|Trident\\/.*; rv:)/);\n          var isIE = false;\n\n          if (match !== -1) {\n            isIE = true;\n          }\n\n          return isIE;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name downloadFile\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Triggers download of a csv file.  Logic provided\n         * by @cssensei (from his colleagues at https://github.com/ifeelgoods) in issue #2391\n         * @param {string} fileName the filename we'd like our file to be\n         * given\n         * @param {string} csvContent the csv content that we'd like to\n         * download as a file\n         * @param {boolean} exporterOlderExcelCompatibility whether or not we put a utf-16 BOM on the from (\\uFEFF)\n         */\n        downloadFile: function (fileName, csvContent, exporterOlderExcelCompatibility) {\n          var D = document;\n          var a = D.createElement('a');\n          var strMimeType = 'application/octet-stream;charset=utf-8';\n          var rawFile;\n          var ieVersion;\n\n          ieVersion = this.isIE();\n          if (ieVersion && ieVersion < 10) {\n            var frame = D.createElement('iframe');\n            document.body.appendChild(frame);\n\n            frame.contentWindow.document.open(\"text/html\", \"replace\");\n            frame.contentWindow.document.write('sep=,\\r\\n' + csvContent);\n            frame.contentWindow.document.close();\n            frame.contentWindow.focus();\n            frame.contentWindow.document.execCommand('SaveAs', true, fileName);\n\n            document.body.removeChild(frame);\n            return true;\n          }\n\n          // IE10+\n          if (navigator.msSaveBlob) {\n            return navigator.msSaveOrOpenBlob(\n              new Blob(\n                [exporterOlderExcelCompatibility ? \"\\uFEFF\" : '', csvContent],\n                { type: strMimeType } ),\n              fileName\n            );\n          }\n\n          //html5 A[download]\n          if ('download' in a) {\n            var blob = new Blob(\n              [exporterOlderExcelCompatibility ? \"\\uFEFF\" : '', csvContent],\n              { type: strMimeType }\n            );\n            rawFile = URL.createObjectURL(blob);\n            a.setAttribute('download', fileName);\n          } else {\n            rawFile = 'data:' + strMimeType + ',' + encodeURIComponent(csvContent);\n            a.setAttribute('target', '_blank');\n          }\n\n          a.href = rawFile;\n          a.setAttribute('style', 'display:none;');\n          D.body.appendChild(a);\n          setTimeout(function() {\n            if (a.click) {\n              a.click();\n              // Workaround for Safari 5\n            } else if (document.createEvent) {\n              var eventObj = document.createEvent('MouseEvents');\n              eventObj.initEvent('click', true, true);\n              a.dispatchEvent(eventObj);\n            }\n            D.body.removeChild(a);\n\n          }, this.delay);\n        },\n\n        /**\n         * @ngdoc function\n         * @name pdfExport\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Exports rows from the grid in pdf format,\n         * the data exported is selected based on the provided options.\n         * Note that this function has a dependency on pdfMake, which must\n         * be installed.  The resulting pdf opens in a new\n         * browser window.\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {string} rowTypes which rows to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         * @param {string} colTypes which columns to export, valid values are\n         * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,\n         * uiGridExporterConstants.SELECTED\n         */\n        pdfExport: function (grid, rowTypes, colTypes) {\n          var self = this;\n          this.loadAllDataIfNeeded(grid, rowTypes, colTypes).then(function () {\n            var exportColumnHeaders = self.getColumnHeaders(grid, colTypes);\n            var exportData = self.getData(grid, rowTypes, colTypes);\n            var docDefinition = self.prepareAsPdf(grid, exportColumnHeaders, exportData);\n\n            if (self.isIE() || navigator.appVersion.indexOf(\"Edge\") !== -1) {\n              self.downloadPDF(grid.options.exporterPdfFilename, docDefinition);\n            } else {\n              pdfMake.createPdf(docDefinition).open();\n            }\n          });\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name downloadPdf\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Generates and retrieves the pdf as a blob, then downloads\n         * it as a file.  Only used in IE, in all other browsers we use the native\n         * pdfMake.open function to just open the PDF\n         * @param {string} fileName the filename to give to the pdf, can be set\n         * through exporterPdfFilename\n         * @param {object} docDefinition a pdf docDefinition that we can generate\n         * and get a blob from\n         */\n        downloadPDF: function (fileName, docDefinition) {\n          var D = document;\n          var a = D.createElement('a');\n          var strMimeType = 'application/octet-stream;charset=utf-8';\n          var rawFile;\n          var ieVersion;\n\n          ieVersion = this.isIE(); // This is now a boolean value\n          var doc = pdfMake.createPdf(docDefinition);\n          var blob;\n\n          doc.getBuffer( function (buffer) {\n            blob = new Blob([buffer]);\n\n            // IE10+\n            if (navigator.msSaveBlob) {\n              return navigator.msSaveBlob(\n                blob, fileName\n              );\n            }\n\n            // Previously:  && ieVersion < 10\n            // ieVersion now returns a boolean for the\n            // sake of sanity. We just check `msSaveBlob` first.\n            if (ieVersion) {\n              var frame = D.createElement('iframe');\n              document.body.appendChild(frame);\n\n              frame.contentWindow.document.open(\"text/html\", \"replace\");\n              frame.contentWindow.document.write(blob);\n              frame.contentWindow.document.close();\n              frame.contentWindow.focus();\n              frame.contentWindow.document.execCommand('SaveAs', true, fileName);\n\n              document.body.removeChild(frame);\n              return true;\n            }\n          });\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name renderAsPdf\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Renders the data into a pdf, and opens that pdf.\n         *\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {array} exportColumnHeaders an array of column headers,\n         * where each header is an object with name, width and maybe alignment\n         * @param {array} exportData an array of rows, where each row is\n         * an array of column data\n         * @returns {object} a pdfMake format document definition, ready\n         * for generation\n         */\n        prepareAsPdf: function(grid, exportColumnHeaders, exportData) {\n          var headerWidths = this.calculatePdfHeaderWidths( grid, exportColumnHeaders );\n\n          var headerColumns = exportColumnHeaders.map( function( header ) {\n            return { text: header.displayName, style: 'tableHeader' };\n          });\n\n          var stringData = exportData.map(this.formatRowAsPdf(this));\n\n          var allData = [headerColumns].concat(stringData);\n\n          var docDefinition = {\n            pageOrientation: grid.options.exporterPdfOrientation,\n            pageSize: grid.options.exporterPdfPageSize,\n            content: [{\n              style: 'tableStyle',\n              table: {\n                headerRows: 1,\n                widths: headerWidths,\n                body: allData\n              }\n            }],\n            styles: {\n              tableStyle: grid.options.exporterPdfTableStyle,\n              tableHeader: grid.options.exporterPdfTableHeaderStyle\n            },\n            defaultStyle: grid.options.exporterPdfDefaultStyle\n          };\n\n          if ( grid.options.exporterPdfLayout ){\n            docDefinition.layout = grid.options.exporterPdfLayout;\n          }\n\n          if ( grid.options.exporterPdfHeader ){\n            docDefinition.header = grid.options.exporterPdfHeader;\n          }\n\n          if ( grid.options.exporterPdfFooter ){\n            docDefinition.footer = grid.options.exporterPdfFooter;\n          }\n\n          if ( grid.options.exporterPdfCustomFormatter ){\n            docDefinition = grid.options.exporterPdfCustomFormatter( docDefinition );\n          }\n          return docDefinition;\n\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name calculatePdfHeaderWidths\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Determines the column widths base on the\n         * widths we got from the grid.  If the column is drawn\n         * then we have a drawnWidth.  If the column is not visible\n         * then we have '*', 'x%' or a width.  When columns are\n         * not visible they don't contribute to the overall gridWidth,\n         * so we need to adjust to allow for extra columns\n         *\n         * Our basic heuristic is to take the current gridWidth, plus\n         * numeric columns and call this the base gridwidth.\n         *\n         * To that we add 100 for any '*' column, and x% of the base gridWidth\n         * for any column that is a %\n         *\n         * @param {Grid} grid the grid from which data should be exported\n         * @param {array} exportHeaders array of header information\n         * @returns {object} an array of header widths\n         */\n        calculatePdfHeaderWidths: function ( grid, exportHeaders ) {\n          var baseGridWidth = 0;\n          exportHeaders.forEach( function(value){\n            if (typeof(value.width) === 'number'){\n              baseGridWidth += value.width;\n            }\n          });\n\n          var extraColumns = 0;\n          exportHeaders.forEach( function(value){\n            if (value.width === '*'){\n              extraColumns += 100;\n            }\n            if (typeof(value.width) === 'string' && value.width.match(/(\\d)*%/)) {\n              var percent = parseInt(value.width.match(/(\\d)*%/)[0]);\n\n              value.width = baseGridWidth * percent / 100;\n              extraColumns += value.width;\n            }\n          });\n\n          var gridWidth = baseGridWidth + extraColumns;\n\n          return exportHeaders.map(function( header ) {\n            return header.width === '*' ? header.width : header.width * grid.options.exporterPdfMaxGridWidth / gridWidth;\n          });\n\n        },\n\n        /**\n         * @ngdoc function\n         * @name formatRowAsPdf\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Renders a row in a format consumable by PDF,\n         * mainly meaning casting everything to a string\n         * @param {exporterService} exporter pass in exporter\n         * @param {array} row the row to be turned into a csv string\n         * @returns {string} a csv-ified version of the row\n         */\n        formatRowAsPdf: function ( exporter ) {\n          return function( row ) {\n            return row.map(exporter.formatFieldAsPdfString);\n          };\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name formatFieldAsCsv\n         * @methodOf  ui.grid.exporter.service:uiGridExporterService\n         * @description Renders a single field as a pdf-able field, which\n         * is different from a csv field only in that strings don't have quotes\n         * around them\n         * @param {field} field the field to be turned into a pdf string,\n         * may be of any type\n         * @returns {string} a string-ified version of the field\n         */\n        formatFieldAsPdfString: function (field) {\n          var returnVal;\n          if (field.value == null) { // we want to catch anything null-ish, hence just == not ===\n            returnVal = '';\n          } else if (typeof(field.value) === 'number') {\n            returnVal = field.value.toString();\n          } else if (typeof(field.value) === 'boolean') {\n            returnVal = (field.value ? 'TRUE' : 'FALSE') ;\n          } else if (typeof(field.value) === 'string') {\n            returnVal = field.value.replace(/\"/g,'\"\"');\n          } else {\n            returnVal = JSON.stringify(field.value).replace(/^\"/,'').replace(/\"$/,'');\n          }\n\n          if (field.alignment && typeof(field.alignment) === 'string' ){\n            returnVal = { text: returnVal, alignment: field.alignment };\n          }\n\n          return returnVal;\n        }\n      };\n\n      return service;\n\n    }\n  ]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.exporter.directive:uiGridExporter\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds exporter features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.exporter']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.gridOptions = {\n        enableGridMenu: true,\n        exporterMenuCsv: false,\n        columnDefs: [\n          {name: 'name', enableCellEdit: true},\n          {name: 'title', enableCellEdit: true}\n        ],\n        data: $scope.data\n      };\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"gridOptions\" ui-grid-exporter></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridExporter', ['uiGridExporterConstants', 'uiGridExporterService', 'gridUtil', '$compile',\n    function (uiGridExporterConstants, uiGridExporterService, gridUtil, $compile) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        link: function ($scope, $elm, $attrs, uiGridCtrl) {\n          uiGridExporterService.initializeGrid(uiGridCtrl.grid);\n          uiGridCtrl.grid.exporter.$scope = $scope;\n        }\n      };\n    }\n  ]);\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.grouping\n   * @description\n   *\n   * # ui.grid.grouping\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Beta</strong> This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs.</div>\n   *\n   * This module provides grouping of rows based on the data in them, similar\n   * in concept to excel grouping.  You can group multiple columns, resulting in\n   * nested grouping.\n   *\n   * In concept this feature is similar to sorting + grid footer/aggregation, it\n   * sorts the data based on the grouped columns, then creates group rows that\n   * reflect a break in the data.  Each of those group rows can have aggregations for\n   * the data within that group.\n   *\n   * This feature leverages treeBase to provide the tree functionality itself,\n   * the key thing this feature does therefore is to set treeLevels on the rows\n   * and insert the group headers.\n   *\n   * Design information:\n   * -------------------\n   *\n   * Each column will get new menu items - group by, and aggregate by.  Group by\n   * will cause this column to be sorted (if not already), and will move this column\n   * to the front of the sorted columns (i.e. grouped columns take precedence over\n   * sorted columns).  It will respect the sort order already set if there is one,\n   * and it will allow the sorting logic to change that sort order, it just forces\n   * the column to the front of the sorting.  You can group by multiple columns, the\n   * logic will add this column to the sorting after any already grouped columns.\n   *\n   * Once a grouping is defined, grouping logic is added to the rowsProcessors.  This\n   * will process the rows, identifying a break in the data value, and inserting a grouping row.\n   * Grouping rows have specific attributes on them:\n   *\n   *  - internalRow = true: tells us that this isn't a real row, so we can ignore it\n   *    from any processing that it looking at core data rows.  This is used by the core\n   *    logic (or will be one day), as it's not grouping specific\n   *  - groupHeader = true: tells us this is a groupHeader.  This is used by the grouping logic\n   *    to know if this is a groupHeader row or not\n   *\n   * Since the logic is baked into the rowsProcessors, it should get triggered whenever\n   * row order or filtering or anything like that is changed.  In order to avoid the row instantiation\n   * time, and to preserve state across invocations, we hold a cache of the rows that we created\n   * last time, and we use them again this time if we can.\n   *\n   * By default rows are collapsed, which means all data rows have their visible property\n   * set to false, and only level 0 group rows are set to visible.\n   *\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.grouping\"></div>\n   */\n\n  var module = angular.module('ui.grid.grouping', ['ui.grid', 'ui.grid.treeBase']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.grouping.constant:uiGridGroupingConstants\n   *\n   *  @description constants available in grouping module, this includes\n   *  all the constants declared in the treeBase module (these are manually copied\n   *  as there isn't an easy way to include constants in another constants file, and\n   *  we don't want to make users include treeBase)\n   *\n   */\n  module.constant('uiGridGroupingConstants', {\n    featureName: \"grouping\",\n    rowHeaderColName: 'treeBaseRowHeaderCol',\n    EXPANDED: 'expanded',\n    COLLAPSED: 'collapsed',\n    aggregation: {\n      COUNT: 'count',\n      SUM: 'sum',\n      MAX: 'max',\n      MIN: 'min',\n      AVG: 'avg'\n    }\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.grouping.service:uiGridGroupingService\n   *\n   *  @description Services for grouping features\n   */\n  module.service('uiGridGroupingService', ['$q', 'uiGridGroupingConstants', 'gridUtil', 'rowSorter', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants', 'uiGridTreeBaseService',\n  function ($q, uiGridGroupingConstants, gridUtil, rowSorter, GridRow, gridClassFactory, i18nService, uiGridConstants, uiGridTreeBaseService) {\n\n    var service = {\n\n      initializeGrid: function (grid, $scope) {\n        uiGridTreeBaseService.initializeGrid( grid, $scope );\n\n        //add feature namespace and any properties to grid for needed\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.grouping.grid:grouping\n         *\n         *  @description Grid properties and functions added for grouping\n         */\n        grid.grouping = {};\n\n        /**\n         *  @ngdoc property\n         *  @propertyOf ui.grid.grouping.grid:grouping\n         *  @name groupHeaderCache\n         *\n         *  @description Cache that holds the group header rows we created last time, we'll\n         *  reuse these next time, not least because they hold our expanded states.\n         *\n         *  We need to take care with these that they don't become a memory leak, we\n         *  create a new cache each time using the values from the old cache.  This works\n         *  so long as we're creating group rows for invisible rows as well.\n         *\n         *  The cache is a nested hash, indexed on the value we grouped by.  So if we\n         *  grouped by gender then age, we'd maybe have something like:\n         *  ```\n         *    {\n         *      male: {\n         *        row: <pointer to the old row>,\n         *        children: {\n         *          22: { row: <pointer to the old row> },\n         *          31: { row: <pointer to the old row> }\n         *      },\n         *      female: {\n         *        row: <pointer to the old row>,\n         *        children: {\n         *          28: { row: <pointer to the old row> },\n         *          55: { row: <pointer to the old row> }\n         *      }\n         *    }\n         *  ```\n         *\n         *  We create new rows for any missing rows, this means that they come in as collapsed.\n         *\n         */\n        grid.grouping.groupHeaderCache = {};\n\n        service.defaultGridOptions(grid.options);\n\n        grid.registerRowsProcessor(service.groupRows, 400);\n\n        grid.registerColumnBuilder( service.groupingColumnBuilder);\n\n        grid.registerColumnsProcessor(service.groupingColumnProcessor, 400);\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.grouping.api:PublicApi\n         *\n         *  @description Public Api for grouping feature\n         */\n        var publicApi = {\n          events: {\n            grouping: {\n              /**\n               * @ngdoc event\n               * @eventOf ui.grid.grouping.api:PublicApi\n               * @name aggregationChanged\n               * @description raised whenever aggregation is changed, added or removed from a column\n               *\n               * <pre>\n               *      gridApi.grouping.on.aggregationChanged(scope,function(col){})\n               * </pre>\n               * @param {gridCol} col the column which on which aggregation changed. The aggregation\n               * type is available as `col.treeAggregation.type`\n               */\n              aggregationChanged: {},\n              /**\n               * @ngdoc event\n               * @eventOf ui.grid.grouping.api:PublicApi\n               * @name groupingChanged\n               * @description raised whenever the grouped columns changes\n               *\n               * <pre>\n               *      gridApi.grouping.on.groupingChanged(scope,function(col){})\n               * </pre>\n               * @param {gridCol} col the column which on which grouping changed. The new grouping is\n               * available as `col.grouping`\n               */\n              groupingChanged: {}\n            }\n          },\n          methods: {\n            grouping: {\n              /**\n               * @ngdoc function\n               * @name getGrouping\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Get the grouping configuration for this grid,\n               * used by the saveState feature.  Adds expandedState to the information\n               * provided by the internal getGrouping, and removes any aggregations that have a source\n               * of grouping (i.e. will be automatically reapplied when we regroup the column)\n               * Returned grouping is an object\n               *   `{ grouping: groupArray, treeAggregations: aggregateArray, expandedState: hash }`\n               * where grouping contains an array of objects:\n               *   `{ field: column.field, colName: column.name, groupPriority: column.grouping.groupPriority }`\n               * and aggregations contains an array of objects:\n               *   `{ field: column.field, colName: column.name, aggregation: column.grouping.aggregation }`\n               * and expandedState is a hash of the currently expanded nodes\n               *\n               * The groupArray will be sorted by groupPriority.\n               *\n               * @param {boolean} getExpanded whether or not to return the expanded state\n               * @returns {object} grouping configuration\n               */\n              getGrouping: function ( getExpanded ) {\n                var grouping = service.getGrouping(grid);\n\n                grouping.grouping.forEach( function( group ) {\n                  group.colName = group.col.name;\n                  delete group.col;\n                });\n\n                grouping.aggregations.forEach( function( aggregation ) {\n                  aggregation.colName = aggregation.col.name;\n                  delete aggregation.col;\n                });\n\n                grouping.aggregations = grouping.aggregations.filter( function( aggregation ){\n                  return !aggregation.aggregation.source || aggregation.aggregation.source !== 'grouping';\n                });\n\n                if ( getExpanded ){\n                  grouping.rowExpandedStates = service.getRowExpandedStates( grid.grouping.groupingHeaderCache );\n                }\n\n                return grouping;\n              },\n\n              /**\n               * @ngdoc function\n               * @name setGrouping\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Set the grouping configuration for this grid,\n               * used by the saveState feature, but can also be used by any\n               * user to specify a combined grouping and aggregation configuration\n               * @param {object} config the config you want to apply, in the format\n               * provided out by getGrouping\n               */\n              setGrouping: function ( config ) {\n                service.setGrouping(grid, config);\n              },\n\n              /**\n               * @ngdoc function\n               * @name groupColumn\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Adds this column to the existing grouping, at the end of the priority order.\n               * If the column doesn't have a sort, adds one, by default ASC\n               *\n               * This column will move to the left of any non-group columns, the\n               * move is handled in a columnProcessor, so gets called as part of refresh\n               *\n               * @param {string} columnName the name of the column we want to group\n               */\n              groupColumn: function( columnName ) {\n                var column = grid.getColumn(columnName);\n                service.groupColumn(grid, column);\n              },\n\n              /**\n               * @ngdoc function\n               * @name ungroupColumn\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Removes the groupPriority from this column.  If the\n               * column was previously aggregated the aggregation will come back.\n               * The sort will remain.\n               *\n               * This column will move to the right of any other group columns, the\n               * move is handled in a columnProcessor, so gets called as part of refresh\n               *\n               * @param {string} columnName the name of the column we want to ungroup\n               */\n              ungroupColumn: function( columnName ) {\n                var column = grid.getColumn(columnName);\n                service.ungroupColumn(grid, column);\n              },\n\n              /**\n               * @ngdoc function\n               * @name clearGrouping\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Clear any grouped columns and any aggregations.  Doesn't remove sorting,\n               * as we don't know whether that sorting was added by grouping or was there beforehand\n               *\n               */\n              clearGrouping: function() {\n                service.clearGrouping(grid);\n              },\n\n              /**\n               * @ngdoc function\n               * @name aggregateColumn\n               * @methodOf  ui.grid.grouping.api:PublicApi\n               * @description Sets the aggregation type on a column, if the\n               * column is currently grouped then it removes the grouping first.\n               * If the aggregationDef is null then will result in the aggregation\n               * being removed\n               *\n               * @param {string} columnName the column we want to aggregate\n               * @param {string} or {function} aggregationDef one of the recognised types\n               * from uiGridGroupingConstants or a custom aggregation function.\n               * @param {string} aggregationLabel (optional) The label to use for this aggregation.\n               */\n              aggregateColumn: function( columnName, aggregationDef, aggregationLabel){\n                var column = grid.getColumn(columnName);\n                service.aggregateColumn( grid, column, aggregationDef, aggregationLabel);\n              }\n\n            }\n          }\n        };\n\n        grid.api.registerEventsFromObject(publicApi.events);\n\n        grid.api.registerMethodsFromObject(publicApi.methods);\n\n        grid.api.core.on.sortChanged( $scope, service.tidyPriorities);\n\n      },\n\n      defaultGridOptions: function (gridOptions) {\n        //default option to true unless it was explicitly set to false\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.grouping.api:GridOptions\n         *\n         *  @description GridOptions for grouping feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enableGrouping\n         *  @propertyOf  ui.grid.grouping.api:GridOptions\n         *  @description Enable row grouping for entire grid.\n         *  <br/>Defaults to true\n         */\n        gridOptions.enableGrouping = gridOptions.enableGrouping !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name groupingShowCounts\n         *  @propertyOf  ui.grid.grouping.api:GridOptions\n         *  @description shows counts on the groupHeader rows. Not that if you are using a cellFilter or a\n         *  sortingAlgorithm which relies on a specific format or data type, showing counts may cause that\n         *  to break, since the group header rows will always be a string with groupingShowCounts enabled.\n         *  <br/>Defaults to true except on columns of type 'date'\n         */\n        gridOptions.groupingShowCounts = gridOptions.groupingShowCounts !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name groupingNullLabel\n         *  @propertyOf  ui.grid.grouping.api:GridOptions\n         *  @description The string to use for the grouping header row label on rows which contain a null or undefined value in the grouped column.\n         *  <br/>Defaults to \"Null\"\n         */\n        gridOptions.groupingNullLabel = typeof(gridOptions.groupingNullLabel) === 'undefined' ? 'Null' : gridOptions.groupingNullLabel;\n\n        /**\n         *  @ngdoc object\n         *  @name enableGroupHeaderSelection\n         *  @propertyOf  ui.grid.grouping.api:GridOptions\n         *  @description Allows group header rows to be selected.\n         *  <br/>Defaults to false\n         */\n        gridOptions.enableGroupHeaderSelection = gridOptions.enableGroupHeaderSelection === true;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name groupingColumnBuilder\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Sets the grouping defaults based on the columnDefs\n       *\n       * @param {object} colDef columnDef we're basing on\n       * @param {GridCol} col the column we're to update\n       * @param {object} gridOptions the options we should use\n       * @returns {promise} promise for the builder - actually we do it all inline so it's immediately resolved\n       */\n      groupingColumnBuilder: function (colDef, col, gridOptions) {\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.grouping.api:ColumnDef\n         *\n         *  @description ColumnDef for grouping feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enableGrouping\n         *  @propertyOf  ui.grid.grouping.api:ColumnDef\n         *  @description Enable grouping on this column\n         *  <br/>Defaults to true.\n         */\n        if (colDef.enableGrouping === false){\n          return;\n        }\n\n        /**\n         *  @ngdoc object\n         *  @name grouping\n         *  @propertyOf  ui.grid.grouping.api:ColumnDef\n         *  @description Set the grouping for a column.  Format is:\n         *  ```\n         *    {\n         *      groupPriority: <number, starts at 0, if less than 0 or undefined then we're aggregating in this column>\n         *    }\n         *  ```\n         *\n         *  **Note that aggregation used to be included in grouping, but is now separately set on the column via treeAggregation\n         *  setting in treeBase**\n         *\n         *  We group in the priority order given, this will also put these columns to the high order of the sort irrespective\n         *  of the sort priority given them.  If there is no sort defined then we sort ascending, if there is a sort defined then\n         *  we use that sort.\n         *\n         *  If the groupPriority is undefined or less than 0, then we expect to be aggregating, and we look at the\n         *  aggregation types to determine what sort of aggregation we can do.  Values are in the constants file, but\n         *  include SUM, COUNT, MAX, MIN\n         *\n         *  groupPriorities should generally be sequential, if they're not then the next time getGrouping is called\n         *  we'll renumber them to be sequential.\n         *  <br/>Defaults to undefined.\n         */\n\n        if ( typeof(col.grouping) === 'undefined' && typeof(colDef.grouping) !== 'undefined') {\n          col.grouping = angular.copy(colDef.grouping);\n          if ( typeof(col.grouping.groupPriority) !== 'undefined' && col.grouping.groupPriority > -1 ){\n            col.treeAggregationFn = uiGridTreeBaseService.nativeAggregations()[uiGridGroupingConstants.aggregation.COUNT].aggregationFn;\n            col.treeAggregationFinalizerFn = service.groupedFinalizerFn;\n          }\n        } else if (typeof(col.grouping) === 'undefined'){\n          col.grouping = {};\n        }\n\n        if (typeof(col.grouping) !== 'undefined' && typeof(col.grouping.groupPriority) !== 'undefined' && col.grouping.groupPriority >= 0){\n          col.suppressRemoveSort = true;\n        }\n\n        var groupColumn = {\n          name: 'ui.grid.grouping.group',\n          title: i18nService.get().grouping.group,\n          icon: 'ui-grid-icon-indent-right',\n          shown: function () {\n            return typeof(this.context.col.grouping) === 'undefined' ||\n                   typeof(this.context.col.grouping.groupPriority) === 'undefined' ||\n                   this.context.col.grouping.groupPriority < 0;\n          },\n          action: function () {\n            service.groupColumn( this.context.col.grid, this.context.col );\n          }\n        };\n\n        var ungroupColumn = {\n          name: 'ui.grid.grouping.ungroup',\n          title: i18nService.get().grouping.ungroup,\n          icon: 'ui-grid-icon-indent-left',\n          shown: function () {\n            return typeof(this.context.col.grouping) !== 'undefined' &&\n                   typeof(this.context.col.grouping.groupPriority) !== 'undefined' &&\n                   this.context.col.grouping.groupPriority >= 0;\n          },\n          action: function () {\n            service.ungroupColumn( this.context.col.grid, this.context.col );\n          }\n        };\n\n        var aggregateRemove = {\n          name: 'ui.grid.grouping.aggregateRemove',\n          title: i18nService.get().grouping.aggregate_remove,\n          shown: function () {\n            return typeof(this.context.col.treeAggregationFn) !== 'undefined';\n          },\n          action: function () {\n            service.aggregateColumn( this.context.col.grid, this.context.col, null);\n          }\n        };\n\n        // generic adder for the aggregation menus, which follow a pattern\n        var addAggregationMenu = function(type, title){\n          title = title || i18nService.get().grouping['aggregate_' + type] || type;\n          var menuItem = {\n            name: 'ui.grid.grouping.aggregate' + type,\n            title: title,\n            shown: function () {\n              return typeof(this.context.col.treeAggregation) === 'undefined' ||\n                     typeof(this.context.col.treeAggregation.type) === 'undefined' ||\n                     this.context.col.treeAggregation.type !== type;\n            },\n            action: function () {\n              service.aggregateColumn( this.context.col.grid, this.context.col, type);\n            }\n          };\n\n          if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.aggregate' + type)) {\n            col.menuItems.push(menuItem);\n          }\n        };\n\n        /**\n         *  @ngdoc object\n         *  @name groupingShowGroupingMenu\n         *  @propertyOf  ui.grid.grouping.api:ColumnDef\n         *  @description Show the grouping (group and ungroup items) menu on this column\n         *  <br/>Defaults to true.\n         */\n        if ( col.colDef.groupingShowGroupingMenu !== false ){\n          if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.group')) {\n            col.menuItems.push(groupColumn);\n          }\n\n          if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.ungroup')) {\n            col.menuItems.push(ungroupColumn);\n          }\n        }\n\n\n        /**\n         *  @ngdoc object\n         *  @name groupingShowAggregationMenu\n         *  @propertyOf  ui.grid.grouping.api:ColumnDef\n         *  @description Show the aggregation menu on this column\n         *  <br/>Defaults to true.\n         */\n        if ( col.colDef.groupingShowAggregationMenu !== false ){\n          angular.forEach(uiGridTreeBaseService.nativeAggregations(), function(aggregationDef, name){\n            addAggregationMenu(name);\n          });\n          angular.forEach(gridOptions.treeCustomAggregations, function(aggregationDef, name){\n            addAggregationMenu(name, aggregationDef.menuTitle);\n          });\n\n          if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.aggregateRemove')) {\n            col.menuItems.push(aggregateRemove);\n          }\n        }\n      },\n\n\n\n\n      /**\n       * @ngdoc function\n       * @name groupingColumnProcessor\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Moves the columns around based on which are grouped\n       *\n       * @param {array} columns the columns to consider rendering\n       * @param {array} rows the grid rows, which we don't use but are passed to us\n       * @returns {array} updated columns array\n       */\n      groupingColumnProcessor: function( columns, rows ) {\n        var grid = this;\n\n        columns = service.moveGroupColumns(this, columns, rows);\n        return columns;\n      },\n\n      /**\n       * @ngdoc function\n       * @name groupedFinalizerFn\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Used on group columns to display the rendered value and optionally\n       * display the count of rows.\n       *\n       * @param {aggregation} the aggregation entity for a grouped column\n       */\n      groupedFinalizerFn: function( aggregation ){\n        var col = this;\n\n        if ( typeof(aggregation.groupVal) !== 'undefined') {\n          aggregation.rendered = aggregation.groupVal;\n          if ( col.grid.options.groupingShowCounts && col.colDef.type !== 'date' ){\n            aggregation.rendered += (' (' + aggregation.value + ')');\n          }\n        } else {\n          aggregation.rendered = null;\n        }\n      },\n\n      /**\n       * @ngdoc function\n       * @name moveGroupColumns\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Moves the column order so that the grouped columns are lined up\n       * to the left (well, unless you're RTL, then it's the right).  By doing this in\n       * the columnsProcessor, we make it transient - when the column is ungrouped it'll\n       * go back to where it was.\n       *\n       * Does nothing if the option `moveGroupColumns` is set to false.\n       *\n       * @param {Grid} grid grid object\n       * @param {array} columns the columns that we should process/move\n       * @param {array} rows the grid rows\n       * @returns {array} updated columns\n       */\n      moveGroupColumns: function( grid, columns, rows ){\n        if ( grid.options.moveGroupColumns === false){\n          return columns;\n        }\n\n        columns.forEach( function(column, index){\n          // position used to make stable sort in moveGroupColumns\n          column.groupingPosition = index;\n        });\n\n        columns.sort(function(a, b){\n          var a_group, b_group;\n          if (a.isRowHeader){\n            a_group = -1000;\n          }\n          else if ( typeof(a.grouping) === 'undefined' || typeof(a.grouping.groupPriority) === 'undefined' || a.grouping.groupPriority < 0){\n            a_group = null;\n          } else {\n            a_group = a.grouping.groupPriority;\n          }\n\n          if (b.isRowHeader){\n            b_group = -1000;\n          }\n          else if ( typeof(b.grouping) === 'undefined' || typeof(b.grouping.groupPriority) === 'undefined' || b.grouping.groupPriority < 0){\n            b_group = null;\n          } else {\n            b_group = b.grouping.groupPriority;\n          }\n\n          // groups get sorted to the top\n          if ( a_group !== null && b_group === null) { return -1; }\n          if ( b_group !== null && a_group === null) { return 1; }\n          if ( a_group !== null && b_group !== null) {return a_group - b_group; }\n\n          return a.groupingPosition - b.groupingPosition;\n        });\n\n        columns.forEach( function(column, index) {\n          delete column.groupingPosition;\n        });\n\n        return columns;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name groupColumn\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Adds this column to the existing grouping, at the end of the priority order.\n       * If the column doesn't have a sort, adds one, by default ASC\n       *\n       * This column will move to the left of any non-group columns, the\n       * move is handled in a columnProcessor, so gets called as part of refresh\n       *\n       * @param {Grid} grid grid object\n       * @param {GridCol} column the column we want to group\n       */\n      groupColumn: function( grid, column){\n        if ( typeof(column.grouping) === 'undefined' ){\n          column.grouping = {};\n        }\n\n        // set the group priority to the next number in the hierarchy\n        var existingGrouping = service.getGrouping( grid );\n        column.grouping.groupPriority = existingGrouping.grouping.length;\n\n        // add sort if not present\n        if ( !column.sort ){\n          column.sort = { direction: uiGridConstants.ASC };\n        } else if ( typeof(column.sort.direction) === 'undefined' || column.sort.direction === null ){\n          column.sort.direction = uiGridConstants.ASC;\n        }\n\n        column.treeAggregation = { type: uiGridGroupingConstants.aggregation.COUNT, source: 'grouping' };\n        column.treeAggregationFn = uiGridTreeBaseService.nativeAggregations()[uiGridGroupingConstants.aggregation.COUNT].aggregationFn;\n        column.treeAggregationFinalizerFn = service.groupedFinalizerFn;\n\n        grid.api.grouping.raise.groupingChanged(column);\n        // This indirectly calls service.tidyPriorities( grid );\n        grid.api.core.raise.sortChanged(grid, grid.getColumnSorting());\n\n        grid.queueGridRefresh();\n      },\n\n\n       /**\n       * @ngdoc function\n       * @name ungroupColumn\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Removes the groupPriority from this column.  If the\n       * column was previously aggregated the aggregation will come back.\n       * The sort will remain.\n       *\n       * This column will move to the right of any other group columns, the\n       * move is handled in a columnProcessor, so gets called as part of refresh\n       *\n       * @param {Grid} grid grid object\n       * @param {GridCol} column the column we want to ungroup\n       */\n      ungroupColumn: function( grid, column){\n        if ( typeof(column.grouping) === 'undefined' ){\n          return;\n        }\n\n        delete column.grouping.groupPriority;\n        delete column.treeAggregation;\n        delete column.customTreeAggregationFinalizer;\n\n        service.tidyPriorities( grid );\n\n        grid.api.grouping.raise.groupingChanged(column);\n\n        grid.queueGridRefresh();\n      },\n\n      /**\n       * @ngdoc function\n       * @name aggregateColumn\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Sets the aggregation type on a column, if the\n       * column is currently grouped then it removes the grouping first.\n       *\n       * @param {Grid} grid grid object\n       * @param {GridCol} column the column we want to aggregate\n       * @param {string} one of the recognised types from uiGridGroupingConstants or one of the custom aggregations from gridOptions\n       */\n      aggregateColumn: function( grid, column, aggregationType){\n\n        if (typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){\n          service.ungroupColumn( grid, column );\n        }\n\n        var aggregationDef = {};\n        if ( typeof(grid.options.treeCustomAggregations[aggregationType]) !== 'undefined' ){\n          aggregationDef = grid.options.treeCustomAggregations[aggregationType];\n        } else if ( typeof(uiGridTreeBaseService.nativeAggregations()[aggregationType]) !== 'undefined' ){\n          aggregationDef = uiGridTreeBaseService.nativeAggregations()[aggregationType];\n        }\n\n        column.treeAggregation = { type: aggregationType, label:  i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label };\n        column.treeAggregationFn = aggregationDef.aggregationFn;\n        column.treeAggregationFinalizerFn = aggregationDef.finalizerFn;\n\n        grid.api.grouping.raise.aggregationChanged(column);\n\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name setGrouping\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Set the grouping based on a config object, used by the save state feature\n       * (more specifically, by the restore function in that feature )\n       *\n       * @param {Grid} grid grid object\n       * @param {object} config the config we want to set, same format as that returned by getGrouping\n       */\n      setGrouping: function ( grid, config ){\n        if ( typeof(config) === 'undefined' ){\n          return;\n        }\n\n        // first remove any existing grouping\n        service.clearGrouping(grid);\n\n        if ( config.grouping && config.grouping.length && config.grouping.length > 0 ){\n          config.grouping.forEach( function( group ) {\n            var col = grid.getColumn(group.colName);\n\n            if ( col ) {\n              service.groupColumn( grid, col );\n            }\n          });\n        }\n\n        if ( config.aggregations && config.aggregations.length ){\n          config.aggregations.forEach( function( aggregation ) {\n            var col = grid.getColumn(aggregation.colName);\n\n            if ( col ) {\n              service.aggregateColumn( grid, col, aggregation.aggregation.type );\n            }\n          });\n        }\n\n        if ( config.rowExpandedStates ){\n          service.applyRowExpandedStates( grid.grouping.groupingHeaderCache, config.rowExpandedStates );\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name clearGrouping\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Clear any grouped columns and any aggregations.  Doesn't remove sorting,\n       * as we don't know whether that sorting was added by grouping or was there beforehand\n       *\n       * @param {Grid} grid grid object\n       */\n      clearGrouping: function( grid ) {\n        var currentGrouping = service.getGrouping(grid);\n\n        if ( currentGrouping.grouping.length > 0 ){\n          currentGrouping.grouping.forEach( function( group ) {\n            if (!group.col){\n              // should have a group.colName if there's no col\n              group.col = grid.getColumn(group.colName);\n            }\n            service.ungroupColumn(grid, group.col);\n          });\n        }\n\n        if ( currentGrouping.aggregations.length > 0 ){\n          currentGrouping.aggregations.forEach( function( aggregation ){\n            if (!aggregation.col){\n              // should have a group.colName if there's no col\n              aggregation.col = grid.getColumn(aggregation.colName);\n            }\n            service.aggregateColumn(grid, aggregation.col, null);\n          });\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name tidyPriorities\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Renumbers groupPriority and sortPriority such that\n       * groupPriority is contiguous, and sortPriority either matches\n       * groupPriority (for group columns), and otherwise is contiguous and\n       * higher than groupPriority.\n       *\n       * @param {Grid} grid grid object\n       */\n      tidyPriorities: function( grid ){\n        // if we're called from sortChanged, grid is in this, not passed as param, the param can be a column or undefined\n        if ( ( typeof(grid) === 'undefined' || typeof(grid.grid) !== 'undefined' ) && typeof(this.grid) !== 'undefined' ) {\n          grid = this.grid;\n        }\n\n        var groupArray = [];\n        var sortArray = [];\n\n        grid.columns.forEach( function(column, index){\n          if ( typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){\n            groupArray.push(column);\n          } else if ( typeof(column.sort) !== 'undefined' && typeof(column.sort.priority) !== 'undefined' && column.sort.priority >= 0){\n            sortArray.push(column);\n          }\n        });\n\n        groupArray.sort(function(a, b){ return a.grouping.groupPriority - b.grouping.groupPriority; });\n        groupArray.forEach( function(column, index){\n          column.grouping.groupPriority = index;\n          column.suppressRemoveSort = true;\n          if ( typeof(column.sort) === 'undefined'){\n            column.sort = {};\n          }\n          column.sort.priority = index;\n        });\n\n        var i = groupArray.length;\n        sortArray.sort(function(a, b){ return a.sort.priority - b.sort.priority; });\n        sortArray.forEach( function(column, index){\n          column.sort.priority = i;\n          column.suppressRemoveSort = column.colDef.suppressRemoveSort;\n          i++;\n        });\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name groupRows\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description The rowProcessor that creates the groupHeaders (i.e. does\n       * the actual grouping).\n       *\n       * Assumes it is always called after the sorting processor, guaranteed by the priority setting\n       *\n       * Processes all the rows in order, inserting a groupHeader row whenever there is a change\n       * in value of a grouped row, based on the sortAlgorithm used for the column.  The group header row\n       * is looked up in the groupHeaderCache, and used from there if there is one. The entity is reset\n       * to {} if one is found.\n       *\n       * As it processes it maintains a `processingState` array. This records, for each level of grouping we're\n       * working with, the following information:\n       * ```\n       *   {\n       *     fieldName: name,\n       *     col: col,\n       *     initialised: boolean,\n       *     currentValue: value,\n       *     currentRow: gridRow,\n       *   }\n       * ```\n       * We look for changes in the currentValue at any of the levels.  Where we find a change we:\n       *\n       * - create a new groupHeader row in the array\n       *\n       * @param {array} renderableRows the rows we want to process, usually the output from the previous rowProcessor\n       * @returns {array} the updated rows, including our new group rows\n       */\n      groupRows: function( renderableRows ) {\n        if (renderableRows.length === 0){\n          return renderableRows;\n        }\n\n        var grid = this;\n        grid.grouping.oldGroupingHeaderCache = grid.grouping.groupingHeaderCache || {};\n        grid.grouping.groupingHeaderCache = {};\n\n        var processingState = service.initialiseProcessingState( grid );\n\n        // processes each of the fields we are grouping by, checks if the value has changed and inserts a groupHeader\n        // Broken out as shouldn't create functions in a loop.\n        var updateProcessingState = function( groupFieldState, stateIndex ) {\n          var fieldValue = grid.getCellValue(row, groupFieldState.col);\n\n          // look for change of value - and insert a header\n          if ( !groupFieldState.initialised || rowSorter.getSortFn(grid, groupFieldState.col, renderableRows)(fieldValue, groupFieldState.currentValue) !== 0 ){\n            service.insertGroupHeader( grid, renderableRows, i, processingState, stateIndex );\n            i++;\n          }\n        };\n\n        // use a for loop because it's tolerant of the array length changing whilst we go - we can\n        // manipulate the iterator when we insert groupHeader rows\n        for (var i = 0; i < renderableRows.length; i++ ){\n          var row = renderableRows[i];\n\n          if ( row.visible ){\n            processingState.forEach( updateProcessingState );\n          }\n        }\n\n        delete grid.grouping.oldGroupingHeaderCache;\n        return renderableRows;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name initialiseProcessingState\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Creates the processing state array that is used\n       * for groupRows.\n       *\n       * @param {Grid} grid grid object\n       * @returns {array} an array in the format described in the groupRows method,\n       * initialised with blank values\n       */\n      initialiseProcessingState: function( grid ){\n        var processingState = [];\n        var columnSettings = service.getGrouping( grid );\n\n        columnSettings.grouping.forEach( function( groupItem, index){\n          processingState.push({\n            fieldName: groupItem.field,\n            col: groupItem.col,\n            initialised: false,\n            currentValue: null,\n            currentRow: null\n          });\n        });\n\n        return processingState;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name getGrouping\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Get the grouping settings from the columns.  As a side effect\n       * this always renumbers the grouping starting at 0\n       * @param {Grid} grid grid object\n       * @returns {array} an array of the group fields, in order of priority\n       */\n      getGrouping: function( grid ){\n        var groupArray = [];\n        var aggregateArray = [];\n\n        // get all the grouping\n        grid.columns.forEach( function(column, columnIndex){\n          if ( column.grouping ){\n            if ( typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){\n              groupArray.push({ field: column.field, col: column, groupPriority: column.grouping.groupPriority, grouping: column.grouping });\n            }\n          }\n          if ( column.treeAggregation && column.treeAggregation.type ){\n            aggregateArray.push({ field: column.field, col: column, aggregation: column.treeAggregation });\n          }\n        });\n\n        // sort grouping into priority order\n        groupArray.sort( function(a, b){\n          return a.groupPriority - b.groupPriority;\n        });\n\n        // renumber the priority in case it was somewhat messed up, then remove the grouping reference\n        groupArray.forEach( function( group, index) {\n          group.grouping.groupPriority = index;\n          group.groupPriority = index;\n          delete group.grouping;\n        });\n\n        return { grouping: groupArray, aggregations: aggregateArray };\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name insertGroupHeader\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Create a group header row, and link it to the various configuration\n       * items that we use.\n       *\n       * Look for the row in the oldGroupingHeaderCache, write the row into the new groupingHeaderCache.\n       *\n       * @param {Grid} grid grid object\n       * @param {array} renderableRows the rows that we are processing\n       * @param {number} rowIndex the row we were up to processing\n       * @param {array} processingState the current processing state\n       * @param {number} stateIndex the processing state item that we were on when we triggered a new group header -\n       * i.e. the column that we want to create a header for\n       */\n      insertGroupHeader: function( grid, renderableRows, rowIndex, processingState, stateIndex ) {\n        // set the value that caused the end of a group into the header row and the processing state\n        var fieldName = processingState[stateIndex].fieldName;\n        var col = processingState[stateIndex].col;\n\n        var newValue = grid.getCellValue(renderableRows[rowIndex], col);\n        var newDisplayValue = newValue;\n        if ( typeof(newValue) === 'undefined' || newValue === null ) {\n          newDisplayValue = grid.options.groupingNullLabel;\n        }\n\n        var getKeyAsValueForCacheMap = function(key) {\n          if (angular.isObject(key)) {\n              return JSON.stringify(key);\n          } else {\n              return key;\n          }\n        };\n\n        var cacheItem = grid.grouping.oldGroupingHeaderCache;\n        for ( var i = 0; i < stateIndex; i++ ){\n          if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)] ){\n            cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;\n          }\n        }\n\n        var headerRow;\n        if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(newValue)]){\n          headerRow = cacheItem[getKeyAsValueForCacheMap(newValue)].row;\n          headerRow.entity = {};\n        } else {\n          headerRow = new GridRow( {}, null, grid );\n          gridClassFactory.rowTemplateAssigner.call(grid, headerRow);\n        }\n\n        headerRow.entity['$$' + processingState[stateIndex].col.uid] = { groupVal: newDisplayValue };\n        headerRow.treeLevel = stateIndex;\n        headerRow.groupHeader = true;\n        headerRow.internalRow = true;\n        headerRow.enableCellEdit = false;\n        headerRow.enableSelection = grid.options.enableGroupHeaderSelection;\n        processingState[stateIndex].initialised = true;\n        processingState[stateIndex].currentValue = newValue;\n        processingState[stateIndex].currentRow = headerRow;\n\n        // set all processing states below this one to not be initialised - change of this state\n        // means all those need to start again\n        service.finaliseProcessingState( processingState, stateIndex + 1);\n\n        // insert our new header row\n        renderableRows.splice(rowIndex, 0, headerRow);\n\n        // add our new header row to the cache\n        cacheItem = grid.grouping.groupingHeaderCache;\n        for ( i = 0; i < stateIndex; i++ ){\n          cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children;\n        }\n        cacheItem[getKeyAsValueForCacheMap(newValue)] = { row: headerRow, children: {} };\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name finaliseProcessingState\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Set all processing states lower than the one that had a break in value to\n       * no longer be initialised.  Render the counts into the entity ready for display.\n       *\n       * @param {Grid} grid grid object\n       * @param {array} processingState the current processing state\n       * @param {number} stateIndex the processing state item that we were on when we triggered a new group header, all\n       * processing states after this need to be finalised\n       */\n      finaliseProcessingState: function( processingState, stateIndex ){\n        for ( var i = stateIndex; i < processingState.length; i++){\n          processingState[i].initialised = false;\n          processingState[i].currentRow = null;\n          processingState[i].currentValue = null;\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name getRowExpandedStates\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Extract the groupHeaderCache hash, pulling out only the states.\n       *\n       * The example below shows a grid that is grouped by gender then age\n       *\n       * <pre>\n       *   {\n       *     male: {\n       *       state: 'expanded',\n       *       children: {\n       *         22: { state: 'expanded' },\n       *         30: { state: 'collapsed' }\n       *       }\n       *     },\n       *     female: {\n       *       state: 'expanded',\n       *       children: {\n       *         28: { state: 'expanded' },\n       *         55: { state: 'collapsed' }\n       *       }\n       *     }\n       *   }\n       * </pre>\n       *\n       * @param {Grid} grid grid object\n       * @returns {hash} the expanded states as a hash\n       */\n      getRowExpandedStates: function(treeChildren){\n        if ( typeof(treeChildren) === 'undefined' ){\n          return {};\n        }\n\n        var newChildren = {};\n\n        angular.forEach( treeChildren, function( value, key ){\n          newChildren[key] = { state: value.row.treeNode.state };\n          if ( value.children ){\n            newChildren[key].children = service.getRowExpandedStates( value.children );\n          } else {\n            newChildren[key].children = {};\n          }\n        });\n\n        return newChildren;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name applyRowExpandedStates\n       * @methodOf  ui.grid.grouping.service:uiGridGroupingService\n       * @description Take a hash in the format as created by getRowExpandedStates,\n       * and apply it to the grid.grouping.groupHeaderCache.\n       *\n       * Takes a treeSubset, and applies to a treeSubset - so can be called\n       * recursively.\n       *\n       * @param {object} currentNode can be grid.grouping.groupHeaderCache, or any of\n       * the children of that hash\n       * @returns {hash} expandedStates can be the full expanded states, or children\n       * of that expanded states (which hopefully matches the subset of the groupHeaderCache)\n       */\n      applyRowExpandedStates: function( currentNode, expandedStates ){\n        if ( typeof(expandedStates) === 'undefined' ){\n          return;\n        }\n\n        angular.forEach(expandedStates, function( value, key ) {\n          if ( currentNode[key] ){\n            currentNode[key].row.treeNode.state = value.state;\n\n            if (value.children && currentNode[key].children){\n              service.applyRowExpandedStates( currentNode[key].children, value.children );\n            }\n          }\n        });\n      }\n\n\n    };\n\n    return service;\n\n  }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.grouping.directive:uiGridGrouping\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds grouping features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.grouping']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name', enableCellEdit: true},\n        {name: 'title', enableCellEdit: true}\n      ];\n\n      $scope.gridOptions = { columnDefs: $scope.columnDefs, data: $scope.data };\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"gridOptions\" ui-grid-grouping></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridGrouping', ['uiGridGroupingConstants', 'uiGridGroupingService', '$templateCache',\n  function (uiGridGroupingConstants, uiGridGroupingService, $templateCache) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            if (uiGridCtrl.grid.options.enableGrouping !== false){\n              uiGridGroupingService.initializeGrid(uiGridCtrl.grid, $scope);\n            }\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.importer\n   * @description\n   *\n   * # ui.grid.importer\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module provides the ability to import data into the grid. It\n   * uses the column defs to work out which data belongs in which column,\n   * and creates entities from a configured class (typically a $resource).\n   *\n   * If the rowEdit feature is enabled, it also calls save on those newly\n   * created objects, and then displays any errors in the imported data.\n   *\n   * Currently the importer imports only CSV and json files, although provision has been\n   * made to process other file formats, and these can be added over time.\n   *\n   * For json files, the properties within each object in the json must match the column names\n   * (to put it another way, the importer doesn't process the json, it just copies the objects\n   * within the json into a new instance of the specified object type)\n   *\n   * For CSV import, the default column identification relies on each column in the\n   * header row matching a column.name or column.displayName. Optionally, a column identification\n   * callback can be used.  This allows matching using other attributes, which is particularly\n   * useful if your application has internationalised column headings (i.e. the headings that\n   * the user sees don't match the column names).\n   *\n   * The importer makes use of the grid menu as the UI for requesting an\n   * import.\n   *\n   * <div ui-grid-importer></div>\n   */\n\n  var module = angular.module('ui.grid.importer', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.importer.constant:uiGridImporterConstants\n   *\n   *  @description constants available in importer module\n   */\n\n  module.constant('uiGridImporterConstants', {\n    featureName: 'importer'\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.importer.service:uiGridImporterService\n   *\n   *  @description Services for importer feature\n   */\n  module.service('uiGridImporterService', ['$q', 'uiGridConstants', 'uiGridImporterConstants', 'gridUtil', '$compile', '$interval', 'i18nService', '$window',\n    function ($q, uiGridConstants, uiGridImporterConstants, gridUtil, $compile, $interval, i18nService, $window) {\n\n      var service = {\n\n        initializeGrid: function ($scope, grid) {\n\n          //add feature namespace and any properties to grid for needed state\n          grid.importer = {\n            $scope: $scope\n          };\n\n          this.defaultGridOptions(grid.options);\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.importer.api:PublicApi\n           *\n           *  @description Public Api for importer feature\n           */\n          var publicApi = {\n            events: {\n              importer: {\n              }\n            },\n            methods: {\n              importer: {\n                /**\n                 * @ngdoc function\n                 * @name importFile\n                 * @methodOf  ui.grid.importer.api:PublicApi\n                 * @description Imports a file into the grid using the file object\n                 * provided.  Bypasses the grid menu\n                 * @param {File} fileObject the file we want to import, as a javascript\n                 * File object\n                 */\n                importFile: function ( fileObject ) {\n                  service.importThisFile( grid, fileObject );\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n          if ( grid.options.enableImporter && grid.options.importerShowMenu ){\n            if ( grid.api.core.addToGridMenu ){\n              service.addToMenu( grid );\n            } else {\n              // order of registration is not guaranteed, register in a little while\n              $interval( function() {\n                if (grid.api.core.addToGridMenu){\n                  service.addToMenu( grid );\n                }\n              }, 100, 1);\n            }\n          }\n        },\n\n\n        defaultGridOptions: function (gridOptions) {\n          //default option to true unless it was explicitly set to false\n          /**\n           * @ngdoc object\n           * @name ui.grid.importer.api:GridOptions\n           *\n           * @description GridOptions for importer feature, these are available to be\n           * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           * @ngdoc property\n           * @propertyOf ui.grid.importer.api:GridOptions\n           * @name enableImporter\n           * @description Whether or not importer is enabled.  Automatically set\n           * to false if the user's browser does not support the required fileApi.\n           * Otherwise defaults to true.\n           *\n           */\n          if (gridOptions.enableImporter  || gridOptions.enableImporter === undefined) {\n            if ( !($window.hasOwnProperty('File') && $window.hasOwnProperty('FileReader') && $window.hasOwnProperty('FileList') && $window.hasOwnProperty('Blob')) ) {\n              gridUtil.logError('The File APIs are not fully supported in this browser, grid importer cannot be used.');\n              gridOptions.enableImporter = false;\n            } else {\n              gridOptions.enableImporter = true;\n            }\n          } else {\n            gridOptions.enableImporter = false;\n          }\n\n          /**\n           * @ngdoc method\n           * @name importerProcessHeaders\n           * @methodOf ui.grid.importer.api:GridOptions\n           * @description A callback function that will process headers using custom\n           * logic.  Set this callback function if the headers that your user will provide in their\n           * import file don't necessarily match the grid header or field names.  This might commonly\n           * occur where your application is internationalised, and therefore the field names\n           * that the user recognises are in a different language than the field names that\n           * ui-grid knows about.\n           *\n           * Defaults to the internal `processHeaders` method, which seeks to match using both\n           * displayName and column.name.  Any non-matching columns are discarded.\n           *\n           * Your callback routine should respond by processing the header array, and returning an array\n           * of matching column names.  A null value in any given position means \"don't import this column\"\n           *\n           * <pre>\n           *      gridOptions.importerProcessHeaders: function( headerArray ) {\n           *        var myHeaderColumns = [];\n           *        var thisCol;\n           *        headerArray.forEach( function( value, index ) {\n           *          thisCol = mySpecialLookupFunction( value );\n           *          myHeaderColumns.push( thisCol.name );\n           *        });\n           *\n           *        return myHeaderCols;\n           *      })\n           * </pre>\n           * @param {Grid} grid the grid we're importing into\n           * @param {array} headerArray an array of the text from the first row of the csv file,\n           * which you need to match to column.names\n           * @returns {array} array of matching column names, in the same order as the headerArray\n           *\n           */\n          gridOptions.importerProcessHeaders = gridOptions.importerProcessHeaders || service.processHeaders;\n\n          /**\n           * @ngdoc method\n           * @name importerHeaderFilter\n           * @methodOf ui.grid.importer.api:GridOptions\n           * @description A callback function that will filter (usually translate) a single\n           * header.  Used when you want to match the passed in column names to the column\n           * displayName after the header filter.\n           *\n           * Your callback routine needs to return the filtered header value.\n           * <pre>\n           *      gridOptions.importerHeaderFilter: function( displayName ) {\n           *        return $translate.instant( displayName );\n           *      })\n           * </pre>\n           *\n           * or:\n           * <pre>\n           *      gridOptions.importerHeaderFilter: $translate.instant\n           * </pre>\n           * @param {string} displayName the displayName that we'd like to translate\n           * @returns {string} the translated name\n           *\n           */\n          gridOptions.importerHeaderFilter = gridOptions.importerHeaderFilter || function( displayName ) { return displayName; };\n\n          /**\n           * @ngdoc method\n           * @name importerErrorCallback\n           * @methodOf ui.grid.importer.api:GridOptions\n           * @description A callback function that provides custom error handling, rather\n           * than the standard grid behaviour of an alert box and a console message.  You\n           * might use this to internationalise the console log messages, or to write to a\n           * custom logging routine that returned errors to the server.\n           *\n           * <pre>\n           *      gridOptions.importerErrorCallback: function( grid, errorKey, consoleMessage, context ) {\n           *        myUserDisplayRoutine( errorKey );\n           *        myLoggingRoutine( consoleMessage, context );\n           *      })\n           * </pre>\n           * @param {Grid} grid the grid we're importing into, may be useful if you're positioning messages\n           * in some way\n           * @param {string} errorKey one of the i18n keys the importer can return - importer.noHeaders,\n           * importer.noObjects, importer.invalidCsv, importer.invalidJson, importer.jsonNotArray\n           * @param {string} consoleMessage the English console message that importer would have written\n           * @param {object} context the context data that importer would have appended to that console message,\n           * often the file content itself or the element that is in error\n           *\n           */\n          if ( !gridOptions.importerErrorCallback ||  typeof(gridOptions.importerErrorCallback) !== 'function' ){\n            delete gridOptions.importerErrorCallback;\n          }\n\n          /**\n           * @ngdoc method\n           * @name importerDataAddCallback\n           * @methodOf ui.grid.importer.api:GridOptions\n           * @description A mandatory callback function that adds data to the source data array.  The grid\n           * generally doesn't add rows to the source data array, it is tidier to handle this through a user\n           * callback.\n           *\n           * <pre>\n           *      gridOptions.importerDataAddCallback: function( grid, newObjects ) {\n           *        $scope.myData = $scope.myData.concat( newObjects );\n           *      })\n           * </pre>\n           * @param {Grid} grid the grid we're importing into, may be useful in some way\n           * @param {array} newObjects an array of new objects that you should add to your data\n           *\n           */\n          if ( gridOptions.enableImporter === true && !gridOptions.importerDataAddCallback ) {\n            gridUtil.logError(\"You have not set an importerDataAddCallback, importer is disabled\");\n            gridOptions.enableImporter = false;\n          }\n\n          /**\n           * @ngdoc object\n           * @name importerNewObject\n           * @propertyOf  ui.grid.importer.api:GridOptions\n           * @description An object on which we call `new` to create each new row before inserting it into\n           * the data array.  Typically this would be a $resource entity, which means that if you're using\n           * the rowEdit feature, you can directly call save on this entity when the save event is triggered.\n           *\n           * Defaults to a vanilla javascript object\n           *\n           * @example\n           * <pre>\n           *   gridOptions.importerNewObject = MyRes;\n           * </pre>\n           *\n           */\n\n          /**\n           * @ngdoc property\n           * @propertyOf ui.grid.importer.api:GridOptions\n           * @name importerShowMenu\n           * @description Whether or not to show an item in the grid menu.  Defaults to true.\n           *\n           */\n          gridOptions.importerShowMenu = gridOptions.importerShowMenu !== false;\n\n          /**\n           * @ngdoc method\n           * @methodOf ui.grid.importer.api:GridOptions\n           * @name importerObjectCallback\n           * @description A callback that massages the data for each object.  For example,\n           * you might have data stored as a code value, but display the decode.  This callback\n           * can be used to change the decoded value back into a code.  Defaults to doing nothing.\n           * @param {Grid} grid in case you need it\n           * @param {object} newObject the new object as importer has created it, modify it\n           * then return the modified version\n           * @returns {object} the modified object\n           * @example\n           * <pre>\n           *   gridOptions.importerObjectCallback = function ( grid, newObject ) {\n           *     switch newObject.status {\n           *       case 'Active':\n           *         newObject.status = 1;\n           *         break;\n           *       case 'Inactive':\n           *         newObject.status = 2;\n           *         break;\n           *     }\n           *     return newObject;\n           *   };\n           * </pre>\n           */\n          gridOptions.importerObjectCallback = gridOptions.importerObjectCallback || function( grid, newObject ) { return newObject; };\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name addToMenu\n         * @methodOf  ui.grid.importer.service:uiGridImporterService\n         * @description Adds import menu item to the grid menu,\n         * allowing the user to request import of a file\n         * @param {Grid} grid the grid into which data should be imported\n         */\n        addToMenu: function ( grid ) {\n          grid.api.core.addToGridMenu( grid, [\n            {\n              title: i18nService.getSafeText('gridMenu.importerTitle'),\n              order: 150\n            },\n            {\n              templateUrl: 'ui-grid/importerMenuItemContainer',\n              action: function ($event) {\n                this.grid.api.importer.importAFile( grid );\n              },\n              order: 151\n            }\n          ]);\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name importThisFile\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Imports the provided file into the grid using the file object\n         * provided.  Bypasses the grid menu\n         * @param {Grid} grid the grid we're importing into\n         * @param {File} fileObject the file we want to import, as returned from the File\n         * javascript object\n         */\n        importThisFile: function ( grid, fileObject ) {\n          if (!fileObject){\n            gridUtil.logError( 'No file object provided to importThisFile, should be impossible, aborting');\n            return;\n          }\n\n          var reader = new FileReader();\n\n          switch ( fileObject.type ){\n            case 'application/json':\n              reader.onload = service.importJsonClosure( grid );\n              break;\n            default:\n              reader.onload = service.importCsvClosure( grid );\n              break;\n          }\n\n          reader.readAsText( fileObject );\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name importJson\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Creates a function that imports a json file into the grid.\n         * The json data is imported into new objects of type `gridOptions.importerNewObject`,\n         * and if the rowEdit feature is enabled the rows are marked as dirty\n         * @param {Grid} grid the grid we want to import into\n         * @param {FileObject} importFile the file that we want to import, as\n         * a FileObject\n         */\n        importJsonClosure: function( grid ) {\n          return function( importFile ){\n            var newObjects = [];\n            var newObject;\n\n            var importArray = service.parseJson( grid, importFile );\n            if (importArray === null){\n              return;\n            }\n            importArray.forEach(  function( value, index ) {\n              newObject = service.newObject( grid );\n              angular.extend( newObject, value );\n              newObject = grid.options.importerObjectCallback( grid, newObject );\n              newObjects.push( newObject );\n            });\n\n            service.addObjects( grid, newObjects );\n\n          };\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name parseJson\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Parses a json file, returns the parsed data.\n         * Displays an error if file doesn't parse\n         * @param {Grid} grid the grid that we want to import into\n         * @param {FileObject} importFile the file that we want to import, as\n         * a FileObject\n         * @returns {array} array of objects from the imported json\n         */\n        parseJson: function( grid, importFile ){\n          var loadedObjects;\n          try {\n            loadedObjects = JSON.parse( importFile.target.result );\n          } catch (e) {\n            service.alertError( grid, 'importer.invalidJson', 'File could not be processed, is it valid json? Content was: ', importFile.target.result );\n            return;\n          }\n\n          if ( !Array.isArray( loadedObjects ) ){\n            service.alertError( grid, 'importer.jsonNotarray', 'Import failed, file is not an array, file was: ', importFile.target.result );\n            return [];\n          } else {\n            return loadedObjects;\n          }\n        },\n\n\n\n        /**\n         * @ngdoc function\n         * @name importCsvClosure\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Creates a function that imports a csv file into the grid\n         * (allowing it to be used in the reader.onload event)\n         * @param {Grid} grid the grid that we want to import into\n         * @param {FileObject} importFile the file that we want to import, as\n         * a file object\n         */\n        importCsvClosure: function( grid ) {\n          return function( importFile ){\n            var importArray = service.parseCsv( importFile );\n            if ( !importArray || importArray.length < 1 ){\n              service.alertError( grid, 'importer.invalidCsv', 'File could not be processed, is it valid csv? Content was: ', importFile.target.result );\n              return;\n            }\n\n            var newObjects = service.createCsvObjects( grid, importArray );\n            if ( !newObjects || newObjects.length === 0 ){\n              service.alertError( grid, 'importer.noObjects', 'Objects were not able to be derived, content was: ', importFile.target.result );\n              return;\n            }\n\n            service.addObjects( grid, newObjects );\n          };\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name parseCsv\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Parses a csv file into an array of arrays, with the first\n         * array being the headers, and the remaining arrays being the data.\n         * The logic for this comes from https://github.com/thetalecrafter/excel.js/blob/master/src/csv.js,\n         * which is noted as being under the MIT license.  The code is modified to pass the jscs yoda condition\n         * checker\n         * @param {FileObject} importFile the file that we want to import, as a\n         * file object\n         */\n        parseCsv: function( importFile ) {\n          var csv = importFile.target.result;\n\n          // use the CSV-JS library to parse\n          return CSV.parse(csv);\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name createCsvObjects\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Converts an array of arrays (representing the csv file)\n         * into a set of objects.  Uses the provided `gridOptions.importerNewObject`\n         * to create the objects, and maps the header row into the individual columns\n         * using either `gridOptions.importerProcessHeaders`, or by using a native method\n         * of matching to either the displayName, column name or column field of\n         * the columns in the column defs.  The resulting objects will have attributes\n         * that are named based on the column.field or column.name, in that order.\n         * @param {Grid} grid the grid that we want to import into\n         * @param {Array} importArray the data that we want to import, as an array\n         */\n        createCsvObjects: function( grid, importArray ){\n          // pull off header row and turn into headers\n          var headerMapping = grid.options.importerProcessHeaders( grid, importArray.shift() );\n          if ( !headerMapping || headerMapping.length === 0 ){\n            service.alertError( grid, 'importer.noHeaders', 'Column names could not be derived, content was: ', importArray );\n            return [];\n          }\n\n          var newObjects = [];\n          var newObject;\n          importArray.forEach( function( row, index ) {\n            newObject = service.newObject( grid );\n            if ( row !== null ){\n              row.forEach( function( field, index ){\n                if ( headerMapping[index] !== null ){\n                  newObject[ headerMapping[index] ] = field;\n                }\n              });\n            }\n            newObject = grid.options.importerObjectCallback( grid, newObject );\n            newObjects.push( newObject );\n          });\n\n          return newObjects;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name processHeaders\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Determines the columns that the header row from\n         * a csv (or other) file represents.\n         * @param {Grid} grid the grid we're importing into\n         * @param {array} headerRow the header row that we wish to match against\n         * the column definitions\n         * @returns {array} an array of the attribute names that should be used\n         * for that column, based on matching the headers or creating the headers\n         *\n         */\n        processHeaders: function( grid, headerRow ) {\n          var headers = [];\n          if ( !grid.options.columnDefs || grid.options.columnDefs.length === 0 ){\n            // we are going to create new columnDefs for all these columns, so just remove\n            // spaces from the names to create fields\n            headerRow.forEach( function( value, index ) {\n              headers.push( value.replace( /[^0-9a-zA-Z\\-_]/g, '_' ) );\n            });\n            return headers;\n          } else {\n            var lookupHash = service.flattenColumnDefs( grid, grid.options.columnDefs );\n            headerRow.forEach(  function( value, index ) {\n              if ( lookupHash[value] ) {\n                headers.push( lookupHash[value] );\n              } else if ( lookupHash[ value.toLowerCase() ] ) {\n                headers.push( lookupHash[ value.toLowerCase() ] );\n              } else {\n                headers.push( null );\n              }\n            });\n            return headers;\n          }\n        },\n\n\n        /**\n         * @name flattenColumnDefs\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Runs through the column defs and creates a hash of\n         * the displayName, name and field, and of each of those values forced to lower case,\n         * with each pointing to the field or name\n         * (whichever is present).  Used to lookup column headers and decide what\n         * attribute name to give to the resulting field.\n         * @param {Grid} grid the grid we're importing into\n         * @param {array} columnDefs the columnDefs that we should flatten\n         * @returns {hash} the flattened version of the column def information, allowing\n         * us to look up a value by `flattenedHash[ headerValue ]`\n         */\n        flattenColumnDefs: function( grid, columnDefs ){\n          var flattenedHash = {};\n          columnDefs.forEach(  function( columnDef, index) {\n            if ( columnDef.name ){\n              flattenedHash[ columnDef.name ] = columnDef.field || columnDef.name;\n              flattenedHash[ columnDef.name.toLowerCase() ] = columnDef.field || columnDef.name;\n            }\n\n            if ( columnDef.field ){\n              flattenedHash[ columnDef.field ] = columnDef.field || columnDef.name;\n              flattenedHash[ columnDef.field.toLowerCase() ] = columnDef.field || columnDef.name;\n            }\n\n            if ( columnDef.displayName ){\n              flattenedHash[ columnDef.displayName ] = columnDef.field || columnDef.name;\n              flattenedHash[ columnDef.displayName.toLowerCase() ] = columnDef.field || columnDef.name;\n            }\n\n            if ( columnDef.displayName && grid.options.importerHeaderFilter ){\n              flattenedHash[ grid.options.importerHeaderFilter(columnDef.displayName) ] = columnDef.field || columnDef.name;\n              flattenedHash[ grid.options.importerHeaderFilter(columnDef.displayName).toLowerCase() ] = columnDef.field || columnDef.name;\n            }\n          });\n\n          return flattenedHash;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name addObjects\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Inserts our new objects into the grid data, and\n         * sets the rows to dirty if the rowEdit feature is being used\n         *\n         * Does this by registering a watch on dataChanges, which essentially\n         * is waiting on the result of the grid data watch, and downstream processing.\n         *\n         * When the callback is called, it deregisters itself - we don't want to run\n         * again next time data is added.\n         *\n         * If we never get called, we deregister on destroy.\n         *\n         * @param {Grid} grid the grid we're importing into\n         * @param {array} newObjects the objects we want to insert into the grid data\n         * @returns {object} the new object\n         */\n        addObjects: function( grid, newObjects, $scope ){\n          if ( grid.api.rowEdit ){\n            var dataChangeDereg = grid.registerDataChangeCallback( function() {\n              grid.api.rowEdit.setRowsDirty( newObjects );\n              dataChangeDereg();\n            }, [uiGridConstants.dataChange.ROW] );\n\n            grid.importer.$scope.$on( '$destroy', dataChangeDereg );\n          }\n\n          grid.importer.$scope.$apply( grid.options.importerDataAddCallback( grid, newObjects ) );\n\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name newObject\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Makes a new object based on `gridOptions.importerNewObject`,\n         * or based on an empty object if not present\n         * @param {Grid} grid the grid we're importing into\n         * @returns {object} the new object\n         */\n        newObject: function( grid ){\n          if ( typeof(grid.options) !== \"undefined\" && typeof(grid.options.importerNewObject) !== \"undefined\" ){\n            return new grid.options.importerNewObject();\n          } else {\n            return {};\n          }\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name alertError\n         * @methodOf ui.grid.importer.service:uiGridImporterService\n         * @description Provides an internationalised user alert for the failure,\n         * and logs a console message including diagnostic content.\n         * Optionally, if the the `gridOptions.importerErrorCallback` routine\n         * is defined, then calls that instead, allowing user specified error routines\n         * @param {Grid} grid the grid we're importing into\n         * @param {array} headerRow the header row that we wish to match against\n         * the column definitions\n         */\n        alertError: function( grid, alertI18nToken, consoleMessage, context ){\n          if ( grid.options.importerErrorCallback ){\n            grid.options.importerErrorCallback( grid, alertI18nToken, consoleMessage, context );\n          } else {\n            $window.alert(i18nService.getSafeText( alertI18nToken ));\n            gridUtil.logError(consoleMessage + context );\n          }\n        }\n      };\n\n      return service;\n\n    }\n  ]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.importer.directive:uiGridImporter\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds importer features to grid\n   *\n   */\n  module.directive('uiGridImporter', ['uiGridImporterConstants', 'uiGridImporterService', 'gridUtil', '$compile',\n    function (uiGridImporterConstants, uiGridImporterService, gridUtil, $compile) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        link: function ($scope, $elm, $attrs, uiGridCtrl) {\n          uiGridImporterService.initializeGrid($scope, uiGridCtrl.grid);\n        }\n      };\n    }\n  ]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.importer.directive:uiGridImporterMenuItem\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Handles the processing from the importer menu item - once a file is\n   *  selected\n   *\n   */\n  module.directive('uiGridImporterMenuItem', ['uiGridImporterConstants', 'uiGridImporterService', 'gridUtil', '$compile',\n    function (uiGridImporterConstants, uiGridImporterService, gridUtil, $compile) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        templateUrl: 'ui-grid/importerMenuItem',\n        link: function ($scope, $elm, $attrs, uiGridCtrl) {\n          var handleFileSelect = function( event ){\n            var target = event.srcElement || event.target;\n\n            if (target && target.files && target.files.length === 1) {\n              var fileObject = target.files[0];\n              uiGridImporterService.importThisFile( grid, fileObject );\n              target.form.reset();\n            }\n          };\n\n          var fileChooser = $elm[0].querySelectorAll('.ui-grid-importer-file-chooser');\n          var grid = uiGridCtrl.grid;\n\n          if ( fileChooser.length !== 1 ){\n            gridUtil.logError('Found > 1 or < 1 file choosers within the menu item, error, cannot continue');\n          } else {\n            fileChooser[0].addEventListener('change', handleFileSelect, false);  // TODO: why the false on the end?  Google\n          }\n        }\n      };\n    }\n  ]);\n})();\n\n(function() {\n  'use strict';\n  /**\n   *  @ngdoc overview\n   *  @name ui.grid.infiniteScroll\n   *\n   *  @description\n   *\n   * #ui.grid.infiniteScroll\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Beta</strong> This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs.</div>\n   *\n   * This module provides infinite scroll functionality to ui-grid\n   *\n   */\n  var module = angular.module('ui.grid.infiniteScroll', ['ui.grid']);\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n   *\n   *  @description Service for infinite scroll features\n   */\n  module.service('uiGridInfiniteScrollService', ['gridUtil', '$compile', '$timeout', 'uiGridConstants', 'ScrollEvent', '$q', function (gridUtil, $compile, $timeout, uiGridConstants, ScrollEvent, $q) {\n\n    var service = {\n\n      /**\n       * @ngdoc function\n       * @name initializeGrid\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description This method register events and methods into grid public API\n       */\n\n      initializeGrid: function(grid, $scope) {\n        service.defaultGridOptions(grid.options);\n\n        if (!grid.options.enableInfiniteScroll){\n          return;\n        }\n\n        grid.infiniteScroll = { dataLoading: false };\n        service.setScrollDirections( grid, grid.options.infiniteScrollUp, grid.options.infiniteScrollDown );\n          grid.api.core.on.scrollEnd($scope, service.handleScroll);\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.infiniteScroll.api:PublicAPI\n         *\n         *  @description Public API for infinite scroll feature\n         */\n        var publicApi = {\n          events: {\n            infiniteScroll: {\n\n              /**\n               * @ngdoc event\n               * @name needLoadMoreData\n               * @eventOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description This event fires when scroll reaches bottom percentage of grid\n               * and needs to load data\n               */\n\n              needLoadMoreData: function ($scope, fn) {\n              },\n\n              /**\n               * @ngdoc event\n               * @name needLoadMoreDataTop\n               * @eventOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description This event fires when scroll reaches top percentage of grid\n               * and needs to load data\n               */\n\n              needLoadMoreDataTop: function ($scope, fn) {\n              }\n            }\n          },\n          methods: {\n            infiniteScroll: {\n\n              /**\n               * @ngdoc function\n               * @name dataLoaded\n               * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description Call this function when you have loaded the additional data\n               * requested.  You should set scrollUp and scrollDown to indicate\n               * whether there are still more pages in each direction.\n               *\n               * If you call dataLoaded without first calling `saveScrollPercentage` then we will\n               * scroll the user to the start of the newly loaded data, which usually gives a smooth scroll\n               * experience, but can give a jumpy experience with large `infiniteScrollRowsFromEnd` values, and\n               * on variable speed internet connections.  Using `saveScrollPercentage` as demonstrated in the tutorial\n               * should give a smoother scrolling experience for users.\n               *\n               * See infinite_scroll tutorial for example of usage\n               * @param {boolean} scrollUp if set to false flags that there are no more pages upwards, so don't fire\n               * any more infinite scroll events upward\n               * @param {boolean} scrollDown if set to false flags that there are no more pages downwards, so don't\n               * fire any more infinite scroll events downward\n               * @returns {promise} a promise that is resolved when the grid scrolling is fully adjusted.  If you're\n               * planning to remove pages, you should wait on this promise first, or you'll break the scroll positioning\n               */\n              dataLoaded: function( scrollUp, scrollDown ) {\n                service.setScrollDirections(grid, scrollUp, scrollDown);\n\n                var promise = service.adjustScroll(grid).then(function() {\n                  grid.infiniteScroll.dataLoading = false;\n                });\n\n                return promise;\n              },\n\n              /**\n               * @ngdoc function\n               * @name resetScroll\n               * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description Call this function when you have taken some action that makes the current\n               * scroll position invalid.  For example, if you're using external sorting and you've resorted\n               * then you might reset the scroll, or if you've otherwise substantially changed the data, perhaps\n               * you've reused an existing grid for a new data set\n               *\n               * You must tell us whether there is data upwards or downwards after the reset\n               *\n               * @param {boolean} scrollUp flag that there are pages upwards, fire\n               * infinite scroll events upward\n               * @param {boolean} scrollDown flag that there are pages downwards, so\n               * fire infinite scroll events downward\n               * @returns {promise} promise that is resolved when the scroll reset is complete\n               */\n              resetScroll: function( scrollUp, scrollDown ) {\n                service.setScrollDirections( grid, scrollUp, scrollDown);\n\n                return service.adjustInfiniteScrollPosition(grid, 0);\n              },\n\n\n              /**\n               * @ngdoc function\n               * @name saveScrollPercentage\n               * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description Saves the scroll percentage and number of visible rows before you adjust the data,\n               * used if you're subsequently going to call `dataRemovedTop` or `dataRemovedBottom`\n               */\n              saveScrollPercentage: function() {\n                grid.infiniteScroll.prevScrollTop = grid.renderContainers.body.prevScrollTop;\n                grid.infiniteScroll.previousVisibleRows = grid.getVisibleRowCount();\n              },\n\n\n              /**\n               * @ngdoc function\n               * @name dataRemovedTop\n               * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description Adjusts the scroll position after you've removed data at the top\n               * @param {boolean} scrollUp flag that there are pages upwards, fire\n               * infinite scroll events upward\n               * @param {boolean} scrollDown flag that there are pages downwards, so\n               * fire infinite scroll events downward\n               */\n              dataRemovedTop: function( scrollUp, scrollDown ) {\n                service.dataRemovedTop( grid, scrollUp, scrollDown );\n              },\n\n              /**\n               * @ngdoc function\n               * @name dataRemovedBottom\n               * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n               * @description Adjusts the scroll position after you've removed data at the bottom\n               * @param {boolean} scrollUp flag that there are pages upwards, fire\n               * infinite scroll events upward\n               * @param {boolean} scrollDown flag that there are pages downwards, so\n               * fire infinite scroll events downward\n               */\n              dataRemovedBottom: function( scrollUp, scrollDown ) {\n                service.dataRemovedBottom( grid, scrollUp, scrollDown );\n              },\n\n              /**\n               * @ngdoc function\n               * @name setScrollDirections\n               * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n               * @description Sets the scrollUp and scrollDown flags, handling nulls and undefined,\n               * and also sets the grid.suppressParentScroll\n               * @param {boolean} scrollUp whether there are pages available up - defaults to false\n               * @param {boolean} scrollDown whether there are pages available down - defaults to true\n               */\n              setScrollDirections:  function ( scrollUp, scrollDown ) {\n                service.setScrollDirections( grid, scrollUp, scrollDown );\n              }\n\n            }\n          }\n        };\n        grid.api.registerEventsFromObject(publicApi.events);\n        grid.api.registerMethodsFromObject(publicApi.methods);\n      },\n\n\n      defaultGridOptions: function (gridOptions) {\n        //default option to true unless it was explicitly set to false\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.infiniteScroll.api:GridOptions\n         *\n         *  @description GridOptions for infinite scroll feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enableInfiniteScroll\n         *  @propertyOf  ui.grid.infiniteScroll.api:GridOptions\n         *  @description Enable infinite scrolling for this grid\n         *  <br/>Defaults to true\n         */\n        gridOptions.enableInfiniteScroll = gridOptions.enableInfiniteScroll !== false;\n\n        /**\n         * @ngdoc property\n         * @name infiniteScrollRowsFromEnd\n         * @propertyOf ui.grid.class:GridOptions\n         * @description This setting controls how close to the end of the dataset a user gets before\n         * more data is requested by the infinite scroll, whether scrolling up or down.  This allows you to\n         * 'prefetch' rows before the user actually runs out of scrolling.\n         *\n         * Note that if you set this value too high it may give jumpy scrolling behaviour, if you're getting\n         * this behaviour you could use the `saveScrollPercentageMethod` right before loading your data, and we'll\n         * preserve that scroll position\n         *\n         * <br> Defaults to 20\n         */\n        gridOptions.infiniteScrollRowsFromEnd = gridOptions.infiniteScrollRowsFromEnd || 20;\n\n        /**\n         * @ngdoc property\n         * @name infiniteScrollUp\n         * @propertyOf ui.grid.class:GridOptions\n         * @description Whether you allow infinite scroll up, implying that the first page of data\n         * you have displayed is in the middle of your data set.  If set to true then we trigger the\n         * needMoreDataTop event when the user hits the top of the scrollbar.\n         * <br> Defaults to false\n         */\n        gridOptions.infiniteScrollUp = gridOptions.infiniteScrollUp === true;\n\n        /**\n         * @ngdoc property\n         * @name infiniteScrollDown\n         * @propertyOf ui.grid.class:GridOptions\n         * @description Whether you allow infinite scroll down, implying that the first page of data\n         * you have displayed is in the middle of your data set.  If set to true then we trigger the\n         * needMoreData event when the user hits the bottom of the scrollbar.\n         * <br> Defaults to true\n         */\n        gridOptions.infiniteScrollDown = gridOptions.infiniteScrollDown !== false;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name setScrollDirections\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description Sets the scrollUp and scrollDown flags, handling nulls and undefined,\n       * and also sets the grid.suppressParentScroll\n       * @param {grid} grid the grid we're operating on\n       * @param {boolean} scrollUp whether there are pages available up - defaults to false\n       * @param {boolean} scrollDown whether there are pages available down - defaults to true\n       */\n      setScrollDirections:  function ( grid, scrollUp, scrollDown ) {\n        grid.infiniteScroll.scrollUp = ( scrollUp === true );\n        grid.suppressParentScrollUp = ( scrollUp === true );\n\n        grid.infiniteScroll.scrollDown = ( scrollDown !== false);\n        grid.suppressParentScrollDown = ( scrollDown !== false);\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name handleScroll\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description Called whenever the grid scrolls, determines whether the scroll should\n       * trigger an infinite scroll request for more data\n       * @param {object} args the args from the event\n       */\n      handleScroll:  function (args) {\n        // don't request data if already waiting for data, or if source is coming from ui.grid.adjustInfiniteScrollPosition() function\n        if ( args.grid.infiniteScroll && args.grid.infiniteScroll.dataLoading || args.source === 'ui.grid.adjustInfiniteScrollPosition' ){\n          return;\n        }\n\n        if (args.y) {\n          var percentage;\n          var targetPercentage = args.grid.options.infiniteScrollRowsFromEnd / args.grid.renderContainers.body.visibleRowCache.length;\n          if (args.grid.scrollDirection === uiGridConstants.scrollDirection.UP ) {\n            percentage = args.y.percentage;\n            if (percentage <= targetPercentage){\n              service.loadData(args.grid);\n            }\n          } else if (args.grid.scrollDirection === uiGridConstants.scrollDirection.DOWN) {\n            percentage = 1 - args.y.percentage;\n            if (percentage <= targetPercentage){\n              service.loadData(args.grid);\n            }\n          }\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name loadData\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description This function fires 'needLoadMoreData' or 'needLoadMoreDataTop' event based on scrollDirection\n       * and whether there are more pages upwards or downwards.  It also stores the number of rows that we had previously,\n       * and clears out any saved scroll position so that we know whether or not the user calls `saveScrollPercentage`\n       * @param {Grid} grid the grid we're working on\n       */\n      loadData: function (grid) {\n        // save number of currently visible rows to calculate new scroll position later - we know that we want\n        // to be at approximately the row we're currently at\n        grid.infiniteScroll.previousVisibleRows = grid.renderContainers.body.visibleRowCache.length;\n        grid.infiniteScroll.direction = grid.scrollDirection;\n        delete grid.infiniteScroll.prevScrollTop;\n\n        if (grid.scrollDirection === uiGridConstants.scrollDirection.UP && grid.infiniteScroll.scrollUp ) {\n          grid.infiniteScroll.dataLoading = true;\n          grid.api.infiniteScroll.raise.needLoadMoreDataTop();\n        } else if (grid.scrollDirection === uiGridConstants.scrollDirection.DOWN && grid.infiniteScroll.scrollDown ) {\n          grid.infiniteScroll.dataLoading = true;\n          grid.api.infiniteScroll.raise.needLoadMoreData();\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name adjustScroll\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description Once we are informed that data has been loaded, adjust the scroll position to account for that\n       * addition and to make things look clean.\n       *\n       * If we're scrolling up we scroll to the first row of the old data set -\n       * so we're assuming that you would have gotten to the top of the grid (from the 20% need more data trigger) by\n       * the time the data comes back.  If we're scrolling down we scoll to the last row of the old data set - so we're\n       * assuming that you would have gotten to the bottom of the grid (from the 80% need more data trigger) by the time\n       * the data comes back.\n       *\n       * Neither of these are good assumptions, but making this a smoother experience really requires\n       * that trigger to not be a percentage, and to be much closer to the end of the data (say, 5 rows off the end).  Even then\n       * it'd be better still to actually run into the end.  But if the data takes a while to come back, they may have scrolled\n       * somewhere else in the mean-time, in which case they'll get a jump back to the new data.  Anyway, this will do for\n       * now, until someone wants to do better.\n       * @param {Grid} grid the grid we're working on\n       * @returns {promise} a promise that is resolved when scrolling has finished\n       */\n      adjustScroll: function(grid){\n        var promise = $q.defer();\n        $timeout(function () {\n          var newPercentage, viewportHeight, rowHeight, newVisibleRows, oldTop, newTop;\n\n          viewportHeight = grid.getViewportHeight() + grid.headerHeight - grid.renderContainers.body.headerHeight - grid.scrollbarHeight;\n          rowHeight = grid.options.rowHeight;\n\n          if ( grid.infiniteScroll.direction === undefined ){\n            // called from initialize, tweak our scroll up a little\n            service.adjustInfiniteScrollPosition(grid, 0);\n          }\n\n          newVisibleRows = grid.getVisibleRowCount();\n\n          // in case not enough data is loaded to enable scroller - load more data\n          var canvasHeight = rowHeight * newVisibleRows;\n          if (grid.infiniteScroll.scrollDown && (viewportHeight > canvasHeight)) {\n            grid.api.infiniteScroll.raise.needLoadMoreData();\n          }\n\n          if ( grid.infiniteScroll.direction === uiGridConstants.scrollDirection.UP ){\n            oldTop = grid.infiniteScroll.prevScrollTop || 0;\n            newTop = oldTop + (newVisibleRows - grid.infiniteScroll.previousVisibleRows)*rowHeight;\n            service.adjustInfiniteScrollPosition(grid, newTop);\n            $timeout( function() {\n              promise.resolve();\n            });\n          }\n\n          if ( grid.infiniteScroll.direction === uiGridConstants.scrollDirection.DOWN ){\n            newTop = grid.infiniteScroll.prevScrollTop || (grid.infiniteScroll.previousVisibleRows*rowHeight - viewportHeight);\n            service.adjustInfiniteScrollPosition(grid, newTop);\n            $timeout( function() {\n              promise.resolve();\n            });\n          }\n        }, 0);\n\n        return promise.promise;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name adjustInfiniteScrollPosition\n       * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService\n       * @description This function fires 'needLoadMoreData' or 'needLoadMoreDataTop' event based on scrollDirection\n       * @param {Grid} grid the grid we're working on\n       * @param {number} scrollTop the position through the grid that we want to scroll to\n       * @returns {promise} a promise that is resolved when the scrolling finishes\n       */\n      adjustInfiniteScrollPosition: function (grid, scrollTop) {\n        var scrollEvent = new ScrollEvent(grid, null, null, 'ui.grid.adjustInfiniteScrollPosition'),\n          visibleRows = grid.getVisibleRowCount(),\n          viewportHeight = grid.getViewportHeight() + grid.headerHeight - grid.renderContainers.body.headerHeight - grid.scrollbarHeight,\n          rowHeight = grid.options.rowHeight,\n          scrollHeight = visibleRows*rowHeight-viewportHeight;\n\n        //for infinite scroll, if there are pages upwards then never allow it to be at the zero position so the up button can be active\n        if (scrollTop === 0 && grid.infiniteScroll.scrollUp) {\n          // using pixels results in a relative scroll, hence we have to use percentage\n          scrollEvent.y = {percentage: 1/scrollHeight};\n        }\n        else {\n          scrollEvent.y = {percentage: scrollTop/scrollHeight};\n        }\n        grid.scrollContainers('', scrollEvent);\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name dataRemovedTop\n       * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n       * @description Adjusts the scroll position after you've removed data at the top. You should\n       * have called `saveScrollPercentage` before you remove the data, and if you're doing this in\n       * response to a `needMoreData` you should wait until the promise from `loadData` has resolved\n       * before you start removing data\n       * @param {Grid} grid the grid we're working on\n       * @param {boolean} scrollUp flag that there are pages upwards, fire\n       * infinite scroll events upward\n       * @param {boolean} scrollDown flag that there are pages downwards, so\n       * fire infinite scroll events downward\n       * @returns {promise} a promise that is resolved when the scrolling finishes\n       */\n      dataRemovedTop: function( grid, scrollUp, scrollDown ) {\n        var newVisibleRows, oldTop, newTop, rowHeight;\n        service.setScrollDirections( grid, scrollUp, scrollDown );\n\n        newVisibleRows = grid.renderContainers.body.visibleRowCache.length;\n        oldTop = grid.infiniteScroll.prevScrollTop;\n        rowHeight = grid.options.rowHeight;\n\n        // since we removed from the top, our new scroll row will be the old scroll row less the number\n        // of rows removed\n        newTop = oldTop - ( grid.infiniteScroll.previousVisibleRows - newVisibleRows )*rowHeight;\n\n        return service.adjustInfiniteScrollPosition( grid, newTop );\n      },\n\n      /**\n       * @ngdoc function\n       * @name dataRemovedBottom\n       * @methodOf ui.grid.infiniteScroll.api:PublicAPI\n       * @description Adjusts the scroll position after you've removed data at the bottom.  You should\n       * have called `saveScrollPercentage` before you remove the data, and if you're doing this in\n       * response to a `needMoreData` you should wait until the promise from `loadData` has resolved\n       * before you start removing data\n       * @param {Grid} grid the grid we're working on\n       * @param {boolean} scrollUp flag that there are pages upwards, fire\n       * infinite scroll events upward\n       * @param {boolean} scrollDown flag that there are pages downwards, so\n       * fire infinite scroll events downward\n       */\n      dataRemovedBottom: function( grid, scrollUp, scrollDown ) {\n        var newTop;\n        service.setScrollDirections( grid, scrollUp, scrollDown );\n\n        newTop = grid.infiniteScroll.prevScrollTop;\n\n        return service.adjustInfiniteScrollPosition( grid, newTop );\n      }\n    };\n    return service;\n  }]);\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.infiniteScroll.directive:uiGridInfiniteScroll\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds infinite scroll features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.infiniteScroll']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Alex', car: 'Toyota' },\n            { name: 'Sam', car: 'Lexus' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name'},\n        {name: 'car'}\n      ];\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-infinite-scroll=\"20\"></div>\n   </div>\n   </file>\n   </example>\n   */\n\n  module.directive('uiGridInfiniteScroll', ['uiGridInfiniteScrollService',\n    function (uiGridInfiniteScrollService) {\n      return {\n        priority: -200,\n        scope: false,\n        require: '^uiGrid',\n        compile: function($scope, $elm, $attr){\n          return {\n            pre: function($scope, $elm, $attr, uiGridCtrl) {\n              uiGridInfiniteScrollService.initializeGrid(uiGridCtrl.grid, $scope);\n            },\n            post: function($scope, $elm, $attr) {\n            }\n          };\n        }\n      };\n    }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.moveColumns\n   * @description\n   *\n   * # ui.grid.moveColumns\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Alpha</strong> This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>\n   *\n   * This module provides column moving capability to ui.grid. It enables to change the position of columns.\n   * <div doc-module-components=\"ui.grid.moveColumns\"></div>\n   */\n  var module = angular.module('ui.grid.moveColumns', ['ui.grid']);\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.moveColumns.service:uiGridMoveColumnService\n   *  @description Service for column moving feature.\n   */\n  module.service('uiGridMoveColumnService', ['$q', '$timeout', '$log', 'ScrollEvent', 'uiGridConstants', 'gridUtil', function ($q, $timeout, $log, ScrollEvent, uiGridConstants, gridUtil) {\n\n    var service = {\n      initializeGrid: function (grid) {\n        var self = this;\n        this.registerPublicApi(grid);\n        this.defaultGridOptions(grid.options);\n        grid.moveColumns = {orderCache: []}; // Used to cache the order before columns are rebuilt\n        grid.registerColumnBuilder(self.movableColumnBuilder);\n        grid.registerDataChangeCallback(self.verifyColumnOrder, [uiGridConstants.dataChange.COLUMN]);\n      },\n      registerPublicApi: function (grid) {\n        var self = this;\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.moveColumns.api:PublicApi\n         *  @description Public Api for column moving feature.\n         */\n        var publicApi = {\n          events: {\n            /**\n             * @ngdoc event\n             * @name columnPositionChanged\n             * @eventOf  ui.grid.moveColumns.api:PublicApi\n             * @description raised when column is moved\n             * <pre>\n             *      gridApi.colMovable.on.columnPositionChanged(scope,function(colDef, originalPosition, newPosition){})\n             * </pre>\n             * @param {object} colDef the column that was moved\n             * @param {integer} originalPosition of the column\n             * @param {integer} finalPosition of the column\n             */\n            colMovable: {\n              columnPositionChanged: function (colDef, originalPosition, newPosition) {\n              }\n            }\n          },\n          methods: {\n            /**\n             * @ngdoc method\n             * @name moveColumn\n             * @methodOf  ui.grid.moveColumns.api:PublicApi\n             * @description Method can be used to change column position.\n             * <pre>\n             *      gridApi.colMovable.moveColumn(oldPosition, newPosition)\n             * </pre>\n             * @param {integer} originalPosition of the column\n             * @param {integer} finalPosition of the column\n             */\n            colMovable: {\n              moveColumn: function (originalPosition, finalPosition) {\n                var columns = grid.columns;\n                if (!angular.isNumber(originalPosition) || !angular.isNumber(finalPosition)) {\n                  gridUtil.logError('MoveColumn: Please provide valid values for originalPosition and finalPosition');\n                  return;\n                }\n                var nonMovableColumns = 0;\n                for (var i = 0; i < columns.length; i++) {\n                  if ((angular.isDefined(columns[i].colDef.visible) && columns[i].colDef.visible === false) || columns[i].isRowHeader === true) {\n                    nonMovableColumns++;\n                  }\n                }\n                if (originalPosition >= (columns.length - nonMovableColumns) || finalPosition >= (columns.length - nonMovableColumns)) {\n                  gridUtil.logError('MoveColumn: Invalid values for originalPosition, finalPosition');\n                  return;\n                }\n                var findPositionForRenderIndex = function (index) {\n                  var position = index;\n                  for (var i = 0; i <= position; i++) {\n                    if (angular.isDefined(columns[i]) && ((angular.isDefined(columns[i].colDef.visible) && columns[i].colDef.visible === false) || columns[i].isRowHeader === true)) {\n                      position++;\n                    }\n                  }\n                  return position;\n                };\n                self.redrawColumnAtPosition(grid, findPositionForRenderIndex(originalPosition), findPositionForRenderIndex(finalPosition));\n              }\n            }\n          }\n        };\n        grid.api.registerEventsFromObject(publicApi.events);\n        grid.api.registerMethodsFromObject(publicApi.methods);\n      },\n      defaultGridOptions: function (gridOptions) {\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.moveColumns.api:GridOptions\n         *\n         *  @description Options for configuring the move column feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n        /**\n         *  @ngdoc object\n         *  @name enableColumnMoving\n         *  @propertyOf  ui.grid.moveColumns.api:GridOptions\n         *  @description If defined, sets the default value for the colMovable flag on each individual colDefs\n         *  if their individual enableColumnMoving configuration is not defined. Defaults to true.\n         */\n        gridOptions.enableColumnMoving = gridOptions.enableColumnMoving !== false;\n      },\n      movableColumnBuilder: function (colDef, col, gridOptions) {\n        var promises = [];\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.moveColumns.api:ColumnDef\n         *\n         *  @description Column Definition for move column feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n         */\n        /**\n         *  @ngdoc object\n         *  @name enableColumnMoving\n         *  @propertyOf  ui.grid.moveColumns.api:ColumnDef\n         *  @description Enable column moving for the column.\n         */\n        colDef.enableColumnMoving = colDef.enableColumnMoving === undefined ? gridOptions.enableColumnMoving\n          : colDef.enableColumnMoving;\n        return $q.all(promises);\n      },\n      /**\n       * @ngdoc method\n       * @name updateColumnCache\n       * @methodOf  ui.grid.moveColumns\n       * @description Cache the current order of columns, so we can restore them after new columnDefs are defined\n       */\n      updateColumnCache: function(grid){\n        grid.moveColumns.orderCache = grid.getOnlyDataColumns();\n      },\n      /**\n       * @ngdoc method\n       * @name verifyColumnOrder\n       * @methodOf  ui.grid.moveColumns\n       * @description dataChangeCallback which uses the cached column order to restore the column order\n       * when it is reset by altering the columnDefs array.\n       */\n      verifyColumnOrder: function(grid){\n        var headerRowOffset = grid.rowHeaderColumns.length;\n        var newIndex;\n\n        angular.forEach(grid.moveColumns.orderCache, function(cacheCol, cacheIndex){\n          newIndex = grid.columns.indexOf(cacheCol);\n          if ( newIndex !== -1 && newIndex - headerRowOffset !== cacheIndex ){\n            var column = grid.columns.splice(newIndex, 1)[0];\n            grid.columns.splice(cacheIndex + headerRowOffset, 0, column);\n          }\n        });\n      },\n      redrawColumnAtPosition: function (grid, originalPosition, newPosition) {\n        if (originalPosition === newPosition) {\n          return;\n        }\n\n        var columns = grid.columns;\n\n        var originalColumn = columns[originalPosition];\n        if (originalColumn.colDef.enableColumnMoving) {\n          if (originalPosition > newPosition) {\n            for (var i1 = originalPosition; i1 > newPosition; i1--) {\n              columns[i1] = columns[i1 - 1];\n            }\n          }\n          else if (newPosition > originalPosition) {\n            for (var i2 = originalPosition; i2 < newPosition; i2++) {\n              columns[i2] = columns[i2 + 1];\n            }\n          }\n          columns[newPosition] = originalColumn;\n          service.updateColumnCache(grid);\n          grid.queueGridRefresh();\n          $timeout(function () {\n            grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );\n            grid.api.colMovable.raise.columnPositionChanged(originalColumn.colDef, originalPosition, newPosition);\n          });\n        }\n      }\n    };\n    return service;\n  }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.moveColumns.directive:uiGridMoveColumns\n   *  @element div\n   *  @restrict A\n   *  @description Adds column moving features to the ui-grid directive.\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.moveColumns']);\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n        $scope.data = [\n          { name: 'Bob', title: 'CEO', age: 45 },\n          { name: 'Frank', title: 'Lowly Developer', age: 25 },\n          { name: 'Jenny', title: 'Highly Developer', age: 35 }\n        ];\n        $scope.columnDefs = [\n          {name: 'name'},\n          {name: 'title'},\n          {name: 'age'}\n        ];\n      }]);\n   </file>\n   <file name=\"main.css\">\n   .grid {\n      width: 100%;\n      height: 150px;\n    }\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div class=\"grid\" ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-move-columns></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridMoveColumns', ['uiGridMoveColumnService', function (uiGridMoveColumnService) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            uiGridMoveColumnService.initializeGrid(uiGridCtrl.grid);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.moveColumns.directive:uiGridHeaderCell\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Stacks on top of ui.grid.uiGridHeaderCell to provide capability to be able to move it to reposition column.\n   *\n   *  On receiving mouseDown event headerCell is cloned, now as the mouse moves the cloned header cell also moved in the grid.\n   *  In case the moving cloned header cell reaches the left or right extreme of grid, grid scrolling is triggered (if horizontal scroll exists).\n   *  On mouseUp event column is repositioned at position where mouse is released and cloned header cell is removed.\n   *\n   *  Events that invoke cloning of header cell:\n   *    - mousedown\n   *\n   *  Events that invoke movement of cloned header cell:\n   *    - mousemove\n   *\n   *  Events that invoke repositioning of column:\n   *    - mouseup\n   */\n  module.directive('uiGridHeaderCell', ['$q', 'gridUtil', 'uiGridMoveColumnService', '$document', '$log', 'uiGridConstants', 'ScrollEvent',\n    function ($q, gridUtil, uiGridMoveColumnService, $document, $log, uiGridConstants, ScrollEvent) {\n      return {\n        priority: -10,\n        require: '^uiGrid',\n        compile: function () {\n          return {\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n              if ($scope.col.colDef.enableColumnMoving) {\n\n                /*\n                 * Our general approach to column move is that we listen to a touchstart or mousedown\n                 * event over the column header.  When we hear one, then we wait for a move of the same type\n                 * - if we are a touchstart then we listen for a touchmove, if we are a mousedown we listen for\n                 * a mousemove (i.e. a drag) before we decide that there's a move underway.  If there's never a move,\n                 * and we instead get a mouseup or a touchend, then we just drop out again and do nothing.\n                 *\n                 */\n                var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') );\n\n                var gridLeft;\n                var previousMouseX;\n                var totalMouseMovement;\n                var rightMoveLimit;\n                var elmCloned = false;\n                var movingElm;\n                var reducedWidth;\n                var moveOccurred = false;\n\n                var downFn = function( event ){\n                  //Setting some variables required for calculations.\n                  gridLeft = $scope.grid.element[0].getBoundingClientRect().left;\n                  if ( $scope.grid.hasLeftContainer() ){\n                    gridLeft += $scope.grid.renderContainers.left.header[0].getBoundingClientRect().width;\n                  }\n\n                  previousMouseX = event.pageX;\n                  totalMouseMovement = 0;\n                  rightMoveLimit = gridLeft + $scope.grid.getViewportWidth();\n\n                  if ( event.type === 'mousedown' ){\n                    $document.on('mousemove', moveFn);\n                    $document.on('mouseup', upFn);\n                  } else if ( event.type === 'touchstart' ){\n                    $document.on('touchmove', moveFn);\n                    $document.on('touchend', upFn);\n                  }\n                };\n\n                var moveFn = function( event ) {\n                  var changeValue = event.pageX - previousMouseX;\n                  if ( changeValue === 0 ){ return; }\n                  //Disable text selection in Chrome during column move\n                  document.onselectstart = function() { return false; };\n\n                  moveOccurred = true;\n\n                  if (!elmCloned) {\n                    cloneElement();\n                  }\n                  else if (elmCloned) {\n                    moveElement(changeValue);\n                    previousMouseX = event.pageX;\n                  }\n                };\n\n                var upFn = function( event ){\n                  //Re-enable text selection after column move\n                  document.onselectstart = null;\n\n                  //Remove the cloned element on mouse up.\n                  if (movingElm) {\n                    movingElm.remove();\n                    elmCloned = false;\n                  }\n\n                  offAllEvents();\n                  onDownEvents();\n\n                  if (!moveOccurred){\n                    return;\n                  }\n\n                  var columns = $scope.grid.columns;\n                  var columnIndex = 0;\n                  for (var i = 0; i < columns.length; i++) {\n                    if (columns[i].colDef.name !== $scope.col.colDef.name) {\n                      columnIndex++;\n                    }\n                    else {\n                      break;\n                    }\n                  }\n\n                  var targetIndex;\n\n                  //Case where column should be moved to a position on its left\n                  if (totalMouseMovement < 0) {\n                    var totalColumnsLeftWidth = 0;\n                    var il;\n                    if ( $scope.grid.isRTL() ){\n                      for (il = columnIndex + 1; il < columns.length; il++) {\n                        if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) {\n                          totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width;\n                          if (totalColumnsLeftWidth > Math.abs(totalMouseMovement)) {\n                            uiGridMoveColumnService.redrawColumnAtPosition\n                            ($scope.grid, columnIndex, il - 1);\n                            break;\n                          }\n                        }\n                      }\n                    }\n                    else {\n                      for (il = columnIndex - 1; il >= 0; il--) {\n                        if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) {\n                          totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width;\n                          if (totalColumnsLeftWidth > Math.abs(totalMouseMovement)) {\n                            uiGridMoveColumnService.redrawColumnAtPosition\n                            ($scope.grid, columnIndex, il + 1);\n                            break;\n                          }\n                        }\n                      }\n                    }\n\n                    //Case where column should be moved to beginning (or end in RTL) of the grid.\n                    if (totalColumnsLeftWidth < Math.abs(totalMouseMovement)) {\n                      targetIndex = 0;\n                      if ( $scope.grid.isRTL() ){\n                        targetIndex = columns.length - 1;\n                      }\n                      uiGridMoveColumnService.redrawColumnAtPosition\n                      ($scope.grid, columnIndex, targetIndex);\n                    }\n                  }\n\n                  //Case where column should be moved to a position on its right\n                  else if (totalMouseMovement > 0) {\n                    var totalColumnsRightWidth = 0;\n                    var ir;\n                    if ( $scope.grid.isRTL() ){\n                      for (ir = columnIndex - 1; ir > 0; ir--) {\n                        if (angular.isUndefined(columns[ir].colDef.visible) || columns[ir].colDef.visible === true) {\n                          totalColumnsRightWidth += columns[ir].drawnWidth || columns[ir].width || columns[ir].colDef.width;\n                          if (totalColumnsRightWidth > totalMouseMovement) {\n                            uiGridMoveColumnService.redrawColumnAtPosition\n                            ($scope.grid, columnIndex, ir);\n                            break;\n                          }\n                        }\n                      }\n                    }\n                    else {\n                      for (ir = columnIndex + 1; ir < columns.length; ir++) {\n                        if (angular.isUndefined(columns[ir].colDef.visible) || columns[ir].colDef.visible === true) {\n                          totalColumnsRightWidth += columns[ir].drawnWidth || columns[ir].width || columns[ir].colDef.width;\n                          if (totalColumnsRightWidth > totalMouseMovement) {\n                            uiGridMoveColumnService.redrawColumnAtPosition\n                            ($scope.grid, columnIndex, ir - 1);\n                            break;\n                          }\n                        }\n                      }\n                    }\n\n\n                    //Case where column should be moved to end (or beginning in RTL) of the grid.\n                    if (totalColumnsRightWidth < totalMouseMovement) {\n                      targetIndex = columns.length - 1;\n                      if ( $scope.grid.isRTL() ){\n                        targetIndex = 0;\n                      }\n                      uiGridMoveColumnService.redrawColumnAtPosition\n                      ($scope.grid, columnIndex, targetIndex);\n                    }\n                  }\n\n\n\n                };\n\n                var onDownEvents = function(){\n                  $contentsElm.on('touchstart', downFn);\n                  $contentsElm.on('mousedown', downFn);\n                };\n\n                var offAllEvents = function() {\n                  $contentsElm.off('touchstart', downFn);\n                  $contentsElm.off('mousedown', downFn);\n\n                  $document.off('mousemove', moveFn);\n                  $document.off('touchmove', moveFn);\n\n                  $document.off('mouseup', upFn);\n                  $document.off('touchend', upFn);\n                };\n\n                onDownEvents();\n\n\n                var cloneElement = function () {\n                  elmCloned = true;\n\n                  //Cloning header cell and appending to current header cell.\n                  movingElm = $elm.clone();\n                  $elm.parent().append(movingElm);\n\n                  //Left of cloned element should be aligned to original header cell.\n                  movingElm.addClass('movingColumn');\n                  var movingElementStyles = {};\n                  movingElementStyles.left = $elm[0].offsetLeft + 'px';\n                  var gridRight = $scope.grid.element[0].getBoundingClientRect().right;\n                  var elmRight = $elm[0].getBoundingClientRect().right;\n                  if (elmRight > gridRight) {\n                    reducedWidth = $scope.col.drawnWidth + (gridRight - elmRight);\n                    movingElementStyles.width = reducedWidth + 'px';\n                  }\n                  movingElm.css(movingElementStyles);\n                };\n\n                var moveElement = function (changeValue) {\n                  //Calculate total column width\n                  var columns = $scope.grid.columns;\n                  var totalColumnWidth = 0;\n                  for (var i = 0; i < columns.length; i++) {\n                    if (angular.isUndefined(columns[i].colDef.visible) || columns[i].colDef.visible === true) {\n                      totalColumnWidth += columns[i].drawnWidth || columns[i].width || columns[i].colDef.width;\n                    }\n                  }\n\n                  //Calculate new position of left of column\n                  var currentElmLeft = movingElm[0].getBoundingClientRect().left - 1;\n                  var currentElmRight = movingElm[0].getBoundingClientRect().right;\n                  var newElementLeft;\n\n                  newElementLeft = currentElmLeft - gridLeft + changeValue;\n                  newElementLeft = newElementLeft < rightMoveLimit ? newElementLeft : rightMoveLimit;\n\n                  //Update css of moving column to adjust to new left value or fire scroll in case column has reached edge of grid\n                  if ((currentElmLeft >= gridLeft || changeValue > 0) && (currentElmRight <= rightMoveLimit || changeValue < 0)) {\n                    movingElm.css({visibility: 'visible', 'left': (movingElm[0].offsetLeft +\n                    (newElementLeft < rightMoveLimit ? changeValue : (rightMoveLimit - currentElmLeft))) + 'px'});\n                  }\n                  else if (totalColumnWidth > Math.ceil(uiGridCtrl.grid.gridWidth)) {\n                    changeValue *= 8;\n                    var scrollEvent = new ScrollEvent($scope.col.grid, null, null, 'uiGridHeaderCell.moveElement');\n                    scrollEvent.x = {pixels: changeValue};\n                    scrollEvent.grid.scrollContainers('',scrollEvent);\n                  }\n\n                  //Calculate total width of columns on the left of the moving column and the mouse movement\n                  var totalColumnsLeftWidth = 0;\n                  for (var il = 0; il < columns.length; il++) {\n                    if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) {\n                      if (columns[il].colDef.name !== $scope.col.colDef.name) {\n                        totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width;\n                      }\n                      else {\n                        break;\n                      }\n                    }\n                  }\n                  if ($scope.newScrollLeft === undefined) {\n                    totalMouseMovement += changeValue;\n                  }\n                  else {\n                    totalMouseMovement = $scope.newScrollLeft + newElementLeft - totalColumnsLeftWidth;\n                  }\n\n                  //Increase width of moving column, in case the rightmost column was moved and its width was\n                  //decreased because of overflow\n                  if (reducedWidth < $scope.col.drawnWidth) {\n                    reducedWidth += Math.abs(changeValue);\n                    movingElm.css({'width': reducedWidth + 'px'});\n                  }\n                };\n              }\n            }\n          };\n        }\n      };\n    }]);\n})();\n\n(function() {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.pagination\n   *\n   * @description\n   *\n   * # ui.grid.pagination\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Alpha</strong> This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>\n   *\n   * This module provides pagination support to ui-grid\n   */\n  var module = angular.module('ui.grid.pagination', ['ng', 'ui.grid']);\n\n  /**\n   * @ngdoc service\n   * @name ui.grid.pagination.service:uiGridPaginationService\n   *\n   * @description Service for the pagination feature\n   */\n  module.service('uiGridPaginationService', ['gridUtil',\n    function (gridUtil) {\n      var service = {\n        /**\n         * @ngdoc method\n         * @name initializeGrid\n         * @methodOf ui.grid.pagination.service:uiGridPaginationService\n         * @description Attaches the service to a certain grid\n         * @param {Grid} grid The grid we want to work with\n         */\n        initializeGrid: function (grid) {\n          service.defaultGridOptions(grid.options);\n\n          /**\n          * @ngdoc object\n          * @name ui.grid.pagination.api:PublicAPI\n          *\n          * @description Public API for the pagination feature\n          */\n          var publicApi = {\n            events: {\n              pagination: {\n              /**\n               * @ngdoc event\n               * @name paginationChanged\n               * @eventOf ui.grid.pagination.api:PublicAPI\n               * @description This event fires when the pageSize or currentPage changes\n               * @param {int} currentPage requested page number\n               * @param {int} pageSize requested page size\n               */\n                paginationChanged: function (currentPage, pageSize) { }\n              }\n            },\n            methods: {\n              pagination: {\n                /**\n                 * @ngdoc method\n                 * @name getPage\n                 * @methodOf ui.grid.pagination.api:PublicAPI\n                 * @description Returns the number of the current page\n                 */\n                getPage: function () {\n                  return grid.options.enablePagination ? grid.options.paginationCurrentPage : null;\n                },\n                /**\n                 * @ngdoc method\n                 * @name getTotalPages\n                 * @methodOf ui.grid.pagination.api:PublicAPI\n                 * @description Returns the total number of pages\n                 */\n                getTotalPages: function () {\n                  if (!grid.options.enablePagination) {\n                    return null;\n                  }\n\n                  return (grid.options.totalItems === 0) ? 1 : Math.ceil(grid.options.totalItems / grid.options.paginationPageSize);\n                },\n                /**\n                 * @ngdoc method\n                 * @name nextPage\n                 * @methodOf ui.grid.pagination.api:PublicAPI\n                 * @description Moves to the next page, if possible\n                 */\n                nextPage: function () {\n                  if (!grid.options.enablePagination) {\n                    return;\n                  }\n\n                  if (grid.options.totalItems > 0) {\n                    grid.options.paginationCurrentPage = Math.min(\n                      grid.options.paginationCurrentPage + 1,\n                      publicApi.methods.pagination.getTotalPages()\n                    );\n                  } else {\n                    grid.options.paginationCurrentPage++;\n                  }\n                },\n                /**\n                 * @ngdoc method\n                 * @name previousPage\n                 * @methodOf ui.grid.pagination.api:PublicAPI\n                 * @description Moves to the previous page, if we're not on the first page\n                 */\n                previousPage: function () {\n                  if (!grid.options.enablePagination) {\n                    return;\n                  }\n\n                  grid.options.paginationCurrentPage = Math.max(grid.options.paginationCurrentPage - 1, 1);\n                },\n                /**\n                 * @ngdoc method\n                 * @name seek\n                 * @methodOf ui.grid.pagination.api:PublicAPI\n                 * @description Moves to the requested page\n                 * @param {int} page The number of the page that should be displayed\n                 */\n                seek: function (page) {\n                  if (!grid.options.enablePagination) {\n                    return;\n                  }\n                  if (!angular.isNumber(page) || page < 1) {\n                    throw 'Invalid page number: ' + page;\n                  }\n\n                  grid.options.paginationCurrentPage = Math.min(page, publicApi.methods.pagination.getTotalPages());\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n          var processPagination = function( renderableRows ){\n            if (grid.options.useExternalPagination || !grid.options.enablePagination) {\n              return renderableRows;\n            }\n            //client side pagination\n            var pageSize = parseInt(grid.options.paginationPageSize, 10);\n            var currentPage = parseInt(grid.options.paginationCurrentPage, 10);\n\n            var visibleRows = renderableRows.filter(function (row) { return row.visible; });\n            grid.options.totalItems = visibleRows.length;\n\n            var firstRow = (currentPage - 1) * pageSize;\n            if (firstRow > visibleRows.length) {\n              currentPage = grid.options.paginationCurrentPage = 1;\n              firstRow = (currentPage - 1) * pageSize;\n            }\n            return visibleRows.slice(firstRow, firstRow + pageSize);\n          };\n\n          grid.registerRowsProcessor(processPagination, 900 );\n\n        },\n        defaultGridOptions: function (gridOptions) {\n          /**\n           * @ngdoc object\n           * @name ui.grid.pagination.api:GridOptions\n           *\n           * @description GridOptions for the pagination feature, these are available to be\n           * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           * @ngdoc property\n           * @name enablePagination\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Enables pagination.  Defaults to true.\n           */\n          gridOptions.enablePagination = gridOptions.enablePagination !== false;\n          /**\n           * @ngdoc property\n           * @name enablePaginationControls\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Enables the paginator at the bottom of the grid. Turn this off if you want to implement your\n           *              own controls outside the grid.\n           */\n          gridOptions.enablePaginationControls = gridOptions.enablePaginationControls !== false;\n          /**\n           * @ngdoc property\n           * @name useExternalPagination\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Disables client side pagination. When true, handle the paginationChanged event and set data\n           *              and totalItems.  Defaults to `false`\n           */\n          gridOptions.useExternalPagination = gridOptions.useExternalPagination === true;\n          /**\n           * @ngdoc property\n           * @name totalItems\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Total number of items, set automatically when using client side pagination, but needs set by user\n           *              for server side pagination\n           */\n          if (gridUtil.isNullOrUndefined(gridOptions.totalItems)) {\n            gridOptions.totalItems = 0;\n          }\n          /**\n           * @ngdoc property\n           * @name paginationPageSizes\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Array of page sizes, defaults to `[250, 500, 1000]`\n           */\n          if (gridUtil.isNullOrUndefined(gridOptions.paginationPageSizes)) {\n            gridOptions.paginationPageSizes = [250, 500, 1000];\n          }\n          /**\n           * @ngdoc property\n           * @name paginationPageSize\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Page size, defaults to the first item in paginationPageSizes, or 0 if paginationPageSizes is empty\n           */\n          if (gridUtil.isNullOrUndefined(gridOptions.paginationPageSize)) {\n            if (gridOptions.paginationPageSizes.length > 0) {\n              gridOptions.paginationPageSize = gridOptions.paginationPageSizes[0];\n            } else {\n              gridOptions.paginationPageSize = 0;\n            }\n          }\n          /**\n           * @ngdoc property\n           * @name paginationCurrentPage\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description Current page number, defaults to 1\n           */\n          if (gridUtil.isNullOrUndefined(gridOptions.paginationCurrentPage)) {\n            gridOptions.paginationCurrentPage = 1;\n          }\n\n          /**\n           * @ngdoc property\n           * @name paginationTemplate\n           * @propertyOf ui.grid.pagination.api:GridOptions\n           * @description A custom template for the pager, defaults to `ui-grid/pagination`\n           */\n          if (gridUtil.isNullOrUndefined(gridOptions.paginationTemplate)) {\n            gridOptions.paginationTemplate = 'ui-grid/pagination';\n          }\n        },\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.pagination.service:uiGridPaginationService\n         * @name uiGridPaginationService\n         * @description  Raises paginationChanged and calls refresh for client side pagination\n         * @param {Grid} grid the grid for which the pagination changed\n         * @param {int} currentPage requested page number\n         * @param {int} pageSize requested page size\n         */\n        onPaginationChanged: function (grid, currentPage, pageSize) {\n            grid.api.pagination.raise.paginationChanged(currentPage, pageSize);\n            if (!grid.options.useExternalPagination) {\n              grid.queueGridRefresh(); //client side pagination\n            }\n        }\n      };\n\n      return service;\n    }\n  ]);\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.pagination.directive:uiGridPagination\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds pagination features to grid\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.pagination']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Alex', car: 'Toyota' },\n        { name: 'Sam', car: 'Lexus' },\n        { name: 'Joe', car: 'Dodge' },\n        { name: 'Bob', car: 'Buick' },\n        { name: 'Cindy', car: 'Ford' },\n        { name: 'Brian', car: 'Audi' },\n        { name: 'Malcom', car: 'Mercedes Benz' },\n        { name: 'Dave', car: 'Ford' },\n        { name: 'Stacey', car: 'Audi' },\n        { name: 'Amy', car: 'Acura' },\n        { name: 'Scott', car: 'Toyota' },\n        { name: 'Ryan', car: 'BMW' },\n      ];\n\n      $scope.gridOptions = {\n        data: 'data',\n        paginationPageSizes: [5, 10, 25],\n        paginationPageSize: 5,\n        columnDefs: [\n          {name: 'name'},\n          {name: 'car'}\n        ]\n       }\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"gridOptions\" ui-grid-pagination></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridPagination', ['gridUtil', 'uiGridPaginationService',\n    function (gridUtil, uiGridPaginationService) {\n      return {\n        priority: -200,\n        scope: false,\n        require: 'uiGrid',\n        link: {\n          pre: function ($scope, $elm, $attr, uiGridCtrl) {\n            uiGridPaginationService.initializeGrid(uiGridCtrl.grid);\n\n            gridUtil.getTemplate(uiGridCtrl.grid.options.paginationTemplate)\n              .then(function (contents) {\n                var template = angular.element(contents);\n                $elm.append(template);\n                uiGridCtrl.innerCompile(template);\n              });\n          }\n        }\n      };\n    }\n  ]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.pagination.directive:uiGridPager\n   *  @element div\n   *\n   *  @description Panel for handling pagination\n   */\n  module.directive('uiGridPager', ['uiGridPaginationService', 'uiGridConstants', 'gridUtil', 'i18nService',\n    function (uiGridPaginationService, uiGridConstants, gridUtil, i18nService) {\n      return {\n        priority: -200,\n        scope: true,\n        require: '^uiGrid',\n        link: function ($scope, $elm, $attr, uiGridCtrl) {\n          var defaultFocusElementSelector = '.ui-grid-pager-control-input';\n          $scope.aria = i18nService.getSafeText('pagination.aria'); //Returns an object with all of the aria labels\n\n          $scope.paginationApi = uiGridCtrl.grid.api.pagination;\n          $scope.sizesLabel = i18nService.getSafeText('pagination.sizes');\n          $scope.totalItemsLabel = i18nService.getSafeText('pagination.totalItems');\n          $scope.paginationOf = i18nService.getSafeText('pagination.of');\n          $scope.paginationThrough = i18nService.getSafeText('pagination.through');\n\n          var options = uiGridCtrl.grid.options;\n\n          uiGridCtrl.grid.renderContainers.body.registerViewportAdjuster(function (adjustment) {\n            adjustment.height = adjustment.height - gridUtil.elementHeight($elm, \"padding\");\n            return adjustment;\n          });\n\n          var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback(function (grid) {\n            if (!grid.options.useExternalPagination) {\n              grid.options.totalItems = grid.rows.length;\n            }\n          }, [uiGridConstants.dataChange.ROW]);\n\n          $scope.$on('$destroy', dataChangeDereg);\n\n          var setShowing = function () {\n            $scope.showingLow = ((options.paginationCurrentPage - 1) * options.paginationPageSize) + 1;\n            $scope.showingHigh = Math.min(options.paginationCurrentPage * options.paginationPageSize, options.totalItems);\n          };\n\n          var deregT = $scope.$watch('grid.options.totalItems + grid.options.paginationPageSize', setShowing);\n\n          var deregP = $scope.$watch('grid.options.paginationCurrentPage + grid.options.paginationPageSize', function (newValues, oldValues) {\n              if (newValues === oldValues || oldValues === undefined) {\n                return;\n              }\n\n              if (!angular.isNumber(options.paginationCurrentPage) || options.paginationCurrentPage < 1) {\n                options.paginationCurrentPage = 1;\n                return;\n              }\n\n              if (options.totalItems > 0 && options.paginationCurrentPage > $scope.paginationApi.getTotalPages()) {\n                options.paginationCurrentPage = $scope.paginationApi.getTotalPages();\n                return;\n              }\n\n              setShowing();\n              uiGridPaginationService.onPaginationChanged($scope.grid, options.paginationCurrentPage, options.paginationPageSize);\n            }\n          );\n\n          $scope.$on('$destroy', function() {\n            deregT();\n            deregP();\n          });\n\n          $scope.cantPageForward = function () {\n            if (options.totalItems > 0) {\n              return options.paginationCurrentPage >= $scope.paginationApi.getTotalPages();\n            } else {\n              return options.data.length < 1;\n            }\n          };\n\n          $scope.cantPageToLast = function () {\n            if (options.totalItems > 0) {\n              return $scope.cantPageForward();\n            } else {\n              return true;\n            }\n          };\n\n          $scope.cantPageBackward = function () {\n            return options.paginationCurrentPage <= 1;\n          };\n\n          var focusToInputIf = function(condition){\n            if (condition){\n              gridUtil.focus.bySelector($elm, defaultFocusElementSelector);\n            }\n          };\n\n          //Takes care of setting focus to the middle element when focus is lost\n          $scope.pageFirstPageClick = function () {\n            $scope.paginationApi.seek(1);\n            focusToInputIf($scope.cantPageBackward());\n          };\n\n          $scope.pagePreviousPageClick = function () {\n            $scope.paginationApi.previousPage();\n            focusToInputIf($scope.cantPageBackward());\n          };\n\n          $scope.pageNextPageClick = function () {\n            $scope.paginationApi.nextPage();\n            focusToInputIf($scope.cantPageForward());\n          };\n\n          $scope.pageLastPageClick = function () {\n            $scope.paginationApi.seek($scope.paginationApi.getTotalPages());\n            focusToInputIf($scope.cantPageToLast());\n          };\n\n        }\n      };\n    }\n  ]);\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.pinning\n   * @description\n   *\n   * # ui.grid.pinning\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module provides column pinning to the end user via menu options in the column header\n   *\n   * <div doc-module-components=\"ui.grid.pinning\"></div>\n   */\n\n  var module = angular.module('ui.grid.pinning', ['ui.grid']);\n\n  module.constant('uiGridPinningConstants', {\n    container: {\n      LEFT: 'left',\n      RIGHT: 'right',\n      NONE: ''\n    }\n  });\n\n  module.service('uiGridPinningService', ['gridUtil', 'GridRenderContainer', 'i18nService', 'uiGridPinningConstants', function (gridUtil, GridRenderContainer, i18nService, uiGridPinningConstants) {\n    var service = {\n\n      initializeGrid: function (grid) {\n        service.defaultGridOptions(grid.options);\n\n        // Register a column builder to add new menu items for pinning left and right\n        grid.registerColumnBuilder(service.pinningColumnBuilder);\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.pinning.api:PublicApi\n         *\n         *  @description Public Api for pinning feature\n         */\n        var publicApi = {\n          events: {\n            pinning: {\n              /**\n               * @ngdoc event\n               * @name columnPin\n               * @eventOf ui.grid.pinning.api:PublicApi\n               * @description raised when column pin state has changed\n               * <pre>\n               *   gridApi.pinning.on.columnPinned(scope, function(colDef){})\n               * </pre>\n               * @param {object} colDef the column that was changed\n               * @param {string} container the render container the column is in ('left', 'right', '')\n               */\n              columnPinned: function(colDef, container) {\n              }\n            }\n          },\n          methods: {\n            pinning: {\n              /**\n               * @ngdoc function\n               * @name pinColumn\n               * @methodOf ui.grid.pinning.api:PublicApi\n               * @description pin column left, right, or none\n               * <pre>\n               *   gridApi.pinning.pinColumn(col, uiGridPinningConstants.container.LEFT)\n               * </pre>\n               * @param {gridColumn} col the column being pinned\n               * @param {string} container one of the recognised types\n               * from uiGridPinningConstants\n               */\n              pinColumn: function(col, container) {\n                service.pinColumn(grid, col, container);\n              }\n            }\n          }\n        };\n\n        grid.api.registerEventsFromObject(publicApi.events);\n        grid.api.registerMethodsFromObject(publicApi.methods);\n      },\n\n      defaultGridOptions: function (gridOptions) {\n        //default option to true unless it was explicitly set to false\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.pinning.api:GridOptions\n         *\n         *  @description GridOptions for pinning feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enablePinning\n         *  @propertyOf  ui.grid.pinning.api:GridOptions\n         *  @description Enable pinning for the entire grid.\n         *  <br/>Defaults to true\n         */\n        gridOptions.enablePinning = gridOptions.enablePinning !== false;\n\n      },\n\n      pinningColumnBuilder: function (colDef, col, gridOptions) {\n        //default to true unless gridOptions or colDef is explicitly false\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.pinning.api:ColumnDef\n         *\n         *  @description ColumnDef for pinning feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enablePinning\n         *  @propertyOf  ui.grid.pinning.api:ColumnDef\n         *  @description Enable pinning for the individual column.\n         *  <br/>Defaults to true\n         */\n        colDef.enablePinning = colDef.enablePinning === undefined ? gridOptions.enablePinning : colDef.enablePinning;\n\n\n        /**\n         *  @ngdoc object\n         *  @name pinnedLeft\n         *  @propertyOf  ui.grid.pinning.api:ColumnDef\n         *  @description Column is pinned left when grid is rendered\n         *  <br/>Defaults to false\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name pinnedRight\n         *  @propertyOf  ui.grid.pinning.api:ColumnDef\n         *  @description Column is pinned right when grid is rendered\n         *  <br/>Defaults to false\n         */\n        if (colDef.pinnedLeft) {\n          col.renderContainer = 'left';\n          col.grid.createLeftContainer();\n        }\n        else if (colDef.pinnedRight) {\n          col.renderContainer = 'right';\n          col.grid.createRightContainer();\n        }\n\n        if (!colDef.enablePinning) {\n          return;\n        }\n\n        var pinColumnLeftAction = {\n          name: 'ui.grid.pinning.pinLeft',\n          title: i18nService.get().pinning.pinLeft,\n          icon: 'ui-grid-icon-left-open',\n          shown: function () {\n            return typeof(this.context.col.renderContainer) === 'undefined' || !this.context.col.renderContainer || this.context.col.renderContainer !== 'left';\n          },\n          action: function () {\n            service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.LEFT);\n          }\n        };\n\n        var pinColumnRightAction = {\n          name: 'ui.grid.pinning.pinRight',\n          title: i18nService.get().pinning.pinRight,\n          icon: 'ui-grid-icon-right-open',\n          shown: function () {\n            return typeof(this.context.col.renderContainer) === 'undefined' || !this.context.col.renderContainer || this.context.col.renderContainer !== 'right';\n          },\n          action: function () {\n            service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.RIGHT);\n          }\n        };\n\n        var removePinAction = {\n          name: 'ui.grid.pinning.unpin',\n          title: i18nService.get().pinning.unpin,\n          icon: 'ui-grid-icon-cancel',\n          shown: function () {\n            return typeof(this.context.col.renderContainer) !== 'undefined' && this.context.col.renderContainer !== null && this.context.col.renderContainer !== 'body';\n          },\n          action: function () {\n            service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.NONE);\n          }\n        };\n\n        if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.pinLeft')) {\n          col.menuItems.push(pinColumnLeftAction);\n        }\n        if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.pinRight')) {\n          col.menuItems.push(pinColumnRightAction);\n        }\n        if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.unpin')) {\n          col.menuItems.push(removePinAction);\n        }\n      },\n\n      pinColumn: function(grid, col, container) {\n        if (container === uiGridPinningConstants.container.NONE) {\n          col.renderContainer = null;\n          col.colDef.pinnedLeft = col.colDef.pinnedRight = false;\n        }\n        else {\n          col.renderContainer = container;\n          if (container === uiGridPinningConstants.container.LEFT) {\n            grid.createLeftContainer();\n          }\n          else if (container === uiGridPinningConstants.container.RIGHT) {\n            grid.createRightContainer();\n          }\n        }\n\n        grid.refresh()\n        .then(function() {\n          grid.api.pinning.raise.columnPinned( col.colDef, container );\n        });\n      }\n    };\n\n    return service;\n  }]);\n\n  module.directive('uiGridPinning', ['gridUtil', 'uiGridPinningService',\n    function (gridUtil, uiGridPinningService) {\n      return {\n        require: 'uiGrid',\n        scope: false,\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n              uiGridPinningService.initializeGrid(uiGridCtrl.grid);\n            },\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            }\n          };\n        }\n      };\n    }]);\n\n\n})();\n\n(function(){\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.resizeColumns\n   * @description\n   *\n   * # ui.grid.resizeColumns\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module allows columns to be resized.\n   */\n  var module = angular.module('ui.grid.resizeColumns', ['ui.grid']);\n\n  module.service('uiGridResizeColumnsService', ['gridUtil', '$q', '$timeout',\n    function (gridUtil, $q, $timeout) {\n\n      var service = {\n        defaultGridOptions: function(gridOptions){\n          //default option to true unless it was explicitly set to false\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.resizeColumns.api:GridOptions\n           *\n           *  @description GridOptions for resizeColumns feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableColumnResizing\n           *  @propertyOf  ui.grid.resizeColumns.api:GridOptions\n           *  @description Enable column resizing on the entire grid\n           *  <br/>Defaults to true\n           */\n          gridOptions.enableColumnResizing = gridOptions.enableColumnResizing !== false;\n\n          //legacy support\n          //use old name if it is explicitly false\n          if (gridOptions.enableColumnResize === false){\n            gridOptions.enableColumnResizing = false;\n          }\n        },\n\n        colResizerColumnBuilder: function (colDef, col, gridOptions) {\n\n          var promises = [];\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.resizeColumns.api:ColumnDef\n           *\n           *  @description ColumnDef for resizeColumns feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableColumnResizing\n           *  @propertyOf  ui.grid.resizeColumns.api:ColumnDef\n           *  @description Enable column resizing on an individual column\n           *  <br/>Defaults to GridOptions.enableColumnResizing\n           */\n          //default to true unless gridOptions or colDef is explicitly false\n          colDef.enableColumnResizing = colDef.enableColumnResizing === undefined ? gridOptions.enableColumnResizing : colDef.enableColumnResizing;\n\n\n          //legacy support of old option name\n          if (colDef.enableColumnResize === false){\n            colDef.enableColumnResizing = false;\n          }\n\n          return $q.all(promises);\n        },\n\n        registerPublicApi: function (grid) {\n            /**\n             *  @ngdoc object\n             *  @name ui.grid.resizeColumns.api:PublicApi\n             *  @description Public Api for column resize feature.\n             */\n            var publicApi = {\n              events: {\n                /**\n                 * @ngdoc event\n                 * @name columnSizeChanged\n                 * @eventOf  ui.grid.resizeColumns.api:PublicApi\n                 * @description raised when column is resized\n                 * <pre>\n                 *      gridApi.colResizable.on.columnSizeChanged(scope,function(colDef, deltaChange){})\n                 * </pre>\n                 * @param {object} colDef the column that was resized\n                 * @param {integer} delta of the column size change\n                 */\n                colResizable: {\n                  columnSizeChanged: function (colDef, deltaChange) {\n                  }\n                }\n              }\n            };\n            grid.api.registerEventsFromObject(publicApi.events);\n        },\n\n        fireColumnSizeChanged: function (grid, colDef, deltaChange) {\n          $timeout(function () {\n            if ( grid.api.colResizable ){\n              grid.api.colResizable.raise.columnSizeChanged(colDef, deltaChange);\n            } else {\n              gridUtil.logError(\"The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition.  Cannot raise any events.\");\n            }\n          });\n        },\n\n        // get either this column, or the column next to this column, to resize,\n        // returns the column we're going to resize\n        findTargetCol: function(col, position, rtlMultiplier){\n          var renderContainer = col.getRenderContainer();\n\n          if (position === 'left') {\n            // Get the column to the left of this one\n            var colIndex = renderContainer.visibleColumnCache.indexOf(col);\n            return renderContainer.visibleColumnCache[colIndex - 1 * rtlMultiplier];\n          } else {\n            return col;\n          }\n        }\n\n      };\n\n      return service;\n\n    }]);\n\n\n  /**\n   * @ngdoc directive\n   * @name ui.grid.resizeColumns.directive:uiGridResizeColumns\n   * @element div\n   * @restrict A\n   * @description\n   * Enables resizing for all columns on the grid. If, for some reason, you want to use the ui-grid-resize-columns directive, but not allow column resizing, you can explicitly set the\n   * option to false. This prevents resizing for the entire grid, regardless of individual columnDef options.\n   *\n   * @example\n   <doc:example module=\"app\">\n   <doc:source>\n   <script>\n   var app = angular.module('app', ['ui.grid', 'ui.grid.resizeColumns']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n          $scope.gridOpts = {\n            data: [\n              { \"name\": \"Ethel Price\", \"gender\": \"female\", \"company\": \"Enersol\" },\n              { \"name\": \"Claudine Neal\", \"gender\": \"female\", \"company\": \"Sealoud\" },\n              { \"name\": \"Beryl Rice\", \"gender\": \"female\", \"company\": \"Velity\" },\n              { \"name\": \"Wilder Gonzales\", \"gender\": \"male\", \"company\": \"Geekko\" }\n            ]\n          };\n        }]);\n   </script>\n\n   <div ng-controller=\"MainCtrl\">\n   <div class=\"testGrid\" ui-grid=\"gridOpts\" ui-grid-resize-columns ></div>\n   </div>\n   </doc:source>\n   <doc:scenario>\n\n   </doc:scenario>\n   </doc:example>\n   */\n  module.directive('uiGridResizeColumns', ['gridUtil', 'uiGridResizeColumnsService', function (gridUtil, uiGridResizeColumnsService) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            uiGridResizeColumnsService.defaultGridOptions(uiGridCtrl.grid.options);\n            uiGridCtrl.grid.registerColumnBuilder( uiGridResizeColumnsService.colResizerColumnBuilder);\n            uiGridResizeColumnsService.registerPublicApi(uiGridCtrl.grid);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n\n  // Extend the uiGridHeaderCell directive\n  module.directive('uiGridHeaderCell', ['gridUtil', '$templateCache', '$compile', '$q', 'uiGridResizeColumnsService', 'uiGridConstants', '$timeout', function (gridUtil, $templateCache, $compile, $q, uiGridResizeColumnsService, uiGridConstants, $timeout) {\n    return {\n      // Run after the original uiGridHeaderCell\n      priority: -10,\n      require: '^uiGrid',\n      // scope: false,\n      compile: function() {\n        return {\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n            var grid = uiGridCtrl.grid;\n\n            if (grid.options.enableColumnResizing) {\n              var columnResizerElm = $templateCache.get('ui-grid/columnResizer');\n\n              var rtlMultiplier = 1;\n              //when in RTL mode reverse the direction using the rtlMultiplier and change the position to left\n              if (grid.isRTL()) {\n                $scope.position = 'left';\n                rtlMultiplier = -1;\n              }\n\n              var displayResizers = function(){\n\n                // remove any existing resizers.\n                var resizers = $elm[0].getElementsByClassName('ui-grid-column-resizer');\n                for ( var i = 0; i < resizers.length; i++ ){\n                  angular.element(resizers[i]).remove();\n                }\n\n                // get the target column for the left resizer\n                var otherCol = uiGridResizeColumnsService.findTargetCol($scope.col, 'left', rtlMultiplier);\n                var renderContainer = $scope.col.getRenderContainer();\n\n                // Don't append the left resizer if this is the first column or the column to the left of this one has resizing disabled\n                if (otherCol && renderContainer.visibleColumnCache.indexOf($scope.col) !== 0 && otherCol.colDef.enableColumnResizing !== false) {\n                  var resizerLeft = angular.element(columnResizerElm).clone();\n                  resizerLeft.attr('position', 'left');\n\n                  $elm.prepend(resizerLeft);\n                  $compile(resizerLeft)($scope);\n                }\n\n                // Don't append the right resizer if this column has resizing disabled\n                if ($scope.col.colDef.enableColumnResizing !== false) {\n                  var resizerRight = angular.element(columnResizerElm).clone();\n                  resizerRight.attr('position', 'right');\n\n                  $elm.append(resizerRight);\n                  $compile(resizerRight)($scope);\n                }\n              };\n\n              displayResizers();\n\n              var waitDisplay = function(){\n                $timeout(displayResizers);\n              };\n\n              var dataChangeDereg = grid.registerDataChangeCallback( waitDisplay, [uiGridConstants.dataChange.COLUMN] );\n\n              $scope.$on( '$destroy', dataChangeDereg );\n            }\n          }\n        };\n      }\n    };\n  }]);\n\n\n\n  /**\n   * @ngdoc directive\n   * @name ui.grid.resizeColumns.directive:uiGridColumnResizer\n   * @element div\n   * @restrict A\n   *\n   * @description\n   * Draggable handle that controls column resizing.\n   *\n   * @example\n   <doc:example module=\"app\">\n     <doc:source>\n       <script>\n        var app = angular.module('app', ['ui.grid', 'ui.grid.resizeColumns']);\n\n        app.controller('MainCtrl', ['$scope', function ($scope) {\n          $scope.gridOpts = {\n            enableColumnResizing: true,\n            data: [\n              { \"name\": \"Ethel Price\", \"gender\": \"female\", \"company\": \"Enersol\" },\n              { \"name\": \"Claudine Neal\", \"gender\": \"female\", \"company\": \"Sealoud\" },\n              { \"name\": \"Beryl Rice\", \"gender\": \"female\", \"company\": \"Velity\" },\n              { \"name\": \"Wilder Gonzales\", \"gender\": \"male\", \"company\": \"Geekko\" }\n            ]\n          };\n        }]);\n       </script>\n\n       <div ng-controller=\"MainCtrl\">\n        <div class=\"testGrid\" ui-grid=\"gridOpts\"></div>\n       </div>\n     </doc:source>\n     <doc:scenario>\n      // TODO: e2e specs?\n\n      // TODO: post-resize a horizontal scroll event should be fired\n     </doc:scenario>\n   </doc:example>\n   */\n  module.directive('uiGridColumnResizer', ['$document', 'gridUtil', 'uiGridConstants', 'uiGridResizeColumnsService', function ($document, gridUtil, uiGridConstants, uiGridResizeColumnsService) {\n    var resizeOverlay = angular.element('<div class=\"ui-grid-resize-overlay\"></div>');\n\n    var resizer = {\n      priority: 0,\n      scope: {\n        col: '=',\n        position: '@',\n        renderIndex: '='\n      },\n      require: '?^uiGrid',\n      link: function ($scope, $elm, $attrs, uiGridCtrl) {\n        var startX = 0,\n            x = 0,\n            gridLeft = 0,\n            rtlMultiplier = 1;\n\n        //when in RTL mode reverse the direction using the rtlMultiplier and change the position to left\n        if (uiGridCtrl.grid.isRTL()) {\n          $scope.position = 'left';\n          rtlMultiplier = -1;\n        }\n\n        if ($scope.position === 'left') {\n          $elm.addClass('left');\n        }\n        else if ($scope.position === 'right') {\n          $elm.addClass('right');\n        }\n\n        // Refresh the grid canvas\n        //   takes an argument representing the diff along the X-axis that the resize had\n        function refreshCanvas(xDiff) {\n          // Then refresh the grid canvas, rebuilding the styles so that the scrollbar updates its size\n          uiGridCtrl.grid.refreshCanvas(true).then( function() {\n            uiGridCtrl.grid.queueGridRefresh();\n          });\n        }\n\n        // Check that the requested width isn't wider than the maxWidth, or narrower than the minWidth\n        // Returns the new recommended with, after constraints applied\n        function constrainWidth(col, width){\n          var newWidth = width;\n\n          // If the new width would be less than the column's allowably minimum width, don't allow it\n          if (col.minWidth && newWidth < col.minWidth) {\n            newWidth = col.minWidth;\n          }\n          else if (col.maxWidth && newWidth > col.maxWidth) {\n            newWidth = col.maxWidth;\n          }\n\n          return newWidth;\n        }\n\n\n        /*\n         * Our approach to event handling aims to deal with both touch devices and mouse devices\n         * We register down handlers on both touch and mouse.  When a touchstart or mousedown event\n         * occurs, we register the corresponding touchmove/touchend, or mousemove/mouseend events.\n         *\n         * This way we can listen for both without worrying about the fact many touch devices also emulate\n         * mouse events - basically whichever one we hear first is what we'll go with.\n         */\n        function moveFunction(event, args) {\n          if (event.originalEvent) { event = event.originalEvent; }\n          event.preventDefault();\n\n          x = (event.targetTouches ? event.targetTouches[0] : event).clientX - gridLeft;\n\n          if (x < 0) { x = 0; }\n          else if (x > uiGridCtrl.grid.gridWidth) { x = uiGridCtrl.grid.gridWidth; }\n\n          var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier);\n\n          // Don't resize if it's disabled on this column\n          if (col.colDef.enableColumnResizing === false) {\n            return;\n          }\n\n          if (!uiGridCtrl.grid.element.hasClass('column-resizing')) {\n            uiGridCtrl.grid.element.addClass('column-resizing');\n          }\n\n          // Get the diff along the X axis\n          var xDiff = x - startX;\n\n          // Get the width that this mouse would give the column\n          var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10);\n\n          // check we're not outside the allowable bounds for this column\n          x = x + ( constrainWidth(col, newWidth) - newWidth ) * rtlMultiplier;\n\n          resizeOverlay.css({ left: x + 'px' });\n\n          uiGridCtrl.fireEvent(uiGridConstants.events.ITEM_DRAGGING);\n        }\n\n\n        function upFunction(event, args) {\n          if (event.originalEvent) { event = event.originalEvent; }\n          event.preventDefault();\n\n          uiGridCtrl.grid.element.removeClass('column-resizing');\n\n          resizeOverlay.remove();\n\n          // Resize the column\n          x = (event.changedTouches ? event.changedTouches[0] : event).clientX - gridLeft;\n          var xDiff = x - startX;\n\n          if (xDiff === 0) {\n            // no movement, so just reset event handlers, including turning back on both\n            // down events - we turned one off when this event started\n            offAllEvents();\n            onDownEvents();\n            return;\n          }\n\n          var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier);\n\n          // Don't resize if it's disabled on this column\n          if (col.colDef.enableColumnResizing === false) {\n            return;\n          }\n\n          // Get the new width\n          var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10);\n\n          // check we're not outside the allowable bounds for this column\n          col.width = constrainWidth(col, newWidth);\n          col.hasCustomWidth = true;\n\n          refreshCanvas(xDiff);\n\n          uiGridResizeColumnsService.fireColumnSizeChanged(uiGridCtrl.grid, col.colDef, xDiff);\n\n          // stop listening of up and move events - wait for next down\n          // reset the down events - we will have turned one off when this event started\n          offAllEvents();\n          onDownEvents();\n        }\n\n\n        var downFunction = function(event, args) {\n          if (event.originalEvent) { event = event.originalEvent; }\n          event.stopPropagation();\n\n          // Get the left offset of the grid\n          // gridLeft = uiGridCtrl.grid.element[0].offsetLeft;\n          gridLeft = uiGridCtrl.grid.element[0].getBoundingClientRect().left;\n\n          // Get the starting X position, which is the X coordinate of the click minus the grid's offset\n          startX = (event.targetTouches ? event.targetTouches[0] : event).clientX - gridLeft;\n\n          // Append the resizer overlay\n          uiGridCtrl.grid.element.append(resizeOverlay);\n\n          // Place the resizer overlay at the start position\n          resizeOverlay.css({ left: startX });\n\n          // Add handlers for move and up events - if we were mousedown then we listen for mousemove and mouseup, if\n          // we were touchdown then we listen for touchmove and touchup.  Also remove the handler for the equivalent\n          // down event - so if we're touchdown, then remove the mousedown handler until this event is over, if we're\n          // mousedown then remove the touchdown handler until this event is over, this avoids processing duplicate events\n          if ( event.type === 'touchstart' ){\n            $document.on('touchend', upFunction);\n            $document.on('touchmove', moveFunction);\n            $elm.off('mousedown', downFunction);\n          } else {\n            $document.on('mouseup', upFunction);\n            $document.on('mousemove', moveFunction);\n            $elm.off('touchstart', downFunction);\n          }\n        };\n\n        var onDownEvents = function() {\n          $elm.on('mousedown', downFunction);\n          $elm.on('touchstart', downFunction);\n        };\n\n        var offAllEvents = function() {\n          $document.off('mouseup', upFunction);\n          $document.off('touchend', upFunction);\n          $document.off('mousemove', moveFunction);\n          $document.off('touchmove', moveFunction);\n          $elm.off('mousedown', downFunction);\n          $elm.off('touchstart', downFunction);\n        };\n\n        onDownEvents();\n\n\n        // On doubleclick, resize to fit all rendered cells\n        var dblClickFn = function(event, args){\n          event.stopPropagation();\n\n          var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier);\n\n          // Don't resize if it's disabled on this column\n          if (col.colDef.enableColumnResizing === false) {\n            return;\n          }\n\n          // Go through the rendered rows and find out the max size for the data in this column\n          var maxWidth = 0;\n          var xDiff = 0;\n\n          // Get the parent render container element\n          var renderContainerElm = gridUtil.closestElm($elm, '.ui-grid-render-container');\n\n          // Get the cell contents so we measure correctly. For the header cell we have to account for the sort icon and the menu buttons, if present\n          var cells = renderContainerElm.querySelectorAll('.' + uiGridConstants.COL_CLASS_PREFIX + col.uid + ' .ui-grid-cell-contents');\n          Array.prototype.forEach.call(cells, function (cell) {\n              // Get the cell width\n              // gridUtil.logDebug('width', gridUtil.elementWidth(cell));\n\n              // Account for the menu button if it exists\n              var menuButton;\n              if (angular.element(cell).parent().hasClass('ui-grid-header-cell')) {\n                menuButton = angular.element(cell).parent()[0].querySelectorAll('.ui-grid-column-menu-button');\n              }\n\n              gridUtil.fakeElement(cell, {}, function(newElm) {\n                // Make the element float since it's a div and can expand to fill its container\n                var e = angular.element(newElm);\n                e.attr('style', 'float: left');\n\n                var width = gridUtil.elementWidth(e);\n\n                if (menuButton) {\n                  var menuButtonWidth = gridUtil.elementWidth(menuButton);\n                  width = width + menuButtonWidth;\n                }\n\n                if (width > maxWidth) {\n                  maxWidth = width;\n                  xDiff = maxWidth - width;\n                }\n              });\n            });\n\n          // check we're not outside the allowable bounds for this column\n          col.width = constrainWidth(col, maxWidth);\n          col.hasCustomWidth = true;\n\n          refreshCanvas(xDiff);\n\n          uiGridResizeColumnsService.fireColumnSizeChanged(uiGridCtrl.grid, col.colDef, xDiff);        };\n        $elm.on('dblclick', dblClickFn);\n\n        $elm.on('$destroy', function() {\n          $elm.off('dblclick', dblClickFn);\n          offAllEvents();\n        });\n      }\n    };\n\n    return resizer;\n  }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.rowEdit\n   * @description\n   *\n   * # ui.grid.rowEdit\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module extends the edit feature to provide tracking and saving of rows\n   * of data.  The tutorial provides more information on how this feature is best\n   * used {@link tutorial/205_row_editable here}.\n   * <br/>\n   * This feature depends on usage of the ui-grid-edit feature, and also benefits\n   * from use of ui-grid-cellNav to provide the full spreadsheet-like editing\n   * experience\n   *\n   */\n\n  var module = angular.module('ui.grid.rowEdit', ['ui.grid', 'ui.grid.edit', 'ui.grid.cellNav']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.rowEdit.constant:uiGridRowEditConstants\n   *\n   *  @description constants available in row edit module\n   */\n  module.constant('uiGridRowEditConstants', {\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.rowEdit.service:uiGridRowEditService\n   *\n   *  @description Services for row editing features\n   */\n  module.service('uiGridRowEditService', ['$interval', '$q', 'uiGridConstants', 'uiGridRowEditConstants', 'gridUtil',\n    function ($interval, $q, uiGridConstants, uiGridRowEditConstants, gridUtil) {\n\n      var service = {\n\n        initializeGrid: function (scope, grid) {\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.rowEdit.api:PublicApi\n           *\n           *  @description Public Api for rowEdit feature\n           */\n\n          grid.rowEdit = {};\n\n          var publicApi = {\n            events: {\n              rowEdit: {\n                /**\n                 * @ngdoc event\n                 * @eventOf ui.grid.rowEdit.api:PublicApi\n                 * @name saveRow\n                 * @description raised when a row is ready for saving.  Once your\n                 * row has saved you may need to use angular.extend to update the\n                 * data entity with any changed data from your save (for example,\n                 * lock version information if you're using optimistic locking,\n                 * or last update time/user information).\n                 *\n                 * Your method should call setSavePromise somewhere in the body before\n                 * returning control.  The feature will then wait, with the gridRow greyed out\n                 * whilst this promise is being resolved.\n                 *\n                 * <pre>\n                 *      gridApi.rowEdit.on.saveRow(scope,function(rowEntity){})\n                 * </pre>\n                 * and somewhere within the event handler:\n                 * <pre>\n                 *      gridApi.rowEdit.setSavePromise( rowEntity, savePromise)\n                 * </pre>\n                 * @param {object} rowEntity the options.data element that was edited\n                 * @returns {promise} Your saveRow method should return a promise, the\n                 * promise should either be resolved (implying successful save), or\n                 * rejected (implying an error).\n                 */\n                saveRow: function (rowEntity) {\n                }\n              }\n            },\n            methods: {\n              rowEdit: {\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name setSavePromise\n                 * @description Sets the promise associated with the row save, mandatory that\n                 * the saveRow event handler calls this method somewhere before returning.\n                 * <pre>\n                 *      gridApi.rowEdit.setSavePromise(rowEntity, savePromise)\n                 * </pre>\n                 * @param {object} rowEntity a data row from the grid for which a save has\n                 * been initiated\n                 * @param {promise} savePromise the promise that will be resolved when the\n                 * save is successful, or rejected if the save fails\n                 *\n                 */\n                setSavePromise: function ( rowEntity, savePromise) {\n                  service.setSavePromise(grid, rowEntity, savePromise);\n                },\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name getDirtyRows\n                 * @description Returns all currently dirty rows\n                 * <pre>\n                 *      gridApi.rowEdit.getDirtyRows(grid)\n                 * </pre>\n                 * @returns {array} An array of gridRows that are currently dirty\n                 *\n                 */\n                getDirtyRows: function () {\n                  return grid.rowEdit.dirtyRows ? grid.rowEdit.dirtyRows : [];\n                },\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name getErrorRows\n                 * @description Returns all currently errored rows\n                 * <pre>\n                 *      gridApi.rowEdit.getErrorRows(grid)\n                 * </pre>\n                 * @returns {array} An array of gridRows that are currently in error\n                 *\n                 */\n                getErrorRows: function () {\n                  return grid.rowEdit.errorRows ? grid.rowEdit.errorRows : [];\n                },\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name flushDirtyRows\n                 * @description Triggers a save event for all currently dirty rows, could\n                 * be used where user presses a save button or navigates away from the page\n                 * <pre>\n                 *      gridApi.rowEdit.flushDirtyRows(grid)\n                 * </pre>\n                 * @returns {promise} a promise that represents the aggregate of all\n                 * of the individual save promises - i.e. it will be resolved when all\n                 * the individual save promises have been resolved.\n                 *\n                 */\n                flushDirtyRows: function () {\n                  return service.flushDirtyRows(grid);\n                },\n\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name setRowsDirty\n                 * @description Sets each of the rows passed in dataRows\n                 * to be dirty.  note that if you have only just inserted the\n                 * rows into your data you will need to wait for a $digest cycle\n                 * before the gridRows are present - so often you would wrap this\n                 * call in a $interval or $timeout\n                 * <pre>\n                 *      $interval( function() {\n                 *        gridApi.rowEdit.setRowsDirty(myDataRows);\n                 *      }, 0, 1);\n                 * </pre>\n                 * @param {array} dataRows the data entities for which the gridRows\n                 * should be set dirty.\n                 *\n                 */\n                setRowsDirty: function ( dataRows) {\n                  service.setRowsDirty(grid, dataRows);\n                },\n\n                /**\n                 * @ngdoc method\n                 * @methodOf ui.grid.rowEdit.api:PublicApi\n                 * @name setRowsClean\n                 * @description Sets each of the rows passed in dataRows\n                 * to be clean, removing them from the dirty cache and the error cache,\n                 * and clearing the error flag and the dirty flag\n                 * <pre>\n                 *      var gridRows = $scope.gridApi.rowEdit.getDirtyRows();\n                 *      var dataRows = gridRows.map( function( gridRow ) { return gridRow.entity; });\n                 *      $scope.gridApi.rowEdit.setRowsClean( dataRows );\n                 * </pre>\n                 * @param {array} dataRows the data entities for which the gridRows\n                 * should be set clean.\n                 *\n                 */\n                setRowsClean: function ( dataRows) {\n                  service.setRowsClean(grid, dataRows);\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n          grid.api.core.on.renderingComplete( scope, function ( gridApi ) {\n            grid.api.edit.on.afterCellEdit( scope, service.endEditCell );\n            grid.api.edit.on.beginCellEdit( scope, service.beginEditCell );\n            grid.api.edit.on.cancelCellEdit( scope, service.cancelEditCell );\n\n            if ( grid.api.cellNav ) {\n              grid.api.cellNav.on.navigate( scope, service.navigate );\n            }\n          });\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.rowEdit.api:GridOptions\n           *\n           *  @description Options for configuring the rowEdit feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name saveRow\n         * @description  Returns a function that saves the specified row from the grid,\n         * and returns a promise\n         * @param {object} grid the grid for which dirty rows should be flushed\n         * @param {GridRow} gridRow the row that should be saved\n         * @returns {function} the saveRow function returns a function.  That function\n         * in turn, when called, returns a promise relating to the save callback\n         */\n        saveRow: function ( grid, gridRow ) {\n          var self = this;\n\n          return function() {\n            gridRow.isSaving = true;\n\n            if ( gridRow.rowEditSavePromise ){\n              // don't save the row again if it's already saving - that causes stale object exceptions\n              return gridRow.rowEditSavePromise;\n            }\n\n            var promise = grid.api.rowEdit.raise.saveRow( gridRow.entity );\n\n            if ( gridRow.rowEditSavePromise ){\n              gridRow.rowEditSavePromise.then( self.processSuccessPromise( grid, gridRow ), self.processErrorPromise( grid, gridRow ));\n            } else {\n              gridUtil.logError( 'A promise was not returned when saveRow event was raised, either nobody is listening to event, or event handler did not return a promise' );\n            }\n            return promise;\n          };\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf  ui.grid.rowEdit.service:uiGridRowEditService\n         * @name setSavePromise\n         * @description Sets the promise associated with the row save, mandatory that\n         * the saveRow event handler calls this method somewhere before returning.\n         * <pre>\n         *      gridApi.rowEdit.setSavePromise(grid, rowEntity)\n         * </pre>\n         * @param {object} grid the grid for which dirty rows should be returned\n         * @param {object} rowEntity a data row from the grid for which a save has\n         * been initiated\n         * @param {promise} savePromise the promise that will be resolved when the\n         * save is successful, or rejected if the save fails\n         *\n         */\n        setSavePromise: function (grid, rowEntity, savePromise) {\n          var gridRow = grid.getRow( rowEntity );\n          gridRow.rowEditSavePromise = savePromise;\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name processSuccessPromise\n         * @description  Returns a function that processes the successful\n         * resolution of a save promise\n         * @param {object} grid the grid for which the promise should be processed\n         * @param {GridRow} gridRow the row that has been saved\n         * @returns {function} the success handling function\n         */\n        processSuccessPromise: function ( grid, gridRow ) {\n          var self = this;\n\n          return function() {\n            delete gridRow.isSaving;\n            delete gridRow.isDirty;\n            delete gridRow.isError;\n            delete gridRow.rowEditSaveTimer;\n            delete gridRow.rowEditSavePromise;\n            self.removeRow( grid.rowEdit.errorRows, gridRow );\n            self.removeRow( grid.rowEdit.dirtyRows, gridRow );\n          };\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name processErrorPromise\n         * @description  Returns a function that processes the failed\n         * resolution of a save promise\n         * @param {object} grid the grid for which the promise should be processed\n         * @param {GridRow} gridRow the row that is now in error\n         * @returns {function} the error handling function\n         */\n        processErrorPromise: function ( grid, gridRow ) {\n          return function() {\n            delete gridRow.isSaving;\n            delete gridRow.rowEditSaveTimer;\n            delete gridRow.rowEditSavePromise;\n\n            gridRow.isError = true;\n\n            if (!grid.rowEdit.errorRows){\n              grid.rowEdit.errorRows = [];\n            }\n            if (!service.isRowPresent( grid.rowEdit.errorRows, gridRow ) ){\n              grid.rowEdit.errorRows.push( gridRow );\n            }\n          };\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name removeRow\n         * @description  Removes a row from a cache of rows - either\n         * grid.rowEdit.errorRows or grid.rowEdit.dirtyRows.  If the row\n         * is not present silently does nothing.\n         * @param {array} rowArray the array from which to remove the row\n         * @param {GridRow} gridRow the row that should be removed\n         */\n        removeRow: function( rowArray, removeGridRow ){\n          if (typeof(rowArray) === 'undefined' || rowArray === null){\n            return;\n          }\n\n          rowArray.forEach( function( gridRow, index ){\n            if ( gridRow.uid === removeGridRow.uid ){\n              rowArray.splice( index, 1);\n            }\n          });\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name isRowPresent\n         * @description  Checks whether a row is already present\n         * in the given array\n         * @param {array} rowArray the array in which to look for the row\n         * @param {GridRow} gridRow the row that should be looked for\n         */\n        isRowPresent: function( rowArray, removeGridRow ){\n          var present = false;\n          rowArray.forEach( function( gridRow, index ){\n            if ( gridRow.uid === removeGridRow.uid ){\n              present = true;\n            }\n          });\n          return present;\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name flushDirtyRows\n         * @description Triggers a save event for all currently dirty rows, could\n         * be used where user presses a save button or navigates away from the page\n         * <pre>\n         *      gridApi.rowEdit.flushDirtyRows(grid)\n         * </pre>\n         * @param {object} grid the grid for which dirty rows should be flushed\n         * @returns {promise} a promise that represents the aggregate of all\n         * of the individual save promises - i.e. it will be resolved when all\n         * the individual save promises have been resolved.\n         *\n         */\n        flushDirtyRows: function(grid){\n          var promises = [];\n          grid.api.rowEdit.getDirtyRows().forEach( function( gridRow ){\n            service.saveRow( grid, gridRow )();\n            promises.push( gridRow.rowEditSavePromise );\n          });\n\n          return $q.all( promises );\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name endEditCell\n         * @description Receives an afterCellEdit event from the edit function,\n         * and sets flags as appropriate.  Only the rowEntity parameter\n         * is processed, although other params are available.  Grid\n         * is automatically provided by the gridApi.\n         * @param {object} rowEntity the data entity for which the cell\n         * was edited\n         */\n        endEditCell: function( rowEntity, colDef, newValue, previousValue ){\n          var grid = this.grid;\n          var gridRow = grid.getRow( rowEntity );\n          if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, dirty flag cannot be set' ); return; }\n\n          if ( newValue !== previousValue || gridRow.isDirty ){\n            if ( !grid.rowEdit.dirtyRows ){\n              grid.rowEdit.dirtyRows = [];\n            }\n\n            if ( !gridRow.isDirty ){\n              gridRow.isDirty = true;\n              grid.rowEdit.dirtyRows.push( gridRow );\n            }\n\n            delete gridRow.isError;\n\n            service.considerSetTimer( grid, gridRow );\n          }\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name beginEditCell\n         * @description Receives a beginCellEdit event from the edit function,\n         * and cancels any rowEditSaveTimers if present, as the user is still editing\n         * this row.  Only the rowEntity parameter\n         * is processed, although other params are available.  Grid\n         * is automatically provided by the gridApi.\n         * @param {object} rowEntity the data entity for which the cell\n         * editing has commenced\n         */\n        beginEditCell: function( rowEntity, colDef ){\n          var grid = this.grid;\n          var gridRow = grid.getRow( rowEntity );\n          if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, timer cannot be cancelled' ); return; }\n\n          service.cancelTimer( grid, gridRow );\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name cancelEditCell\n         * @description Receives a cancelCellEdit event from the edit function,\n         * and if the row was already dirty, restarts the save timer.  If the row\n         * was not already dirty, then it's not dirty now either and does nothing.\n         *\n         * Only the rowEntity parameter\n         * is processed, although other params are available.  Grid\n         * is automatically provided by the gridApi.\n         *\n         * @param {object} rowEntity the data entity for which the cell\n         * editing was cancelled\n         */\n        cancelEditCell: function( rowEntity, colDef ){\n          var grid = this.grid;\n          var gridRow = grid.getRow( rowEntity );\n          if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, timer cannot be set' ); return; }\n\n          service.considerSetTimer( grid, gridRow );\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name navigate\n         * @description cellNav tells us that the selected cell has changed.  If\n         * the new row had a timer running, then stop it similar to in a beginCellEdit\n         * call.  If the old row is dirty and not the same as the new row, then\n         * start a timer on it.\n         * @param {object} newRowCol the row and column that were selected\n         * @param {object} oldRowCol the row and column that was left\n         *\n         */\n        navigate: function( newRowCol, oldRowCol ){\n          var grid = this.grid;\n          if ( newRowCol.row.rowEditSaveTimer ){\n            service.cancelTimer( grid, newRowCol.row );\n          }\n\n          if ( oldRowCol && oldRowCol.row && oldRowCol.row !== newRowCol.row ){\n            service.considerSetTimer( grid, oldRowCol.row );\n          }\n        },\n\n\n        /**\n         * @ngdoc property\n         * @propertyOf ui.grid.rowEdit.api:GridOptions\n         * @name rowEditWaitInterval\n         * @description How long the grid should wait for another change on this row\n         * before triggering a save (in milliseconds).  If set to -1, then saves are\n         * never triggered by timer (implying that the user will call flushDirtyRows()\n         * manually)\n         *\n         * @example\n         * Setting the wait interval to 4 seconds\n         * <pre>\n         *   $scope.gridOptions = { rowEditWaitInterval: 4000 }\n         * </pre>\n         *\n         */\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name considerSetTimer\n         * @description Consider setting a timer on this row (if it is dirty).  if there is a timer running\n         * on the row and the row isn't currently saving, cancel it, using cancelTimer, then if the row is\n         * dirty and not currently saving then set a new timer\n         * @param {object} grid the grid for which we are processing\n         * @param {GridRow} gridRow the row for which the timer should be adjusted\n         *\n         */\n        considerSetTimer: function( grid, gridRow ){\n          service.cancelTimer( grid, gridRow );\n\n          if ( gridRow.isDirty && !gridRow.isSaving ){\n            if ( grid.options.rowEditWaitInterval !== -1 ){\n              var waitTime = grid.options.rowEditWaitInterval ? grid.options.rowEditWaitInterval : 2000;\n              gridRow.rowEditSaveTimer = $interval( service.saveRow( grid, gridRow ), waitTime, 1);\n            }\n          }\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name cancelTimer\n         * @description cancel the $interval for any timer running on this row\n         * then delete the timer itself\n         * @param {object} grid the grid for which we are processing\n         * @param {GridRow} gridRow the row for which the timer should be adjusted\n         *\n         */\n        cancelTimer: function( grid, gridRow ){\n          if ( gridRow.rowEditSaveTimer && !gridRow.isSaving ){\n            $interval.cancel(gridRow.rowEditSaveTimer);\n            delete gridRow.rowEditSaveTimer;\n          }\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name setRowsDirty\n         * @description Sets each of the rows passed in dataRows\n         * to be dirty.  note that if you have only just inserted the\n         * rows into your data you will need to wait for a $digest cycle\n         * before the gridRows are present - so often you would wrap this\n         * call in a $interval or $timeout\n         * <pre>\n         *      $interval( function() {\n         *        gridApi.rowEdit.setRowsDirty( myDataRows);\n         *      }, 0, 1);\n         * </pre>\n         * @param {object} grid the grid for which rows should be set dirty\n         * @param {array} dataRows the data entities for which the gridRows\n         * should be set dirty.\n         *\n         */\n        setRowsDirty: function( grid, myDataRows ) {\n          var gridRow;\n          myDataRows.forEach( function( value, index ){\n            gridRow = grid.getRow( value );\n            if ( gridRow ){\n              if ( !grid.rowEdit.dirtyRows ){\n                grid.rowEdit.dirtyRows = [];\n              }\n\n              if ( !gridRow.isDirty ){\n                gridRow.isDirty = true;\n                grid.rowEdit.dirtyRows.push( gridRow );\n              }\n\n              delete gridRow.isError;\n\n              service.considerSetTimer( grid, gridRow );\n            } else {\n              gridUtil.logError( \"requested row not found in rowEdit.setRowsDirty, row was: \" + value );\n            }\n          });\n        },\n\n\n        /**\n         * @ngdoc method\n         * @methodOf ui.grid.rowEdit.service:uiGridRowEditService\n         * @name setRowsClean\n         * @description Sets each of the rows passed in dataRows\n         * to be clean, clearing the dirty flag and the error flag, and removing\n         * the rows from the dirty and error caches.\n         * @param {object} grid the grid for which rows should be set clean\n         * @param {array} dataRows the data entities for which the gridRows\n         * should be set clean.\n         *\n         */\n        setRowsClean: function( grid, myDataRows ) {\n          var gridRow;\n\n          myDataRows.forEach( function( value, index ){\n            gridRow = grid.getRow( value );\n            if ( gridRow ){\n              delete gridRow.isDirty;\n              service.removeRow( grid.rowEdit.dirtyRows, gridRow );\n              service.cancelTimer( grid, gridRow );\n\n              delete gridRow.isError;\n              service.removeRow( grid.rowEdit.errorRows, gridRow );\n            } else {\n              gridUtil.logError( \"requested row not found in rowEdit.setRowsClean, row was: \" + value );\n            }\n          });\n        }\n\n      };\n\n      return service;\n\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.rowEdit.directive:uiGridEdit\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds row editing features to the ui-grid-edit directive.\n   *\n   */\n  module.directive('uiGridRowEdit', ['gridUtil', 'uiGridRowEditService', 'uiGridEditConstants',\n  function (gridUtil, uiGridRowEditService, uiGridEditConstants) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            uiGridRowEditService.initializeGrid($scope, uiGridCtrl.grid);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.rowEdit.directive:uiGridViewport\n   *  @element div\n   *\n   *  @description Stacks on top of ui.grid.uiGridViewport to alter the attributes used\n   *  for the grid row to allow coloring of saving and error rows\n   */\n  module.directive('uiGridViewport',\n    ['$compile', 'uiGridConstants', 'gridUtil', '$parse',\n      function ($compile, uiGridConstants, gridUtil, $parse) {\n        return {\n          priority: -200, // run after default  directive\n          scope: false,\n          compile: function ($elm, $attrs) {\n            var rowRepeatDiv = angular.element($elm.children().children()[0]);\n\n            var existingNgClass = rowRepeatDiv.attr(\"ng-class\");\n            var newNgClass = '';\n            if ( existingNgClass ) {\n              newNgClass = existingNgClass.slice(0, -1) + \", 'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}\";\n            } else {\n              newNgClass = \"{'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}\";\n            }\n            rowRepeatDiv.attr(\"ng-class\", newNgClass);\n\n            return {\n              pre: function ($scope, $elm, $attrs, controllers) {\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n              }\n            };\n          }\n        };\n      }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.saveState\n   * @description\n   *\n   * # ui.grid.saveState\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * This module provides the ability to save the grid state, and restore\n   * it when the user returns to the page.\n   *\n   * No UI is provided, the caller should provide their own UI/buttons\n   * as appropriate. Usually the navigate events would be used to save\n   * the grid state and restore it.\n   *\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.save-state\"></div>\n   */\n\n  var module = angular.module('ui.grid.saveState', ['ui.grid', 'ui.grid.selection', 'ui.grid.cellNav', 'ui.grid.grouping', 'ui.grid.pinning', 'ui.grid.treeView']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.saveState.constant:uiGridSaveStateConstants\n   *\n   *  @description constants available in save state module\n   */\n\n  module.constant('uiGridSaveStateConstants', {\n    featureName: 'saveState'\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.saveState.service:uiGridSaveStateService\n   *\n   *  @description Services for saveState feature\n   */\n  module.service('uiGridSaveStateService', ['$q', 'uiGridSaveStateConstants', 'gridUtil', '$compile', '$interval', 'uiGridConstants',\n    function ($q, uiGridSaveStateConstants, gridUtil, $compile, $interval, uiGridConstants ) {\n\n      var service = {\n\n        initializeGrid: function (grid) {\n\n          //add feature namespace and any properties to grid for needed state\n          grid.saveState = {};\n          this.defaultGridOptions(grid.options);\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.saveState.api:PublicApi\n           *\n           *  @description Public Api for saveState feature\n           */\n          var publicApi = {\n            events: {\n              saveState: {\n              }\n            },\n            methods: {\n              saveState: {\n                /**\n                 * @ngdoc function\n                 * @name save\n                 * @methodOf  ui.grid.saveState.api:PublicApi\n                 * @description Packages the current state of the grid into\n                 * an object, and provides it to the user for saving\n                 * @returns {object} the state as a javascript object that can be saved\n                 */\n                save: function () {\n                  return service.save(grid);\n                },\n                /**\n                 * @ngdoc function\n                 * @name restore\n                 * @methodOf  ui.grid.saveState.api:PublicApi\n                 * @description Restores the provided state into the grid\n                 * @param {scope} $scope a scope that we can broadcast on\n                 * @param {object} state the state that should be restored into the grid\n                 */\n                restore: function ( $scope, state) {\n                  service.restore(grid, $scope, state);\n                }\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n          //default option to true unless it was explicitly set to false\n          /**\n           * @ngdoc object\n           * @name ui.grid.saveState.api:GridOptions\n           *\n           * @description GridOptions for saveState feature, these are available to be\n           * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n          /**\n           * @ngdoc object\n           * @name saveWidths\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the current column widths.  Note that unless\n           * you've provided the user with some way to resize their columns (say\n           * the resize columns feature), then this makes little sense.\n           * <br/>Defaults to true\n           */\n          gridOptions.saveWidths = gridOptions.saveWidths !== false;\n          /**\n           * @ngdoc object\n           * @name saveOrder\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Restore the current column order.  Note that unless\n           * you've provided the user with some way to reorder their columns (for\n           * example the move columns feature), this makes little sense.\n           * <br/>Defaults to true\n           */\n          gridOptions.saveOrder = gridOptions.saveOrder !== false;\n          /**\n           * @ngdoc object\n           * @name saveScroll\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the current scroll position.  Note that this\n           * is saved as the percentage of the grid scrolled - so if your\n           * user returns to a grid with a significantly different number of\n           * rows (perhaps some data has been deleted) then the scroll won't\n           * actually show the same rows as before.  If you want to scroll to\n           * a specific row then you should instead use the saveFocus option, which\n           * is the default.\n           *\n           * Note that this element will only be saved if the cellNav feature is\n           * enabled\n           * <br/>Defaults to false\n           */\n          gridOptions.saveScroll = gridOptions.saveScroll === true;\n          /**\n           * @ngdoc object\n           * @name saveFocus\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the current focused cell.  On returning\n           * to this focused cell we'll also scroll.  This option is\n           * preferred to the saveScroll option, so is set to true by\n           * default.  If saveScroll is set to true then this option will\n           * be disabled.\n           *\n           * By default this option saves the current row number and column\n           * number, and returns to that row and column.  However, if you define\n           * a saveRowIdentity function, then it will return you to the currently\n           * selected column within that row (in a business sense - so if some\n           * rows have been deleted, it will still find the same data, presuming it\n           * still exists in the list.  If it isn't in the list then it will instead\n           * return to the same row number - i.e. scroll percentage)\n           *\n           * Note that this option will do nothing if the cellNav\n           * feature is not enabled.\n           *\n           * <br/>Defaults to true (unless saveScroll is true)\n           */\n          gridOptions.saveFocus = gridOptions.saveScroll !== true && gridOptions.saveFocus !== false;\n          /**\n           * @ngdoc object\n           * @name saveRowIdentity\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description A function that can be called, passing in a rowEntity,\n           * and that will return a unique id for that row.  This might simply\n           * return the `id` field from that row (if you have one), or it might\n           * concatenate some fields within the row to make a unique value.\n           *\n           * This value will be used to find the same row again and set the focus\n           * to it, if it exists when we return.\n           *\n           * <br/>Defaults to undefined\n           */\n          /**\n           * @ngdoc object\n           * @name saveVisible\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save whether or not columns are visible.\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveVisible = gridOptions.saveVisible !== false;\n          /**\n           * @ngdoc object\n           * @name saveSort\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the current sort state for each column\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveSort = gridOptions.saveSort !== false;\n          /**\n           * @ngdoc object\n           * @name saveFilter\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the current filter state for each column\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveFilter = gridOptions.saveFilter !== false;\n          /**\n           * @ngdoc object\n           * @name saveSelection\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the currently selected rows.  If the `saveRowIdentity` callback\n           * is defined, then it will save the id of the row and select that.  If not, then\n           * it will attempt to select the rows by row number, which will give the wrong results\n           * if the data set has changed in the mean-time.\n           *\n           * Note that this option only does anything\n           * if the selection feature is enabled.\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveSelection = gridOptions.saveSelection !== false;\n          /**\n           * @ngdoc object\n           * @name saveGrouping\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the grouping configuration.  If set to true and the\n           * grouping feature is not enabled then does nothing.\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveGrouping = gridOptions.saveGrouping !== false;\n          /**\n           * @ngdoc object\n           * @name saveGroupingExpandedStates\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the grouping row expanded states.  If set to true and the\n           * grouping feature is not enabled then does nothing.\n           *\n           * This can be quite a bit of data, in many cases you wouldn't want to save this\n           * information.\n           *\n           * <br/>Defaults to false\n           */\n          gridOptions.saveGroupingExpandedStates = gridOptions.saveGroupingExpandedStates === true;\n          /**\n           * @ngdoc object\n           * @name savePinning\n           * @propertyOf ui.grid.saveState.api:GridOptions\n           * @description Save pinning state for columns.\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.savePinning = gridOptions.savePinning !== false;\n          /**\n           * @ngdoc object\n           * @name saveTreeView\n           * @propertyOf  ui.grid.saveState.api:GridOptions\n           * @description Save the treeView configuration.  If set to true and the\n           * treeView feature is not enabled then does nothing.\n           *\n           * <br/>Defaults to true\n           */\n          gridOptions.saveTreeView = gridOptions.saveTreeView !== false;\n        },\n\n\n\n        /**\n         * @ngdoc function\n         * @name save\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the current grid state into an object, and\n         * passes that object back to the caller\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {object} the state ready to be saved\n         */\n        save: function (grid) {\n          var savedState = {};\n\n          savedState.columns = service.saveColumns( grid );\n          savedState.scrollFocus = service.saveScrollFocus( grid );\n          savedState.selection = service.saveSelection( grid );\n          savedState.grouping = service.saveGrouping( grid );\n          savedState.treeView = service.saveTreeView( grid );\n          savedState.pagination = service.savePagination( grid );\n\n          return savedState;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name restore\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Applies the provided state to the grid\n         *\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {scope} $scope a scope that we can broadcast on\n         * @param {object} state the state we'd like to restore\n         */\n        restore: function( grid, $scope, state ){\n          if ( state.columns ) {\n            service.restoreColumns( grid, state.columns );\n          }\n\n          if ( state.scrollFocus ){\n            service.restoreScrollFocus( grid, $scope, state.scrollFocus );\n          }\n\n          if ( state.selection ){\n            service.restoreSelection( grid, state.selection );\n          }\n\n          if ( state.grouping ){\n            service.restoreGrouping( grid, state.grouping );\n          }\n\n          if ( state.treeView ){\n            service.restoreTreeView( grid, state.treeView );\n          }\n\n          if ( state.pagination ){\n            service.restorePagination( grid, state.pagination );\n          }\n\n          grid.refresh();\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name saveColumns\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the column setup, including sort, filters, ordering,\n         * pinning and column widths.\n         *\n         * Works through the current columns, storing them in order.  Stores the\n         * column name, then the visible flag, width, sort and filters for each column.\n         *\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {array} the columns state ready to be saved\n         */\n        saveColumns: function( grid ) {\n          var columns = [];\n          grid.getOnlyDataColumns().forEach( function( column ) {\n            var savedColumn = {};\n            savedColumn.name = column.name;\n\n            if ( grid.options.saveVisible ){\n              savedColumn.visible = column.visible;\n            }\n\n            if ( grid.options.saveWidths ){\n              savedColumn.width = column.width;\n            }\n\n            // these two must be copied, not just pointed too - otherwise our saved state is pointing to the same object as current state\n            if ( grid.options.saveSort ){\n              savedColumn.sort = angular.copy( column.sort );\n            }\n\n            if ( grid.options.saveFilter ){\n              savedColumn.filters = [];\n              column.filters.forEach( function( filter ){\n                var copiedFilter = {};\n                angular.forEach( filter, function( value, key) {\n                  if ( key !== 'condition' && key !== '$$hashKey' && key !== 'placeholder'){\n                    copiedFilter[key] = value;\n                  }\n                });\n                savedColumn.filters.push(copiedFilter);\n              });\n            }\n\n            if ( !!grid.api.pinning && grid.options.savePinning ){\n              savedColumn.pinned = column.renderContainer ? column.renderContainer : '';\n            }\n\n            columns.push( savedColumn );\n          });\n\n          return columns;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name saveScrollFocus\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the currently scroll or focus.\n         *\n         * If cellNav isn't present then does nothing - we can't return\n         * to the scroll position without cellNav anyway.\n         *\n         * If the cellNav module is present, and saveFocus is true, then\n         * it saves the currently focused cell.  If rowIdentity is present\n         * then saves using rowIdentity, otherwise saves visibleRowNum.\n         *\n         * If the cellNav module is not present, and saveScroll is true, then\n         * it approximates the current scroll row and column, and saves that.\n         *\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {object} the selection state ready to be saved\n         */\n        saveScrollFocus: function( grid ){\n          if ( !grid.api.cellNav ){\n            return {};\n          }\n\n          var scrollFocus = {};\n          if ( grid.options.saveFocus ){\n            scrollFocus.focus = true;\n            var rowCol = grid.api.cellNav.getFocusedCell();\n            if ( rowCol !== null ) {\n              if ( rowCol.col !== null ){\n                scrollFocus.colName = rowCol.col.colDef.name;\n              }\n              if ( rowCol.row !== null ){\n                scrollFocus.rowVal = service.getRowVal( grid, rowCol.row );\n              }\n            }\n          }\n\n          if ( grid.options.saveScroll || grid.options.saveFocus && !scrollFocus.colName && !scrollFocus.rowVal ) {\n            scrollFocus.focus = false;\n            if ( grid.renderContainers.body.prevRowScrollIndex ){\n              scrollFocus.rowVal = service.getRowVal( grid, grid.renderContainers.body.visibleRowCache[ grid.renderContainers.body.prevRowScrollIndex ]);\n            }\n\n            if ( grid.renderContainers.body.prevColScrollIndex ){\n              scrollFocus.colName = grid.renderContainers.body.visibleColumnCache[ grid.renderContainers.body.prevColScrollIndex ].name;\n            }\n          }\n\n          return scrollFocus;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name saveSelection\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the currently selected rows, if the selection feature is enabled\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {array} the selection state ready to be saved\n         */\n        saveSelection: function( grid ){\n          if ( !grid.api.selection || !grid.options.saveSelection ){\n            return [];\n          }\n\n          var selection = grid.api.selection.getSelectedGridRows().map( function( gridRow ) {\n            return service.getRowVal( grid, gridRow );\n          });\n\n          return selection;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name saveGrouping\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the grouping state, if the grouping feature is enabled\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {object} the grouping state ready to be saved\n         */\n        saveGrouping: function( grid ){\n          if ( !grid.api.grouping || !grid.options.saveGrouping ){\n            return {};\n          }\n\n          return grid.api.grouping.getGrouping( grid.options.saveGroupingExpandedStates );\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name savePagination\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the pagination state, if the pagination feature is enabled\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {object} the pagination state ready to be saved\n         */\n        savePagination: function( grid ) {\n          if ( !grid.api.pagination || !grid.options.paginationPageSize ){\n            return {};\n          }\n\n          return {\n            paginationCurrentPage: grid.options.paginationCurrentPage,\n            paginationPageSize: grid.options.paginationPageSize\n          };\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name saveTreeView\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Saves the tree view state, if the tree feature is enabled\n         * @param {Grid} grid the grid whose state we'd like to save\n         * @returns {object} the tree view state ready to be saved\n         */\n        saveTreeView: function( grid ){\n          if ( !grid.api.treeView || !grid.options.saveTreeView ){\n            return {};\n          }\n\n          return grid.api.treeView.getTreeView();\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name getRowVal\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Helper function that gets either the rowNum or\n         * the saveRowIdentity, given a gridRow\n         * @param {Grid} grid the grid the row is in\n         * @param {GridRow} gridRow the row we want the rowNum for\n         * @returns {object} an object containing { identity: true/false, row: rowNumber/rowIdentity }\n         *\n         */\n        getRowVal: function( grid, gridRow ){\n          if ( !gridRow ) {\n            return null;\n          }\n\n          var rowVal = {};\n          if ( grid.options.saveRowIdentity ){\n            rowVal.identity = true;\n            rowVal.row = grid.options.saveRowIdentity( gridRow.entity );\n          } else {\n            rowVal.identity = false;\n            rowVal.row = grid.renderContainers.body.visibleRowCache.indexOf( gridRow );\n          }\n          return rowVal;\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name restoreColumns\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Restores the columns, including order, visible, width,\n         * pinning, sort and filters.\n         *\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} columnsState the list of columns we had before, with their state\n         */\n        restoreColumns: function( grid, columnsState ){\n          var isSortChanged = false;\n\n          columnsState.forEach( function( columnState, index ) {\n            var currentCol = grid.getColumn( columnState.name );\n\n            if ( currentCol && !grid.isRowHeaderColumn(currentCol) ){\n              if ( grid.options.saveVisible &&\n                   ( currentCol.visible !== columnState.visible ||\n                     currentCol.colDef.visible !== columnState.visible ) ){\n                currentCol.visible = columnState.visible;\n                currentCol.colDef.visible = columnState.visible;\n                grid.api.core.raise.columnVisibilityChanged(currentCol);\n              }\n\n              if ( grid.options.saveWidths && currentCol.width !== columnState.width){\n                currentCol.width = columnState.width;\n                currentCol.hasCustomWidth = true;\n              }\n\n              if ( grid.options.saveSort &&\n                   !angular.equals(currentCol.sort, columnState.sort) &&\n                   !( currentCol.sort === undefined && angular.isEmpty(columnState.sort) ) ){\n                currentCol.sort = angular.copy( columnState.sort );\n                isSortChanged = true;\n              }\n\n              if ( grid.options.saveFilter &&\n                   !angular.equals(currentCol.filters, columnState.filters ) ){\n                columnState.filters.forEach( function( filter, index ){\n                  angular.extend( currentCol.filters[index], filter );\n                  if ( typeof(filter.term) === 'undefined' || filter.term === null ){\n                    delete currentCol.filters[index].term;\n                  }\n                });\n                grid.api.core.raise.filterChanged();\n              }\n\n              if ( !!grid.api.pinning && grid.options.savePinning && currentCol.renderContainer !== columnState.pinned ){\n                grid.api.pinning.pinColumn(currentCol, columnState.pinned);\n              }\n\n              var currentIndex = grid.getOnlyDataColumns().indexOf( currentCol );\n              if (currentIndex !== -1) {\n                if (grid.options.saveOrder && currentIndex !== index) {\n                  var column = grid.columns.splice(currentIndex + grid.rowHeaderColumns.length, 1)[0];\n                  grid.columns.splice(index + grid.rowHeaderColumns.length, 0, column);\n                }\n              }\n            }\n          });\n\n          if ( isSortChanged ) {\n            grid.api.core.raise.sortChanged( grid, grid.getColumnSorting() );\n          }\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name restoreScrollFocus\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Scrolls to the position that was saved.  If focus is true, then\n         * sets focus to the specified row/col.  If focus is false, then scrolls to the\n         * specified row/col.\n         *\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {scope} $scope a scope that we can broadcast on\n         * @param {object} scrollFocusState the scroll/focus state ready to be restored\n         */\n        restoreScrollFocus: function( grid, $scope, scrollFocusState ){\n          if ( !grid.api.cellNav ){\n            return;\n          }\n\n          var colDef, row;\n          if ( scrollFocusState.colName ){\n            var colDefs = grid.options.columnDefs.filter( function( colDef ) { return colDef.name === scrollFocusState.colName; });\n            if ( colDefs.length > 0 ){\n              colDef = colDefs[0];\n            }\n          }\n\n          if ( scrollFocusState.rowVal && scrollFocusState.rowVal.row ){\n            if ( scrollFocusState.rowVal.identity ){\n              row = service.findRowByIdentity( grid, scrollFocusState.rowVal );\n            } else {\n              row = grid.renderContainers.body.visibleRowCache[ scrollFocusState.rowVal.row ];\n            }\n          }\n\n          var entity = row && row.entity ? row.entity : null ;\n\n          if ( colDef || entity ) {\n            if (scrollFocusState.focus ){\n              grid.api.cellNav.scrollToFocus( entity, colDef );\n            } else {\n              grid.scrollTo( entity, colDef );\n            }\n          }\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name restoreSelection\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Selects the rows that are provided in the selection\n         * state.  If you are using `saveRowIdentity` and more than one row matches the identity\n         * function then only the first is selected.\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} selectionState the selection state ready to be restored\n         */\n        restoreSelection: function( grid, selectionState ){\n          if ( !grid.api.selection ){\n            return;\n          }\n\n          grid.api.selection.clearSelectedRows();\n\n          selectionState.forEach(  function( rowVal ) {\n            if ( rowVal.identity ){\n              var foundRow = service.findRowByIdentity( grid, rowVal );\n\n              if ( foundRow ){\n                grid.api.selection.selectRow( foundRow.entity );\n              }\n\n            } else {\n              grid.api.selection.selectRowByVisibleIndex( rowVal.row );\n            }\n          });\n        },\n\n\n        /**\n         * @ngdoc function\n         * @name restoreGrouping\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Restores the grouping configuration, if the grouping feature\n         * is enabled.\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} groupingState the grouping state ready to be restored\n         */\n        restoreGrouping: function( grid, groupingState ){\n          if ( !grid.api.grouping || typeof(groupingState) === 'undefined' || groupingState === null || angular.equals(groupingState, {}) ){\n            return;\n          }\n\n          grid.api.grouping.setGrouping( groupingState );\n        },\n\n        /**\n         * @ngdoc function\n         * @name restoreTreeView\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Restores the tree view configuration, if the tree view feature\n         * is enabled.\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} treeViewState the tree view state ready to be restored\n         */\n        restoreTreeView: function( grid, treeViewState ){\n          if ( !grid.api.treeView || typeof(treeViewState) === 'undefined' || treeViewState === null || angular.equals(treeViewState, {}) ){\n            return;\n          }\n\n          grid.api.treeView.setTreeView( treeViewState );\n        },\n\n        /**\n         * @ngdoc function\n         * @name restorePagination\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Restores the pagination information, if pagination is enabled.\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} pagination the pagination object to be restored\n         * @param {number} pagination.paginationCurrentPage the page number to restore\n         * @param {number} pagination.paginationPageSize the number of items displayed per page\n         */\n        restorePagination: function( grid, pagination ){\n          if ( !grid.api.pagination || !grid.options.paginationPageSize ){\n            return;\n          }\n\n          grid.options.paginationCurrentPage = pagination.paginationCurrentPage;\n          grid.options.paginationPageSize = pagination.paginationPageSize;\n        },\n\n        /**\n         * @ngdoc function\n         * @name findRowByIdentity\n         * @methodOf  ui.grid.saveState.service:uiGridSaveStateService\n         * @description Finds a row given it's identity value, returns the first found row\n         * if any are found, otherwise returns null if no rows are found.\n         * @param {Grid} grid the grid whose state we'd like to restore\n         * @param {object} rowVal the row we'd like to find\n         * @returns {gridRow} the found row, or null if none found\n         */\n        findRowByIdentity: function( grid, rowVal ){\n          if ( !grid.options.saveRowIdentity ){\n            return null;\n          }\n\n          var filteredRows = grid.rows.filter( function( gridRow ) {\n            if ( grid.options.saveRowIdentity( gridRow.entity ) === rowVal.row ){\n              return true;\n            } else {\n              return false;\n            }\n          });\n\n          if ( filteredRows.length > 0 ){\n            return filteredRows[0];\n          } else {\n            return null;\n          }\n        }\n      };\n\n      return service;\n\n    }\n  ]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.saveState.directive:uiGridSaveState\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds saveState features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.saveState']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n        { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.gridOptions = {\n        columnDefs: [\n          {name: 'name'},\n          {name: 'title', enableCellEdit: true}\n        ],\n        data: $scope.data\n      };\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"gridOptions\" ui-grid-save-state></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridSaveState', ['uiGridSaveStateConstants', 'uiGridSaveStateService', 'gridUtil', '$compile',\n    function (uiGridSaveStateConstants, uiGridSaveStateService, gridUtil, $compile) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        link: function ($scope, $elm, $attrs, uiGridCtrl) {\n          uiGridSaveStateService.initializeGrid(uiGridCtrl.grid);\n        }\n      };\n    }\n  ]);\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.selection\n   * @description\n   *\n   * # ui.grid.selection\n   * This module provides row selection\n   *\n   * <div class=\"alert alert-success\" role=\"alert\"><strong>Stable</strong> This feature is stable. There should no longer be breaking api changes without a deprecation warning.</div>\n   *\n   * <div doc-module-components=\"ui.grid.selection\"></div>\n   */\n\n  var module = angular.module('ui.grid.selection', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.selection.constant:uiGridSelectionConstants\n   *\n   *  @description constants available in selection module\n   */\n  module.constant('uiGridSelectionConstants', {\n    featureName: \"selection\",\n    selectionRowHeaderColName: 'selectionRowHeaderCol'\n  });\n\n  //add methods to GridRow\n  angular.module('ui.grid').config(['$provide', function($provide) {\n    $provide.decorator('GridRow', ['$delegate', function($delegate) {\n\n      /**\n       *  @ngdoc object\n       *  @name ui.grid.selection.api:GridRow\n       *\n       *  @description GridRow prototype functions added for selection\n       */\n\n      /**\n       *  @ngdoc object\n       *  @name enableSelection\n       *  @propertyOf  ui.grid.selection.api:GridRow\n       *  @description Enable row selection for this row, only settable by internal code.\n       *\n       *  The grouping feature, for example, might set group header rows to not be selectable.\n       *  <br/>Defaults to true\n       */\n\n      /**\n       *  @ngdoc object\n       *  @name isSelected\n       *  @propertyOf  ui.grid.selection.api:GridRow\n       *  @description Selected state of row.  Should be readonly. Make any changes to selected state using setSelected().\n       *  <br/>Defaults to false\n       */\n\n\n        /**\n         * @ngdoc function\n         * @name setSelected\n         * @methodOf ui.grid.selection.api:GridRow\n         * @description Sets the isSelected property and updates the selectedCount\n         * Changes to isSelected state should only be made via this function\n         * @param {bool} selected value to set\n         */\n        $delegate.prototype.setSelected = function(selected) {\n          this.isSelected = selected;\n          if (selected) {\n            this.grid.selection.selectedCount++;\n          }\n          else {\n            this.grid.selection.selectedCount--;\n          }\n        };\n\n      return $delegate;\n    }]);\n  }]);\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.selection.service:uiGridSelectionService\n   *\n   *  @description Services for selection features\n   */\n  module.service('uiGridSelectionService', ['$q', '$templateCache', 'uiGridSelectionConstants', 'gridUtil',\n    function ($q, $templateCache, uiGridSelectionConstants, gridUtil) {\n\n      var service = {\n\n        initializeGrid: function (grid) {\n\n          //add feature namespace and any properties to grid for needed\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.selection.grid:selection\n           *\n           *  @description Grid properties and functions added for selection\n           */\n          grid.selection = {};\n          grid.selection.lastSelectedRow = null;\n          grid.selection.selectAll = false;\n\n\n          /**\n           *  @ngdoc object\n           *  @name selectedCount\n           *  @propertyOf  ui.grid.selection.grid:selection\n           *  @description Current count of selected rows\n           *  @example\n           *  var count = grid.selection.selectedCount\n           */\n          grid.selection.selectedCount = 0;\n\n          service.defaultGridOptions(grid.options);\n\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.selection.api:PublicApi\n           *\n           *  @description Public Api for selection feature\n           */\n          var publicApi = {\n            events: {\n              selection: {\n                /**\n                 * @ngdoc event\n                 * @name rowSelectionChanged\n                 * @eventOf  ui.grid.selection.api:PublicApi\n                 * @description  is raised after the row.isSelected state is changed\n                 * @param {GridRow} row the row that was selected/deselected\n                 * @param {Event} event object if raised from an event\n                 */\n                rowSelectionChanged: function (scope, row, evt) {\n                },\n                /**\n                 * @ngdoc event\n                 * @name rowSelectionChangedBatch\n                 * @eventOf  ui.grid.selection.api:PublicApi\n                 * @description  is raised after the row.isSelected state is changed\n                 * in bulk, if the `enableSelectionBatchEvent` option is set to true\n                 * (which it is by default).  This allows more efficient processing\n                 * of bulk events.\n                 * @param {array} rows the rows that were selected/deselected\n                 * @param {Event} event object if raised from an event\n                 */\n                rowSelectionChangedBatch: function (scope, rows, evt) {\n                }\n              }\n            },\n            methods: {\n              selection: {\n                /**\n                 * @ngdoc function\n                 * @name toggleRowSelection\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Toggles data row as selected or unselected\n                 * @param {object} rowEntity gridOptions.data[] array instance\n                 * @param {Event} event object if raised from an event\n                 */\n                toggleRowSelection: function (rowEntity, evt) {\n                  var row = grid.getRow(rowEntity);\n                  if (row !== null) {\n                    service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect);\n                  }\n                },\n                /**\n                 * @ngdoc function\n                 * @name selectRow\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Select the data row\n                 * @param {object} rowEntity gridOptions.data[] array instance\n                 * @param {Event} event object if raised from an event\n                 */\n                selectRow: function (rowEntity, evt) {\n                  var row = grid.getRow(rowEntity);\n                  if (row !== null && !row.isSelected) {\n                    service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect);\n                  }\n                },\n                /**\n                 * @ngdoc function\n                 * @name selectRowByVisibleIndex\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Select the specified row by visible index (i.e. if you\n                 * specify row 0 you'll get the first visible row selected).  In this context\n                 * visible means of those rows that are theoretically visible (i.e. not filtered),\n                 * rather than rows currently rendered on the screen.\n                 * @param {number} index index within the rowsVisible array\n                 * @param {Event} event object if raised from an event\n                 */\n                selectRowByVisibleIndex: function ( rowNum, evt ) {\n                  var row = grid.renderContainers.body.visibleRowCache[rowNum];\n                  if (row !== null && typeof(row) !== 'undefined' && !row.isSelected) {\n                    service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect);\n                  }\n                },\n                /**\n                 * @ngdoc function\n                 * @name unSelectRow\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description UnSelect the data row\n                 * @param {object} rowEntity gridOptions.data[] array instance\n                 * @param {Event} event object if raised from an event\n                 */\n                unSelectRow: function (rowEntity, evt) {\n                  var row = grid.getRow(rowEntity);\n                  if (row !== null && row.isSelected) {\n                    service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect);\n                  }\n                },\n                /**\n                 * @ngdoc function\n                 * @name selectAllRows\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Selects all rows.  Does nothing if multiSelect = false\n                 * @param {Event} event object if raised from an event\n                 */\n                selectAllRows: function (evt) {\n                  if (grid.options.multiSelect === false) {\n                    return;\n                  }\n\n                  var changedRows = [];\n                  grid.rows.forEach(function (row) {\n                    if ( !row.isSelected && row.enableSelection !== false ){\n                      row.setSelected(true);\n                      service.decideRaiseSelectionEvent( grid, row, changedRows, evt );\n                    }\n                  });\n                  service.decideRaiseSelectionBatchEvent( grid, changedRows, evt );\n                  grid.selection.selectAll = true;\n                },\n                /**\n                 * @ngdoc function\n                 * @name selectAllVisibleRows\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Selects all visible rows.  Does nothing if multiSelect = false\n                 * @param {Event} event object if raised from an event\n                 */\n                selectAllVisibleRows: function (evt) {\n                  if (grid.options.multiSelect === false) {\n                    return;\n                  }\n\n                  var changedRows = [];\n                  grid.rows.forEach(function (row) {\n                    if (row.visible) {\n                      if (!row.isSelected && row.enableSelection !== false){\n                        row.setSelected(true);\n                        service.decideRaiseSelectionEvent( grid, row, changedRows, evt );\n                      }\n                    } else {\n                      if (row.isSelected){\n                        row.setSelected(false);\n                        service.decideRaiseSelectionEvent( grid, row, changedRows, evt );\n                      }\n                    }\n                  });\n                  service.decideRaiseSelectionBatchEvent( grid, changedRows, evt );\n                  grid.selection.selectAll = true;\n                },\n                /**\n                 * @ngdoc function\n                 * @name clearSelectedRows\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Unselects all rows\n                 * @param {Event} event object if raised from an event\n                 */\n                clearSelectedRows: function (evt) {\n                  service.clearSelectedRows(grid, evt);\n                },\n                /**\n                 * @ngdoc function\n                 * @name getSelectedRows\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description returns all selectedRow's entity references\n                 */\n                getSelectedRows: function () {\n                  return service.getSelectedRows(grid).map(function (gridRow) {\n                    return gridRow.entity;\n                  });\n                },\n                /**\n                 * @ngdoc function\n                 * @name getSelectedGridRows\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description returns all selectedRow's as gridRows\n                 */\n                getSelectedGridRows: function () {\n                  return service.getSelectedRows(grid);\n                },\n                /**\n                 * @ngdoc function\n                 * @name getSelectedCount\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description returns the number of rows selected\n                 */\n                getSelectedCount: function () {\n                  return grid.selection.selectedCount;\n                },\n                /**\n                 * @ngdoc function\n                 * @name setMultiSelect\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Sets the current gridOption.multiSelect to true or false\n                 * @param {bool} multiSelect true to allow multiple rows\n                 */\n                setMultiSelect: function (multiSelect) {\n                  grid.options.multiSelect = multiSelect;\n                },\n                /**\n                 * @ngdoc function\n                 * @name setModifierKeysToMultiSelect\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Sets the current gridOption.modifierKeysToMultiSelect to true or false\n                 * @param {bool} modifierKeysToMultiSelect true to only allow multiple rows when using ctrlKey or shiftKey is used\n                 */\n                setModifierKeysToMultiSelect: function (modifierKeysToMultiSelect) {\n                  grid.options.modifierKeysToMultiSelect = modifierKeysToMultiSelect;\n                },\n                /**\n                 * @ngdoc function\n                 * @name getSelectAllState\n                 * @methodOf  ui.grid.selection.api:PublicApi\n                 * @description Returns whether or not the selectAll checkbox is currently ticked.  The\n                 * grid doesn't automatically select rows when you add extra data - so when you add data\n                 * you need to explicitly check whether the selectAll is set, and then call setVisible rows\n                 * if it is\n                 */\n                getSelectAllState: function () {\n                  return grid.selection.selectAll;\n                }\n\n              }\n            }\n          };\n\n          grid.api.registerEventsFromObject(publicApi.events);\n\n          grid.api.registerMethodsFromObject(publicApi.methods);\n\n        },\n\n        defaultGridOptions: function (gridOptions) {\n          //default option to true unless it was explicitly set to false\n          /**\n           *  @ngdoc object\n           *  @name ui.grid.selection.api:GridOptions\n           *\n           *  @description GridOptions for selection feature, these are available to be\n           *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n           */\n\n          /**\n           *  @ngdoc object\n           *  @name enableRowSelection\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable row selection for entire grid.\n           *  <br/>Defaults to true\n           */\n          gridOptions.enableRowSelection = gridOptions.enableRowSelection !== false;\n          /**\n           *  @ngdoc object\n           *  @name multiSelect\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable multiple row selection for entire grid\n           *  <br/>Defaults to true\n           */\n          gridOptions.multiSelect = gridOptions.multiSelect !== false;\n          /**\n           *  @ngdoc object\n           *  @name noUnselect\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Prevent a row from being unselected.  Works in conjunction\n           *  with `multiselect = false` and `gridApi.selection.selectRow()` to allow\n           *  you to create a single selection only grid - a row is always selected, you\n           *  can only select different rows, you can't unselect the row.\n           *  <br/>Defaults to false\n           */\n          gridOptions.noUnselect = gridOptions.noUnselect === true;\n          /**\n           *  @ngdoc object\n           *  @name modifierKeysToMultiSelect\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable multiple row selection only when using the ctrlKey or shiftKey. Requires multiSelect to be true.\n           *  <br/>Defaults to false\n           */\n          gridOptions.modifierKeysToMultiSelect = gridOptions.modifierKeysToMultiSelect === true;\n          /**\n           *  @ngdoc object\n           *  @name enableRowHeaderSelection\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable a row header to be used for selection\n           *  <br/>Defaults to true\n           */\n          gridOptions.enableRowHeaderSelection = gridOptions.enableRowHeaderSelection !== false;\n          /**\n           *  @ngdoc object\n           *  @name enableFullRowSelection\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable selection by clicking anywhere on the row.  Defaults to\n           *  false if `enableRowHeaderSelection` is true, otherwise defaults to false.\n           */\n          if ( typeof(gridOptions.enableFullRowSelection) === 'undefined' ){\n            gridOptions.enableFullRowSelection = !gridOptions.enableRowHeaderSelection;\n          }\n          /**\n           *  @ngdoc object\n           *  @name enableSelectAll\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Enable the select all checkbox at the top of the selectionRowHeader\n           *  <br/>Defaults to true\n           */\n          gridOptions.enableSelectAll = gridOptions.enableSelectAll !== false;\n          /**\n           *  @ngdoc object\n           *  @name enableSelectionBatchEvent\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description If selected rows are changed in bulk, either via the API or\n           *  via the selectAll checkbox, then a separate event is fired.  Setting this\n           *  option to false will cause the rowSelectionChanged event to be called multiple times\n           *  instead\n           *  <br/>Defaults to true\n           */\n          gridOptions.enableSelectionBatchEvent = gridOptions.enableSelectionBatchEvent !== false;\n          /**\n           *  @ngdoc object\n           *  @name selectionRowHeaderWidth\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description can be used to set a custom width for the row header selection column\n           *  <br/>Defaults to 30px\n           */\n          gridOptions.selectionRowHeaderWidth = angular.isDefined(gridOptions.selectionRowHeaderWidth) ? gridOptions.selectionRowHeaderWidth : 30;\n\n          /**\n           *  @ngdoc object\n           *  @name enableFooterTotalSelected\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Shows the total number of selected items in footer if true.\n           *  <br/>Defaults to true.\n           *  <br/>GridOptions.showGridFooter must also be set to true.\n           */\n          gridOptions.enableFooterTotalSelected = gridOptions.enableFooterTotalSelected !== false;\n\n          /**\n           *  @ngdoc object\n           *  @name isRowSelectable\n           *  @propertyOf  ui.grid.selection.api:GridOptions\n           *  @description Makes it possible to specify a method that evaluates for each row and sets its \"enableSelection\" property.\n           */\n\n          gridOptions.isRowSelectable = angular.isDefined(gridOptions.isRowSelectable) ? gridOptions.isRowSelectable : angular.noop;\n        },\n\n        /**\n         * @ngdoc function\n         * @name toggleRowSelection\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description Toggles row as selected or unselected\n         * @param {Grid} grid grid object\n         * @param {GridRow} row row to select or deselect\n         * @param {Event} event object if resulting from event\n         * @param {bool} multiSelect if false, only one row at time can be selected\n         * @param {bool} noUnselect if true then rows cannot be unselected\n         */\n        toggleRowSelection: function (grid, row, evt, multiSelect, noUnselect) {\n          var selected = row.isSelected;\n\n          if ( row.enableSelection === false && !selected ){\n            return;\n          }\n\n          var selectedRows;\n          if (!multiSelect && !selected) {\n            service.clearSelectedRows(grid, evt);\n          } else if (!multiSelect && selected) {\n            selectedRows = service.getSelectedRows(grid);\n            if (selectedRows.length > 1) {\n              selected = false; // Enable reselect of the row\n              service.clearSelectedRows(grid, evt);\n            }\n          }\n\n          if (selected && noUnselect){\n            // don't deselect the row\n          } else {\n            row.setSelected(!selected);\n            if (row.isSelected === true) {\n              grid.selection.lastSelectedRow = row;\n            }\n\n            selectedRows = service.getSelectedRows(grid);\n            grid.selection.selectAll = grid.rows.length === selectedRows.length;\n\n            grid.api.selection.raise.rowSelectionChanged(row, evt);\n          }\n        },\n        /**\n         * @ngdoc function\n         * @name shiftSelect\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description selects a group of rows from the last selected row using the shift key\n         * @param {Grid} grid grid object\n         * @param {GridRow} clicked row\n         * @param {Event} event object if raised from an event\n         * @param {bool} multiSelect if false, does nothing this is for multiSelect only\n         */\n        shiftSelect: function (grid, row, evt, multiSelect) {\n          if (!multiSelect) {\n            return;\n          }\n          var selectedRows = service.getSelectedRows(grid);\n          var fromRow = selectedRows.length > 0 ? grid.renderContainers.body.visibleRowCache.indexOf(grid.selection.lastSelectedRow) : 0;\n          var toRow = grid.renderContainers.body.visibleRowCache.indexOf(row);\n          //reverse select direction\n          if (fromRow > toRow) {\n            var tmp = fromRow;\n            fromRow = toRow;\n            toRow = tmp;\n          }\n\n          var changedRows = [];\n          for (var i = fromRow; i <= toRow; i++) {\n            var rowToSelect = grid.renderContainers.body.visibleRowCache[i];\n            if (rowToSelect) {\n              if ( !rowToSelect.isSelected && rowToSelect.enableSelection !== false ){\n                rowToSelect.setSelected(true);\n                grid.selection.lastSelectedRow = rowToSelect;\n                service.decideRaiseSelectionEvent( grid, rowToSelect, changedRows, evt );\n              }\n            }\n          }\n          service.decideRaiseSelectionBatchEvent( grid, changedRows, evt );\n        },\n        /**\n         * @ngdoc function\n         * @name getSelectedRows\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description Returns all the selected rows\n         * @param {Grid} grid grid object\n         */\n        getSelectedRows: function (grid) {\n          return grid.rows.filter(function (row) {\n            return row.isSelected;\n          });\n        },\n\n        /**\n         * @ngdoc function\n         * @name clearSelectedRows\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description Clears all selected rows\n         * @param {Grid} grid grid object\n         * @param {Event} event object if raised from an event\n         */\n        clearSelectedRows: function (grid, evt) {\n          var changedRows = [];\n          service.getSelectedRows(grid).forEach(function (row) {\n            if ( row.isSelected ){\n              row.setSelected(false);\n              service.decideRaiseSelectionEvent( grid, row, changedRows, evt );\n            }\n          });\n          service.decideRaiseSelectionBatchEvent( grid, changedRows, evt );\n          grid.selection.selectAll = false;\n          grid.selection.selectedCount = 0;\n        },\n\n        /**\n         * @ngdoc function\n         * @name decideRaiseSelectionEvent\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description Decides whether to raise a single event or a batch event\n         * @param {Grid} grid grid object\n         * @param {GridRow} row row that has changed\n         * @param {array} changedRows an array to which we can append the changed\n         * @param {Event} event object if raised from an event\n         * row if we're doing batch events\n         */\n        decideRaiseSelectionEvent: function( grid, row, changedRows, evt ){\n          if ( !grid.options.enableSelectionBatchEvent ){\n            grid.api.selection.raise.rowSelectionChanged(row, evt);\n          } else {\n            changedRows.push(row);\n          }\n        },\n\n        /**\n         * @ngdoc function\n         * @name raiseSelectionEvent\n         * @methodOf  ui.grid.selection.service:uiGridSelectionService\n         * @description Decides whether we need to raise a batch event, and\n         * raises it if we do.\n         * @param {Grid} grid grid object\n         * @param {array} changedRows an array of changed rows, only populated\n         * @param {Event} event object if raised from an event\n         * if we're doing batch events\n         */\n        decideRaiseSelectionBatchEvent: function( grid, changedRows, evt ){\n          if ( changedRows.length > 0 ){\n            grid.api.selection.raise.rowSelectionChangedBatch(changedRows, evt);\n          }\n        }\n      };\n\n      return service;\n\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.selection.directive:uiGridSelection\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds selection features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.selection']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name', enableCellEdit: true},\n        {name: 'title', enableCellEdit: true}\n      ];\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-selection></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridSelection', ['uiGridSelectionConstants', 'uiGridSelectionService', '$templateCache', 'uiGridConstants',\n    function (uiGridSelectionConstants, uiGridSelectionService, $templateCache, uiGridConstants) {\n      return {\n        replace: true,\n        priority: 0,\n        require: '^uiGrid',\n        scope: false,\n        compile: function () {\n          return {\n            pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n              uiGridSelectionService.initializeGrid(uiGridCtrl.grid);\n              if (uiGridCtrl.grid.options.enableRowHeaderSelection) {\n                var selectionRowHeaderDef = {\n                  name: uiGridSelectionConstants.selectionRowHeaderColName,\n                  displayName: '',\n                  width:  uiGridCtrl.grid.options.selectionRowHeaderWidth,\n                  minWidth: 10,\n                  cellTemplate: 'ui-grid/selectionRowHeader',\n                  headerCellTemplate: 'ui-grid/selectionHeaderCell',\n                  enableColumnResizing: false,\n                  enableColumnMenu: false,\n                  exporterSuppressExport: true,\n                  allowCellFocus: true\n                };\n\n                uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef);\n              }\n\n              var processorSet = false;\n\n              var processSelectableRows = function( rows ){\n                rows.forEach(function(row){\n                  row.enableSelection = uiGridCtrl.grid.options.isRowSelectable(row);\n                });\n                return rows;\n              };\n\n              var updateOptions = function(){\n                if (uiGridCtrl.grid.options.isRowSelectable !== angular.noop && processorSet !== true) {\n                  uiGridCtrl.grid.registerRowsProcessor(processSelectableRows, 500);\n                  processorSet = true;\n                }\n              };\n\n              updateOptions();\n\n              var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback( updateOptions, [uiGridConstants.dataChange.OPTIONS] );\n\n              $scope.$on( '$destroy', dataChangeDereg);\n            },\n            post: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n            }\n          };\n        }\n      };\n    }]);\n\n  module.directive('uiGridSelectionRowHeaderButtons', ['$templateCache', 'uiGridSelectionService', 'gridUtil',\n    function ($templateCache, uiGridSelectionService, gridUtil) {\n      return {\n        replace: true,\n        restrict: 'E',\n        template: $templateCache.get('ui-grid/selectionRowHeaderButtons'),\n        scope: true,\n        require: '^uiGrid',\n        link: function($scope, $elm, $attrs, uiGridCtrl) {\n          var self = uiGridCtrl.grid;\n          $scope.selectButtonClick = selectButtonClick;\n\n          // On IE, prevent mousedowns on the select button from starting a selection.\n          //   If this is not done and you shift+click on another row, the browser will select a big chunk of text\n          if (gridUtil.detectBrowser() === 'ie') {\n            $elm.on('mousedown', selectButtonMouseDown);\n          }\n\n\n          function selectButtonClick(row, evt) {\n            evt.stopPropagation();\n\n            if (evt.shiftKey) {\n              uiGridSelectionService.shiftSelect(self, row, evt, self.options.multiSelect);\n            }\n            else if (evt.ctrlKey || evt.metaKey) {\n              uiGridSelectionService.toggleRowSelection(self, row, evt, self.options.multiSelect, self.options.noUnselect);\n            }\n            else {\n              uiGridSelectionService.toggleRowSelection(self, row, evt, (self.options.multiSelect && !self.options.modifierKeysToMultiSelect), self.options.noUnselect);\n            }\n          }\n\n          function selectButtonMouseDown(evt) {\n            if (evt.ctrlKey || evt.shiftKey) {\n              evt.target.onselectstart = function () { return false; };\n              window.setTimeout(function () { evt.target.onselectstart = null; }, 0);\n            }\n          }\n        }\n      };\n    }]);\n\n  module.directive('uiGridSelectionSelectAllButtons', ['$templateCache', 'uiGridSelectionService',\n    function ($templateCache, uiGridSelectionService) {\n      return {\n        replace: true,\n        restrict: 'E',\n        template: $templateCache.get('ui-grid/selectionSelectAllButtons'),\n        scope: false,\n        link: function($scope, $elm, $attrs, uiGridCtrl) {\n          var self = $scope.col.grid;\n\n          $scope.headerButtonClick = function(row, evt) {\n            if ( self.selection.selectAll ){\n              uiGridSelectionService.clearSelectedRows(self, evt);\n              if ( self.options.noUnselect ){\n                self.api.selection.selectRowByVisibleIndex(0, evt);\n              }\n              self.selection.selectAll = false;\n            } else {\n              if ( self.options.multiSelect ){\n                self.api.selection.selectAllVisibleRows(evt);\n                self.selection.selectAll = true;\n              }\n            }\n          };\n        }\n      };\n    }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.selection.directive:uiGridViewport\n   *  @element div\n   *\n   *  @description Stacks on top of ui.grid.uiGridViewport to alter the attributes used\n   *  for the grid row\n   */\n  module.directive('uiGridViewport',\n    ['$compile', 'uiGridConstants', 'uiGridSelectionConstants', 'gridUtil', '$parse', 'uiGridSelectionService',\n      function ($compile, uiGridConstants, uiGridSelectionConstants, gridUtil, $parse, uiGridSelectionService) {\n        return {\n          priority: -200, // run after default  directive\n          scope: false,\n          compile: function ($elm, $attrs) {\n            var rowRepeatDiv = angular.element($elm.children().children()[0]);\n\n            var existingNgClass = rowRepeatDiv.attr(\"ng-class\");\n            var newNgClass = '';\n            if ( existingNgClass ) {\n              newNgClass = existingNgClass.slice(0, -1) + \",'ui-grid-row-selected': row.isSelected}\";\n            } else {\n              newNgClass = \"{'ui-grid-row-selected': row.isSelected}\";\n            }\n            rowRepeatDiv.attr(\"ng-class\", newNgClass);\n\n            return {\n              pre: function ($scope, $elm, $attrs, controllers) {\n\n              },\n              post: function ($scope, $elm, $attrs, controllers) {\n              }\n            };\n          }\n        };\n      }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.selection.directive:uiGridCell\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Stacks on top of ui.grid.uiGridCell to provide selection feature\n   */\n  module.directive('uiGridCell',\n    ['$compile', 'uiGridConstants', 'uiGridSelectionConstants', 'gridUtil', '$parse', 'uiGridSelectionService', '$timeout',\n      function ($compile, uiGridConstants, uiGridSelectionConstants, gridUtil, $parse, uiGridSelectionService, $timeout) {\n        return {\n          priority: -200, // run after default uiGridCell directive\n          restrict: 'A',\n          require: '?^uiGrid',\n          scope: false,\n          link: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n            var touchStartTime = 0;\n            var touchTimeout = 300;\n\n            // Bind to keydown events in the render container\n            if (uiGridCtrl.grid.api.cellNav) {\n\n              uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) {\n                if (rowCol === null ||\n                  rowCol.row !== $scope.row ||\n                  rowCol.col !== $scope.col) {\n                  return;\n                }\n\n                if (evt.keyCode === 32 && $scope.col.colDef.name === \"selectionRowHeaderCol\") {\n                  uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);\n                  $scope.$apply();\n                }\n\n              //  uiGridCellNavService.scrollToIfNecessary(uiGridCtrl.grid, rowCol.row, rowCol.col);\n              });\n            }\n\n            //$elm.bind('keydown', function (evt) {\n            //  if (evt.keyCode === 32 && $scope.col.colDef.name === \"selectionRowHeaderCol\") {\n            //    uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);\n            //    $scope.$apply();\n            //  }\n            //});\n\n            var selectCells = function(evt){\n              // if we get a click, then stop listening for touchend\n              $elm.off('touchend', touchEnd);\n\n              if (evt.shiftKey) {\n                uiGridSelectionService.shiftSelect($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect);\n              }\n              else if (evt.ctrlKey || evt.metaKey) {\n                uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect, $scope.grid.options.noUnselect);\n              }\n              else {\n                uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect);\n              }\n              $scope.$apply();\n\n              // don't re-enable the touchend handler for a little while - some devices generate both, and it will\n              // take a little while to move your hand from the mouse to the screen if you have both modes of input\n              $timeout(function() {\n                $elm.on('touchend', touchEnd);\n              }, touchTimeout);\n            };\n\n            var touchStart = function(evt){\n              touchStartTime = (new Date()).getTime();\n\n              // if we get a touch event, then stop listening for click\n              $elm.off('click', selectCells);\n            };\n\n            var touchEnd = function(evt) {\n              var touchEndTime = (new Date()).getTime();\n              var touchTime = touchEndTime - touchStartTime;\n\n              if (touchTime < touchTimeout ) {\n                // short touch\n                selectCells(evt);\n              }\n\n              // don't re-enable the click handler for a little while - some devices generate both, and it will\n              // take a little while to move your hand from the screen to the mouse if you have both modes of input\n              $timeout(function() {\n                $elm.on('click', selectCells);\n              }, touchTimeout);\n            };\n\n            function registerRowSelectionEvents() {\n              if ($scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection) {\n                $elm.addClass('ui-grid-disable-selection');\n                $elm.on('touchstart', touchStart);\n                $elm.on('touchend', touchEnd);\n                $elm.on('click', selectCells);\n\n                $scope.registered = true;\n              }\n            }\n\n            function deregisterRowSelectionEvents() {\n              if ($scope.registered){\n                $elm.removeClass('ui-grid-disable-selection');\n\n                $elm.off('touchstart', touchStart);\n                $elm.off('touchend', touchEnd);\n                $elm.off('click', selectCells);\n\n                $scope.registered = false;\n              }\n            }\n\n            registerRowSelectionEvents();\n            // register a dataChange callback so that we can change the selection configuration dynamically\n            // if the user changes the options\n            var dataChangeDereg = $scope.grid.registerDataChangeCallback( function() {\n              if ( $scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection &&\n                !$scope.registered ){\n                registerRowSelectionEvents();\n              } else if ( ( !$scope.grid.options.enableRowSelection || !$scope.grid.options.enableFullRowSelection ) &&\n                $scope.registered ){\n                deregisterRowSelectionEvents();\n              }\n            }, [uiGridConstants.dataChange.OPTIONS] );\n\n            $elm.on( '$destroy', dataChangeDereg);\n          }\n        };\n      }]);\n\n  module.directive('uiGridGridFooter', ['$compile', 'uiGridConstants', 'gridUtil', function ($compile, uiGridConstants, gridUtil) {\n    return {\n      restrict: 'EA',\n      replace: true,\n      priority: -1000,\n      require: '^uiGrid',\n      scope: true,\n      compile: function ($elm, $attrs) {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n            if (!uiGridCtrl.grid.options.showGridFooter) {\n              return;\n            }\n\n\n            gridUtil.getTemplate('ui-grid/gridFooterSelectedItems')\n              .then(function (contents) {\n                var template = angular.element(contents);\n\n                var newElm = $compile(template)($scope);\n\n                angular.element($elm[0].getElementsByClassName('ui-grid-grid-footer')[0]).append(newElm);\n              });\n          },\n\n          post: function ($scope, $elm, $attrs, controllers) {\n\n          }\n        };\n      }\n    };\n  }]);\n\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.treeBase\n   * @description\n   *\n   * # ui.grid.treeBase\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Beta</strong> This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs.</div>\n   *\n   * This module provides base tree handling functions that are shared by other features, notably grouping\n   * and treeView.  It provides a tree view of the data, with nodes in that\n   * tree and leaves.\n   *\n   * Design information:\n   * -------------------\n   *\n   * The raw data that is provided must come with a $$treeLevel on any non-leaf node.  Grouping will create\n   * these on all the group header rows, treeView will expect these to be set in the raw data by the user.\n   * TreeBase will run a rowsProcessor that:\n   *  - builds `treeBase.tree` out of the provided rows\n   *  - permits a recursive sort of the tree\n   *  - maintains the expand/collapse state of each node\n   *  - provides the expand/collapse all button and the expand/collapse buttons\n   *  - maintains the count of children for each node\n   *\n   * Each row is updated with a link to the tree node that represents it.  Refer {@link ui.grid.treeBase.grid:treeBase.tree tree documentation}\n   * for information.\n   *\n   *  TreeBase adds information to the rows\n   *  - treeLevel: if present and > -1 tells us the level (level 0 is the top level)\n   *  - treeNode: pointer to the node in the grid.treeBase.tree that refers\n   *    to this row, allowing us to manipulate the state\n   *\n   * Since the logic is baked into the rowsProcessors, it should get triggered whenever\n   * row order or filtering or anything like that is changed.  We recall the expanded state\n   * across invocations of the rowsProcessors by the reference to the treeNode on the individual\n   * rows.  We rebuild the tree itself quite frequently, when we do this we use the saved treeNodes to\n   * get the state, but we overwrite the other data in that treeNode.\n   *\n   * By default rows are collapsed, which means all data rows have their visible property\n   * set to false, and only level 0 group rows are set to visible.\n   *\n   * We rely on the rowsProcessors to do the actual expanding and collapsing, so we set the flags we want into\n   * grid.treeBase.tree, then call refresh.  This is because we can't easily change the visible\n   * row cache without calling the processors, and once we've built the logic into the rowProcessors we may as\n   * well use it all the time.\n   *\n   * Tree base provides sorting (on non-grouped columns).\n   *\n   * Sorting works in two passes.  The standard sorting is performed for any columns that are important to building\n   * the tree (for example, any grouped columns).  Then after the tree is built, a recursive tree sort is performed\n   * for the remaining sort columns (including the original sort) - these columns are sorted within each tree level\n   * (so all the level 1 nodes are sorted, then all the level 2 nodes within each level 1 node etc).\n   *\n   * To achieve this we make use of the `ignoreSort` property on the sort configuration.  The parent feature (treeView or grouping)\n   * must provide a rowsProcessor that runs with very low priority (typically in the 60-65 range), and that sets\n   * the `ignoreSort`on any sort that it wants to run on the tree.  TreeBase will clear the ignoreSort on all sorts - so it\n   * will turn on any sorts that haven't run.  It will then call a recursive sort on the tree.\n   *\n   * Tree base provides treeAggregation.  It checks the treeAggregation configuration on each column, and aggregates based on\n   * the logic provided as it builds the tree. Footer aggregation from the uiGrid core should not be used with treeBase aggregation,\n   * since it operates on all visible rows, as opposed to to leaf nodes only. Setting `showColumnFooter: true` will show the\n   * treeAggregations in the column footer.  Aggregation information will be collected in the format:\n   *\n   * ```\n   *   {\n   *     type: 'count',\n   *     value: 4,\n   *     label: 'count: ',\n   *     rendered: 'count: 4'\n   *   }\n   * ```\n   *\n   * A callback is provided to format the value once it is finalised (aka a valueFilter).\n   *\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.treeBase\"></div>\n   */\n\n  var module = angular.module('ui.grid.treeBase', ['ui.grid']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.treeBase.constant:uiGridTreeBaseConstants\n   *\n   *  @description constants available in treeBase module.\n   *\n   *  These constants are manually copied into grouping and treeView,\n   *  as I haven't found a way to simply include them, and it's not worth\n   *  investing time in for something that changes very infrequently.\n   *\n   */\n  module.constant('uiGridTreeBaseConstants', {\n    featureName: \"treeBase\",\n    rowHeaderColName: 'treeBaseRowHeaderCol',\n    EXPANDED: 'expanded',\n    COLLAPSED: 'collapsed',\n    aggregation: {\n      COUNT: 'count',\n      SUM: 'sum',\n      MAX: 'max',\n      MIN: 'min',\n      AVG: 'avg'\n    }\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.treeBase.service:uiGridTreeBaseService\n   *\n   *  @description Services for treeBase feature\n   */\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.treeBase.api:ColumnDef\n   *\n   *  @description ColumnDef for tree feature, these are available to be\n   *  set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs}\n   */\n\n  module.service('uiGridTreeBaseService', ['$q', 'uiGridTreeBaseConstants', 'gridUtil', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants', 'rowSorter',\n  function ($q, uiGridTreeBaseConstants, gridUtil, GridRow, gridClassFactory, i18nService, uiGridConstants, rowSorter) {\n\n    var service = {\n\n      initializeGrid: function (grid, $scope) {\n\n        //add feature namespace and any properties to grid for needed\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeBase.grid:treeBase\n         *\n         *  @description Grid properties and functions added for treeBase\n         */\n        grid.treeBase = {};\n\n        /**\n         *  @ngdoc property\n         *  @propertyOf ui.grid.treeBase.grid:treeBase\n         *  @name numberLevels\n         *\n         *  @description Total number of tree levels currently used, calculated by the rowsProcessor by\n         *  retaining the highest tree level it sees\n         */\n        grid.treeBase.numberLevels = 0;\n\n        /**\n         *  @ngdoc property\n         *  @propertyOf ui.grid.treeBase.grid:treeBase\n         *  @name expandAll\n         *\n         *  @description Whether or not the expandAll box is selected\n         */\n        grid.treeBase.expandAll = false;\n\n        /**\n         *  @ngdoc property\n         *  @propertyOf ui.grid.treeBase.grid:treeBase\n         *  @name tree\n         *\n         *  @description Tree represented as a nested array that holds the state of each node, along with a\n         *  pointer to the row.  The array order is material - we will display the children in the order\n         *  they are stored in the array\n         *\n         *  Each node stores:\n         *\n         *    - the state of this node\n         *    - an array of children of this node\n         *    - a pointer to the parent of this node (reverse pointer, allowing us to walk up the tree)\n         *    - the number of children of this node\n         *    - aggregation information calculated from the nodes\n         *\n         *  ```\n         *    [{\n         *      state: 'expanded',\n         *      row: <reference to row>,\n         *      parentRow: null,\n         *      aggregations: [{\n         *        type: 'count',\n         *        col: <gridCol>,\n         *        value: 2,\n         *        label: 'count: ',\n         *        rendered: 'count: 2'\n         *      }],\n         *      children: [\n         *        {\n         *          state: 'expanded',\n         *          row: <reference to row>,\n         *          parentRow: <reference to row>,\n         *          aggregations: [{\n         *            type: 'count',\n         *            col: '<gridCol>,\n         *            value: 4,\n         *            label: 'count: ',\n         *            rendered: 'count: 4'\n         *          }],\n         *          children: [\n         *            { state: 'expanded', row: <reference to row>, parentRow: <reference to row> },\n         *            { state: 'collapsed', row: <reference to row>, parentRow: <reference to row> },\n         *            { state: 'expanded', row: <reference to row>, parentRow: <reference to row> },\n         *            { state: 'collapsed', row: <reference to row>, parentRow: <reference to row> }\n         *          ]\n         *        },\n         *        {\n         *          state: 'collapsed',\n         *          row: <reference to row>,\n         *          parentRow: <reference to row>,\n         *          aggregations: [{\n         *            type: 'count',\n         *            col: <gridCol>,\n         *            value: 3,\n         *            label: 'count: ',\n         *            rendered: 'count: 3'\n         *          }],\n         *          children: [\n         *            { state: 'expanded', row: <reference to row>, parentRow: <reference to row> },\n         *            { state: 'collapsed', row: <reference to row>, parentRow: <reference to row> },\n         *            { state: 'expanded', row: <reference to row>, parentRow: <reference to row> }\n         *          ]\n         *        }\n         *      ]\n         *    }, {<another level 0 node maybe>} ]\n         *  ```\n         *  Missing state values are false - meaning they aren't expanded.\n         *\n         *  This is used because the rowProcessors run every time the grid is refreshed, so\n         *  we'd lose the expanded state every time the grid was refreshed.  This instead gives\n         *  us a reliable lookup that persists across rowProcessors.\n         *\n         *  This tree is rebuilt every time we run the rowsProcessors.  Since each row holds a pointer\n         *  to it's tree node we can persist expand/collapse state across calls to rowsProcessor, we discard\n         *  all transient information on the tree (children, childCount) and recalculate it\n         *\n         */\n        grid.treeBase.tree = [];\n\n        service.defaultGridOptions(grid.options);\n\n        grid.registerRowsProcessor(service.treeRows, 410);\n\n        grid.registerColumnBuilder( service.treeBaseColumnBuilder );\n\n        service.createRowHeader( grid );\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeBase.api:PublicApi\n         *\n         *  @description Public Api for treeBase feature\n         */\n        var publicApi = {\n          events: {\n            treeBase: {\n              /**\n               * @ngdoc event\n               * @eventOf ui.grid.treeBase.api:PublicApi\n               * @name rowExpanded\n               * @description raised whenever a row is expanded.  If you are dynamically\n               * rendering your tree you can listen to this event, and then retrieve\n               * the children of this row and load them into the grid data.\n               *\n               * When the data is loaded the grid will automatically refresh to show these new rows\n               *\n               * <pre>\n               *      gridApi.treeBase.on.rowExpanded(scope,function(row){})\n               * </pre>\n               * @param {gridRow} row the row that was expanded.  You can also\n               * retrieve the grid from this row with row.grid\n               */\n              rowExpanded: {},\n\n              /**\n               * @ngdoc event\n               * @eventOf ui.grid.treeBase.api:PublicApi\n               * @name rowCollapsed\n               * @description raised whenever a row is collapsed.  Doesn't really have\n               * a purpose at the moment, included for symmetry\n               *\n               * <pre>\n               *      gridApi.treeBase.on.rowCollapsed(scope,function(row){})\n               * </pre>\n               * @param {gridRow} row the row that was collapsed.  You can also\n               * retrieve the grid from this row with row.grid\n               */\n              rowCollapsed: {}\n            }\n          },\n\n          methods: {\n            treeBase: {\n              /**\n               * @ngdoc function\n               * @name expandAllRows\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description Expands all tree rows\n               */\n              expandAllRows: function () {\n                service.expandAllRows(grid);\n              },\n\n              /**\n               * @ngdoc function\n               * @name collapseAllRows\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description collapse all tree rows\n               */\n              collapseAllRows: function () {\n                service.collapseAllRows(grid);\n              },\n\n              /**\n               * @ngdoc function\n               * @name toggleRowTreeState\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description  call expand if the row is collapsed, collapse if it is expanded\n               * @param {gridRow} row the row you wish to toggle\n               */\n              toggleRowTreeState: function (row) {\n                service.toggleRowTreeState(grid, row);\n              },\n\n              /**\n               * @ngdoc function\n               * @name expandRow\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description expand the immediate children of the specified row\n               * @param {gridRow} row the row you wish to expand\n               */\n              expandRow: function (row) {\n                service.expandRow(grid, row);\n              },\n\n              /**\n               * @ngdoc function\n               * @name expandRowChildren\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description expand all children of the specified row\n               * @param {gridRow} row the row you wish to expand\n               */\n              expandRowChildren: function (row) {\n                service.expandRowChildren(grid, row);\n              },\n\n              /**\n               * @ngdoc function\n               * @name collapseRow\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description collapse  the specified row.  When\n               * you expand the row again, all grandchildren will retain their state\n               * @param {gridRow} row the row you wish to collapse\n               */\n              collapseRow: function ( row ) {\n                service.collapseRow(grid, row);\n              },\n\n              /**\n               * @ngdoc function\n               * @name collapseRowChildren\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description collapse all children of the specified row.  When\n               * you expand the row again, all grandchildren will be collapsed\n               * @param {gridRow} row the row you wish to collapse children for\n               */\n              collapseRowChildren: function ( row ) {\n                service.collapseRowChildren(grid, row);\n              },\n\n              /**\n               * @ngdoc function\n               * @name getTreeState\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description Get the tree state for this grid,\n               * used by the saveState feature\n               * Returned treeState as an object\n               *   `{ expandedState: { uid: 'expanded', uid: 'collapsed' } }`\n               * where expandedState is a hash of row uid and the current expanded state\n               *\n               * @returns {object} tree state\n               *\n               * TODO - this needs work - we need an identifier that persists across instantiations,\n               * not uid.  This really means we need a row identity defined, but that won't work for\n               * grouping.  Perhaps this needs to be moved up to treeView and grouping, rather than\n               * being in base.\n               */\n              getTreeExpandedState: function () {\n                return { expandedState: service.getTreeState(grid) };\n              },\n\n              /**\n               * @ngdoc function\n               * @name setTreeState\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description Set the expanded states of the tree\n               * @param {object} config the config you want to apply, in the format\n               * provided by getTreeState\n               */\n              setTreeState: function ( config ) {\n                service.setTreeState( grid, config );\n              },\n\n              /**\n               * @ngdoc function\n               * @name getRowChildren\n               * @methodOf  ui.grid.treeBase.api:PublicApi\n               * @description Get the children of the specified row\n               * @param {GridRow} row the row you want the children of\n               * @returns {Array} array of children of this row, the children\n               * are all gridRows\n               */\n              getRowChildren: function ( row ){\n                return row.treeNode.children.map( function( childNode ){\n                  return childNode.row;\n                });\n              }\n            }\n          }\n        };\n\n        grid.api.registerEventsFromObject(publicApi.events);\n\n        grid.api.registerMethodsFromObject(publicApi.methods);\n      },\n\n\n      defaultGridOptions: function (gridOptions) {\n        //default option to true unless it was explicitly set to false\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeBase.api:GridOptions\n         *\n         *  @description GridOptions for treeBase feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name treeRowHeaderBaseWidth\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description Base width of the tree header, provides for a single level of tree.  This\n         *  is incremented by `treeIndent` for each extra level\n         *  <br/>Defaults to 30\n         */\n        gridOptions.treeRowHeaderBaseWidth = gridOptions.treeRowHeaderBaseWidth || 30;\n\n        /**\n         *  @ngdoc object\n         *  @name treeIndent\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description Number of pixels of indent for the icon at each tree level, wider indents are visually more pleasing,\n         *  but will make the tree row header wider\n         *  <br/>Defaults to 10\n         */\n        gridOptions.treeIndent = gridOptions.treeIndent || 10;\n\n        /**\n         *  @ngdoc object\n         *  @name showTreeRowHeader\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description If set to false, don't create the row header.  Youll need to programatically control the expand\n         *  states\n         *  <br/>Defaults to true\n         */\n        gridOptions.showTreeRowHeader = gridOptions.showTreeRowHeader !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name showTreeExpandNoChildren\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description If set to true, show the expand/collapse button even if there are no\n         *  children of a node.  You'd use this if you're planning to dynamically load the children\n         *\n         *  <br/>Defaults to true, grouping overrides to false\n         */\n        gridOptions.showTreeExpandNoChildren = gridOptions.showTreeExpandNoChildren !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name treeRowHeaderAlwaysVisible\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description If set to true, row header even if there are no tree nodes\n         *\n         *  <br/>Defaults to true\n         */\n        gridOptions.treeRowHeaderAlwaysVisible = gridOptions.treeRowHeaderAlwaysVisible !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name treeCustomAggregations\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description Define custom aggregation functions. The properties of this object will be\n         *  aggregation types available for use on columnDef with {@link ui.grid.treeBase.api:ColumnDef treeAggregationType} or through the column menu.\n         *  If a function defined here uses the same name as one of the native aggregations, this one will take precedence.\n         *  The object format is:\n         *\n         *  <pre>\n         *    {\n         *      aggregationName: {\n         *        label: (optional) string,\n         *        aggregationFn: function( aggregation, fieldValue, numValue, row ){...},\n         *        finalizerFn: (optional) function( aggregation ){...}\n       *        },\n         *      mean: {\n         *        label: 'mean',\n         *        aggregationFn: function( aggregation, fieldValue, numValue ){\n       *            aggregation.count = (aggregation.count || 1) + 1;\n         *          aggregation.sum = (aggregation.sum || 0) + numValue;\n         *        },\n         *        finalizerFn: function( aggregation ){\n         *          aggregation.value = aggregation.sum / aggregation.count\n         *        }\n         *      }\n         *    }\n         *  </pre>\n         *\n         *  <br/>The `finalizerFn` may be used to manipulate the value before rendering, or to\n         *  apply a custom rendered value. If `aggregation.rendered` is left undefined, the value will be\n         *  rendered. Note that the native aggregation functions use an `finalizerFn` to concatenate\n         *  the label and the value.\n         *\n         *  <br/>Defaults to {}\n         */\n        gridOptions.treeCustomAggregations = gridOptions.treeCustomAggregations || {};\n\n        /**\n         *  @ngdoc object\n         *  @name enableExpandAll\n         *  @propertyOf  ui.grid.treeBase.api:GridOptions\n         *  @description Enable the expand all button at the top of the row header\n         *\n         *  <br/>Defaults to true\n         */\n        gridOptions.enableExpandAll = gridOptions.enableExpandAll !== false;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name treeBaseColumnBuilder\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Sets the tree defaults based on the columnDefs\n       *\n       * @param {object} colDef columnDef we're basing on\n       * @param {GridCol} col the column we're to update\n       * @param {object} gridOptions the options we should use\n       * @returns {promise} promise for the builder - actually we do it all inline so it's immediately resolved\n       */\n      treeBaseColumnBuilder: function (colDef, col, gridOptions) {\n\n\n        /**\n         *  @ngdoc object\n         *  @name customTreeAggregationFn\n         *  @propertyOf  ui.grid.treeBase.api:ColumnDef\n         *  @description A custom function that aggregates rows into some form of\n         *  total.  Aggregations run row-by-row, the function needs to be capable of\n         *  creating a running total.\n         *\n         *  The function will be provided the aggregation item (in which you can store running\n         *  totals), the row value that is to be aggregated, and that same row value converted to\n         *  a number (most aggregations work on numbers)\n         *  @example\n         *  <pre>\n         *    customTreeAggregationFn = function ( aggregation, fieldValue, numValue, row ){\n         *      // calculates the average of the squares of the values\n         *      if ( typeof(aggregation.count) === 'undefined' ){\n         *        aggregation.count = 0;\n         *      }\n         *      aggregation.count++;\n         *\n         *      if ( !isNaN(numValue) ){\n         *        if ( typeof(aggregation.total) === 'undefined' ){\n         *          aggregation.total = 0;\n         *        }\n         *        aggregation.total = aggregation.total + numValue * numValue;\n         *      }\n         *\n         *      aggregation.value = aggregation.total / aggregation.count;\n         *    }\n         *  </pre>\n         *  <br/>Defaults to undefined. May be overwritten by treeAggregationType, the two options should not be used together.\n         */\n        if ( typeof(colDef.customTreeAggregationFn) !== 'undefined' ){\n          col.treeAggregationFn = colDef.customTreeAggregationFn;\n        }\n\n        /**\n         *  @ngdoc object\n         *  @name treeAggregationType\n         *  @propertyOf  ui.grid.treeBase.api:ColumnDef\n         *  @description Use one of the native or grid-level aggregation methods for calculating aggregations on this column.\n         *  Native method are in the constants file and include: SUM, COUNT, MIN, MAX, AVG. This may also be the property the\n         *  name of an aggregation function defined with {@link ui.grid.treeBase.api:GridOptions treeCustomAggregations}.\n         *\n         *  <pre>\n         *      treeAggregationType = uiGridTreeBaseConstants.aggregation.SUM,\n         *    }\n         *  </pre>\n         *\n         *  If you are using aggregations you should either:\n         *\n         *   - also use grouping, in which case the aggregations are displayed in the group header, OR\n         *   - use treeView, in which case you can set `treeAggregationUpdateEntity: true` in the colDef, and\n         *     treeBase will store the aggregation information in the entity, or you can set `treeAggregationUpdateEntity: false`\n         *     in the colDef, and you need to manual retrieve the calculated aggregations from the row.treeNode.aggregations\n         *\n         *  <br/>Takes precendence over a treeAggregationFn, the two options should not be used together.\n         *  <br/>Defaults to undefined.\n         */\n        if ( typeof(colDef.treeAggregationType) !== 'undefined' ){\n          col.treeAggregation = { type: colDef.treeAggregationType };\n          if ( typeof(gridOptions.treeCustomAggregations[colDef.treeAggregationType]) !== 'undefined' ){\n            col.treeAggregationFn = gridOptions.treeCustomAggregations[colDef.treeAggregationType].aggregationFn;\n            col.treeAggregationFinalizerFn = gridOptions.treeCustomAggregations[colDef.treeAggregationType].finalizerFn;\n            col.treeAggregation.label = gridOptions.treeCustomAggregations[colDef.treeAggregationType].label;\n          } else if ( typeof(service.nativeAggregations()[colDef.treeAggregationType]) !== 'undefined' ){\n            col.treeAggregationFn = service.nativeAggregations()[colDef.treeAggregationType].aggregationFn;\n            col.treeAggregation.label = service.nativeAggregations()[colDef.treeAggregationType].label;\n          }\n        }\n\n         /**\n         *  @ngdoc object\n         *  @name treeAggregationLabel\n         *  @propertyOf  ui.grid.treeBase.api:ColumnDef\n         *  @description A custom label to use for this aggregation. If provided we don't use native i18n.\n         */\n        if ( typeof(colDef.treeAggregationLabel) !== 'undefined' ){\n          if (typeof(col.treeAggregation) === 'undefined' ){\n            col.treeAggregation = {};\n          }\n          col.treeAggregation.label = colDef.treeAggregationLabel;\n        }\n\n        /**\n         *  @ngdoc object\n         *  @name treeAggregationUpdateEntity\n         *  @propertyOf  ui.grid.treeBase.api:ColumnDef\n         *  @description Store calculated aggregations into the entity, allowing them\n         *  to be displayed in the grid using a standard cellTemplate.  This defaults to true,\n         *  if you are using grouping then you shouldn't set it to false, as then the aggregations won't\n         *  display.\n         *\n         *  If you are using treeView in most cases you'll want to set this to true.  This will result in\n         *  getCellValue returning the aggregation rather than whatever was stored in the cell attribute on\n         *  the entity.  If you want to render the underlying entity value (and do something else with the aggregation)\n         *  then you could use a custom cellTemplate to display `row.entity.myAttribute`, rather than using getCellValue.\n         *\n         *  <br/>Defaults to true\n         *\n         *  @example\n         *  <pre>\n         *    gridOptions.columns = [{\n         *      name: 'myCol',\n         *      treeAggregation: { type: uiGridTreeBaseConstants.aggregation.SUM },\n         *      treeAggregationUpdateEntity: true\n         *      cellTemplate: '<div>{{row.entity.myCol + \" \" + row.treeNode.aggregations[0].rendered}}</div>'\n         *    }];\n         * </pre>\n         */\n        col.treeAggregationUpdateEntity = colDef.treeAggregationUpdateEntity !== false;\n\n        /**\n         *  @ngdoc object\n         *  @name customTreeAggregationFinalizerFn\n         *  @propertyOf  ui.grid.treeBase.api:ColumnDef\n         *  @description A custom function that populates aggregation.rendered, this is called when\n         *  a particular aggregation has been fully calculated, and we want to render the value.\n         *\n         *  With the native aggregation options we just concatenate `aggregation.label` and\n         *  `aggregation.value`, but if you wanted to apply a filter or otherwise manipulate the label\n         *  or the value, you can do so with this function. This function will be called after the\n         *  the default `finalizerFn`.\n         *\n         *  @example\n         *  <pre>\n         *    customTreeAggregationFinalizerFn = function ( aggregation ){\n         *      aggregation.rendered = aggregation.label + aggregation.value / 100 + '%';\n         *    }\n         *  </pre>\n         *  <br/>Defaults to undefined.\n         */\n        if ( typeof(col.customTreeAggregationFinalizerFn) === 'undefined' ){\n          col.customTreeAggregationFinalizerFn = colDef.customTreeAggregationFinalizerFn;\n        }\n\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name createRowHeader\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Create the rowHeader.  If treeRowHeaderAlwaysVisible then\n       * set it to visible, otherwise set it to invisible\n       *\n       * @param {Grid} grid grid object\n       */\n      createRowHeader: function( grid ){\n        var rowHeaderColumnDef = {\n          name: uiGridTreeBaseConstants.rowHeaderColName,\n          displayName: '',\n          width:  grid.options.treeRowHeaderBaseWidth,\n          minWidth: 10,\n          cellTemplate: 'ui-grid/treeBaseRowHeader',\n          headerCellTemplate: 'ui-grid/treeBaseHeaderCell',\n          enableColumnResizing: false,\n          enableColumnMenu: false,\n          exporterSuppressExport: true,\n          allowCellFocus: true\n        };\n\n        rowHeaderColumnDef.visible = grid.options.treeRowHeaderAlwaysVisible;\n        grid.addRowHeaderColumn( rowHeaderColumnDef );\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name expandAllRows\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Expands all nodes in the tree\n       *\n       * @param {Grid} grid grid object\n       */\n      expandAllRows: function (grid) {\n        grid.treeBase.tree.forEach( function( node ) {\n          service.setAllNodes( grid, node, uiGridTreeBaseConstants.EXPANDED);\n        });\n        grid.treeBase.expandAll = true;\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name collapseAllRows\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Collapses all nodes in the tree\n       *\n       * @param {Grid} grid grid object\n       */\n      collapseAllRows: function (grid) {\n        grid.treeBase.tree.forEach( function( node ) {\n          service.setAllNodes( grid, node, uiGridTreeBaseConstants.COLLAPSED);\n        });\n        grid.treeBase.expandAll = false;\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name setAllNodes\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Works through a subset of grid.treeBase.rowExpandedStates, setting\n       * all child nodes (and their descendents) of the provided node to the given state.\n       *\n       * Calls itself recursively on all nodes so as to achieve this.\n       *\n       * @param {Grid} grid the grid we're operating on (so we can raise events)\n       * @param {object} treeNode a node in the tree that we want to update\n       * @param {string} targetState the state we want to set it to\n       */\n      setAllNodes: function (grid, treeNode, targetState) {\n        if ( typeof(treeNode.state) !== 'undefined' && treeNode.state !== targetState ){\n          treeNode.state = targetState;\n\n          if ( targetState === uiGridTreeBaseConstants.EXPANDED ){\n            grid.api.treeBase.raise.rowExpanded(treeNode.row);\n          } else {\n            grid.api.treeBase.raise.rowCollapsed(treeNode.row);\n          }\n        }\n\n        // set all child nodes\n        if ( treeNode.children ){\n          treeNode.children.forEach(function( childNode ){\n            service.setAllNodes(grid, childNode, targetState);\n          });\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name toggleRowTreeState\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Toggles the expand or collapse state of this grouped row, if\n       * it's a parent row\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to toggle\n       */\n      toggleRowTreeState: function ( grid, row ){\n        if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){\n          return;\n        }\n\n        if (row.treeNode.state === uiGridTreeBaseConstants.EXPANDED){\n          service.collapseRow(grid, row);\n        } else {\n          service.expandRow(grid, row);\n        }\n\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name expandRow\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Expands this specific row, showing only immediate children.\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to expand\n       */\n      expandRow: function ( grid, row ){\n        if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){\n          return;\n        }\n\n        if ( row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){\n          row.treeNode.state = uiGridTreeBaseConstants.EXPANDED;\n          grid.api.treeBase.raise.rowExpanded(row);\n          grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree);\n          grid.queueGridRefresh();\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name expandRowChildren\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Expands this specific row, showing all children.\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to expand\n       */\n      expandRowChildren: function ( grid, row ){\n        if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){\n          return;\n        }\n\n        service.setAllNodes(grid, row.treeNode, uiGridTreeBaseConstants.EXPANDED);\n        grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree);\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name collapseRow\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Collapses this specific row\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to collapse\n       */\n      collapseRow: function( grid, row ){\n        if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){\n          return;\n        }\n\n        if ( row.treeNode.state !== uiGridTreeBaseConstants.COLLAPSED ){\n          row.treeNode.state = uiGridTreeBaseConstants.COLLAPSED;\n          grid.treeBase.expandAll = false;\n          grid.api.treeBase.raise.rowCollapsed(row);\n          grid.queueGridRefresh();\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name collapseRowChildren\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Collapses this specific row and all children\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to collapse\n       */\n      collapseRowChildren: function( grid, row ){\n        if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){\n          return;\n        }\n\n        service.setAllNodes(grid, row.treeNode, uiGridTreeBaseConstants.COLLAPSED);\n        grid.treeBase.expandAll = false;\n        grid.queueGridRefresh();\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name allExpanded\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Returns true if all rows are expanded, false\n       * if they're not.  Walks the tree to determine this.  Used\n       * to set the expandAll state.\n       *\n       * If the node has no children, then return true (it's immaterial\n       * whether it is expanded).  If the node has children, then return\n       * false if this node is collapsed, or if any child node is not all expanded\n       *\n       * @param {object} tree the grid to check\n       * @returns {boolean} whether or not the tree is all expanded\n       */\n      allExpanded: function( tree ){\n        var allExpanded = true;\n        tree.forEach( function( node ){\n          if ( !service.allExpandedInternal( node ) ){\n            allExpanded = false;\n          }\n        });\n        return allExpanded;\n      },\n\n      allExpandedInternal: function( treeNode ){\n        if ( treeNode.children && treeNode.children.length > 0 ){\n          if ( treeNode.state === uiGridTreeBaseConstants.COLLAPSED ){\n            return false;\n          }\n          var allExpanded = true;\n          treeNode.children.forEach( function( node ){\n            if ( !service.allExpandedInternal( node ) ){\n              allExpanded = false;\n            }\n          });\n          return allExpanded;\n        } else {\n          return true;\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name treeRows\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description The rowProcessor that adds the nodes to the tree, and sets the visible\n       * state of each row based on it's parent state\n       *\n       * Assumes it is always called after the sorting processor, and the grouping processor if there is one.\n       * Performs any tree sorts itself after having built the tree\n       *\n       * Processes all the rows in order, setting the group level based on the $$treeLevel in the associated\n       * entity, and setting the visible state based on the parent's state.\n       *\n       * Calculates the deepest level of tree whilst it goes, and updates that so that the header column can be correctly\n       * sized.\n       *\n       * Aggregates if necessary along the way.\n       *\n       * @param {array} renderableRows the rows we want to process, usually the output from the previous rowProcessor\n       * @returns {array} the updated rows\n       */\n      treeRows: function( renderableRows ) {\n        if (renderableRows.length === 0){\n          return renderableRows;\n        }\n\n        var grid = this;\n        var currentLevel = 0;\n        var currentState = uiGridTreeBaseConstants.EXPANDED;\n        var parents = [];\n\n        grid.treeBase.tree = service.createTree( grid, renderableRows );\n        service.updateRowHeaderWidth( grid );\n\n        service.sortTree( grid );\n        service.fixFilter( grid );\n\n        return service.renderTree( grid.treeBase.tree );\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name createOrUpdateRowHeaderWidth\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Calculates the rowHeader width.\n       *\n       * If rowHeader is always present, updates the width.\n       *\n       * If rowHeader is only sometimes present (`treeRowHeaderAlwaysVisible: false`), determines whether there\n       * should be one, then creates or removes it as appropriate, with the created rowHeader having the\n       * right width.\n       *\n       * If there's never a rowHeader then never creates one: `showTreeRowHeader: false`\n       *\n       * @param {Grid} grid the grid we want to set the row header on\n       */\n      updateRowHeaderWidth: function( grid ){\n        var rowHeader = grid.getColumn(uiGridTreeBaseConstants.rowHeaderColName);\n\n        var newWidth = grid.options.treeRowHeaderBaseWidth + grid.options.treeIndent * Math.max(grid.treeBase.numberLevels - 1, 0);\n        if ( rowHeader && newWidth !== rowHeader.width ){\n          rowHeader.width = newWidth;\n          grid.queueRefresh();\n        }\n\n        var newVisibility = true;\n        if ( grid.options.showTreeRowHeader === false ){\n          newVisibility = false;\n        }\n        if ( grid.options.treeRowHeaderAlwaysVisible === false && grid.treeBase.numberLevels <= 0 ){\n          newVisibility = false;\n        }\n        if ( rowHeader.visible !== newVisibility ) {\n          rowHeader.visible = newVisibility;\n          rowHeader.colDef.visible = newVisibility;\n          grid.queueGridRefresh();\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name renderTree\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Creates an array of rows based on the tree, exporting only\n       * the visible nodes and leaves\n       *\n       * @param {array} nodeList the list of nodes - can be grid.treeBase.tree, or can be node.children when\n       * we're calling recursively\n       * @returns {array} renderable rows\n       */\n      renderTree: function( nodeList ){\n        var renderableRows = [];\n\n        nodeList.forEach( function ( node ){\n          if ( node.row.visible ){\n            renderableRows.push( node.row );\n          }\n          if ( node.state === uiGridTreeBaseConstants.EXPANDED && node.children && node.children.length > 0 ){\n            renderableRows = renderableRows.concat( service.renderTree( node.children ) );\n          }\n        });\n        return renderableRows;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name createTree\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Creates a tree from the renderableRows\n       *\n       * @param {Grid} grid the grid\n       * @param {array} renderableRows the rows we want to create a tree from\n       * @returns {object} the tree we've build\n       */\n      createTree: function( grid, renderableRows ) {\n        var currentLevel = -1;\n        var parents = [];\n        var currentState;\n        grid.treeBase.tree = [];\n        grid.treeBase.numberLevels = 0;\n        var aggregations = service.getAggregations( grid );\n\n        var createNode = function( row ){\n          if ( typeof(row.entity.$$treeLevel) !== 'undefined' && row.treeLevel !== row.entity.$$treeLevel ){\n            row.treeLevel = row.entity.$$treeLevel;\n          }\n\n          if ( row.treeLevel <= currentLevel ){\n            // pop any levels that aren't parents of this level, formatting the aggregation at the same time\n            while ( row.treeLevel <= currentLevel ){\n              var lastParent = parents.pop();\n              service.finaliseAggregations( lastParent );\n              currentLevel--;\n            }\n\n            // reset our current state based on the new parent, set to expanded if this is a level 0 node\n            if ( parents.length > 0 ){\n              currentState = service.setCurrentState(parents);\n            } else {\n              currentState = uiGridTreeBaseConstants.EXPANDED;\n            }\n          }\n\n          // aggregate if this is a leaf node\n          if ( ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ) && row.visible  ){\n            service.aggregate( grid, row, parents );\n          }\n\n          // add this node to the tree\n          service.addOrUseNode(grid, row, parents, aggregations);\n\n          if ( typeof(row.treeLevel) !== 'undefined' && row.treeLevel !== null && row.treeLevel >= 0 ){\n            parents.push(row);\n            currentLevel++;\n            currentState = service.setCurrentState(parents);\n          }\n\n          // update the tree number of levels, so we can set header width if we need to\n          if ( grid.treeBase.numberLevels < row.treeLevel + 1){\n            grid.treeBase.numberLevels = row.treeLevel + 1;\n          }\n        };\n\n        renderableRows.forEach( createNode );\n\n        // finalise remaining aggregations\n        while ( parents.length > 0 ){\n          var lastParent = parents.pop();\n          service.finaliseAggregations( lastParent );\n        }\n\n        return grid.treeBase.tree;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name addOrUseNode\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Creates a tree node for this row.  If this row already has a treeNode\n       * recorded against it, preserves the state, but otherwise overwrites the data.\n       *\n       * @param {grid} grid the grid we're operating on\n       * @param {gridRow} row the row we want to set\n       * @param {array} parents an array of the parents this row should have\n       * @param {array} aggregationBase empty aggregation information\n       * @returns {undefined} updates the parents array, updates the row to have a treeNode, and updates the\n       * grid.treeBase.tree\n       */\n      addOrUseNode: function( grid, row, parents, aggregationBase ){\n        var newAggregations = [];\n        aggregationBase.forEach( function(aggregation){\n          newAggregations.push(service.buildAggregationObject(aggregation.col));\n        });\n\n        var newNode = { state: uiGridTreeBaseConstants.COLLAPSED, row: row, parentRow: null, aggregations: newAggregations, children: [] };\n        if ( row.treeNode ){\n          newNode.state = row.treeNode.state;\n        }\n        if ( parents.length > 0 ){\n          newNode.parentRow = parents[parents.length - 1];\n        }\n        row.treeNode = newNode;\n\n        if ( parents.length === 0 ){\n          grid.treeBase.tree.push( newNode );\n        } else {\n          parents[parents.length - 1].treeNode.children.push( newNode );\n        }\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name setCurrentState\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Looks at the parents array to determine our current state.\n       * If any node in the hierarchy is collapsed, then return collapsed, otherwise return\n       * expanded.\n       *\n       * @param {array} parents an array of the parents this row should have\n       * @returns {string} the state we should be setting to any nodes we see\n       */\n      setCurrentState: function( parents ){\n        var currentState = uiGridTreeBaseConstants.EXPANDED;\n        parents.forEach( function(parent){\n          if ( parent.treeNode.state === uiGridTreeBaseConstants.COLLAPSED ){\n            currentState = uiGridTreeBaseConstants.COLLAPSED;\n          }\n        });\n        return currentState;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name sortTree\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Performs a recursive sort on the tree nodes, sorting the\n       * children of each node and putting them back into the children array.\n       *\n       * Before doing this it turns back on all the sortIgnore - things that were previously\n       * ignored we process now.  Since we're sorting within the nodes, presumably anything\n       * that was already sorted is how we derived the nodes, we can keep those sorts too.\n       *\n       * We only sort tree nodes that are expanded - no point in wasting effort sorting collapsed\n       * nodes\n       *\n       * @param {Grid} grid the grid to get the aggregation information from\n       * @returns {array} the aggregation information\n       */\n      sortTree: function( grid ){\n        grid.columns.forEach( function( column ) {\n          if ( column.sort && column.sort.ignoreSort ){\n            delete column.sort.ignoreSort;\n          }\n        });\n\n        grid.treeBase.tree = service.sortInternal( grid, grid.treeBase.tree );\n      },\n\n      sortInternal: function( grid, treeList ){\n        var rows = treeList.map( function( node ){\n          return node.row;\n        });\n\n        rows = rowSorter.sort( grid, rows, grid.columns );\n\n        var treeNodes = rows.map( function( row ){\n          return row.treeNode;\n        });\n\n        treeNodes.forEach( function( node ){\n          if ( node.state === uiGridTreeBaseConstants.EXPANDED && node.children && node.children.length > 0 ){\n            node.children = service.sortInternal( grid, node.children );\n          }\n        });\n\n        return treeNodes;\n      },\n\n      /**\n       * @ngdoc function\n       * @name fixFilter\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description After filtering has run, we need to go back through the tree\n       * and make sure the parent rows are always visible if any of the child rows\n       * are visible (filtering may make a child visible, but the parent may not\n       * match the filter criteria)\n       *\n       * This has a risk of being computationally expensive, we do it by walking\n       * the tree and remembering whether there are any invisible nodes on the\n       * way down.\n       *\n       * @param {Grid} grid the grid to fix filters on\n       */\n      fixFilter: function( grid ){\n        var parentsVisible;\n\n        grid.treeBase.tree.forEach( function( node ){\n          if ( node.children && node.children.length > 0 ){\n            parentsVisible = node.row.visible;\n            service.fixFilterInternal( node.children, parentsVisible );\n          }\n        });\n      },\n\n      fixFilterInternal: function( nodes, parentsVisible) {\n        nodes.forEach( function( node ){\n          if ( node.row.visible && !parentsVisible ){\n            service.setParentsVisible( node );\n            parentsVisible = true;\n          }\n\n          if ( node.children && node.children.length > 0 ){\n            if ( service.fixFilterInternal( node.children, ( parentsVisible && node.row.visible ) ) ) {\n              parentsVisible = true;\n            }\n          }\n        });\n\n        return parentsVisible;\n      },\n\n      setParentsVisible: function( node ){\n        while ( node.parentRow ){\n          node.parentRow.visible = true;\n          node = node.parentRow.treeNode;\n        }\n      },\n\n      /**\n       * @ngdoc function\n       * @name buildAggregationObject\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Build the object which is stored on the column for holding meta-data about the aggregation.\n       * This method should only be called with columns which have an aggregation.\n       *\n       * @param {Column} the column which this object relates to\n       * @returns {object} {col: Column object, label: string, type: string (optional)}\n       */\n      buildAggregationObject: function( column ){\n        var newAggregation = { col: column };\n\n        if ( column.treeAggregation && column.treeAggregation.type ){\n          newAggregation.type = column.treeAggregation.type;\n        }\n\n        if ( column.treeAggregation && column.treeAggregation.label ){\n          newAggregation.label = column.treeAggregation.label;\n        }\n\n        return newAggregation;\n      },\n\n      /**\n       * @ngdoc function\n       * @name getAggregations\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Looks through the grid columns to find those with aggregations,\n       * and collates the aggregation information into an array, returns that array\n       *\n       * @param {Grid} grid the grid to get the aggregation information from\n       * @returns {array} the aggregation information\n       */\n      getAggregations: function( grid ){\n        var aggregateArray = [];\n\n        grid.columns.forEach( function(column){\n          if ( typeof(column.treeAggregationFn) !== 'undefined' ){\n            aggregateArray.push( service.buildAggregationObject(column) );\n\n            if ( grid.options.showColumnFooter && typeof(column.colDef.aggregationType) === 'undefined' && column.treeAggregation ){\n              // Add aggregation object for footer\n              column.treeFooterAggregation = service.buildAggregationObject(column);\n              column.aggregationType = service.treeFooterAggregationType;\n            }\n          }\n        });\n        return aggregateArray;\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name aggregate\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Accumulate the data from this row onto the aggregations for each parent\n       *\n       * Iterate over the parents, then iterate over the aggregations for each of those parents,\n       * and perform the aggregation for each individual aggregation\n       *\n       * @param {Grid} grid grid object\n       * @param {GridRow} row the row we want to set grouping visibility on\n       * @param {array} parents the parents that we would want to aggregate onto\n       */\n      aggregate: function( grid, row, parents ){\n        if ( parents.length === 0 && row.treeNode && row.treeNode.aggregations ){\n          row.treeNode.aggregations.forEach(function(aggregation){\n            // Calculate aggregations for footer even if there are no grouped rows\n            if ( typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) {\n              var fieldValue = grid.getCellValue(row, aggregation.col);\n              var numValue = Number(fieldValue);\n              aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);\n            }\n          });\n        }\n\n        parents.forEach( function( parent, index ){\n          if ( parent.treeNode.aggregations ){\n            parent.treeNode.aggregations.forEach( function( aggregation ){\n              var fieldValue = grid.getCellValue(row, aggregation.col);\n              var numValue = Number(fieldValue);\n              aggregation.col.treeAggregationFn(aggregation, fieldValue, numValue, row);\n\n              if ( index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ){\n                aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row);\n              }\n            });\n          }\n        });\n      },\n\n\n      // Aggregation routines - no doco needed as self evident\n      nativeAggregations: function() {\n        var nativeAggregations = {\n          count: {\n            label: i18nService.get().aggregation.count,\n            menuTitle: i18nService.get().grouping.aggregate_count,\n            aggregationFn: function (aggregation, fieldValue, numValue) {\n              if (typeof(aggregation.value) === 'undefined') {\n                aggregation.value = 1;\n              } else {\n                aggregation.value++;\n              }\n            }\n          },\n\n          sum: {\n            label: i18nService.get().aggregation.sum,\n            menuTitle: i18nService.get().grouping.aggregate_sum,\n            aggregationFn: function( aggregation, fieldValue, numValue ) {\n              if (!isNaN(numValue)) {\n                if (typeof(aggregation.value) === 'undefined') {\n                  aggregation.value = numValue;\n                } else {\n                  aggregation.value += numValue;\n                }\n              }\n            }\n          },\n\n          min: {\n            label: i18nService.get().aggregation.min,\n            menuTitle: i18nService.get().grouping.aggregate_min,\n            aggregationFn: function( aggregation, fieldValue, numValue ) {\n              if (typeof(aggregation.value) === 'undefined') {\n                aggregation.value = fieldValue;\n              } else {\n                if (typeof(fieldValue) !== 'undefined' && fieldValue !== null && (fieldValue < aggregation.value || aggregation.value === null)) {\n                  aggregation.value = fieldValue;\n                }\n              }\n            }\n          },\n\n          max: {\n            label: i18nService.get().aggregation.max,\n            menuTitle: i18nService.get().grouping.aggregate_max,\n            aggregationFn: function( aggregation, fieldValue, numValue ){\n              if ( typeof(aggregation.value) === 'undefined' ){\n                aggregation.value = fieldValue;\n              } else {\n                if ( typeof(fieldValue) !== 'undefined' && fieldValue !== null && (fieldValue > aggregation.value || aggregation.value === null)){\n                  aggregation.value = fieldValue;\n                }\n              }\n            }\n          },\n\n          avg: {\n            label: i18nService.get().aggregation.avg,\n            menuTitle: i18nService.get().grouping.aggregate_avg,\n            aggregationFn: function( aggregation, fieldValue, numValue ){\n              if ( typeof(aggregation.count) === 'undefined' ){\n                aggregation.count = 1;\n              } else {\n                aggregation.count++;\n              }\n\n              if ( isNaN(numValue) ){\n                return;\n              }\n\n              if ( typeof(aggregation.value) === 'undefined' || typeof(aggregation.sum) === 'undefined' ){\n                aggregation.value = numValue;\n                aggregation.sum = numValue;\n              } else {\n                aggregation.sum += numValue;\n                aggregation.value = aggregation.sum / aggregation.count;\n              }\n            }\n          }\n        };\n        return nativeAggregations;\n      },\n\n      /**\n       * @ngdoc function\n       * @name finaliseAggregation\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Helper function used to finalize aggregation nodes and footer cells\n       *\n       * @param {gridRow} row the parent we're finalising\n       * @param {aggregation} the aggregation object manipulated by the aggregationFn\n       */\n      finaliseAggregation: function(row, aggregation){\n        if ( aggregation.col.treeAggregationUpdateEntity && typeof(row) !== 'undefined' && typeof(row.entity[ '$$' + aggregation.col.uid ]) !== 'undefined' ){\n          angular.extend( aggregation, row.entity[ '$$' + aggregation.col.uid ]);\n        }\n\n        if ( typeof(aggregation.col.treeAggregationFinalizerFn) === 'function' ){\n          aggregation.col.treeAggregationFinalizerFn( aggregation );\n        }\n        if ( typeof(aggregation.col.customTreeAggregationFinalizerFn) === 'function' ){\n          aggregation.col.customTreeAggregationFinalizerFn( aggregation );\n        }\n        if ( typeof(aggregation.rendered) === 'undefined' ){\n          aggregation.rendered = aggregation.label ? aggregation.label + aggregation.value : aggregation.value;\n        }\n      },\n\n      /**\n       * @ngdoc function\n       * @name finaliseAggregations\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Format the data from the aggregation into the rendered text\n       * e.g. if we had label: 'sum: ' and value: 25, we'd create 'sum: 25'.\n       *\n       * As part of this we call any formatting callback routines we've been provided.\n       *\n       * We write our aggregation out to the row.entity if treeAggregationUpdateEntity is\n       * set on the column - we don't overwrite any information that's already there, we append\n       * to it so that grouping can have set the groupVal beforehand without us overwriting it.\n       *\n       * We need to copy the data from the row.entity first before we finalise the aggregation,\n       * we need that information for the finaliserFn\n       *\n       * @param {gridRow} row the parent we're finalising\n       */\n      finaliseAggregations: function( row ){\n        if ( typeof(row.treeNode.aggregations) === 'undefined' ){\n          return;\n        }\n\n        row.treeNode.aggregations.forEach( function( aggregation ) {\n          service.finaliseAggregation(row, aggregation);\n\n          if ( aggregation.col.treeAggregationUpdateEntity ){\n            var aggregationCopy = {};\n            angular.forEach( aggregation, function( value, key ){\n              if ( aggregation.hasOwnProperty(key) && key !== 'col' ){\n                aggregationCopy[key] = value;\n              }\n            });\n\n            row.entity[ '$$' + aggregation.col.uid ] = aggregationCopy;\n          }\n        });\n      },\n\n      /**\n       * @ngdoc function\n       * @name treeFooterAggregationType\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Uses the tree aggregation functions and finalizers to set the\n       * column footer aggregations.\n       *\n       * @param {rows} visible rows. not used, but accepted to match signature of GridColumn.aggregationType\n       * @param {gridColumn} the column we are finalizing\n       */\n      treeFooterAggregationType: function( rows, column ) {\n        service.finaliseAggregation(undefined, column.treeFooterAggregation);\n        if ( typeof(column.treeFooterAggregation.value) === 'undefined' || column.treeFooterAggregation.rendered === null ){\n          // The was apparently no aggregation performed (perhaps this is a grouped column\n          return '';\n        }\n        return column.treeFooterAggregation.rendered;\n      }\n    };\n\n    return service;\n\n  }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.treeBase.directive:uiGridTreeRowHeaderButtons\n   *  @element div\n   *\n   *  @description Provides the expand/collapse button on rows\n   */\n  module.directive('uiGridTreeBaseRowHeaderButtons', ['$templateCache', 'uiGridTreeBaseService',\n  function ($templateCache, uiGridTreeBaseService) {\n    return {\n      replace: true,\n      restrict: 'E',\n      template: $templateCache.get('ui-grid/treeBaseRowHeaderButtons'),\n      scope: true,\n      require: '^uiGrid',\n      link: function($scope, $elm, $attrs, uiGridCtrl) {\n        var self = uiGridCtrl.grid;\n        $scope.treeButtonClick = function(row, evt) {\n          uiGridTreeBaseService.toggleRowTreeState(self, row, evt);\n        };\n      }\n    };\n  }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.treeBase.directive:uiGridTreeBaseExpandAllButtons\n   *  @element div\n   *\n   *  @description Provides the expand/collapse all button\n   */\n  module.directive('uiGridTreeBaseExpandAllButtons', ['$templateCache', 'uiGridTreeBaseService',\n  function ($templateCache, uiGridTreeBaseService) {\n    return {\n      replace: true,\n      restrict: 'E',\n      template: $templateCache.get('ui-grid/treeBaseExpandAllButtons'),\n      scope: false,\n      link: function($scope, $elm, $attrs, uiGridCtrl) {\n        var self = $scope.col.grid;\n\n        $scope.headerButtonClick = function(row, evt) {\n          if ( self.treeBase.expandAll ){\n            uiGridTreeBaseService.collapseAllRows(self, evt);\n          } else {\n            uiGridTreeBaseService.expandAllRows(self, evt);\n          }\n        };\n      }\n    };\n  }]);\n\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.treeBase.directive:uiGridViewport\n   *  @element div\n   *\n   *  @description Stacks on top of ui.grid.uiGridViewport to set formatting on a tree header row\n   */\n  module.directive('uiGridViewport',\n  ['$compile', 'uiGridConstants', 'gridUtil', '$parse',\n    function ($compile, uiGridConstants, gridUtil, $parse) {\n      return {\n        priority: -200, // run after default  directive\n        scope: false,\n        compile: function ($elm, $attrs) {\n          var rowRepeatDiv = angular.element($elm.children().children()[0]);\n\n          var existingNgClass = rowRepeatDiv.attr(\"ng-class\");\n          var newNgClass = '';\n          if ( existingNgClass ) {\n            newNgClass = existingNgClass.slice(0, -1) + \",'ui-grid-tree-header-row': row.treeLevel > -1}\";\n          } else {\n            newNgClass = \"{'ui-grid-tree-header-row': row.treeLevel > -1}\";\n          }\n          rowRepeatDiv.attr(\"ng-class\", newNgClass);\n\n          return {\n            pre: function ($scope, $elm, $attrs, controllers) {\n\n            },\n            post: function ($scope, $elm, $attrs, controllers) {\n            }\n          };\n        }\n      };\n    }]);\n})();\n\n(function () {\n  'use strict';\n\n  /**\n   * @ngdoc overview\n   * @name ui.grid.treeView\n   * @description\n   *\n   * # ui.grid.treeView\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Beta</strong> This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs.</div>\n   *\n   * This module provides a tree view of the data that it is provided, with nodes in that\n   * tree and leaves.  Unlike grouping, the tree is an inherent property of the data and must\n   * be provided with your data array.\n   *\n   * Design information:\n   * -------------------\n   *\n   * TreeView uses treeBase for the underlying functionality, and is a very thin wrapper around\n   * that logic.  Most of the design information has now moved to treebase.\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.treeView\"></div>\n   */\n\n  var module = angular.module('ui.grid.treeView', ['ui.grid', 'ui.grid.treeBase']);\n\n  /**\n   *  @ngdoc object\n   *  @name ui.grid.treeView.constant:uiGridTreeViewConstants\n   *\n   *  @description constants available in treeView module, this includes\n   *  all the constants declared in the treeBase module (these are manually copied\n   *  as there isn't an easy way to include constants in another constants file, and\n   *  we don't want to make users include treeBase)\n   *\n   */\n  module.constant('uiGridTreeViewConstants', {\n    featureName: \"treeView\",\n    rowHeaderColName: 'treeBaseRowHeaderCol',\n    EXPANDED: 'expanded',\n    COLLAPSED: 'collapsed',\n    aggregation: {\n      COUNT: 'count',\n      SUM: 'sum',\n      MAX: 'max',\n      MIN: 'min',\n      AVG: 'avg'\n    }\n  });\n\n  /**\n   *  @ngdoc service\n   *  @name ui.grid.treeView.service:uiGridTreeViewService\n   *\n   *  @description Services for treeView features\n   */\n  module.service('uiGridTreeViewService', ['$q', 'uiGridTreeViewConstants', 'uiGridTreeBaseConstants', 'uiGridTreeBaseService', 'gridUtil', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants',\n  function ($q, uiGridTreeViewConstants, uiGridTreeBaseConstants, uiGridTreeBaseService, gridUtil, GridRow, gridClassFactory, i18nService, uiGridConstants) {\n\n    var service = {\n\n      initializeGrid: function (grid, $scope) {\n        uiGridTreeBaseService.initializeGrid( grid, $scope );\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeView.grid:treeView\n         *\n         *  @description Grid properties and functions added for treeView\n         */\n        grid.treeView = {};\n\n        grid.registerRowsProcessor(service.adjustSorting, 60);\n\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeView.api:PublicApi\n         *\n         *  @description Public Api for treeView feature\n         */\n        var publicApi = {\n          events: {\n            treeView: {\n            }\n          },\n          methods: {\n            treeView: {\n            }\n          }\n        };\n\n        grid.api.registerEventsFromObject(publicApi.events);\n\n        grid.api.registerMethodsFromObject(publicApi.methods);\n\n      },\n\n      defaultGridOptions: function (gridOptions) {\n        //default option to true unless it was explicitly set to false\n        /**\n         *  @ngdoc object\n         *  @name ui.grid.treeView.api:GridOptions\n         *\n         *  @description GridOptions for treeView feature, these are available to be\n         *  set using the ui-grid {@link ui.grid.class:GridOptions gridOptions}\n         *\n         *  Many tree options are set on treeBase, make sure to look at that feature in\n         *  conjunction with these options.\n         */\n\n        /**\n         *  @ngdoc object\n         *  @name enableTreeView\n         *  @propertyOf  ui.grid.treeView.api:GridOptions\n         *  @description Enable row tree view for entire grid.\n         *  <br/>Defaults to true\n         */\n        gridOptions.enableTreeView = gridOptions.enableTreeView !== false;\n\n      },\n\n\n      /**\n       * @ngdoc function\n       * @name adjustSorting\n       * @methodOf  ui.grid.treeBase.service:uiGridTreeBaseService\n       * @description Trees cannot be sorted the same as flat lists of rows -\n       * trees are sorted recursively within each level - so the children of each\n       * node are sorted, but not the full set of rows.\n       *\n       * To achieve this, we suppress the normal sorting by setting ignoreSort on\n       * each of the sort columns.  When the treeBase rowsProcessor runs it will then\n       * unignore these, and will perform a recursive sort against the tree that it builds.\n       *\n       * @param {array} renderableRows the rows that we need to pass on through\n       * @returns {array} renderableRows that we passed on through\n       */\n      adjustSorting: function( renderableRows ) {\n        var grid = this;\n\n        grid.columns.forEach( function( column ){\n          if ( column.sort ){\n            column.sort.ignoreSort = true;\n          }\n        });\n\n        return renderableRows;\n      }\n\n    };\n\n    return service;\n\n  }]);\n\n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.treeView.directive:uiGridTreeView\n   *  @element div\n   *  @restrict A\n   *\n   *  @description Adds treeView features to grid\n   *\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.treeView']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name', enableCellEdit: true},\n        {name: 'title', enableCellEdit: true}\n      ];\n\n      $scope.gridOptions = { columnDefs: $scope.columnDefs, data: $scope.data };\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"gridOptions\" ui-grid-tree-view></div>\n   </div>\n   </file>\n   </example>\n   */\n  module.directive('uiGridTreeView', ['uiGridTreeViewConstants', 'uiGridTreeViewService', '$templateCache',\n  function (uiGridTreeViewConstants, uiGridTreeViewService, $templateCache) {\n    return {\n      replace: true,\n      priority: 0,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            if (uiGridCtrl.grid.options.enableTreeView !== false){\n              uiGridTreeViewService.initializeGrid(uiGridCtrl.grid, $scope);\n            }\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n\n          }\n        };\n      }\n    };\n  }]);\n})();\n\n(function () {\n  'use strict';\n  \n  /**\n   * @ngdoc overview\n   * @name ui.grid.validate\n   * @description\n   *\n   * # ui.grid.validate\n   *\n   * <div class=\"alert alert-warning\" role=\"alert\"><strong>Alpha</strong> This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs.</div>\n   *\n   * This module provides the ability to validate cells upon change.\n   *\n   * Design information:\n   * -------------------\n   *\n   * Validation is not based on angularjs validation, since it would work only when editing the field.\n   * \n   * Instead it adds custom properties to any field considered as invalid.\n   *\n   * <br/>\n   * <br/>\n   *\n   * <div doc-module-components=\"ui.grid.expandable\"></div>\n   */\n\n  var module = angular.module('ui.grid.validate', ['ui.grid']);\n  \n  \n  /**\n   *  @ngdoc service\n   *  @name ui.grid.validate.service:uiGridValidateService\n   *\n   *  @description Services for validation features\n   */\n  module.service('uiGridValidateService', ['$sce', '$q', '$http', 'i18nService', 'uiGridConstants', function ($sce, $q, $http, i18nService, uiGridConstants) {\n\n    var service = {\n      \n      /**\n       *  @ngdoc object\n       *  @name validatorFactories\n       *  @propertyOf ui.grid.validate.service:uiGridValidateService\n       *  @description object containing all the factories used to validate data.<br/>\n       *  These factories will be in the form <br/>\n       *  ```\n       *  {\n       *    validatorFactory: function(argument) {\n       *                        return function(newValue, oldValue, rowEntity, colDef) {\n       *                          return true || false || promise\n       *                        }\n       *                      },\n       *    messageFunction: function(argument) {\n       *                       return string\n       *                     }\n       *  }\n       *  ```\n       *\n       * Promises should return true or false as result according to the result of validation.\n       */\n      validatorFactories: {},\n\n      \n      /**\n       * @ngdoc service\n       * @name setExternalFactoryFunction\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Adds a way to retrieve validators from an external service\n       * <p>Validators from this external service have a higher priority than default\n       * ones\n       * @param {function} externalFactoryFunction a function that accepts name and argument to pass to a\n       * validator factory and that returns an object with the same properties as \n       * you can see in {@link ui.grid.validate.service:uiGridValidateService#properties_validatorFactories validatorFactories}\n       */\n      setExternalFactoryFunction: function(externalFactoryFunction) {\n        service.externalFactoryFunction = externalFactoryFunction;\n      },\n      \n      /**\n       * @ngdoc service\n       * @name clearExternalFactory\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Removes any link to external factory from this service\n       */\n      clearExternalFactory: function() {\n        delete service.externalFactoryFunction;\n      },\n\n      /**\n       * @ngdoc service\n       * @name getValidatorFromExternalFactory\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Retrieves a validator by executing a validatorFactory\n       * stored in an external service.\n       * @param {string} name the name of the validator to retrieve\n       * @param {object} argument an argument to pass to the validator factory\n       */\n      getValidatorFromExternalFactory: function(name, argument) {\n        return service.externalFactoryFunction(name, argument).validatorFactory(argument);\n      },\n      \n      /**\n       * @ngdoc service\n       * @name getMessageFromExternalFactory\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Retrieves a message stored in an external service.\n       * @param {string} name the name of the validator\n       * @param {object} argument an argument to pass to the message function\n       */\n      getMessageFromExternalFactory: function(name, argument) {\n        return service.externalFactoryFunction(name, argument).messageFunction(argument);\n      },\n      \n      /**\n       * @ngdoc service\n       * @name setValidator\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description  Adds a new validator to the service\n       * @param {string} name the name of the validator, must be unique\n       * @param {function} validatorFactory a factory that return a validatorFunction\n       * @param {function} messageFunction a function that return the error message\n       */\n      setValidator: function(name, validatorFactory, messageFunction) {\n        service.validatorFactories[name] = {\n          validatorFactory: validatorFactory,\n          messageFunction: messageFunction\n        };\n      },\n\n      /**\n       * @ngdoc service\n       * @name getValidator\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Returns a validator registered to the service\n       * or retrieved from the external factory\n       * @param {string} name the name of the validator to retrieve\n       * @param {object} argument an argument to pass to the validator factory\n       * @returns {object} the validator function\n       */\n      getValidator: function(name, argument) {\n        if (service.externalFactoryFunction) {\n          var validator = service.getValidatorFromExternalFactory(name, argument);\n          if (validator) {\n            return validator;\n          }\n        }\n        if (!service.validatorFactories[name]) {\n          throw (\"Invalid validator name: \" + name);\n        }\n        return service.validatorFactories[name].validatorFactory(argument);\n      },\n\n      /**\n       * @ngdoc service\n       * @name getMessage\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Returns the error message related to the validator \n       * @param {string} name the name of the validator\n       * @param {object} argument an argument to pass to the message function\n       * @returns {string} the error message related to the validator\n       */\n      getMessage: function(name, argument) {\n        if (service.externalFactoryFunction) {\n          var message = service.getMessageFromExternalFactory(name, argument);\n          if (message) {\n            return message;\n          }\n        }\n        return service.validatorFactories[name].messageFunction(argument);\n      },\n\n      /**\n       * @ngdoc service\n       * @name isInvalid\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Returns true if the cell (identified by rowEntity, colDef) is invalid \n       * @param {object} rowEntity the row entity of the cell\n       * @param {object} colDef the colDef of the cell\n       * @returns {boolean} true if the cell is invalid\n       */\n      isInvalid: function (rowEntity, colDef) {\n        return rowEntity['$$invalid'+colDef.name];\n      },\n\n      /**\n       * @ngdoc service\n       * @name setInvalid\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Makes the cell invalid by adding the proper field to the entity\n       * @param {object} rowEntity the row entity of the cell\n       * @param {object} colDef the colDef of the cell\n       */\n      setInvalid: function (rowEntity, colDef) {\n        rowEntity['$$invalid'+colDef.name] = true;\n      },\n    \n      /**\n       * @ngdoc service\n       * @name setValid\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Makes the cell valid by removing the proper error field from the entity\n       * @param {object} rowEntity the row entity of the cell\n       * @param {object} colDef the colDef of the cell\n       */\n      setValid: function (rowEntity, colDef) {\n        delete rowEntity['$$invalid'+colDef.name];\n      },\n\n      /**\n       * @ngdoc service\n       * @name setError\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Adds the proper error to the entity errors field\n       * @param {object} rowEntity the row entity of the cell\n       * @param {object} colDef the colDef of the cell\n       * @param {string} validatorName the name of the validator that is failing\n       */\n      setError: function(rowEntity, colDef, validatorName) {\n        if (!rowEntity['$$errors'+colDef.name]) {\n          rowEntity['$$errors'+colDef.name] = {};\n        }\n        rowEntity['$$errors'+colDef.name][validatorName] = true;\n      },\n\n      /**\n       * @ngdoc service\n       * @name clearError\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Removes the proper error from the entity errors field\n       * @param {object} rowEntity the row entity of the cell\n       * @param {object} colDef the colDef of the cell\n       * @param {string} validatorName the name of the validator that is failing\n       */\n      clearError: function(rowEntity, colDef, validatorName) {\n        if (!rowEntity['$$errors'+colDef.name]) {\n          return;\n        }\n        if (validatorName in rowEntity['$$errors'+colDef.name]) {\n            delete rowEntity['$$errors'+colDef.name][validatorName];\n        }\n      },\n      \n      /**\n       * @ngdoc function\n       * @name getErrorMessages\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description returns an array of i18n-ed error messages.\n       * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n       * @param {object} colDef the column whose errors we are looking for\n       * @returns {array} An array of strings containing all the error messages for the cell\n       */\n      getErrorMessages: function(rowEntity, colDef) {\n        var errors = [];\n\n        if (!rowEntity['$$errors'+colDef.name] || Object.keys(rowEntity['$$errors'+colDef.name]).length === 0) {\n          return errors;\n        }\n\n        Object.keys(rowEntity['$$errors'+colDef.name]).sort().forEach(function(validatorName) {\n          errors.push(service.getMessage(validatorName, colDef.validators[validatorName]));\n        });\n        \n        return errors;\n      },\n      \n      /**\n       * @ngdoc function\n       * @name getFormattedErrors\n       * @methodOf  ui.grid.validate.service:uiGridValidateService\n       * @description returns the error i18n-ed and formatted in html to be shown inside the page.\n       * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n       * @param {object} colDef the column whose errors we are looking for\n       * @returns {object} An object that can be used in a template (like a cellTemplate) to display the\n       * message inside the page (i.e. inside a div)\n       */\n      getFormattedErrors: function(rowEntity, colDef) {\n\n        var msgString = \"\";\n\n        var errors = service.getErrorMessages(rowEntity, colDef);\n        \n        if (!errors.length) {\n          return;\n        }\n        \n        errors.forEach(function(errorMsg) {\n          msgString += errorMsg + \"<br/>\";\n        });\n\n        return $sce.trustAsHtml('<p><b>' + i18nService.getSafeText('validate.error') + '</b></p>' + msgString );\n      },\n\n      /**\n       * @ngdoc function\n       * @name getTitleFormattedErrors\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description returns the error i18n-ed and formatted in javaScript to be shown inside an html \n       * title attribute.\n       * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n       * @param {object} colDef the column whose errors we are looking for\n       * @returns {object} An object that can be used in a template (like a cellTemplate) to display the\n       * message inside an html title attribute\n       */\n      getTitleFormattedErrors: function(rowEntity, colDef) {\n\n        var newLine = \"\\n\";\n\n        var msgString = \"\";\n        \n        var errors = service.getErrorMessages(rowEntity, colDef);\n        \n        if (!errors.length) {\n          return;\n        }\n        \n        errors.forEach(function(errorMsg) {\n          msgString += errorMsg + newLine;\n        });\n\n        return $sce.trustAsHtml(i18nService.getSafeText('validate.error') + newLine + msgString);\n      },\n\n      /**\n       * @ngdoc function\n       * @name getTitleFormattedErrors\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description Executes all validators on a cell (identified by row entity and column definition) and sets or clears errors\n       * @param {object} rowEntity the row entity of the cell we want to run the validators on\n       * @param {object} colDef the column definition of the cell we want to run the validators on\n       * @param {object} newValue the value the user just entered\n       * @param {object} oldValue the value the field had before\n       */\n      runValidators: function(rowEntity, colDef, newValue, oldValue, grid) {\n        \n        if (newValue === oldValue) {\n          // If the value has not changed we perform no validation\n          return;\n        }\n        \n        if (typeof(colDef.name) === 'undefined' || !colDef.name) {\n          throw new Error('colDef.name is required to perform validation');\n        }\n        \n        service.setValid(rowEntity, colDef);\n        \n        var validateClosureFactory = function(rowEntity, colDef, validatorName) {\n          return function(value) {\n            if (!value) {\n              service.setInvalid(rowEntity, colDef);\n              service.setError(rowEntity, colDef, validatorName);\n              if (grid) {\n                grid.api.validate.raise.validationFailed(rowEntity, colDef, newValue, oldValue);\n              }\n            }\n          };\n        };\n\n        for (var validatorName in colDef.validators) {\n          service.clearError(rowEntity, colDef, validatorName);\n          var msg;\n          var validatorFunction = service.getValidator(validatorName, colDef.validators[validatorName]);\n          // We pass the arguments as oldValue, newValue so they are in the same order \n          // as ng-model validators (modelValue, viewValue)\n          $q.when(validatorFunction(oldValue, newValue, rowEntity, colDef))\n            .then(validateClosureFactory(rowEntity, colDef, validatorName)\n          );\n        }\n      },\n\n      /**\n       * @ngdoc function\n       * @name createDefaultValidators\n       * @methodOf ui.grid.validate.service:uiGridValidateService\n       * @description adds the basic validators to the list of service validators\n       */\n      createDefaultValidators: function() {\n        service.setValidator('minLength',\n                             function (argument) {\n                               return function (oldValue, newValue, rowEntity, colDef) {\n                                 if (newValue === undefined || newValue === null || newValue === '') {\n                                   return true;\n                                 }\n                                 return newValue.length >= argument;\n                               };\n                             },\n                               function(argument) {\n                                 return i18nService.getSafeText('validate.minLength').replace('THRESHOLD', argument);\n                               });\n        \n        service.setValidator('maxLength',\n                             function (argument) {\n                               return function (oldValue, newValue, rowEntity, colDef) {\n                                 if (newValue === undefined || newValue === null || newValue === '') {\n                                   return true;\n                                 }\n                                 return newValue.length <= argument;\n                               };\n                             },\n                             function(threshold) {\n                               return i18nService.getSafeText('validate.maxLength').replace('THRESHOLD', threshold);\n                             });\n        \n        service.setValidator('required',\n                             function (argument) {\n                               return function (oldValue, newValue, rowEntity, colDef) {\n                                 if (argument) {\n                                   return !(newValue === undefined || newValue === null || newValue === '');\n                                 }\n                                 return true;\n                               };\n                             },\n                             function(argument) {\n                               return i18nService.getSafeText('validate.required');\n                             });\n      },\n\n      initializeGrid: function (scope, grid) {\n        grid.validate = {\n        \n          isInvalid: service.isInvalid,\n\n          getFormattedErrors: service.getFormattedErrors,\n         \n          getTitleFormattedErrors: service.getTitleFormattedErrors,\n\n          runValidators: service.runValidators\n        };\n        \n        /**\n         *  @ngdoc object\n         *  @name ui.grid.validate.api:PublicApi\n         *\n         *  @description Public Api for validation feature\n         */\n        var publicApi = {\n          events: {\n            validate: {\n              /**\n               * @ngdoc event\n               * @name validationFailed\n               * @eventOf  ui.grid.validate.api:PublicApi\n               * @description raised when one or more failure happened during validation \n               * <pre>\n               *      gridApi.validate.on.validationFailed(scope, function(rowEntity, colDef, newValue, oldValue){...})\n               * </pre>\n               * @param {object} rowEntity the options.data element whose validation failed\n               * @param {object} colDef the column whose validation failed\n               * @param {object} newValue new value\n               * @param {object} oldValue old value\n               */\n              validationFailed: function (rowEntity, colDef, newValue, oldValue) {\n              }\n            }\n          },\n          methods: {\n            validate: {\n              /**\n               * @ngdoc function\n               * @name isInvalid\n               * @methodOf  ui.grid.validate.api:PublicApi\n               * @description checks if a cell (identified by rowEntity, colDef) is invalid\n               * @param {object} rowEntity gridOptions.data[] array instance we want to check\n               * @param {object} colDef the column whose errors we want to check\n               * @returns {boolean} true if the cell value is not valid\n               */\n              isInvalid: function(rowEntity, colDef) {\n                return grid.validate.isInvalid(rowEntity, colDef);\n              },\n              /**\n               * @ngdoc function\n               * @name getErrorMessages\n               * @methodOf  ui.grid.validate.api:PublicApi\n               * @description returns an array of i18n-ed error messages.\n               * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n               * @param {object} colDef the column whose errors we are looking for\n               * @returns {array} An array of strings containing all the error messages for the cell\n               */\n              getErrorMessages: function (rowEntity, colDef) {\n                return grid.validate.getErrorMessages(rowEntity, colDef);\n              },\n              /**\n               * @ngdoc function\n               * @name getFormattedErrors\n               * @methodOf  ui.grid.validate.api:PublicApi\n               * @description returns the error i18n-ed and formatted in html to be shown inside the page.\n               * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n               * @param {object} colDef the column whose errors we are looking for\n               * @returns {object} An object that can be used in a template (like a cellTemplate) to display the\n               * message inside the page (i.e. inside a div)\n               */\n              getFormattedErrors: function (rowEntity, colDef) {\n                return grid.validate.getFormattedErrors(rowEntity, colDef);\n              },\n              /**\n               * @ngdoc function\n               * @name getTitleFormattedErrors\n               * @methodOf  ui.grid.validate.api:PublicApi\n               * @description returns the error i18n-ed and formatted in javaScript to be shown inside an html \n               * title attribute.\n               * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for\n               * @param {object} colDef the column whose errors we are looking for\n               * @returns {object} An object that can be used in a template (like a cellTemplate) to display the\n               * message inside an html title attribute\n               */\n              getTitleFormattedErrors: function (rowEntity, colDef) {\n                return grid.validate.getTitleFormattedErrors(rowEntity, colDef);\n              }\n            } \n          }\n        };\n        \n        grid.api.registerEventsFromObject(publicApi.events);\n        grid.api.registerMethodsFromObject(publicApi.methods);\n\n        if (grid.edit) {\n          grid.api.edit.on.afterCellEdit(scope, function(rowEntity, colDef, newValue, oldValue) {\n            grid.validate.runValidators(rowEntity, colDef, newValue, oldValue, grid);\n          });\n        }\n\n        service.createDefaultValidators();\n      }\n      \n    };\n  \n    return service;\n  }]);\n  \n  \n  /**\n   *  @ngdoc directive\n   *  @name ui.grid.validate.directive:uiGridValidate\n   *  @element div\n   *  @restrict A\n   *  @description Adds validating features to the ui-grid directive.\n   *  @example\n   <example module=\"app\">\n   <file name=\"app.js\">\n   var app = angular.module('app', ['ui.grid', 'ui.grid.edit', 'ui.grid.validate']);\n\n   app.controller('MainCtrl', ['$scope', function ($scope) {\n      $scope.data = [\n        { name: 'Bob', title: 'CEO' },\n            { name: 'Frank', title: 'Lowly Developer' }\n      ];\n\n      $scope.columnDefs = [\n        {name: 'name', enableCellEdit: true, validators: {minLength: 3, maxLength: 9}, cellTemplate: 'ui-grid/cellTitleValidator'},\n        {name: 'title', enableCellEdit: true, validators: {required: true}, cellTemplate: 'ui-grid/cellTitleValidator'}\n      ];\n    }]);\n   </file>\n   <file name=\"index.html\">\n   <div ng-controller=\"MainCtrl\">\n   <div ui-grid=\"{ data: data, columnDefs: columnDefs }\" ui-grid-edit ui-grid-validate></div>\n   </div>\n   </file>\n   </example>\n   */\n\n  module.directive('uiGridValidate', ['gridUtil', 'uiGridValidateService', function (gridUtil, uiGridValidateService) {\n    return {\n      priority: 0,\n      replace: true,\n      require: '^uiGrid',\n      scope: false,\n      compile: function () {\n        return {\n          pre: function ($scope, $elm, $attrs, uiGridCtrl) {\n            uiGridValidateService.initializeGrid($scope, uiGridCtrl.grid);\n          },\n          post: function ($scope, $elm, $attrs, uiGridCtrl) {\n          }\n        };\n      }\n    };\n  }]);\n})();\nangular.module('ui.grid').run(['$templateCache', function($templateCache) {\n  'use strict';\n\n  $templateCache.put('ui-grid/ui-grid-filter',\n    \"<div class=\\\"ui-grid-filter-container\\\" ng-repeat=\\\"colFilter in col.filters\\\" ng-class=\\\"{'ui-grid-filter-cancel-button-hidden' : colFilter.disableCancelFilterButton === true }\\\"><div ng-if=\\\"colFilter.type !== 'select'\\\"><input type=\\\"text\\\" class=\\\"ui-grid-filter-input ui-grid-filter-input-{{$index}}\\\" ng-model=\\\"colFilter.term\\\" ng-attr-placeholder=\\\"{{colFilter.placeholder || ''}}\\\" aria-label=\\\"{{colFilter.ariaLabel || aria.defaultFilterLabel}}\\\"><div role=\\\"button\\\" class=\\\"ui-grid-filter-button\\\" ng-click=\\\"removeFilter(colFilter, $index)\\\" ng-if=\\\"!colFilter.disableCancelFilterButton\\\" ng-disabled=\\\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\\\" ng-show=\\\"colFilter.term !== undefined && colFilter.term !== null && colFilter.term !== ''\\\"><i class=\\\"ui-grid-icon-cancel\\\" ui-grid-one-bind-aria-label=\\\"aria.removeFilter\\\">&nbsp;</i></div></div><div ng-if=\\\"colFilter.type === 'select'\\\"><select class=\\\"ui-grid-filter-select ui-grid-filter-input-{{$index}}\\\" ng-model=\\\"colFilter.term\\\" ng-attr-placeholder=\\\"{{colFilter.placeholder || aria.defaultFilterLabel}}\\\" aria-label=\\\"{{colFilter.ariaLabel || ''}}\\\" ng-options=\\\"option.value as option.label for option in colFilter.selectOptions\\\"><option value=\\\"\\\"></option></select><div role=\\\"button\\\" class=\\\"ui-grid-filter-button-select\\\" ng-click=\\\"removeFilter(colFilter, $index)\\\" ng-if=\\\"!colFilter.disableCancelFilterButton\\\" ng-disabled=\\\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\\\" ng-show=\\\"colFilter.term !== undefined && colFilter.term != null\\\"><i class=\\\"ui-grid-icon-cancel\\\" ui-grid-one-bind-aria-label=\\\"aria.removeFilter\\\">&nbsp;</i></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-footer',\n    \"<div class=\\\"ui-grid-footer-panel ui-grid-footer-aggregates-row\\\"><!-- tfooter --><div class=\\\"ui-grid-footer ui-grid-footer-viewport\\\"><div class=\\\"ui-grid-footer-canvas\\\"><div class=\\\"ui-grid-footer-cell-wrapper\\\" ng-style=\\\"colContainer.headerCellWrapperStyle()\\\"><div role=\\\"row\\\" class=\\\"ui-grid-footer-cell-row\\\"><div ui-grid-footer-cell role=\\\"gridcell\\\" ng-repeat=\\\"col in colContainer.renderedColumns track by col.uid\\\" col=\\\"col\\\" render-index=\\\"$index\\\" class=\\\"ui-grid-footer-cell ui-grid-clearfix\\\"></div></div></div></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-grid-footer',\n    \"<div class=\\\"ui-grid-footer-info ui-grid-grid-footer\\\"><span>{{'search.totalItems' | t}} {{grid.rows.length}}</span> <span ng-if=\\\"grid.renderContainers.body.visibleRowCache.length !== grid.rows.length\\\" class=\\\"ngLabel\\\">({{\\\"search.showingItems\\\" | t}} {{grid.renderContainers.body.visibleRowCache.length}})</span></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-group-panel',\n    \"<div class=\\\"ui-grid-group-panel\\\"><div ui-t=\\\"groupPanel.description\\\" class=\\\"description\\\" ng-show=\\\"groupings.length == 0\\\"></div><ul ng-show=\\\"groupings.length > 0\\\" class=\\\"ngGroupList\\\"><li class=\\\"ngGroupItem\\\" ng-repeat=\\\"group in configGroups\\\"><span class=\\\"ngGroupElement\\\"><span class=\\\"ngGroupName\\\">{{group.displayName}} <span ng-click=\\\"removeGroup($index)\\\" class=\\\"ngRemoveGroup\\\">x</span></span> <span ng-hide=\\\"$last\\\" class=\\\"ngGroupArrow\\\"></span></span></li></ul></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-header',\n    \"<div role=\\\"rowgroup\\\" class=\\\"ui-grid-header\\\"><!-- theader --><div class=\\\"ui-grid-top-panel\\\"><div class=\\\"ui-grid-header-viewport\\\"><div class=\\\"ui-grid-header-canvas\\\"><div class=\\\"ui-grid-header-cell-wrapper\\\" ng-style=\\\"colContainer.headerCellWrapperStyle()\\\"><div role=\\\"row\\\" class=\\\"ui-grid-header-cell-row\\\"><div class=\\\"ui-grid-header-cell ui-grid-clearfix\\\" ng-repeat=\\\"col in colContainer.renderedColumns track by col.uid\\\" ui-grid-header-cell col=\\\"col\\\" render-index=\\\"$index\\\"></div></div></div></div></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-menu-button',\n    \"<div class=\\\"ui-grid-menu-button\\\"><div role=\\\"button\\\" ui-grid-one-bind-id-grid=\\\"'grid-menu'\\\" class=\\\"ui-grid-icon-container\\\" ng-click=\\\"toggleMenu()\\\" aria-haspopup=\\\"true\\\"><i class=\\\"ui-grid-icon-menu\\\" ui-grid-one-bind-aria-label=\\\"i18n.aria.buttonLabel\\\">&nbsp;</i></div><div ui-grid-menu menu-items=\\\"menuItems\\\"></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-no-header',\n    \"<div class=\\\"ui-grid-top-panel\\\"></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid-row',\n    \"<div ng-repeat=\\\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\\\" ui-grid-one-bind-id-grid=\\\"rowRenderIndex + '-' + col.uid + '-cell'\\\" class=\\\"ui-grid-cell\\\" ng-class=\\\"{ 'ui-grid-row-header-cell': col.isRowHeader }\\\" role=\\\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\\\" ui-grid-cell></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/ui-grid',\n    \"<div ui-i18n=\\\"en\\\" class=\\\"ui-grid\\\"><!-- TODO (c0bra): add \\\"scoped\\\" attr here, eventually? --><style ui-grid-style>.grid{{ grid.id }} {\\n\" +\n    \"      /* Styles for the grid */\\n\" +\n    \"    }\\n\" +\n    \"\\n\" +\n    \"    .grid{{ grid.id }} .ui-grid-row, .grid{{ grid.id }} .ui-grid-cell, .grid{{ grid.id }} .ui-grid-cell .ui-grid-vertical-bar {\\n\" +\n    \"      height: {{ grid.options.rowHeight }}px;\\n\" +\n    \"    }\\n\" +\n    \"\\n\" +\n    \"    .grid{{ grid.id }} .ui-grid-row:last-child .ui-grid-cell {\\n\" +\n    \"      border-bottom-width: {{ ((grid.getTotalRowHeight() < grid.getViewportHeight()) && '1') || '0' }}px;\\n\" +\n    \"    }\\n\" +\n    \"\\n\" +\n    \"    {{ grid.verticalScrollbarStyles }}\\n\" +\n    \"    {{ grid.horizontalScrollbarStyles }}\\n\" +\n    \"\\n\" +\n    \"    /*\\n\" +\n    \"    .ui-grid[dir=rtl] .ui-grid-viewport {\\n\" +\n    \"      padding-left: {{ grid.verticalScrollbarWidth }}px;\\n\" +\n    \"    }\\n\" +\n    \"    */\\n\" +\n    \"\\n\" +\n    \"    {{ grid.customStyles }}</style><div class=\\\"ui-grid-contents-wrapper\\\"><div ui-grid-menu-button ng-if=\\\"grid.options.enableGridMenu\\\"></div><div ng-if=\\\"grid.hasLeftContainer()\\\" style=\\\"width: 0\\\" ui-grid-pinned-container=\\\"'left'\\\"></div><div ui-grid-render-container container-id=\\\"'body'\\\" col-container-name=\\\"'body'\\\" row-container-name=\\\"'body'\\\" bind-scroll-horizontal=\\\"true\\\" bind-scroll-vertical=\\\"true\\\" enable-horizontal-scrollbar=\\\"grid.options.enableHorizontalScrollbar\\\" enable-vertical-scrollbar=\\\"grid.options.enableVerticalScrollbar\\\"></div><div ng-if=\\\"grid.hasRightContainer()\\\" style=\\\"width: 0\\\" ui-grid-pinned-container=\\\"'right'\\\"></div><div ui-grid-grid-footer ng-if=\\\"grid.options.showGridFooter\\\"></div><div ui-grid-column-menu ng-if=\\\"grid.options.enableColumnMenus\\\"></div><div ng-transclude></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridCell',\n    \"<div class=\\\"ui-grid-cell-contents\\\" title=\\\"TOOLTIP\\\">{{COL_FIELD CUSTOM_FILTERS}}</div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridColumnMenu',\n    \"<div class=\\\"ui-grid-column-menu\\\"><div ui-grid-menu menu-items=\\\"menuItems\\\"><!-- <div class=\\\"ui-grid-column-menu\\\">\\n\" +\n    \"    <div class=\\\"inner\\\" ng-show=\\\"menuShown\\\">\\n\" +\n    \"      <ul>\\n\" +\n    \"        <div ng-show=\\\"grid.options.enableSorting\\\">\\n\" +\n    \"          <li ng-click=\\\"sortColumn($event, asc)\\\" ng-class=\\\"{ 'selected' : col.sort.direction == asc }\\\"><i class=\\\"ui-grid-icon-sort-alt-up\\\"></i> Sort Ascending</li>\\n\" +\n    \"          <li ng-click=\\\"sortColumn($event, desc)\\\" ng-class=\\\"{ 'selected' : col.sort.direction == desc }\\\"><i class=\\\"ui-grid-icon-sort-alt-down\\\"></i> Sort Descending</li>\\n\" +\n    \"          <li ng-show=\\\"col.sort.direction\\\" ng-click=\\\"unsortColumn()\\\"><i class=\\\"ui-grid-icon-cancel\\\"></i> Remove Sort</li>\\n\" +\n    \"        </div>\\n\" +\n    \"      </ul>\\n\" +\n    \"    </div>\\n\" +\n    \"  </div> --></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridFooterCell',\n    \"<div class=\\\"ui-grid-cell-contents\\\" col-index=\\\"renderIndex\\\"><div>{{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}</div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridHeaderCell',\n    \"<div role=\\\"columnheader\\\" ng-class=\\\"{ 'sortable': sortable }\\\" ui-grid-one-bind-aria-labelledby-grid=\\\"col.uid + '-header-text ' + col.uid + '-sortdir-text'\\\" aria-sort=\\\"{{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending' : (!col.sort.direction ? 'none' : 'other'))}}\\\"><div role=\\\"button\\\" tabindex=\\\"0\\\" class=\\\"ui-grid-cell-contents ui-grid-header-cell-primary-focus\\\" col-index=\\\"renderIndex\\\" title=\\\"TOOLTIP\\\"><span class=\\\"ui-grid-header-cell-label\\\" ui-grid-one-bind-id-grid=\\\"col.uid + '-header-text'\\\">{{ col.displayName CUSTOM_FILTERS }}</span> <span ui-grid-one-bind-id-grid=\\\"col.uid + '-sortdir-text'\\\" ui-grid-visible=\\\"col.sort.direction\\\" aria-label=\\\"{{getSortDirectionAriaLabel()}}\\\"><i ng-class=\\\"{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }\\\" title=\\\"{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + ( col.sort.priority + 1 )  : null}}\\\" aria-hidden=\\\"true\\\"></i> <sub ui-grid-visible=\\\"isSortPriorityVisible()\\\" class=\\\"ui-grid-sort-priority-number\\\">{{col.sort.priority + 1}}</sub></span></div><div role=\\\"button\\\" tabindex=\\\"0\\\" ui-grid-one-bind-id-grid=\\\"col.uid + '-menu-button'\\\" class=\\\"ui-grid-column-menu-button\\\" ng-if=\\\"grid.options.enableColumnMenus && !col.isRowHeader  && col.colDef.enableColumnMenu !== false\\\" ng-click=\\\"toggleMenu($event)\\\" ng-class=\\\"{'ui-grid-column-menu-button-last-col': isLastCol}\\\" ui-grid-one-bind-aria-label=\\\"i18n.headerCell.aria.columnMenuButtonLabel\\\" aria-haspopup=\\\"true\\\"><i class=\\\"ui-grid-icon-angle-down\\\" aria-hidden=\\\"true\\\">&nbsp;</i></div><div ui-grid-filter></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridMenu',\n    \"<div class=\\\"ui-grid-menu\\\" ng-if=\\\"shown\\\"><style ui-grid-style>{{dynamicStyles}}</style><div class=\\\"ui-grid-menu-mid\\\" ng-show=\\\"shownMid\\\"><div class=\\\"ui-grid-menu-inner\\\"><ul role=\\\"menu\\\" class=\\\"ui-grid-menu-items\\\"><li ng-repeat=\\\"item in menuItems\\\" role=\\\"menuitem\\\" ui-grid-menu-item ui-grid-one-bind-id=\\\"'menuitem-'+$index\\\" action=\\\"item.action\\\" name=\\\"item.title\\\" active=\\\"item.active\\\" icon=\\\"item.icon\\\" shown=\\\"item.shown\\\" context=\\\"item.context\\\" template-url=\\\"item.templateUrl\\\" leave-open=\\\"item.leaveOpen\\\" screen-reader-only=\\\"item.screenReaderOnly\\\"></li></ul></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridMenuItem',\n    \"<button type=\\\"button\\\" class=\\\"ui-grid-menu-item\\\" ng-click=\\\"itemAction($event, title)\\\" ng-show=\\\"itemShown()\\\" ng-class=\\\"{ 'ui-grid-menu-item-active': active(), 'ui-grid-sr-only': (!focus && screenReaderOnly) }\\\" aria-pressed=\\\"{{active()}}\\\" tabindex=\\\"0\\\" ng-focus=\\\"focus=true\\\" ng-blur=\\\"focus=false\\\"><i ng-class=\\\"icon\\\" aria-hidden=\\\"true\\\">&nbsp;</i> {{ name }}</button>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridRenderContainer',\n    \"<div role=\\\"grid\\\" ui-grid-one-bind-id-grid=\\\"'grid-container'\\\" class=\\\"ui-grid-render-container\\\" ng-style=\\\"{ 'margin-left': colContainer.getMargin('left') + 'px', 'margin-right': colContainer.getMargin('right') + 'px' }\\\"><!-- All of these dom elements are replaced in place --><div ui-grid-header></div><div ui-grid-viewport></div><div ng-if=\\\"colContainer.needsHScrollbarPlaceholder()\\\" class=\\\"ui-grid-scrollbar-placeholder\\\" ng-style=\\\"{height:colContainer.grid.scrollbarHeight + 'px'}\\\"></div><ui-grid-footer ng-if=\\\"grid.options.showColumnFooter\\\"></ui-grid-footer></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/uiGridViewport',\n    \"<div role=\\\"rowgroup\\\" class=\\\"ui-grid-viewport\\\" ng-style=\\\"colContainer.getViewportStyle()\\\"><!-- tbody --><div class=\\\"ui-grid-canvas\\\"><div ng-repeat=\\\"(rowRenderIndex, row) in rowContainer.renderedRows track by $index\\\" class=\\\"ui-grid-row\\\" ng-style=\\\"Viewport.rowStyle(rowRenderIndex)\\\"><div role=\\\"row\\\" ui-grid-row=\\\"row\\\" row-render-index=\\\"rowRenderIndex\\\"></div></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/cellEditor',\n    \"<div><form name=\\\"inputForm\\\"><input type=\\\"INPUT_TYPE\\\" ng-class=\\\"'colt' + col.uid\\\" ui-grid-editor ng-model=\\\"MODEL_COL_FIELD\\\"></form></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/dropdownEditor',\n    \"<div><form name=\\\"inputForm\\\"><select ng-class=\\\"'colt' + col.uid\\\" ui-grid-edit-dropdown ng-model=\\\"MODEL_COL_FIELD\\\" ng-options=\\\"field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray\\\"></select></form></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/fileChooserEditor',\n    \"<div><form name=\\\"inputForm\\\"><input ng-class=\\\"'colt' + col.uid\\\" ui-grid-edit-file-chooser type=\\\"file\\\" id=\\\"files\\\" name=\\\"files[]\\\" ng-model=\\\"MODEL_COL_FIELD\\\"></form></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/expandableRow',\n    \"<div ui-grid-expandable-row ng-if=\\\"expandableRow.shouldRenderExpand()\\\" class=\\\"expandableRow\\\" style=\\\"float:left; margin-top: 1px; margin-bottom: 1px\\\" ng-style=\\\"{width: (grid.renderContainers.body.getCanvasWidth()) + 'px', height: row.expandedRowHeight + 'px'}\\\"></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/expandableRowHeader',\n    \"<div class=\\\"ui-grid-row-header-cell ui-grid-expandable-buttons-cell\\\"><div class=\\\"ui-grid-cell-contents\\\"><i ng-class=\\\"{ 'ui-grid-icon-plus-squared' : !row.isExpanded, 'ui-grid-icon-minus-squared' : row.isExpanded }\\\" ng-click=\\\"grid.api.expandable.toggleRowExpansion(row.entity)\\\"></i></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/expandableScrollFiller',\n    \"<div ng-if=\\\"expandableRow.shouldRenderFiller()\\\" ng-class=\\\"{scrollFiller:true, scrollFillerClass:(colContainer.name === 'body')}\\\" ng-style=\\\"{ width: (grid.getViewportWidth()) + 'px', height: row.expandedRowHeight + 2 + 'px', 'margin-left': grid.options.rowHeader.rowHeaderWidth + 'px' }\\\"><i class=\\\"ui-grid-icon-spin5 ui-grid-animate-spin\\\" ng-style=\\\"{'margin-top': ( row.expandedRowHeight/2 - 5) + 'px', 'margin-left' : ((grid.getViewportWidth() - grid.options.rowHeader.rowHeaderWidth)/2 - 5) + 'px'}\\\"></i></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/expandableTopRowHeader',\n    \"<div class=\\\"ui-grid-row-header-cell ui-grid-expandable-buttons-cell\\\"><div class=\\\"ui-grid-cell-contents\\\"><i ng-class=\\\"{ 'ui-grid-icon-plus-squared' : !grid.expandable.expandedAll, 'ui-grid-icon-minus-squared' : grid.expandable.expandedAll }\\\" ng-click=\\\"grid.api.expandable.toggleAllRows()\\\"></i></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/csvLink',\n    \"<span class=\\\"ui-grid-exporter-csv-link-span\\\"><a href=\\\"data:text/csv;charset=UTF-8,CSV_CONTENT\\\" download=\\\"FILE_NAME\\\">LINK_LABEL</a></span>\"\n  );\n\n\n  $templateCache.put('ui-grid/importerMenuItem',\n    \"<li class=\\\"ui-grid-menu-item\\\"><form><input class=\\\"ui-grid-importer-file-chooser\\\" type=\\\"file\\\" id=\\\"files\\\" name=\\\"files[]\\\"></form></li>\"\n  );\n\n\n  $templateCache.put('ui-grid/importerMenuItemContainer',\n    \"<div ui-grid-importer-menu-item></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/pagination',\n    \"<div role=\\\"contentinfo\\\" class=\\\"ui-grid-pager-panel\\\" ui-grid-pager ng-show=\\\"grid.options.enablePaginationControls\\\"><div role=\\\"navigation\\\" class=\\\"ui-grid-pager-container\\\"><div role=\\\"menubar\\\" class=\\\"ui-grid-pager-control\\\"><button type=\\\"button\\\" role=\\\"menuitem\\\" class=\\\"ui-grid-pager-first\\\" ui-grid-one-bind-title=\\\"aria.pageToFirst\\\" ui-grid-one-bind-aria-label=\\\"aria.pageToFirst\\\" ng-click=\\\"pageFirstPageClick()\\\" ng-disabled=\\\"cantPageBackward()\\\"><div ng-class=\\\"grid.isRTL() ? 'last-triangle' : 'first-triangle'\\\"><div ng-class=\\\"grid.isRTL() ? 'last-bar-rtl' : 'first-bar'\\\"></div></div></button> <button type=\\\"button\\\" role=\\\"menuitem\\\" class=\\\"ui-grid-pager-previous\\\" ui-grid-one-bind-title=\\\"aria.pageBack\\\" ui-grid-one-bind-aria-label=\\\"aria.pageBack\\\" ng-click=\\\"pagePreviousPageClick()\\\" ng-disabled=\\\"cantPageBackward()\\\"><div ng-class=\\\"grid.isRTL() ? 'last-triangle prev-triangle' : 'first-triangle prev-triangle'\\\"></div></button> <input type=\\\"number\\\" ui-grid-one-bind-title=\\\"aria.pageSelected\\\" ui-grid-one-bind-aria-label=\\\"aria.pageSelected\\\" class=\\\"ui-grid-pager-control-input\\\" ng-model=\\\"grid.options.paginationCurrentPage\\\" min=\\\"1\\\" max=\\\"{{ paginationApi.getTotalPages() }}\\\" required> <span class=\\\"ui-grid-pager-max-pages-number\\\" ng-show=\\\"paginationApi.getTotalPages() > 0\\\"><abbr ui-grid-one-bind-title=\\\"paginationOf\\\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\\\"button\\\" role=\\\"menuitem\\\" class=\\\"ui-grid-pager-next\\\" ui-grid-one-bind-title=\\\"aria.pageForward\\\" ui-grid-one-bind-aria-label=\\\"aria.pageForward\\\" ng-click=\\\"pageNextPageClick()\\\" ng-disabled=\\\"cantPageForward()\\\"><div ng-class=\\\"grid.isRTL() ? 'first-triangle next-triangle' : 'last-triangle next-triangle'\\\"></div></button> <button type=\\\"button\\\" role=\\\"menuitem\\\" class=\\\"ui-grid-pager-last\\\" ui-grid-one-bind-title=\\\"aria.pageToLast\\\" ui-grid-one-bind-aria-label=\\\"aria.pageToLast\\\" ng-click=\\\"pageLastPageClick()\\\" ng-disabled=\\\"cantPageToLast()\\\"><div ng-class=\\\"grid.isRTL() ? 'first-triangle' : 'last-triangle'\\\"><div ng-class=\\\"grid.isRTL() ? 'first-bar-rtl' : 'last-bar'\\\"></div></div></button></div><div class=\\\"ui-grid-pager-row-count-picker\\\" ng-if=\\\"grid.options.paginationPageSizes.length > 1\\\"><select ui-grid-one-bind-aria-labelledby-grid=\\\"'items-per-page-label'\\\" ng-model=\\\"grid.options.paginationPageSize\\\" ng-options=\\\"o as o for o in grid.options.paginationPageSizes\\\"></select><span ui-grid-one-bind-id-grid=\\\"'items-per-page-label'\\\" class=\\\"ui-grid-pager-row-count-label\\\">&nbsp;{{sizesLabel}}</span></div><span ng-if=\\\"grid.options.paginationPageSizes.length <= 1\\\" class=\\\"ui-grid-pager-row-count-label\\\">{{grid.options.paginationPageSize}}&nbsp;{{sizesLabel}}</span></div><div class=\\\"ui-grid-pager-count-container\\\"><div class=\\\"ui-grid-pager-count\\\"><span ng-show=\\\"grid.options.totalItems > 0\\\">{{showingLow}} <abbr ui-grid-one-bind-title=\\\"paginationThrough\\\">-</abbr> {{showingHigh}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/columnResizer',\n    \"<div ui-grid-column-resizer ng-if=\\\"grid.options.enableColumnResizing\\\" class=\\\"ui-grid-column-resizer\\\" col=\\\"col\\\" position=\\\"right\\\" render-index=\\\"renderIndex\\\" unselectable=\\\"on\\\"></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/gridFooterSelectedItems',\n    \"<span ng-if=\\\"grid.selection.selectedCount !== 0 && grid.options.enableFooterTotalSelected\\\">({{\\\"search.selectedItems\\\" | t}} {{grid.selection.selectedCount}})</span>\"\n  );\n\n\n  $templateCache.put('ui-grid/selectionHeaderCell',\n    \"<div><!-- <div class=\\\"ui-grid-vertical-bar\\\">&nbsp;</div> --><div class=\\\"ui-grid-cell-contents\\\" col-index=\\\"renderIndex\\\"><ui-grid-selection-select-all-buttons ng-if=\\\"grid.options.enableSelectAll\\\"></ui-grid-selection-select-all-buttons></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/selectionRowHeader',\n    \"<div class=\\\"ui-grid-disable-selection\\\"><div class=\\\"ui-grid-cell-contents\\\"><ui-grid-selection-row-header-buttons></ui-grid-selection-row-header-buttons></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/selectionRowHeaderButtons',\n    \"<div class=\\\"ui-grid-selection-row-header-buttons ui-grid-icon-ok\\\" ng-class=\\\"{'ui-grid-row-selected': row.isSelected}\\\" ng-click=\\\"selectButtonClick(row, $event)\\\">&nbsp;</div>\"\n  );\n\n\n  $templateCache.put('ui-grid/selectionSelectAllButtons',\n    \"<div class=\\\"ui-grid-selection-row-header-buttons ui-grid-icon-ok\\\" ng-class=\\\"{'ui-grid-all-selected': grid.selection.selectAll}\\\" ng-click=\\\"headerButtonClick($event)\\\"></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/treeBaseExpandAllButtons',\n    \"<div class=\\\"ui-grid-tree-base-row-header-buttons\\\" ng-class=\\\"{'ui-grid-icon-minus-squared': grid.treeBase.numberLevels > 0 && grid.treeBase.expandAll, 'ui-grid-icon-plus-squared': grid.treeBase.numberLevels > 0 && !grid.treeBase.expandAll}\\\" ng-click=\\\"headerButtonClick($event)\\\"></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/treeBaseHeaderCell',\n    \"<div><div class=\\\"ui-grid-cell-contents\\\" col-index=\\\"renderIndex\\\"><ui-grid-tree-base-expand-all-buttons ng-if=\\\"grid.options.enableExpandAll\\\"></ui-grid-tree-base-expand-all-buttons></div></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/treeBaseRowHeader',\n    \"<div class=\\\"ui-grid-cell-contents\\\"><ui-grid-tree-base-row-header-buttons></ui-grid-tree-base-row-header-buttons></div>\"\n  );\n\n\n  $templateCache.put('ui-grid/treeBaseRowHeaderButtons',\n    \"<div class=\\\"ui-grid-tree-base-row-header-buttons\\\" ng-class=\\\"{'ui-grid-tree-base-header': row.treeLevel > -1 }\\\" ng-click=\\\"treeButtonClick(row, $event)\\\"><i ng-class=\\\"{'ui-grid-icon-minus-squared': ( ( grid.options.showTreeExpandNoChildren && row.treeLevel > -1 ) || ( row.treeNode.children && row.treeNode.children.length > 0 ) ) && row.treeNode.state === 'expanded', 'ui-grid-icon-plus-squared': ( ( grid.options.showTreeExpandNoChildren && row.treeLevel > -1 ) || ( row.treeNode.children && row.treeNode.children.length > 0 ) ) && row.treeNode.state === 'collapsed'}\\\" ng-style=\\\"{'padding-left': grid.options.treeIndent * row.treeLevel + 'px'}\\\"></i> &nbsp;</div>\"\n  );\n\n\n  $templateCache.put('ui-grid/cellTitleValidator',\n    \"<div class=\\\"ui-grid-cell-contents\\\" ng-class=\\\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\\\" title=\\\"{{grid.validate.getTitleFormattedErrors(row.entity,col.colDef)}}\\\">{{COL_FIELD CUSTOM_FILTERS}}</div>\"\n  );\n\n\n  $templateCache.put('ui-grid/cellTooltipValidator',\n    \"<div class=\\\"ui-grid-cell-contents\\\" ng-class=\\\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\\\" tooltip-html-unsafe=\\\"{{grid.validate.getFormattedErrors(row.entity,col.colDef)}}\\\" tooltip-enable=\\\"grid.validate.isInvalid(row.entity,col.colDef)\\\" tooltip-append-to-body=\\\"true\\\" tooltip-placement=\\\"top\\\" title=\\\"TOOLTIP\\\">{{COL_FIELD CUSTOM_FILTERS}}</div>\"\n  );\n\n}]);\n"
  },
  {
    "path": "html/lib/angular-ui-grid/validate/less/validate.less",
    "content": "@import '../../../less/variables';\n\ndiv.ui-grid-cell-contents.invalid {\n  border: @invalidValueBorder;\n}"
  },
  {
    "path": "html/lib/angular-ui-grid/variables.less",
    "content": "\n/* This file contains variable declarations (do not remove this line) */\n\n/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n\n@bootstrapDirectory: \"../../../node_modules/bootstrap\";\n\n/**\n* @section Grid styles\n*/\n@gridBorderWidth: 1px;\n@gridBorderRadius: 0px;\n@borderColor: #d4d4d4;\n\n\n/**\n* @section Header styles\n*/\n\n/** @description Colors for header gradient */\n@headerBackgroundColor: #f3f3f3;\n@headerGradientStart: #eee;\n@headerGradientStop: #fff;\n@headerVerticalBarColor: @borderColor;\n\n/**\n* @section Grid body styles\n*/\n\n/** @description Colors used for row alternation */\n@verticalBarColor: @borderColor;\n@rowColorEven: #f3f3f3;\n@rowColorOdd: #fdfdfd;\n\n// TODO: colors for buttons\n\n/**\n* @section Sort arrow colors\n*/\n\n@sortArrowBackgroundColor: #aaaaaa;\n@sortArrowBorderColor: #777777;\n\n\n// TODO: color for menu background\n@rowHeaderCell: #F0F0EE;\n@rowSelected: #C9DDE1;\n@rowSavingForeground: #848484;\n@rowErrorForeground: #FF0000;\n@rowDirtyForeground: #610B38;\n\n// TODO: color for cell selections\n@focusedCell: #b3c4c7;\n\n// Color to use for enabled or selected settings/items/cells, etc. Should probably override the one above\n@selectedColor: #cecece;\n\n/**\n* @section Scrollbar styles\n*/\n@scrollbarBackground: darken(@rowColorEven, 15%);\n@scrollbarBackgroundHover: darken(@scrollbarBackground, 15%);\n@scrollbarBackgroundScrolling: darken(@scrollbarBackgroundHover, 15%);\n@scrollbarWidth: 10px;\n@scrollbarBorderRadius: 2px;\n@scrollbarShadow: 0 0 0px #fff;\n@scrollbarBorder: 1px solid darken(@scrollbarBackground, 15%);\n@scrollbarBorderScrolling: 1px solid darken(@scrollbarBackgroundScrolling, 15%);\n\n//Border to be applied to editors when the input value or invalid\n@invalidValueBorder: 1px solid rgb(252, 143, 143);\n@validValueBorder: 1px solid @borderColor;\n\n//Pagination controls\n@paginationButtonColor: @headerGradientStart;\n@paginationButtonBackgroundColor: @headerBackgroundColor;\n@paginationButtonBorderColor: #ccc;\n\n\n/**\n* @section font library path\n*/\n@font-path: '';\n\n/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/\n"
  },
  {
    "path": "html/lib/bootstrap/bootstrap-theme.css",
    "content": "/*!\n * Bootstrap v3.3.6 (http://getbootstrap.com)\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n */\n.btn-default,\n.btn-primary,\n.btn-success,\n.btn-info,\n.btn-warning,\n.btn-danger {\n  text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);\n}\n.btn-default:active,\n.btn-primary:active,\n.btn-success:active,\n.btn-info:active,\n.btn-warning:active,\n.btn-danger:active,\n.btn-default.active,\n.btn-primary.active,\n.btn-success.active,\n.btn-info.active,\n.btn-warning.active,\n.btn-danger.active {\n  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n}\n.btn-default.disabled,\n.btn-primary.disabled,\n.btn-success.disabled,\n.btn-info.disabled,\n.btn-warning.disabled,\n.btn-danger.disabled,\n.btn-default[disabled],\n.btn-primary[disabled],\n.btn-success[disabled],\n.btn-info[disabled],\n.btn-warning[disabled],\n.btn-danger[disabled],\nfieldset[disabled] .btn-default,\nfieldset[disabled] .btn-primary,\nfieldset[disabled] .btn-success,\nfieldset[disabled] .btn-info,\nfieldset[disabled] .btn-warning,\nfieldset[disabled] .btn-danger {\n  -webkit-box-shadow: none;\n          box-shadow: none;\n}\n.btn-default .badge,\n.btn-primary .badge,\n.btn-success .badge,\n.btn-info .badge,\n.btn-warning .badge,\n.btn-danger .badge {\n  text-shadow: none;\n}\n.btn:active,\n.btn.active {\n  background-image: none;\n}\n.btn-default {\n  text-shadow: 0 1px 0 #fff;\n  background-image: -webkit-linear-gradient(top, #fff 0%, #e0e0e0 100%);\n  background-image:      -o-linear-gradient(top, #fff 0%, #e0e0e0 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#e0e0e0));\n  background-image:         linear-gradient(to bottom, #fff 0%, #e0e0e0 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #dbdbdb;\n  border-color: #ccc;\n}\n.btn-default:hover,\n.btn-default:focus {\n  background-color: #e0e0e0;\n  background-position: 0 -15px;\n}\n.btn-default:active,\n.btn-default.active {\n  background-color: #e0e0e0;\n  border-color: #dbdbdb;\n}\n.btn-default.disabled,\n.btn-default[disabled],\nfieldset[disabled] .btn-default,\n.btn-default.disabled:hover,\n.btn-default[disabled]:hover,\nfieldset[disabled] .btn-default:hover,\n.btn-default.disabled:focus,\n.btn-default[disabled]:focus,\nfieldset[disabled] .btn-default:focus,\n.btn-default.disabled.focus,\n.btn-default[disabled].focus,\nfieldset[disabled] .btn-default.focus,\n.btn-default.disabled:active,\n.btn-default[disabled]:active,\nfieldset[disabled] .btn-default:active,\n.btn-default.disabled.active,\n.btn-default[disabled].active,\nfieldset[disabled] .btn-default.active {\n  background-color: #e0e0e0;\n  background-image: none;\n}\n.btn-primary {\n  background-image: -webkit-linear-gradient(top, #337ab7 0%, #265a88 100%);\n  background-image:      -o-linear-gradient(top, #337ab7 0%, #265a88 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#265a88));\n  background-image:         linear-gradient(to bottom, #337ab7 0%, #265a88 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #245580;\n}\n.btn-primary:hover,\n.btn-primary:focus {\n  background-color: #265a88;\n  background-position: 0 -15px;\n}\n.btn-primary:active,\n.btn-primary.active {\n  background-color: #265a88;\n  border-color: #245580;\n}\n.btn-primary.disabled,\n.btn-primary[disabled],\nfieldset[disabled] .btn-primary,\n.btn-primary.disabled:hover,\n.btn-primary[disabled]:hover,\nfieldset[disabled] .btn-primary:hover,\n.btn-primary.disabled:focus,\n.btn-primary[disabled]:focus,\nfieldset[disabled] .btn-primary:focus,\n.btn-primary.disabled.focus,\n.btn-primary[disabled].focus,\nfieldset[disabled] .btn-primary.focus,\n.btn-primary.disabled:active,\n.btn-primary[disabled]:active,\nfieldset[disabled] .btn-primary:active,\n.btn-primary.disabled.active,\n.btn-primary[disabled].active,\nfieldset[disabled] .btn-primary.active {\n  background-color: #265a88;\n  background-image: none;\n}\n.btn-success {\n  background-image: -webkit-linear-gradient(top, #5cb85c 0%, #419641 100%);\n  background-image:      -o-linear-gradient(top, #5cb85c 0%, #419641 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#419641));\n  background-image:         linear-gradient(to bottom, #5cb85c 0%, #419641 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #3e8f3e;\n}\n.btn-success:hover,\n.btn-success:focus {\n  background-color: #419641;\n  background-position: 0 -15px;\n}\n.btn-success:active,\n.btn-success.active {\n  background-color: #419641;\n  border-color: #3e8f3e;\n}\n.btn-success.disabled,\n.btn-success[disabled],\nfieldset[disabled] .btn-success,\n.btn-success.disabled:hover,\n.btn-success[disabled]:hover,\nfieldset[disabled] .btn-success:hover,\n.btn-success.disabled:focus,\n.btn-success[disabled]:focus,\nfieldset[disabled] .btn-success:focus,\n.btn-success.disabled.focus,\n.btn-success[disabled].focus,\nfieldset[disabled] .btn-success.focus,\n.btn-success.disabled:active,\n.btn-success[disabled]:active,\nfieldset[disabled] .btn-success:active,\n.btn-success.disabled.active,\n.btn-success[disabled].active,\nfieldset[disabled] .btn-success.active {\n  background-color: #419641;\n  background-image: none;\n}\n.btn-info {\n  background-image: -webkit-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);\n  background-image:      -o-linear-gradient(top, #5bc0de 0%, #2aabd2 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#2aabd2));\n  background-image:         linear-gradient(to bottom, #5bc0de 0%, #2aabd2 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #28a4c9;\n}\n.btn-info:hover,\n.btn-info:focus {\n  background-color: #2aabd2;\n  background-position: 0 -15px;\n}\n.btn-info:active,\n.btn-info.active {\n  background-color: #2aabd2;\n  border-color: #28a4c9;\n}\n.btn-info.disabled,\n.btn-info[disabled],\nfieldset[disabled] .btn-info,\n.btn-info.disabled:hover,\n.btn-info[disabled]:hover,\nfieldset[disabled] .btn-info:hover,\n.btn-info.disabled:focus,\n.btn-info[disabled]:focus,\nfieldset[disabled] .btn-info:focus,\n.btn-info.disabled.focus,\n.btn-info[disabled].focus,\nfieldset[disabled] .btn-info.focus,\n.btn-info.disabled:active,\n.btn-info[disabled]:active,\nfieldset[disabled] .btn-info:active,\n.btn-info.disabled.active,\n.btn-info[disabled].active,\nfieldset[disabled] .btn-info.active {\n  background-color: #2aabd2;\n  background-image: none;\n}\n.btn-warning {\n  background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);\n  background-image:      -o-linear-gradient(top, #f0ad4e 0%, #eb9316 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#eb9316));\n  background-image:         linear-gradient(to bottom, #f0ad4e 0%, #eb9316 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #e38d13;\n}\n.btn-warning:hover,\n.btn-warning:focus {\n  background-color: #eb9316;\n  background-position: 0 -15px;\n}\n.btn-warning:active,\n.btn-warning.active {\n  background-color: #eb9316;\n  border-color: #e38d13;\n}\n.btn-warning.disabled,\n.btn-warning[disabled],\nfieldset[disabled] .btn-warning,\n.btn-warning.disabled:hover,\n.btn-warning[disabled]:hover,\nfieldset[disabled] .btn-warning:hover,\n.btn-warning.disabled:focus,\n.btn-warning[disabled]:focus,\nfieldset[disabled] .btn-warning:focus,\n.btn-warning.disabled.focus,\n.btn-warning[disabled].focus,\nfieldset[disabled] .btn-warning.focus,\n.btn-warning.disabled:active,\n.btn-warning[disabled]:active,\nfieldset[disabled] .btn-warning:active,\n.btn-warning.disabled.active,\n.btn-warning[disabled].active,\nfieldset[disabled] .btn-warning.active {\n  background-color: #eb9316;\n  background-image: none;\n}\n.btn-danger {\n  background-image: -webkit-linear-gradient(top, #d9534f 0%, #c12e2a 100%);\n  background-image:      -o-linear-gradient(top, #d9534f 0%, #c12e2a 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c12e2a));\n  background-image:         linear-gradient(to bottom, #d9534f 0%, #c12e2a 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-color: #b92c28;\n}\n.btn-danger:hover,\n.btn-danger:focus {\n  background-color: #c12e2a;\n  background-position: 0 -15px;\n}\n.btn-danger:active,\n.btn-danger.active {\n  background-color: #c12e2a;\n  border-color: #b92c28;\n}\n.btn-danger.disabled,\n.btn-danger[disabled],\nfieldset[disabled] .btn-danger,\n.btn-danger.disabled:hover,\n.btn-danger[disabled]:hover,\nfieldset[disabled] .btn-danger:hover,\n.btn-danger.disabled:focus,\n.btn-danger[disabled]:focus,\nfieldset[disabled] .btn-danger:focus,\n.btn-danger.disabled.focus,\n.btn-danger[disabled].focus,\nfieldset[disabled] .btn-danger.focus,\n.btn-danger.disabled:active,\n.btn-danger[disabled]:active,\nfieldset[disabled] .btn-danger:active,\n.btn-danger.disabled.active,\n.btn-danger[disabled].active,\nfieldset[disabled] .btn-danger.active {\n  background-color: #c12e2a;\n  background-image: none;\n}\n.thumbnail,\n.img-thumbnail {\n  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);\n          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);\n}\n.dropdown-menu > li > a:hover,\n.dropdown-menu > li > a:focus {\n  background-color: #e8e8e8;\n  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);\n  background-image:      -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));\n  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);\n  background-repeat: repeat-x;\n}\n.dropdown-menu > .active > a,\n.dropdown-menu > .active > a:hover,\n.dropdown-menu > .active > a:focus {\n  background-color: #2e6da4;\n  background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n  background-image:      -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));\n  background-image:         linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);\n  background-repeat: repeat-x;\n}\n.navbar-default {\n  background-image: -webkit-linear-gradient(top, #fff 0%, #f8f8f8 100%);\n  background-image:      -o-linear-gradient(top, #fff 0%, #f8f8f8 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f8f8f8));\n  background-image:         linear-gradient(to bottom, #fff 0%, #f8f8f8 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 5px rgba(0, 0, 0, .075);\n}\n.navbar-default .navbar-nav > .open > a,\n.navbar-default .navbar-nav > .active > a {\n  background-image: -webkit-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);\n  background-image:      -o-linear-gradient(top, #dbdbdb 0%, #e2e2e2 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#dbdbdb), to(#e2e2e2));\n  background-image:         linear-gradient(to bottom, #dbdbdb 0%, #e2e2e2 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);\n  background-repeat: repeat-x;\n  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .075);\n}\n.navbar-brand,\n.navbar-nav > li > a {\n  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);\n}\n.navbar-inverse {\n  background-image: -webkit-linear-gradient(top, #3c3c3c 0%, #222 100%);\n  background-image:      -o-linear-gradient(top, #3c3c3c 0%, #222 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#3c3c3c), to(#222));\n  background-image:         linear-gradient(to bottom, #3c3c3c 0%, #222 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n  background-repeat: repeat-x;\n  border-radius: 4px;\n}\n.navbar-inverse .navbar-nav > .open > a,\n.navbar-inverse .navbar-nav > .active > a {\n  background-image: -webkit-linear-gradient(top, #080808 0%, #0f0f0f 100%);\n  background-image:      -o-linear-gradient(top, #080808 0%, #0f0f0f 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#080808), to(#0f0f0f));\n  background-image:         linear-gradient(to bottom, #080808 0%, #0f0f0f 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);\n  background-repeat: repeat-x;\n  -webkit-box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);\n          box-shadow: inset 0 3px 9px rgba(0, 0, 0, .25);\n}\n.navbar-inverse .navbar-brand,\n.navbar-inverse .navbar-nav > li > a {\n  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);\n}\n.navbar-static-top,\n.navbar-fixed-top,\n.navbar-fixed-bottom {\n  border-radius: 0;\n}\n@media (max-width: 767px) {\n  .navbar .navbar-nav .open .dropdown-menu > .active > a,\n  .navbar .navbar-nav .open .dropdown-menu > .active > a:hover,\n  .navbar .navbar-nav .open .dropdown-menu > .active > a:focus {\n    color: #fff;\n    background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n    background-image:      -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n    background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));\n    background-image:         linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);\n    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);\n    background-repeat: repeat-x;\n  }\n}\n.alert {\n  text-shadow: 0 1px 0 rgba(255, 255, 255, .2);\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);\n          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .05);\n}\n.alert-success {\n  background-image: -webkit-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);\n  background-image:      -o-linear-gradient(top, #dff0d8 0%, #c8e5bc 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#c8e5bc));\n  background-image:         linear-gradient(to bottom, #dff0d8 0%, #c8e5bc 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #b2dba1;\n}\n.alert-info {\n  background-image: -webkit-linear-gradient(top, #d9edf7 0%, #b9def0 100%);\n  background-image:      -o-linear-gradient(top, #d9edf7 0%, #b9def0 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#b9def0));\n  background-image:         linear-gradient(to bottom, #d9edf7 0%, #b9def0 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #9acfea;\n}\n.alert-warning {\n  background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);\n  background-image:      -o-linear-gradient(top, #fcf8e3 0%, #f8efc0 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#f8efc0));\n  background-image:         linear-gradient(to bottom, #fcf8e3 0%, #f8efc0 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #f5e79e;\n}\n.alert-danger {\n  background-image: -webkit-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);\n  background-image:      -o-linear-gradient(top, #f2dede 0%, #e7c3c3 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#e7c3c3));\n  background-image:         linear-gradient(to bottom, #f2dede 0%, #e7c3c3 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #dca7a7;\n}\n.progress {\n  background-image: -webkit-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);\n  background-image:      -o-linear-gradient(top, #ebebeb 0%, #f5f5f5 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#f5f5f5));\n  background-image:         linear-gradient(to bottom, #ebebeb 0%, #f5f5f5 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar {\n  background-image: -webkit-linear-gradient(top, #337ab7 0%, #286090 100%);\n  background-image:      -o-linear-gradient(top, #337ab7 0%, #286090 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#286090));\n  background-image:         linear-gradient(to bottom, #337ab7 0%, #286090 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar-success {\n  background-image: -webkit-linear-gradient(top, #5cb85c 0%, #449d44 100%);\n  background-image:      -o-linear-gradient(top, #5cb85c 0%, #449d44 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#5cb85c), to(#449d44));\n  background-image:         linear-gradient(to bottom, #5cb85c 0%, #449d44 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar-info {\n  background-image: -webkit-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);\n  background-image:      -o-linear-gradient(top, #5bc0de 0%, #31b0d5 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#5bc0de), to(#31b0d5));\n  background-image:         linear-gradient(to bottom, #5bc0de 0%, #31b0d5 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar-warning {\n  background-image: -webkit-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);\n  background-image:      -o-linear-gradient(top, #f0ad4e 0%, #ec971f 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f0ad4e), to(#ec971f));\n  background-image:         linear-gradient(to bottom, #f0ad4e 0%, #ec971f 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar-danger {\n  background-image: -webkit-linear-gradient(top, #d9534f 0%, #c9302c 100%);\n  background-image:      -o-linear-gradient(top, #d9534f 0%, #c9302c 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9534f), to(#c9302c));\n  background-image:         linear-gradient(to bottom, #d9534f 0%, #c9302c 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);\n  background-repeat: repeat-x;\n}\n.progress-bar-striped {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n}\n.list-group {\n  border-radius: 4px;\n  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .075);\n          box-shadow: 0 1px 2px rgba(0, 0, 0, .075);\n}\n.list-group-item.active,\n.list-group-item.active:hover,\n.list-group-item.active:focus {\n  text-shadow: 0 -1px 0 #286090;\n  background-image: -webkit-linear-gradient(top, #337ab7 0%, #2b669a 100%);\n  background-image:      -o-linear-gradient(top, #337ab7 0%, #2b669a 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2b669a));\n  background-image:         linear-gradient(to bottom, #337ab7 0%, #2b669a 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #2b669a;\n}\n.list-group-item.active .badge,\n.list-group-item.active:hover .badge,\n.list-group-item.active:focus .badge {\n  text-shadow: none;\n}\n.panel {\n  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);\n          box-shadow: 0 1px 2px rgba(0, 0, 0, .05);\n}\n.panel-default > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);\n  background-image:      -o-linear-gradient(top, #f5f5f5 0%, #e8e8e8 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f5f5f5), to(#e8e8e8));\n  background-image:         linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);\n  background-repeat: repeat-x;\n}\n.panel-primary > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n  background-image:      -o-linear-gradient(top, #337ab7 0%, #2e6da4 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#337ab7), to(#2e6da4));\n  background-image:         linear-gradient(to bottom, #337ab7 0%, #2e6da4 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);\n  background-repeat: repeat-x;\n}\n.panel-success > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);\n  background-image:      -o-linear-gradient(top, #dff0d8 0%, #d0e9c6 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#dff0d8), to(#d0e9c6));\n  background-image:         linear-gradient(to bottom, #dff0d8 0%, #d0e9c6 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);\n  background-repeat: repeat-x;\n}\n.panel-info > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);\n  background-image:      -o-linear-gradient(top, #d9edf7 0%, #c4e3f3 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#d9edf7), to(#c4e3f3));\n  background-image:         linear-gradient(to bottom, #d9edf7 0%, #c4e3f3 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);\n  background-repeat: repeat-x;\n}\n.panel-warning > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);\n  background-image:      -o-linear-gradient(top, #fcf8e3 0%, #faf2cc 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#fcf8e3), to(#faf2cc));\n  background-image:         linear-gradient(to bottom, #fcf8e3 0%, #faf2cc 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);\n  background-repeat: repeat-x;\n}\n.panel-danger > .panel-heading {\n  background-image: -webkit-linear-gradient(top, #f2dede 0%, #ebcccc 100%);\n  background-image:      -o-linear-gradient(top, #f2dede 0%, #ebcccc 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#f2dede), to(#ebcccc));\n  background-image:         linear-gradient(to bottom, #f2dede 0%, #ebcccc 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);\n  background-repeat: repeat-x;\n}\n.well {\n  background-image: -webkit-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);\n  background-image:      -o-linear-gradient(top, #e8e8e8 0%, #f5f5f5 100%);\n  background-image: -webkit-gradient(linear, left top, left bottom, from(#e8e8e8), to(#f5f5f5));\n  background-image:         linear-gradient(to bottom, #e8e8e8 0%, #f5f5f5 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);\n  background-repeat: repeat-x;\n  border-color: #dcdcdc;\n  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);\n          box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05), 0 1px 0 rgba(255, 255, 255, .1);\n}\n/*# sourceMappingURL=bootstrap-theme.css.map */\n"
  },
  {
    "path": "html/lib/bootstrap/bootstrap.css",
    "content": "/*!\n * Bootstrap v3.3.6 (http://getbootstrap.com)\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n */\n/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */\nhtml {\n  font-family: sans-serif;\n  -webkit-text-size-adjust: 100%;\n      -ms-text-size-adjust: 100%;\n}\nbody {\n  margin: 0;\n}\narticle,\naside,\ndetails,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nmenu,\nnav,\nsection,\nsummary {\n  display: block;\n}\naudio,\ncanvas,\nprogress,\nvideo {\n  display: inline-block;\n  vertical-align: baseline;\n}\naudio:not([controls]) {\n  display: none;\n  height: 0;\n}\n[hidden],\ntemplate {\n  display: none;\n}\na {\n  background-color: transparent;\n}\na:active,\na:hover {\n  outline: 0;\n}\nabbr[title] {\n  border-bottom: 1px dotted;\n}\nb,\nstrong {\n  font-weight: bold;\n}\ndfn {\n  font-style: italic;\n}\nh1 {\n  margin: .67em 0;\n  font-size: 2em;\n}\nmark {\n  color: #000;\n  background: #ff0;\n}\nsmall {\n  font-size: 80%;\n}\nsub,\nsup {\n  position: relative;\n  font-size: 75%;\n  line-height: 0;\n  vertical-align: baseline;\n}\nsup {\n  top: -.5em;\n}\nsub {\n  bottom: -.25em;\n}\nimg {\n  border: 0;\n}\nsvg:not(:root) {\n  overflow: hidden;\n}\nfigure {\n  margin: 1em 40px;\n}\nhr {\n  height: 0;\n  -webkit-box-sizing: content-box;\n     -moz-box-sizing: content-box;\n          box-sizing: content-box;\n}\npre {\n  overflow: auto;\n}\ncode,\nkbd,\npre,\nsamp {\n  font-family: monospace, monospace;\n  font-size: 1em;\n}\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n  margin: 0;\n  font: inherit;\n  color: inherit;\n}\nbutton {\n  overflow: visible;\n}\nbutton,\nselect {\n  text-transform: none;\n}\nbutton,\nhtml input[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\n  -webkit-appearance: button;\n  cursor: pointer;\n}\nbutton[disabled],\nhtml input[disabled] {\n  cursor: default;\n}\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n  padding: 0;\n  border: 0;\n}\ninput {\n  line-height: normal;\n}\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n  -webkit-box-sizing: border-box;\n     -moz-box-sizing: border-box;\n          box-sizing: border-box;\n  padding: 0;\n}\ninput[type=\"number\"]::-webkit-inner-spin-button,\ninput[type=\"number\"]::-webkit-outer-spin-button {\n  height: auto;\n}\ninput[type=\"search\"] {\n  -webkit-box-sizing: content-box;\n     -moz-box-sizing: content-box;\n          box-sizing: content-box;\n  -webkit-appearance: textfield;\n}\ninput[type=\"search\"]::-webkit-search-cancel-button,\ninput[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\nfieldset {\n  padding: .35em .625em .75em;\n  margin: 0 2px;\n  border: 1px solid #c0c0c0;\n}\nlegend {\n  padding: 0;\n  border: 0;\n}\ntextarea {\n  overflow: auto;\n}\noptgroup {\n  font-weight: bold;\n}\ntable {\n  border-spacing: 0;\n  border-collapse: collapse;\n}\ntd,\nth {\n  padding: 0;\n}\n/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */\n@media print {\n  *,\n  *:before,\n  *:after {\n    color: #000 !important;\n    text-shadow: none !important;\n    background: transparent !important;\n    -webkit-box-shadow: none !important;\n            box-shadow: none !important;\n  }\n  a,\n  a:visited {\n    text-decoration: underline;\n  }\n  a[href]:after {\n    content: \" (\" attr(href) \")\";\n  }\n  abbr[title]:after {\n    content: \" (\" attr(title) \")\";\n  }\n  a[href^=\"#\"]:after,\n  a[href^=\"javascript:\"]:after {\n    content: \"\";\n  }\n  pre,\n  blockquote {\n    border: 1px solid #999;\n\n    page-break-inside: avoid;\n  }\n  thead {\n    display: table-header-group;\n  }\n  tr,\n  img {\n    page-break-inside: avoid;\n  }\n  img {\n    max-width: 100% !important;\n  }\n  p,\n  h2,\n  h3 {\n    orphans: 3;\n    widows: 3;\n  }\n  h2,\n  h3 {\n    page-break-after: avoid;\n  }\n  .navbar {\n    display: none;\n  }\n  .btn > .caret,\n  .dropup > .btn > .caret {\n    border-top-color: #000 !important;\n  }\n  .label {\n    border: 1px solid #000;\n  }\n  .table {\n    border-collapse: collapse !important;\n  }\n  .table td,\n  .table th {\n    background-color: #fff !important;\n  }\n  .table-bordered th,\n  .table-bordered td {\n    border: 1px solid #ddd !important;\n  }\n}\n@font-face {\n  font-family: 'Glyphicons Halflings';\n\n  src: url('../fonts/glyphicons-halflings-regular.eot');\n  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');\n}\n.glyphicon {\n  position: relative;\n  top: 1px;\n  display: inline-block;\n  font-family: 'Glyphicons Halflings';\n  font-style: normal;\n  font-weight: normal;\n  line-height: 1;\n\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n.glyphicon-asterisk:before {\n  content: \"\\002a\";\n}\n.glyphicon-plus:before {\n  content: \"\\002b\";\n}\n.glyphicon-euro:before,\n.glyphicon-eur:before {\n  content: \"\\20ac\";\n}\n.glyphicon-minus:before {\n  content: \"\\2212\";\n}\n.glyphicon-cloud:before {\n  content: \"\\2601\";\n}\n.glyphicon-envelope:before {\n  content: \"\\2709\";\n}\n.glyphicon-pencil:before {\n  content: \"\\270f\";\n}\n.glyphicon-glass:before {\n  content: \"\\e001\";\n}\n.glyphicon-music:before {\n  content: \"\\e002\";\n}\n.glyphicon-search:before {\n  content: \"\\e003\";\n}\n.glyphicon-heart:before {\n  content: \"\\e005\";\n}\n.glyphicon-star:before {\n  content: \"\\e006\";\n}\n.glyphicon-star-empty:before {\n  content: \"\\e007\";\n}\n.glyphicon-user:before {\n  content: \"\\e008\";\n}\n.glyphicon-film:before {\n  content: \"\\e009\";\n}\n.glyphicon-th-large:before {\n  content: \"\\e010\";\n}\n.glyphicon-th:before {\n  content: \"\\e011\";\n}\n.glyphicon-th-list:before {\n  content: \"\\e012\";\n}\n.glyphicon-ok:before {\n  content: \"\\e013\";\n}\n.glyphicon-remove:before {\n  content: \"\\e014\";\n}\n.glyphicon-zoom-in:before {\n  content: \"\\e015\";\n}\n.glyphicon-zoom-out:before {\n  content: \"\\e016\";\n}\n.glyphicon-off:before {\n  content: \"\\e017\";\n}\n.glyphicon-signal:before {\n  content: \"\\e018\";\n}\n.glyphicon-cog:before {\n  content: \"\\e019\";\n}\n.glyphicon-trash:before {\n  content: \"\\e020\";\n}\n.glyphicon-home:before {\n  content: \"\\e021\";\n}\n.glyphicon-file:before {\n  content: \"\\e022\";\n}\n.glyphicon-time:before {\n  content: \"\\e023\";\n}\n.glyphicon-road:before {\n  content: \"\\e024\";\n}\n.glyphicon-download-alt:before {\n  content: \"\\e025\";\n}\n.glyphicon-download:before {\n  content: \"\\e026\";\n}\n.glyphicon-upload:before {\n  content: \"\\e027\";\n}\n.glyphicon-inbox:before {\n  content: \"\\e028\";\n}\n.glyphicon-play-circle:before {\n  content: \"\\e029\";\n}\n.glyphicon-repeat:before {\n  content: \"\\e030\";\n}\n.glyphicon-refresh:before {\n  content: \"\\e031\";\n}\n.glyphicon-list-alt:before {\n  content: \"\\e032\";\n}\n.glyphicon-lock:before {\n  content: \"\\e033\";\n}\n.glyphicon-flag:before {\n  content: \"\\e034\";\n}\n.glyphicon-headphones:before {\n  content: \"\\e035\";\n}\n.glyphicon-volume-off:before {\n  content: \"\\e036\";\n}\n.glyphicon-volume-down:before {\n  content: \"\\e037\";\n}\n.glyphicon-volume-up:before {\n  content: \"\\e038\";\n}\n.glyphicon-qrcode:before {\n  content: \"\\e039\";\n}\n.glyphicon-barcode:before {\n  content: \"\\e040\";\n}\n.glyphicon-tag:before {\n  content: \"\\e041\";\n}\n.glyphicon-tags:before {\n  content: \"\\e042\";\n}\n.glyphicon-book:before {\n  content: \"\\e043\";\n}\n.glyphicon-bookmark:before {\n  content: \"\\e044\";\n}\n.glyphicon-print:before {\n  content: \"\\e045\";\n}\n.glyphicon-camera:before {\n  content: \"\\e046\";\n}\n.glyphicon-font:before {\n  content: \"\\e047\";\n}\n.glyphicon-bold:before {\n  content: \"\\e048\";\n}\n.glyphicon-italic:before {\n  content: \"\\e049\";\n}\n.glyphicon-text-height:before {\n  content: \"\\e050\";\n}\n.glyphicon-text-width:before {\n  content: \"\\e051\";\n}\n.glyphicon-align-left:before {\n  content: \"\\e052\";\n}\n.glyphicon-align-center:before {\n  content: \"\\e053\";\n}\n.glyphicon-align-right:before {\n  content: \"\\e054\";\n}\n.glyphicon-align-justify:before {\n  content: \"\\e055\";\n}\n.glyphicon-list:before {\n  content: \"\\e056\";\n}\n.glyphicon-indent-left:before {\n  content: \"\\e057\";\n}\n.glyphicon-indent-right:before {\n  content: \"\\e058\";\n}\n.glyphicon-facetime-video:before {\n  content: \"\\e059\";\n}\n.glyphicon-picture:before {\n  content: \"\\e060\";\n}\n.glyphicon-map-marker:before {\n  content: \"\\e062\";\n}\n.glyphicon-adjust:before {\n  content: \"\\e063\";\n}\n.glyphicon-tint:before {\n  content: \"\\e064\";\n}\n.glyphicon-edit:before {\n  content: \"\\e065\";\n}\n.glyphicon-share:before {\n  content: \"\\e066\";\n}\n.glyphicon-check:before {\n  content: \"\\e067\";\n}\n.glyphicon-move:before {\n  content: \"\\e068\";\n}\n.glyphicon-step-backward:before {\n  content: \"\\e069\";\n}\n.glyphicon-fast-backward:before {\n  content: \"\\e070\";\n}\n.glyphicon-backward:before {\n  content: \"\\e071\";\n}\n.glyphicon-play:before {\n  content: \"\\e072\";\n}\n.glyphicon-pause:before {\n  content: \"\\e073\";\n}\n.glyphicon-stop:before {\n  content: \"\\e074\";\n}\n.glyphicon-forward:before {\n  content: \"\\e075\";\n}\n.glyphicon-fast-forward:before {\n  content: \"\\e076\";\n}\n.glyphicon-step-forward:before {\n  content: \"\\e077\";\n}\n.glyphicon-eject:before {\n  content: \"\\e078\";\n}\n.glyphicon-chevron-left:before {\n  content: \"\\e079\";\n}\n.glyphicon-chevron-right:before {\n  content: \"\\e080\";\n}\n.glyphicon-plus-sign:before {\n  content: \"\\e081\";\n}\n.glyphicon-minus-sign:before {\n  content: \"\\e082\";\n}\n.glyphicon-remove-sign:before {\n  content: \"\\e083\";\n}\n.glyphicon-ok-sign:before {\n  content: \"\\e084\";\n}\n.glyphicon-question-sign:before {\n  content: \"\\e085\";\n}\n.glyphicon-info-sign:before {\n  content: \"\\e086\";\n}\n.glyphicon-screenshot:before {\n  content: \"\\e087\";\n}\n.glyphicon-remove-circle:before {\n  content: \"\\e088\";\n}\n.glyphicon-ok-circle:before {\n  content: \"\\e089\";\n}\n.glyphicon-ban-circle:before {\n  content: \"\\e090\";\n}\n.glyphicon-arrow-left:before {\n  content: \"\\e091\";\n}\n.glyphicon-arrow-right:before {\n  content: \"\\e092\";\n}\n.glyphicon-arrow-up:before {\n  content: \"\\e093\";\n}\n.glyphicon-arrow-down:before {\n  content: \"\\e094\";\n}\n.glyphicon-share-alt:before {\n  content: \"\\e095\";\n}\n.glyphicon-resize-full:before {\n  content: \"\\e096\";\n}\n.glyphicon-resize-small:before {\n  content: \"\\e097\";\n}\n.glyphicon-exclamation-sign:before {\n  content: \"\\e101\";\n}\n.glyphicon-gift:before {\n  content: \"\\e102\";\n}\n.glyphicon-leaf:before {\n  content: \"\\e103\";\n}\n.glyphicon-fire:before {\n  content: \"\\e104\";\n}\n.glyphicon-eye-open:before {\n  content: \"\\e105\";\n}\n.glyphicon-eye-close:before {\n  content: \"\\e106\";\n}\n.glyphicon-warning-sign:before {\n  content: \"\\e107\";\n}\n.glyphicon-plane:before {\n  content: \"\\e108\";\n}\n.glyphicon-calendar:before {\n  content: \"\\e109\";\n}\n.glyphicon-random:before {\n  content: \"\\e110\";\n}\n.glyphicon-comment:before {\n  content: \"\\e111\";\n}\n.glyphicon-magnet:before {\n  content: \"\\e112\";\n}\n.glyphicon-chevron-up:before {\n  content: \"\\e113\";\n}\n.glyphicon-chevron-down:before {\n  content: \"\\e114\";\n}\n.glyphicon-retweet:before {\n  content: \"\\e115\";\n}\n.glyphicon-shopping-cart:before {\n  content: \"\\e116\";\n}\n.glyphicon-folder-close:before {\n  content: \"\\e117\";\n}\n.glyphicon-folder-open:before {\n  content: \"\\e118\";\n}\n.glyphicon-resize-vertical:before {\n  content: \"\\e119\";\n}\n.glyphicon-resize-horizontal:before {\n  content: \"\\e120\";\n}\n.glyphicon-hdd:before {\n  content: \"\\e121\";\n}\n.glyphicon-bullhorn:before {\n  content: \"\\e122\";\n}\n.glyphicon-bell:before {\n  content: \"\\e123\";\n}\n.glyphicon-certificate:before {\n  content: \"\\e124\";\n}\n.glyphicon-thumbs-up:before {\n  content: \"\\e125\";\n}\n.glyphicon-thumbs-down:before {\n  content: \"\\e126\";\n}\n.glyphicon-hand-right:before {\n  content: \"\\e127\";\n}\n.glyphicon-hand-left:before {\n  content: \"\\e128\";\n}\n.glyphicon-hand-up:before {\n  content: \"\\e129\";\n}\n.glyphicon-hand-down:before {\n  content: \"\\e130\";\n}\n.glyphicon-circle-arrow-right:before {\n  content: \"\\e131\";\n}\n.glyphicon-circle-arrow-left:before {\n  content: \"\\e132\";\n}\n.glyphicon-circle-arrow-up:before {\n  content: \"\\e133\";\n}\n.glyphicon-circle-arrow-down:before {\n  content: \"\\e134\";\n}\n.glyphicon-globe:before {\n  content: \"\\e135\";\n}\n.glyphicon-wrench:before {\n  content: \"\\e136\";\n}\n.glyphicon-tasks:before {\n  content: \"\\e137\";\n}\n.glyphicon-filter:before {\n  content: \"\\e138\";\n}\n.glyphicon-briefcase:before {\n  content: \"\\e139\";\n}\n.glyphicon-fullscreen:before {\n  content: \"\\e140\";\n}\n.glyphicon-dashboard:before {\n  content: \"\\e141\";\n}\n.glyphicon-paperclip:before {\n  content: \"\\e142\";\n}\n.glyphicon-heart-empty:before {\n  content: \"\\e143\";\n}\n.glyphicon-link:before {\n  content: \"\\e144\";\n}\n.glyphicon-phone:before {\n  content: \"\\e145\";\n}\n.glyphicon-pushpin:before {\n  content: \"\\e146\";\n}\n.glyphicon-usd:before {\n  content: \"\\e148\";\n}\n.glyphicon-gbp:before {\n  content: \"\\e149\";\n}\n.glyphicon-sort:before {\n  content: \"\\e150\";\n}\n.glyphicon-sort-by-alphabet:before {\n  content: \"\\e151\";\n}\n.glyphicon-sort-by-alphabet-alt:before {\n  content: \"\\e152\";\n}\n.glyphicon-sort-by-order:before {\n  content: \"\\e153\";\n}\n.glyphicon-sort-by-order-alt:before {\n  content: \"\\e154\";\n}\n.glyphicon-sort-by-attributes:before {\n  content: \"\\e155\";\n}\n.glyphicon-sort-by-attributes-alt:before {\n  content: \"\\e156\";\n}\n.glyphicon-unchecked:before {\n  content: \"\\e157\";\n}\n.glyphicon-expand:before {\n  content: \"\\e158\";\n}\n.glyphicon-collapse-down:before {\n  content: \"\\e159\";\n}\n.glyphicon-collapse-up:before {\n  content: \"\\e160\";\n}\n.glyphicon-log-in:before {\n  content: \"\\e161\";\n}\n.glyphicon-flash:before {\n  content: \"\\e162\";\n}\n.glyphicon-log-out:before {\n  content: \"\\e163\";\n}\n.glyphicon-new-window:before {\n  content: \"\\e164\";\n}\n.glyphicon-record:before {\n  content: \"\\e165\";\n}\n.glyphicon-save:before {\n  content: \"\\e166\";\n}\n.glyphicon-open:before {\n  content: \"\\e167\";\n}\n.glyphicon-saved:before {\n  content: \"\\e168\";\n}\n.glyphicon-import:before {\n  content: \"\\e169\";\n}\n.glyphicon-export:before {\n  content: \"\\e170\";\n}\n.glyphicon-send:before {\n  content: \"\\e171\";\n}\n.glyphicon-floppy-disk:before {\n  content: \"\\e172\";\n}\n.glyphicon-floppy-saved:before {\n  content: \"\\e173\";\n}\n.glyphicon-floppy-remove:before {\n  content: \"\\e174\";\n}\n.glyphicon-floppy-save:before {\n  content: \"\\e175\";\n}\n.glyphicon-floppy-open:before {\n  content: \"\\e176\";\n}\n.glyphicon-credit-card:before {\n  content: \"\\e177\";\n}\n.glyphicon-transfer:before {\n  content: \"\\e178\";\n}\n.glyphicon-cutlery:before {\n  content: \"\\e179\";\n}\n.glyphicon-header:before {\n  content: \"\\e180\";\n}\n.glyphicon-compressed:before {\n  content: \"\\e181\";\n}\n.glyphicon-earphone:before {\n  content: \"\\e182\";\n}\n.glyphicon-phone-alt:before {\n  content: \"\\e183\";\n}\n.glyphicon-tower:before {\n  content: \"\\e184\";\n}\n.glyphicon-stats:before {\n  content: \"\\e185\";\n}\n.glyphicon-sd-video:before {\n  content: \"\\e186\";\n}\n.glyphicon-hd-video:before {\n  content: \"\\e187\";\n}\n.glyphicon-subtitles:before {\n  content: \"\\e188\";\n}\n.glyphicon-sound-stereo:before {\n  content: \"\\e189\";\n}\n.glyphicon-sound-dolby:before {\n  content: \"\\e190\";\n}\n.glyphicon-sound-5-1:before {\n  content: \"\\e191\";\n}\n.glyphicon-sound-6-1:before {\n  content: \"\\e192\";\n}\n.glyphicon-sound-7-1:before {\n  content: \"\\e193\";\n}\n.glyphicon-copyright-mark:before {\n  content: \"\\e194\";\n}\n.glyphicon-registration-mark:before {\n  content: \"\\e195\";\n}\n.glyphicon-cloud-download:before {\n  content: \"\\e197\";\n}\n.glyphicon-cloud-upload:before {\n  content: \"\\e198\";\n}\n.glyphicon-tree-conifer:before {\n  content: \"\\e199\";\n}\n.glyphicon-tree-deciduous:before {\n  content: \"\\e200\";\n}\n.glyphicon-cd:before {\n  content: \"\\e201\";\n}\n.glyphicon-save-file:before {\n  content: \"\\e202\";\n}\n.glyphicon-open-file:before {\n  content: \"\\e203\";\n}\n.glyphicon-level-up:before {\n  content: \"\\e204\";\n}\n.glyphicon-copy:before {\n  content: \"\\e205\";\n}\n.glyphicon-paste:before {\n  content: \"\\e206\";\n}\n.glyphicon-alert:before {\n  content: \"\\e209\";\n}\n.glyphicon-equalizer:before {\n  content: \"\\e210\";\n}\n.glyphicon-king:before {\n  content: \"\\e211\";\n}\n.glyphicon-queen:before {\n  content: \"\\e212\";\n}\n.glyphicon-pawn:before {\n  content: \"\\e213\";\n}\n.glyphicon-bishop:before {\n  content: \"\\e214\";\n}\n.glyphicon-knight:before {\n  content: \"\\e215\";\n}\n.glyphicon-baby-formula:before {\n  content: \"\\e216\";\n}\n.glyphicon-tent:before {\n  content: \"\\26fa\";\n}\n.glyphicon-blackboard:before {\n  content: \"\\e218\";\n}\n.glyphicon-bed:before {\n  content: \"\\e219\";\n}\n.glyphicon-apple:before {\n  content: \"\\f8ff\";\n}\n.glyphicon-erase:before {\n  content: \"\\e221\";\n}\n.glyphicon-hourglass:before {\n  content: \"\\231b\";\n}\n.glyphicon-lamp:before {\n  content: \"\\e223\";\n}\n.glyphicon-duplicate:before {\n  content: \"\\e224\";\n}\n.glyphicon-piggy-bank:before {\n  content: \"\\e225\";\n}\n.glyphicon-scissors:before {\n  content: \"\\e226\";\n}\n.glyphicon-bitcoin:before {\n  content: \"\\e227\";\n}\n.glyphicon-btc:before {\n  content: \"\\e227\";\n}\n.glyphicon-xbt:before {\n  content: \"\\e227\";\n}\n.glyphicon-yen:before {\n  content: \"\\00a5\";\n}\n.glyphicon-jpy:before {\n  content: \"\\00a5\";\n}\n.glyphicon-ruble:before {\n  content: \"\\20bd\";\n}\n.glyphicon-rub:before {\n  content: \"\\20bd\";\n}\n.glyphicon-scale:before {\n  content: \"\\e230\";\n}\n.glyphicon-ice-lolly:before {\n  content: \"\\e231\";\n}\n.glyphicon-ice-lolly-tasted:before {\n  content: \"\\e232\";\n}\n.glyphicon-education:before {\n  content: \"\\e233\";\n}\n.glyphicon-option-horizontal:before {\n  content: \"\\e234\";\n}\n.glyphicon-option-vertical:before {\n  content: \"\\e235\";\n}\n.glyphicon-menu-hamburger:before {\n  content: \"\\e236\";\n}\n.glyphicon-modal-window:before {\n  content: \"\\e237\";\n}\n.glyphicon-oil:before {\n  content: \"\\e238\";\n}\n.glyphicon-grain:before {\n  content: \"\\e239\";\n}\n.glyphicon-sunglasses:before {\n  content: \"\\e240\";\n}\n.glyphicon-text-size:before {\n  content: \"\\e241\";\n}\n.glyphicon-text-color:before {\n  content: \"\\e242\";\n}\n.glyphicon-text-background:before {\n  content: \"\\e243\";\n}\n.glyphicon-object-align-top:before {\n  content: \"\\e244\";\n}\n.glyphicon-object-align-bottom:before {\n  content: \"\\e245\";\n}\n.glyphicon-object-align-horizontal:before {\n  content: \"\\e246\";\n}\n.glyphicon-object-align-left:before {\n  content: \"\\e247\";\n}\n.glyphicon-object-align-vertical:before {\n  content: \"\\e248\";\n}\n.glyphicon-object-align-right:before {\n  content: \"\\e249\";\n}\n.glyphicon-triangle-right:before {\n  content: \"\\e250\";\n}\n.glyphicon-triangle-left:before {\n  content: \"\\e251\";\n}\n.glyphicon-triangle-bottom:before {\n  content: \"\\e252\";\n}\n.glyphicon-triangle-top:before {\n  content: \"\\e253\";\n}\n.glyphicon-console:before {\n  content: \"\\e254\";\n}\n.glyphicon-superscript:before {\n  content: \"\\e255\";\n}\n.glyphicon-subscript:before {\n  content: \"\\e256\";\n}\n.glyphicon-menu-left:before {\n  content: \"\\e257\";\n}\n.glyphicon-menu-right:before {\n  content: \"\\e258\";\n}\n.glyphicon-menu-down:before {\n  content: \"\\e259\";\n}\n.glyphicon-menu-up:before {\n  content: \"\\e260\";\n}\n* {\n  -webkit-box-sizing: border-box;\n     -moz-box-sizing: border-box;\n          box-sizing: border-box;\n}\n*:before,\n*:after {\n  -webkit-box-sizing: border-box;\n     -moz-box-sizing: border-box;\n          box-sizing: border-box;\n}\nhtml {\n  font-size: 10px;\n\n  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\nbody {\n  font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  font-size: 14px;\n  line-height: 1.42857143;\n  color: #333;\n  background-color: #fff;\n}\ninput,\nbutton,\nselect,\ntextarea {\n  font-family: inherit;\n  font-size: inherit;\n  line-height: inherit;\n}\na {\n  color: #337ab7;\n  text-decoration: none;\n}\na:hover,\na:focus {\n  color: #23527c;\n  text-decoration: underline;\n}\na:focus {\n  outline: thin dotted;\n  outline: 5px auto -webkit-focus-ring-color;\n  outline-offset: -2px;\n}\nfigure {\n  margin: 0;\n}\nimg {\n  vertical-align: middle;\n}\n.img-responsive,\n.thumbnail > img,\n.thumbnail a > img,\n.carousel-inner > .item > img,\n.carousel-inner > .item > a > img {\n  display: block;\n  max-width: 100%;\n  height: auto;\n}\n.img-rounded {\n  border-radius: 6px;\n}\n.img-thumbnail {\n  display: inline-block;\n  max-width: 100%;\n  height: auto;\n  padding: 4px;\n  line-height: 1.42857143;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  -webkit-transition: all .2s ease-in-out;\n       -o-transition: all .2s ease-in-out;\n          transition: all .2s ease-in-out;\n}\n.img-circle {\n  border-radius: 50%;\n}\nhr {\n  margin-top: 20px;\n  margin-bottom: 20px;\n  border: 0;\n  border-top: 1px solid #eee;\n}\n.sr-only {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  padding: 0;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  border: 0;\n}\n.sr-only-focusable:active,\n.sr-only-focusable:focus {\n  position: static;\n  width: auto;\n  height: auto;\n  margin: 0;\n  overflow: visible;\n  clip: auto;\n}\n[role=\"button\"] {\n  cursor: pointer;\n}\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\n.h1,\n.h2,\n.h3,\n.h4,\n.h5,\n.h6 {\n  font-family: inherit;\n  font-weight: 500;\n  line-height: 1.1;\n  color: inherit;\n}\nh1 small,\nh2 small,\nh3 small,\nh4 small,\nh5 small,\nh6 small,\n.h1 small,\n.h2 small,\n.h3 small,\n.h4 small,\n.h5 small,\n.h6 small,\nh1 .small,\nh2 .small,\nh3 .small,\nh4 .small,\nh5 .small,\nh6 .small,\n.h1 .small,\n.h2 .small,\n.h3 .small,\n.h4 .small,\n.h5 .small,\n.h6 .small {\n  font-weight: normal;\n  line-height: 1;\n  color: #777;\n}\nh1,\n.h1,\nh2,\n.h2,\nh3,\n.h3 {\n  margin-top: 20px;\n  margin-bottom: 10px;\n}\nh1 small,\n.h1 small,\nh2 small,\n.h2 small,\nh3 small,\n.h3 small,\nh1 .small,\n.h1 .small,\nh2 .small,\n.h2 .small,\nh3 .small,\n.h3 .small {\n  font-size: 65%;\n}\nh4,\n.h4,\nh5,\n.h5,\nh6,\n.h6 {\n  margin-top: 10px;\n  margin-bottom: 10px;\n}\nh4 small,\n.h4 small,\nh5 small,\n.h5 small,\nh6 small,\n.h6 small,\nh4 .small,\n.h4 .small,\nh5 .small,\n.h5 .small,\nh6 .small,\n.h6 .small {\n  font-size: 75%;\n}\nh1,\n.h1 {\n  font-size: 36px;\n}\nh2,\n.h2 {\n  font-size: 30px;\n}\nh3,\n.h3 {\n  font-size: 24px;\n}\nh4,\n.h4 {\n  font-size: 18px;\n}\nh5,\n.h5 {\n  font-size: 14px;\n}\nh6,\n.h6 {\n  font-size: 12px;\n}\np {\n  margin: 0 0 10px;\n}\n.lead {\n  margin-bottom: 20px;\n  font-size: 16px;\n  font-weight: 300;\n  line-height: 1.4;\n}\n@media (min-width: 768px) {\n  .lead {\n    font-size: 21px;\n  }\n}\nsmall,\n.small {\n  font-size: 85%;\n}\nmark,\n.mark {\n  padding: .2em;\n  background-color: #fcf8e3;\n}\n.text-left {\n  text-align: left;\n}\n.text-right {\n  text-align: right;\n}\n.text-center {\n  text-align: center;\n}\n.text-justify {\n  text-align: justify;\n}\n.text-nowrap {\n  white-space: nowrap;\n}\n.text-lowercase {\n  text-transform: lowercase;\n}\n.text-uppercase {\n  text-transform: uppercase;\n}\n.text-capitalize {\n  text-transform: capitalize;\n}\n.text-muted {\n  color: #777;\n}\n.text-primary {\n  color: #337ab7;\n}\na.text-primary:hover,\na.text-primary:focus {\n  color: #286090;\n}\n.text-success {\n  color: #3c763d;\n}\na.text-success:hover,\na.text-success:focus {\n  color: #2b542c;\n}\n.text-info {\n  color: #31708f;\n}\na.text-info:hover,\na.text-info:focus {\n  color: #245269;\n}\n.text-warning {\n  color: #8a6d3b;\n}\na.text-warning:hover,\na.text-warning:focus {\n  color: #66512c;\n}\n.text-danger {\n  color: #a94442;\n}\na.text-danger:hover,\na.text-danger:focus {\n  color: #843534;\n}\n.bg-primary {\n  color: #fff;\n  background-color: #337ab7;\n}\na.bg-primary:hover,\na.bg-primary:focus {\n  background-color: #286090;\n}\n.bg-success {\n  background-color: #dff0d8;\n}\na.bg-success:hover,\na.bg-success:focus {\n  background-color: #c1e2b3;\n}\n.bg-info {\n  background-color: #d9edf7;\n}\na.bg-info:hover,\na.bg-info:focus {\n  background-color: #afd9ee;\n}\n.bg-warning {\n  background-color: #fcf8e3;\n}\na.bg-warning:hover,\na.bg-warning:focus {\n  background-color: #f7ecb5;\n}\n.bg-danger {\n  background-color: #f2dede;\n}\na.bg-danger:hover,\na.bg-danger:focus {\n  background-color: #e4b9b9;\n}\n.page-header {\n  padding-bottom: 9px;\n  margin: 40px 0 20px;\n  border-bottom: 1px solid #eee;\n}\nul,\nol {\n  margin-top: 0;\n  margin-bottom: 10px;\n}\nul ul,\nol ul,\nul ol,\nol ol {\n  margin-bottom: 0;\n}\n.list-unstyled {\n  padding-left: 0;\n  list-style: none;\n}\n.list-inline {\n  padding-left: 0;\n  margin-left: -5px;\n  list-style: none;\n}\n.list-inline > li {\n  display: inline-block;\n  padding-right: 5px;\n  padding-left: 5px;\n}\ndl {\n  margin-top: 0;\n  margin-bottom: 20px;\n}\ndt,\ndd {\n  line-height: 1.42857143;\n}\ndt {\n  font-weight: bold;\n}\ndd {\n  margin-left: 0;\n}\n@media (min-width: 768px) {\n  .dl-horizontal dt {\n    float: left;\n    width: 160px;\n    overflow: hidden;\n    clear: left;\n    text-align: right;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n  .dl-horizontal dd {\n    margin-left: 180px;\n  }\n}\nabbr[title],\nabbr[data-original-title] {\n  cursor: help;\n  border-bottom: 1px dotted #777;\n}\n.initialism {\n  font-size: 90%;\n  text-transform: uppercase;\n}\nblockquote {\n  padding: 10px 20px;\n  margin: 0 0 20px;\n  font-size: 17.5px;\n  border-left: 5px solid #eee;\n}\nblockquote p:last-child,\nblockquote ul:last-child,\nblockquote ol:last-child {\n  margin-bottom: 0;\n}\nblockquote footer,\nblockquote small,\nblockquote .small {\n  display: block;\n  font-size: 80%;\n  line-height: 1.42857143;\n  color: #777;\n}\nblockquote footer:before,\nblockquote small:before,\nblockquote .small:before {\n  content: '\\2014 \\00A0';\n}\n.blockquote-reverse,\nblockquote.pull-right {\n  padding-right: 15px;\n  padding-left: 0;\n  text-align: right;\n  border-right: 5px solid #eee;\n  border-left: 0;\n}\n.blockquote-reverse footer:before,\nblockquote.pull-right footer:before,\n.blockquote-reverse small:before,\nblockquote.pull-right small:before,\n.blockquote-reverse .small:before,\nblockquote.pull-right .small:before {\n  content: '';\n}\n.blockquote-reverse footer:after,\nblockquote.pull-right footer:after,\n.blockquote-reverse small:after,\nblockquote.pull-right small:after,\n.blockquote-reverse .small:after,\nblockquote.pull-right .small:after {\n  content: '\\00A0 \\2014';\n}\naddress {\n  margin-bottom: 20px;\n  font-style: normal;\n  line-height: 1.42857143;\n}\ncode,\nkbd,\npre,\nsamp {\n  font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\ncode {\n  padding: 2px 4px;\n  font-size: 90%;\n  color: #c7254e;\n  background-color: #f9f2f4;\n  border-radius: 4px;\n}\nkbd {\n  padding: 2px 4px;\n  font-size: 90%;\n  color: #fff;\n  background-color: #333;\n  border-radius: 3px;\n  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);\n          box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);\n}\nkbd kbd {\n  padding: 0;\n  font-size: 100%;\n  font-weight: bold;\n  -webkit-box-shadow: none;\n          box-shadow: none;\n}\npre {\n  display: block;\n  padding: 9.5px;\n  margin: 0 0 10px;\n  font-size: 13px;\n  line-height: 1.42857143;\n  color: #333;\n  word-break: break-all;\n  word-wrap: break-word;\n  background-color: #f5f5f5;\n  border: 1px solid #ccc;\n  border-radius: 4px;\n}\npre code {\n  padding: 0;\n  font-size: inherit;\n  color: inherit;\n  white-space: pre-wrap;\n  background-color: transparent;\n  border-radius: 0;\n}\n.pre-scrollable {\n  max-height: 340px;\n  overflow-y: scroll;\n}\n.container {\n  padding-right: 15px;\n  padding-left: 15px;\n  margin-right: auto;\n  margin-left: auto;\n}\n@media (min-width: 768px) {\n  .container {\n    width: 750px;\n  }\n}\n@media (min-width: 992px) {\n  .container {\n    width: 970px;\n  }\n}\n@media (min-width: 1200px) {\n  .container {\n    width: 1170px;\n  }\n}\n.container-fluid {\n  padding-right: 15px;\n  padding-left: 15px;\n  margin-right: auto;\n  margin-left: auto;\n}\n.row {\n  margin-right: -15px;\n  margin-left: -15px;\n}\n.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {\n  position: relative;\n  min-height: 1px;\n  padding-right: 15px;\n  padding-left: 15px;\n}\n.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {\n  float: left;\n}\n.col-xs-12 {\n  width: 100%;\n}\n.col-xs-11 {\n  width: 91.66666667%;\n}\n.col-xs-10 {\n  width: 83.33333333%;\n}\n.col-xs-9 {\n  width: 75%;\n}\n.col-xs-8 {\n  width: 66.66666667%;\n}\n.col-xs-7 {\n  width: 58.33333333%;\n}\n.col-xs-6 {\n  width: 50%;\n}\n.col-xs-5 {\n  width: 41.66666667%;\n}\n.col-xs-4 {\n  width: 33.33333333%;\n}\n.col-xs-3 {\n  width: 25%;\n}\n.col-xs-2 {\n  width: 16.66666667%;\n}\n.col-xs-1 {\n  width: 8.33333333%;\n}\n.col-xs-pull-12 {\n  right: 100%;\n}\n.col-xs-pull-11 {\n  right: 91.66666667%;\n}\n.col-xs-pull-10 {\n  right: 83.33333333%;\n}\n.col-xs-pull-9 {\n  right: 75%;\n}\n.col-xs-pull-8 {\n  right: 66.66666667%;\n}\n.col-xs-pull-7 {\n  right: 58.33333333%;\n}\n.col-xs-pull-6 {\n  right: 50%;\n}\n.col-xs-pull-5 {\n  right: 41.66666667%;\n}\n.col-xs-pull-4 {\n  right: 33.33333333%;\n}\n.col-xs-pull-3 {\n  right: 25%;\n}\n.col-xs-pull-2 {\n  right: 16.66666667%;\n}\n.col-xs-pull-1 {\n  right: 8.33333333%;\n}\n.col-xs-pull-0 {\n  right: auto;\n}\n.col-xs-push-12 {\n  left: 100%;\n}\n.col-xs-push-11 {\n  left: 91.66666667%;\n}\n.col-xs-push-10 {\n  left: 83.33333333%;\n}\n.col-xs-push-9 {\n  left: 75%;\n}\n.col-xs-push-8 {\n  left: 66.66666667%;\n}\n.col-xs-push-7 {\n  left: 58.33333333%;\n}\n.col-xs-push-6 {\n  left: 50%;\n}\n.col-xs-push-5 {\n  left: 41.66666667%;\n}\n.col-xs-push-4 {\n  left: 33.33333333%;\n}\n.col-xs-push-3 {\n  left: 25%;\n}\n.col-xs-push-2 {\n  left: 16.66666667%;\n}\n.col-xs-push-1 {\n  left: 8.33333333%;\n}\n.col-xs-push-0 {\n  left: auto;\n}\n.col-xs-offset-12 {\n  margin-left: 100%;\n}\n.col-xs-offset-11 {\n  margin-left: 91.66666667%;\n}\n.col-xs-offset-10 {\n  margin-left: 83.33333333%;\n}\n.col-xs-offset-9 {\n  margin-left: 75%;\n}\n.col-xs-offset-8 {\n  margin-left: 66.66666667%;\n}\n.col-xs-offset-7 {\n  margin-left: 58.33333333%;\n}\n.col-xs-offset-6 {\n  margin-left: 50%;\n}\n.col-xs-offset-5 {\n  margin-left: 41.66666667%;\n}\n.col-xs-offset-4 {\n  margin-left: 33.33333333%;\n}\n.col-xs-offset-3 {\n  margin-left: 25%;\n}\n.col-xs-offset-2 {\n  margin-left: 16.66666667%;\n}\n.col-xs-offset-1 {\n  margin-left: 8.33333333%;\n}\n.col-xs-offset-0 {\n  margin-left: 0;\n}\n@media (min-width: 768px) {\n  .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {\n    float: left;\n  }\n  .col-sm-12 {\n    width: 100%;\n  }\n  .col-sm-11 {\n    width: 91.66666667%;\n  }\n  .col-sm-10 {\n    width: 83.33333333%;\n  }\n  .col-sm-9 {\n    width: 75%;\n  }\n  .col-sm-8 {\n    width: 66.66666667%;\n  }\n  .col-sm-7 {\n    width: 58.33333333%;\n  }\n  .col-sm-6 {\n    width: 50%;\n  }\n  .col-sm-5 {\n    width: 41.66666667%;\n  }\n  .col-sm-4 {\n    width: 33.33333333%;\n  }\n  .col-sm-3 {\n    width: 25%;\n  }\n  .col-sm-2 {\n    width: 16.66666667%;\n  }\n  .col-sm-1 {\n    width: 8.33333333%;\n  }\n  .col-sm-pull-12 {\n    right: 100%;\n  }\n  .col-sm-pull-11 {\n    right: 91.66666667%;\n  }\n  .col-sm-pull-10 {\n    right: 83.33333333%;\n  }\n  .col-sm-pull-9 {\n    right: 75%;\n  }\n  .col-sm-pull-8 {\n    right: 66.66666667%;\n  }\n  .col-sm-pull-7 {\n    right: 58.33333333%;\n  }\n  .col-sm-pull-6 {\n    right: 50%;\n  }\n  .col-sm-pull-5 {\n    right: 41.66666667%;\n  }\n  .col-sm-pull-4 {\n    right: 33.33333333%;\n  }\n  .col-sm-pull-3 {\n    right: 25%;\n  }\n  .col-sm-pull-2 {\n    right: 16.66666667%;\n  }\n  .col-sm-pull-1 {\n    right: 8.33333333%;\n  }\n  .col-sm-pull-0 {\n    right: auto;\n  }\n  .col-sm-push-12 {\n    left: 100%;\n  }\n  .col-sm-push-11 {\n    left: 91.66666667%;\n  }\n  .col-sm-push-10 {\n    left: 83.33333333%;\n  }\n  .col-sm-push-9 {\n    left: 75%;\n  }\n  .col-sm-push-8 {\n    left: 66.66666667%;\n  }\n  .col-sm-push-7 {\n    left: 58.33333333%;\n  }\n  .col-sm-push-6 {\n    left: 50%;\n  }\n  .col-sm-push-5 {\n    left: 41.66666667%;\n  }\n  .col-sm-push-4 {\n    left: 33.33333333%;\n  }\n  .col-sm-push-3 {\n    left: 25%;\n  }\n  .col-sm-push-2 {\n    left: 16.66666667%;\n  }\n  .col-sm-push-1 {\n    left: 8.33333333%;\n  }\n  .col-sm-push-0 {\n    left: auto;\n  }\n  .col-sm-offset-12 {\n    margin-left: 100%;\n  }\n  .col-sm-offset-11 {\n    margin-left: 91.66666667%;\n  }\n  .col-sm-offset-10 {\n    margin-left: 83.33333333%;\n  }\n  .col-sm-offset-9 {\n    margin-left: 75%;\n  }\n  .col-sm-offset-8 {\n    margin-left: 66.66666667%;\n  }\n  .col-sm-offset-7 {\n    margin-left: 58.33333333%;\n  }\n  .col-sm-offset-6 {\n    margin-left: 50%;\n  }\n  .col-sm-offset-5 {\n    margin-left: 41.66666667%;\n  }\n  .col-sm-offset-4 {\n    margin-left: 33.33333333%;\n  }\n  .col-sm-offset-3 {\n    margin-left: 25%;\n  }\n  .col-sm-offset-2 {\n    margin-left: 16.66666667%;\n  }\n  .col-sm-offset-1 {\n    margin-left: 8.33333333%;\n  }\n  .col-sm-offset-0 {\n    margin-left: 0;\n  }\n}\n@media (min-width: 992px) {\n  .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {\n    float: left;\n  }\n  .col-md-12 {\n    width: 100%;\n  }\n  .col-md-11 {\n    width: 91.66666667%;\n  }\n  .col-md-10 {\n    width: 83.33333333%;\n  }\n  .col-md-9 {\n    width: 75%;\n  }\n  .col-md-8 {\n    width: 66.66666667%;\n  }\n  .col-md-7 {\n    width: 58.33333333%;\n  }\n  .col-md-6 {\n    width: 50%;\n  }\n  .col-md-5 {\n    width: 41.66666667%;\n  }\n  .col-md-4 {\n    width: 33.33333333%;\n  }\n  .col-md-3 {\n    width: 25%;\n  }\n  .col-md-2 {\n    width: 16.66666667%;\n  }\n  .col-md-1 {\n    width: 8.33333333%;\n  }\n  .col-md-pull-12 {\n    right: 100%;\n  }\n  .col-md-pull-11 {\n    right: 91.66666667%;\n  }\n  .col-md-pull-10 {\n    right: 83.33333333%;\n  }\n  .col-md-pull-9 {\n    right: 75%;\n  }\n  .col-md-pull-8 {\n    right: 66.66666667%;\n  }\n  .col-md-pull-7 {\n    right: 58.33333333%;\n  }\n  .col-md-pull-6 {\n    right: 50%;\n  }\n  .col-md-pull-5 {\n    right: 41.66666667%;\n  }\n  .col-md-pull-4 {\n    right: 33.33333333%;\n  }\n  .col-md-pull-3 {\n    right: 25%;\n  }\n  .col-md-pull-2 {\n    right: 16.66666667%;\n  }\n  .col-md-pull-1 {\n    right: 8.33333333%;\n  }\n  .col-md-pull-0 {\n    right: auto;\n  }\n  .col-md-push-12 {\n    left: 100%;\n  }\n  .col-md-push-11 {\n    left: 91.66666667%;\n  }\n  .col-md-push-10 {\n    left: 83.33333333%;\n  }\n  .col-md-push-9 {\n    left: 75%;\n  }\n  .col-md-push-8 {\n    left: 66.66666667%;\n  }\n  .col-md-push-7 {\n    left: 58.33333333%;\n  }\n  .col-md-push-6 {\n    left: 50%;\n  }\n  .col-md-push-5 {\n    left: 41.66666667%;\n  }\n  .col-md-push-4 {\n    left: 33.33333333%;\n  }\n  .col-md-push-3 {\n    left: 25%;\n  }\n  .col-md-push-2 {\n    left: 16.66666667%;\n  }\n  .col-md-push-1 {\n    left: 8.33333333%;\n  }\n  .col-md-push-0 {\n    left: auto;\n  }\n  .col-md-offset-12 {\n    margin-left: 100%;\n  }\n  .col-md-offset-11 {\n    margin-left: 91.66666667%;\n  }\n  .col-md-offset-10 {\n    margin-left: 83.33333333%;\n  }\n  .col-md-offset-9 {\n    margin-left: 75%;\n  }\n  .col-md-offset-8 {\n    margin-left: 66.66666667%;\n  }\n  .col-md-offset-7 {\n    margin-left: 58.33333333%;\n  }\n  .col-md-offset-6 {\n    margin-left: 50%;\n  }\n  .col-md-offset-5 {\n    margin-left: 41.66666667%;\n  }\n  .col-md-offset-4 {\n    margin-left: 33.33333333%;\n  }\n  .col-md-offset-3 {\n    margin-left: 25%;\n  }\n  .col-md-offset-2 {\n    margin-left: 16.66666667%;\n  }\n  .col-md-offset-1 {\n    margin-left: 8.33333333%;\n  }\n  .col-md-offset-0 {\n    margin-left: 0;\n  }\n}\n@media (min-width: 1200px) {\n  .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {\n    float: left;\n  }\n  .col-lg-12 {\n    width: 100%;\n  }\n  .col-lg-11 {\n    width: 91.66666667%;\n  }\n  .col-lg-10 {\n    width: 83.33333333%;\n  }\n  .col-lg-9 {\n    width: 75%;\n  }\n  .col-lg-8 {\n    width: 66.66666667%;\n  }\n  .col-lg-7 {\n    width: 58.33333333%;\n  }\n  .col-lg-6 {\n    width: 50%;\n  }\n  .col-lg-5 {\n    width: 41.66666667%;\n  }\n  .col-lg-4 {\n    width: 33.33333333%;\n  }\n  .col-lg-3 {\n    width: 25%;\n  }\n  .col-lg-2 {\n    width: 16.66666667%;\n  }\n  .col-lg-1 {\n    width: 8.33333333%;\n  }\n  .col-lg-pull-12 {\n    right: 100%;\n  }\n  .col-lg-pull-11 {\n    right: 91.66666667%;\n  }\n  .col-lg-pull-10 {\n    right: 83.33333333%;\n  }\n  .col-lg-pull-9 {\n    right: 75%;\n  }\n  .col-lg-pull-8 {\n    right: 66.66666667%;\n  }\n  .col-lg-pull-7 {\n    right: 58.33333333%;\n  }\n  .col-lg-pull-6 {\n    right: 50%;\n  }\n  .col-lg-pull-5 {\n    right: 41.66666667%;\n  }\n  .col-lg-pull-4 {\n    right: 33.33333333%;\n  }\n  .col-lg-pull-3 {\n    right: 25%;\n  }\n  .col-lg-pull-2 {\n    right: 16.66666667%;\n  }\n  .col-lg-pull-1 {\n    right: 8.33333333%;\n  }\n  .col-lg-pull-0 {\n    right: auto;\n  }\n  .col-lg-push-12 {\n    left: 100%;\n  }\n  .col-lg-push-11 {\n    left: 91.66666667%;\n  }\n  .col-lg-push-10 {\n    left: 83.33333333%;\n  }\n  .col-lg-push-9 {\n    left: 75%;\n  }\n  .col-lg-push-8 {\n    left: 66.66666667%;\n  }\n  .col-lg-push-7 {\n    left: 58.33333333%;\n  }\n  .col-lg-push-6 {\n    left: 50%;\n  }\n  .col-lg-push-5 {\n    left: 41.66666667%;\n  }\n  .col-lg-push-4 {\n    left: 33.33333333%;\n  }\n  .col-lg-push-3 {\n    left: 25%;\n  }\n  .col-lg-push-2 {\n    left: 16.66666667%;\n  }\n  .col-lg-push-1 {\n    left: 8.33333333%;\n  }\n  .col-lg-push-0 {\n    left: auto;\n  }\n  .col-lg-offset-12 {\n    margin-left: 100%;\n  }\n  .col-lg-offset-11 {\n    margin-left: 91.66666667%;\n  }\n  .col-lg-offset-10 {\n    margin-left: 83.33333333%;\n  }\n  .col-lg-offset-9 {\n    margin-left: 75%;\n  }\n  .col-lg-offset-8 {\n    margin-left: 66.66666667%;\n  }\n  .col-lg-offset-7 {\n    margin-left: 58.33333333%;\n  }\n  .col-lg-offset-6 {\n    margin-left: 50%;\n  }\n  .col-lg-offset-5 {\n    margin-left: 41.66666667%;\n  }\n  .col-lg-offset-4 {\n    margin-left: 33.33333333%;\n  }\n  .col-lg-offset-3 {\n    margin-left: 25%;\n  }\n  .col-lg-offset-2 {\n    margin-left: 16.66666667%;\n  }\n  .col-lg-offset-1 {\n    margin-left: 8.33333333%;\n  }\n  .col-lg-offset-0 {\n    margin-left: 0;\n  }\n}\ntable {\n  background-color: transparent;\n}\ncaption {\n  padding-top: 8px;\n  padding-bottom: 8px;\n  color: #777;\n  text-align: left;\n}\nth {\n  text-align: left;\n}\n.table {\n  width: 100%;\n  max-width: 100%;\n  margin-bottom: 20px;\n}\n.table > thead > tr > th,\n.table > tbody > tr > th,\n.table > tfoot > tr > th,\n.table > thead > tr > td,\n.table > tbody > tr > td,\n.table > tfoot > tr > td {\n  padding: 8px;\n  line-height: 1.42857143;\n  vertical-align: top;\n  border-top: 1px solid #ddd;\n}\n.table > thead > tr > th {\n  vertical-align: bottom;\n  border-bottom: 2px solid #ddd;\n}\n.table > caption + thead > tr:first-child > th,\n.table > colgroup + thead > tr:first-child > th,\n.table > thead:first-child > tr:first-child > th,\n.table > caption + thead > tr:first-child > td,\n.table > colgroup + thead > tr:first-child > td,\n.table > thead:first-child > tr:first-child > td {\n  border-top: 0;\n}\n.table > tbody + tbody {\n  border-top: 2px solid #ddd;\n}\n.table .table {\n  background-color: #fff;\n}\n.table-condensed > thead > tr > th,\n.table-condensed > tbody > tr > th,\n.table-condensed > tfoot > tr > th,\n.table-condensed > thead > tr > td,\n.table-condensed > tbody > tr > td,\n.table-condensed > tfoot > tr > td {\n  padding: 5px;\n}\n.table-bordered {\n  border: 1px solid #ddd;\n}\n.table-bordered > thead > tr > th,\n.table-bordered > tbody > tr > th,\n.table-bordered > tfoot > tr > th,\n.table-bordered > thead > tr > td,\n.table-bordered > tbody > tr > td,\n.table-bordered > tfoot > tr > td {\n  border: 1px solid #ddd;\n}\n.table-bordered > thead > tr > th,\n.table-bordered > thead > tr > td {\n  border-bottom-width: 2px;\n}\n.table-striped > tbody > tr:nth-of-type(odd) {\n  background-color: #f9f9f9;\n}\n.table-hover > tbody > tr:hover {\n  background-color: #f5f5f5;\n}\ntable col[class*=\"col-\"] {\n  position: static;\n  display: table-column;\n  float: none;\n}\ntable td[class*=\"col-\"],\ntable th[class*=\"col-\"] {\n  position: static;\n  display: table-cell;\n  float: none;\n}\n.table > thead > tr > td.active,\n.table > tbody > tr > td.active,\n.table > tfoot > tr > td.active,\n.table > thead > tr > th.active,\n.table > tbody > tr > th.active,\n.table > tfoot > tr > th.active,\n.table > thead > tr.active > td,\n.table > tbody > tr.active > td,\n.table > tfoot > tr.active > td,\n.table > thead > tr.active > th,\n.table > tbody > tr.active > th,\n.table > tfoot > tr.active > th {\n  background-color: #f5f5f5;\n}\n.table-hover > tbody > tr > td.active:hover,\n.table-hover > tbody > tr > th.active:hover,\n.table-hover > tbody > tr.active:hover > td,\n.table-hover > tbody > tr:hover > .active,\n.table-hover > tbody > tr.active:hover > th {\n  background-color: #e8e8e8;\n}\n.table > thead > tr > td.success,\n.table > tbody > tr > td.success,\n.table > tfoot > tr > td.success,\n.table > thead > tr > th.success,\n.table > tbody > tr > th.success,\n.table > tfoot > tr > th.success,\n.table > thead > tr.success > td,\n.table > tbody > tr.success > td,\n.table > tfoot > tr.success > td,\n.table > thead > tr.success > th,\n.table > tbody > tr.success > th,\n.table > tfoot > tr.success > th {\n  background-color: #dff0d8;\n}\n.table-hover > tbody > tr > td.success:hover,\n.table-hover > tbody > tr > th.success:hover,\n.table-hover > tbody > tr.success:hover > td,\n.table-hover > tbody > tr:hover > .success,\n.table-hover > tbody > tr.success:hover > th {\n  background-color: #d0e9c6;\n}\n.table > thead > tr > td.info,\n.table > tbody > tr > td.info,\n.table > tfoot > tr > td.info,\n.table > thead > tr > th.info,\n.table > tbody > tr > th.info,\n.table > tfoot > tr > th.info,\n.table > thead > tr.info > td,\n.table > tbody > tr.info > td,\n.table > tfoot > tr.info > td,\n.table > thead > tr.info > th,\n.table > tbody > tr.info > th,\n.table > tfoot > tr.info > th {\n  background-color: #d9edf7;\n}\n.table-hover > tbody > tr > td.info:hover,\n.table-hover > tbody > tr > th.info:hover,\n.table-hover > tbody > tr.info:hover > td,\n.table-hover > tbody > tr:hover > .info,\n.table-hover > tbody > tr.info:hover > th {\n  background-color: #c4e3f3;\n}\n.table > thead > tr > td.warning,\n.table > tbody > tr > td.warning,\n.table > tfoot > tr > td.warning,\n.table > thead > tr > th.warning,\n.table > tbody > tr > th.warning,\n.table > tfoot > tr > th.warning,\n.table > thead > tr.warning > td,\n.table > tbody > tr.warning > td,\n.table > tfoot > tr.warning > td,\n.table > thead > tr.warning > th,\n.table > tbody > tr.warning > th,\n.table > tfoot > tr.warning > th {\n  background-color: #fcf8e3;\n}\n.table-hover > tbody > tr > td.warning:hover,\n.table-hover > tbody > tr > th.warning:hover,\n.table-hover > tbody > tr.warning:hover > td,\n.table-hover > tbody > tr:hover > .warning,\n.table-hover > tbody > tr.warning:hover > th {\n  background-color: #faf2cc;\n}\n.table > thead > tr > td.danger,\n.table > tbody > tr > td.danger,\n.table > tfoot > tr > td.danger,\n.table > thead > tr > th.danger,\n.table > tbody > tr > th.danger,\n.table > tfoot > tr > th.danger,\n.table > thead > tr.danger > td,\n.table > tbody > tr.danger > td,\n.table > tfoot > tr.danger > td,\n.table > thead > tr.danger > th,\n.table > tbody > tr.danger > th,\n.table > tfoot > tr.danger > th {\n  background-color: #f2dede;\n}\n.table-hover > tbody > tr > td.danger:hover,\n.table-hover > tbody > tr > th.danger:hover,\n.table-hover > tbody > tr.danger:hover > td,\n.table-hover > tbody > tr:hover > .danger,\n.table-hover > tbody > tr.danger:hover > th {\n  background-color: #ebcccc;\n}\n.table-responsive {\n  min-height: .01%;\n  overflow-x: auto;\n}\n@media screen and (max-width: 767px) {\n  .table-responsive {\n    width: 100%;\n    margin-bottom: 15px;\n    overflow-y: hidden;\n    -ms-overflow-style: -ms-autohiding-scrollbar;\n    border: 1px solid #ddd;\n  }\n  .table-responsive > .table {\n    margin-bottom: 0;\n  }\n  .table-responsive > .table > thead > tr > th,\n  .table-responsive > .table > tbody > tr > th,\n  .table-responsive > .table > tfoot > tr > th,\n  .table-responsive > .table > thead > tr > td,\n  .table-responsive > .table > tbody > tr > td,\n  .table-responsive > .table > tfoot > tr > td {\n    white-space: nowrap;\n  }\n  .table-responsive > .table-bordered {\n    border: 0;\n  }\n  .table-responsive > .table-bordered > thead > tr > th:first-child,\n  .table-responsive > .table-bordered > tbody > tr > th:first-child,\n  .table-responsive > .table-bordered > tfoot > tr > th:first-child,\n  .table-responsive > .table-bordered > thead > tr > td:first-child,\n  .table-responsive > .table-bordered > tbody > tr > td:first-child,\n  .table-responsive > .table-bordered > tfoot > tr > td:first-child {\n    border-left: 0;\n  }\n  .table-responsive > .table-bordered > thead > tr > th:last-child,\n  .table-responsive > .table-bordered > tbody > tr > th:last-child,\n  .table-responsive > .table-bordered > tfoot > tr > th:last-child,\n  .table-responsive > .table-bordered > thead > tr > td:last-child,\n  .table-responsive > .table-bordered > tbody > tr > td:last-child,\n  .table-responsive > .table-bordered > tfoot > tr > td:last-child {\n    border-right: 0;\n  }\n  .table-responsive > .table-bordered > tbody > tr:last-child > th,\n  .table-responsive > .table-bordered > tfoot > tr:last-child > th,\n  .table-responsive > .table-bordered > tbody > tr:last-child > td,\n  .table-responsive > .table-bordered > tfoot > tr:last-child > td {\n    border-bottom: 0;\n  }\n}\nfieldset {\n  min-width: 0;\n  padding: 0;\n  margin: 0;\n  border: 0;\n}\nlegend {\n  display: block;\n  width: 100%;\n  padding: 0;\n  margin-bottom: 20px;\n  font-size: 21px;\n  line-height: inherit;\n  color: #333;\n  border: 0;\n  border-bottom: 1px solid #e5e5e5;\n}\nlabel {\n  display: inline-block;\n  max-width: 100%;\n  margin-bottom: 5px;\n  font-weight: bold;\n}\ninput[type=\"search\"] {\n  -webkit-box-sizing: border-box;\n     -moz-box-sizing: border-box;\n          box-sizing: border-box;\n}\ninput[type=\"radio\"],\ninput[type=\"checkbox\"] {\n  margin: 4px 0 0;\n  margin-top: 1px \\9;\n  line-height: normal;\n}\ninput[type=\"file\"] {\n  display: block;\n}\ninput[type=\"range\"] {\n  display: block;\n  width: 100%;\n}\nselect[multiple],\nselect[size] {\n  height: auto;\n}\ninput[type=\"file\"]:focus,\ninput[type=\"radio\"]:focus,\ninput[type=\"checkbox\"]:focus {\n  outline: thin dotted;\n  outline: 5px auto -webkit-focus-ring-color;\n  outline-offset: -2px;\n}\noutput {\n  display: block;\n  padding-top: 7px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  color: #555;\n}\n.form-control {\n  display: block;\n  width: 100%;\n  height: 34px;\n  padding: 6px 12px;\n  font-size: 14px;\n  line-height: 1.42857143;\n  color: #555;\n  background-color: #fff;\n  background-image: none;\n  border: 1px solid #ccc;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n  -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;\n       -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n          transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;\n}\n.form-control:focus {\n  border-color: #66afe9;\n  outline: 0;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);\n          box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);\n}\n.form-control::-moz-placeholder {\n  color: #999;\n  opacity: 1;\n}\n.form-control:-ms-input-placeholder {\n  color: #999;\n}\n.form-control::-webkit-input-placeholder {\n  color: #999;\n}\n.form-control::-ms-expand {\n  background-color: transparent;\n  border: 0;\n}\n.form-control[disabled],\n.form-control[readonly],\nfieldset[disabled] .form-control {\n  background-color: #eee;\n  opacity: 1;\n}\n.form-control[disabled],\nfieldset[disabled] .form-control {\n  cursor: not-allowed;\n}\ntextarea.form-control {\n  height: auto;\n}\ninput[type=\"search\"] {\n  -webkit-appearance: none;\n}\n@media screen and (-webkit-min-device-pixel-ratio: 0) {\n  input[type=\"date\"].form-control,\n  input[type=\"time\"].form-control,\n  input[type=\"datetime-local\"].form-control,\n  input[type=\"month\"].form-control {\n    line-height: 34px;\n  }\n  input[type=\"date\"].input-sm,\n  input[type=\"time\"].input-sm,\n  input[type=\"datetime-local\"].input-sm,\n  input[type=\"month\"].input-sm,\n  .input-group-sm input[type=\"date\"],\n  .input-group-sm input[type=\"time\"],\n  .input-group-sm input[type=\"datetime-local\"],\n  .input-group-sm input[type=\"month\"] {\n    line-height: 30px;\n  }\n  input[type=\"date\"].input-lg,\n  input[type=\"time\"].input-lg,\n  input[type=\"datetime-local\"].input-lg,\n  input[type=\"month\"].input-lg,\n  .input-group-lg input[type=\"date\"],\n  .input-group-lg input[type=\"time\"],\n  .input-group-lg input[type=\"datetime-local\"],\n  .input-group-lg input[type=\"month\"] {\n    line-height: 46px;\n  }\n}\n.form-group {\n  margin-bottom: 15px;\n}\n.radio,\n.checkbox {\n  position: relative;\n  display: block;\n  margin-top: 10px;\n  margin-bottom: 10px;\n}\n.radio label,\n.checkbox label {\n  min-height: 20px;\n  padding-left: 20px;\n  margin-bottom: 0;\n  font-weight: normal;\n  cursor: pointer;\n}\n.radio input[type=\"radio\"],\n.radio-inline input[type=\"radio\"],\n.checkbox input[type=\"checkbox\"],\n.checkbox-inline input[type=\"checkbox\"] {\n  position: absolute;\n  margin-top: 4px \\9;\n  margin-left: -20px;\n}\n.radio + .radio,\n.checkbox + .checkbox {\n  margin-top: -5px;\n}\n.radio-inline,\n.checkbox-inline {\n  position: relative;\n  display: inline-block;\n  padding-left: 20px;\n  margin-bottom: 0;\n  font-weight: normal;\n  vertical-align: middle;\n  cursor: pointer;\n}\n.radio-inline + .radio-inline,\n.checkbox-inline + .checkbox-inline {\n  margin-top: 0;\n  margin-left: 10px;\n}\ninput[type=\"radio\"][disabled],\ninput[type=\"checkbox\"][disabled],\ninput[type=\"radio\"].disabled,\ninput[type=\"checkbox\"].disabled,\nfieldset[disabled] input[type=\"radio\"],\nfieldset[disabled] input[type=\"checkbox\"] {\n  cursor: not-allowed;\n}\n.radio-inline.disabled,\n.checkbox-inline.disabled,\nfieldset[disabled] .radio-inline,\nfieldset[disabled] .checkbox-inline {\n  cursor: not-allowed;\n}\n.radio.disabled label,\n.checkbox.disabled label,\nfieldset[disabled] .radio label,\nfieldset[disabled] .checkbox label {\n  cursor: not-allowed;\n}\n.form-control-static {\n  min-height: 34px;\n  padding-top: 7px;\n  padding-bottom: 7px;\n  margin-bottom: 0;\n}\n.form-control-static.input-lg,\n.form-control-static.input-sm {\n  padding-right: 0;\n  padding-left: 0;\n}\n.input-sm {\n  height: 30px;\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n}\nselect.input-sm {\n  height: 30px;\n  line-height: 30px;\n}\ntextarea.input-sm,\nselect[multiple].input-sm {\n  height: auto;\n}\n.form-group-sm .form-control {\n  height: 30px;\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n}\n.form-group-sm select.form-control {\n  height: 30px;\n  line-height: 30px;\n}\n.form-group-sm textarea.form-control,\n.form-group-sm select[multiple].form-control {\n  height: auto;\n}\n.form-group-sm .form-control-static {\n  height: 30px;\n  min-height: 32px;\n  padding: 6px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n}\n.input-lg {\n  height: 46px;\n  padding: 10px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n  border-radius: 6px;\n}\nselect.input-lg {\n  height: 46px;\n  line-height: 46px;\n}\ntextarea.input-lg,\nselect[multiple].input-lg {\n  height: auto;\n}\n.form-group-lg .form-control {\n  height: 46px;\n  padding: 10px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n  border-radius: 6px;\n}\n.form-group-lg select.form-control {\n  height: 46px;\n  line-height: 46px;\n}\n.form-group-lg textarea.form-control,\n.form-group-lg select[multiple].form-control {\n  height: auto;\n}\n.form-group-lg .form-control-static {\n  height: 46px;\n  min-height: 38px;\n  padding: 11px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n}\n.has-feedback {\n  position: relative;\n}\n.has-feedback .form-control {\n  padding-right: 42.5px;\n}\n.form-control-feedback {\n  position: absolute;\n  top: 0;\n  right: 0;\n  z-index: 2;\n  display: block;\n  width: 34px;\n  height: 34px;\n  line-height: 34px;\n  text-align: center;\n  pointer-events: none;\n}\n.input-lg + .form-control-feedback,\n.input-group-lg + .form-control-feedback,\n.form-group-lg .form-control + .form-control-feedback {\n  width: 46px;\n  height: 46px;\n  line-height: 46px;\n}\n.input-sm + .form-control-feedback,\n.input-group-sm + .form-control-feedback,\n.form-group-sm .form-control + .form-control-feedback {\n  width: 30px;\n  height: 30px;\n  line-height: 30px;\n}\n.has-success .help-block,\n.has-success .control-label,\n.has-success .radio,\n.has-success .checkbox,\n.has-success .radio-inline,\n.has-success .checkbox-inline,\n.has-success.radio label,\n.has-success.checkbox label,\n.has-success.radio-inline label,\n.has-success.checkbox-inline label {\n  color: #3c763d;\n}\n.has-success .form-control {\n  border-color: #3c763d;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n}\n.has-success .form-control:focus {\n  border-color: #2b542c;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;\n}\n.has-success .input-group-addon {\n  color: #3c763d;\n  background-color: #dff0d8;\n  border-color: #3c763d;\n}\n.has-success .form-control-feedback {\n  color: #3c763d;\n}\n.has-warning .help-block,\n.has-warning .control-label,\n.has-warning .radio,\n.has-warning .checkbox,\n.has-warning .radio-inline,\n.has-warning .checkbox-inline,\n.has-warning.radio label,\n.has-warning.checkbox label,\n.has-warning.radio-inline label,\n.has-warning.checkbox-inline label {\n  color: #8a6d3b;\n}\n.has-warning .form-control {\n  border-color: #8a6d3b;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n}\n.has-warning .form-control:focus {\n  border-color: #66512c;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;\n}\n.has-warning .input-group-addon {\n  color: #8a6d3b;\n  background-color: #fcf8e3;\n  border-color: #8a6d3b;\n}\n.has-warning .form-control-feedback {\n  color: #8a6d3b;\n}\n.has-error .help-block,\n.has-error .control-label,\n.has-error .radio,\n.has-error .checkbox,\n.has-error .radio-inline,\n.has-error .checkbox-inline,\n.has-error.radio label,\n.has-error.checkbox label,\n.has-error.radio-inline label,\n.has-error.checkbox-inline label {\n  color: #a94442;\n}\n.has-error .form-control {\n  border-color: #a94442;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);\n}\n.has-error .form-control:focus {\n  border-color: #843534;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;\n}\n.has-error .input-group-addon {\n  color: #a94442;\n  background-color: #f2dede;\n  border-color: #a94442;\n}\n.has-error .form-control-feedback {\n  color: #a94442;\n}\n.has-feedback label ~ .form-control-feedback {\n  top: 25px;\n}\n.has-feedback label.sr-only ~ .form-control-feedback {\n  top: 0;\n}\n.help-block {\n  display: block;\n  margin-top: 5px;\n  margin-bottom: 10px;\n  color: #737373;\n}\n@media (min-width: 768px) {\n  .form-inline .form-group {\n    display: inline-block;\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .form-inline .form-control {\n    display: inline-block;\n    width: auto;\n    vertical-align: middle;\n  }\n  .form-inline .form-control-static {\n    display: inline-block;\n  }\n  .form-inline .input-group {\n    display: inline-table;\n    vertical-align: middle;\n  }\n  .form-inline .input-group .input-group-addon,\n  .form-inline .input-group .input-group-btn,\n  .form-inline .input-group .form-control {\n    width: auto;\n  }\n  .form-inline .input-group > .form-control {\n    width: 100%;\n  }\n  .form-inline .control-label {\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .form-inline .radio,\n  .form-inline .checkbox {\n    display: inline-block;\n    margin-top: 0;\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .form-inline .radio label,\n  .form-inline .checkbox label {\n    padding-left: 0;\n  }\n  .form-inline .radio input[type=\"radio\"],\n  .form-inline .checkbox input[type=\"checkbox\"] {\n    position: relative;\n    margin-left: 0;\n  }\n  .form-inline .has-feedback .form-control-feedback {\n    top: 0;\n  }\n}\n.form-horizontal .radio,\n.form-horizontal .checkbox,\n.form-horizontal .radio-inline,\n.form-horizontal .checkbox-inline {\n  padding-top: 7px;\n  margin-top: 0;\n  margin-bottom: 0;\n}\n.form-horizontal .radio,\n.form-horizontal .checkbox {\n  min-height: 27px;\n}\n.form-horizontal .form-group {\n  margin-right: -15px;\n  margin-left: -15px;\n}\n@media (min-width: 768px) {\n  .form-horizontal .control-label {\n    padding-top: 7px;\n    margin-bottom: 0;\n    text-align: right;\n  }\n}\n.form-horizontal .has-feedback .form-control-feedback {\n  right: 15px;\n}\n@media (min-width: 768px) {\n  .form-horizontal .form-group-lg .control-label {\n    padding-top: 11px;\n    font-size: 18px;\n  }\n}\n@media (min-width: 768px) {\n  .form-horizontal .form-group-sm .control-label {\n    padding-top: 6px;\n    font-size: 12px;\n  }\n}\n.btn {\n  display: inline-block;\n  padding: 6px 12px;\n  margin-bottom: 0;\n  font-size: 14px;\n  font-weight: normal;\n  line-height: 1.42857143;\n  text-align: center;\n  white-space: nowrap;\n  vertical-align: middle;\n  -ms-touch-action: manipulation;\n      touch-action: manipulation;\n  cursor: pointer;\n  -webkit-user-select: none;\n     -moz-user-select: none;\n      -ms-user-select: none;\n          user-select: none;\n  background-image: none;\n  border: 1px solid transparent;\n  border-radius: 4px;\n}\n.btn:focus,\n.btn:active:focus,\n.btn.active:focus,\n.btn.focus,\n.btn:active.focus,\n.btn.active.focus {\n  outline: thin dotted;\n  outline: 5px auto -webkit-focus-ring-color;\n  outline-offset: -2px;\n}\n.btn:hover,\n.btn:focus,\n.btn.focus {\n  color: #333;\n  text-decoration: none;\n}\n.btn:active,\n.btn.active {\n  background-image: none;\n  outline: 0;\n  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n}\n.btn.disabled,\n.btn[disabled],\nfieldset[disabled] .btn {\n  cursor: not-allowed;\n  filter: alpha(opacity=65);\n  -webkit-box-shadow: none;\n          box-shadow: none;\n  opacity: .65;\n}\na.btn.disabled,\nfieldset[disabled] a.btn {\n  pointer-events: none;\n}\n.btn-default {\n  color: #333;\n  background-color: #fff;\n  border-color: #ccc;\n}\n.btn-default:focus,\n.btn-default.focus {\n  color: #333;\n  background-color: #e6e6e6;\n  border-color: #8c8c8c;\n}\n.btn-default:hover {\n  color: #333;\n  background-color: #e6e6e6;\n  border-color: #adadad;\n}\n.btn-default:active,\n.btn-default.active,\n.open > .dropdown-toggle.btn-default {\n  color: #333;\n  background-color: #e6e6e6;\n  border-color: #adadad;\n}\n.btn-default:active:hover,\n.btn-default.active:hover,\n.open > .dropdown-toggle.btn-default:hover,\n.btn-default:active:focus,\n.btn-default.active:focus,\n.open > .dropdown-toggle.btn-default:focus,\n.btn-default:active.focus,\n.btn-default.active.focus,\n.open > .dropdown-toggle.btn-default.focus {\n  color: #333;\n  background-color: #d4d4d4;\n  border-color: #8c8c8c;\n}\n.btn-default:active,\n.btn-default.active,\n.open > .dropdown-toggle.btn-default {\n  background-image: none;\n}\n.btn-default.disabled:hover,\n.btn-default[disabled]:hover,\nfieldset[disabled] .btn-default:hover,\n.btn-default.disabled:focus,\n.btn-default[disabled]:focus,\nfieldset[disabled] .btn-default:focus,\n.btn-default.disabled.focus,\n.btn-default[disabled].focus,\nfieldset[disabled] .btn-default.focus {\n  background-color: #fff;\n  border-color: #ccc;\n}\n.btn-default .badge {\n  color: #fff;\n  background-color: #333;\n}\n.btn-primary {\n  color: #fff;\n  background-color: #337ab7;\n  border-color: #2e6da4;\n}\n.btn-primary:focus,\n.btn-primary.focus {\n  color: #fff;\n  background-color: #286090;\n  border-color: #122b40;\n}\n.btn-primary:hover {\n  color: #fff;\n  background-color: #286090;\n  border-color: #204d74;\n}\n.btn-primary:active,\n.btn-primary.active,\n.open > .dropdown-toggle.btn-primary {\n  color: #fff;\n  background-color: #286090;\n  border-color: #204d74;\n}\n.btn-primary:active:hover,\n.btn-primary.active:hover,\n.open > .dropdown-toggle.btn-primary:hover,\n.btn-primary:active:focus,\n.btn-primary.active:focus,\n.open > .dropdown-toggle.btn-primary:focus,\n.btn-primary:active.focus,\n.btn-primary.active.focus,\n.open > .dropdown-toggle.btn-primary.focus {\n  color: #fff;\n  background-color: #204d74;\n  border-color: #122b40;\n}\n.btn-primary:active,\n.btn-primary.active,\n.open > .dropdown-toggle.btn-primary {\n  background-image: none;\n}\n.btn-primary.disabled:hover,\n.btn-primary[disabled]:hover,\nfieldset[disabled] .btn-primary:hover,\n.btn-primary.disabled:focus,\n.btn-primary[disabled]:focus,\nfieldset[disabled] .btn-primary:focus,\n.btn-primary.disabled.focus,\n.btn-primary[disabled].focus,\nfieldset[disabled] .btn-primary.focus {\n  background-color: #337ab7;\n  border-color: #2e6da4;\n}\n.btn-primary .badge {\n  color: #337ab7;\n  background-color: #fff;\n}\n.btn-success {\n  color: #fff;\n  background-color: #5cb85c;\n  border-color: #4cae4c;\n}\n.btn-success:focus,\n.btn-success.focus {\n  color: #fff;\n  background-color: #449d44;\n  border-color: #255625;\n}\n.btn-success:hover {\n  color: #fff;\n  background-color: #449d44;\n  border-color: #398439;\n}\n.btn-success:active,\n.btn-success.active,\n.open > .dropdown-toggle.btn-success {\n  color: #fff;\n  background-color: #449d44;\n  border-color: #398439;\n}\n.btn-success:active:hover,\n.btn-success.active:hover,\n.open > .dropdown-toggle.btn-success:hover,\n.btn-success:active:focus,\n.btn-success.active:focus,\n.open > .dropdown-toggle.btn-success:focus,\n.btn-success:active.focus,\n.btn-success.active.focus,\n.open > .dropdown-toggle.btn-success.focus {\n  color: #fff;\n  background-color: #398439;\n  border-color: #255625;\n}\n.btn-success:active,\n.btn-success.active,\n.open > .dropdown-toggle.btn-success {\n  background-image: none;\n}\n.btn-success.disabled:hover,\n.btn-success[disabled]:hover,\nfieldset[disabled] .btn-success:hover,\n.btn-success.disabled:focus,\n.btn-success[disabled]:focus,\nfieldset[disabled] .btn-success:focus,\n.btn-success.disabled.focus,\n.btn-success[disabled].focus,\nfieldset[disabled] .btn-success.focus {\n  background-color: #5cb85c;\n  border-color: #4cae4c;\n}\n.btn-success .badge {\n  color: #5cb85c;\n  background-color: #fff;\n}\n.btn-info {\n  color: #fff;\n  background-color: #5bc0de;\n  border-color: #46b8da;\n}\n.btn-info:focus,\n.btn-info.focus {\n  color: #fff;\n  background-color: #31b0d5;\n  border-color: #1b6d85;\n}\n.btn-info:hover {\n  color: #fff;\n  background-color: #31b0d5;\n  border-color: #269abc;\n}\n.btn-info:active,\n.btn-info.active,\n.open > .dropdown-toggle.btn-info {\n  color: #fff;\n  background-color: #31b0d5;\n  border-color: #269abc;\n}\n.btn-info:active:hover,\n.btn-info.active:hover,\n.open > .dropdown-toggle.btn-info:hover,\n.btn-info:active:focus,\n.btn-info.active:focus,\n.open > .dropdown-toggle.btn-info:focus,\n.btn-info:active.focus,\n.btn-info.active.focus,\n.open > .dropdown-toggle.btn-info.focus {\n  color: #fff;\n  background-color: #269abc;\n  border-color: #1b6d85;\n}\n.btn-info:active,\n.btn-info.active,\n.open > .dropdown-toggle.btn-info {\n  background-image: none;\n}\n.btn-info.disabled:hover,\n.btn-info[disabled]:hover,\nfieldset[disabled] .btn-info:hover,\n.btn-info.disabled:focus,\n.btn-info[disabled]:focus,\nfieldset[disabled] .btn-info:focus,\n.btn-info.disabled.focus,\n.btn-info[disabled].focus,\nfieldset[disabled] .btn-info.focus {\n  background-color: #5bc0de;\n  border-color: #46b8da;\n}\n.btn-info .badge {\n  color: #5bc0de;\n  background-color: #fff;\n}\n.btn-warning {\n  color: #fff;\n  background-color: #f0ad4e;\n  border-color: #eea236;\n}\n.btn-warning:focus,\n.btn-warning.focus {\n  color: #fff;\n  background-color: #ec971f;\n  border-color: #985f0d;\n}\n.btn-warning:hover {\n  color: #fff;\n  background-color: #ec971f;\n  border-color: #d58512;\n}\n.btn-warning:active,\n.btn-warning.active,\n.open > .dropdown-toggle.btn-warning {\n  color: #fff;\n  background-color: #ec971f;\n  border-color: #d58512;\n}\n.btn-warning:active:hover,\n.btn-warning.active:hover,\n.open > .dropdown-toggle.btn-warning:hover,\n.btn-warning:active:focus,\n.btn-warning.active:focus,\n.open > .dropdown-toggle.btn-warning:focus,\n.btn-warning:active.focus,\n.btn-warning.active.focus,\n.open > .dropdown-toggle.btn-warning.focus {\n  color: #fff;\n  background-color: #d58512;\n  border-color: #985f0d;\n}\n.btn-warning:active,\n.btn-warning.active,\n.open > .dropdown-toggle.btn-warning {\n  background-image: none;\n}\n.btn-warning.disabled:hover,\n.btn-warning[disabled]:hover,\nfieldset[disabled] .btn-warning:hover,\n.btn-warning.disabled:focus,\n.btn-warning[disabled]:focus,\nfieldset[disabled] .btn-warning:focus,\n.btn-warning.disabled.focus,\n.btn-warning[disabled].focus,\nfieldset[disabled] .btn-warning.focus {\n  background-color: #f0ad4e;\n  border-color: #eea236;\n}\n.btn-warning .badge {\n  color: #f0ad4e;\n  background-color: #fff;\n}\n.btn-danger {\n  color: #fff;\n  background-color: #d9534f;\n  border-color: #d43f3a;\n}\n.btn-danger:focus,\n.btn-danger.focus {\n  color: #fff;\n  background-color: #c9302c;\n  border-color: #761c19;\n}\n.btn-danger:hover {\n  color: #fff;\n  background-color: #c9302c;\n  border-color: #ac2925;\n}\n.btn-danger:active,\n.btn-danger.active,\n.open > .dropdown-toggle.btn-danger {\n  color: #fff;\n  background-color: #c9302c;\n  border-color: #ac2925;\n}\n.btn-danger:active:hover,\n.btn-danger.active:hover,\n.open > .dropdown-toggle.btn-danger:hover,\n.btn-danger:active:focus,\n.btn-danger.active:focus,\n.open > .dropdown-toggle.btn-danger:focus,\n.btn-danger:active.focus,\n.btn-danger.active.focus,\n.open > .dropdown-toggle.btn-danger.focus {\n  color: #fff;\n  background-color: #ac2925;\n  border-color: #761c19;\n}\n.btn-danger:active,\n.btn-danger.active,\n.open > .dropdown-toggle.btn-danger {\n  background-image: none;\n}\n.btn-danger.disabled:hover,\n.btn-danger[disabled]:hover,\nfieldset[disabled] .btn-danger:hover,\n.btn-danger.disabled:focus,\n.btn-danger[disabled]:focus,\nfieldset[disabled] .btn-danger:focus,\n.btn-danger.disabled.focus,\n.btn-danger[disabled].focus,\nfieldset[disabled] .btn-danger.focus {\n  background-color: #d9534f;\n  border-color: #d43f3a;\n}\n.btn-danger .badge {\n  color: #d9534f;\n  background-color: #fff;\n}\n.btn-link {\n  font-weight: normal;\n  color: #337ab7;\n  border-radius: 0;\n}\n.btn-link,\n.btn-link:active,\n.btn-link.active,\n.btn-link[disabled],\nfieldset[disabled] .btn-link {\n  background-color: transparent;\n  -webkit-box-shadow: none;\n          box-shadow: none;\n}\n.btn-link,\n.btn-link:hover,\n.btn-link:focus,\n.btn-link:active {\n  border-color: transparent;\n}\n.btn-link:hover,\n.btn-link:focus {\n  color: #23527c;\n  text-decoration: underline;\n  background-color: transparent;\n}\n.btn-link[disabled]:hover,\nfieldset[disabled] .btn-link:hover,\n.btn-link[disabled]:focus,\nfieldset[disabled] .btn-link:focus {\n  color: #777;\n  text-decoration: none;\n}\n.btn-lg,\n.btn-group-lg > .btn {\n  padding: 10px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n  border-radius: 6px;\n}\n.btn-sm,\n.btn-group-sm > .btn {\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n}\n.btn-xs,\n.btn-group-xs > .btn {\n  padding: 1px 5px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n}\n.btn-block {\n  display: block;\n  width: 100%;\n}\n.btn-block + .btn-block {\n  margin-top: 5px;\n}\ninput[type=\"submit\"].btn-block,\ninput[type=\"reset\"].btn-block,\ninput[type=\"button\"].btn-block {\n  width: 100%;\n}\n.fade {\n  opacity: 0;\n  -webkit-transition: opacity .15s linear;\n       -o-transition: opacity .15s linear;\n          transition: opacity .15s linear;\n}\n.fade.in {\n  opacity: 1;\n}\n.collapse {\n  display: none;\n}\n.collapse.in {\n  display: block;\n}\ntr.collapse.in {\n  display: table-row;\n}\ntbody.collapse.in {\n  display: table-row-group;\n}\n.collapsing {\n  position: relative;\n  height: 0;\n  overflow: hidden;\n  -webkit-transition-timing-function: ease;\n       -o-transition-timing-function: ease;\n          transition-timing-function: ease;\n  -webkit-transition-duration: .35s;\n       -o-transition-duration: .35s;\n          transition-duration: .35s;\n  -webkit-transition-property: height, visibility;\n       -o-transition-property: height, visibility;\n          transition-property: height, visibility;\n}\n.caret {\n  display: inline-block;\n  width: 0;\n  height: 0;\n  margin-left: 2px;\n  vertical-align: middle;\n  border-top: 4px dashed;\n  border-top: 4px solid \\9;\n  border-right: 4px solid transparent;\n  border-left: 4px solid transparent;\n}\n.dropup,\n.dropdown {\n  position: relative;\n}\n.dropdown-toggle:focus {\n  outline: 0;\n}\n.dropdown-menu {\n  position: absolute;\n  top: 100%;\n  left: 0;\n  z-index: 1000;\n  display: none;\n  float: left;\n  min-width: 160px;\n  padding: 5px 0;\n  margin: 2px 0 0;\n  font-size: 14px;\n  text-align: left;\n  list-style: none;\n  background-color: #fff;\n  -webkit-background-clip: padding-box;\n          background-clip: padding-box;\n  border: 1px solid #ccc;\n  border: 1px solid rgba(0, 0, 0, .15);\n  border-radius: 4px;\n  -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);\n          box-shadow: 0 6px 12px rgba(0, 0, 0, .175);\n}\n.dropdown-menu.pull-right {\n  right: 0;\n  left: auto;\n}\n.dropdown-menu .divider {\n  height: 1px;\n  margin: 9px 0;\n  overflow: hidden;\n  background-color: #e5e5e5;\n}\n.dropdown-menu > li > a {\n  display: block;\n  padding: 3px 20px;\n  clear: both;\n  font-weight: normal;\n  line-height: 1.42857143;\n  color: #333;\n  white-space: nowrap;\n}\n.dropdown-menu > li > a:hover,\n.dropdown-menu > li > a:focus {\n  color: #262626;\n  text-decoration: none;\n  background-color: #f5f5f5;\n}\n.dropdown-menu > .active > a,\n.dropdown-menu > .active > a:hover,\n.dropdown-menu > .active > a:focus {\n  color: #fff;\n  text-decoration: none;\n  background-color: #337ab7;\n  outline: 0;\n}\n.dropdown-menu > .disabled > a,\n.dropdown-menu > .disabled > a:hover,\n.dropdown-menu > .disabled > a:focus {\n  color: #777;\n}\n.dropdown-menu > .disabled > a:hover,\n.dropdown-menu > .disabled > a:focus {\n  text-decoration: none;\n  cursor: not-allowed;\n  background-color: transparent;\n  background-image: none;\n  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);\n}\n.open > .dropdown-menu {\n  display: block;\n}\n.open > a {\n  outline: 0;\n}\n.dropdown-menu-right {\n  right: 0;\n  left: auto;\n}\n.dropdown-menu-left {\n  right: auto;\n  left: 0;\n}\n.dropdown-header {\n  display: block;\n  padding: 3px 20px;\n  font-size: 12px;\n  line-height: 1.42857143;\n  color: #777;\n  white-space: nowrap;\n}\n.dropdown-backdrop {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 990;\n}\n.pull-right > .dropdown-menu {\n  right: 0;\n  left: auto;\n}\n.dropup .caret,\n.navbar-fixed-bottom .dropdown .caret {\n  content: \"\";\n  border-top: 0;\n  border-bottom: 4px dashed;\n  border-bottom: 4px solid \\9;\n}\n.dropup .dropdown-menu,\n.navbar-fixed-bottom .dropdown .dropdown-menu {\n  top: auto;\n  bottom: 100%;\n  margin-bottom: 2px;\n}\n@media (min-width: 768px) {\n  .navbar-right .dropdown-menu {\n    right: 0;\n    left: auto;\n  }\n  .navbar-right .dropdown-menu-left {\n    right: auto;\n    left: 0;\n  }\n}\n.btn-group,\n.btn-group-vertical {\n  position: relative;\n  display: inline-block;\n  vertical-align: middle;\n}\n.btn-group > .btn,\n.btn-group-vertical > .btn {\n  position: relative;\n  float: left;\n}\n.btn-group > .btn:hover,\n.btn-group-vertical > .btn:hover,\n.btn-group > .btn:focus,\n.btn-group-vertical > .btn:focus,\n.btn-group > .btn:active,\n.btn-group-vertical > .btn:active,\n.btn-group > .btn.active,\n.btn-group-vertical > .btn.active {\n  z-index: 2;\n}\n.btn-group .btn + .btn,\n.btn-group .btn + .btn-group,\n.btn-group .btn-group + .btn,\n.btn-group .btn-group + .btn-group {\n  margin-left: -1px;\n}\n.btn-toolbar {\n  margin-left: -5px;\n}\n.btn-toolbar .btn,\n.btn-toolbar .btn-group,\n.btn-toolbar .input-group {\n  float: left;\n}\n.btn-toolbar > .btn,\n.btn-toolbar > .btn-group,\n.btn-toolbar > .input-group {\n  margin-left: 5px;\n}\n.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {\n  border-radius: 0;\n}\n.btn-group > .btn:first-child {\n  margin-left: 0;\n}\n.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {\n  border-top-right-radius: 0;\n  border-bottom-right-radius: 0;\n}\n.btn-group > .btn:last-child:not(:first-child),\n.btn-group > .dropdown-toggle:not(:first-child) {\n  border-top-left-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.btn-group > .btn-group {\n  float: left;\n}\n.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {\n  border-radius: 0;\n}\n.btn-group > .btn-group:first-child:not(:last-child) > .btn:last-child,\n.btn-group > .btn-group:first-child:not(:last-child) > .dropdown-toggle {\n  border-top-right-radius: 0;\n  border-bottom-right-radius: 0;\n}\n.btn-group > .btn-group:last-child:not(:first-child) > .btn:first-child {\n  border-top-left-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.btn-group .dropdown-toggle:active,\n.btn-group.open .dropdown-toggle {\n  outline: 0;\n}\n.btn-group > .btn + .dropdown-toggle {\n  padding-right: 8px;\n  padding-left: 8px;\n}\n.btn-group > .btn-lg + .dropdown-toggle {\n  padding-right: 12px;\n  padding-left: 12px;\n}\n.btn-group.open .dropdown-toggle {\n  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);\n}\n.btn-group.open .dropdown-toggle.btn-link {\n  -webkit-box-shadow: none;\n          box-shadow: none;\n}\n.btn .caret {\n  margin-left: 0;\n}\n.btn-lg .caret {\n  border-width: 5px 5px 0;\n  border-bottom-width: 0;\n}\n.dropup .btn-lg .caret {\n  border-width: 0 5px 5px;\n}\n.btn-group-vertical > .btn,\n.btn-group-vertical > .btn-group,\n.btn-group-vertical > .btn-group > .btn {\n  display: block;\n  float: none;\n  width: 100%;\n  max-width: 100%;\n}\n.btn-group-vertical > .btn-group > .btn {\n  float: none;\n}\n.btn-group-vertical > .btn + .btn,\n.btn-group-vertical > .btn + .btn-group,\n.btn-group-vertical > .btn-group + .btn,\n.btn-group-vertical > .btn-group + .btn-group {\n  margin-top: -1px;\n  margin-left: 0;\n}\n.btn-group-vertical > .btn:not(:first-child):not(:last-child) {\n  border-radius: 0;\n}\n.btn-group-vertical > .btn:first-child:not(:last-child) {\n  border-top-left-radius: 4px;\n  border-top-right-radius: 4px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.btn-group-vertical > .btn:last-child:not(:first-child) {\n  border-top-left-radius: 0;\n  border-top-right-radius: 0;\n  border-bottom-right-radius: 4px;\n  border-bottom-left-radius: 4px;\n}\n.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {\n  border-radius: 0;\n}\n.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child,\n.btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle {\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {\n  border-top-left-radius: 0;\n  border-top-right-radius: 0;\n}\n.btn-group-justified {\n  display: table;\n  width: 100%;\n  table-layout: fixed;\n  border-collapse: separate;\n}\n.btn-group-justified > .btn,\n.btn-group-justified > .btn-group {\n  display: table-cell;\n  float: none;\n  width: 1%;\n}\n.btn-group-justified > .btn-group .btn {\n  width: 100%;\n}\n.btn-group-justified > .btn-group .dropdown-menu {\n  left: auto;\n}\n[data-toggle=\"buttons\"] > .btn input[type=\"radio\"],\n[data-toggle=\"buttons\"] > .btn-group > .btn input[type=\"radio\"],\n[data-toggle=\"buttons\"] > .btn input[type=\"checkbox\"],\n[data-toggle=\"buttons\"] > .btn-group > .btn input[type=\"checkbox\"] {\n  position: absolute;\n  clip: rect(0, 0, 0, 0);\n  pointer-events: none;\n}\n.input-group {\n  position: relative;\n  display: table;\n  border-collapse: separate;\n}\n.input-group[class*=\"col-\"] {\n  float: none;\n  padding-right: 0;\n  padding-left: 0;\n}\n.input-group .form-control {\n  position: relative;\n  z-index: 2;\n  float: left;\n  width: 100%;\n  margin-bottom: 0;\n}\n.input-group .form-control:focus {\n  z-index: 3;\n}\n.input-group-lg > .form-control,\n.input-group-lg > .input-group-addon,\n.input-group-lg > .input-group-btn > .btn {\n  height: 46px;\n  padding: 10px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n  border-radius: 6px;\n}\nselect.input-group-lg > .form-control,\nselect.input-group-lg > .input-group-addon,\nselect.input-group-lg > .input-group-btn > .btn {\n  height: 46px;\n  line-height: 46px;\n}\ntextarea.input-group-lg > .form-control,\ntextarea.input-group-lg > .input-group-addon,\ntextarea.input-group-lg > .input-group-btn > .btn,\nselect[multiple].input-group-lg > .form-control,\nselect[multiple].input-group-lg > .input-group-addon,\nselect[multiple].input-group-lg > .input-group-btn > .btn {\n  height: auto;\n}\n.input-group-sm > .form-control,\n.input-group-sm > .input-group-addon,\n.input-group-sm > .input-group-btn > .btn {\n  height: 30px;\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n  border-radius: 3px;\n}\nselect.input-group-sm > .form-control,\nselect.input-group-sm > .input-group-addon,\nselect.input-group-sm > .input-group-btn > .btn {\n  height: 30px;\n  line-height: 30px;\n}\ntextarea.input-group-sm > .form-control,\ntextarea.input-group-sm > .input-group-addon,\ntextarea.input-group-sm > .input-group-btn > .btn,\nselect[multiple].input-group-sm > .form-control,\nselect[multiple].input-group-sm > .input-group-addon,\nselect[multiple].input-group-sm > .input-group-btn > .btn {\n  height: auto;\n}\n.input-group-addon,\n.input-group-btn,\n.input-group .form-control {\n  display: table-cell;\n}\n.input-group-addon:not(:first-child):not(:last-child),\n.input-group-btn:not(:first-child):not(:last-child),\n.input-group .form-control:not(:first-child):not(:last-child) {\n  border-radius: 0;\n}\n.input-group-addon,\n.input-group-btn {\n  width: 1%;\n  white-space: nowrap;\n  vertical-align: middle;\n}\n.input-group-addon {\n  padding: 6px 12px;\n  font-size: 14px;\n  font-weight: normal;\n  line-height: 1;\n  color: #555;\n  text-align: center;\n  background-color: #eee;\n  border: 1px solid #ccc;\n  border-radius: 4px;\n}\n.input-group-addon.input-sm {\n  padding: 5px 10px;\n  font-size: 12px;\n  border-radius: 3px;\n}\n.input-group-addon.input-lg {\n  padding: 10px 16px;\n  font-size: 18px;\n  border-radius: 6px;\n}\n.input-group-addon input[type=\"radio\"],\n.input-group-addon input[type=\"checkbox\"] {\n  margin-top: 0;\n}\n.input-group .form-control:first-child,\n.input-group-addon:first-child,\n.input-group-btn:first-child > .btn,\n.input-group-btn:first-child > .btn-group > .btn,\n.input-group-btn:first-child > .dropdown-toggle,\n.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),\n.input-group-btn:last-child > .btn-group:not(:last-child) > .btn {\n  border-top-right-radius: 0;\n  border-bottom-right-radius: 0;\n}\n.input-group-addon:first-child {\n  border-right: 0;\n}\n.input-group .form-control:last-child,\n.input-group-addon:last-child,\n.input-group-btn:last-child > .btn,\n.input-group-btn:last-child > .btn-group > .btn,\n.input-group-btn:last-child > .dropdown-toggle,\n.input-group-btn:first-child > .btn:not(:first-child),\n.input-group-btn:first-child > .btn-group:not(:first-child) > .btn {\n  border-top-left-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.input-group-addon:last-child {\n  border-left: 0;\n}\n.input-group-btn {\n  position: relative;\n  font-size: 0;\n  white-space: nowrap;\n}\n.input-group-btn > .btn {\n  position: relative;\n}\n.input-group-btn > .btn + .btn {\n  margin-left: -1px;\n}\n.input-group-btn > .btn:hover,\n.input-group-btn > .btn:focus,\n.input-group-btn > .btn:active {\n  z-index: 2;\n}\n.input-group-btn:first-child > .btn,\n.input-group-btn:first-child > .btn-group {\n  margin-right: -1px;\n}\n.input-group-btn:last-child > .btn,\n.input-group-btn:last-child > .btn-group {\n  z-index: 2;\n  margin-left: -1px;\n}\n.nav {\n  padding-left: 0;\n  margin-bottom: 0;\n  list-style: none;\n}\n.nav > li {\n  position: relative;\n  display: block;\n}\n.nav > li > a {\n  position: relative;\n  display: block;\n  padding: 10px 15px;\n}\n.nav > li > a:hover,\n.nav > li > a:focus {\n  text-decoration: none;\n  background-color: #eee;\n}\n.nav > li.disabled > a {\n  color: #777;\n}\n.nav > li.disabled > a:hover,\n.nav > li.disabled > a:focus {\n  color: #777;\n  text-decoration: none;\n  cursor: not-allowed;\n  background-color: transparent;\n}\n.nav .open > a,\n.nav .open > a:hover,\n.nav .open > a:focus {\n  background-color: #eee;\n  border-color: #337ab7;\n}\n.nav .nav-divider {\n  height: 1px;\n  margin: 9px 0;\n  overflow: hidden;\n  background-color: #e5e5e5;\n}\n.nav > li > a > img {\n  max-width: none;\n}\n.nav-tabs {\n  border-bottom: 1px solid #ddd;\n}\n.nav-tabs > li {\n  float: left;\n  margin-bottom: -1px;\n}\n.nav-tabs > li > a {\n  margin-right: 2px;\n  line-height: 1.42857143;\n  border: 1px solid transparent;\n  border-radius: 4px 4px 0 0;\n}\n.nav-tabs > li > a:hover {\n  border-color: #eee #eee #ddd;\n}\n.nav-tabs > li.active > a,\n.nav-tabs > li.active > a:hover,\n.nav-tabs > li.active > a:focus {\n  color: #555;\n  cursor: default;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  border-bottom-color: transparent;\n}\n.nav-tabs.nav-justified {\n  width: 100%;\n  border-bottom: 0;\n}\n.nav-tabs.nav-justified > li {\n  float: none;\n}\n.nav-tabs.nav-justified > li > a {\n  margin-bottom: 5px;\n  text-align: center;\n}\n.nav-tabs.nav-justified > .dropdown .dropdown-menu {\n  top: auto;\n  left: auto;\n}\n@media (min-width: 768px) {\n  .nav-tabs.nav-justified > li {\n    display: table-cell;\n    width: 1%;\n  }\n  .nav-tabs.nav-justified > li > a {\n    margin-bottom: 0;\n  }\n}\n.nav-tabs.nav-justified > li > a {\n  margin-right: 0;\n  border-radius: 4px;\n}\n.nav-tabs.nav-justified > .active > a,\n.nav-tabs.nav-justified > .active > a:hover,\n.nav-tabs.nav-justified > .active > a:focus {\n  border: 1px solid #ddd;\n}\n@media (min-width: 768px) {\n  .nav-tabs.nav-justified > li > a {\n    border-bottom: 1px solid #ddd;\n    border-radius: 4px 4px 0 0;\n  }\n  .nav-tabs.nav-justified > .active > a,\n  .nav-tabs.nav-justified > .active > a:hover,\n  .nav-tabs.nav-justified > .active > a:focus {\n    border-bottom-color: #fff;\n  }\n}\n.nav-pills > li {\n  float: left;\n}\n.nav-pills > li > a {\n  border-radius: 4px;\n}\n.nav-pills > li + li {\n  margin-left: 2px;\n}\n.nav-pills > li.active > a,\n.nav-pills > li.active > a:hover,\n.nav-pills > li.active > a:focus {\n  color: #fff;\n  background-color: #337ab7;\n}\n.nav-stacked > li {\n  float: none;\n}\n.nav-stacked > li + li {\n  margin-top: 2px;\n  margin-left: 0;\n}\n.nav-justified {\n  width: 100%;\n}\n.nav-justified > li {\n  float: none;\n}\n.nav-justified > li > a {\n  margin-bottom: 5px;\n  text-align: center;\n}\n.nav-justified > .dropdown .dropdown-menu {\n  top: auto;\n  left: auto;\n}\n@media (min-width: 768px) {\n  .nav-justified > li {\n    display: table-cell;\n    width: 1%;\n  }\n  .nav-justified > li > a {\n    margin-bottom: 0;\n  }\n}\n.nav-tabs-justified {\n  border-bottom: 0;\n}\n.nav-tabs-justified > li > a {\n  margin-right: 0;\n  border-radius: 4px;\n}\n.nav-tabs-justified > .active > a,\n.nav-tabs-justified > .active > a:hover,\n.nav-tabs-justified > .active > a:focus {\n  border: 1px solid #ddd;\n}\n@media (min-width: 768px) {\n  .nav-tabs-justified > li > a {\n    border-bottom: 1px solid #ddd;\n    border-radius: 4px 4px 0 0;\n  }\n  .nav-tabs-justified > .active > a,\n  .nav-tabs-justified > .active > a:hover,\n  .nav-tabs-justified > .active > a:focus {\n    border-bottom-color: #fff;\n  }\n}\n.tab-content > .tab-pane {\n  display: none;\n}\n.tab-content > .active {\n  display: block;\n}\n.nav-tabs .dropdown-menu {\n  margin-top: -1px;\n  border-top-left-radius: 0;\n  border-top-right-radius: 0;\n}\n.navbar {\n  position: relative;\n  min-height: 50px;\n  margin-bottom: 20px;\n  border: 1px solid transparent;\n}\n@media (min-width: 768px) {\n  .navbar {\n    border-radius: 4px;\n  }\n}\n@media (min-width: 768px) {\n  .navbar-header {\n    float: left;\n  }\n}\n.navbar-collapse {\n  padding-right: 15px;\n  padding-left: 15px;\n  overflow-x: visible;\n  -webkit-overflow-scrolling: touch;\n  border-top: 1px solid transparent;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);\n          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);\n}\n.navbar-collapse.in {\n  overflow-y: auto;\n}\n@media (min-width: 768px) {\n  .navbar-collapse {\n    width: auto;\n    border-top: 0;\n    -webkit-box-shadow: none;\n            box-shadow: none;\n  }\n  .navbar-collapse.collapse {\n    display: block !important;\n    height: auto !important;\n    padding-bottom: 0;\n    overflow: visible !important;\n  }\n  .navbar-collapse.in {\n    overflow-y: visible;\n  }\n  .navbar-fixed-top .navbar-collapse,\n  .navbar-static-top .navbar-collapse,\n  .navbar-fixed-bottom .navbar-collapse {\n    padding-right: 0;\n    padding-left: 0;\n  }\n}\n.navbar-fixed-top .navbar-collapse,\n.navbar-fixed-bottom .navbar-collapse {\n  max-height: 340px;\n}\n@media (max-device-width: 480px) and (orientation: landscape) {\n  .navbar-fixed-top .navbar-collapse,\n  .navbar-fixed-bottom .navbar-collapse {\n    max-height: 200px;\n  }\n}\n.container > .navbar-header,\n.container-fluid > .navbar-header,\n.container > .navbar-collapse,\n.container-fluid > .navbar-collapse {\n  margin-right: -15px;\n  margin-left: -15px;\n}\n@media (min-width: 768px) {\n  .container > .navbar-header,\n  .container-fluid > .navbar-header,\n  .container > .navbar-collapse,\n  .container-fluid > .navbar-collapse {\n    margin-right: 0;\n    margin-left: 0;\n  }\n}\n.navbar-static-top {\n  z-index: 1000;\n  border-width: 0 0 1px;\n}\n@media (min-width: 768px) {\n  .navbar-static-top {\n    border-radius: 0;\n  }\n}\n.navbar-fixed-top,\n.navbar-fixed-bottom {\n  position: fixed;\n  right: 0;\n  left: 0;\n  z-index: 1030;\n}\n@media (min-width: 768px) {\n  .navbar-fixed-top,\n  .navbar-fixed-bottom {\n    border-radius: 0;\n  }\n}\n.navbar-fixed-top {\n  top: 0;\n  border-width: 0 0 1px;\n}\n.navbar-fixed-bottom {\n  bottom: 0;\n  margin-bottom: 0;\n  border-width: 1px 0 0;\n}\n.navbar-brand {\n  float: left;\n  height: 50px;\n  padding: 15px 15px;\n  font-size: 18px;\n  line-height: 20px;\n}\n.navbar-brand:hover,\n.navbar-brand:focus {\n  text-decoration: none;\n}\n.navbar-brand > img {\n  display: block;\n}\n@media (min-width: 768px) {\n  .navbar > .container .navbar-brand,\n  .navbar > .container-fluid .navbar-brand {\n    margin-left: -15px;\n  }\n}\n.navbar-toggle {\n  position: relative;\n  float: right;\n  padding: 9px 10px;\n  margin-top: 8px;\n  margin-right: 15px;\n  margin-bottom: 8px;\n  background-color: transparent;\n  background-image: none;\n  border: 1px solid transparent;\n  border-radius: 4px;\n}\n.navbar-toggle:focus {\n  outline: 0;\n}\n.navbar-toggle .icon-bar {\n  display: block;\n  width: 22px;\n  height: 2px;\n  border-radius: 1px;\n}\n.navbar-toggle .icon-bar + .icon-bar {\n  margin-top: 4px;\n}\n@media (min-width: 768px) {\n  .navbar-toggle {\n    display: none;\n  }\n}\n.navbar-nav {\n  margin: 7.5px -15px;\n}\n.navbar-nav > li > a {\n  padding-top: 10px;\n  padding-bottom: 10px;\n  line-height: 20px;\n}\n@media (max-width: 767px) {\n  .navbar-nav .open .dropdown-menu {\n    position: static;\n    float: none;\n    width: auto;\n    margin-top: 0;\n    background-color: transparent;\n    border: 0;\n    -webkit-box-shadow: none;\n            box-shadow: none;\n  }\n  .navbar-nav .open .dropdown-menu > li > a,\n  .navbar-nav .open .dropdown-menu .dropdown-header {\n    padding: 5px 15px 5px 25px;\n  }\n  .navbar-nav .open .dropdown-menu > li > a {\n    line-height: 20px;\n  }\n  .navbar-nav .open .dropdown-menu > li > a:hover,\n  .navbar-nav .open .dropdown-menu > li > a:focus {\n    background-image: none;\n  }\n}\n@media (min-width: 768px) {\n  .navbar-nav {\n    float: left;\n    margin: 0;\n  }\n  .navbar-nav > li {\n    float: left;\n  }\n  .navbar-nav > li > a {\n    padding-top: 15px;\n    padding-bottom: 15px;\n  }\n}\n.navbar-form {\n  padding: 10px 15px;\n  margin-top: 8px;\n  margin-right: -15px;\n  margin-bottom: 8px;\n  margin-left: -15px;\n  border-top: 1px solid transparent;\n  border-bottom: 1px solid transparent;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);\n          box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);\n}\n@media (min-width: 768px) {\n  .navbar-form .form-group {\n    display: inline-block;\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .navbar-form .form-control {\n    display: inline-block;\n    width: auto;\n    vertical-align: middle;\n  }\n  .navbar-form .form-control-static {\n    display: inline-block;\n  }\n  .navbar-form .input-group {\n    display: inline-table;\n    vertical-align: middle;\n  }\n  .navbar-form .input-group .input-group-addon,\n  .navbar-form .input-group .input-group-btn,\n  .navbar-form .input-group .form-control {\n    width: auto;\n  }\n  .navbar-form .input-group > .form-control {\n    width: 100%;\n  }\n  .navbar-form .control-label {\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .navbar-form .radio,\n  .navbar-form .checkbox {\n    display: inline-block;\n    margin-top: 0;\n    margin-bottom: 0;\n    vertical-align: middle;\n  }\n  .navbar-form .radio label,\n  .navbar-form .checkbox label {\n    padding-left: 0;\n  }\n  .navbar-form .radio input[type=\"radio\"],\n  .navbar-form .checkbox input[type=\"checkbox\"] {\n    position: relative;\n    margin-left: 0;\n  }\n  .navbar-form .has-feedback .form-control-feedback {\n    top: 0;\n  }\n}\n@media (max-width: 767px) {\n  .navbar-form .form-group {\n    margin-bottom: 5px;\n  }\n  .navbar-form .form-group:last-child {\n    margin-bottom: 0;\n  }\n}\n@media (min-width: 768px) {\n  .navbar-form {\n    width: auto;\n    padding-top: 0;\n    padding-bottom: 0;\n    margin-right: 0;\n    margin-left: 0;\n    border: 0;\n    -webkit-box-shadow: none;\n            box-shadow: none;\n  }\n}\n.navbar-nav > li > .dropdown-menu {\n  margin-top: 0;\n  border-top-left-radius: 0;\n  border-top-right-radius: 0;\n}\n.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {\n  margin-bottom: 0;\n  border-top-left-radius: 4px;\n  border-top-right-radius: 4px;\n  border-bottom-right-radius: 0;\n  border-bottom-left-radius: 0;\n}\n.navbar-btn {\n  margin-top: 8px;\n  margin-bottom: 8px;\n}\n.navbar-btn.btn-sm {\n  margin-top: 10px;\n  margin-bottom: 10px;\n}\n.navbar-btn.btn-xs {\n  margin-top: 14px;\n  margin-bottom: 14px;\n}\n.navbar-text {\n  margin-top: 15px;\n  margin-bottom: 15px;\n}\n@media (min-width: 768px) {\n  .navbar-text {\n    float: left;\n    margin-right: 15px;\n    margin-left: 15px;\n  }\n}\n@media (min-width: 768px) {\n  .navbar-left {\n    float: left !important;\n  }\n  .navbar-right {\n    float: right !important;\n    margin-right: -15px;\n  }\n  .navbar-right ~ .navbar-right {\n    margin-right: 0;\n  }\n}\n.navbar-default {\n  background-color: #f8f8f8;\n  border-color: #e7e7e7;\n}\n.navbar-default .navbar-brand {\n  color: #777;\n}\n.navbar-default .navbar-brand:hover,\n.navbar-default .navbar-brand:focus {\n  color: #5e5e5e;\n  background-color: transparent;\n}\n.navbar-default .navbar-text {\n  color: #777;\n}\n.navbar-default .navbar-nav > li > a {\n  color: #777;\n}\n.navbar-default .navbar-nav > li > a:hover,\n.navbar-default .navbar-nav > li > a:focus {\n  color: #333;\n  background-color: transparent;\n}\n.navbar-default .navbar-nav > .active > a,\n.navbar-default .navbar-nav > .active > a:hover,\n.navbar-default .navbar-nav > .active > a:focus {\n  color: #555;\n  background-color: #e7e7e7;\n}\n.navbar-default .navbar-nav > .disabled > a,\n.navbar-default .navbar-nav > .disabled > a:hover,\n.navbar-default .navbar-nav > .disabled > a:focus {\n  color: #ccc;\n  background-color: transparent;\n}\n.navbar-default .navbar-toggle {\n  border-color: #ddd;\n}\n.navbar-default .navbar-toggle:hover,\n.navbar-default .navbar-toggle:focus {\n  background-color: #ddd;\n}\n.navbar-default .navbar-toggle .icon-bar {\n  background-color: #888;\n}\n.navbar-default .navbar-collapse,\n.navbar-default .navbar-form {\n  border-color: #e7e7e7;\n}\n.navbar-default .navbar-nav > .open > a,\n.navbar-default .navbar-nav > .open > a:hover,\n.navbar-default .navbar-nav > .open > a:focus {\n  color: #555;\n  background-color: #e7e7e7;\n}\n@media (max-width: 767px) {\n  .navbar-default .navbar-nav .open .dropdown-menu > li > a {\n    color: #777;\n  }\n  .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,\n  .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {\n    color: #333;\n    background-color: transparent;\n  }\n  .navbar-default .navbar-nav .open .dropdown-menu > .active > a,\n  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,\n  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {\n    color: #555;\n    background-color: #e7e7e7;\n  }\n  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,\n  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,\n  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {\n    color: #ccc;\n    background-color: transparent;\n  }\n}\n.navbar-default .navbar-link {\n  color: #777;\n}\n.navbar-default .navbar-link:hover {\n  color: #333;\n}\n.navbar-default .btn-link {\n  color: #777;\n}\n.navbar-default .btn-link:hover,\n.navbar-default .btn-link:focus {\n  color: #333;\n}\n.navbar-default .btn-link[disabled]:hover,\nfieldset[disabled] .navbar-default .btn-link:hover,\n.navbar-default .btn-link[disabled]:focus,\nfieldset[disabled] .navbar-default .btn-link:focus {\n  color: #ccc;\n}\n.navbar-inverse {\n  background-color: #222;\n  border-color: #080808;\n}\n.navbar-inverse .navbar-brand {\n  color: #9d9d9d;\n}\n.navbar-inverse .navbar-brand:hover,\n.navbar-inverse .navbar-brand:focus {\n  color: #fff;\n  background-color: transparent;\n}\n.navbar-inverse .navbar-text {\n  color: #9d9d9d;\n}\n.navbar-inverse .navbar-nav > li > a {\n  color: #9d9d9d;\n}\n.navbar-inverse .navbar-nav > li > a:hover,\n.navbar-inverse .navbar-nav > li > a:focus {\n  color: #fff;\n  background-color: transparent;\n}\n.navbar-inverse .navbar-nav > .active > a,\n.navbar-inverse .navbar-nav > .active > a:hover,\n.navbar-inverse .navbar-nav > .active > a:focus {\n  color: #fff;\n  background-color: #080808;\n}\n.navbar-inverse .navbar-nav > .disabled > a,\n.navbar-inverse .navbar-nav > .disabled > a:hover,\n.navbar-inverse .navbar-nav > .disabled > a:focus {\n  color: #444;\n  background-color: transparent;\n}\n.navbar-inverse .navbar-toggle {\n  border-color: #333;\n}\n.navbar-inverse .navbar-toggle:hover,\n.navbar-inverse .navbar-toggle:focus {\n  background-color: #333;\n}\n.navbar-inverse .navbar-toggle .icon-bar {\n  background-color: #fff;\n}\n.navbar-inverse .navbar-collapse,\n.navbar-inverse .navbar-form {\n  border-color: #101010;\n}\n.navbar-inverse .navbar-nav > .open > a,\n.navbar-inverse .navbar-nav > .open > a:hover,\n.navbar-inverse .navbar-nav > .open > a:focus {\n  color: #fff;\n  background-color: #080808;\n}\n@media (max-width: 767px) {\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {\n    border-color: #080808;\n  }\n  .navbar-inverse .navbar-nav .open .dropdown-menu .divider {\n    background-color: #080808;\n  }\n  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {\n    color: #9d9d9d;\n  }\n  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,\n  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {\n    color: #fff;\n    background-color: transparent;\n  }\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {\n    color: #fff;\n    background-color: #080808;\n  }\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,\n  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {\n    color: #444;\n    background-color: transparent;\n  }\n}\n.navbar-inverse .navbar-link {\n  color: #9d9d9d;\n}\n.navbar-inverse .navbar-link:hover {\n  color: #fff;\n}\n.navbar-inverse .btn-link {\n  color: #9d9d9d;\n}\n.navbar-inverse .btn-link:hover,\n.navbar-inverse .btn-link:focus {\n  color: #fff;\n}\n.navbar-inverse .btn-link[disabled]:hover,\nfieldset[disabled] .navbar-inverse .btn-link:hover,\n.navbar-inverse .btn-link[disabled]:focus,\nfieldset[disabled] .navbar-inverse .btn-link:focus {\n  color: #444;\n}\n.breadcrumb {\n  padding: 8px 15px;\n  margin-bottom: 20px;\n  list-style: none;\n  background-color: #f5f5f5;\n  border-radius: 4px;\n}\n.breadcrumb > li {\n  display: inline-block;\n}\n.breadcrumb > li + li:before {\n  padding: 0 5px;\n  color: #ccc;\n  content: \"/\\00a0\";\n}\n.breadcrumb > .active {\n  color: #777;\n}\n.pagination {\n  display: inline-block;\n  padding-left: 0;\n  margin: 20px 0;\n  border-radius: 4px;\n}\n.pagination > li {\n  display: inline;\n}\n.pagination > li > a,\n.pagination > li > span {\n  position: relative;\n  float: left;\n  padding: 6px 12px;\n  margin-left: -1px;\n  line-height: 1.42857143;\n  color: #337ab7;\n  text-decoration: none;\n  background-color: #fff;\n  border: 1px solid #ddd;\n}\n.pagination > li:first-child > a,\n.pagination > li:first-child > span {\n  margin-left: 0;\n  border-top-left-radius: 4px;\n  border-bottom-left-radius: 4px;\n}\n.pagination > li:last-child > a,\n.pagination > li:last-child > span {\n  border-top-right-radius: 4px;\n  border-bottom-right-radius: 4px;\n}\n.pagination > li > a:hover,\n.pagination > li > span:hover,\n.pagination > li > a:focus,\n.pagination > li > span:focus {\n  z-index: 2;\n  color: #23527c;\n  background-color: #eee;\n  border-color: #ddd;\n}\n.pagination > .active > a,\n.pagination > .active > span,\n.pagination > .active > a:hover,\n.pagination > .active > span:hover,\n.pagination > .active > a:focus,\n.pagination > .active > span:focus {\n  z-index: 3;\n  color: #fff;\n  cursor: default;\n  background-color: #337ab7;\n  border-color: #337ab7;\n}\n.pagination > .disabled > span,\n.pagination > .disabled > span:hover,\n.pagination > .disabled > span:focus,\n.pagination > .disabled > a,\n.pagination > .disabled > a:hover,\n.pagination > .disabled > a:focus {\n  color: #777;\n  cursor: not-allowed;\n  background-color: #fff;\n  border-color: #ddd;\n}\n.pagination-lg > li > a,\n.pagination-lg > li > span {\n  padding: 10px 16px;\n  font-size: 18px;\n  line-height: 1.3333333;\n}\n.pagination-lg > li:first-child > a,\n.pagination-lg > li:first-child > span {\n  border-top-left-radius: 6px;\n  border-bottom-left-radius: 6px;\n}\n.pagination-lg > li:last-child > a,\n.pagination-lg > li:last-child > span {\n  border-top-right-radius: 6px;\n  border-bottom-right-radius: 6px;\n}\n.pagination-sm > li > a,\n.pagination-sm > li > span {\n  padding: 5px 10px;\n  font-size: 12px;\n  line-height: 1.5;\n}\n.pagination-sm > li:first-child > a,\n.pagination-sm > li:first-child > span {\n  border-top-left-radius: 3px;\n  border-bottom-left-radius: 3px;\n}\n.pagination-sm > li:last-child > a,\n.pagination-sm > li:last-child > span {\n  border-top-right-radius: 3px;\n  border-bottom-right-radius: 3px;\n}\n.pager {\n  padding-left: 0;\n  margin: 20px 0;\n  text-align: center;\n  list-style: none;\n}\n.pager li {\n  display: inline;\n}\n.pager li > a,\n.pager li > span {\n  display: inline-block;\n  padding: 5px 14px;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  border-radius: 15px;\n}\n.pager li > a:hover,\n.pager li > a:focus {\n  text-decoration: none;\n  background-color: #eee;\n}\n.pager .next > a,\n.pager .next > span {\n  float: right;\n}\n.pager .previous > a,\n.pager .previous > span {\n  float: left;\n}\n.pager .disabled > a,\n.pager .disabled > a:hover,\n.pager .disabled > a:focus,\n.pager .disabled > span {\n  color: #777;\n  cursor: not-allowed;\n  background-color: #fff;\n}\n.label {\n  display: inline;\n  padding: .2em .6em .3em;\n  font-size: 75%;\n  font-weight: bold;\n  line-height: 1;\n  color: #fff;\n  text-align: center;\n  white-space: nowrap;\n  vertical-align: baseline;\n  border-radius: .25em;\n}\na.label:hover,\na.label:focus {\n  color: #fff;\n  text-decoration: none;\n  cursor: pointer;\n}\n.label:empty {\n  display: none;\n}\n.btn .label {\n  position: relative;\n  top: -1px;\n}\n.label-default {\n  background-color: #777;\n}\n.label-default[href]:hover,\n.label-default[href]:focus {\n  background-color: #5e5e5e;\n}\n.label-primary {\n  background-color: #337ab7;\n}\n.label-primary[href]:hover,\n.label-primary[href]:focus {\n  background-color: #286090;\n}\n.label-success {\n  background-color: #5cb85c;\n}\n.label-success[href]:hover,\n.label-success[href]:focus {\n  background-color: #449d44;\n}\n.label-info {\n  background-color: #5bc0de;\n}\n.label-info[href]:hover,\n.label-info[href]:focus {\n  background-color: #31b0d5;\n}\n.label-warning {\n  background-color: #f0ad4e;\n}\n.label-warning[href]:hover,\n.label-warning[href]:focus {\n  background-color: #ec971f;\n}\n.label-danger {\n  background-color: #d9534f;\n}\n.label-danger[href]:hover,\n.label-danger[href]:focus {\n  background-color: #c9302c;\n}\n.badge {\n  display: inline-block;\n  min-width: 10px;\n  padding: 3px 7px;\n  font-size: 12px;\n  font-weight: bold;\n  line-height: 1;\n  color: #fff;\n  text-align: center;\n  white-space: nowrap;\n  vertical-align: middle;\n  background-color: #777;\n  border-radius: 10px;\n}\n.badge:empty {\n  display: none;\n}\n.btn .badge {\n  position: relative;\n  top: -1px;\n}\n.btn-xs .badge,\n.btn-group-xs > .btn .badge {\n  top: 0;\n  padding: 1px 5px;\n}\na.badge:hover,\na.badge:focus {\n  color: #fff;\n  text-decoration: none;\n  cursor: pointer;\n}\n.list-group-item.active > .badge,\n.nav-pills > .active > a > .badge {\n  color: #337ab7;\n  background-color: #fff;\n}\n.list-group-item > .badge {\n  float: right;\n}\n.list-group-item > .badge + .badge {\n  margin-right: 5px;\n}\n.nav-pills > li > a > .badge {\n  margin-left: 3px;\n}\n.jumbotron {\n  padding-top: 30px;\n  padding-bottom: 30px;\n  margin-bottom: 30px;\n  color: inherit;\n  background-color: #eee;\n}\n.jumbotron h1,\n.jumbotron .h1 {\n  color: inherit;\n}\n.jumbotron p {\n  margin-bottom: 15px;\n  font-size: 21px;\n  font-weight: 200;\n}\n.jumbotron > hr {\n  border-top-color: #d5d5d5;\n}\n.container .jumbotron,\n.container-fluid .jumbotron {\n  padding-right: 15px;\n  padding-left: 15px;\n  border-radius: 6px;\n}\n.jumbotron .container {\n  max-width: 100%;\n}\n@media screen and (min-width: 768px) {\n  .jumbotron {\n    padding-top: 48px;\n    padding-bottom: 48px;\n  }\n  .container .jumbotron,\n  .container-fluid .jumbotron {\n    padding-right: 60px;\n    padding-left: 60px;\n  }\n  .jumbotron h1,\n  .jumbotron .h1 {\n    font-size: 63px;\n  }\n}\n.thumbnail {\n  display: block;\n  padding: 4px;\n  margin-bottom: 20px;\n  line-height: 1.42857143;\n  background-color: #fff;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  -webkit-transition: border .2s ease-in-out;\n       -o-transition: border .2s ease-in-out;\n          transition: border .2s ease-in-out;\n}\n.thumbnail > img,\n.thumbnail a > img {\n  margin-right: auto;\n  margin-left: auto;\n}\na.thumbnail:hover,\na.thumbnail:focus,\na.thumbnail.active {\n  border-color: #337ab7;\n}\n.thumbnail .caption {\n  padding: 9px;\n  color: #333;\n}\n.alert {\n  padding: 15px;\n  margin-bottom: 20px;\n  border: 1px solid transparent;\n  border-radius: 4px;\n}\n.alert h4 {\n  margin-top: 0;\n  color: inherit;\n}\n.alert .alert-link {\n  font-weight: bold;\n}\n.alert > p,\n.alert > ul {\n  margin-bottom: 0;\n}\n.alert > p + p {\n  margin-top: 5px;\n}\n.alert-dismissable,\n.alert-dismissible {\n  padding-right: 35px;\n}\n.alert-dismissable .close,\n.alert-dismissible .close {\n  position: relative;\n  top: -2px;\n  right: -21px;\n  color: inherit;\n}\n.alert-success {\n  color: #3c763d;\n  background-color: #dff0d8;\n  border-color: #d6e9c6;\n}\n.alert-success hr {\n  border-top-color: #c9e2b3;\n}\n.alert-success .alert-link {\n  color: #2b542c;\n}\n.alert-info {\n  color: #31708f;\n  background-color: #d9edf7;\n  border-color: #bce8f1;\n}\n.alert-info hr {\n  border-top-color: #a6e1ec;\n}\n.alert-info .alert-link {\n  color: #245269;\n}\n.alert-warning {\n  color: #8a6d3b;\n  background-color: #fcf8e3;\n  border-color: #faebcc;\n}\n.alert-warning hr {\n  border-top-color: #f7e1b5;\n}\n.alert-warning .alert-link {\n  color: #66512c;\n}\n.alert-danger {\n  color: #a94442;\n  background-color: #f2dede;\n  border-color: #ebccd1;\n}\n.alert-danger hr {\n  border-top-color: #e4b9c0;\n}\n.alert-danger .alert-link {\n  color: #843534;\n}\n@-webkit-keyframes progress-bar-stripes {\n  from {\n    background-position: 40px 0;\n  }\n  to {\n    background-position: 0 0;\n  }\n}\n@-o-keyframes progress-bar-stripes {\n  from {\n    background-position: 40px 0;\n  }\n  to {\n    background-position: 0 0;\n  }\n}\n@keyframes progress-bar-stripes {\n  from {\n    background-position: 40px 0;\n  }\n  to {\n    background-position: 0 0;\n  }\n}\n.progress {\n  height: 20px;\n  margin-bottom: 20px;\n  overflow: hidden;\n  background-color: #f5f5f5;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);\n          box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);\n}\n.progress-bar {\n  float: left;\n  width: 0;\n  height: 100%;\n  font-size: 12px;\n  line-height: 20px;\n  color: #fff;\n  text-align: center;\n  background-color: #337ab7;\n  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);\n          box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);\n  -webkit-transition: width .6s ease;\n       -o-transition: width .6s ease;\n          transition: width .6s ease;\n}\n.progress-striped .progress-bar,\n.progress-bar-striped {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  -webkit-background-size: 40px 40px;\n          background-size: 40px 40px;\n}\n.progress.active .progress-bar,\n.progress-bar.active {\n  -webkit-animation: progress-bar-stripes 2s linear infinite;\n       -o-animation: progress-bar-stripes 2s linear infinite;\n          animation: progress-bar-stripes 2s linear infinite;\n}\n.progress-bar-success {\n  background-color: #5cb85c;\n}\n.progress-striped .progress-bar-success {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n}\n.progress-bar-info {\n  background-color: #5bc0de;\n}\n.progress-striped .progress-bar-info {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n}\n.progress-bar-warning {\n  background-color: #f0ad4e;\n}\n.progress-striped .progress-bar-warning {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n}\n.progress-bar-danger {\n  background-color: #d9534f;\n}\n.progress-striped .progress-bar-danger {\n  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:      -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n  background-image:         linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);\n}\n.media {\n  margin-top: 15px;\n}\n.media:first-child {\n  margin-top: 0;\n}\n.media,\n.media-body {\n  overflow: hidden;\n  zoom: 1;\n}\n.media-body {\n  width: 10000px;\n}\n.media-object {\n  display: block;\n}\n.media-object.img-thumbnail {\n  max-width: none;\n}\n.media-right,\n.media > .pull-right {\n  padding-left: 10px;\n}\n.media-left,\n.media > .pull-left {\n  padding-right: 10px;\n}\n.media-left,\n.media-right,\n.media-body {\n  display: table-cell;\n  vertical-align: top;\n}\n.media-middle {\n  vertical-align: middle;\n}\n.media-bottom {\n  vertical-align: bottom;\n}\n.media-heading {\n  margin-top: 0;\n  margin-bottom: 5px;\n}\n.media-list {\n  padding-left: 0;\n  list-style: none;\n}\n.list-group {\n  padding-left: 0;\n  margin-bottom: 20px;\n}\n.list-group-item {\n  position: relative;\n  display: block;\n  padding: 10px 15px;\n  margin-bottom: -1px;\n  background-color: #fff;\n  border: 1px solid #ddd;\n}\n.list-group-item:first-child {\n  border-top-left-radius: 4px;\n  border-top-right-radius: 4px;\n}\n.list-group-item:last-child {\n  margin-bottom: 0;\n  border-bottom-right-radius: 4px;\n  border-bottom-left-radius: 4px;\n}\na.list-group-item,\nbutton.list-group-item {\n  color: #555;\n}\na.list-group-item .list-group-item-heading,\nbutton.list-group-item .list-group-item-heading {\n  color: #333;\n}\na.list-group-item:hover,\nbutton.list-group-item:hover,\na.list-group-item:focus,\nbutton.list-group-item:focus {\n  color: #555;\n  text-decoration: none;\n  background-color: #f5f5f5;\n}\nbutton.list-group-item {\n  width: 100%;\n  text-align: left;\n}\n.list-group-item.disabled,\n.list-group-item.disabled:hover,\n.list-group-item.disabled:focus {\n  color: #777;\n  cursor: not-allowed;\n  background-color: #eee;\n}\n.list-group-item.disabled .list-group-item-heading,\n.list-group-item.disabled:hover .list-group-item-heading,\n.list-group-item.disabled:focus .list-group-item-heading {\n  color: inherit;\n}\n.list-group-item.disabled .list-group-item-text,\n.list-group-item.disabled:hover .list-group-item-text,\n.list-group-item.disabled:focus .list-group-item-text {\n  color: #777;\n}\n.list-group-item.active,\n.list-group-item.active:hover,\n.list-group-item.active:focus {\n  z-index: 2;\n  color: #fff;\n  background-color: #337ab7;\n  border-color: #337ab7;\n}\n.list-group-item.active .list-group-item-heading,\n.list-group-item.active:hover .list-group-item-heading,\n.list-group-item.active:focus .list-group-item-heading,\n.list-group-item.active .list-group-item-heading > small,\n.list-group-item.active:hover .list-group-item-heading > small,\n.list-group-item.active:focus .list-group-item-heading > small,\n.list-group-item.active .list-group-item-heading > .small,\n.list-group-item.active:hover .list-group-item-heading > .small,\n.list-group-item.active:focus .list-group-item-heading > .small {\n  color: inherit;\n}\n.list-group-item.active .list-group-item-text,\n.list-group-item.active:hover .list-group-item-text,\n.list-group-item.active:focus .list-group-item-text {\n  color: #c7ddef;\n}\n.list-group-item-success {\n  color: #3c763d;\n  background-color: #dff0d8;\n}\na.list-group-item-success,\nbutton.list-group-item-success {\n  color: #3c763d;\n}\na.list-group-item-success .list-group-item-heading,\nbutton.list-group-item-success .list-group-item-heading {\n  color: inherit;\n}\na.list-group-item-success:hover,\nbutton.list-group-item-success:hover,\na.list-group-item-success:focus,\nbutton.list-group-item-success:focus {\n  color: #3c763d;\n  background-color: #d0e9c6;\n}\na.list-group-item-success.active,\nbutton.list-group-item-success.active,\na.list-group-item-success.active:hover,\nbutton.list-group-item-success.active:hover,\na.list-group-item-success.active:focus,\nbutton.list-group-item-success.active:focus {\n  color: #fff;\n  background-color: #3c763d;\n  border-color: #3c763d;\n}\n.list-group-item-info {\n  color: #31708f;\n  background-color: #d9edf7;\n}\na.list-group-item-info,\nbutton.list-group-item-info {\n  color: #31708f;\n}\na.list-group-item-info .list-group-item-heading,\nbutton.list-group-item-info .list-group-item-heading {\n  color: inherit;\n}\na.list-group-item-info:hover,\nbutton.list-group-item-info:hover,\na.list-group-item-info:focus,\nbutton.list-group-item-info:focus {\n  color: #31708f;\n  background-color: #c4e3f3;\n}\na.list-group-item-info.active,\nbutton.list-group-item-info.active,\na.list-group-item-info.active:hover,\nbutton.list-group-item-info.active:hover,\na.list-group-item-info.active:focus,\nbutton.list-group-item-info.active:focus {\n  color: #fff;\n  background-color: #31708f;\n  border-color: #31708f;\n}\n.list-group-item-warning {\n  color: #8a6d3b;\n  background-color: #fcf8e3;\n}\na.list-group-item-warning,\nbutton.list-group-item-warning {\n  color: #8a6d3b;\n}\na.list-group-item-warning .list-group-item-heading,\nbutton.list-group-item-warning .list-group-item-heading {\n  color: inherit;\n}\na.list-group-item-warning:hover,\nbutton.list-group-item-warning:hover,\na.list-group-item-warning:focus,\nbutton.list-group-item-warning:focus {\n  color: #8a6d3b;\n  background-color: #faf2cc;\n}\na.list-group-item-warning.active,\nbutton.list-group-item-warning.active,\na.list-group-item-warning.active:hover,\nbutton.list-group-item-warning.active:hover,\na.list-group-item-warning.active:focus,\nbutton.list-group-item-warning.active:focus {\n  color: #fff;\n  background-color: #8a6d3b;\n  border-color: #8a6d3b;\n}\n.list-group-item-danger {\n  color: #a94442;\n  background-color: #f2dede;\n}\na.list-group-item-danger,\nbutton.list-group-item-danger {\n  color: #a94442;\n}\na.list-group-item-danger .list-group-item-heading,\nbutton.list-group-item-danger .list-group-item-heading {\n  color: inherit;\n}\na.list-group-item-danger:hover,\nbutton.list-group-item-danger:hover,\na.list-group-item-danger:focus,\nbutton.list-group-item-danger:focus {\n  color: #a94442;\n  background-color: #ebcccc;\n}\na.list-group-item-danger.active,\nbutton.list-group-item-danger.active,\na.list-group-item-danger.active:hover,\nbutton.list-group-item-danger.active:hover,\na.list-group-item-danger.active:focus,\nbutton.list-group-item-danger.active:focus {\n  color: #fff;\n  background-color: #a94442;\n  border-color: #a94442;\n}\n.list-group-item-heading {\n  margin-top: 0;\n  margin-bottom: 5px;\n}\n.list-group-item-text {\n  margin-bottom: 0;\n  line-height: 1.3;\n}\n.panel {\n  margin-bottom: 20px;\n  background-color: #fff;\n  border: 1px solid transparent;\n  border-radius: 4px;\n  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);\n          box-shadow: 0 1px 1px rgba(0, 0, 0, .05);\n}\n.panel-body {\n  padding: 15px;\n}\n.panel-heading {\n  padding: 10px 15px;\n  border-bottom: 1px solid transparent;\n  border-top-left-radius: 3px;\n  border-top-right-radius: 3px;\n}\n.panel-heading > .dropdown .dropdown-toggle {\n  color: inherit;\n}\n.panel-title {\n  margin-top: 0;\n  margin-bottom: 0;\n  font-size: 16px;\n  color: inherit;\n}\n.panel-title > a,\n.panel-title > small,\n.panel-title > .small,\n.panel-title > small > a,\n.panel-title > .small > a {\n  color: inherit;\n}\n.panel-footer {\n  padding: 10px 15px;\n  background-color: #f5f5f5;\n  border-top: 1px solid #ddd;\n  border-bottom-right-radius: 3px;\n  border-bottom-left-radius: 3px;\n}\n.panel > .list-group,\n.panel > .panel-collapse > .list-group {\n  margin-bottom: 0;\n}\n.panel > .list-group .list-group-item,\n.panel > .panel-collapse > .list-group .list-group-item {\n  border-width: 1px 0;\n  border-radius: 0;\n}\n.panel > .list-group:first-child .list-group-item:first-child,\n.panel > .panel-collapse > .list-group:first-child .list-group-item:first-child {\n  border-top: 0;\n  border-top-left-radius: 3px;\n  border-top-right-radius: 3px;\n}\n.panel > .list-group:last-child .list-group-item:last-child,\n.panel > .panel-collapse > .list-group:last-child .list-group-item:last-child {\n  border-bottom: 0;\n  border-bottom-right-radius: 3px;\n  border-bottom-left-radius: 3px;\n}\n.panel > .panel-heading + .panel-collapse > .list-group .list-group-item:first-child {\n  border-top-left-radius: 0;\n  border-top-right-radius: 0;\n}\n.panel-heading + .list-group .list-group-item:first-child {\n  border-top-width: 0;\n}\n.list-group + .panel-footer {\n  border-top-width: 0;\n}\n.panel > .table,\n.panel > .table-responsive > .table,\n.panel > .panel-collapse > .table {\n  margin-bottom: 0;\n}\n.panel > .table caption,\n.panel > .table-responsive > .table caption,\n.panel > .panel-collapse > .table caption {\n  padding-right: 15px;\n  padding-left: 15px;\n}\n.panel > .table:first-child,\n.panel > .table-responsive:first-child > .table:first-child {\n  border-top-left-radius: 3px;\n  border-top-right-radius: 3px;\n}\n.panel > .table:first-child > thead:first-child > tr:first-child,\n.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child,\n.panel > .table:first-child > tbody:first-child > tr:first-child,\n.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child {\n  border-top-left-radius: 3px;\n  border-top-right-radius: 3px;\n}\n.panel > .table:first-child > thead:first-child > tr:first-child td:first-child,\n.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child,\n.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child,\n.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child,\n.panel > .table:first-child > thead:first-child > tr:first-child th:first-child,\n.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child,\n.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child,\n.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child {\n  border-top-left-radius: 3px;\n}\n.panel > .table:first-child > thead:first-child > tr:first-child td:last-child,\n.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child,\n.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child,\n.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child,\n.panel > .table:first-child > thead:first-child > tr:first-child th:last-child,\n.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child,\n.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child,\n.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child {\n  border-top-right-radius: 3px;\n}\n.panel > .table:last-child,\n.panel > .table-responsive:last-child > .table:last-child {\n  border-bottom-right-radius: 3px;\n  border-bottom-left-radius: 3px;\n}\n.panel > .table:last-child > tbody:last-child > tr:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child,\n.panel > .table:last-child > tfoot:last-child > tr:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child {\n  border-bottom-right-radius: 3px;\n  border-bottom-left-radius: 3px;\n}\n.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child,\n.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child,\n.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child,\n.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child,\n.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child,\n.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child,\n.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child,\n.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child {\n  border-bottom-left-radius: 3px;\n}\n.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child,\n.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child,\n.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child,\n.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child,\n.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child {\n  border-bottom-right-radius: 3px;\n}\n.panel > .panel-body + .table,\n.panel > .panel-body + .table-responsive,\n.panel > .table + .panel-body,\n.panel > .table-responsive + .panel-body {\n  border-top: 1px solid #ddd;\n}\n.panel > .table > tbody:first-child > tr:first-child th,\n.panel > .table > tbody:first-child > tr:first-child td {\n  border-top: 0;\n}\n.panel > .table-bordered,\n.panel > .table-responsive > .table-bordered {\n  border: 0;\n}\n.panel > .table-bordered > thead > tr > th:first-child,\n.panel > .table-responsive > .table-bordered > thead > tr > th:first-child,\n.panel > .table-bordered > tbody > tr > th:first-child,\n.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child,\n.panel > .table-bordered > tfoot > tr > th:first-child,\n.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child,\n.panel > .table-bordered > thead > tr > td:first-child,\n.panel > .table-responsive > .table-bordered > thead > tr > td:first-child,\n.panel > .table-bordered > tbody > tr > td:first-child,\n.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child,\n.panel > .table-bordered > tfoot > tr > td:first-child,\n.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {\n  border-left: 0;\n}\n.panel > .table-bordered > thead > tr > th:last-child,\n.panel > .table-responsive > .table-bordered > thead > tr > th:last-child,\n.panel > .table-bordered > tbody > tr > th:last-child,\n.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child,\n.panel > .table-bordered > tfoot > tr > th:last-child,\n.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child,\n.panel > .table-bordered > thead > tr > td:last-child,\n.panel > .table-responsive > .table-bordered > thead > tr > td:last-child,\n.panel > .table-bordered > tbody > tr > td:last-child,\n.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child,\n.panel > .table-bordered > tfoot > tr > td:last-child,\n.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {\n  border-right: 0;\n}\n.panel > .table-bordered > thead > tr:first-child > td,\n.panel > .table-responsive > .table-bordered > thead > tr:first-child > td,\n.panel > .table-bordered > tbody > tr:first-child > td,\n.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td,\n.panel > .table-bordered > thead > tr:first-child > th,\n.panel > .table-responsive > .table-bordered > thead > tr:first-child > th,\n.panel > .table-bordered > tbody > tr:first-child > th,\n.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th {\n  border-bottom: 0;\n}\n.panel > .table-bordered > tbody > tr:last-child > td,\n.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td,\n.panel > .table-bordered > tfoot > tr:last-child > td,\n.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td,\n.panel > .table-bordered > tbody > tr:last-child > th,\n.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th,\n.panel > .table-bordered > tfoot > tr:last-child > th,\n.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th {\n  border-bottom: 0;\n}\n.panel > .table-responsive {\n  margin-bottom: 0;\n  border: 0;\n}\n.panel-group {\n  margin-bottom: 20px;\n}\n.panel-group .panel {\n  margin-bottom: 0;\n  border-radius: 4px;\n}\n.panel-group .panel + .panel {\n  margin-top: 5px;\n}\n.panel-group .panel-heading {\n  border-bottom: 0;\n}\n.panel-group .panel-heading + .panel-collapse > .panel-body,\n.panel-group .panel-heading + .panel-collapse > .list-group {\n  border-top: 1px solid #ddd;\n}\n.panel-group .panel-footer {\n  border-top: 0;\n}\n.panel-group .panel-footer + .panel-collapse .panel-body {\n  border-bottom: 1px solid #ddd;\n}\n.panel-default {\n  border-color: #ddd;\n}\n.panel-default > .panel-heading {\n  color: #333;\n  background-color: #f5f5f5;\n  border-color: #ddd;\n}\n.panel-default > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #ddd;\n}\n.panel-default > .panel-heading .badge {\n  color: #f5f5f5;\n  background-color: #333;\n}\n.panel-default > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #ddd;\n}\n.panel-primary {\n  border-color: #337ab7;\n}\n.panel-primary > .panel-heading {\n  color: #fff;\n  background-color: #337ab7;\n  border-color: #337ab7;\n}\n.panel-primary > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #337ab7;\n}\n.panel-primary > .panel-heading .badge {\n  color: #337ab7;\n  background-color: #fff;\n}\n.panel-primary > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #337ab7;\n}\n.panel-success {\n  border-color: #d6e9c6;\n}\n.panel-success > .panel-heading {\n  color: #3c763d;\n  background-color: #dff0d8;\n  border-color: #d6e9c6;\n}\n.panel-success > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #d6e9c6;\n}\n.panel-success > .panel-heading .badge {\n  color: #dff0d8;\n  background-color: #3c763d;\n}\n.panel-success > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #d6e9c6;\n}\n.panel-info {\n  border-color: #bce8f1;\n}\n.panel-info > .panel-heading {\n  color: #31708f;\n  background-color: #d9edf7;\n  border-color: #bce8f1;\n}\n.panel-info > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #bce8f1;\n}\n.panel-info > .panel-heading .badge {\n  color: #d9edf7;\n  background-color: #31708f;\n}\n.panel-info > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #bce8f1;\n}\n.panel-warning {\n  border-color: #faebcc;\n}\n.panel-warning > .panel-heading {\n  color: #8a6d3b;\n  background-color: #fcf8e3;\n  border-color: #faebcc;\n}\n.panel-warning > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #faebcc;\n}\n.panel-warning > .panel-heading .badge {\n  color: #fcf8e3;\n  background-color: #8a6d3b;\n}\n.panel-warning > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #faebcc;\n}\n.panel-danger {\n  border-color: #ebccd1;\n}\n.panel-danger > .panel-heading {\n  color: #a94442;\n  background-color: #f2dede;\n  border-color: #ebccd1;\n}\n.panel-danger > .panel-heading + .panel-collapse > .panel-body {\n  border-top-color: #ebccd1;\n}\n.panel-danger > .panel-heading .badge {\n  color: #f2dede;\n  background-color: #a94442;\n}\n.panel-danger > .panel-footer + .panel-collapse > .panel-body {\n  border-bottom-color: #ebccd1;\n}\n.embed-responsive {\n  position: relative;\n  display: block;\n  height: 0;\n  padding: 0;\n  overflow: hidden;\n}\n.embed-responsive .embed-responsive-item,\n.embed-responsive iframe,\n.embed-responsive embed,\n.embed-responsive object,\n.embed-responsive video {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  border: 0;\n}\n.embed-responsive-16by9 {\n  padding-bottom: 56.25%;\n}\n.embed-responsive-4by3 {\n  padding-bottom: 75%;\n}\n.well {\n  min-height: 20px;\n  padding: 19px;\n  margin-bottom: 20px;\n  background-color: #f5f5f5;\n  border: 1px solid #e3e3e3;\n  border-radius: 4px;\n  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);\n          box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);\n}\n.well blockquote {\n  border-color: #ddd;\n  border-color: rgba(0, 0, 0, .15);\n}\n.well-lg {\n  padding: 24px;\n  border-radius: 6px;\n}\n.well-sm {\n  padding: 9px;\n  border-radius: 3px;\n}\n.close {\n  float: right;\n  font-size: 21px;\n  font-weight: bold;\n  line-height: 1;\n  color: #000;\n  text-shadow: 0 1px 0 #fff;\n  filter: alpha(opacity=20);\n  opacity: .2;\n}\n.close:hover,\n.close:focus {\n  color: #000;\n  text-decoration: none;\n  cursor: pointer;\n  filter: alpha(opacity=50);\n  opacity: .5;\n}\nbutton.close {\n  -webkit-appearance: none;\n  padding: 0;\n  cursor: pointer;\n  background: transparent;\n  border: 0;\n}\n.modal-open {\n  overflow: hidden;\n}\n.modal {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1050;\n  display: none;\n  overflow: hidden;\n  -webkit-overflow-scrolling: touch;\n  outline: 0;\n}\n.modal.fade .modal-dialog {\n  -webkit-transition: -webkit-transform .3s ease-out;\n       -o-transition:      -o-transform .3s ease-out;\n          transition:         transform .3s ease-out;\n  -webkit-transform: translate(0, -25%);\n      -ms-transform: translate(0, -25%);\n       -o-transform: translate(0, -25%);\n          transform: translate(0, -25%);\n}\n.modal.in .modal-dialog {\n  -webkit-transform: translate(0, 0);\n      -ms-transform: translate(0, 0);\n       -o-transform: translate(0, 0);\n          transform: translate(0, 0);\n}\n.modal-open .modal {\n  overflow-x: hidden;\n  overflow-y: auto;\n}\n.modal-dialog {\n  position: relative;\n  width: auto;\n  margin: 10px;\n}\n.modal-content {\n  position: relative;\n  background-color: #fff;\n  -webkit-background-clip: padding-box;\n          background-clip: padding-box;\n  border: 1px solid #999;\n  border: 1px solid rgba(0, 0, 0, .2);\n  border-radius: 6px;\n  outline: 0;\n  -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);\n          box-shadow: 0 3px 9px rgba(0, 0, 0, .5);\n}\n.modal-backdrop {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1040;\n  background-color: #000;\n}\n.modal-backdrop.fade {\n  filter: alpha(opacity=0);\n  opacity: 0;\n}\n.modal-backdrop.in {\n  filter: alpha(opacity=50);\n  opacity: .5;\n}\n.modal-header {\n  padding: 15px;\n  border-bottom: 1px solid #e5e5e5;\n}\n.modal-header .close {\n  margin-top: -2px;\n}\n.modal-title {\n  margin: 0;\n  line-height: 1.42857143;\n}\n.modal-body {\n  position: relative;\n  padding: 15px;\n}\n.modal-footer {\n  padding: 15px;\n  text-align: right;\n  border-top: 1px solid #e5e5e5;\n}\n.modal-footer .btn + .btn {\n  margin-bottom: 0;\n  margin-left: 5px;\n}\n.modal-footer .btn-group .btn + .btn {\n  margin-left: -1px;\n}\n.modal-footer .btn-block + .btn-block {\n  margin-left: 0;\n}\n.modal-scrollbar-measure {\n  position: absolute;\n  top: -9999px;\n  width: 50px;\n  height: 50px;\n  overflow: scroll;\n}\n@media (min-width: 768px) {\n  .modal-dialog {\n    width: 600px;\n    margin: 30px auto;\n  }\n  .modal-content {\n    -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);\n            box-shadow: 0 5px 15px rgba(0, 0, 0, .5);\n  }\n  .modal-sm {\n    width: 300px;\n  }\n}\n@media (min-width: 992px) {\n  .modal-lg {\n    width: 900px;\n  }\n}\n.tooltip {\n  position: absolute;\n  z-index: 1070;\n  display: block;\n  font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  font-size: 12px;\n  font-style: normal;\n  font-weight: normal;\n  line-height: 1.42857143;\n  text-align: left;\n  text-align: start;\n  text-decoration: none;\n  text-shadow: none;\n  text-transform: none;\n  letter-spacing: normal;\n  word-break: normal;\n  word-spacing: normal;\n  word-wrap: normal;\n  white-space: normal;\n  filter: alpha(opacity=0);\n  opacity: 0;\n\n  line-break: auto;\n}\n.tooltip.in {\n  filter: alpha(opacity=90);\n  opacity: .9;\n}\n.tooltip.top {\n  padding: 5px 0;\n  margin-top: -3px;\n}\n.tooltip.right {\n  padding: 0 5px;\n  margin-left: 3px;\n}\n.tooltip.bottom {\n  padding: 5px 0;\n  margin-top: 3px;\n}\n.tooltip.left {\n  padding: 0 5px;\n  margin-left: -3px;\n}\n.tooltip-inner {\n  max-width: 200px;\n  padding: 3px 8px;\n  color: #fff;\n  text-align: center;\n  background-color: #000;\n  border-radius: 4px;\n}\n.tooltip-arrow {\n  position: absolute;\n  width: 0;\n  height: 0;\n  border-color: transparent;\n  border-style: solid;\n}\n.tooltip.top .tooltip-arrow {\n  bottom: 0;\n  left: 50%;\n  margin-left: -5px;\n  border-width: 5px 5px 0;\n  border-top-color: #000;\n}\n.tooltip.top-left .tooltip-arrow {\n  right: 5px;\n  bottom: 0;\n  margin-bottom: -5px;\n  border-width: 5px 5px 0;\n  border-top-color: #000;\n}\n.tooltip.top-right .tooltip-arrow {\n  bottom: 0;\n  left: 5px;\n  margin-bottom: -5px;\n  border-width: 5px 5px 0;\n  border-top-color: #000;\n}\n.tooltip.right .tooltip-arrow {\n  top: 50%;\n  left: 0;\n  margin-top: -5px;\n  border-width: 5px 5px 5px 0;\n  border-right-color: #000;\n}\n.tooltip.left .tooltip-arrow {\n  top: 50%;\n  right: 0;\n  margin-top: -5px;\n  border-width: 5px 0 5px 5px;\n  border-left-color: #000;\n}\n.tooltip.bottom .tooltip-arrow {\n  top: 0;\n  left: 50%;\n  margin-left: -5px;\n  border-width: 0 5px 5px;\n  border-bottom-color: #000;\n}\n.tooltip.bottom-left .tooltip-arrow {\n  top: 0;\n  right: 5px;\n  margin-top: -5px;\n  border-width: 0 5px 5px;\n  border-bottom-color: #000;\n}\n.tooltip.bottom-right .tooltip-arrow {\n  top: 0;\n  left: 5px;\n  margin-top: -5px;\n  border-width: 0 5px 5px;\n  border-bottom-color: #000;\n}\n.popover {\n  position: absolute;\n  top: 0;\n  left: 0;\n  z-index: 1060;\n  display: none;\n  max-width: 276px;\n  padding: 1px;\n  font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  font-size: 14px;\n  font-style: normal;\n  font-weight: normal;\n  line-height: 1.42857143;\n  text-align: left;\n  text-align: start;\n  text-decoration: none;\n  text-shadow: none;\n  text-transform: none;\n  letter-spacing: normal;\n  word-break: normal;\n  word-spacing: normal;\n  word-wrap: normal;\n  white-space: normal;\n  background-color: #fff;\n  -webkit-background-clip: padding-box;\n          background-clip: padding-box;\n  border: 1px solid #ccc;\n  border: 1px solid rgba(0, 0, 0, .2);\n  border-radius: 6px;\n  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);\n          box-shadow: 0 5px 10px rgba(0, 0, 0, .2);\n\n  line-break: auto;\n}\n.popover.top {\n  margin-top: -10px;\n}\n.popover.right {\n  margin-left: 10px;\n}\n.popover.bottom {\n  margin-top: 10px;\n}\n.popover.left {\n  margin-left: -10px;\n}\n.popover-title {\n  padding: 8px 14px;\n  margin: 0;\n  font-size: 14px;\n  background-color: #f7f7f7;\n  border-bottom: 1px solid #ebebeb;\n  border-radius: 5px 5px 0 0;\n}\n.popover-content {\n  padding: 9px 14px;\n}\n.popover > .arrow,\n.popover > .arrow:after {\n  position: absolute;\n  display: block;\n  width: 0;\n  height: 0;\n  border-color: transparent;\n  border-style: solid;\n}\n.popover > .arrow {\n  border-width: 11px;\n}\n.popover > .arrow:after {\n  content: \"\";\n  border-width: 10px;\n}\n.popover.top > .arrow {\n  bottom: -11px;\n  left: 50%;\n  margin-left: -11px;\n  border-top-color: #999;\n  border-top-color: rgba(0, 0, 0, .25);\n  border-bottom-width: 0;\n}\n.popover.top > .arrow:after {\n  bottom: 1px;\n  margin-left: -10px;\n  content: \" \";\n  border-top-color: #fff;\n  border-bottom-width: 0;\n}\n.popover.right > .arrow {\n  top: 50%;\n  left: -11px;\n  margin-top: -11px;\n  border-right-color: #999;\n  border-right-color: rgba(0, 0, 0, .25);\n  border-left-width: 0;\n}\n.popover.right > .arrow:after {\n  bottom: -10px;\n  left: 1px;\n  content: \" \";\n  border-right-color: #fff;\n  border-left-width: 0;\n}\n.popover.bottom > .arrow {\n  top: -11px;\n  left: 50%;\n  margin-left: -11px;\n  border-top-width: 0;\n  border-bottom-color: #999;\n  border-bottom-color: rgba(0, 0, 0, .25);\n}\n.popover.bottom > .arrow:after {\n  top: 1px;\n  margin-left: -10px;\n  content: \" \";\n  border-top-width: 0;\n  border-bottom-color: #fff;\n}\n.popover.left > .arrow {\n  top: 50%;\n  right: -11px;\n  margin-top: -11px;\n  border-right-width: 0;\n  border-left-color: #999;\n  border-left-color: rgba(0, 0, 0, .25);\n}\n.popover.left > .arrow:after {\n  right: 1px;\n  bottom: -10px;\n  content: \" \";\n  border-right-width: 0;\n  border-left-color: #fff;\n}\n.carousel {\n  position: relative;\n}\n.carousel-inner {\n  position: relative;\n  width: 100%;\n  overflow: hidden;\n}\n.carousel-inner > .item {\n  position: relative;\n  display: none;\n  -webkit-transition: .6s ease-in-out left;\n       -o-transition: .6s ease-in-out left;\n          transition: .6s ease-in-out left;\n}\n.carousel-inner > .item > img,\n.carousel-inner > .item > a > img {\n  line-height: 1;\n}\n@media all and (transform-3d), (-webkit-transform-3d) {\n  .carousel-inner > .item {\n    -webkit-transition: -webkit-transform .6s ease-in-out;\n         -o-transition:      -o-transform .6s ease-in-out;\n            transition:         transform .6s ease-in-out;\n\n    -webkit-backface-visibility: hidden;\n            backface-visibility: hidden;\n    -webkit-perspective: 1000px;\n            perspective: 1000px;\n  }\n  .carousel-inner > .item.next,\n  .carousel-inner > .item.active.right {\n    left: 0;\n    -webkit-transform: translate3d(100%, 0, 0);\n            transform: translate3d(100%, 0, 0);\n  }\n  .carousel-inner > .item.prev,\n  .carousel-inner > .item.active.left {\n    left: 0;\n    -webkit-transform: translate3d(-100%, 0, 0);\n            transform: translate3d(-100%, 0, 0);\n  }\n  .carousel-inner > .item.next.left,\n  .carousel-inner > .item.prev.right,\n  .carousel-inner > .item.active {\n    left: 0;\n    -webkit-transform: translate3d(0, 0, 0);\n            transform: translate3d(0, 0, 0);\n  }\n}\n.carousel-inner > .active,\n.carousel-inner > .next,\n.carousel-inner > .prev {\n  display: block;\n}\n.carousel-inner > .active {\n  left: 0;\n}\n.carousel-inner > .next,\n.carousel-inner > .prev {\n  position: absolute;\n  top: 0;\n  width: 100%;\n}\n.carousel-inner > .next {\n  left: 100%;\n}\n.carousel-inner > .prev {\n  left: -100%;\n}\n.carousel-inner > .next.left,\n.carousel-inner > .prev.right {\n  left: 0;\n}\n.carousel-inner > .active.left {\n  left: -100%;\n}\n.carousel-inner > .active.right {\n  left: 100%;\n}\n.carousel-control {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  width: 15%;\n  font-size: 20px;\n  color: #fff;\n  text-align: center;\n  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);\n  background-color: rgba(0, 0, 0, 0);\n  filter: alpha(opacity=50);\n  opacity: .5;\n}\n.carousel-control.left {\n  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);\n  background-image:      -o-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);\n  background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .5)), to(rgba(0, 0, 0, .0001)));\n  background-image:         linear-gradient(to right, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);\n  background-repeat: repeat-x;\n}\n.carousel-control.right {\n  right: 0;\n  left: auto;\n  background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);\n  background-image:      -o-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);\n  background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .0001)), to(rgba(0, 0, 0, .5)));\n  background-image:         linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);\n  background-repeat: repeat-x;\n}\n.carousel-control:hover,\n.carousel-control:focus {\n  color: #fff;\n  text-decoration: none;\n  filter: alpha(opacity=90);\n  outline: 0;\n  opacity: .9;\n}\n.carousel-control .icon-prev,\n.carousel-control .icon-next,\n.carousel-control .glyphicon-chevron-left,\n.carousel-control .glyphicon-chevron-right {\n  position: absolute;\n  top: 50%;\n  z-index: 5;\n  display: inline-block;\n  margin-top: -10px;\n}\n.carousel-control .icon-prev,\n.carousel-control .glyphicon-chevron-left {\n  left: 50%;\n  margin-left: -10px;\n}\n.carousel-control .icon-next,\n.carousel-control .glyphicon-chevron-right {\n  right: 50%;\n  margin-right: -10px;\n}\n.carousel-control .icon-prev,\n.carousel-control .icon-next {\n  width: 20px;\n  height: 20px;\n  font-family: serif;\n  line-height: 1;\n}\n.carousel-control .icon-prev:before {\n  content: '\\2039';\n}\n.carousel-control .icon-next:before {\n  content: '\\203a';\n}\n.carousel-indicators {\n  position: absolute;\n  bottom: 10px;\n  left: 50%;\n  z-index: 15;\n  width: 60%;\n  padding-left: 0;\n  margin-left: -30%;\n  text-align: center;\n  list-style: none;\n}\n.carousel-indicators li {\n  display: inline-block;\n  width: 10px;\n  height: 10px;\n  margin: 1px;\n  text-indent: -999px;\n  cursor: pointer;\n  background-color: #000 \\9;\n  background-color: rgba(0, 0, 0, 0);\n  border: 1px solid #fff;\n  border-radius: 10px;\n}\n.carousel-indicators .active {\n  width: 12px;\n  height: 12px;\n  margin: 0;\n  background-color: #fff;\n}\n.carousel-caption {\n  position: absolute;\n  right: 15%;\n  bottom: 20px;\n  left: 15%;\n  z-index: 10;\n  padding-top: 20px;\n  padding-bottom: 20px;\n  color: #fff;\n  text-align: center;\n  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);\n}\n.carousel-caption .btn {\n  text-shadow: none;\n}\n@media screen and (min-width: 768px) {\n  .carousel-control .glyphicon-chevron-left,\n  .carousel-control .glyphicon-chevron-right,\n  .carousel-control .icon-prev,\n  .carousel-control .icon-next {\n    width: 30px;\n    height: 30px;\n    margin-top: -10px;\n    font-size: 30px;\n  }\n  .carousel-control .glyphicon-chevron-left,\n  .carousel-control .icon-prev {\n    margin-left: -10px;\n  }\n  .carousel-control .glyphicon-chevron-right,\n  .carousel-control .icon-next {\n    margin-right: -10px;\n  }\n  .carousel-caption {\n    right: 20%;\n    left: 20%;\n    padding-bottom: 30px;\n  }\n  .carousel-indicators {\n    bottom: 20px;\n  }\n}\n.clearfix:before,\n.clearfix:after,\n.dl-horizontal dd:before,\n.dl-horizontal dd:after,\n.container:before,\n.container:after,\n.container-fluid:before,\n.container-fluid:after,\n.row:before,\n.row:after,\n.form-horizontal .form-group:before,\n.form-horizontal .form-group:after,\n.btn-toolbar:before,\n.btn-toolbar:after,\n.btn-group-vertical > .btn-group:before,\n.btn-group-vertical > .btn-group:after,\n.nav:before,\n.nav:after,\n.navbar:before,\n.navbar:after,\n.navbar-header:before,\n.navbar-header:after,\n.navbar-collapse:before,\n.navbar-collapse:after,\n.pager:before,\n.pager:after,\n.panel-body:before,\n.panel-body:after,\n.modal-header:before,\n.modal-header:after,\n.modal-footer:before,\n.modal-footer:after {\n  display: table;\n  content: \" \";\n}\n.clearfix:after,\n.dl-horizontal dd:after,\n.container:after,\n.container-fluid:after,\n.row:after,\n.form-horizontal .form-group:after,\n.btn-toolbar:after,\n.btn-group-vertical > .btn-group:after,\n.nav:after,\n.navbar:after,\n.navbar-header:after,\n.navbar-collapse:after,\n.pager:after,\n.panel-body:after,\n.modal-header:after,\n.modal-footer:after {\n  clear: both;\n}\n.center-block {\n  display: block;\n  margin-right: auto;\n  margin-left: auto;\n}\n.pull-right {\n  float: right !important;\n}\n.pull-left {\n  float: left !important;\n}\n.hide {\n  display: none !important;\n}\n.show {\n  display: block !important;\n}\n.invisible {\n  visibility: hidden;\n}\n.text-hide {\n  font: 0/0 a;\n  color: transparent;\n  text-shadow: none;\n  background-color: transparent;\n  border: 0;\n}\n.hidden {\n  display: none !important;\n}\n.affix {\n  position: fixed;\n}\n@-ms-viewport {\n  width: device-width;\n}\n.visible-xs,\n.visible-sm,\n.visible-md,\n.visible-lg {\n  display: none !important;\n}\n.visible-xs-block,\n.visible-xs-inline,\n.visible-xs-inline-block,\n.visible-sm-block,\n.visible-sm-inline,\n.visible-sm-inline-block,\n.visible-md-block,\n.visible-md-inline,\n.visible-md-inline-block,\n.visible-lg-block,\n.visible-lg-inline,\n.visible-lg-inline-block {\n  display: none !important;\n}\n@media (max-width: 767px) {\n  .visible-xs {\n    display: block !important;\n  }\n  table.visible-xs {\n    display: table !important;\n  }\n  tr.visible-xs {\n    display: table-row !important;\n  }\n  th.visible-xs,\n  td.visible-xs {\n    display: table-cell !important;\n  }\n}\n@media (max-width: 767px) {\n  .visible-xs-block {\n    display: block !important;\n  }\n}\n@media (max-width: 767px) {\n  .visible-xs-inline {\n    display: inline !important;\n  }\n}\n@media (max-width: 767px) {\n  .visible-xs-inline-block {\n    display: inline-block !important;\n  }\n}\n@media (min-width: 768px) and (max-width: 991px) {\n  .visible-sm {\n    display: block !important;\n  }\n  table.visible-sm {\n    display: table !important;\n  }\n  tr.visible-sm {\n    display: table-row !important;\n  }\n  th.visible-sm,\n  td.visible-sm {\n    display: table-cell !important;\n  }\n}\n@media (min-width: 768px) and (max-width: 991px) {\n  .visible-sm-block {\n    display: block !important;\n  }\n}\n@media (min-width: 768px) and (max-width: 991px) {\n  .visible-sm-inline {\n    display: inline !important;\n  }\n}\n@media (min-width: 768px) and (max-width: 991px) {\n  .visible-sm-inline-block {\n    display: inline-block !important;\n  }\n}\n@media (min-width: 992px) and (max-width: 1199px) {\n  .visible-md {\n    display: block !important;\n  }\n  table.visible-md {\n    display: table !important;\n  }\n  tr.visible-md {\n    display: table-row !important;\n  }\n  th.visible-md,\n  td.visible-md {\n    display: table-cell !important;\n  }\n}\n@media (min-width: 992px) and (max-width: 1199px) {\n  .visible-md-block {\n    display: block !important;\n  }\n}\n@media (min-width: 992px) and (max-width: 1199px) {\n  .visible-md-inline {\n    display: inline !important;\n  }\n}\n@media (min-width: 992px) and (max-width: 1199px) {\n  .visible-md-inline-block {\n    display: inline-block !important;\n  }\n}\n@media (min-width: 1200px) {\n  .visible-lg {\n    display: block !important;\n  }\n  table.visible-lg {\n    display: table !important;\n  }\n  tr.visible-lg {\n    display: table-row !important;\n  }\n  th.visible-lg,\n  td.visible-lg {\n    display: table-cell !important;\n  }\n}\n@media (min-width: 1200px) {\n  .visible-lg-block {\n    display: block !important;\n  }\n}\n@media (min-width: 1200px) {\n  .visible-lg-inline {\n    display: inline !important;\n  }\n}\n@media (min-width: 1200px) {\n  .visible-lg-inline-block {\n    display: inline-block !important;\n  }\n}\n@media (max-width: 767px) {\n  .hidden-xs {\n    display: none !important;\n  }\n}\n@media (min-width: 768px) and (max-width: 991px) {\n  .hidden-sm {\n    display: none !important;\n  }\n}\n@media (min-width: 992px) and (max-width: 1199px) {\n  .hidden-md {\n    display: none !important;\n  }\n}\n@media (min-width: 1200px) {\n  .hidden-lg {\n    display: none !important;\n  }\n}\n.visible-print {\n  display: none !important;\n}\n@media print {\n  .visible-print {\n    display: block !important;\n  }\n  table.visible-print {\n    display: table !important;\n  }\n  tr.visible-print {\n    display: table-row !important;\n  }\n  th.visible-print,\n  td.visible-print {\n    display: table-cell !important;\n  }\n}\n.visible-print-block {\n  display: none !important;\n}\n@media print {\n  .visible-print-block {\n    display: block !important;\n  }\n}\n.visible-print-inline {\n  display: none !important;\n}\n@media print {\n  .visible-print-inline {\n    display: inline !important;\n  }\n}\n.visible-print-inline-block {\n  display: none !important;\n}\n@media print {\n  .visible-print-inline-block {\n    display: inline-block !important;\n  }\n}\n@media print {\n  .hidden-print {\n    display: none !important;\n  }\n}\n/*# sourceMappingURL=bootstrap.css.map */\n"
  },
  {
    "path": "html/lib/bootstrap/bootstrap.js",
    "content": "/*!\n * Bootstrap v3.3.6 (http://getbootstrap.com)\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under the MIT license\n */\n\nif (typeof jQuery === 'undefined') {\n  throw new Error('Bootstrap\\'s JavaScript requires jQuery')\n}\n\n+function ($) {\n  'use strict';\n  var version = $.fn.jquery.split(' ')[0].split('.')\n  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 2)) {\n    throw new Error('Bootstrap\\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3')\n  }\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: transition.js v3.3.6\n * http://getbootstrap.com/javascript/#transitions\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)\n  // ============================================================\n\n  function transitionEnd() {\n    var el = document.createElement('bootstrap')\n\n    var transEndEventNames = {\n      WebkitTransition : 'webkitTransitionEnd',\n      MozTransition    : 'transitionend',\n      OTransition      : 'oTransitionEnd otransitionend',\n      transition       : 'transitionend'\n    }\n\n    for (var name in transEndEventNames) {\n      if (el.style[name] !== undefined) {\n        return { end: transEndEventNames[name] }\n      }\n    }\n\n    return false // explicit for ie8 (  ._.)\n  }\n\n  // http://blog.alexmaccaw.com/css-transitions\n  $.fn.emulateTransitionEnd = function (duration) {\n    var called = false\n    var $el = this\n    $(this).one('bsTransitionEnd', function () { called = true })\n    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }\n    setTimeout(callback, duration)\n    return this\n  }\n\n  $(function () {\n    $.support.transition = transitionEnd()\n\n    if (!$.support.transition) return\n\n    $.event.special.bsTransitionEnd = {\n      bindType: $.support.transition.end,\n      delegateType: $.support.transition.end,\n      handle: function (e) {\n        if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)\n      }\n    }\n  })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: alert.js v3.3.6\n * http://getbootstrap.com/javascript/#alerts\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // ALERT CLASS DEFINITION\n  // ======================\n\n  var dismiss = '[data-dismiss=\"alert\"]'\n  var Alert   = function (el) {\n    $(el).on('click', dismiss, this.close)\n  }\n\n  Alert.VERSION = '3.3.6'\n\n  Alert.TRANSITION_DURATION = 150\n\n  Alert.prototype.close = function (e) {\n    var $this    = $(this)\n    var selector = $this.attr('data-target')\n\n    if (!selector) {\n      selector = $this.attr('href')\n      selector = selector && selector.replace(/.*(?=#[^\\s]*$)/, '') // strip for ie7\n    }\n\n    var $parent = $(selector)\n\n    if (e) e.preventDefault()\n\n    if (!$parent.length) {\n      $parent = $this.closest('.alert')\n    }\n\n    $parent.trigger(e = $.Event('close.bs.alert'))\n\n    if (e.isDefaultPrevented()) return\n\n    $parent.removeClass('in')\n\n    function removeElement() {\n      // detach from parent, fire event then clean up data\n      $parent.detach().trigger('closed.bs.alert').remove()\n    }\n\n    $.support.transition && $parent.hasClass('fade') ?\n      $parent\n        .one('bsTransitionEnd', removeElement)\n        .emulateTransitionEnd(Alert.TRANSITION_DURATION) :\n      removeElement()\n  }\n\n\n  // ALERT PLUGIN DEFINITION\n  // =======================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this = $(this)\n      var data  = $this.data('bs.alert')\n\n      if (!data) $this.data('bs.alert', (data = new Alert(this)))\n      if (typeof option == 'string') data[option].call($this)\n    })\n  }\n\n  var old = $.fn.alert\n\n  $.fn.alert             = Plugin\n  $.fn.alert.Constructor = Alert\n\n\n  // ALERT NO CONFLICT\n  // =================\n\n  $.fn.alert.noConflict = function () {\n    $.fn.alert = old\n    return this\n  }\n\n\n  // ALERT DATA-API\n  // ==============\n\n  $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: button.js v3.3.6\n * http://getbootstrap.com/javascript/#buttons\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // BUTTON PUBLIC CLASS DEFINITION\n  // ==============================\n\n  var Button = function (element, options) {\n    this.$element  = $(element)\n    this.options   = $.extend({}, Button.DEFAULTS, options)\n    this.isLoading = false\n  }\n\n  Button.VERSION  = '3.3.6'\n\n  Button.DEFAULTS = {\n    loadingText: 'loading...'\n  }\n\n  Button.prototype.setState = function (state) {\n    var d    = 'disabled'\n    var $el  = this.$element\n    var val  = $el.is('input') ? 'val' : 'html'\n    var data = $el.data()\n\n    state += 'Text'\n\n    if (data.resetText == null) $el.data('resetText', $el[val]())\n\n    // push to event loop to allow forms to submit\n    setTimeout($.proxy(function () {\n      $el[val](data[state] == null ? this.options[state] : data[state])\n\n      if (state == 'loadingText') {\n        this.isLoading = true\n        $el.addClass(d).attr(d, d)\n      } else if (this.isLoading) {\n        this.isLoading = false\n        $el.removeClass(d).removeAttr(d)\n      }\n    }, this), 0)\n  }\n\n  Button.prototype.toggle = function () {\n    var changed = true\n    var $parent = this.$element.closest('[data-toggle=\"buttons\"]')\n\n    if ($parent.length) {\n      var $input = this.$element.find('input')\n      if ($input.prop('type') == 'radio') {\n        if ($input.prop('checked')) changed = false\n        $parent.find('.active').removeClass('active')\n        this.$element.addClass('active')\n      } else if ($input.prop('type') == 'checkbox') {\n        if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false\n        this.$element.toggleClass('active')\n      }\n      $input.prop('checked', this.$element.hasClass('active'))\n      if (changed) $input.trigger('change')\n    } else {\n      this.$element.attr('aria-pressed', !this.$element.hasClass('active'))\n      this.$element.toggleClass('active')\n    }\n  }\n\n\n  // BUTTON PLUGIN DEFINITION\n  // ========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.button')\n      var options = typeof option == 'object' && option\n\n      if (!data) $this.data('bs.button', (data = new Button(this, options)))\n\n      if (option == 'toggle') data.toggle()\n      else if (option) data.setState(option)\n    })\n  }\n\n  var old = $.fn.button\n\n  $.fn.button             = Plugin\n  $.fn.button.Constructor = Button\n\n\n  // BUTTON NO CONFLICT\n  // ==================\n\n  $.fn.button.noConflict = function () {\n    $.fn.button = old\n    return this\n  }\n\n\n  // BUTTON DATA-API\n  // ===============\n\n  $(document)\n    .on('click.bs.button.data-api', '[data-toggle^=\"button\"]', function (e) {\n      var $btn = $(e.target)\n      if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')\n      Plugin.call($btn, 'toggle')\n      if (!($(e.target).is('input[type=\"radio\"]') || $(e.target).is('input[type=\"checkbox\"]'))) e.preventDefault()\n    })\n    .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^=\"button\"]', function (e) {\n      $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))\n    })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: carousel.js v3.3.6\n * http://getbootstrap.com/javascript/#carousel\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // CAROUSEL CLASS DEFINITION\n  // =========================\n\n  var Carousel = function (element, options) {\n    this.$element    = $(element)\n    this.$indicators = this.$element.find('.carousel-indicators')\n    this.options     = options\n    this.paused      = null\n    this.sliding     = null\n    this.interval    = null\n    this.$active     = null\n    this.$items      = null\n\n    this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))\n\n    this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element\n      .on('mouseenter.bs.carousel', $.proxy(this.pause, this))\n      .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))\n  }\n\n  Carousel.VERSION  = '3.3.6'\n\n  Carousel.TRANSITION_DURATION = 600\n\n  Carousel.DEFAULTS = {\n    interval: 5000,\n    pause: 'hover',\n    wrap: true,\n    keyboard: true\n  }\n\n  Carousel.prototype.keydown = function (e) {\n    if (/input|textarea/i.test(e.target.tagName)) return\n    switch (e.which) {\n      case 37: this.prev(); break\n      case 39: this.next(); break\n      default: return\n    }\n\n    e.preventDefault()\n  }\n\n  Carousel.prototype.cycle = function (e) {\n    e || (this.paused = false)\n\n    this.interval && clearInterval(this.interval)\n\n    this.options.interval\n      && !this.paused\n      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))\n\n    return this\n  }\n\n  Carousel.prototype.getItemIndex = function (item) {\n    this.$items = item.parent().children('.item')\n    return this.$items.index(item || this.$active)\n  }\n\n  Carousel.prototype.getItemForDirection = function (direction, active) {\n    var activeIndex = this.getItemIndex(active)\n    var willWrap = (direction == 'prev' && activeIndex === 0)\n                || (direction == 'next' && activeIndex == (this.$items.length - 1))\n    if (willWrap && !this.options.wrap) return active\n    var delta = direction == 'prev' ? -1 : 1\n    var itemIndex = (activeIndex + delta) % this.$items.length\n    return this.$items.eq(itemIndex)\n  }\n\n  Carousel.prototype.to = function (pos) {\n    var that        = this\n    var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))\n\n    if (pos > (this.$items.length - 1) || pos < 0) return\n\n    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, \"slid\"\n    if (activeIndex == pos) return this.pause().cycle()\n\n    return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos))\n  }\n\n  Carousel.prototype.pause = function (e) {\n    e || (this.paused = true)\n\n    if (this.$element.find('.next, .prev').length && $.support.transition) {\n      this.$element.trigger($.support.transition.end)\n      this.cycle(true)\n    }\n\n    this.interval = clearInterval(this.interval)\n\n    return this\n  }\n\n  Carousel.prototype.next = function () {\n    if (this.sliding) return\n    return this.slide('next')\n  }\n\n  Carousel.prototype.prev = function () {\n    if (this.sliding) return\n    return this.slide('prev')\n  }\n\n  Carousel.prototype.slide = function (type, next) {\n    var $active   = this.$element.find('.item.active')\n    var $next     = next || this.getItemForDirection(type, $active)\n    var isCycling = this.interval\n    var direction = type == 'next' ? 'left' : 'right'\n    var that      = this\n\n    if ($next.hasClass('active')) return (this.sliding = false)\n\n    var relatedTarget = $next[0]\n    var slideEvent = $.Event('slide.bs.carousel', {\n      relatedTarget: relatedTarget,\n      direction: direction\n    })\n    this.$element.trigger(slideEvent)\n    if (slideEvent.isDefaultPrevented()) return\n\n    this.sliding = true\n\n    isCycling && this.pause()\n\n    if (this.$indicators.length) {\n      this.$indicators.find('.active').removeClass('active')\n      var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])\n      $nextIndicator && $nextIndicator.addClass('active')\n    }\n\n    var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, \"slid\"\n    if ($.support.transition && this.$element.hasClass('slide')) {\n      $next.addClass(type)\n      $next[0].offsetWidth // force reflow\n      $active.addClass(direction)\n      $next.addClass(direction)\n      $active\n        .one('bsTransitionEnd', function () {\n          $next.removeClass([type, direction].join(' ')).addClass('active')\n          $active.removeClass(['active', direction].join(' '))\n          that.sliding = false\n          setTimeout(function () {\n            that.$element.trigger(slidEvent)\n          }, 0)\n        })\n        .emulateTransitionEnd(Carousel.TRANSITION_DURATION)\n    } else {\n      $active.removeClass('active')\n      $next.addClass('active')\n      this.sliding = false\n      this.$element.trigger(slidEvent)\n    }\n\n    isCycling && this.cycle()\n\n    return this\n  }\n\n\n  // CAROUSEL PLUGIN DEFINITION\n  // ==========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.carousel')\n      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)\n      var action  = typeof option == 'string' ? option : options.slide\n\n      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))\n      if (typeof option == 'number') data.to(option)\n      else if (action) data[action]()\n      else if (options.interval) data.pause().cycle()\n    })\n  }\n\n  var old = $.fn.carousel\n\n  $.fn.carousel             = Plugin\n  $.fn.carousel.Constructor = Carousel\n\n\n  // CAROUSEL NO CONFLICT\n  // ====================\n\n  $.fn.carousel.noConflict = function () {\n    $.fn.carousel = old\n    return this\n  }\n\n\n  // CAROUSEL DATA-API\n  // =================\n\n  var clickHandler = function (e) {\n    var href\n    var $this   = $(this)\n    var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\\s]+$)/, '')) // strip for ie7\n    if (!$target.hasClass('carousel')) return\n    var options = $.extend({}, $target.data(), $this.data())\n    var slideIndex = $this.attr('data-slide-to')\n    if (slideIndex) options.interval = false\n\n    Plugin.call($target, options)\n\n    if (slideIndex) {\n      $target.data('bs.carousel').to(slideIndex)\n    }\n\n    e.preventDefault()\n  }\n\n  $(document)\n    .on('click.bs.carousel.data-api', '[data-slide]', clickHandler)\n    .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler)\n\n  $(window).on('load', function () {\n    $('[data-ride=\"carousel\"]').each(function () {\n      var $carousel = $(this)\n      Plugin.call($carousel, $carousel.data())\n    })\n  })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: collapse.js v3.3.6\n * http://getbootstrap.com/javascript/#collapse\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // COLLAPSE PUBLIC CLASS DEFINITION\n  // ================================\n\n  var Collapse = function (element, options) {\n    this.$element      = $(element)\n    this.options       = $.extend({}, Collapse.DEFAULTS, options)\n    this.$trigger      = $('[data-toggle=\"collapse\"][href=\"#' + element.id + '\"],' +\n                           '[data-toggle=\"collapse\"][data-target=\"#' + element.id + '\"]')\n    this.transitioning = null\n\n    if (this.options.parent) {\n      this.$parent = this.getParent()\n    } else {\n      this.addAriaAndCollapsedClass(this.$element, this.$trigger)\n    }\n\n    if (this.options.toggle) this.toggle()\n  }\n\n  Collapse.VERSION  = '3.3.6'\n\n  Collapse.TRANSITION_DURATION = 350\n\n  Collapse.DEFAULTS = {\n    toggle: true\n  }\n\n  Collapse.prototype.dimension = function () {\n    var hasWidth = this.$element.hasClass('width')\n    return hasWidth ? 'width' : 'height'\n  }\n\n  Collapse.prototype.show = function () {\n    if (this.transitioning || this.$element.hasClass('in')) return\n\n    var activesData\n    var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing')\n\n    if (actives && actives.length) {\n      activesData = actives.data('bs.collapse')\n      if (activesData && activesData.transitioning) return\n    }\n\n    var startEvent = $.Event('show.bs.collapse')\n    this.$element.trigger(startEvent)\n    if (startEvent.isDefaultPrevented()) return\n\n    if (actives && actives.length) {\n      Plugin.call(actives, 'hide')\n      activesData || actives.data('bs.collapse', null)\n    }\n\n    var dimension = this.dimension()\n\n    this.$element\n      .removeClass('collapse')\n      .addClass('collapsing')[dimension](0)\n      .attr('aria-expanded', true)\n\n    this.$trigger\n      .removeClass('collapsed')\n      .attr('aria-expanded', true)\n\n    this.transitioning = 1\n\n    var complete = function () {\n      this.$element\n        .removeClass('collapsing')\n        .addClass('collapse in')[dimension]('')\n      this.transitioning = 0\n      this.$element\n        .trigger('shown.bs.collapse')\n    }\n\n    if (!$.support.transition) return complete.call(this)\n\n    var scrollSize = $.camelCase(['scroll', dimension].join('-'))\n\n    this.$element\n      .one('bsTransitionEnd', $.proxy(complete, this))\n      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize])\n  }\n\n  Collapse.prototype.hide = function () {\n    if (this.transitioning || !this.$element.hasClass('in')) return\n\n    var startEvent = $.Event('hide.bs.collapse')\n    this.$element.trigger(startEvent)\n    if (startEvent.isDefaultPrevented()) return\n\n    var dimension = this.dimension()\n\n    this.$element[dimension](this.$element[dimension]())[0].offsetHeight\n\n    this.$element\n      .addClass('collapsing')\n      .removeClass('collapse in')\n      .attr('aria-expanded', false)\n\n    this.$trigger\n      .addClass('collapsed')\n      .attr('aria-expanded', false)\n\n    this.transitioning = 1\n\n    var complete = function () {\n      this.transitioning = 0\n      this.$element\n        .removeClass('collapsing')\n        .addClass('collapse')\n        .trigger('hidden.bs.collapse')\n    }\n\n    if (!$.support.transition) return complete.call(this)\n\n    this.$element\n      [dimension](0)\n      .one('bsTransitionEnd', $.proxy(complete, this))\n      .emulateTransitionEnd(Collapse.TRANSITION_DURATION)\n  }\n\n  Collapse.prototype.toggle = function () {\n    this[this.$element.hasClass('in') ? 'hide' : 'show']()\n  }\n\n  Collapse.prototype.getParent = function () {\n    return $(this.options.parent)\n      .find('[data-toggle=\"collapse\"][data-parent=\"' + this.options.parent + '\"]')\n      .each($.proxy(function (i, element) {\n        var $element = $(element)\n        this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element)\n      }, this))\n      .end()\n  }\n\n  Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {\n    var isOpen = $element.hasClass('in')\n\n    $element.attr('aria-expanded', isOpen)\n    $trigger\n      .toggleClass('collapsed', !isOpen)\n      .attr('aria-expanded', isOpen)\n  }\n\n  function getTargetFromTrigger($trigger) {\n    var href\n    var target = $trigger.attr('data-target')\n      || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\\s]+$)/, '') // strip for ie7\n\n    return $(target)\n  }\n\n\n  // COLLAPSE PLUGIN DEFINITION\n  // ==========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.collapse')\n      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)\n\n      if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false\n      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.collapse\n\n  $.fn.collapse             = Plugin\n  $.fn.collapse.Constructor = Collapse\n\n\n  // COLLAPSE NO CONFLICT\n  // ====================\n\n  $.fn.collapse.noConflict = function () {\n    $.fn.collapse = old\n    return this\n  }\n\n\n  // COLLAPSE DATA-API\n  // =================\n\n  $(document).on('click.bs.collapse.data-api', '[data-toggle=\"collapse\"]', function (e) {\n    var $this   = $(this)\n\n    if (!$this.attr('data-target')) e.preventDefault()\n\n    var $target = getTargetFromTrigger($this)\n    var data    = $target.data('bs.collapse')\n    var option  = data ? 'toggle' : $this.data()\n\n    Plugin.call($target, option)\n  })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: dropdown.js v3.3.6\n * http://getbootstrap.com/javascript/#dropdowns\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // DROPDOWN CLASS DEFINITION\n  // =========================\n\n  var backdrop = '.dropdown-backdrop'\n  var toggle   = '[data-toggle=\"dropdown\"]'\n  var Dropdown = function (element) {\n    $(element).on('click.bs.dropdown', this.toggle)\n  }\n\n  Dropdown.VERSION = '3.3.6'\n\n  function getParent($this) {\n    var selector = $this.attr('data-target')\n\n    if (!selector) {\n      selector = $this.attr('href')\n      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\\s]*$)/, '') // strip for ie7\n    }\n\n    var $parent = selector && $(selector)\n\n    return $parent && $parent.length ? $parent : $this.parent()\n  }\n\n  function clearMenus(e) {\n    if (e && e.which === 3) return\n    $(backdrop).remove()\n    $(toggle).each(function () {\n      var $this         = $(this)\n      var $parent       = getParent($this)\n      var relatedTarget = { relatedTarget: this }\n\n      if (!$parent.hasClass('open')) return\n\n      if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return\n\n      $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))\n\n      if (e.isDefaultPrevented()) return\n\n      $this.attr('aria-expanded', 'false')\n      $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))\n    })\n  }\n\n  Dropdown.prototype.toggle = function (e) {\n    var $this = $(this)\n\n    if ($this.is('.disabled, :disabled')) return\n\n    var $parent  = getParent($this)\n    var isActive = $parent.hasClass('open')\n\n    clearMenus()\n\n    if (!isActive) {\n      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {\n        // if mobile we use a backdrop because click events don't delegate\n        $(document.createElement('div'))\n          .addClass('dropdown-backdrop')\n          .insertAfter($(this))\n          .on('click', clearMenus)\n      }\n\n      var relatedTarget = { relatedTarget: this }\n      $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))\n\n      if (e.isDefaultPrevented()) return\n\n      $this\n        .trigger('focus')\n        .attr('aria-expanded', 'true')\n\n      $parent\n        .toggleClass('open')\n        .trigger($.Event('shown.bs.dropdown', relatedTarget))\n    }\n\n    return false\n  }\n\n  Dropdown.prototype.keydown = function (e) {\n    if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return\n\n    var $this = $(this)\n\n    e.preventDefault()\n    e.stopPropagation()\n\n    if ($this.is('.disabled, :disabled')) return\n\n    var $parent  = getParent($this)\n    var isActive = $parent.hasClass('open')\n\n    if (!isActive && e.which != 27 || isActive && e.which == 27) {\n      if (e.which == 27) $parent.find(toggle).trigger('focus')\n      return $this.trigger('click')\n    }\n\n    var desc = ' li:not(.disabled):visible a'\n    var $items = $parent.find('.dropdown-menu' + desc)\n\n    if (!$items.length) return\n\n    var index = $items.index(e.target)\n\n    if (e.which == 38 && index > 0)                 index--         // up\n    if (e.which == 40 && index < $items.length - 1) index++         // down\n    if (!~index)                                    index = 0\n\n    $items.eq(index).trigger('focus')\n  }\n\n\n  // DROPDOWN PLUGIN DEFINITION\n  // ==========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this = $(this)\n      var data  = $this.data('bs.dropdown')\n\n      if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))\n      if (typeof option == 'string') data[option].call($this)\n    })\n  }\n\n  var old = $.fn.dropdown\n\n  $.fn.dropdown             = Plugin\n  $.fn.dropdown.Constructor = Dropdown\n\n\n  // DROPDOWN NO CONFLICT\n  // ====================\n\n  $.fn.dropdown.noConflict = function () {\n    $.fn.dropdown = old\n    return this\n  }\n\n\n  // APPLY TO STANDARD DROPDOWN ELEMENTS\n  // ===================================\n\n  $(document)\n    .on('click.bs.dropdown.data-api', clearMenus)\n    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })\n    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)\n    .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)\n    .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: modal.js v3.3.6\n * http://getbootstrap.com/javascript/#modals\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // MODAL CLASS DEFINITION\n  // ======================\n\n  var Modal = function (element, options) {\n    this.options             = options\n    this.$body               = $(document.body)\n    this.$element            = $(element)\n    this.$dialog             = this.$element.find('.modal-dialog')\n    this.$backdrop           = null\n    this.isShown             = null\n    this.originalBodyPad     = null\n    this.scrollbarWidth      = 0\n    this.ignoreBackdropClick = false\n\n    if (this.options.remote) {\n      this.$element\n        .find('.modal-content')\n        .load(this.options.remote, $.proxy(function () {\n          this.$element.trigger('loaded.bs.modal')\n        }, this))\n    }\n  }\n\n  Modal.VERSION  = '3.3.6'\n\n  Modal.TRANSITION_DURATION = 300\n  Modal.BACKDROP_TRANSITION_DURATION = 150\n\n  Modal.DEFAULTS = {\n    backdrop: true,\n    keyboard: true,\n    show: true\n  }\n\n  Modal.prototype.toggle = function (_relatedTarget) {\n    return this.isShown ? this.hide() : this.show(_relatedTarget)\n  }\n\n  Modal.prototype.show = function (_relatedTarget) {\n    var that = this\n    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })\n\n    this.$element.trigger(e)\n\n    if (this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = true\n\n    this.checkScrollbar()\n    this.setScrollbar()\n    this.$body.addClass('modal-open')\n\n    this.escape()\n    this.resize()\n\n    this.$element.on('click.dismiss.bs.modal', '[data-dismiss=\"modal\"]', $.proxy(this.hide, this))\n\n    this.$dialog.on('mousedown.dismiss.bs.modal', function () {\n      that.$element.one('mouseup.dismiss.bs.modal', function (e) {\n        if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true\n      })\n    })\n\n    this.backdrop(function () {\n      var transition = $.support.transition && that.$element.hasClass('fade')\n\n      if (!that.$element.parent().length) {\n        that.$element.appendTo(that.$body) // don't move modals dom position\n      }\n\n      that.$element\n        .show()\n        .scrollTop(0)\n\n      that.adjustDialog()\n\n      if (transition) {\n        that.$element[0].offsetWidth // force reflow\n      }\n\n      that.$element.addClass('in')\n\n      that.enforceFocus()\n\n      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })\n\n      transition ?\n        that.$dialog // wait for modal to slide in\n          .one('bsTransitionEnd', function () {\n            that.$element.trigger('focus').trigger(e)\n          })\n          .emulateTransitionEnd(Modal.TRANSITION_DURATION) :\n        that.$element.trigger('focus').trigger(e)\n    })\n  }\n\n  Modal.prototype.hide = function (e) {\n    if (e) e.preventDefault()\n\n    e = $.Event('hide.bs.modal')\n\n    this.$element.trigger(e)\n\n    if (!this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = false\n\n    this.escape()\n    this.resize()\n\n    $(document).off('focusin.bs.modal')\n\n    this.$element\n      .removeClass('in')\n      .off('click.dismiss.bs.modal')\n      .off('mouseup.dismiss.bs.modal')\n\n    this.$dialog.off('mousedown.dismiss.bs.modal')\n\n    $.support.transition && this.$element.hasClass('fade') ?\n      this.$element\n        .one('bsTransitionEnd', $.proxy(this.hideModal, this))\n        .emulateTransitionEnd(Modal.TRANSITION_DURATION) :\n      this.hideModal()\n  }\n\n  Modal.prototype.enforceFocus = function () {\n    $(document)\n      .off('focusin.bs.modal') // guard against infinite focus loop\n      .on('focusin.bs.modal', $.proxy(function (e) {\n        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {\n          this.$element.trigger('focus')\n        }\n      }, this))\n  }\n\n  Modal.prototype.escape = function () {\n    if (this.isShown && this.options.keyboard) {\n      this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {\n        e.which == 27 && this.hide()\n      }, this))\n    } else if (!this.isShown) {\n      this.$element.off('keydown.dismiss.bs.modal')\n    }\n  }\n\n  Modal.prototype.resize = function () {\n    if (this.isShown) {\n      $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))\n    } else {\n      $(window).off('resize.bs.modal')\n    }\n  }\n\n  Modal.prototype.hideModal = function () {\n    var that = this\n    this.$element.hide()\n    this.backdrop(function () {\n      that.$body.removeClass('modal-open')\n      that.resetAdjustments()\n      that.resetScrollbar()\n      that.$element.trigger('hidden.bs.modal')\n    })\n  }\n\n  Modal.prototype.removeBackdrop = function () {\n    this.$backdrop && this.$backdrop.remove()\n    this.$backdrop = null\n  }\n\n  Modal.prototype.backdrop = function (callback) {\n    var that = this\n    var animate = this.$element.hasClass('fade') ? 'fade' : ''\n\n    if (this.isShown && this.options.backdrop) {\n      var doAnimate = $.support.transition && animate\n\n      this.$backdrop = $(document.createElement('div'))\n        .addClass('modal-backdrop ' + animate)\n        .appendTo(this.$body)\n\n      this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {\n        if (this.ignoreBackdropClick) {\n          this.ignoreBackdropClick = false\n          return\n        }\n        if (e.target !== e.currentTarget) return\n        this.options.backdrop == 'static'\n          ? this.$element[0].focus()\n          : this.hide()\n      }, this))\n\n      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow\n\n      this.$backdrop.addClass('in')\n\n      if (!callback) return\n\n      doAnimate ?\n        this.$backdrop\n          .one('bsTransitionEnd', callback)\n          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :\n        callback()\n\n    } else if (!this.isShown && this.$backdrop) {\n      this.$backdrop.removeClass('in')\n\n      var callbackRemove = function () {\n        that.removeBackdrop()\n        callback && callback()\n      }\n      $.support.transition && this.$element.hasClass('fade') ?\n        this.$backdrop\n          .one('bsTransitionEnd', callbackRemove)\n          .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :\n        callbackRemove()\n\n    } else if (callback) {\n      callback()\n    }\n  }\n\n  // these following methods are used to handle overflowing modals\n\n  Modal.prototype.handleUpdate = function () {\n    this.adjustDialog()\n  }\n\n  Modal.prototype.adjustDialog = function () {\n    var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight\n\n    this.$element.css({\n      paddingLeft:  !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',\n      paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''\n    })\n  }\n\n  Modal.prototype.resetAdjustments = function () {\n    this.$element.css({\n      paddingLeft: '',\n      paddingRight: ''\n    })\n  }\n\n  Modal.prototype.checkScrollbar = function () {\n    var fullWindowWidth = window.innerWidth\n    if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8\n      var documentElementRect = document.documentElement.getBoundingClientRect()\n      fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)\n    }\n    this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth\n    this.scrollbarWidth = this.measureScrollbar()\n  }\n\n  Modal.prototype.setScrollbar = function () {\n    var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)\n    this.originalBodyPad = document.body.style.paddingRight || ''\n    if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)\n  }\n\n  Modal.prototype.resetScrollbar = function () {\n    this.$body.css('padding-right', this.originalBodyPad)\n  }\n\n  Modal.prototype.measureScrollbar = function () { // thx walsh\n    var scrollDiv = document.createElement('div')\n    scrollDiv.className = 'modal-scrollbar-measure'\n    this.$body.append(scrollDiv)\n    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth\n    this.$body[0].removeChild(scrollDiv)\n    return scrollbarWidth\n  }\n\n\n  // MODAL PLUGIN DEFINITION\n  // =======================\n\n  function Plugin(option, _relatedTarget) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.modal')\n      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)\n\n      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))\n      if (typeof option == 'string') data[option](_relatedTarget)\n      else if (options.show) data.show(_relatedTarget)\n    })\n  }\n\n  var old = $.fn.modal\n\n  $.fn.modal             = Plugin\n  $.fn.modal.Constructor = Modal\n\n\n  // MODAL NO CONFLICT\n  // =================\n\n  $.fn.modal.noConflict = function () {\n    $.fn.modal = old\n    return this\n  }\n\n\n  // MODAL DATA-API\n  // ==============\n\n  $(document).on('click.bs.modal.data-api', '[data-toggle=\"modal\"]', function (e) {\n    var $this   = $(this)\n    var href    = $this.attr('href')\n    var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\\s]+$)/, ''))) // strip for ie7\n    var option  = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())\n\n    if ($this.is('a')) e.preventDefault()\n\n    $target.one('show.bs.modal', function (showEvent) {\n      if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown\n      $target.one('hidden.bs.modal', function () {\n        $this.is(':visible') && $this.trigger('focus')\n      })\n    })\n    Plugin.call($target, option, this)\n  })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: tooltip.js v3.3.6\n * http://getbootstrap.com/javascript/#tooltip\n * Inspired by the original jQuery.tipsy by Jason Frame\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // TOOLTIP PUBLIC CLASS DEFINITION\n  // ===============================\n\n  var Tooltip = function (element, options) {\n    this.type       = null\n    this.options    = null\n    this.enabled    = null\n    this.timeout    = null\n    this.hoverState = null\n    this.$element   = null\n    this.inState    = null\n\n    this.init('tooltip', element, options)\n  }\n\n  Tooltip.VERSION  = '3.3.6'\n\n  Tooltip.TRANSITION_DURATION = 150\n\n  Tooltip.DEFAULTS = {\n    animation: true,\n    placement: 'top',\n    selector: false,\n    template: '<div class=\"tooltip\" role=\"tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner\"></div></div>',\n    trigger: 'hover focus',\n    title: '',\n    delay: 0,\n    html: false,\n    container: false,\n    viewport: {\n      selector: 'body',\n      padding: 0\n    }\n  }\n\n  Tooltip.prototype.init = function (type, element, options) {\n    this.enabled   = true\n    this.type      = type\n    this.$element  = $(element)\n    this.options   = this.getOptions(options)\n    this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))\n    this.inState   = { click: false, hover: false, focus: false }\n\n    if (this.$element[0] instanceof document.constructor && !this.options.selector) {\n      throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')\n    }\n\n    var triggers = this.options.trigger.split(' ')\n\n    for (var i = triggers.length; i--;) {\n      var trigger = triggers[i]\n\n      if (trigger == 'click') {\n        this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))\n      } else if (trigger != 'manual') {\n        var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'\n        var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'\n\n        this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))\n        this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))\n      }\n    }\n\n    this.options.selector ?\n      (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :\n      this.fixTitle()\n  }\n\n  Tooltip.prototype.getDefaults = function () {\n    return Tooltip.DEFAULTS\n  }\n\n  Tooltip.prototype.getOptions = function (options) {\n    options = $.extend({}, this.getDefaults(), this.$element.data(), options)\n\n    if (options.delay && typeof options.delay == 'number') {\n      options.delay = {\n        show: options.delay,\n        hide: options.delay\n      }\n    }\n\n    return options\n  }\n\n  Tooltip.prototype.getDelegateOptions = function () {\n    var options  = {}\n    var defaults = this.getDefaults()\n\n    this._options && $.each(this._options, function (key, value) {\n      if (defaults[key] != value) options[key] = value\n    })\n\n    return options\n  }\n\n  Tooltip.prototype.enter = function (obj) {\n    var self = obj instanceof this.constructor ?\n      obj : $(obj.currentTarget).data('bs.' + this.type)\n\n    if (!self) {\n      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())\n      $(obj.currentTarget).data('bs.' + this.type, self)\n    }\n\n    if (obj instanceof $.Event) {\n      self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true\n    }\n\n    if (self.tip().hasClass('in') || self.hoverState == 'in') {\n      self.hoverState = 'in'\n      return\n    }\n\n    clearTimeout(self.timeout)\n\n    self.hoverState = 'in'\n\n    if (!self.options.delay || !self.options.delay.show) return self.show()\n\n    self.timeout = setTimeout(function () {\n      if (self.hoverState == 'in') self.show()\n    }, self.options.delay.show)\n  }\n\n  Tooltip.prototype.isInStateTrue = function () {\n    for (var key in this.inState) {\n      if (this.inState[key]) return true\n    }\n\n    return false\n  }\n\n  Tooltip.prototype.leave = function (obj) {\n    var self = obj instanceof this.constructor ?\n      obj : $(obj.currentTarget).data('bs.' + this.type)\n\n    if (!self) {\n      self = new this.constructor(obj.currentTarget, this.getDelegateOptions())\n      $(obj.currentTarget).data('bs.' + this.type, self)\n    }\n\n    if (obj instanceof $.Event) {\n      self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false\n    }\n\n    if (self.isInStateTrue()) return\n\n    clearTimeout(self.timeout)\n\n    self.hoverState = 'out'\n\n    if (!self.options.delay || !self.options.delay.hide) return self.hide()\n\n    self.timeout = setTimeout(function () {\n      if (self.hoverState == 'out') self.hide()\n    }, self.options.delay.hide)\n  }\n\n  Tooltip.prototype.show = function () {\n    var e = $.Event('show.bs.' + this.type)\n\n    if (this.hasContent() && this.enabled) {\n      this.$element.trigger(e)\n\n      var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])\n      if (e.isDefaultPrevented() || !inDom) return\n      var that = this\n\n      var $tip = this.tip()\n\n      var tipId = this.getUID(this.type)\n\n      this.setContent()\n      $tip.attr('id', tipId)\n      this.$element.attr('aria-describedby', tipId)\n\n      if (this.options.animation) $tip.addClass('fade')\n\n      var placement = typeof this.options.placement == 'function' ?\n        this.options.placement.call(this, $tip[0], this.$element[0]) :\n        this.options.placement\n\n      var autoToken = /\\s?auto?\\s?/i\n      var autoPlace = autoToken.test(placement)\n      if (autoPlace) placement = placement.replace(autoToken, '') || 'top'\n\n      $tip\n        .detach()\n        .css({ top: 0, left: 0, display: 'block' })\n        .addClass(placement)\n        .data('bs.' + this.type, this)\n\n      this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)\n      this.$element.trigger('inserted.bs.' + this.type)\n\n      var pos          = this.getPosition()\n      var actualWidth  = $tip[0].offsetWidth\n      var actualHeight = $tip[0].offsetHeight\n\n      if (autoPlace) {\n        var orgPlacement = placement\n        var viewportDim = this.getPosition(this.$viewport)\n\n        placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top'    :\n                    placement == 'top'    && pos.top    - actualHeight < viewportDim.top    ? 'bottom' :\n                    placement == 'right'  && pos.right  + actualWidth  > viewportDim.width  ? 'left'   :\n                    placement == 'left'   && pos.left   - actualWidth  < viewportDim.left   ? 'right'  :\n                    placement\n\n        $tip\n          .removeClass(orgPlacement)\n          .addClass(placement)\n      }\n\n      var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)\n\n      this.applyPlacement(calculatedOffset, placement)\n\n      var complete = function () {\n        var prevHoverState = that.hoverState\n        that.$element.trigger('shown.bs.' + that.type)\n        that.hoverState = null\n\n        if (prevHoverState == 'out') that.leave(that)\n      }\n\n      $.support.transition && this.$tip.hasClass('fade') ?\n        $tip\n          .one('bsTransitionEnd', complete)\n          .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :\n        complete()\n    }\n  }\n\n  Tooltip.prototype.applyPlacement = function (offset, placement) {\n    var $tip   = this.tip()\n    var width  = $tip[0].offsetWidth\n    var height = $tip[0].offsetHeight\n\n    // manually read margins because getBoundingClientRect includes difference\n    var marginTop = parseInt($tip.css('margin-top'), 10)\n    var marginLeft = parseInt($tip.css('margin-left'), 10)\n\n    // we must check for NaN for ie 8/9\n    if (isNaN(marginTop))  marginTop  = 0\n    if (isNaN(marginLeft)) marginLeft = 0\n\n    offset.top  += marginTop\n    offset.left += marginLeft\n\n    // $.fn.offset doesn't round pixel values\n    // so we use setOffset directly with our own function B-0\n    $.offset.setOffset($tip[0], $.extend({\n      using: function (props) {\n        $tip.css({\n          top: Math.round(props.top),\n          left: Math.round(props.left)\n        })\n      }\n    }, offset), 0)\n\n    $tip.addClass('in')\n\n    // check to see if placing tip in new offset caused the tip to resize itself\n    var actualWidth  = $tip[0].offsetWidth\n    var actualHeight = $tip[0].offsetHeight\n\n    if (placement == 'top' && actualHeight != height) {\n      offset.top = offset.top + height - actualHeight\n    }\n\n    var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)\n\n    if (delta.left) offset.left += delta.left\n    else offset.top += delta.top\n\n    var isVertical          = /top|bottom/.test(placement)\n    var arrowDelta          = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight\n    var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'\n\n    $tip.offset(offset)\n    this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)\n  }\n\n  Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) {\n    this.arrow()\n      .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')\n      .css(isVertical ? 'top' : 'left', '')\n  }\n\n  Tooltip.prototype.setContent = function () {\n    var $tip  = this.tip()\n    var title = this.getTitle()\n\n    $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)\n    $tip.removeClass('fade in top bottom left right')\n  }\n\n  Tooltip.prototype.hide = function (callback) {\n    var that = this\n    var $tip = $(this.$tip)\n    var e    = $.Event('hide.bs.' + this.type)\n\n    function complete() {\n      if (that.hoverState != 'in') $tip.detach()\n      that.$element\n        .removeAttr('aria-describedby')\n        .trigger('hidden.bs.' + that.type)\n      callback && callback()\n    }\n\n    this.$element.trigger(e)\n\n    if (e.isDefaultPrevented()) return\n\n    $tip.removeClass('in')\n\n    $.support.transition && $tip.hasClass('fade') ?\n      $tip\n        .one('bsTransitionEnd', complete)\n        .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :\n      complete()\n\n    this.hoverState = null\n\n    return this\n  }\n\n  Tooltip.prototype.fixTitle = function () {\n    var $e = this.$element\n    if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') {\n      $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')\n    }\n  }\n\n  Tooltip.prototype.hasContent = function () {\n    return this.getTitle()\n  }\n\n  Tooltip.prototype.getPosition = function ($element) {\n    $element   = $element || this.$element\n\n    var el     = $element[0]\n    var isBody = el.tagName == 'BODY'\n\n    var elRect    = el.getBoundingClientRect()\n    if (elRect.width == null) {\n      // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093\n      elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })\n    }\n    var elOffset  = isBody ? { top: 0, left: 0 } : $element.offset()\n    var scroll    = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }\n    var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null\n\n    return $.extend({}, elRect, scroll, outerDims, elOffset)\n  }\n\n  Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {\n    return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2 } :\n           placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :\n           placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :\n        /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }\n\n  }\n\n  Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {\n    var delta = { top: 0, left: 0 }\n    if (!this.$viewport) return delta\n\n    var viewportPadding = this.options.viewport && this.options.viewport.padding || 0\n    var viewportDimensions = this.getPosition(this.$viewport)\n\n    if (/right|left/.test(placement)) {\n      var topEdgeOffset    = pos.top - viewportPadding - viewportDimensions.scroll\n      var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight\n      if (topEdgeOffset < viewportDimensions.top) { // top overflow\n        delta.top = viewportDimensions.top - topEdgeOffset\n      } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow\n        delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset\n      }\n    } else {\n      var leftEdgeOffset  = pos.left - viewportPadding\n      var rightEdgeOffset = pos.left + viewportPadding + actualWidth\n      if (leftEdgeOffset < viewportDimensions.left) { // left overflow\n        delta.left = viewportDimensions.left - leftEdgeOffset\n      } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow\n        delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset\n      }\n    }\n\n    return delta\n  }\n\n  Tooltip.prototype.getTitle = function () {\n    var title\n    var $e = this.$element\n    var o  = this.options\n\n    title = $e.attr('data-original-title')\n      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)\n\n    return title\n  }\n\n  Tooltip.prototype.getUID = function (prefix) {\n    do prefix += ~~(Math.random() * 1000000)\n    while (document.getElementById(prefix))\n    return prefix\n  }\n\n  Tooltip.prototype.tip = function () {\n    if (!this.$tip) {\n      this.$tip = $(this.options.template)\n      if (this.$tip.length != 1) {\n        throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')\n      }\n    }\n    return this.$tip\n  }\n\n  Tooltip.prototype.arrow = function () {\n    return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))\n  }\n\n  Tooltip.prototype.enable = function () {\n    this.enabled = true\n  }\n\n  Tooltip.prototype.disable = function () {\n    this.enabled = false\n  }\n\n  Tooltip.prototype.toggleEnabled = function () {\n    this.enabled = !this.enabled\n  }\n\n  Tooltip.prototype.toggle = function (e) {\n    var self = this\n    if (e) {\n      self = $(e.currentTarget).data('bs.' + this.type)\n      if (!self) {\n        self = new this.constructor(e.currentTarget, this.getDelegateOptions())\n        $(e.currentTarget).data('bs.' + this.type, self)\n      }\n    }\n\n    if (e) {\n      self.inState.click = !self.inState.click\n      if (self.isInStateTrue()) self.enter(self)\n      else self.leave(self)\n    } else {\n      self.tip().hasClass('in') ? self.leave(self) : self.enter(self)\n    }\n  }\n\n  Tooltip.prototype.destroy = function () {\n    var that = this\n    clearTimeout(this.timeout)\n    this.hide(function () {\n      that.$element.off('.' + that.type).removeData('bs.' + that.type)\n      if (that.$tip) {\n        that.$tip.detach()\n      }\n      that.$tip = null\n      that.$arrow = null\n      that.$viewport = null\n    })\n  }\n\n\n  // TOOLTIP PLUGIN DEFINITION\n  // =========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.tooltip')\n      var options = typeof option == 'object' && option\n\n      if (!data && /destroy|hide/.test(option)) return\n      if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.tooltip\n\n  $.fn.tooltip             = Plugin\n  $.fn.tooltip.Constructor = Tooltip\n\n\n  // TOOLTIP NO CONFLICT\n  // ===================\n\n  $.fn.tooltip.noConflict = function () {\n    $.fn.tooltip = old\n    return this\n  }\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: popover.js v3.3.6\n * http://getbootstrap.com/javascript/#popovers\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // POPOVER PUBLIC CLASS DEFINITION\n  // ===============================\n\n  var Popover = function (element, options) {\n    this.init('popover', element, options)\n  }\n\n  if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')\n\n  Popover.VERSION  = '3.3.6'\n\n  Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {\n    placement: 'right',\n    trigger: 'click',\n    content: '',\n    template: '<div class=\"popover\" role=\"tooltip\"><div class=\"arrow\"></div><h3 class=\"popover-title\"></h3><div class=\"popover-content\"></div></div>'\n  })\n\n\n  // NOTE: POPOVER EXTENDS tooltip.js\n  // ================================\n\n  Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)\n\n  Popover.prototype.constructor = Popover\n\n  Popover.prototype.getDefaults = function () {\n    return Popover.DEFAULTS\n  }\n\n  Popover.prototype.setContent = function () {\n    var $tip    = this.tip()\n    var title   = this.getTitle()\n    var content = this.getContent()\n\n    $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)\n    $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events\n      this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'\n    ](content)\n\n    $tip.removeClass('fade top bottom left right in')\n\n    // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do\n    // this manually by checking the contents.\n    if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()\n  }\n\n  Popover.prototype.hasContent = function () {\n    return this.getTitle() || this.getContent()\n  }\n\n  Popover.prototype.getContent = function () {\n    var $e = this.$element\n    var o  = this.options\n\n    return $e.attr('data-content')\n      || (typeof o.content == 'function' ?\n            o.content.call($e[0]) :\n            o.content)\n  }\n\n  Popover.prototype.arrow = function () {\n    return (this.$arrow = this.$arrow || this.tip().find('.arrow'))\n  }\n\n\n  // POPOVER PLUGIN DEFINITION\n  // =========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.popover')\n      var options = typeof option == 'object' && option\n\n      if (!data && /destroy|hide/.test(option)) return\n      if (!data) $this.data('bs.popover', (data = new Popover(this, options)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.popover\n\n  $.fn.popover             = Plugin\n  $.fn.popover.Constructor = Popover\n\n\n  // POPOVER NO CONFLICT\n  // ===================\n\n  $.fn.popover.noConflict = function () {\n    $.fn.popover = old\n    return this\n  }\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: scrollspy.js v3.3.6\n * http://getbootstrap.com/javascript/#scrollspy\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // SCROLLSPY CLASS DEFINITION\n  // ==========================\n\n  function ScrollSpy(element, options) {\n    this.$body          = $(document.body)\n    this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)\n    this.options        = $.extend({}, ScrollSpy.DEFAULTS, options)\n    this.selector       = (this.options.target || '') + ' .nav li > a'\n    this.offsets        = []\n    this.targets        = []\n    this.activeTarget   = null\n    this.scrollHeight   = 0\n\n    this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))\n    this.refresh()\n    this.process()\n  }\n\n  ScrollSpy.VERSION  = '3.3.6'\n\n  ScrollSpy.DEFAULTS = {\n    offset: 10\n  }\n\n  ScrollSpy.prototype.getScrollHeight = function () {\n    return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)\n  }\n\n  ScrollSpy.prototype.refresh = function () {\n    var that          = this\n    var offsetMethod  = 'offset'\n    var offsetBase    = 0\n\n    this.offsets      = []\n    this.targets      = []\n    this.scrollHeight = this.getScrollHeight()\n\n    if (!$.isWindow(this.$scrollElement[0])) {\n      offsetMethod = 'position'\n      offsetBase   = this.$scrollElement.scrollTop()\n    }\n\n    this.$body\n      .find(this.selector)\n      .map(function () {\n        var $el   = $(this)\n        var href  = $el.data('target') || $el.attr('href')\n        var $href = /^#./.test(href) && $(href)\n\n        return ($href\n          && $href.length\n          && $href.is(':visible')\n          && [[$href[offsetMethod]().top + offsetBase, href]]) || null\n      })\n      .sort(function (a, b) { return a[0] - b[0] })\n      .each(function () {\n        that.offsets.push(this[0])\n        that.targets.push(this[1])\n      })\n  }\n\n  ScrollSpy.prototype.process = function () {\n    var scrollTop    = this.$scrollElement.scrollTop() + this.options.offset\n    var scrollHeight = this.getScrollHeight()\n    var maxScroll    = this.options.offset + scrollHeight - this.$scrollElement.height()\n    var offsets      = this.offsets\n    var targets      = this.targets\n    var activeTarget = this.activeTarget\n    var i\n\n    if (this.scrollHeight != scrollHeight) {\n      this.refresh()\n    }\n\n    if (scrollTop >= maxScroll) {\n      return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)\n    }\n\n    if (activeTarget && scrollTop < offsets[0]) {\n      this.activeTarget = null\n      return this.clear()\n    }\n\n    for (i = offsets.length; i--;) {\n      activeTarget != targets[i]\n        && scrollTop >= offsets[i]\n        && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])\n        && this.activate(targets[i])\n    }\n  }\n\n  ScrollSpy.prototype.activate = function (target) {\n    this.activeTarget = target\n\n    this.clear()\n\n    var selector = this.selector +\n      '[data-target=\"' + target + '\"],' +\n      this.selector + '[href=\"' + target + '\"]'\n\n    var active = $(selector)\n      .parents('li')\n      .addClass('active')\n\n    if (active.parent('.dropdown-menu').length) {\n      active = active\n        .closest('li.dropdown')\n        .addClass('active')\n    }\n\n    active.trigger('activate.bs.scrollspy')\n  }\n\n  ScrollSpy.prototype.clear = function () {\n    $(this.selector)\n      .parentsUntil(this.options.target, '.active')\n      .removeClass('active')\n  }\n\n\n  // SCROLLSPY PLUGIN DEFINITION\n  // ===========================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.scrollspy')\n      var options = typeof option == 'object' && option\n\n      if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.scrollspy\n\n  $.fn.scrollspy             = Plugin\n  $.fn.scrollspy.Constructor = ScrollSpy\n\n\n  // SCROLLSPY NO CONFLICT\n  // =====================\n\n  $.fn.scrollspy.noConflict = function () {\n    $.fn.scrollspy = old\n    return this\n  }\n\n\n  // SCROLLSPY DATA-API\n  // ==================\n\n  $(window).on('load.bs.scrollspy.data-api', function () {\n    $('[data-spy=\"scroll\"]').each(function () {\n      var $spy = $(this)\n      Plugin.call($spy, $spy.data())\n    })\n  })\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: tab.js v3.3.6\n * http://getbootstrap.com/javascript/#tabs\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // TAB CLASS DEFINITION\n  // ====================\n\n  var Tab = function (element) {\n    // jscs:disable requireDollarBeforejQueryAssignment\n    this.element = $(element)\n    // jscs:enable requireDollarBeforejQueryAssignment\n  }\n\n  Tab.VERSION = '3.3.6'\n\n  Tab.TRANSITION_DURATION = 150\n\n  Tab.prototype.show = function () {\n    var $this    = this.element\n    var $ul      = $this.closest('ul:not(.dropdown-menu)')\n    var selector = $this.data('target')\n\n    if (!selector) {\n      selector = $this.attr('href')\n      selector = selector && selector.replace(/.*(?=#[^\\s]*$)/, '') // strip for ie7\n    }\n\n    if ($this.parent('li').hasClass('active')) return\n\n    var $previous = $ul.find('.active:last a')\n    var hideEvent = $.Event('hide.bs.tab', {\n      relatedTarget: $this[0]\n    })\n    var showEvent = $.Event('show.bs.tab', {\n      relatedTarget: $previous[0]\n    })\n\n    $previous.trigger(hideEvent)\n    $this.trigger(showEvent)\n\n    if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return\n\n    var $target = $(selector)\n\n    this.activate($this.closest('li'), $ul)\n    this.activate($target, $target.parent(), function () {\n      $previous.trigger({\n        type: 'hidden.bs.tab',\n        relatedTarget: $this[0]\n      })\n      $this.trigger({\n        type: 'shown.bs.tab',\n        relatedTarget: $previous[0]\n      })\n    })\n  }\n\n  Tab.prototype.activate = function (element, container, callback) {\n    var $active    = container.find('> .active')\n    var transition = callback\n      && $.support.transition\n      && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)\n\n    function next() {\n      $active\n        .removeClass('active')\n        .find('> .dropdown-menu > .active')\n          .removeClass('active')\n        .end()\n        .find('[data-toggle=\"tab\"]')\n          .attr('aria-expanded', false)\n\n      element\n        .addClass('active')\n        .find('[data-toggle=\"tab\"]')\n          .attr('aria-expanded', true)\n\n      if (transition) {\n        element[0].offsetWidth // reflow for transition\n        element.addClass('in')\n      } else {\n        element.removeClass('fade')\n      }\n\n      if (element.parent('.dropdown-menu').length) {\n        element\n          .closest('li.dropdown')\n            .addClass('active')\n          .end()\n          .find('[data-toggle=\"tab\"]')\n            .attr('aria-expanded', true)\n      }\n\n      callback && callback()\n    }\n\n    $active.length && transition ?\n      $active\n        .one('bsTransitionEnd', next)\n        .emulateTransitionEnd(Tab.TRANSITION_DURATION) :\n      next()\n\n    $active.removeClass('in')\n  }\n\n\n  // TAB PLUGIN DEFINITION\n  // =====================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this = $(this)\n      var data  = $this.data('bs.tab')\n\n      if (!data) $this.data('bs.tab', (data = new Tab(this)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.tab\n\n  $.fn.tab             = Plugin\n  $.fn.tab.Constructor = Tab\n\n\n  // TAB NO CONFLICT\n  // ===============\n\n  $.fn.tab.noConflict = function () {\n    $.fn.tab = old\n    return this\n  }\n\n\n  // TAB DATA-API\n  // ============\n\n  var clickHandler = function (e) {\n    e.preventDefault()\n    Plugin.call($(this), 'show')\n  }\n\n  $(document)\n    .on('click.bs.tab.data-api', '[data-toggle=\"tab\"]', clickHandler)\n    .on('click.bs.tab.data-api', '[data-toggle=\"pill\"]', clickHandler)\n\n}(jQuery);\n\n/* ========================================================================\n * Bootstrap: affix.js v3.3.6\n * http://getbootstrap.com/javascript/#affix\n * ========================================================================\n * Copyright 2011-2015 Twitter, Inc.\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ======================================================================== */\n\n\n+function ($) {\n  'use strict';\n\n  // AFFIX CLASS DEFINITION\n  // ======================\n\n  var Affix = function (element, options) {\n    this.options = $.extend({}, Affix.DEFAULTS, options)\n\n    this.$target = $(this.options.target)\n      .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))\n      .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))\n\n    this.$element     = $(element)\n    this.affixed      = null\n    this.unpin        = null\n    this.pinnedOffset = null\n\n    this.checkPosition()\n  }\n\n  Affix.VERSION  = '3.3.6'\n\n  Affix.RESET    = 'affix affix-top affix-bottom'\n\n  Affix.DEFAULTS = {\n    offset: 0,\n    target: window\n  }\n\n  Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {\n    var scrollTop    = this.$target.scrollTop()\n    var position     = this.$element.offset()\n    var targetHeight = this.$target.height()\n\n    if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false\n\n    if (this.affixed == 'bottom') {\n      if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'\n      return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'\n    }\n\n    var initializing   = this.affixed == null\n    var colliderTop    = initializing ? scrollTop : position.top\n    var colliderHeight = initializing ? targetHeight : height\n\n    if (offsetTop != null && scrollTop <= offsetTop) return 'top'\n    if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'\n\n    return false\n  }\n\n  Affix.prototype.getPinnedOffset = function () {\n    if (this.pinnedOffset) return this.pinnedOffset\n    this.$element.removeClass(Affix.RESET).addClass('affix')\n    var scrollTop = this.$target.scrollTop()\n    var position  = this.$element.offset()\n    return (this.pinnedOffset = position.top - scrollTop)\n  }\n\n  Affix.prototype.checkPositionWithEventLoop = function () {\n    setTimeout($.proxy(this.checkPosition, this), 1)\n  }\n\n  Affix.prototype.checkPosition = function () {\n    if (!this.$element.is(':visible')) return\n\n    var height       = this.$element.height()\n    var offset       = this.options.offset\n    var offsetTop    = offset.top\n    var offsetBottom = offset.bottom\n    var scrollHeight = Math.max($(document).height(), $(document.body).height())\n\n    if (typeof offset != 'object')         offsetBottom = offsetTop = offset\n    if (typeof offsetTop == 'function')    offsetTop    = offset.top(this.$element)\n    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)\n\n    var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)\n\n    if (this.affixed != affix) {\n      if (this.unpin != null) this.$element.css('top', '')\n\n      var affixType = 'affix' + (affix ? '-' + affix : '')\n      var e         = $.Event(affixType + '.bs.affix')\n\n      this.$element.trigger(e)\n\n      if (e.isDefaultPrevented()) return\n\n      this.affixed = affix\n      this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null\n\n      this.$element\n        .removeClass(Affix.RESET)\n        .addClass(affixType)\n        .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')\n    }\n\n    if (affix == 'bottom') {\n      this.$element.offset({\n        top: scrollHeight - height - offsetBottom\n      })\n    }\n  }\n\n\n  // AFFIX PLUGIN DEFINITION\n  // =======================\n\n  function Plugin(option) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.affix')\n      var options = typeof option == 'object' && option\n\n      if (!data) $this.data('bs.affix', (data = new Affix(this, options)))\n      if (typeof option == 'string') data[option]()\n    })\n  }\n\n  var old = $.fn.affix\n\n  $.fn.affix             = Plugin\n  $.fn.affix.Constructor = Affix\n\n\n  // AFFIX NO CONFLICT\n  // =================\n\n  $.fn.affix.noConflict = function () {\n    $.fn.affix = old\n    return this\n  }\n\n\n  // AFFIX DATA-API\n  // ==============\n\n  $(window).on('load', function () {\n    $('[data-spy=\"affix\"]').each(function () {\n      var $spy = $(this)\n      var data = $spy.data()\n\n      data.offset = data.offset || {}\n\n      if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom\n      if (data.offsetTop    != null) data.offset.top    = data.offsetTop\n\n      Plugin.call($spy, data)\n    })\n  })\n\n}(jQuery);\n"
  },
  {
    "path": "html/lib/bootstrap/npm.js",
    "content": "// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.\nrequire('../../js/transition.js')\nrequire('../../js/alert.js')\nrequire('../../js/button.js')\nrequire('../../js/carousel.js')\nrequire('../../js/collapse.js')\nrequire('../../js/dropdown.js')\nrequire('../../js/modal.js')\nrequire('../../js/tooltip.js')\nrequire('../../js/popover.js')\nrequire('../../js/scrollspy.js')\nrequire('../../js/tab.js')\nrequire('../../js/affix.js')"
  },
  {
    "path": "html/lib/bootstrap-submenu/css/bootstrap-submenu.css",
    "content": "/*!\n * Bootstrap-submenu v2.0.4 (https://vsn4ik.github.io/bootstrap-submenu/)\n * Copyright 2014-2016 Vasily A. (https://github.com/vsn4ik)\n * Licensed under the MIT license\n */\n\n.dropdown-submenu > a:after {\n  content: \"\";\n}\n@media (min-width: 768px) {\n  .dropdown-submenu {\n    position: relative;\n  }\n  .dropdown-submenu .dropdown-menu {\n    top: 0;\n    left: 100%;\n    margin-top: -6px;\n    border-top-left-radius: 0;\n  }\n  .dropup .dropdown-submenu .dropdown-menu,\n  .navbar-fixed-bottom .dropdown-submenu .dropdown-menu {\n    top: auto;\n    bottom: 0;\n    margin-top: 0;\n    margin-bottom: -6px;\n    border-top-left-radius: 4px;\n    border-bottom-left-radius: 0;\n  }\n  .dropdown-menu-right .dropdown-submenu .dropdown-menu,\n  .navbar-right .dropdown-submenu .dropdown-menu {\n    left: auto;\n    right: 100%;\n    border-top-left-radius: 4px;\n    border-top-right-radius: 0;\n  }\n  .dropup .dropdown-menu-right .dropdown-submenu .dropdown-menu,\n  .dropup .navbar-right .dropdown-submenu .dropdown-menu,\n  .navbar-fixed-bottom .dropdown-menu-right .dropdown-submenu .dropdown-menu,\n  .navbar-fixed-bottom .navbar-right .dropdown-submenu .dropdown-menu {\n    border-radius: 4px 4px 0;\n  }\n  .dropdown-submenu > a:after {\n    float: right;\n    margin-top: 6px;\n    margin-right: -10px;\n    border-left: 4px dashed;\n    border-top: 4px solid transparent;\n    border-bottom: 4px solid transparent;\n  }\n  .dropdown-menu-right .dropdown-submenu > a:after,\n  .navbar-right .dropdown-submenu > a:after {\n    float: left;\n    border-left: none;\n    margin-left: -10px;\n    margin-right: 0;\n    border-right: 4px dashed;\n    border-top: 4px solid transparent;\n    border-bottom: 4px solid transparent;\n  }\n}\n@media (max-width: 767px) {\n  .dropdown-submenu .dropdown-menu {\n    position: static;\n    margin-top: 0;\n    border: 0;\n    box-shadow: none;\n  }\n  .dropdown-submenu > a:after {\n    margin-left: 6px;\n    display: inline-block;\n    vertical-align: middle;\n    border-top: 4px dashed;\n    border-left: 4px solid transparent;\n    border-right: 4px solid transparent;\n  }\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li.dropdown-header,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li.dropdown-header,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li.dropdown-header,\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > a,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > a,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > a {\n    padding-left: 30px;\n  }\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > a,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > a,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 40px;\n  }\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 50px;\n  }\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a,\n  .dropup > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a,\n  .btn-group > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 60px;\n  }\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li.dropdown-header,\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > a {\n    padding-left: 35px;\n  }\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 45px;\n  }\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 55px;\n  }\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li.dropdown-header,\n  .navbar-nav > .dropdown > .dropdown-menu > .dropdown-submenu > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > .dropdown-menu > li > a {\n    padding-left: 65px;\n  }\n}\n/*# sourceMappingURL=bootstrap-submenu.css.map */"
  },
  {
    "path": "html/lib/bootstrap-submenu/js/bootstrap-submenu.js",
    "content": "/*!\n * Bootstrap-submenu v2.0.4 (https://vsn4ik.github.io/bootstrap-submenu/)\n * Copyright 2014-2016 Vasily A. (https://github.com/vsn4ik)\n * Licensed under the MIT license\n */\n\n/**\n * $.inArray: friends with IE8. Use Array.prototype.indexOf in future.\n * $.proxy: friends with IE8. Use Function.prototype.bind in future.\n */\n\n'use strict';\n\n(function(factory) {\n  if (typeof define == 'function' && define.amd) {\n    // AMD. Register as an anonymous module\n    define(['jquery'], factory);\n  }\n  else if (typeof exports == 'object') {\n    // Node/CommonJS\n    module.exports = factory(require('jquery'));\n  }\n  else {\n    // Browser globals\n    factory(jQuery);\n  }\n})(function($) {\n  function Item(element) {\n    this.$element = $(element);\n    this.$menu = this.$element.closest('.dropdown-menu');\n    this.$main = this.$menu.parent();\n    this.$items = this.$menu.children('.dropdown-submenu');\n\n    this.init();\n  }\n\n  Item.prototype = {\n    init: function() {\n      this.$element.on('keydown', $.proxy(this, 'keydown'));\n    },\n    close: function() {\n      this.$main.removeClass('open');\n      this.$items.trigger('hide.bs.submenu');\n    },\n    keydown: function(event) {\n      // 27: Esc\n\n      if (event.keyCode == 27) {\n        event.stopPropagation();\n\n        this.close();\n        this.$main.children('a, button').trigger('focus');\n      }\n    }\n  };\n\n  function SubmenuItem(element) {\n    this.$element = $(element);\n    this.$main = this.$element.parent();\n    this.$menu = this.$main.children('.dropdown-menu');\n    this.$subs = this.$main.siblings('.dropdown-submenu');\n    this.$items = this.$menu.children('.dropdown-submenu');\n\n    this.init();\n  }\n\n  $.extend(SubmenuItem.prototype, Item.prototype, {\n    init: function() {\n      this.$element.on({\n        click: $.proxy(this, 'click'),\n        keydown: $.proxy(this, 'keydown')\n      });\n\n      this.$main.on('hide.bs.submenu', $.proxy(this, 'hide'));\n    },\n    click: function(event) {\n      // Fix a[href=\"#\"]. For community\n      event.preventDefault();\n\n      event.stopPropagation();\n\n      this.toggle();\n    },\n    hide: function(event) {\n      // Stop event bubbling\n      event.stopPropagation();\n\n      this.close();\n    },\n    open: function() {\n      this.$main.addClass('open');\n      this.$subs.trigger('hide.bs.submenu');\n    },\n    toggle: function() {\n      if (this.$main.hasClass('open')) {\n        this.close();\n      }\n      else {\n        this.open();\n      }\n    },\n    keydown: function(event) {\n      // 13: Return, 32: Spacebar\n\n      if (event.keyCode == 32) {\n        // Off vertical scrolling\n        event.preventDefault();\n      }\n\n      if ($.inArray(event.keyCode, [13, 32]) != -1) {\n        this.toggle();\n      }\n    }\n  });\n\n  function Submenupicker(element) {\n    this.$element = $(element);\n    this.$main = this.$element.parent();\n    this.$menu = this.$main.children('.dropdown-menu');\n    this.$items = this.$menu.children('.dropdown-submenu');\n\n    this.init();\n  }\n\n  Submenupicker.prototype = {\n    init: function() {\n      this.$menu.off('keydown.bs.dropdown.data-api');\n      this.$menu.on('keydown', $.proxy(this, 'itemKeydown'));\n\n      this.$menu.find('li > a').each(function() {\n        new Item(this);\n      });\n\n      this.$menu.find('.dropdown-submenu > a').each(function() {\n        new SubmenuItem(this);\n      });\n\n      this.$main.on('hidden.bs.dropdown', $.proxy(this, 'hidden'));\n    },\n    hidden: function() {\n      this.$items.trigger('hide.bs.submenu');\n    },\n    itemKeydown: function(event) {\n      // 38: Arrow up, 40: Arrow down\n\n      if ($.inArray(event.keyCode, [38, 40]) != -1) {\n        // Off vertical scrolling\n        event.preventDefault();\n\n        event.stopPropagation();\n\n        var $items = this.$menu.find('li:not(.disabled):visible > a');\n        var index = $items.index(event.target);\n\n        if (event.keyCode == 38 && index !== 0) {\n          index--;\n        }\n        else if (event.keyCode == 40 && index !== $items.length - 1) {\n          index++;\n        }\n        else {\n          return;\n        }\n\n        $items.eq(index).trigger('focus');\n      }\n    }\n  };\n\n  var old = $.fn.submenupicker;\n\n  // For AMD/Node/CommonJS used elements (optional)\n  // http://learn.jquery.com/jquery-ui/environments/amd/\n  $.fn.submenupicker = function(elements) {\n    var $elements = this instanceof $ ? this : $(elements);\n\n    return $elements.each(function() {\n      var data = $.data(this, 'bs.submenu');\n\n      if (!data) {\n        data = new Submenupicker(this);\n\n        $.data(this, 'bs.submenu', data);\n      }\n    });\n  };\n\n  $.fn.submenupicker.Constructor = Submenupicker;\n  $.fn.submenupicker.noConflict = function() {\n    $.fn.submenupicker = old;\n    return this;\n  };\n\n  return $.fn.submenupicker;\n});\n"
  },
  {
    "path": "html/lib/d3/d3.js",
    "content": "!function() {\n  var d3 = {\n    version: \"3.5.16\"\n  };\n  var d3_arraySlice = [].slice, d3_array = function(list) {\n    return d3_arraySlice.call(list);\n  };\n  var d3_document = this.document;\n  function d3_documentElement(node) {\n    return node && (node.ownerDocument || node.document || node).documentElement;\n  }\n  function d3_window(node) {\n    return node && (node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView);\n  }\n  if (d3_document) {\n    try {\n      d3_array(d3_document.documentElement.childNodes)[0].nodeType;\n    } catch (e) {\n      d3_array = function(list) {\n        var i = list.length, array = new Array(i);\n        while (i--) array[i] = list[i];\n        return array;\n      };\n    }\n  }\n  if (!Date.now) Date.now = function() {\n    return +new Date();\n  };\n  if (d3_document) {\n    try {\n      d3_document.createElement(\"DIV\").style.setProperty(\"opacity\", 0, \"\");\n    } catch (error) {\n      var d3_element_prototype = this.Element.prototype, d3_element_setAttribute = d3_element_prototype.setAttribute, d3_element_setAttributeNS = d3_element_prototype.setAttributeNS, d3_style_prototype = this.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;\n      d3_element_prototype.setAttribute = function(name, value) {\n        d3_element_setAttribute.call(this, name, value + \"\");\n      };\n      d3_element_prototype.setAttributeNS = function(space, local, value) {\n        d3_element_setAttributeNS.call(this, space, local, value + \"\");\n      };\n      d3_style_prototype.setProperty = function(name, value, priority) {\n        d3_style_setProperty.call(this, name, value + \"\", priority);\n      };\n    }\n  }\n  d3.ascending = d3_ascending;\n  function d3_ascending(a, b) {\n    return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;\n  }\n  d3.descending = function(a, b) {\n    return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n  };\n  d3.min = function(array, f) {\n    var i = -1, n = array.length, a, b;\n    if (arguments.length === 1) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) {\n        a = b;\n        break;\n      }\n      while (++i < n) if ((b = array[i]) != null && a > b) a = b;\n    } else {\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n        a = b;\n        break;\n      }\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;\n    }\n    return a;\n  };\n  d3.max = function(array, f) {\n    var i = -1, n = array.length, a, b;\n    if (arguments.length === 1) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) {\n        a = b;\n        break;\n      }\n      while (++i < n) if ((b = array[i]) != null && b > a) a = b;\n    } else {\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n        a = b;\n        break;\n      }\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;\n    }\n    return a;\n  };\n  d3.extent = function(array, f) {\n    var i = -1, n = array.length, a, b, c;\n    if (arguments.length === 1) {\n      while (++i < n) if ((b = array[i]) != null && b >= b) {\n        a = c = b;\n        break;\n      }\n      while (++i < n) if ((b = array[i]) != null) {\n        if (a > b) a = b;\n        if (c < b) c = b;\n      }\n    } else {\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) {\n        a = c = b;\n        break;\n      }\n      while (++i < n) if ((b = f.call(array, array[i], i)) != null) {\n        if (a > b) a = b;\n        if (c < b) c = b;\n      }\n    }\n    return [ a, c ];\n  };\n  function d3_number(x) {\n    return x === null ? NaN : +x;\n  }\n  function d3_numeric(x) {\n    return !isNaN(x);\n  }\n  d3.sum = function(array, f) {\n    var s = 0, n = array.length, a, i = -1;\n    if (arguments.length === 1) {\n      while (++i < n) if (d3_numeric(a = +array[i])) s += a;\n    } else {\n      while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a;\n    }\n    return s;\n  };\n  d3.mean = function(array, f) {\n    var s = 0, n = array.length, a, i = -1, j = n;\n    if (arguments.length === 1) {\n      while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j;\n    } else {\n      while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j;\n    }\n    if (j) return s / j;\n  };\n  d3.quantile = function(values, p) {\n    var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;\n    return e ? v + e * (values[h] - v) : v;\n  };\n  d3.median = function(array, f) {\n    var numbers = [], n = array.length, a, i = -1;\n    if (arguments.length === 1) {\n      while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a);\n    } else {\n      while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a);\n    }\n    if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5);\n  };\n  d3.variance = function(array, f) {\n    var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0;\n    if (arguments.length === 1) {\n      while (++i < n) {\n        if (d3_numeric(a = d3_number(array[i]))) {\n          d = a - m;\n          m += d / ++j;\n          s += d * (a - m);\n        }\n      }\n    } else {\n      while (++i < n) {\n        if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) {\n          d = a - m;\n          m += d / ++j;\n          s += d * (a - m);\n        }\n      }\n    }\n    if (j > 1) return s / (j - 1);\n  };\n  d3.deviation = function() {\n    var v = d3.variance.apply(this, arguments);\n    return v ? Math.sqrt(v) : v;\n  };\n  function d3_bisector(compare) {\n    return {\n      left: function(a, x, lo, hi) {\n        if (arguments.length < 3) lo = 0;\n        if (arguments.length < 4) hi = a.length;\n        while (lo < hi) {\n          var mid = lo + hi >>> 1;\n          if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid;\n        }\n        return lo;\n      },\n      right: function(a, x, lo, hi) {\n        if (arguments.length < 3) lo = 0;\n        if (arguments.length < 4) hi = a.length;\n        while (lo < hi) {\n          var mid = lo + hi >>> 1;\n          if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1;\n        }\n        return lo;\n      }\n    };\n  }\n  var d3_bisect = d3_bisector(d3_ascending);\n  d3.bisectLeft = d3_bisect.left;\n  d3.bisect = d3.bisectRight = d3_bisect.right;\n  d3.bisector = function(f) {\n    return d3_bisector(f.length === 1 ? function(d, x) {\n      return d3_ascending(f(d), x);\n    } : f);\n  };\n  d3.shuffle = function(array, i0, i1) {\n    if ((m = arguments.length) < 3) {\n      i1 = array.length;\n      if (m < 2) i0 = 0;\n    }\n    var m = i1 - i0, t, i;\n    while (m) {\n      i = Math.random() * m-- | 0;\n      t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t;\n    }\n    return array;\n  };\n  d3.permute = function(array, indexes) {\n    var i = indexes.length, permutes = new Array(i);\n    while (i--) permutes[i] = array[indexes[i]];\n    return permutes;\n  };\n  d3.pairs = function(array) {\n    var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n);\n    while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];\n    return pairs;\n  };\n  d3.transpose = function(matrix) {\n    if (!(n = matrix.length)) return [];\n    for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) {\n      for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) {\n        row[j] = matrix[j][i];\n      }\n    }\n    return transpose;\n  };\n  function d3_transposeLength(d) {\n    return d.length;\n  }\n  d3.zip = function() {\n    return d3.transpose(arguments);\n  };\n  d3.keys = function(map) {\n    var keys = [];\n    for (var key in map) keys.push(key);\n    return keys;\n  };\n  d3.values = function(map) {\n    var values = [];\n    for (var key in map) values.push(map[key]);\n    return values;\n  };\n  d3.entries = function(map) {\n    var entries = [];\n    for (var key in map) entries.push({\n      key: key,\n      value: map[key]\n    });\n    return entries;\n  };\n  d3.merge = function(arrays) {\n    var n = arrays.length, m, i = -1, j = 0, merged, array;\n    while (++i < n) j += arrays[i].length;\n    merged = new Array(j);\n    while (--n >= 0) {\n      array = arrays[n];\n      m = array.length;\n      while (--m >= 0) {\n        merged[--j] = array[m];\n      }\n    }\n    return merged;\n  };\n  var abs = Math.abs;\n  d3.range = function(start, stop, step) {\n    if (arguments.length < 3) {\n      step = 1;\n      if (arguments.length < 2) {\n        stop = start;\n        start = 0;\n      }\n    }\n    if ((stop - start) / step === Infinity) throw new Error(\"infinite range\");\n    var range = [], k = d3_range_integerScale(abs(step)), i = -1, j;\n    start *= k, stop *= k, step *= k;\n    if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);\n    return range;\n  };\n  function d3_range_integerScale(x) {\n    var k = 1;\n    while (x * k % 1) k *= 10;\n    return k;\n  }\n  function d3_class(ctor, properties) {\n    for (var key in properties) {\n      Object.defineProperty(ctor.prototype, key, {\n        value: properties[key],\n        enumerable: false\n      });\n    }\n  }\n  d3.map = function(object, f) {\n    var map = new d3_Map();\n    if (object instanceof d3_Map) {\n      object.forEach(function(key, value) {\n        map.set(key, value);\n      });\n    } else if (Array.isArray(object)) {\n      var i = -1, n = object.length, o;\n      if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o);\n    } else {\n      for (var key in object) map.set(key, object[key]);\n    }\n    return map;\n  };\n  function d3_Map() {\n    this._ = Object.create(null);\n  }\n  var d3_map_proto = \"__proto__\", d3_map_zero = \"\\x00\";\n  d3_class(d3_Map, {\n    has: d3_map_has,\n    get: function(key) {\n      return this._[d3_map_escape(key)];\n    },\n    set: function(key, value) {\n      return this._[d3_map_escape(key)] = value;\n    },\n    remove: d3_map_remove,\n    keys: d3_map_keys,\n    values: function() {\n      var values = [];\n      for (var key in this._) values.push(this._[key]);\n      return values;\n    },\n    entries: function() {\n      var entries = [];\n      for (var key in this._) entries.push({\n        key: d3_map_unescape(key),\n        value: this._[key]\n      });\n      return entries;\n    },\n    size: d3_map_size,\n    empty: d3_map_empty,\n    forEach: function(f) {\n      for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]);\n    }\n  });\n  function d3_map_escape(key) {\n    return (key += \"\") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key;\n  }\n  function d3_map_unescape(key) {\n    return (key += \"\")[0] === d3_map_zero ? key.slice(1) : key;\n  }\n  function d3_map_has(key) {\n    return d3_map_escape(key) in this._;\n  }\n  function d3_map_remove(key) {\n    return (key = d3_map_escape(key)) in this._ && delete this._[key];\n  }\n  function d3_map_keys() {\n    var keys = [];\n    for (var key in this._) keys.push(d3_map_unescape(key));\n    return keys;\n  }\n  function d3_map_size() {\n    var size = 0;\n    for (var key in this._) ++size;\n    return size;\n  }\n  function d3_map_empty() {\n    for (var key in this._) return false;\n    return true;\n  }\n  d3.nest = function() {\n    var nest = {}, keys = [], sortKeys = [], sortValues, rollup;\n    function map(mapType, array, depth) {\n      if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;\n      var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values;\n      while (++i < n) {\n        if (values = valuesByKey.get(keyValue = key(object = array[i]))) {\n          values.push(object);\n        } else {\n          valuesByKey.set(keyValue, [ object ]);\n        }\n      }\n      if (mapType) {\n        object = mapType();\n        setter = function(keyValue, values) {\n          object.set(keyValue, map(mapType, values, depth));\n        };\n      } else {\n        object = {};\n        setter = function(keyValue, values) {\n          object[keyValue] = map(mapType, values, depth);\n        };\n      }\n      valuesByKey.forEach(setter);\n      return object;\n    }\n    function entries(map, depth) {\n      if (depth >= keys.length) return map;\n      var array = [], sortKey = sortKeys[depth++];\n      map.forEach(function(key, keyMap) {\n        array.push({\n          key: key,\n          values: entries(keyMap, depth)\n        });\n      });\n      return sortKey ? array.sort(function(a, b) {\n        return sortKey(a.key, b.key);\n      }) : array;\n    }\n    nest.map = function(array, mapType) {\n      return map(mapType, array, 0);\n    };\n    nest.entries = function(array) {\n      return entries(map(d3.map, array, 0), 0);\n    };\n    nest.key = function(d) {\n      keys.push(d);\n      return nest;\n    };\n    nest.sortKeys = function(order) {\n      sortKeys[keys.length - 1] = order;\n      return nest;\n    };\n    nest.sortValues = function(order) {\n      sortValues = order;\n      return nest;\n    };\n    nest.rollup = function(f) {\n      rollup = f;\n      return nest;\n    };\n    return nest;\n  };\n  d3.set = function(array) {\n    var set = new d3_Set();\n    if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]);\n    return set;\n  };\n  function d3_Set() {\n    this._ = Object.create(null);\n  }\n  d3_class(d3_Set, {\n    has: d3_map_has,\n    add: function(key) {\n      this._[d3_map_escape(key += \"\")] = true;\n      return key;\n    },\n    remove: d3_map_remove,\n    values: d3_map_keys,\n    size: d3_map_size,\n    empty: d3_map_empty,\n    forEach: function(f) {\n      for (var key in this._) f.call(this, d3_map_unescape(key));\n    }\n  });\n  d3.behavior = {};\n  function d3_identity(d) {\n    return d;\n  }\n  d3.rebind = function(target, source) {\n    var i = 1, n = arguments.length, method;\n    while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);\n    return target;\n  };\n  function d3_rebind(target, source, method) {\n    return function() {\n      var value = method.apply(source, arguments);\n      return value === source ? target : value;\n    };\n  }\n  function d3_vendorSymbol(object, name) {\n    if (name in object) return name;\n    name = name.charAt(0).toUpperCase() + name.slice(1);\n    for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) {\n      var prefixName = d3_vendorPrefixes[i] + name;\n      if (prefixName in object) return prefixName;\n    }\n  }\n  var d3_vendorPrefixes = [ \"webkit\", \"ms\", \"moz\", \"Moz\", \"o\", \"O\" ];\n  function d3_noop() {}\n  d3.dispatch = function() {\n    var dispatch = new d3_dispatch(), i = -1, n = arguments.length;\n    while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n    return dispatch;\n  };\n  function d3_dispatch() {}\n  d3_dispatch.prototype.on = function(type, listener) {\n    var i = type.indexOf(\".\"), name = \"\";\n    if (i >= 0) {\n      name = type.slice(i + 1);\n      type = type.slice(0, i);\n    }\n    if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);\n    if (arguments.length === 2) {\n      if (listener == null) for (type in this) {\n        if (this.hasOwnProperty(type)) this[type].on(name, null);\n      }\n      return this;\n    }\n  };\n  function d3_dispatch_event(dispatch) {\n    var listeners = [], listenerByName = new d3_Map();\n    function event() {\n      var z = listeners, i = -1, n = z.length, l;\n      while (++i < n) if (l = z[i].on) l.apply(this, arguments);\n      return dispatch;\n    }\n    event.on = function(name, listener) {\n      var l = listenerByName.get(name), i;\n      if (arguments.length < 2) return l && l.on;\n      if (l) {\n        l.on = null;\n        listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));\n        listenerByName.remove(name);\n      }\n      if (listener) listeners.push(listenerByName.set(name, {\n        on: listener\n      }));\n      return dispatch;\n    };\n    return event;\n  }\n  d3.event = null;\n  function d3_eventPreventDefault() {\n    d3.event.preventDefault();\n  }\n  function d3_eventSource() {\n    var e = d3.event, s;\n    while (s = e.sourceEvent) e = s;\n    return e;\n  }\n  function d3_eventDispatch(target) {\n    var dispatch = new d3_dispatch(), i = 0, n = arguments.length;\n    while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);\n    dispatch.of = function(thiz, argumentz) {\n      return function(e1) {\n        try {\n          var e0 = e1.sourceEvent = d3.event;\n          e1.target = target;\n          d3.event = e1;\n          dispatch[e1.type].apply(thiz, argumentz);\n        } finally {\n          d3.event = e0;\n        }\n      };\n    };\n    return dispatch;\n  }\n  d3.requote = function(s) {\n    return s.replace(d3_requote_re, \"\\\\$&\");\n  };\n  var d3_requote_re = /[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g;\n  var d3_subclass = {}.__proto__ ? function(object, prototype) {\n    object.__proto__ = prototype;\n  } : function(object, prototype) {\n    for (var property in prototype) object[property] = prototype[property];\n  };\n  function d3_selection(groups) {\n    d3_subclass(groups, d3_selectionPrototype);\n    return groups;\n  }\n  var d3_select = function(s, n) {\n    return n.querySelector(s);\n  }, d3_selectAll = function(s, n) {\n    return n.querySelectorAll(s);\n  }, d3_selectMatches = function(n, s) {\n    var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, \"matchesSelector\")];\n    d3_selectMatches = function(n, s) {\n      return d3_selectMatcher.call(n, s);\n    };\n    return d3_selectMatches(n, s);\n  };\n  if (typeof Sizzle === \"function\") {\n    d3_select = function(s, n) {\n      return Sizzle(s, n)[0] || null;\n    };\n    d3_selectAll = Sizzle;\n    d3_selectMatches = Sizzle.matchesSelector;\n  }\n  d3.selection = function() {\n    return d3.select(d3_document.documentElement);\n  };\n  var d3_selectionPrototype = d3.selection.prototype = [];\n  d3_selectionPrototype.select = function(selector) {\n    var subgroups = [], subgroup, subnode, group, node;\n    selector = d3_selection_selector(selector);\n    for (var j = -1, m = this.length; ++j < m; ) {\n      subgroups.push(subgroup = []);\n      subgroup.parentNode = (group = this[j]).parentNode;\n      for (var i = -1, n = group.length; ++i < n; ) {\n        if (node = group[i]) {\n          subgroup.push(subnode = selector.call(node, node.__data__, i, j));\n          if (subnode && \"__data__\" in node) subnode.__data__ = node.__data__;\n        } else {\n          subgroup.push(null);\n        }\n      }\n    }\n    return d3_selection(subgroups);\n  };\n  function d3_selection_selector(selector) {\n    return typeof selector === \"function\" ? selector : function() {\n      return d3_select(selector, this);\n    };\n  }\n  d3_selectionPrototype.selectAll = function(selector) {\n    var subgroups = [], subgroup, node;\n    selector = d3_selection_selectorAll(selector);\n    for (var j = -1, m = this.length; ++j < m; ) {\n      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n        if (node = group[i]) {\n          subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j)));\n          subgroup.parentNode = node;\n        }\n      }\n    }\n    return d3_selection(subgroups);\n  };\n  function d3_selection_selectorAll(selector) {\n    return typeof selector === \"function\" ? selector : function() {\n      return d3_selectAll(selector, this);\n    };\n  }\n  var d3_nsXhtml = \"http://www.w3.org/1999/xhtml\";\n  var d3_nsPrefix = {\n    svg: \"http://www.w3.org/2000/svg\",\n    xhtml: d3_nsXhtml,\n    xlink: \"http://www.w3.org/1999/xlink\",\n    xml: \"http://www.w3.org/XML/1998/namespace\",\n    xmlns: \"http://www.w3.org/2000/xmlns/\"\n  };\n  d3.ns = {\n    prefix: d3_nsPrefix,\n    qualify: function(name) {\n      var i = name.indexOf(\":\"), prefix = name;\n      if (i >= 0 && (prefix = name.slice(0, i)) !== \"xmlns\") name = name.slice(i + 1);\n      return d3_nsPrefix.hasOwnProperty(prefix) ? {\n        space: d3_nsPrefix[prefix],\n        local: name\n      } : name;\n    }\n  };\n  d3_selectionPrototype.attr = function(name, value) {\n    if (arguments.length < 2) {\n      if (typeof name === \"string\") {\n        var node = this.node();\n        name = d3.ns.qualify(name);\n        return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);\n      }\n      for (value in name) this.each(d3_selection_attr(value, name[value]));\n      return this;\n    }\n    return this.each(d3_selection_attr(name, value));\n  };\n  function d3_selection_attr(name, value) {\n    name = d3.ns.qualify(name);\n    function attrNull() {\n      this.removeAttribute(name);\n    }\n    function attrNullNS() {\n      this.removeAttributeNS(name.space, name.local);\n    }\n    function attrConstant() {\n      this.setAttribute(name, value);\n    }\n    function attrConstantNS() {\n      this.setAttributeNS(name.space, name.local, value);\n    }\n    function attrFunction() {\n      var x = value.apply(this, arguments);\n      if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);\n    }\n    function attrFunctionNS() {\n      var x = value.apply(this, arguments);\n      if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);\n    }\n    return value == null ? name.local ? attrNullNS : attrNull : typeof value === \"function\" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;\n  }\n  function d3_collapse(s) {\n    return s.trim().replace(/\\s+/g, \" \");\n  }\n  d3_selectionPrototype.classed = function(name, value) {\n    if (arguments.length < 2) {\n      if (typeof name === \"string\") {\n        var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1;\n        if (value = node.classList) {\n          while (++i < n) if (!value.contains(name[i])) return false;\n        } else {\n          value = node.getAttribute(\"class\");\n          while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;\n        }\n        return true;\n      }\n      for (value in name) this.each(d3_selection_classed(value, name[value]));\n      return this;\n    }\n    return this.each(d3_selection_classed(name, value));\n  };\n  function d3_selection_classedRe(name) {\n    return new RegExp(\"(?:^|\\\\s+)\" + d3.requote(name) + \"(?:\\\\s+|$)\", \"g\");\n  }\n  function d3_selection_classes(name) {\n    return (name + \"\").trim().split(/^|\\s+/);\n  }\n  function d3_selection_classed(name, value) {\n    name = d3_selection_classes(name).map(d3_selection_classedName);\n    var n = name.length;\n    function classedConstant() {\n      var i = -1;\n      while (++i < n) name[i](this, value);\n    }\n    function classedFunction() {\n      var i = -1, x = value.apply(this, arguments);\n      while (++i < n) name[i](this, x);\n    }\n    return typeof value === \"function\" ? classedFunction : classedConstant;\n  }\n  function d3_selection_classedName(name) {\n    var re = d3_selection_classedRe(name);\n    return function(node, value) {\n      if (c = node.classList) return value ? c.add(name) : c.remove(name);\n      var c = node.getAttribute(\"class\") || \"\";\n      if (value) {\n        re.lastIndex = 0;\n        if (!re.test(c)) node.setAttribute(\"class\", d3_collapse(c + \" \" + name));\n      } else {\n        node.setAttribute(\"class\", d3_collapse(c.replace(re, \" \")));\n      }\n    };\n  }\n  d3_selectionPrototype.style = function(name, value, priority) {\n    var n = arguments.length;\n    if (n < 3) {\n      if (typeof name !== \"string\") {\n        if (n < 2) value = \"\";\n        for (priority in name) this.each(d3_selection_style(priority, name[priority], value));\n        return this;\n      }\n      if (n < 2) {\n        var node = this.node();\n        return d3_window(node).getComputedStyle(node, null).getPropertyValue(name);\n      }\n      priority = \"\";\n    }\n    return this.each(d3_selection_style(name, value, priority));\n  };\n  function d3_selection_style(name, value, priority) {\n    function styleNull() {\n      this.style.removeProperty(name);\n    }\n    function styleConstant() {\n      this.style.setProperty(name, value, priority);\n    }\n    function styleFunction() {\n      var x = value.apply(this, arguments);\n      if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);\n    }\n    return value == null ? styleNull : typeof value === \"function\" ? styleFunction : styleConstant;\n  }\n  d3_selectionPrototype.property = function(name, value) {\n    if (arguments.length < 2) {\n      if (typeof name === \"string\") return this.node()[name];\n      for (value in name) this.each(d3_selection_property(value, name[value]));\n      return this;\n    }\n    return this.each(d3_selection_property(name, value));\n  };\n  function d3_selection_property(name, value) {\n    function propertyNull() {\n      delete this[name];\n    }\n    function propertyConstant() {\n      this[name] = value;\n    }\n    function propertyFunction() {\n      var x = value.apply(this, arguments);\n      if (x == null) delete this[name]; else this[name] = x;\n    }\n    return value == null ? propertyNull : typeof value === \"function\" ? propertyFunction : propertyConstant;\n  }\n  d3_selectionPrototype.text = function(value) {\n    return arguments.length ? this.each(typeof value === \"function\" ? function() {\n      var v = value.apply(this, arguments);\n      this.textContent = v == null ? \"\" : v;\n    } : value == null ? function() {\n      this.textContent = \"\";\n    } : function() {\n      this.textContent = value;\n    }) : this.node().textContent;\n  };\n  d3_selectionPrototype.html = function(value) {\n    return arguments.length ? this.each(typeof value === \"function\" ? function() {\n      var v = value.apply(this, arguments);\n      this.innerHTML = v == null ? \"\" : v;\n    } : value == null ? function() {\n      this.innerHTML = \"\";\n    } : function() {\n      this.innerHTML = value;\n    }) : this.node().innerHTML;\n  };\n  d3_selectionPrototype.append = function(name) {\n    name = d3_selection_creator(name);\n    return this.select(function() {\n      return this.appendChild(name.apply(this, arguments));\n    });\n  };\n  function d3_selection_creator(name) {\n    function create() {\n      var document = this.ownerDocument, namespace = this.namespaceURI;\n      return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name);\n    }\n    function createNS() {\n      return this.ownerDocument.createElementNS(name.space, name.local);\n    }\n    return typeof name === \"function\" ? name : (name = d3.ns.qualify(name)).local ? createNS : create;\n  }\n  d3_selectionPrototype.insert = function(name, before) {\n    name = d3_selection_creator(name);\n    before = d3_selection_selector(before);\n    return this.select(function() {\n      return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null);\n    });\n  };\n  d3_selectionPrototype.remove = function() {\n    return this.each(d3_selectionRemove);\n  };\n  function d3_selectionRemove() {\n    var parent = this.parentNode;\n    if (parent) parent.removeChild(this);\n  }\n  d3_selectionPrototype.data = function(value, key) {\n    var i = -1, n = this.length, group, node;\n    if (!arguments.length) {\n      value = new Array(n = (group = this[0]).length);\n      while (++i < n) {\n        if (node = group[i]) {\n          value[i] = node.__data__;\n        }\n      }\n      return value;\n    }\n    function bind(group, groupData) {\n      var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData;\n      if (key) {\n        var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;\n        for (i = -1; ++i < n; ) {\n          if (node = group[i]) {\n            if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) {\n              exitNodes[i] = node;\n            } else {\n              nodeByKeyValue.set(keyValue, node);\n            }\n            keyValues[i] = keyValue;\n          }\n        }\n        for (i = -1; ++i < m; ) {\n          if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {\n            enterNodes[i] = d3_selection_dataNode(nodeData);\n          } else if (node !== true) {\n            updateNodes[i] = node;\n            node.__data__ = nodeData;\n          }\n          nodeByKeyValue.set(keyValue, true);\n        }\n        for (i = -1; ++i < n; ) {\n          if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) {\n            exitNodes[i] = group[i];\n          }\n        }\n      } else {\n        for (i = -1; ++i < n0; ) {\n          node = group[i];\n          nodeData = groupData[i];\n          if (node) {\n            node.__data__ = nodeData;\n            updateNodes[i] = node;\n          } else {\n            enterNodes[i] = d3_selection_dataNode(nodeData);\n          }\n        }\n        for (;i < m; ++i) {\n          enterNodes[i] = d3_selection_dataNode(groupData[i]);\n        }\n        for (;i < n; ++i) {\n          exitNodes[i] = group[i];\n        }\n      }\n      enterNodes.update = updateNodes;\n      enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;\n      enter.push(enterNodes);\n      update.push(updateNodes);\n      exit.push(exitNodes);\n    }\n    var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);\n    if (typeof value === \"function\") {\n      while (++i < n) {\n        bind(group = this[i], value.call(group, group.parentNode.__data__, i));\n      }\n    } else {\n      while (++i < n) {\n        bind(group = this[i], value);\n      }\n    }\n    update.enter = function() {\n      return enter;\n    };\n    update.exit = function() {\n      return exit;\n    };\n    return update;\n  };\n  function d3_selection_dataNode(data) {\n    return {\n      __data__: data\n    };\n  }\n  d3_selectionPrototype.datum = function(value) {\n    return arguments.length ? this.property(\"__data__\", value) : this.property(\"__data__\");\n  };\n  d3_selectionPrototype.filter = function(filter) {\n    var subgroups = [], subgroup, group, node;\n    if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n    for (var j = 0, m = this.length; j < m; j++) {\n      subgroups.push(subgroup = []);\n      subgroup.parentNode = (group = this[j]).parentNode;\n      for (var i = 0, n = group.length; i < n; i++) {\n        if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n          subgroup.push(node);\n        }\n      }\n    }\n    return d3_selection(subgroups);\n  };\n  function d3_selection_filter(selector) {\n    return function() {\n      return d3_selectMatches(this, selector);\n    };\n  }\n  d3_selectionPrototype.order = function() {\n    for (var j = -1, m = this.length; ++j < m; ) {\n      for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {\n        if (node = group[i]) {\n          if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);\n          next = node;\n        }\n      }\n    }\n    return this;\n  };\n  d3_selectionPrototype.sort = function(comparator) {\n    comparator = d3_selection_sortComparator.apply(this, arguments);\n    for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);\n    return this.order();\n  };\n  function d3_selection_sortComparator(comparator) {\n    if (!arguments.length) comparator = d3_ascending;\n    return function(a, b) {\n      return a && b ? comparator(a.__data__, b.__data__) : !a - !b;\n    };\n  }\n  d3_selectionPrototype.each = function(callback) {\n    return d3_selection_each(this, function(node, i, j) {\n      callback.call(node, node.__data__, i, j);\n    });\n  };\n  function d3_selection_each(groups, callback) {\n    for (var j = 0, m = groups.length; j < m; j++) {\n      for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {\n        if (node = group[i]) callback(node, i, j);\n      }\n    }\n    return groups;\n  }\n  d3_selectionPrototype.call = function(callback) {\n    var args = d3_array(arguments);\n    callback.apply(args[0] = this, args);\n    return this;\n  };\n  d3_selectionPrototype.empty = function() {\n    return !this.node();\n  };\n  d3_selectionPrototype.node = function() {\n    for (var j = 0, m = this.length; j < m; j++) {\n      for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n        var node = group[i];\n        if (node) return node;\n      }\n    }\n    return null;\n  };\n  d3_selectionPrototype.size = function() {\n    var n = 0;\n    d3_selection_each(this, function() {\n      ++n;\n    });\n    return n;\n  };\n  function d3_selection_enter(selection) {\n    d3_subclass(selection, d3_selection_enterPrototype);\n    return selection;\n  }\n  var d3_selection_enterPrototype = [];\n  d3.selection.enter = d3_selection_enter;\n  d3.selection.enter.prototype = d3_selection_enterPrototype;\n  d3_selection_enterPrototype.append = d3_selectionPrototype.append;\n  d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;\n  d3_selection_enterPrototype.node = d3_selectionPrototype.node;\n  d3_selection_enterPrototype.call = d3_selectionPrototype.call;\n  d3_selection_enterPrototype.size = d3_selectionPrototype.size;\n  d3_selection_enterPrototype.select = function(selector) {\n    var subgroups = [], subgroup, subnode, upgroup, group, node;\n    for (var j = -1, m = this.length; ++j < m; ) {\n      upgroup = (group = this[j]).update;\n      subgroups.push(subgroup = []);\n      subgroup.parentNode = group.parentNode;\n      for (var i = -1, n = group.length; ++i < n; ) {\n        if (node = group[i]) {\n          subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));\n          subnode.__data__ = node.__data__;\n        } else {\n          subgroup.push(null);\n        }\n      }\n    }\n    return d3_selection(subgroups);\n  };\n  d3_selection_enterPrototype.insert = function(name, before) {\n    if (arguments.length < 2) before = d3_selection_enterInsertBefore(this);\n    return d3_selectionPrototype.insert.call(this, name, before);\n  };\n  function d3_selection_enterInsertBefore(enter) {\n    var i0, j0;\n    return function(d, i, j) {\n      var group = enter[j].update, n = group.length, node;\n      if (j != j0) j0 = j, i0 = 0;\n      if (i >= i0) i0 = i + 1;\n      while (!(node = group[i0]) && ++i0 < n) ;\n      return node;\n    };\n  }\n  d3.select = function(node) {\n    var group;\n    if (typeof node === \"string\") {\n      group = [ d3_select(node, d3_document) ];\n      group.parentNode = d3_document.documentElement;\n    } else {\n      group = [ node ];\n      group.parentNode = d3_documentElement(node);\n    }\n    return d3_selection([ group ]);\n  };\n  d3.selectAll = function(nodes) {\n    var group;\n    if (typeof nodes === \"string\") {\n      group = d3_array(d3_selectAll(nodes, d3_document));\n      group.parentNode = d3_document.documentElement;\n    } else {\n      group = d3_array(nodes);\n      group.parentNode = null;\n    }\n    return d3_selection([ group ]);\n  };\n  d3_selectionPrototype.on = function(type, listener, capture) {\n    var n = arguments.length;\n    if (n < 3) {\n      if (typeof type !== \"string\") {\n        if (n < 2) listener = false;\n        for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));\n        return this;\n      }\n      if (n < 2) return (n = this.node()[\"__on\" + type]) && n._;\n      capture = false;\n    }\n    return this.each(d3_selection_on(type, listener, capture));\n  };\n  function d3_selection_on(type, listener, capture) {\n    var name = \"__on\" + type, i = type.indexOf(\".\"), wrap = d3_selection_onListener;\n    if (i > 0) type = type.slice(0, i);\n    var filter = d3_selection_onFilters.get(type);\n    if (filter) type = filter, wrap = d3_selection_onFilter;\n    function onRemove() {\n      var l = this[name];\n      if (l) {\n        this.removeEventListener(type, l, l.$);\n        delete this[name];\n      }\n    }\n    function onAdd() {\n      var l = wrap(listener, d3_array(arguments));\n      onRemove.call(this);\n      this.addEventListener(type, this[name] = l, l.$ = capture);\n      l._ = listener;\n    }\n    function removeAll() {\n      var re = new RegExp(\"^__on([^.]+)\" + d3.requote(type) + \"$\"), match;\n      for (var name in this) {\n        if (match = name.match(re)) {\n          var l = this[name];\n          this.removeEventListener(match[1], l, l.$);\n          delete this[name];\n        }\n      }\n    }\n    return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll;\n  }\n  var d3_selection_onFilters = d3.map({\n    mouseenter: \"mouseover\",\n    mouseleave: \"mouseout\"\n  });\n  if (d3_document) {\n    d3_selection_onFilters.forEach(function(k) {\n      if (\"on\" + k in d3_document) d3_selection_onFilters.remove(k);\n    });\n  }\n  function d3_selection_onListener(listener, argumentz) {\n    return function(e) {\n      var o = d3.event;\n      d3.event = e;\n      argumentz[0] = this.__data__;\n      try {\n        listener.apply(this, argumentz);\n      } finally {\n        d3.event = o;\n      }\n    };\n  }\n  function d3_selection_onFilter(listener, argumentz) {\n    var l = d3_selection_onListener(listener, argumentz);\n    return function(e) {\n      var target = this, related = e.relatedTarget;\n      if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) {\n        l.call(target, e);\n      }\n    };\n  }\n  var d3_event_dragSelect, d3_event_dragId = 0;\n  function d3_event_dragSuppress(node) {\n    var name = \".dragsuppress-\" + ++d3_event_dragId, click = \"click\" + name, w = d3.select(d3_window(node)).on(\"touchmove\" + name, d3_eventPreventDefault).on(\"dragstart\" + name, d3_eventPreventDefault).on(\"selectstart\" + name, d3_eventPreventDefault);\n    if (d3_event_dragSelect == null) {\n      d3_event_dragSelect = \"onselectstart\" in node ? false : d3_vendorSymbol(node.style, \"userSelect\");\n    }\n    if (d3_event_dragSelect) {\n      var style = d3_documentElement(node).style, select = style[d3_event_dragSelect];\n      style[d3_event_dragSelect] = \"none\";\n    }\n    return function(suppressClick) {\n      w.on(name, null);\n      if (d3_event_dragSelect) style[d3_event_dragSelect] = select;\n      if (suppressClick) {\n        var off = function() {\n          w.on(click, null);\n        };\n        w.on(click, function() {\n          d3_eventPreventDefault();\n          off();\n        }, true);\n        setTimeout(off, 0);\n      }\n    };\n  }\n  d3.mouse = function(container) {\n    return d3_mousePoint(container, d3_eventSource());\n  };\n  var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0;\n  function d3_mousePoint(container, e) {\n    if (e.changedTouches) e = e.changedTouches[0];\n    var svg = container.ownerSVGElement || container;\n    if (svg.createSVGPoint) {\n      var point = svg.createSVGPoint();\n      if (d3_mouse_bug44083 < 0) {\n        var window = d3_window(container);\n        if (window.scrollX || window.scrollY) {\n          svg = d3.select(\"body\").append(\"svg\").style({\n            position: \"absolute\",\n            top: 0,\n            left: 0,\n            margin: 0,\n            padding: 0,\n            border: \"none\"\n          }, \"important\");\n          var ctm = svg[0][0].getScreenCTM();\n          d3_mouse_bug44083 = !(ctm.f || ctm.e);\n          svg.remove();\n        }\n      }\n      if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, \n      point.y = e.clientY;\n      point = point.matrixTransform(container.getScreenCTM().inverse());\n      return [ point.x, point.y ];\n    }\n    var rect = container.getBoundingClientRect();\n    return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];\n  }\n  d3.touch = function(container, touches, identifier) {\n    if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches;\n    if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) {\n      if ((touch = touches[i]).identifier === identifier) {\n        return d3_mousePoint(container, touch);\n      }\n    }\n  };\n  d3.behavior.drag = function() {\n    var event = d3_eventDispatch(drag, \"drag\", \"dragstart\", \"dragend\"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, \"mousemove\", \"mouseup\"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, \"touchmove\", \"touchend\");\n    function drag() {\n      this.on(\"mousedown.drag\", mousedown).on(\"touchstart.drag\", touchstart);\n    }\n    function dragstart(id, position, subject, move, end) {\n      return function() {\n        var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = \".drag\" + (dragId == null ? \"\" : \"-\" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId);\n        if (origin) {\n          dragOffset = origin.apply(that, arguments);\n          dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];\n        } else {\n          dragOffset = [ 0, 0 ];\n        }\n        dispatch({\n          type: \"dragstart\"\n        });\n        function moved() {\n          var position1 = position(parent, dragId), dx, dy;\n          if (!position1) return;\n          dx = position1[0] - position0[0];\n          dy = position1[1] - position0[1];\n          dragged |= dx | dy;\n          position0 = position1;\n          dispatch({\n            type: \"drag\",\n            x: position1[0] + dragOffset[0],\n            y: position1[1] + dragOffset[1],\n            dx: dx,\n            dy: dy\n          });\n        }\n        function ended() {\n          if (!position(parent, dragId)) return;\n          dragSubject.on(move + dragName, null).on(end + dragName, null);\n          dragRestore(dragged);\n          dispatch({\n            type: \"dragend\"\n          });\n        }\n      };\n    }\n    drag.origin = function(x) {\n      if (!arguments.length) return origin;\n      origin = x;\n      return drag;\n    };\n    return d3.rebind(drag, event, \"on\");\n  };\n  function d3_behavior_dragTouchId() {\n    return d3.event.changedTouches[0].identifier;\n  }\n  d3.touches = function(container, touches) {\n    if (arguments.length < 2) touches = d3_eventSource().touches;\n    return touches ? d3_array(touches).map(function(touch) {\n      var point = d3_mousePoint(container, touch);\n      point.identifier = touch.identifier;\n      return point;\n    }) : [];\n  };\n  var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π;\n  function d3_sgn(x) {\n    return x > 0 ? 1 : x < 0 ? -1 : 0;\n  }\n  function d3_cross2d(a, b, c) {\n    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);\n  }\n  function d3_acos(x) {\n    return x > 1 ? 0 : x < -1 ? π : Math.acos(x);\n  }\n  function d3_asin(x) {\n    return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);\n  }\n  function d3_sinh(x) {\n    return ((x = Math.exp(x)) - 1 / x) / 2;\n  }\n  function d3_cosh(x) {\n    return ((x = Math.exp(x)) + 1 / x) / 2;\n  }\n  function d3_tanh(x) {\n    return ((x = Math.exp(2 * x)) - 1) / (x + 1);\n  }\n  function d3_haversin(x) {\n    return (x = Math.sin(x / 2)) * x;\n  }\n  var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;\n  d3.interpolateZoom = function(p0, p1) {\n    var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S;\n    if (d2 < ε2) {\n      S = Math.log(w1 / w0) / ρ;\n      i = function(t) {\n        return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ];\n      };\n    } else {\n      var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);\n      S = (r1 - r0) / ρ;\n      i = function(t) {\n        var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));\n        return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];\n      };\n    }\n    i.duration = S * 1e3;\n    return i;\n  };\n  d3.behavior.zoom = function() {\n    var view = {\n      x: 0,\n      y: 0,\n      k: 1\n    }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = \"mousedown.zoom\", mousemove = \"mousemove.zoom\", mouseup = \"mouseup.zoom\", mousewheelTimer, touchstart = \"touchstart.zoom\", touchtime, event = d3_eventDispatch(zoom, \"zoomstart\", \"zoom\", \"zoomend\"), x0, x1, y0, y1;\n    if (!d3_behavior_zoomWheel) {\n      d3_behavior_zoomWheel = \"onwheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n        return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1);\n      }, \"wheel\") : \"onmousewheel\" in d3_document ? (d3_behavior_zoomDelta = function() {\n        return d3.event.wheelDelta;\n      }, \"mousewheel\") : (d3_behavior_zoomDelta = function() {\n        return -d3.event.detail;\n      }, \"MozMousePixelScroll\");\n    }\n    function zoom(g) {\n      g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + \".zoom\", mousewheeled).on(\"dblclick.zoom\", dblclicked).on(touchstart, touchstarted);\n    }\n    zoom.event = function(g) {\n      g.each(function() {\n        var dispatch = event.of(this, arguments), view1 = view;\n        if (d3_transitionInheritId) {\n          d3.select(this).transition().each(\"start.zoom\", function() {\n            view = this.__chart__ || {\n              x: 0,\n              y: 0,\n              k: 1\n            };\n            zoomstarted(dispatch);\n          }).tween(\"zoom:zoom\", function() {\n            var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]);\n            return function(t) {\n              var l = i(t), k = dx / l[2];\n              this.__chart__ = view = {\n                x: cx - l[0] * k,\n                y: cy - l[1] * k,\n                k: k\n              };\n              zoomed(dispatch);\n            };\n          }).each(\"interrupt.zoom\", function() {\n            zoomended(dispatch);\n          }).each(\"end.zoom\", function() {\n            zoomended(dispatch);\n          });\n        } else {\n          this.__chart__ = view;\n          zoomstarted(dispatch);\n          zoomed(dispatch);\n          zoomended(dispatch);\n        }\n      });\n    };\n    zoom.translate = function(_) {\n      if (!arguments.length) return [ view.x, view.y ];\n      view = {\n        x: +_[0],\n        y: +_[1],\n        k: view.k\n      };\n      rescale();\n      return zoom;\n    };\n    zoom.scale = function(_) {\n      if (!arguments.length) return view.k;\n      view = {\n        x: view.x,\n        y: view.y,\n        k: null\n      };\n      scaleTo(+_);\n      rescale();\n      return zoom;\n    };\n    zoom.scaleExtent = function(_) {\n      if (!arguments.length) return scaleExtent;\n      scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ];\n      return zoom;\n    };\n    zoom.center = function(_) {\n      if (!arguments.length) return center;\n      center = _ && [ +_[0], +_[1] ];\n      return zoom;\n    };\n    zoom.size = function(_) {\n      if (!arguments.length) return size;\n      size = _ && [ +_[0], +_[1] ];\n      return zoom;\n    };\n    zoom.duration = function(_) {\n      if (!arguments.length) return duration;\n      duration = +_;\n      return zoom;\n    };\n    zoom.x = function(z) {\n      if (!arguments.length) return x1;\n      x1 = z;\n      x0 = z.copy();\n      view = {\n        x: 0,\n        y: 0,\n        k: 1\n      };\n      return zoom;\n    };\n    zoom.y = function(z) {\n      if (!arguments.length) return y1;\n      y1 = z;\n      y0 = z.copy();\n      view = {\n        x: 0,\n        y: 0,\n        k: 1\n      };\n      return zoom;\n    };\n    function location(p) {\n      return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ];\n    }\n    function point(l) {\n      return [ l[0] * view.k + view.x, l[1] * view.k + view.y ];\n    }\n    function scaleTo(s) {\n      view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));\n    }\n    function translateTo(p, l) {\n      l = point(l);\n      view.x += p[0] - l[0];\n      view.y += p[1] - l[1];\n    }\n    function zoomTo(that, p, l, k) {\n      that.__chart__ = {\n        x: view.x,\n        y: view.y,\n        k: view.k\n      };\n      scaleTo(Math.pow(2, k));\n      translateTo(center0 = p, l);\n      that = d3.select(that);\n      if (duration > 0) that = that.transition().duration(duration);\n      that.call(zoom.event);\n    }\n    function rescale() {\n      if (x1) x1.domain(x0.range().map(function(x) {\n        return (x - view.x) / view.k;\n      }).map(x0.invert));\n      if (y1) y1.domain(y0.range().map(function(y) {\n        return (y - view.y) / view.k;\n      }).map(y0.invert));\n    }\n    function zoomstarted(dispatch) {\n      if (!zooming++) dispatch({\n        type: \"zoomstart\"\n      });\n    }\n    function zoomed(dispatch) {\n      rescale();\n      dispatch({\n        type: \"zoom\",\n        scale: view.k,\n        translate: [ view.x, view.y ]\n      });\n    }\n    function zoomended(dispatch) {\n      if (!--zooming) dispatch({\n        type: \"zoomend\"\n      }), center0 = null;\n    }\n    function mousedowned() {\n      var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that);\n      d3_selection_interrupt.call(that);\n      zoomstarted(dispatch);\n      function moved() {\n        dragged = 1;\n        translateTo(d3.mouse(that), location0);\n        zoomed(dispatch);\n      }\n      function ended() {\n        subject.on(mousemove, null).on(mouseup, null);\n        dragRestore(dragged);\n        zoomended(dispatch);\n      }\n    }\n    function touchstarted() {\n      var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = \".zoom-\" + d3.event.changedTouches[0].identifier, touchmove = \"touchmove\" + zoomName, touchend = \"touchend\" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(that);\n      started();\n      zoomstarted(dispatch);\n      subject.on(mousedown, null).on(touchstart, started);\n      function relocate() {\n        var touches = d3.touches(that);\n        scale0 = view.k;\n        touches.forEach(function(t) {\n          if (t.identifier in locations0) locations0[t.identifier] = location(t);\n        });\n        return touches;\n      }\n      function started() {\n        var target = d3.event.target;\n        d3.select(target).on(touchmove, moved).on(touchend, ended);\n        targets.push(target);\n        var changed = d3.event.changedTouches;\n        for (var i = 0, n = changed.length; i < n; ++i) {\n          locations0[changed[i].identifier] = null;\n        }\n        var touches = relocate(), now = Date.now();\n        if (touches.length === 1) {\n          if (now - touchtime < 500) {\n            var p = touches[0];\n            zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1);\n            d3_eventPreventDefault();\n          }\n          touchtime = now;\n        } else if (touches.length > 1) {\n          var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1];\n          distance0 = dx * dx + dy * dy;\n        }\n      }\n      function moved() {\n        var touches = d3.touches(that), p0, l0, p1, l1;\n        d3_selection_interrupt.call(that);\n        for (var i = 0, n = touches.length; i < n; ++i, l1 = null) {\n          p1 = touches[i];\n          if (l1 = locations0[p1.identifier]) {\n            if (l0) break;\n            p0 = p1, l0 = l1;\n          }\n        }\n        if (l1) {\n          var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0);\n          p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];\n          l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];\n          scaleTo(scale1 * scale0);\n        }\n        touchtime = null;\n        translateTo(p0, l0);\n        zoomed(dispatch);\n      }\n      function ended() {\n        if (d3.event.touches.length) {\n          var changed = d3.event.changedTouches;\n          for (var i = 0, n = changed.length; i < n; ++i) {\n            delete locations0[changed[i].identifier];\n          }\n          for (var identifier in locations0) {\n            return void relocate();\n          }\n        }\n        d3.selectAll(targets).on(zoomName, null);\n        subject.on(mousedown, mousedowned).on(touchstart, touchstarted);\n        dragRestore();\n        zoomended(dispatch);\n      }\n    }\n    function mousewheeled() {\n      var dispatch = event.of(this, arguments);\n      if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), \n      translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch);\n      mousewheelTimer = setTimeout(function() {\n        mousewheelTimer = null;\n        zoomended(dispatch);\n      }, 50);\n      d3_eventPreventDefault();\n      scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k);\n      translateTo(center0, translate0);\n      zoomed(dispatch);\n    }\n    function dblclicked() {\n      var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2;\n      zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1);\n    }\n    return d3.rebind(zoom, event, \"on\");\n  };\n  var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel;\n  d3.color = d3_color;\n  function d3_color() {}\n  d3_color.prototype.toString = function() {\n    return this.rgb() + \"\";\n  };\n  d3.hsl = d3_hsl;\n  function d3_hsl(h, s, l) {\n    return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse(\"\" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l);\n  }\n  var d3_hslPrototype = d3_hsl.prototype = new d3_color();\n  d3_hslPrototype.brighter = function(k) {\n    k = Math.pow(.7, arguments.length ? k : 1);\n    return new d3_hsl(this.h, this.s, this.l / k);\n  };\n  d3_hslPrototype.darker = function(k) {\n    k = Math.pow(.7, arguments.length ? k : 1);\n    return new d3_hsl(this.h, this.s, k * this.l);\n  };\n  d3_hslPrototype.rgb = function() {\n    return d3_hsl_rgb(this.h, this.s, this.l);\n  };\n  function d3_hsl_rgb(h, s, l) {\n    var m1, m2;\n    h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;\n    s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;\n    l = l < 0 ? 0 : l > 1 ? 1 : l;\n    m2 = l <= .5 ? l * (1 + s) : l + s - l * s;\n    m1 = 2 * l - m2;\n    function v(h) {\n      if (h > 360) h -= 360; else if (h < 0) h += 360;\n      if (h < 60) return m1 + (m2 - m1) * h / 60;\n      if (h < 180) return m2;\n      if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;\n      return m1;\n    }\n    function vv(h) {\n      return Math.round(v(h) * 255);\n    }\n    return new d3_rgb(vv(h + 120), vv(h), vv(h - 120));\n  }\n  d3.hcl = d3_hcl;\n  function d3_hcl(h, c, l) {\n    return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l);\n  }\n  var d3_hclPrototype = d3_hcl.prototype = new d3_color();\n  d3_hclPrototype.brighter = function(k) {\n    return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));\n  };\n  d3_hclPrototype.darker = function(k) {\n    return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));\n  };\n  d3_hclPrototype.rgb = function() {\n    return d3_hcl_lab(this.h, this.c, this.l).rgb();\n  };\n  function d3_hcl_lab(h, c, l) {\n    if (isNaN(h)) h = 0;\n    if (isNaN(c)) c = 0;\n    return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);\n  }\n  d3.lab = d3_lab;\n  function d3_lab(l, a, b) {\n    return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b);\n  }\n  var d3_lab_K = 18;\n  var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;\n  var d3_labPrototype = d3_lab.prototype = new d3_color();\n  d3_labPrototype.brighter = function(k) {\n    return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n  };\n  d3_labPrototype.darker = function(k) {\n    return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);\n  };\n  d3_labPrototype.rgb = function() {\n    return d3_lab_rgb(this.l, this.a, this.b);\n  };\n  function d3_lab_rgb(l, a, b) {\n    var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;\n    x = d3_lab_xyz(x) * d3_lab_X;\n    y = d3_lab_xyz(y) * d3_lab_Y;\n    z = d3_lab_xyz(z) * d3_lab_Z;\n    return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));\n  }\n  function d3_lab_hcl(l, a, b) {\n    return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l);\n  }\n  function d3_lab_xyz(x) {\n    return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;\n  }\n  function d3_xyz_lab(x) {\n    return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;\n  }\n  function d3_xyz_rgb(r) {\n    return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));\n  }\n  d3.rgb = d3_rgb;\n  function d3_rgb(r, g, b) {\n    return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse(\"\" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b);\n  }\n  function d3_rgbNumber(value) {\n    return new d3_rgb(value >> 16, value >> 8 & 255, value & 255);\n  }\n  function d3_rgbString(value) {\n    return d3_rgbNumber(value) + \"\";\n  }\n  var d3_rgbPrototype = d3_rgb.prototype = new d3_color();\n  d3_rgbPrototype.brighter = function(k) {\n    k = Math.pow(.7, arguments.length ? k : 1);\n    var r = this.r, g = this.g, b = this.b, i = 30;\n    if (!r && !g && !b) return new d3_rgb(i, i, i);\n    if (r && r < i) r = i;\n    if (g && g < i) g = i;\n    if (b && b < i) b = i;\n    return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k));\n  };\n  d3_rgbPrototype.darker = function(k) {\n    k = Math.pow(.7, arguments.length ? k : 1);\n    return new d3_rgb(k * this.r, k * this.g, k * this.b);\n  };\n  d3_rgbPrototype.hsl = function() {\n    return d3_rgb_hsl(this.r, this.g, this.b);\n  };\n  d3_rgbPrototype.toString = function() {\n    return \"#\" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);\n  };\n  function d3_rgb_hex(v) {\n    return v < 16 ? \"0\" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);\n  }\n  function d3_rgb_parse(format, rgb, hsl) {\n    var r = 0, g = 0, b = 0, m1, m2, color;\n    m1 = /([a-z]+)\\((.*)\\)/.exec(format = format.toLowerCase());\n    if (m1) {\n      m2 = m1[2].split(\",\");\n      switch (m1[1]) {\n       case \"hsl\":\n        {\n          return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);\n        }\n\n       case \"rgb\":\n        {\n          return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));\n        }\n      }\n    }\n    if (color = d3_rgb_names.get(format)) {\n      return rgb(color.r, color.g, color.b);\n    }\n    if (format != null && format.charAt(0) === \"#\" && !isNaN(color = parseInt(format.slice(1), 16))) {\n      if (format.length === 4) {\n        r = (color & 3840) >> 4;\n        r = r >> 4 | r;\n        g = color & 240;\n        g = g >> 4 | g;\n        b = color & 15;\n        b = b << 4 | b;\n      } else if (format.length === 7) {\n        r = (color & 16711680) >> 16;\n        g = (color & 65280) >> 8;\n        b = color & 255;\n      }\n    }\n    return rgb(r, g, b);\n  }\n  function d3_rgb_hsl(r, g, b) {\n    var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;\n    if (d) {\n      s = l < .5 ? d / (max + min) : d / (2 - max - min);\n      if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;\n      h *= 60;\n    } else {\n      h = NaN;\n      s = l > 0 && l < 1 ? 0 : h;\n    }\n    return new d3_hsl(h, s, l);\n  }\n  function d3_rgb_lab(r, g, b) {\n    r = d3_rgb_xyz(r);\n    g = d3_rgb_xyz(g);\n    b = d3_rgb_xyz(b);\n    var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z);\n    return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));\n  }\n  function d3_rgb_xyz(r) {\n    return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);\n  }\n  function d3_rgb_parseNumber(c) {\n    var f = parseFloat(c);\n    return c.charAt(c.length - 1) === \"%\" ? Math.round(f * 2.55) : f;\n  }\n  var d3_rgb_names = d3.map({\n    aliceblue: 15792383,\n    antiquewhite: 16444375,\n    aqua: 65535,\n    aquamarine: 8388564,\n    azure: 15794175,\n    beige: 16119260,\n    bisque: 16770244,\n    black: 0,\n    blanchedalmond: 16772045,\n    blue: 255,\n    blueviolet: 9055202,\n    brown: 10824234,\n    burlywood: 14596231,\n    cadetblue: 6266528,\n    chartreuse: 8388352,\n    chocolate: 13789470,\n    coral: 16744272,\n    cornflowerblue: 6591981,\n    cornsilk: 16775388,\n    crimson: 14423100,\n    cyan: 65535,\n    darkblue: 139,\n    darkcyan: 35723,\n    darkgoldenrod: 12092939,\n    darkgray: 11119017,\n    darkgreen: 25600,\n    darkgrey: 11119017,\n    darkkhaki: 12433259,\n    darkmagenta: 9109643,\n    darkolivegreen: 5597999,\n    darkorange: 16747520,\n    darkorchid: 10040012,\n    darkred: 9109504,\n    darksalmon: 15308410,\n    darkseagreen: 9419919,\n    darkslateblue: 4734347,\n    darkslategray: 3100495,\n    darkslategrey: 3100495,\n    darkturquoise: 52945,\n    darkviolet: 9699539,\n    deeppink: 16716947,\n    deepskyblue: 49151,\n    dimgray: 6908265,\n    dimgrey: 6908265,\n    dodgerblue: 2003199,\n    firebrick: 11674146,\n    floralwhite: 16775920,\n    forestgreen: 2263842,\n    fuchsia: 16711935,\n    gainsboro: 14474460,\n    ghostwhite: 16316671,\n    gold: 16766720,\n    goldenrod: 14329120,\n    gray: 8421504,\n    green: 32768,\n    greenyellow: 11403055,\n    grey: 8421504,\n    honeydew: 15794160,\n    hotpink: 16738740,\n    indianred: 13458524,\n    indigo: 4915330,\n    ivory: 16777200,\n    khaki: 15787660,\n    lavender: 15132410,\n    lavenderblush: 16773365,\n    lawngreen: 8190976,\n    lemonchiffon: 16775885,\n    lightblue: 11393254,\n    lightcoral: 15761536,\n    lightcyan: 14745599,\n    lightgoldenrodyellow: 16448210,\n    lightgray: 13882323,\n    lightgreen: 9498256,\n    lightgrey: 13882323,\n    lightpink: 16758465,\n    lightsalmon: 16752762,\n    lightseagreen: 2142890,\n    lightskyblue: 8900346,\n    lightslategray: 7833753,\n    lightslategrey: 7833753,\n    lightsteelblue: 11584734,\n    lightyellow: 16777184,\n    lime: 65280,\n    limegreen: 3329330,\n    linen: 16445670,\n    magenta: 16711935,\n    maroon: 8388608,\n    mediumaquamarine: 6737322,\n    mediumblue: 205,\n    mediumorchid: 12211667,\n    mediumpurple: 9662683,\n    mediumseagreen: 3978097,\n    mediumslateblue: 8087790,\n    mediumspringgreen: 64154,\n    mediumturquoise: 4772300,\n    mediumvioletred: 13047173,\n    midnightblue: 1644912,\n    mintcream: 16121850,\n    mistyrose: 16770273,\n    moccasin: 16770229,\n    navajowhite: 16768685,\n    navy: 128,\n    oldlace: 16643558,\n    olive: 8421376,\n    olivedrab: 7048739,\n    orange: 16753920,\n    orangered: 16729344,\n    orchid: 14315734,\n    palegoldenrod: 15657130,\n    palegreen: 10025880,\n    paleturquoise: 11529966,\n    palevioletred: 14381203,\n    papayawhip: 16773077,\n    peachpuff: 16767673,\n    peru: 13468991,\n    pink: 16761035,\n    plum: 14524637,\n    powderblue: 11591910,\n    purple: 8388736,\n    rebeccapurple: 6697881,\n    red: 16711680,\n    rosybrown: 12357519,\n    royalblue: 4286945,\n    saddlebrown: 9127187,\n    salmon: 16416882,\n    sandybrown: 16032864,\n    seagreen: 3050327,\n    seashell: 16774638,\n    sienna: 10506797,\n    silver: 12632256,\n    skyblue: 8900331,\n    slateblue: 6970061,\n    slategray: 7372944,\n    slategrey: 7372944,\n    snow: 16775930,\n    springgreen: 65407,\n    steelblue: 4620980,\n    tan: 13808780,\n    teal: 32896,\n    thistle: 14204888,\n    tomato: 16737095,\n    turquoise: 4251856,\n    violet: 15631086,\n    wheat: 16113331,\n    white: 16777215,\n    whitesmoke: 16119285,\n    yellow: 16776960,\n    yellowgreen: 10145074\n  });\n  d3_rgb_names.forEach(function(key, value) {\n    d3_rgb_names.set(key, d3_rgbNumber(value));\n  });\n  function d3_functor(v) {\n    return typeof v === \"function\" ? v : function() {\n      return v;\n    };\n  }\n  d3.functor = d3_functor;\n  d3.xhr = d3_xhrType(d3_identity);\n  function d3_xhrType(response) {\n    return function(url, mimeType, callback) {\n      if (arguments.length === 2 && typeof mimeType === \"function\") callback = mimeType, \n      mimeType = null;\n      return d3_xhr(url, mimeType, response, callback);\n    };\n  }\n  function d3_xhr(url, mimeType, response, callback) {\n    var xhr = {}, dispatch = d3.dispatch(\"beforesend\", \"progress\", \"load\", \"error\"), headers = {}, request = new XMLHttpRequest(), responseType = null;\n    if (this.XDomainRequest && !(\"withCredentials\" in request) && /^(http(s)?:)?\\/\\//.test(url)) request = new XDomainRequest();\n    \"onload\" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {\n      request.readyState > 3 && respond();\n    };\n    function respond() {\n      var status = request.status, result;\n      if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) {\n        try {\n          result = response.call(xhr, request);\n        } catch (e) {\n          dispatch.error.call(xhr, e);\n          return;\n        }\n        dispatch.load.call(xhr, result);\n      } else {\n        dispatch.error.call(xhr, request);\n      }\n    }\n    request.onprogress = function(event) {\n      var o = d3.event;\n      d3.event = event;\n      try {\n        dispatch.progress.call(xhr, request);\n      } finally {\n        d3.event = o;\n      }\n    };\n    xhr.header = function(name, value) {\n      name = (name + \"\").toLowerCase();\n      if (arguments.length < 2) return headers[name];\n      if (value == null) delete headers[name]; else headers[name] = value + \"\";\n      return xhr;\n    };\n    xhr.mimeType = function(value) {\n      if (!arguments.length) return mimeType;\n      mimeType = value == null ? null : value + \"\";\n      return xhr;\n    };\n    xhr.responseType = function(value) {\n      if (!arguments.length) return responseType;\n      responseType = value;\n      return xhr;\n    };\n    xhr.response = function(value) {\n      response = value;\n      return xhr;\n    };\n    [ \"get\", \"post\" ].forEach(function(method) {\n      xhr[method] = function() {\n        return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));\n      };\n    });\n    xhr.send = function(method, data, callback) {\n      if (arguments.length === 2 && typeof data === \"function\") callback = data, data = null;\n      request.open(method, url, true);\n      if (mimeType != null && !(\"accept\" in headers)) headers[\"accept\"] = mimeType + \",*/*\";\n      if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);\n      if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);\n      if (responseType != null) request.responseType = responseType;\n      if (callback != null) xhr.on(\"error\", callback).on(\"load\", function(request) {\n        callback(null, request);\n      });\n      dispatch.beforesend.call(xhr, request);\n      request.send(data == null ? null : data);\n      return xhr;\n    };\n    xhr.abort = function() {\n      request.abort();\n      return xhr;\n    };\n    d3.rebind(xhr, dispatch, \"on\");\n    return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));\n  }\n  function d3_xhr_fixCallback(callback) {\n    return callback.length === 1 ? function(error, request) {\n      callback(error == null ? request : null);\n    } : callback;\n  }\n  function d3_xhrHasResponse(request) {\n    var type = request.responseType;\n    return type && type !== \"text\" ? request.response : request.responseText;\n  }\n  d3.dsv = function(delimiter, mimeType) {\n    var reFormat = new RegExp('[\"' + delimiter + \"\\n]\"), delimiterCode = delimiter.charCodeAt(0);\n    function dsv(url, row, callback) {\n      if (arguments.length < 3) callback = row, row = null;\n      var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback);\n      xhr.row = function(_) {\n        return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row;\n      };\n      return xhr;\n    }\n    function response(request) {\n      return dsv.parse(request.responseText);\n    }\n    function typedResponse(f) {\n      return function(request) {\n        return dsv.parse(request.responseText, f);\n      };\n    }\n    dsv.parse = function(text, f) {\n      var o;\n      return dsv.parseRows(text, function(row, i) {\n        if (o) return o(row, i - 1);\n        var a = new Function(\"d\", \"return {\" + row.map(function(name, i) {\n          return JSON.stringify(name) + \": d[\" + i + \"]\";\n        }).join(\",\") + \"}\");\n        o = f ? function(row, i) {\n          return f(a(row), i);\n        } : a;\n      });\n    };\n    dsv.parseRows = function(text, f) {\n      var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;\n      function token() {\n        if (I >= N) return EOF;\n        if (eol) return eol = false, EOL;\n        var j = I;\n        if (text.charCodeAt(j) === 34) {\n          var i = j;\n          while (i++ < N) {\n            if (text.charCodeAt(i) === 34) {\n              if (text.charCodeAt(i + 1) !== 34) break;\n              ++i;\n            }\n          }\n          I = i + 2;\n          var c = text.charCodeAt(i + 1);\n          if (c === 13) {\n            eol = true;\n            if (text.charCodeAt(i + 2) === 10) ++I;\n          } else if (c === 10) {\n            eol = true;\n          }\n          return text.slice(j + 1, i).replace(/\"\"/g, '\"');\n        }\n        while (I < N) {\n          var c = text.charCodeAt(I++), k = 1;\n          if (c === 10) eol = true; else if (c === 13) {\n            eol = true;\n            if (text.charCodeAt(I) === 10) ++I, ++k;\n          } else if (c !== delimiterCode) continue;\n          return text.slice(j, I - k);\n        }\n        return text.slice(j);\n      }\n      while ((t = token()) !== EOF) {\n        var a = [];\n        while (t !== EOL && t !== EOF) {\n          a.push(t);\n          t = token();\n        }\n        if (f && (a = f(a, n++)) == null) continue;\n        rows.push(a);\n      }\n      return rows;\n    };\n    dsv.format = function(rows) {\n      if (Array.isArray(rows[0])) return dsv.formatRows(rows);\n      var fieldSet = new d3_Set(), fields = [];\n      rows.forEach(function(row) {\n        for (var field in row) {\n          if (!fieldSet.has(field)) {\n            fields.push(fieldSet.add(field));\n          }\n        }\n      });\n      return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) {\n        return fields.map(function(field) {\n          return formatValue(row[field]);\n        }).join(delimiter);\n      })).join(\"\\n\");\n    };\n    dsv.formatRows = function(rows) {\n      return rows.map(formatRow).join(\"\\n\");\n    };\n    function formatRow(row) {\n      return row.map(formatValue).join(delimiter);\n    }\n    function formatValue(text) {\n      return reFormat.test(text) ? '\"' + text.replace(/\\\"/g, '\"\"') + '\"' : text;\n    }\n    return dsv;\n  };\n  d3.csv = d3.dsv(\",\", \"text/csv\");\n  d3.tsv = d3.dsv(\"\t\", \"text/tab-separated-values\");\n  var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, \"requestAnimationFrame\")] || function(callback) {\n    setTimeout(callback, 17);\n  };\n  d3.timer = function() {\n    d3_timer.apply(this, arguments);\n  };\n  function d3_timer(callback, delay, then) {\n    var n = arguments.length;\n    if (n < 2) delay = 0;\n    if (n < 3) then = Date.now();\n    var time = then + delay, timer = {\n      c: callback,\n      t: time,\n      n: null\n    };\n    if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;\n    d3_timer_queueTail = timer;\n    if (!d3_timer_interval) {\n      d3_timer_timeout = clearTimeout(d3_timer_timeout);\n      d3_timer_interval = 1;\n      d3_timer_frame(d3_timer_step);\n    }\n    return timer;\n  }\n  function d3_timer_step() {\n    var now = d3_timer_mark(), delay = d3_timer_sweep() - now;\n    if (delay > 24) {\n      if (isFinite(delay)) {\n        clearTimeout(d3_timer_timeout);\n        d3_timer_timeout = setTimeout(d3_timer_step, delay);\n      }\n      d3_timer_interval = 0;\n    } else {\n      d3_timer_interval = 1;\n      d3_timer_frame(d3_timer_step);\n    }\n  }\n  d3.timer.flush = function() {\n    d3_timer_mark();\n    d3_timer_sweep();\n  };\n  function d3_timer_mark() {\n    var now = Date.now(), timer = d3_timer_queueHead;\n    while (timer) {\n      if (now >= timer.t && timer.c(now - timer.t)) timer.c = null;\n      timer = timer.n;\n    }\n    return now;\n  }\n  function d3_timer_sweep() {\n    var t0, t1 = d3_timer_queueHead, time = Infinity;\n    while (t1) {\n      if (t1.c) {\n        if (t1.t < time) time = t1.t;\n        t1 = (t0 = t1).n;\n      } else {\n        t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;\n      }\n    }\n    d3_timer_queueTail = t0;\n    return time;\n  }\n  function d3_format_precision(x, p) {\n    return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);\n  }\n  d3.round = function(x, n) {\n    return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);\n  };\n  var d3_formatPrefixes = [ \"y\", \"z\", \"a\", \"f\", \"p\", \"n\", \"µ\", \"m\", \"\", \"k\", \"M\", \"G\", \"T\", \"P\", \"E\", \"Z\", \"Y\" ].map(d3_formatPrefix);\n  d3.formatPrefix = function(value, precision) {\n    var i = 0;\n    if (value = +value) {\n      if (value < 0) value *= -1;\n      if (precision) value = d3.round(value, d3_format_precision(value, precision));\n      i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);\n      i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));\n    }\n    return d3_formatPrefixes[8 + i / 3];\n  };\n  function d3_formatPrefix(d, i) {\n    var k = Math.pow(10, abs(8 - i) * 3);\n    return {\n      scale: i > 8 ? function(d) {\n        return d / k;\n      } : function(d) {\n        return d * k;\n      },\n      symbol: d\n    };\n  }\n  function d3_locale_numberFormat(locale) {\n    var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) {\n      var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0;\n      while (i > 0 && g > 0) {\n        if (length + g + 1 > width) g = Math.max(1, width - length);\n        t.push(value.substring(i -= g, i + g));\n        if ((length += g + 1) > width) break;\n        g = locale_grouping[j = (j + 1) % locale_grouping.length];\n      }\n      return t.reverse().join(locale_thousands);\n    } : d3_identity;\n    return function(specifier) {\n      var match = d3_format_re.exec(specifier), fill = match[1] || \" \", align = match[2] || \">\", sign = match[3] || \"-\", symbol = match[4] || \"\", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = \"\", suffix = \"\", integer = false, exponent = true;\n      if (precision) precision = +precision.substring(1);\n      if (zfill || fill === \"0\" && align === \"=\") {\n        zfill = fill = \"0\";\n        align = \"=\";\n      }\n      switch (type) {\n       case \"n\":\n        comma = true;\n        type = \"g\";\n        break;\n\n       case \"%\":\n        scale = 100;\n        suffix = \"%\";\n        type = \"f\";\n        break;\n\n       case \"p\":\n        scale = 100;\n        suffix = \"%\";\n        type = \"r\";\n        break;\n\n       case \"b\":\n       case \"o\":\n       case \"x\":\n       case \"X\":\n        if (symbol === \"#\") prefix = \"0\" + type.toLowerCase();\n\n       case \"c\":\n        exponent = false;\n\n       case \"d\":\n        integer = true;\n        precision = 0;\n        break;\n\n       case \"s\":\n        scale = -1;\n        type = \"r\";\n        break;\n      }\n      if (symbol === \"$\") prefix = locale_currency[0], suffix = locale_currency[1];\n      if (type == \"r\" && !precision) type = \"g\";\n      if (precision != null) {\n        if (type == \"g\") precision = Math.max(1, Math.min(21, precision)); else if (type == \"e\" || type == \"f\") precision = Math.max(0, Math.min(20, precision));\n      }\n      type = d3_format_types.get(type) || d3_format_typeDefault;\n      var zcomma = zfill && comma;\n      return function(value) {\n        var fullSuffix = suffix;\n        if (integer && value % 1) return \"\";\n        var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, \"-\") : sign === \"-\" ? \"\" : sign;\n        if (scale < 0) {\n          var unit = d3.formatPrefix(value, precision);\n          value = unit.scale(value);\n          fullSuffix = unit.symbol + suffix;\n        } else {\n          value *= scale;\n        }\n        value = type(value, precision);\n        var i = value.lastIndexOf(\".\"), before, after;\n        if (i < 0) {\n          var j = exponent ? value.lastIndexOf(\"e\") : -1;\n          if (j < 0) before = value, after = \"\"; else before = value.substring(0, j), after = value.substring(j);\n        } else {\n          before = value.substring(0, i);\n          after = locale_decimal + value.substring(i + 1);\n        }\n        if (!zfill && comma) before = formatGroup(before, Infinity);\n        var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : \"\";\n        if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity);\n        negative += prefix;\n        value = before + after;\n        return (align === \"<\" ? negative + value + padding : align === \">\" ? padding + negative + value : align === \"^\" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix;\n      };\n    };\n  }\n  var d3_format_re = /(?:([^{])?([<>=^]))?([+\\- ])?([$#])?(0)?(\\d+)?(,)?(\\.-?\\d+)?([a-z%])?/i;\n  var d3_format_types = d3.map({\n    b: function(x) {\n      return x.toString(2);\n    },\n    c: function(x) {\n      return String.fromCharCode(x);\n    },\n    o: function(x) {\n      return x.toString(8);\n    },\n    x: function(x) {\n      return x.toString(16);\n    },\n    X: function(x) {\n      return x.toString(16).toUpperCase();\n    },\n    g: function(x, p) {\n      return x.toPrecision(p);\n    },\n    e: function(x, p) {\n      return x.toExponential(p);\n    },\n    f: function(x, p) {\n      return x.toFixed(p);\n    },\n    r: function(x, p) {\n      return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p))));\n    }\n  });\n  function d3_format_typeDefault(x) {\n    return x + \"\";\n  }\n  var d3_time = d3.time = {}, d3_date = Date;\n  function d3_date_utc() {\n    this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);\n  }\n  d3_date_utc.prototype = {\n    getDate: function() {\n      return this._.getUTCDate();\n    },\n    getDay: function() {\n      return this._.getUTCDay();\n    },\n    getFullYear: function() {\n      return this._.getUTCFullYear();\n    },\n    getHours: function() {\n      return this._.getUTCHours();\n    },\n    getMilliseconds: function() {\n      return this._.getUTCMilliseconds();\n    },\n    getMinutes: function() {\n      return this._.getUTCMinutes();\n    },\n    getMonth: function() {\n      return this._.getUTCMonth();\n    },\n    getSeconds: function() {\n      return this._.getUTCSeconds();\n    },\n    getTime: function() {\n      return this._.getTime();\n    },\n    getTimezoneOffset: function() {\n      return 0;\n    },\n    valueOf: function() {\n      return this._.valueOf();\n    },\n    setDate: function() {\n      d3_time_prototype.setUTCDate.apply(this._, arguments);\n    },\n    setDay: function() {\n      d3_time_prototype.setUTCDay.apply(this._, arguments);\n    },\n    setFullYear: function() {\n      d3_time_prototype.setUTCFullYear.apply(this._, arguments);\n    },\n    setHours: function() {\n      d3_time_prototype.setUTCHours.apply(this._, arguments);\n    },\n    setMilliseconds: function() {\n      d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);\n    },\n    setMinutes: function() {\n      d3_time_prototype.setUTCMinutes.apply(this._, arguments);\n    },\n    setMonth: function() {\n      d3_time_prototype.setUTCMonth.apply(this._, arguments);\n    },\n    setSeconds: function() {\n      d3_time_prototype.setUTCSeconds.apply(this._, arguments);\n    },\n    setTime: function() {\n      d3_time_prototype.setTime.apply(this._, arguments);\n    }\n  };\n  var d3_time_prototype = Date.prototype;\n  function d3_time_interval(local, step, number) {\n    function round(date) {\n      var d0 = local(date), d1 = offset(d0, 1);\n      return date - d0 < d1 - date ? d0 : d1;\n    }\n    function ceil(date) {\n      step(date = local(new d3_date(date - 1)), 1);\n      return date;\n    }\n    function offset(date, k) {\n      step(date = new d3_date(+date), k);\n      return date;\n    }\n    function range(t0, t1, dt) {\n      var time = ceil(t0), times = [];\n      if (dt > 1) {\n        while (time < t1) {\n          if (!(number(time) % dt)) times.push(new Date(+time));\n          step(time, 1);\n        }\n      } else {\n        while (time < t1) times.push(new Date(+time)), step(time, 1);\n      }\n      return times;\n    }\n    function range_utc(t0, t1, dt) {\n      try {\n        d3_date = d3_date_utc;\n        var utc = new d3_date_utc();\n        utc._ = t0;\n        return range(utc, t1, dt);\n      } finally {\n        d3_date = Date;\n      }\n    }\n    local.floor = local;\n    local.round = round;\n    local.ceil = ceil;\n    local.offset = offset;\n    local.range = range;\n    var utc = local.utc = d3_time_interval_utc(local);\n    utc.floor = utc;\n    utc.round = d3_time_interval_utc(round);\n    utc.ceil = d3_time_interval_utc(ceil);\n    utc.offset = d3_time_interval_utc(offset);\n    utc.range = range_utc;\n    return local;\n  }\n  function d3_time_interval_utc(method) {\n    return function(date, k) {\n      try {\n        d3_date = d3_date_utc;\n        var utc = new d3_date_utc();\n        utc._ = date;\n        return method(utc, k)._;\n      } finally {\n        d3_date = Date;\n      }\n    };\n  }\n  d3_time.year = d3_time_interval(function(date) {\n    date = d3_time.day(date);\n    date.setMonth(0, 1);\n    return date;\n  }, function(date, offset) {\n    date.setFullYear(date.getFullYear() + offset);\n  }, function(date) {\n    return date.getFullYear();\n  });\n  d3_time.years = d3_time.year.range;\n  d3_time.years.utc = d3_time.year.utc.range;\n  d3_time.day = d3_time_interval(function(date) {\n    var day = new d3_date(2e3, 0);\n    day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n    return day;\n  }, function(date, offset) {\n    date.setDate(date.getDate() + offset);\n  }, function(date) {\n    return date.getDate() - 1;\n  });\n  d3_time.days = d3_time.day.range;\n  d3_time.days.utc = d3_time.day.utc.range;\n  d3_time.dayOfYear = function(date) {\n    var year = d3_time.year(date);\n    return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);\n  };\n  [ \"sunday\", \"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\" ].forEach(function(day, i) {\n    i = 7 - i;\n    var interval = d3_time[day] = d3_time_interval(function(date) {\n      (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);\n      return date;\n    }, function(date, offset) {\n      date.setDate(date.getDate() + Math.floor(offset) * 7);\n    }, function(date) {\n      var day = d3_time.year(date).getDay();\n      return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);\n    });\n    d3_time[day + \"s\"] = interval.range;\n    d3_time[day + \"s\"].utc = interval.utc.range;\n    d3_time[day + \"OfYear\"] = function(date) {\n      var day = d3_time.year(date).getDay();\n      return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7);\n    };\n  });\n  d3_time.week = d3_time.sunday;\n  d3_time.weeks = d3_time.sunday.range;\n  d3_time.weeks.utc = d3_time.sunday.utc.range;\n  d3_time.weekOfYear = d3_time.sundayOfYear;\n  function d3_locale_timeFormat(locale) {\n    var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths;\n    function d3_time_format(template) {\n      var n = template.length;\n      function format(date) {\n        var string = [], i = -1, j = 0, c, p, f;\n        while (++i < n) {\n          if (template.charCodeAt(i) === 37) {\n            string.push(template.slice(j, i));\n            if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);\n            if (f = d3_time_formats[c]) c = f(date, p == null ? c === \"e\" ? \" \" : \"0\" : p);\n            string.push(c);\n            j = i + 1;\n          }\n        }\n        string.push(template.slice(j, i));\n        return string.join(\"\");\n      }\n      format.parse = function(string) {\n        var d = {\n          y: 1900,\n          m: 0,\n          d: 1,\n          H: 0,\n          M: 0,\n          S: 0,\n          L: 0,\n          Z: null\n        }, i = d3_time_parse(d, template, string, 0);\n        if (i != string.length) return null;\n        if (\"p\" in d) d.H = d.H % 12 + d.p * 12;\n        var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();\n        if (\"j\" in d) date.setFullYear(d.y, 0, d.j); else if (\"W\" in d || \"U\" in d) {\n          if (!(\"w\" in d)) d.w = \"W\" in d ? 1 : 0;\n          date.setFullYear(d.y, 0, 1);\n          date.setFullYear(d.y, 0, \"W\" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7);\n        } else date.setFullYear(d.y, d.m, d.d);\n        date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L);\n        return localZ ? date._ : date;\n      };\n      format.toString = function() {\n        return template;\n      };\n      return format;\n    }\n    function d3_time_parse(date, template, string, j) {\n      var c, p, t, i = 0, n = template.length, m = string.length;\n      while (i < n) {\n        if (j >= m) return -1;\n        c = template.charCodeAt(i++);\n        if (c === 37) {\n          t = template.charAt(i++);\n          p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t];\n          if (!p || (j = p(date, string, j)) < 0) return -1;\n        } else if (c != string.charCodeAt(j++)) {\n          return -1;\n        }\n      }\n      return j;\n    }\n    d3_time_format.utc = function(template) {\n      var local = d3_time_format(template);\n      function format(date) {\n        try {\n          d3_date = d3_date_utc;\n          var utc = new d3_date();\n          utc._ = date;\n          return local(utc);\n        } finally {\n          d3_date = Date;\n        }\n      }\n      format.parse = function(string) {\n        try {\n          d3_date = d3_date_utc;\n          var date = local.parse(string);\n          return date && date._;\n        } finally {\n          d3_date = Date;\n        }\n      };\n      format.toString = local.toString;\n      return format;\n    };\n    d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti;\n    var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths);\n    locale_periods.forEach(function(p, i) {\n      d3_time_periodLookup.set(p.toLowerCase(), i);\n    });\n    var d3_time_formats = {\n      a: function(d) {\n        return locale_shortDays[d.getDay()];\n      },\n      A: function(d) {\n        return locale_days[d.getDay()];\n      },\n      b: function(d) {\n        return locale_shortMonths[d.getMonth()];\n      },\n      B: function(d) {\n        return locale_months[d.getMonth()];\n      },\n      c: d3_time_format(locale_dateTime),\n      d: function(d, p) {\n        return d3_time_formatPad(d.getDate(), p, 2);\n      },\n      e: function(d, p) {\n        return d3_time_formatPad(d.getDate(), p, 2);\n      },\n      H: function(d, p) {\n        return d3_time_formatPad(d.getHours(), p, 2);\n      },\n      I: function(d, p) {\n        return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);\n      },\n      j: function(d, p) {\n        return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3);\n      },\n      L: function(d, p) {\n        return d3_time_formatPad(d.getMilliseconds(), p, 3);\n      },\n      m: function(d, p) {\n        return d3_time_formatPad(d.getMonth() + 1, p, 2);\n      },\n      M: function(d, p) {\n        return d3_time_formatPad(d.getMinutes(), p, 2);\n      },\n      p: function(d) {\n        return locale_periods[+(d.getHours() >= 12)];\n      },\n      S: function(d, p) {\n        return d3_time_formatPad(d.getSeconds(), p, 2);\n      },\n      U: function(d, p) {\n        return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2);\n      },\n      w: function(d) {\n        return d.getDay();\n      },\n      W: function(d, p) {\n        return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2);\n      },\n      x: d3_time_format(locale_date),\n      X: d3_time_format(locale_time),\n      y: function(d, p) {\n        return d3_time_formatPad(d.getFullYear() % 100, p, 2);\n      },\n      Y: function(d, p) {\n        return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);\n      },\n      Z: d3_time_zone,\n      \"%\": function() {\n        return \"%\";\n      }\n    };\n    var d3_time_parsers = {\n      a: d3_time_parseWeekdayAbbrev,\n      A: d3_time_parseWeekday,\n      b: d3_time_parseMonthAbbrev,\n      B: d3_time_parseMonth,\n      c: d3_time_parseLocaleFull,\n      d: d3_time_parseDay,\n      e: d3_time_parseDay,\n      H: d3_time_parseHour24,\n      I: d3_time_parseHour24,\n      j: d3_time_parseDayOfYear,\n      L: d3_time_parseMilliseconds,\n      m: d3_time_parseMonthNumber,\n      M: d3_time_parseMinutes,\n      p: d3_time_parseAmPm,\n      S: d3_time_parseSeconds,\n      U: d3_time_parseWeekNumberSunday,\n      w: d3_time_parseWeekdayNumber,\n      W: d3_time_parseWeekNumberMonday,\n      x: d3_time_parseLocaleDate,\n      X: d3_time_parseLocaleTime,\n      y: d3_time_parseYear,\n      Y: d3_time_parseFullYear,\n      Z: d3_time_parseZone,\n      \"%\": d3_time_parseLiteralPercent\n    };\n    function d3_time_parseWeekdayAbbrev(date, string, i) {\n      d3_time_dayAbbrevRe.lastIndex = 0;\n      var n = d3_time_dayAbbrevRe.exec(string.slice(i));\n      return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n    }\n    function d3_time_parseWeekday(date, string, i) {\n      d3_time_dayRe.lastIndex = 0;\n      var n = d3_time_dayRe.exec(string.slice(i));\n      return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n    }\n    function d3_time_parseMonthAbbrev(date, string, i) {\n      d3_time_monthAbbrevRe.lastIndex = 0;\n      var n = d3_time_monthAbbrevRe.exec(string.slice(i));\n      return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n    }\n    function d3_time_parseMonth(date, string, i) {\n      d3_time_monthRe.lastIndex = 0;\n      var n = d3_time_monthRe.exec(string.slice(i));\n      return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1;\n    }\n    function d3_time_parseLocaleFull(date, string, i) {\n      return d3_time_parse(date, d3_time_formats.c.toString(), string, i);\n    }\n    function d3_time_parseLocaleDate(date, string, i) {\n      return d3_time_parse(date, d3_time_formats.x.toString(), string, i);\n    }\n    function d3_time_parseLocaleTime(date, string, i) {\n      return d3_time_parse(date, d3_time_formats.X.toString(), string, i);\n    }\n    function d3_time_parseAmPm(date, string, i) {\n      var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase());\n      return n == null ? -1 : (date.p = n, i);\n    }\n    return d3_time_format;\n  }\n  var d3_time_formatPads = {\n    \"-\": \"\",\n    _: \" \",\n    \"0\": \"0\"\n  }, d3_time_numberRe = /^\\s*\\d+/, d3_time_percentRe = /^%/;\n  function d3_time_formatPad(value, fill, width) {\n    var sign = value < 0 ? \"-\" : \"\", string = (sign ? -value : value) + \"\", length = string.length;\n    return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string);\n  }\n  function d3_time_formatRe(names) {\n    return new RegExp(\"^(?:\" + names.map(d3.requote).join(\"|\") + \")\", \"i\");\n  }\n  function d3_time_formatLookup(names) {\n    var map = new d3_Map(), i = -1, n = names.length;\n    while (++i < n) map.set(names[i].toLowerCase(), i);\n    return map;\n  }\n  function d3_time_parseWeekdayNumber(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 1));\n    return n ? (date.w = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseWeekNumberSunday(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i));\n    return n ? (date.U = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseWeekNumberMonday(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i));\n    return n ? (date.W = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseFullYear(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 4));\n    return n ? (date.y = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseYear(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1;\n  }\n  function d3_time_parseZone(date, string, i) {\n    return /^[+-]\\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, \n    i + 5) : -1;\n  }\n  function d3_time_expandYear(d) {\n    return d + (d > 68 ? 1900 : 2e3);\n  }\n  function d3_time_parseMonthNumber(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.m = n[0] - 1, i + n[0].length) : -1;\n  }\n  function d3_time_parseDay(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.d = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseDayOfYear(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n    return n ? (date.j = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseHour24(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.H = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseMinutes(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.M = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseSeconds(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 2));\n    return n ? (date.S = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_parseMilliseconds(date, string, i) {\n    d3_time_numberRe.lastIndex = 0;\n    var n = d3_time_numberRe.exec(string.slice(i, i + 3));\n    return n ? (date.L = +n[0], i + n[0].length) : -1;\n  }\n  function d3_time_zone(d) {\n    var z = d.getTimezoneOffset(), zs = z > 0 ? \"-\" : \"+\", zh = abs(z) / 60 | 0, zm = abs(z) % 60;\n    return zs + d3_time_formatPad(zh, \"0\", 2) + d3_time_formatPad(zm, \"0\", 2);\n  }\n  function d3_time_parseLiteralPercent(date, string, i) {\n    d3_time_percentRe.lastIndex = 0;\n    var n = d3_time_percentRe.exec(string.slice(i, i + 1));\n    return n ? i + n[0].length : -1;\n  }\n  function d3_time_formatMulti(formats) {\n    var n = formats.length, i = -1;\n    while (++i < n) formats[i][0] = this(formats[i][0]);\n    return function(date) {\n      var i = 0, f = formats[i];\n      while (!f[1](date)) f = formats[++i];\n      return f[0](date);\n    };\n  }\n  d3.locale = function(locale) {\n    return {\n      numberFormat: d3_locale_numberFormat(locale),\n      timeFormat: d3_locale_timeFormat(locale)\n    };\n  };\n  var d3_locale_enUS = d3.locale({\n    decimal: \".\",\n    thousands: \",\",\n    grouping: [ 3 ],\n    currency: [ \"$\", \"\" ],\n    dateTime: \"%a %b %e %X %Y\",\n    date: \"%m/%d/%Y\",\n    time: \"%H:%M:%S\",\n    periods: [ \"AM\", \"PM\" ],\n    days: [ \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\" ],\n    shortDays: [ \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" ],\n    months: [ \"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\" ],\n    shortMonths: [ \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" ]\n  });\n  d3.format = d3_locale_enUS.numberFormat;\n  d3.geo = {};\n  function d3_adder() {}\n  d3_adder.prototype = {\n    s: 0,\n    t: 0,\n    add: function(y) {\n      d3_adderSum(y, this.t, d3_adderTemp);\n      d3_adderSum(d3_adderTemp.s, this.s, this);\n      if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t;\n    },\n    reset: function() {\n      this.s = this.t = 0;\n    },\n    valueOf: function() {\n      return this.s;\n    }\n  };\n  var d3_adderTemp = new d3_adder();\n  function d3_adderSum(a, b, o) {\n    var x = o.s = a + b, bv = x - a, av = x - bv;\n    o.t = a - av + (b - bv);\n  }\n  d3.geo.stream = function(object, listener) {\n    if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) {\n      d3_geo_streamObjectType[object.type](object, listener);\n    } else {\n      d3_geo_streamGeometry(object, listener);\n    }\n  };\n  function d3_geo_streamGeometry(geometry, listener) {\n    if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {\n      d3_geo_streamGeometryType[geometry.type](geometry, listener);\n    }\n  }\n  var d3_geo_streamObjectType = {\n    Feature: function(feature, listener) {\n      d3_geo_streamGeometry(feature.geometry, listener);\n    },\n    FeatureCollection: function(object, listener) {\n      var features = object.features, i = -1, n = features.length;\n      while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);\n    }\n  };\n  var d3_geo_streamGeometryType = {\n    Sphere: function(object, listener) {\n      listener.sphere();\n    },\n    Point: function(object, listener) {\n      object = object.coordinates;\n      listener.point(object[0], object[1], object[2]);\n    },\n    MultiPoint: function(object, listener) {\n      var coordinates = object.coordinates, i = -1, n = coordinates.length;\n      while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]);\n    },\n    LineString: function(object, listener) {\n      d3_geo_streamLine(object.coordinates, listener, 0);\n    },\n    MultiLineString: function(object, listener) {\n      var coordinates = object.coordinates, i = -1, n = coordinates.length;\n      while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);\n    },\n    Polygon: function(object, listener) {\n      d3_geo_streamPolygon(object.coordinates, listener);\n    },\n    MultiPolygon: function(object, listener) {\n      var coordinates = object.coordinates, i = -1, n = coordinates.length;\n      while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);\n    },\n    GeometryCollection: function(object, listener) {\n      var geometries = object.geometries, i = -1, n = geometries.length;\n      while (++i < n) d3_geo_streamGeometry(geometries[i], listener);\n    }\n  };\n  function d3_geo_streamLine(coordinates, listener, closed) {\n    var i = -1, n = coordinates.length - closed, coordinate;\n    listener.lineStart();\n    while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]);\n    listener.lineEnd();\n  }\n  function d3_geo_streamPolygon(coordinates, listener) {\n    var i = -1, n = coordinates.length;\n    listener.polygonStart();\n    while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);\n    listener.polygonEnd();\n  }\n  d3.geo.area = function(object) {\n    d3_geo_areaSum = 0;\n    d3.geo.stream(object, d3_geo_area);\n    return d3_geo_areaSum;\n  };\n  var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder();\n  var d3_geo_area = {\n    sphere: function() {\n      d3_geo_areaSum += 4 * π;\n    },\n    point: d3_noop,\n    lineStart: d3_noop,\n    lineEnd: d3_noop,\n    polygonStart: function() {\n      d3_geo_areaRingSum.reset();\n      d3_geo_area.lineStart = d3_geo_areaRingStart;\n    },\n    polygonEnd: function() {\n      var area = 2 * d3_geo_areaRingSum;\n      d3_geo_areaSum += area < 0 ? 4 * π + area : area;\n      d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;\n    }\n  };\n  function d3_geo_areaRingStart() {\n    var λ00, φ00, λ0, cosφ0, sinφ0;\n    d3_geo_area.point = function(λ, φ) {\n      d3_geo_area.point = nextPoint;\n      λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), \n      sinφ0 = Math.sin(φ);\n    };\n    function nextPoint(λ, φ) {\n      λ *= d3_radians;\n      φ = φ * d3_radians / 2 + π / 4;\n      var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ);\n      d3_geo_areaRingSum.add(Math.atan2(v, u));\n      λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ;\n    }\n    d3_geo_area.lineEnd = function() {\n      nextPoint(λ00, φ00);\n    };\n  }\n  function d3_geo_cartesian(spherical) {\n    var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);\n    return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];\n  }\n  function d3_geo_cartesianDot(a, b) {\n    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n  }\n  function d3_geo_cartesianCross(a, b) {\n    return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ];\n  }\n  function d3_geo_cartesianAdd(a, b) {\n    a[0] += b[0];\n    a[1] += b[1];\n    a[2] += b[2];\n  }\n  function d3_geo_cartesianScale(vector, k) {\n    return [ vector[0] * k, vector[1] * k, vector[2] * k ];\n  }\n  function d3_geo_cartesianNormalize(d) {\n    var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);\n    d[0] /= l;\n    d[1] /= l;\n    d[2] /= l;\n  }\n  function d3_geo_spherical(cartesian) {\n    return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ];\n  }\n  function d3_geo_sphericalEqual(a, b) {\n    return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε;\n  }\n  d3.geo.bounds = function() {\n    var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range;\n    var bound = {\n      point: point,\n      lineStart: lineStart,\n      lineEnd: lineEnd,\n      polygonStart: function() {\n        bound.point = ringPoint;\n        bound.lineStart = ringStart;\n        bound.lineEnd = ringEnd;\n        dλSum = 0;\n        d3_geo_area.polygonStart();\n      },\n      polygonEnd: function() {\n        d3_geo_area.polygonEnd();\n        bound.point = point;\n        bound.lineStart = lineStart;\n        bound.lineEnd = lineEnd;\n        if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90;\n        range[0] = λ0, range[1] = λ1;\n      }\n    };\n    function point(λ, φ) {\n      ranges.push(range = [ λ0 = λ, λ1 = λ ]);\n      if (φ < φ0) φ0 = φ;\n      if (φ > φ1) φ1 = φ;\n    }\n    function linePoint(λ, φ) {\n      var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]);\n      if (p0) {\n        var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal);\n        d3_geo_cartesianNormalize(inflection);\n        inflection = d3_geo_spherical(inflection);\n        var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180;\n        if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) {\n          var φi = inflection[1] * d3_degrees;\n          if (φi > φ1) φ1 = φi;\n        } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) {\n          var φi = -inflection[1] * d3_degrees;\n          if (φi < φ0) φ0 = φi;\n        } else {\n          if (φ < φ0) φ0 = φ;\n          if (φ > φ1) φ1 = φ;\n        }\n        if (antimeridian) {\n          if (λ < λ_) {\n            if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;\n          } else {\n            if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;\n          }\n        } else {\n          if (λ1 >= λ0) {\n            if (λ < λ0) λ0 = λ;\n            if (λ > λ1) λ1 = λ;\n          } else {\n            if (λ > λ_) {\n              if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ;\n            } else {\n              if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ;\n            }\n          }\n        }\n      } else {\n        point(λ, φ);\n      }\n      p0 = p, λ_ = λ;\n    }\n    function lineStart() {\n      bound.point = linePoint;\n    }\n    function lineEnd() {\n      range[0] = λ0, range[1] = λ1;\n      bound.point = point;\n      p0 = null;\n    }\n    function ringPoint(λ, φ) {\n      if (p0) {\n        var dλ = λ - λ_;\n        dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ;\n      } else λ__ = λ, φ__ = φ;\n      d3_geo_area.point(λ, φ);\n      linePoint(λ, φ);\n    }\n    function ringStart() {\n      d3_geo_area.lineStart();\n    }\n    function ringEnd() {\n      ringPoint(λ__, φ__);\n      d3_geo_area.lineEnd();\n      if (abs(dλSum) > ε) λ0 = -(λ1 = 180);\n      range[0] = λ0, range[1] = λ1;\n      p0 = null;\n    }\n    function angle(λ0, λ1) {\n      return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1;\n    }\n    function compareRanges(a, b) {\n      return a[0] - b[0];\n    }\n    function withinRange(x, range) {\n      return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x;\n    }\n    return function(feature) {\n      φ1 = λ1 = -(λ0 = φ0 = Infinity);\n      ranges = [];\n      d3.geo.stream(feature, bound);\n      var n = ranges.length;\n      if (n) {\n        ranges.sort(compareRanges);\n        for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) {\n          b = ranges[i];\n          if (withinRange(b[0], a) || withinRange(b[1], a)) {\n            if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1];\n            if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0];\n          } else {\n            merged.push(a = b);\n          }\n        }\n        var best = -Infinity, dλ;\n        for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) {\n          b = merged[i];\n          if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1];\n        }\n      }\n      ranges = range = null;\n      return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ];\n    };\n  }();\n  d3.geo.centroid = function(object) {\n    d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n    d3.geo.stream(object, d3_geo_centroid);\n    var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z;\n    if (m < ε2) {\n      x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1;\n      if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0;\n      m = x * x + y * y + z * z;\n      if (m < ε2) return [ NaN, NaN ];\n    }\n    return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ];\n  };\n  var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2;\n  var d3_geo_centroid = {\n    sphere: d3_noop,\n    point: d3_geo_centroidPoint,\n    lineStart: d3_geo_centroidLineStart,\n    lineEnd: d3_geo_centroidLineEnd,\n    polygonStart: function() {\n      d3_geo_centroid.lineStart = d3_geo_centroidRingStart;\n    },\n    polygonEnd: function() {\n      d3_geo_centroid.lineStart = d3_geo_centroidLineStart;\n    }\n  };\n  function d3_geo_centroidPoint(λ, φ) {\n    λ *= d3_radians;\n    var cosφ = Math.cos(φ *= d3_radians);\n    d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ));\n  }\n  function d3_geo_centroidPointXYZ(x, y, z) {\n    ++d3_geo_centroidW0;\n    d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0;\n    d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0;\n    d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0;\n  }\n  function d3_geo_centroidLineStart() {\n    var x0, y0, z0;\n    d3_geo_centroid.point = function(λ, φ) {\n      λ *= d3_radians;\n      var cosφ = Math.cos(φ *= d3_radians);\n      x0 = cosφ * Math.cos(λ);\n      y0 = cosφ * Math.sin(λ);\n      z0 = Math.sin(φ);\n      d3_geo_centroid.point = nextPoint;\n      d3_geo_centroidPointXYZ(x0, y0, z0);\n    };\n    function nextPoint(λ, φ) {\n      λ *= d3_radians;\n      var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z);\n      d3_geo_centroidW1 += w;\n      d3_geo_centroidX1 += w * (x0 + (x0 = x));\n      d3_geo_centroidY1 += w * (y0 + (y0 = y));\n      d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n      d3_geo_centroidPointXYZ(x0, y0, z0);\n    }\n  }\n  function d3_geo_centroidLineEnd() {\n    d3_geo_centroid.point = d3_geo_centroidPoint;\n  }\n  function d3_geo_centroidRingStart() {\n    var λ00, φ00, x0, y0, z0;\n    d3_geo_centroid.point = function(λ, φ) {\n      λ00 = λ, φ00 = φ;\n      d3_geo_centroid.point = nextPoint;\n      λ *= d3_radians;\n      var cosφ = Math.cos(φ *= d3_radians);\n      x0 = cosφ * Math.cos(λ);\n      y0 = cosφ * Math.sin(λ);\n      z0 = Math.sin(φ);\n      d3_geo_centroidPointXYZ(x0, y0, z0);\n    };\n    d3_geo_centroid.lineEnd = function() {\n      nextPoint(λ00, φ00);\n      d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;\n      d3_geo_centroid.point = d3_geo_centroidPoint;\n    };\n    function nextPoint(λ, φ) {\n      λ *= d3_radians;\n      var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u);\n      d3_geo_centroidX2 += v * cx;\n      d3_geo_centroidY2 += v * cy;\n      d3_geo_centroidZ2 += v * cz;\n      d3_geo_centroidW1 += w;\n      d3_geo_centroidX1 += w * (x0 + (x0 = x));\n      d3_geo_centroidY1 += w * (y0 + (y0 = y));\n      d3_geo_centroidZ1 += w * (z0 + (z0 = z));\n      d3_geo_centroidPointXYZ(x0, y0, z0);\n    }\n  }\n  function d3_geo_compose(a, b) {\n    function compose(x, y) {\n      return x = a(x, y), b(x[0], x[1]);\n    }\n    if (a.invert && b.invert) compose.invert = function(x, y) {\n      return x = b.invert(x, y), x && a.invert(x[0], x[1]);\n    };\n    return compose;\n  }\n  function d3_true() {\n    return true;\n  }\n  function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) {\n    var subject = [], clip = [];\n    segments.forEach(function(segment) {\n      if ((n = segment.length - 1) <= 0) return;\n      var n, p0 = segment[0], p1 = segment[n];\n      if (d3_geo_sphericalEqual(p0, p1)) {\n        listener.lineStart();\n        for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]);\n        listener.lineEnd();\n        return;\n      }\n      var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false);\n      a.o = b;\n      subject.push(a);\n      clip.push(b);\n      a = new d3_geo_clipPolygonIntersection(p1, segment, null, false);\n      b = new d3_geo_clipPolygonIntersection(p1, null, a, true);\n      a.o = b;\n      subject.push(a);\n      clip.push(b);\n    });\n    clip.sort(compare);\n    d3_geo_clipPolygonLinkCircular(subject);\n    d3_geo_clipPolygonLinkCircular(clip);\n    if (!subject.length) return;\n    for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) {\n      clip[i].e = entry = !entry;\n    }\n    var start = subject[0], points, point;\n    while (1) {\n      var current = start, isSubject = true;\n      while (current.v) if ((current = current.n) === start) return;\n      points = current.z;\n      listener.lineStart();\n      do {\n        current.v = current.o.v = true;\n        if (current.e) {\n          if (isSubject) {\n            for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]);\n          } else {\n            interpolate(current.x, current.n.x, 1, listener);\n          }\n          current = current.n;\n        } else {\n          if (isSubject) {\n            points = current.p.z;\n            for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]);\n          } else {\n            interpolate(current.x, current.p.x, -1, listener);\n          }\n          current = current.p;\n        }\n        current = current.o;\n        points = current.z;\n        isSubject = !isSubject;\n      } while (!current.v);\n      listener.lineEnd();\n    }\n  }\n  function d3_geo_clipPolygonLinkCircular(array) {\n    if (!(n = array.length)) return;\n    var n, i = 0, a = array[0], b;\n    while (++i < n) {\n      a.n = b = array[i];\n      b.p = a;\n      a = b;\n    }\n    a.n = b = array[0];\n    b.p = a;\n  }\n  function d3_geo_clipPolygonIntersection(point, points, other, entry) {\n    this.x = point;\n    this.z = points;\n    this.o = other;\n    this.e = entry;\n    this.v = false;\n    this.n = this.p = null;\n  }\n  function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) {\n    return function(rotate, listener) {\n      var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]);\n      var clip = {\n        point: point,\n        lineStart: lineStart,\n        lineEnd: lineEnd,\n        polygonStart: function() {\n          clip.point = pointRing;\n          clip.lineStart = ringStart;\n          clip.lineEnd = ringEnd;\n          segments = [];\n          polygon = [];\n        },\n        polygonEnd: function() {\n          clip.point = point;\n          clip.lineStart = lineStart;\n          clip.lineEnd = lineEnd;\n          segments = d3.merge(segments);\n          var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon);\n          if (segments.length) {\n            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n            d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener);\n          } else if (clipStartInside) {\n            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n            listener.lineStart();\n            interpolate(null, null, 1, listener);\n            listener.lineEnd();\n          }\n          if (polygonStarted) listener.polygonEnd(), polygonStarted = false;\n          segments = polygon = null;\n        },\n        sphere: function() {\n          listener.polygonStart();\n          listener.lineStart();\n          interpolate(null, null, 1, listener);\n          listener.lineEnd();\n          listener.polygonEnd();\n        }\n      };\n      function point(λ, φ) {\n        var point = rotate(λ, φ);\n        if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ);\n      }\n      function pointLine(λ, φ) {\n        var point = rotate(λ, φ);\n        line.point(point[0], point[1]);\n      }\n      function lineStart() {\n        clip.point = pointLine;\n        line.lineStart();\n      }\n      function lineEnd() {\n        clip.point = point;\n        line.lineEnd();\n      }\n      var segments;\n      var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring;\n      function pointRing(λ, φ) {\n        ring.push([ λ, φ ]);\n        var point = rotate(λ, φ);\n        ringListener.point(point[0], point[1]);\n      }\n      function ringStart() {\n        ringListener.lineStart();\n        ring = [];\n      }\n      function ringEnd() {\n        pointRing(ring[0][0], ring[0][1]);\n        ringListener.lineEnd();\n        var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;\n        ring.pop();\n        polygon.push(ring);\n        ring = null;\n        if (!n) return;\n        if (clean & 1) {\n          segment = ringSegments[0];\n          var n = segment.length - 1, i = -1, point;\n          if (n > 0) {\n            if (!polygonStarted) listener.polygonStart(), polygonStarted = true;\n            listener.lineStart();\n            while (++i < n) listener.point((point = segment[i])[0], point[1]);\n            listener.lineEnd();\n          }\n          return;\n        }\n        if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));\n        segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));\n      }\n      return clip;\n    };\n  }\n  function d3_geo_clipSegmentLength1(segment) {\n    return segment.length > 1;\n  }\n  function d3_geo_clipBufferListener() {\n    var lines = [], line;\n    return {\n      lineStart: function() {\n        lines.push(line = []);\n      },\n      point: function(λ, φ) {\n        line.push([ λ, φ ]);\n      },\n      lineEnd: d3_noop,\n      buffer: function() {\n        var buffer = lines;\n        lines = [];\n        line = null;\n        return buffer;\n      },\n      rejoin: function() {\n        if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));\n      }\n    };\n  }\n  function d3_geo_clipSort(a, b) {\n    return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]);\n  }\n  var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]);\n  function d3_geo_clipAntimeridianLine(listener) {\n    var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;\n    return {\n      lineStart: function() {\n        listener.lineStart();\n        clean = 1;\n      },\n      point: function(λ1, φ1) {\n        var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0);\n        if (abs(dλ - π) < ε) {\n          listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ);\n          listener.point(sλ0, φ0);\n          listener.lineEnd();\n          listener.lineStart();\n          listener.point(sλ1, φ0);\n          listener.point(λ1, φ0);\n          clean = 0;\n        } else if (sλ0 !== sλ1 && dλ >= π) {\n          if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;\n          if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;\n          φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);\n          listener.point(sλ0, φ0);\n          listener.lineEnd();\n          listener.lineStart();\n          listener.point(sλ1, φ0);\n          clean = 0;\n        }\n        listener.point(λ0 = λ1, φ0 = φ1);\n        sλ0 = sλ1;\n      },\n      lineEnd: function() {\n        listener.lineEnd();\n        λ0 = φ0 = NaN;\n      },\n      clean: function() {\n        return 2 - clean;\n      }\n    };\n  }\n  function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {\n    var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);\n    return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2;\n  }\n  function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {\n    var φ;\n    if (from == null) {\n      φ = direction * halfπ;\n      listener.point(-π, φ);\n      listener.point(0, φ);\n      listener.point(π, φ);\n      listener.point(π, 0);\n      listener.point(π, -φ);\n      listener.point(0, -φ);\n      listener.point(-π, -φ);\n      listener.point(-π, 0);\n      listener.point(-π, φ);\n    } else if (abs(from[0] - to[0]) > ε) {\n      var s = from[0] < to[0] ? π : -π;\n      φ = direction * s / 2;\n      listener.point(-s, φ);\n      listener.point(0, φ);\n      listener.point(s, φ);\n    } else {\n      listener.point(to[0], to[1]);\n    }\n  }\n  function d3_geo_pointInPolygon(point, polygon) {\n    var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0;\n    d3_geo_areaRingSum.reset();\n    for (var i = 0, n = polygon.length; i < n; ++i) {\n      var ring = polygon[i], m = ring.length;\n      if (!m) continue;\n      var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1;\n      while (true) {\n        if (j === m) j = 0;\n        point = ring[j];\n        var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ;\n        d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ)));\n        polarAngle += antimeridian ? dλ + sdλ * τ : dλ;\n        if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) {\n          var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point));\n          d3_geo_cartesianNormalize(arc);\n          var intersection = d3_geo_cartesianCross(meridianNormal, arc);\n          d3_geo_cartesianNormalize(intersection);\n          var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]);\n          if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) {\n            winding += antimeridian ^ dλ >= 0 ? 1 : -1;\n          }\n        }\n        if (!j++) break;\n        λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point;\n      }\n    }\n    return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1;\n  }\n  function d3_geo_clipCircle(radius) {\n    var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians);\n    return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]);\n    function visible(λ, φ) {\n      return Math.cos(λ) * Math.cos(φ) > cr;\n    }\n    function clipLine(listener) {\n      var point0, c0, v0, v00, clean;\n      return {\n        lineStart: function() {\n          v00 = v0 = false;\n          clean = 1;\n        },\n        point: function(λ, φ) {\n          var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0;\n          if (!point0 && (v00 = v0 = v)) listener.lineStart();\n          if (v !== v0) {\n            point2 = intersect(point0, point1);\n            if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {\n              point1[0] += ε;\n              point1[1] += ε;\n              v = visible(point1[0], point1[1]);\n            }\n          }\n          if (v !== v0) {\n            clean = 0;\n            if (v) {\n              listener.lineStart();\n              point2 = intersect(point1, point0);\n              listener.point(point2[0], point2[1]);\n            } else {\n              point2 = intersect(point0, point1);\n              listener.point(point2[0], point2[1]);\n              listener.lineEnd();\n            }\n            point0 = point2;\n          } else if (notHemisphere && point0 && smallRadius ^ v) {\n            var t;\n            if (!(c & c0) && (t = intersect(point1, point0, true))) {\n              clean = 0;\n              if (smallRadius) {\n                listener.lineStart();\n                listener.point(t[0][0], t[0][1]);\n                listener.point(t[1][0], t[1][1]);\n                listener.lineEnd();\n              } else {\n                listener.point(t[1][0], t[1][1]);\n                listener.lineEnd();\n                listener.lineStart();\n                listener.point(t[0][0], t[0][1]);\n              }\n            }\n          }\n          if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) {\n            listener.point(point1[0], point1[1]);\n          }\n          point0 = point1, v0 = v, c0 = c;\n        },\n        lineEnd: function() {\n          if (v0) listener.lineEnd();\n          point0 = null;\n        },\n        clean: function() {\n          return clean | (v00 && v0) << 1;\n        }\n      };\n    }\n    function intersect(a, b, two) {\n      var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b);\n      var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;\n      if (!determinant) return !two && a;\n      var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2);\n      d3_geo_cartesianAdd(A, B);\n      var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1);\n      if (t2 < 0) return;\n      var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu);\n      d3_geo_cartesianAdd(q, A);\n      q = d3_geo_spherical(q);\n      if (!two) return q;\n      var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z;\n      if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z;\n      var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε;\n      if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z;\n      if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) {\n        var q1 = d3_geo_cartesianScale(u, (-w + t) / uu);\n        d3_geo_cartesianAdd(q1, A);\n        return [ q, d3_geo_spherical(q1) ];\n      }\n    }\n    function code(λ, φ) {\n      var r = smallRadius ? radius : π - radius, code = 0;\n      if (λ < -r) code |= 1; else if (λ > r) code |= 2;\n      if (φ < -r) code |= 4; else if (φ > r) code |= 8;\n      return code;\n    }\n  }\n  function d3_geom_clipLine(x0, y0, x1, y1) {\n    return function(line) {\n      var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r;\n      r = x0 - ax;\n      if (!dx && r > 0) return;\n      r /= dx;\n      if (dx < 0) {\n        if (r < t0) return;\n        if (r < t1) t1 = r;\n      } else if (dx > 0) {\n        if (r > t1) return;\n        if (r > t0) t0 = r;\n      }\n      r = x1 - ax;\n      if (!dx && r < 0) return;\n      r /= dx;\n      if (dx < 0) {\n        if (r > t1) return;\n        if (r > t0) t0 = r;\n      } else if (dx > 0) {\n        if (r < t0) return;\n        if (r < t1) t1 = r;\n      }\n      r = y0 - ay;\n      if (!dy && r > 0) return;\n      r /= dy;\n      if (dy < 0) {\n        if (r < t0) return;\n        if (r < t1) t1 = r;\n      } else if (dy > 0) {\n        if (r > t1) return;\n        if (r > t0) t0 = r;\n      }\n      r = y1 - ay;\n      if (!dy && r < 0) return;\n      r /= dy;\n      if (dy < 0) {\n        if (r > t1) return;\n        if (r > t0) t0 = r;\n      } else if (dy > 0) {\n        if (r < t0) return;\n        if (r < t1) t1 = r;\n      }\n      if (t0 > 0) line.a = {\n        x: ax + t0 * dx,\n        y: ay + t0 * dy\n      };\n      if (t1 < 1) line.b = {\n        x: ax + t1 * dx,\n        y: ay + t1 * dy\n      };\n      return line;\n    };\n  }\n  var d3_geo_clipExtentMAX = 1e9;\n  d3.geo.clipExtent = function() {\n    var x0, y0, x1, y1, stream, clip, clipExtent = {\n      stream: function(output) {\n        if (stream) stream.valid = false;\n        stream = clip(output);\n        stream.valid = true;\n        return stream;\n      },\n      extent: function(_) {\n        if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n        clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]);\n        if (stream) stream.valid = false, stream = null;\n        return clipExtent;\n      }\n    };\n    return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]);\n  };\n  function d3_geo_clipExtent(x0, y0, x1, y1) {\n    return function(listener) {\n      var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring;\n      var clip = {\n        point: point,\n        lineStart: lineStart,\n        lineEnd: lineEnd,\n        polygonStart: function() {\n          listener = bufferListener;\n          segments = [];\n          polygon = [];\n          clean = true;\n        },\n        polygonEnd: function() {\n          listener = listener_;\n          segments = d3.merge(segments);\n          var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length;\n          if (inside || visible) {\n            listener.polygonStart();\n            if (inside) {\n              listener.lineStart();\n              interpolate(null, null, 1, listener);\n              listener.lineEnd();\n            }\n            if (visible) {\n              d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener);\n            }\n            listener.polygonEnd();\n          }\n          segments = polygon = ring = null;\n        }\n      };\n      function insidePolygon(p) {\n        var wn = 0, n = polygon.length, y = p[1];\n        for (var i = 0; i < n; ++i) {\n          for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) {\n            b = v[j];\n            if (a[1] <= y) {\n              if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn;\n            } else {\n              if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn;\n            }\n            a = b;\n          }\n        }\n        return wn !== 0;\n      }\n      function interpolate(from, to, direction, listener) {\n        var a = 0, a1 = 0;\n        if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) {\n          do {\n            listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0);\n          } while ((a = (a + direction + 4) % 4) !== a1);\n        } else {\n          listener.point(to[0], to[1]);\n        }\n      }\n      function pointVisible(x, y) {\n        return x0 <= x && x <= x1 && y0 <= y && y <= y1;\n      }\n      function point(x, y) {\n        if (pointVisible(x, y)) listener.point(x, y);\n      }\n      var x__, y__, v__, x_, y_, v_, first, clean;\n      function lineStart() {\n        clip.point = linePoint;\n        if (polygon) polygon.push(ring = []);\n        first = true;\n        v_ = false;\n        x_ = y_ = NaN;\n      }\n      function lineEnd() {\n        if (segments) {\n          linePoint(x__, y__);\n          if (v__ && v_) bufferListener.rejoin();\n          segments.push(bufferListener.buffer());\n        }\n        clip.point = point;\n        if (v_) listener.lineEnd();\n      }\n      function linePoint(x, y) {\n        x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x));\n        y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y));\n        var v = pointVisible(x, y);\n        if (polygon) ring.push([ x, y ]);\n        if (first) {\n          x__ = x, y__ = y, v__ = v;\n          first = false;\n          if (v) {\n            listener.lineStart();\n            listener.point(x, y);\n          }\n        } else {\n          if (v && v_) listener.point(x, y); else {\n            var l = {\n              a: {\n                x: x_,\n                y: y_\n              },\n              b: {\n                x: x,\n                y: y\n              }\n            };\n            if (clipLine(l)) {\n              if (!v_) {\n                listener.lineStart();\n                listener.point(l.a.x, l.a.y);\n              }\n              listener.point(l.b.x, l.b.y);\n              if (!v) listener.lineEnd();\n              clean = false;\n            } else if (v) {\n              listener.lineStart();\n              listener.point(x, y);\n              clean = false;\n            }\n          }\n        }\n        x_ = x, y_ = y, v_ = v;\n      }\n      return clip;\n    };\n    function corner(p, direction) {\n      return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;\n    }\n    function compare(a, b) {\n      return comparePoints(a.x, b.x);\n    }\n    function comparePoints(a, b) {\n      var ca = corner(a, 1), cb = corner(b, 1);\n      return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];\n    }\n  }\n  function d3_geo_conic(projectAt) {\n    var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1);\n    p.parallels = function(_) {\n      if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ];\n      return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180);\n    };\n    return p;\n  }\n  function d3_geo_conicEqualArea(φ0, φ1) {\n    var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n;\n    function forward(λ, φ) {\n      var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;\n      return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];\n    }\n    forward.invert = function(x, y) {\n      var ρ0_y = ρ0 - y;\n      return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];\n    };\n    return forward;\n  }\n  (d3.geo.conicEqualArea = function() {\n    return d3_geo_conic(d3_geo_conicEqualArea);\n  }).raw = d3_geo_conicEqualArea;\n  d3.geo.albers = function() {\n    return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070);\n  };\n  d3.geo.albersUsa = function() {\n    var lower48 = d3.geo.albers();\n    var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]);\n    var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]);\n    var point, pointStream = {\n      point: function(x, y) {\n        point = [ x, y ];\n      }\n    }, lower48Point, alaskaPoint, hawaiiPoint;\n    function albersUsa(coordinates) {\n      var x = coordinates[0], y = coordinates[1];\n      point = null;\n      (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y);\n      return point;\n    }\n    albersUsa.invert = function(coordinates) {\n      var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k;\n      return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates);\n    };\n    albersUsa.stream = function(stream) {\n      var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream);\n      return {\n        point: function(x, y) {\n          lower48Stream.point(x, y);\n          alaskaStream.point(x, y);\n          hawaiiStream.point(x, y);\n        },\n        sphere: function() {\n          lower48Stream.sphere();\n          alaskaStream.sphere();\n          hawaiiStream.sphere();\n        },\n        lineStart: function() {\n          lower48Stream.lineStart();\n          alaskaStream.lineStart();\n          hawaiiStream.lineStart();\n        },\n        lineEnd: function() {\n          lower48Stream.lineEnd();\n          alaskaStream.lineEnd();\n          hawaiiStream.lineEnd();\n        },\n        polygonStart: function() {\n          lower48Stream.polygonStart();\n          alaskaStream.polygonStart();\n          hawaiiStream.polygonStart();\n        },\n        polygonEnd: function() {\n          lower48Stream.polygonEnd();\n          alaskaStream.polygonEnd();\n          hawaiiStream.polygonEnd();\n        }\n      };\n    };\n    albersUsa.precision = function(_) {\n      if (!arguments.length) return lower48.precision();\n      lower48.precision(_);\n      alaska.precision(_);\n      hawaii.precision(_);\n      return albersUsa;\n    };\n    albersUsa.scale = function(_) {\n      if (!arguments.length) return lower48.scale();\n      lower48.scale(_);\n      alaska.scale(_ * .35);\n      hawaii.scale(_);\n      return albersUsa.translate(lower48.translate());\n    };\n    albersUsa.translate = function(_) {\n      if (!arguments.length) return lower48.translate();\n      var k = lower48.scale(), x = +_[0], y = +_[1];\n      lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point;\n      alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;\n      hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point;\n      return albersUsa;\n    };\n    return albersUsa.scale(1070);\n  };\n  var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {\n    point: d3_noop,\n    lineStart: d3_noop,\n    lineEnd: d3_noop,\n    polygonStart: function() {\n      d3_geo_pathAreaPolygon = 0;\n      d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;\n    },\n    polygonEnd: function() {\n      d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;\n      d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2);\n    }\n  };\n  function d3_geo_pathAreaRingStart() {\n    var x00, y00, x0, y0;\n    d3_geo_pathArea.point = function(x, y) {\n      d3_geo_pathArea.point = nextPoint;\n      x00 = x0 = x, y00 = y0 = y;\n    };\n    function nextPoint(x, y) {\n      d3_geo_pathAreaPolygon += y0 * x - x0 * y;\n      x0 = x, y0 = y;\n    }\n    d3_geo_pathArea.lineEnd = function() {\n      nextPoint(x00, y00);\n    };\n  }\n  var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1;\n  var d3_geo_pathBounds = {\n    point: d3_geo_pathBoundsPoint,\n    lineStart: d3_noop,\n    lineEnd: d3_noop,\n    polygonStart: d3_noop,\n    polygonEnd: d3_noop\n  };\n  function d3_geo_pathBoundsPoint(x, y) {\n    if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x;\n    if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x;\n    if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y;\n    if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y;\n  }\n  function d3_geo_pathBuffer() {\n    var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = [];\n    var stream = {\n      point: point,\n      lineStart: function() {\n        stream.point = pointLineStart;\n      },\n      lineEnd: lineEnd,\n      polygonStart: function() {\n        stream.lineEnd = lineEndPolygon;\n      },\n      polygonEnd: function() {\n        stream.lineEnd = lineEnd;\n        stream.point = point;\n      },\n      pointRadius: function(_) {\n        pointCircle = d3_geo_pathBufferCircle(_);\n        return stream;\n      },\n      result: function() {\n        if (buffer.length) {\n          var result = buffer.join(\"\");\n          buffer = [];\n          return result;\n        }\n      }\n    };\n    function point(x, y) {\n      buffer.push(\"M\", x, \",\", y, pointCircle);\n    }\n    function pointLineStart(x, y) {\n      buffer.push(\"M\", x, \",\", y);\n      stream.point = pointLine;\n    }\n    function pointLine(x, y) {\n      buffer.push(\"L\", x, \",\", y);\n    }\n    function lineEnd() {\n      stream.point = point;\n    }\n    function lineEndPolygon() {\n      buffer.push(\"Z\");\n    }\n    return stream;\n  }\n  function d3_geo_pathBufferCircle(radius) {\n    return \"m0,\" + radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + -2 * radius + \"a\" + radius + \",\" + radius + \" 0 1,1 0,\" + 2 * radius + \"z\";\n  }\n  var d3_geo_pathCentroid = {\n    point: d3_geo_pathCentroidPoint,\n    lineStart: d3_geo_pathCentroidLineStart,\n    lineEnd: d3_geo_pathCentroidLineEnd,\n    polygonStart: function() {\n      d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;\n    },\n    polygonEnd: function() {\n      d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n      d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;\n      d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;\n    }\n  };\n  function d3_geo_pathCentroidPoint(x, y) {\n    d3_geo_centroidX0 += x;\n    d3_geo_centroidY0 += y;\n    ++d3_geo_centroidZ0;\n  }\n  function d3_geo_pathCentroidLineStart() {\n    var x0, y0;\n    d3_geo_pathCentroid.point = function(x, y) {\n      d3_geo_pathCentroid.point = nextPoint;\n      d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n    };\n    function nextPoint(x, y) {\n      var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n      d3_geo_centroidX1 += z * (x0 + x) / 2;\n      d3_geo_centroidY1 += z * (y0 + y) / 2;\n      d3_geo_centroidZ1 += z;\n      d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n    }\n  }\n  function d3_geo_pathCentroidLineEnd() {\n    d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;\n  }\n  function d3_geo_pathCentroidRingStart() {\n    var x00, y00, x0, y0;\n    d3_geo_pathCentroid.point = function(x, y) {\n      d3_geo_pathCentroid.point = nextPoint;\n      d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y);\n    };\n    function nextPoint(x, y) {\n      var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);\n      d3_geo_centroidX1 += z * (x0 + x) / 2;\n      d3_geo_centroidY1 += z * (y0 + y) / 2;\n      d3_geo_centroidZ1 += z;\n      z = y0 * x - x0 * y;\n      d3_geo_centroidX2 += z * (x0 + x);\n      d3_geo_centroidY2 += z * (y0 + y);\n      d3_geo_centroidZ2 += z * 3;\n      d3_geo_pathCentroidPoint(x0 = x, y0 = y);\n    }\n    d3_geo_pathCentroid.lineEnd = function() {\n      nextPoint(x00, y00);\n    };\n  }\n  function d3_geo_pathContext(context) {\n    var pointRadius = 4.5;\n    var stream = {\n      point: point,\n      lineStart: function() {\n        stream.point = pointLineStart;\n      },\n      lineEnd: lineEnd,\n      polygonStart: function() {\n        stream.lineEnd = lineEndPolygon;\n      },\n      polygonEnd: function() {\n        stream.lineEnd = lineEnd;\n        stream.point = point;\n      },\n      pointRadius: function(_) {\n        pointRadius = _;\n        return stream;\n      },\n      result: d3_noop\n    };\n    function point(x, y) {\n      context.moveTo(x + pointRadius, y);\n      context.arc(x, y, pointRadius, 0, τ);\n    }\n    function pointLineStart(x, y) {\n      context.moveTo(x, y);\n      stream.point = pointLine;\n    }\n    function pointLine(x, y) {\n      context.lineTo(x, y);\n    }\n    function lineEnd() {\n      stream.point = point;\n    }\n    function lineEndPolygon() {\n      context.closePath();\n    }\n    return stream;\n  }\n  function d3_geo_resample(project) {\n    var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16;\n    function resample(stream) {\n      return (maxDepth ? resampleRecursive : resampleNone)(stream);\n    }\n    function resampleNone(stream) {\n      return d3_geo_transformPoint(stream, function(x, y) {\n        x = project(x, y);\n        stream.point(x[0], x[1]);\n      });\n    }\n    function resampleRecursive(stream) {\n      var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0;\n      var resample = {\n        point: point,\n        lineStart: lineStart,\n        lineEnd: lineEnd,\n        polygonStart: function() {\n          stream.polygonStart();\n          resample.lineStart = ringStart;\n        },\n        polygonEnd: function() {\n          stream.polygonEnd();\n          resample.lineStart = lineStart;\n        }\n      };\n      function point(x, y) {\n        x = project(x, y);\n        stream.point(x[0], x[1]);\n      }\n      function lineStart() {\n        x0 = NaN;\n        resample.point = linePoint;\n        stream.lineStart();\n      }\n      function linePoint(λ, φ) {\n        var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);\n        resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);\n        stream.point(x0, y0);\n      }\n      function lineEnd() {\n        resample.point = point;\n        stream.lineEnd();\n      }\n      function ringStart() {\n        lineStart();\n        resample.point = ringPoint;\n        resample.lineEnd = ringEnd;\n      }\n      function ringPoint(λ, φ) {\n        linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;\n        resample.point = linePoint;\n      }\n      function ringEnd() {\n        resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);\n        resample.lineEnd = lineEnd;\n        lineEnd();\n      }\n      return resample;\n    }\n    function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {\n      var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;\n      if (d2 > 4 * δ2 && depth--) {\n        var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2;\n        if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {\n          resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);\n          stream.point(x2, y2);\n          resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);\n        }\n      }\n    }\n    resample.precision = function(_) {\n      if (!arguments.length) return Math.sqrt(δ2);\n      maxDepth = (δ2 = _ * _) > 0 && 16;\n      return resample;\n    };\n    return resample;\n  }\n  d3.geo.path = function() {\n    var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream;\n    function path(object) {\n      if (object) {\n        if (typeof pointRadius === \"function\") contextStream.pointRadius(+pointRadius.apply(this, arguments));\n        if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream);\n        d3.geo.stream(object, cacheStream);\n      }\n      return contextStream.result();\n    }\n    path.area = function(object) {\n      d3_geo_pathAreaSum = 0;\n      d3.geo.stream(object, projectStream(d3_geo_pathArea));\n      return d3_geo_pathAreaSum;\n    };\n    path.centroid = function(object) {\n      d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0;\n      d3.geo.stream(object, projectStream(d3_geo_pathCentroid));\n      return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ];\n    };\n    path.bounds = function(object) {\n      d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity);\n      d3.geo.stream(object, projectStream(d3_geo_pathBounds));\n      return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ];\n    };\n    path.projection = function(_) {\n      if (!arguments.length) return projection;\n      projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;\n      return reset();\n    };\n    path.context = function(_) {\n      if (!arguments.length) return context;\n      contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);\n      if (typeof pointRadius !== \"function\") contextStream.pointRadius(pointRadius);\n      return reset();\n    };\n    path.pointRadius = function(_) {\n      if (!arguments.length) return pointRadius;\n      pointRadius = typeof _ === \"function\" ? _ : (contextStream.pointRadius(+_), +_);\n      return path;\n    };\n    function reset() {\n      cacheStream = null;\n      return path;\n    }\n    return path.projection(d3.geo.albersUsa()).context(null);\n  };\n  function d3_geo_pathProjectStream(project) {\n    var resample = d3_geo_resample(function(x, y) {\n      return project([ x * d3_degrees, y * d3_degrees ]);\n    });\n    return function(stream) {\n      return d3_geo_projectionRadians(resample(stream));\n    };\n  }\n  d3.geo.transform = function(methods) {\n    return {\n      stream: function(stream) {\n        var transform = new d3_geo_transform(stream);\n        for (var k in methods) transform[k] = methods[k];\n        return transform;\n      }\n    };\n  };\n  function d3_geo_transform(stream) {\n    this.stream = stream;\n  }\n  d3_geo_transform.prototype = {\n    point: function(x, y) {\n      this.stream.point(x, y);\n    },\n    sphere: function() {\n      this.stream.sphere();\n    },\n    lineStart: function() {\n      this.stream.lineStart();\n    },\n    lineEnd: function() {\n      this.stream.lineEnd();\n    },\n    polygonStart: function() {\n      this.stream.polygonStart();\n    },\n    polygonEnd: function() {\n      this.stream.polygonEnd();\n    }\n  };\n  function d3_geo_transformPoint(stream, point) {\n    return {\n      point: point,\n      sphere: function() {\n        stream.sphere();\n      },\n      lineStart: function() {\n        stream.lineStart();\n      },\n      lineEnd: function() {\n        stream.lineEnd();\n      },\n      polygonStart: function() {\n        stream.polygonStart();\n      },\n      polygonEnd: function() {\n        stream.polygonEnd();\n      }\n    };\n  }\n  d3.geo.projection = d3_geo_projection;\n  d3.geo.projectionMutator = d3_geo_projectionMutator;\n  function d3_geo_projection(project) {\n    return d3_geo_projectionMutator(function() {\n      return project;\n    })();\n  }\n  function d3_geo_projectionMutator(projectAt) {\n    var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {\n      x = project(x, y);\n      return [ x[0] * k + δx, δy - x[1] * k ];\n    }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream;\n    function projection(point) {\n      point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);\n      return [ point[0] * k + δx, δy - point[1] * k ];\n    }\n    function invert(point) {\n      point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);\n      return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];\n    }\n    projection.stream = function(output) {\n      if (stream) stream.valid = false;\n      stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output))));\n      stream.valid = true;\n      return stream;\n    };\n    projection.clipAngle = function(_) {\n      if (!arguments.length) return clipAngle;\n      preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians);\n      return invalidate();\n    };\n    projection.clipExtent = function(_) {\n      if (!arguments.length) return clipExtent;\n      clipExtent = _;\n      postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity;\n      return invalidate();\n    };\n    projection.scale = function(_) {\n      if (!arguments.length) return k;\n      k = +_;\n      return reset();\n    };\n    projection.translate = function(_) {\n      if (!arguments.length) return [ x, y ];\n      x = +_[0];\n      y = +_[1];\n      return reset();\n    };\n    projection.center = function(_) {\n      if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];\n      λ = _[0] % 360 * d3_radians;\n      φ = _[1] % 360 * d3_radians;\n      return reset();\n    };\n    projection.rotate = function(_) {\n      if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];\n      δλ = _[0] % 360 * d3_radians;\n      δφ = _[1] % 360 * d3_radians;\n      δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;\n      return reset();\n    };\n    d3.rebind(projection, projectResample, \"precision\");\n    function reset() {\n      projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);\n      var center = project(λ, φ);\n      δx = x - center[0] * k;\n      δy = y + center[1] * k;\n      return invalidate();\n    }\n    function invalidate() {\n      if (stream) stream.valid = false, stream = null;\n      return projection;\n    }\n    return function() {\n      project = projectAt.apply(this, arguments);\n      projection.invert = project.invert && invert;\n      return reset();\n    };\n  }\n  function d3_geo_projectionRadians(stream) {\n    return d3_geo_transformPoint(stream, function(x, y) {\n      stream.point(x * d3_radians, y * d3_radians);\n    });\n  }\n  function d3_geo_equirectangular(λ, φ) {\n    return [ λ, φ ];\n  }\n  (d3.geo.equirectangular = function() {\n    return d3_geo_projection(d3_geo_equirectangular);\n  }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;\n  d3.geo.rotation = function(rotate) {\n    rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0);\n    function forward(coordinates) {\n      coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n      return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n    }\n    forward.invert = function(coordinates) {\n      coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians);\n      return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates;\n    };\n    return forward;\n  };\n  function d3_geo_identityRotation(λ, φ) {\n    return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];\n  }\n  d3_geo_identityRotation.invert = d3_geo_equirectangular;\n  function d3_geo_rotation(δλ, δφ, δγ) {\n    return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation;\n  }\n  function d3_geo_forwardRotationλ(δλ) {\n    return function(λ, φ) {\n      return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ];\n    };\n  }\n  function d3_geo_rotationλ(δλ) {\n    var rotation = d3_geo_forwardRotationλ(δλ);\n    rotation.invert = d3_geo_forwardRotationλ(-δλ);\n    return rotation;\n  }\n  function d3_geo_rotationφγ(δφ, δγ) {\n    var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);\n    function rotation(λ, φ) {\n      var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;\n      return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ];\n    }\n    rotation.invert = function(λ, φ) {\n      var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;\n      return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ];\n    };\n    return rotation;\n  }\n  d3.geo.circle = function() {\n    var origin = [ 0, 0 ], angle, precision = 6, interpolate;\n    function circle() {\n      var center = typeof origin === \"function\" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = [];\n      interpolate(null, null, 1, {\n        point: function(x, y) {\n          ring.push(x = rotate(x, y));\n          x[0] *= d3_degrees, x[1] *= d3_degrees;\n        }\n      });\n      return {\n        type: \"Polygon\",\n        coordinates: [ ring ]\n      };\n    }\n    circle.origin = function(x) {\n      if (!arguments.length) return origin;\n      origin = x;\n      return circle;\n    };\n    circle.angle = function(x) {\n      if (!arguments.length) return angle;\n      interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);\n      return circle;\n    };\n    circle.precision = function(_) {\n      if (!arguments.length) return precision;\n      interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);\n      return circle;\n    };\n    return circle.angle(90);\n  };\n  function d3_geo_circleInterpolate(radius, precision) {\n    var cr = Math.cos(radius), sr = Math.sin(radius);\n    return function(from, to, direction, listener) {\n      var step = direction * precision;\n      if (from != null) {\n        from = d3_geo_circleAngle(cr, from);\n        to = d3_geo_circleAngle(cr, to);\n        if (direction > 0 ? from < to : from > to) from += direction * τ;\n      } else {\n        from = radius + direction * τ;\n        to = radius - .5 * step;\n      }\n      for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) {\n        listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);\n      }\n    };\n  }\n  function d3_geo_circleAngle(cr, point) {\n    var a = d3_geo_cartesian(point);\n    a[0] -= cr;\n    d3_geo_cartesianNormalize(a);\n    var angle = d3_acos(-a[1]);\n    return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);\n  }\n  d3.geo.distance = function(a, b) {\n    var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t;\n    return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ);\n  };\n  d3.geo.graticule = function() {\n    var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5;\n    function graticule() {\n      return {\n        type: \"MultiLineString\",\n        coordinates: lines()\n      };\n    }\n    function lines() {\n      return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) {\n        return abs(x % DX) > ε;\n      }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) {\n        return abs(y % DY) > ε;\n      }).map(y));\n    }\n    graticule.lines = function() {\n      return lines().map(function(coordinates) {\n        return {\n          type: \"LineString\",\n          coordinates: coordinates\n        };\n      });\n    };\n    graticule.outline = function() {\n      return {\n        type: \"Polygon\",\n        coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ]\n      };\n    };\n    graticule.extent = function(_) {\n      if (!arguments.length) return graticule.minorExtent();\n      return graticule.majorExtent(_).minorExtent(_);\n    };\n    graticule.majorExtent = function(_) {\n      if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ];\n      X0 = +_[0][0], X1 = +_[1][0];\n      Y0 = +_[0][1], Y1 = +_[1][1];\n      if (X0 > X1) _ = X0, X0 = X1, X1 = _;\n      if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _;\n      return graticule.precision(precision);\n    };\n    graticule.minorExtent = function(_) {\n      if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];\n      x0 = +_[0][0], x1 = +_[1][0];\n      y0 = +_[0][1], y1 = +_[1][1];\n      if (x0 > x1) _ = x0, x0 = x1, x1 = _;\n      if (y0 > y1) _ = y0, y0 = y1, y1 = _;\n      return graticule.precision(precision);\n    };\n    graticule.step = function(_) {\n      if (!arguments.length) return graticule.minorStep();\n      return graticule.majorStep(_).minorStep(_);\n    };\n    graticule.majorStep = function(_) {\n      if (!arguments.length) return [ DX, DY ];\n      DX = +_[0], DY = +_[1];\n      return graticule;\n    };\n    graticule.minorStep = function(_) {\n      if (!arguments.length) return [ dx, dy ];\n      dx = +_[0], dy = +_[1];\n      return graticule;\n    };\n    graticule.precision = function(_) {\n      if (!arguments.length) return precision;\n      precision = +_;\n      x = d3_geo_graticuleX(y0, y1, 90);\n      y = d3_geo_graticuleY(x0, x1, precision);\n      X = d3_geo_graticuleX(Y0, Y1, 90);\n      Y = d3_geo_graticuleY(X0, X1, precision);\n      return graticule;\n    };\n    return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]);\n  };\n  function d3_geo_graticuleX(y0, y1, dy) {\n    var y = d3.range(y0, y1 - ε, dy).concat(y1);\n    return function(x) {\n      return y.map(function(y) {\n        return [ x, y ];\n      });\n    };\n  }\n  function d3_geo_graticuleY(x0, x1, dx) {\n    var x = d3.range(x0, x1 - ε, dx).concat(x1);\n    return function(y) {\n      return x.map(function(x) {\n        return [ x, y ];\n      });\n    };\n  }\n  function d3_source(d) {\n    return d.source;\n  }\n  function d3_target(d) {\n    return d.target;\n  }\n  d3.geo.greatArc = function() {\n    var source = d3_source, source_, target = d3_target, target_;\n    function greatArc() {\n      return {\n        type: \"LineString\",\n        coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ]\n      };\n    }\n    greatArc.distance = function() {\n      return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments));\n    };\n    greatArc.source = function(_) {\n      if (!arguments.length) return source;\n      source = _, source_ = typeof _ === \"function\" ? null : _;\n      return greatArc;\n    };\n    greatArc.target = function(_) {\n      if (!arguments.length) return target;\n      target = _, target_ = typeof _ === \"function\" ? null : _;\n      return greatArc;\n    };\n    greatArc.precision = function() {\n      return arguments.length ? greatArc : 0;\n    };\n    return greatArc;\n  };\n  d3.geo.interpolate = function(source, target) {\n    return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);\n  };\n  function d3_geo_interpolate(x0, y0, x1, y1) {\n    var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d);\n    var interpolate = d ? function(t) {\n      var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;\n      return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ];\n    } : function() {\n      return [ x0 * d3_degrees, y0 * d3_degrees ];\n    };\n    interpolate.distance = d;\n    return interpolate;\n  }\n  d3.geo.length = function(object) {\n    d3_geo_lengthSum = 0;\n    d3.geo.stream(object, d3_geo_length);\n    return d3_geo_lengthSum;\n  };\n  var d3_geo_lengthSum;\n  var d3_geo_length = {\n    sphere: d3_noop,\n    point: d3_noop,\n    lineStart: d3_geo_lengthLineStart,\n    lineEnd: d3_noop,\n    polygonStart: d3_noop,\n    polygonEnd: d3_noop\n  };\n  function d3_geo_lengthLineStart() {\n    var λ0, sinφ0, cosφ0;\n    d3_geo_length.point = function(λ, φ) {\n      λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ);\n      d3_geo_length.point = nextPoint;\n    };\n    d3_geo_length.lineEnd = function() {\n      d3_geo_length.point = d3_geo_length.lineEnd = d3_noop;\n    };\n    function nextPoint(λ, φ) {\n      var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t);\n      d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ);\n      λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ;\n    }\n  }\n  function d3_geo_azimuthal(scale, angle) {\n    function azimuthal(λ, φ) {\n      var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);\n      return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];\n    }\n    azimuthal.invert = function(x, y) {\n      var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);\n      return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];\n    };\n    return azimuthal;\n  }\n  var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {\n    return Math.sqrt(2 / (1 + cosλcosφ));\n  }, function(ρ) {\n    return 2 * Math.asin(ρ / 2);\n  });\n  (d3.geo.azimuthalEqualArea = function() {\n    return d3_geo_projection(d3_geo_azimuthalEqualArea);\n  }).raw = d3_geo_azimuthalEqualArea;\n  var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {\n    var c = Math.acos(cosλcosφ);\n    return c && c / Math.sin(c);\n  }, d3_identity);\n  (d3.geo.azimuthalEquidistant = function() {\n    return d3_geo_projection(d3_geo_azimuthalEquidistant);\n  }).raw = d3_geo_azimuthalEquidistant;\n  function d3_geo_conicConformal(φ0, φ1) {\n    var cosφ0 = Math.cos(φ0), t = function(φ) {\n      return Math.tan(π / 4 + φ / 2);\n    }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n;\n    if (!n) return d3_geo_mercator;\n    function forward(λ, φ) {\n      if (F > 0) {\n        if (φ < -halfπ + ε) φ = -halfπ + ε;\n      } else {\n        if (φ > halfπ - ε) φ = halfπ - ε;\n      }\n      var ρ = F / Math.pow(t(φ), n);\n      return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ];\n    }\n    forward.invert = function(x, y) {\n      var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y);\n      return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ];\n    };\n    return forward;\n  }\n  (d3.geo.conicConformal = function() {\n    return d3_geo_conic(d3_geo_conicConformal);\n  }).raw = d3_geo_conicConformal;\n  function d3_geo_conicEquidistant(φ0, φ1) {\n    var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0;\n    if (abs(n) < ε) return d3_geo_equirectangular;\n    function forward(λ, φ) {\n      var ρ = G - φ;\n      return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ];\n    }\n    forward.invert = function(x, y) {\n      var ρ0_y = G - y;\n      return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ];\n    };\n    return forward;\n  }\n  (d3.geo.conicEquidistant = function() {\n    return d3_geo_conic(d3_geo_conicEquidistant);\n  }).raw = d3_geo_conicEquidistant;\n  var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {\n    return 1 / cosλcosφ;\n  }, Math.atan);\n  (d3.geo.gnomonic = function() {\n    return d3_geo_projection(d3_geo_gnomonic);\n  }).raw = d3_geo_gnomonic;\n  function d3_geo_mercator(λ, φ) {\n    return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ];\n  }\n  d3_geo_mercator.invert = function(x, y) {\n    return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ];\n  };\n  function d3_geo_mercatorProjection(project) {\n    var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto;\n    m.scale = function() {\n      var v = scale.apply(m, arguments);\n      return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n    };\n    m.translate = function() {\n      var v = translate.apply(m, arguments);\n      return v === m ? clipAuto ? m.clipExtent(null) : m : v;\n    };\n    m.clipExtent = function(_) {\n      var v = clipExtent.apply(m, arguments);\n      if (v === m) {\n        if (clipAuto = _ == null) {\n          var k = π * scale(), t = translate();\n          clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]);\n        }\n      } else if (clipAuto) {\n        v = null;\n      }\n      return v;\n    };\n    return m.clipExtent(null);\n  }\n  (d3.geo.mercator = function() {\n    return d3_geo_mercatorProjection(d3_geo_mercator);\n  }).raw = d3_geo_mercator;\n  var d3_geo_orthographic = d3_geo_azimuthal(function() {\n    return 1;\n  }, Math.asin);\n  (d3.geo.orthographic = function() {\n    return d3_geo_projection(d3_geo_orthographic);\n  }).raw = d3_geo_orthographic;\n  var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {\n    return 1 / (1 + cosλcosφ);\n  }, function(ρ) {\n    return 2 * Math.atan(ρ);\n  });\n  (d3.geo.stereographic = function() {\n    return d3_geo_projection(d3_geo_stereographic);\n  }).raw = d3_geo_stereographic;\n  function d3_geo_transverseMercator(λ, φ) {\n    return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ];\n  }\n  d3_geo_transverseMercator.invert = function(x, y) {\n    return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ];\n  };\n  (d3.geo.transverseMercator = function() {\n    var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate;\n    projection.center = function(_) {\n      return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]);\n    };\n    projection.rotate = function(_) {\n      return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), \n      [ _[0], _[1], _[2] - 90 ]);\n    };\n    return rotate([ 0, 0, 90 ]);\n  }).raw = d3_geo_transverseMercator;\n  d3.geom = {};\n  function d3_geom_pointX(d) {\n    return d[0];\n  }\n  function d3_geom_pointY(d) {\n    return d[1];\n  }\n  d3.geom.hull = function(vertices) {\n    var x = d3_geom_pointX, y = d3_geom_pointY;\n    if (arguments.length) return hull(vertices);\n    function hull(data) {\n      if (data.length < 3) return [];\n      var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = [];\n      for (i = 0; i < n; i++) {\n        points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]);\n      }\n      points.sort(d3_geom_hullOrder);\n      for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]);\n      var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints);\n      var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = [];\n      for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]);\n      for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]);\n      return polygon;\n    }\n    hull.x = function(_) {\n      return arguments.length ? (x = _, hull) : x;\n    };\n    hull.y = function(_) {\n      return arguments.length ? (y = _, hull) : y;\n    };\n    return hull;\n  };\n  function d3_geom_hullUpper(points) {\n    var n = points.length, hull = [ 0, 1 ], hs = 2;\n    for (var i = 2; i < n; i++) {\n      while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs;\n      hull[hs++] = i;\n    }\n    return hull.slice(0, hs);\n  }\n  function d3_geom_hullOrder(a, b) {\n    return a[0] - b[0] || a[1] - b[1];\n  }\n  d3.geom.polygon = function(coordinates) {\n    d3_subclass(coordinates, d3_geom_polygonPrototype);\n    return coordinates;\n  };\n  var d3_geom_polygonPrototype = d3.geom.polygon.prototype = [];\n  d3_geom_polygonPrototype.area = function() {\n    var i = -1, n = this.length, a, b = this[n - 1], area = 0;\n    while (++i < n) {\n      a = b;\n      b = this[i];\n      area += a[1] * b[0] - a[0] * b[1];\n    }\n    return area * .5;\n  };\n  d3_geom_polygonPrototype.centroid = function(k) {\n    var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c;\n    if (!arguments.length) k = -1 / (6 * this.area());\n    while (++i < n) {\n      a = b;\n      b = this[i];\n      c = a[0] * b[1] - b[0] * a[1];\n      x += (a[0] + b[0]) * c;\n      y += (a[1] + b[1]) * c;\n    }\n    return [ x * k, y * k ];\n  };\n  d3_geom_polygonPrototype.clip = function(subject) {\n    var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d;\n    while (++i < n) {\n      input = subject.slice();\n      subject.length = 0;\n      b = this[i];\n      c = input[(m = input.length - closed) - 1];\n      j = -1;\n      while (++j < m) {\n        d = input[j];\n        if (d3_geom_polygonInside(d, a, b)) {\n          if (!d3_geom_polygonInside(c, a, b)) {\n            subject.push(d3_geom_polygonIntersect(c, d, a, b));\n          }\n          subject.push(d);\n        } else if (d3_geom_polygonInside(c, a, b)) {\n          subject.push(d3_geom_polygonIntersect(c, d, a, b));\n        }\n        c = d;\n      }\n      if (closed) subject.push(subject[0]);\n      a = b;\n    }\n    return subject;\n  };\n  function d3_geom_polygonInside(p, a, b) {\n    return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);\n  }\n  function d3_geom_polygonIntersect(c, d, a, b) {\n    var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21);\n    return [ x1 + ua * x21, y1 + ua * y21 ];\n  }\n  function d3_geom_polygonClosed(coordinates) {\n    var a = coordinates[0], b = coordinates[coordinates.length - 1];\n    return !(a[0] - b[0] || a[1] - b[1]);\n  }\n  var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = [];\n  function d3_geom_voronoiBeach() {\n    d3_geom_voronoiRedBlackNode(this);\n    this.edge = this.site = this.circle = null;\n  }\n  function d3_geom_voronoiCreateBeach(site) {\n    var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach();\n    beach.site = site;\n    return beach;\n  }\n  function d3_geom_voronoiDetachBeach(beach) {\n    d3_geom_voronoiDetachCircle(beach);\n    d3_geom_voronoiBeaches.remove(beach);\n    d3_geom_voronoiBeachPool.push(beach);\n    d3_geom_voronoiRedBlackNode(beach);\n  }\n  function d3_geom_voronoiRemoveBeach(beach) {\n    var circle = beach.circle, x = circle.x, y = circle.cy, vertex = {\n      x: x,\n      y: y\n    }, previous = beach.P, next = beach.N, disappearing = [ beach ];\n    d3_geom_voronoiDetachBeach(beach);\n    var lArc = previous;\n    while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) {\n      previous = lArc.P;\n      disappearing.unshift(lArc);\n      d3_geom_voronoiDetachBeach(lArc);\n      lArc = previous;\n    }\n    disappearing.unshift(lArc);\n    d3_geom_voronoiDetachCircle(lArc);\n    var rArc = next;\n    while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) {\n      next = rArc.N;\n      disappearing.push(rArc);\n      d3_geom_voronoiDetachBeach(rArc);\n      rArc = next;\n    }\n    disappearing.push(rArc);\n    d3_geom_voronoiDetachCircle(rArc);\n    var nArcs = disappearing.length, iArc;\n    for (iArc = 1; iArc < nArcs; ++iArc) {\n      rArc = disappearing[iArc];\n      lArc = disappearing[iArc - 1];\n      d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);\n    }\n    lArc = disappearing[0];\n    rArc = disappearing[nArcs - 1];\n    rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex);\n    d3_geom_voronoiAttachCircle(lArc);\n    d3_geom_voronoiAttachCircle(rArc);\n  }\n  function d3_geom_voronoiAddBeach(site) {\n    var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._;\n    while (node) {\n      dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x;\n      if (dxl > ε) node = node.L; else {\n        dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix);\n        if (dxr > ε) {\n          if (!node.R) {\n            lArc = node;\n            break;\n          }\n          node = node.R;\n        } else {\n          if (dxl > -ε) {\n            lArc = node.P;\n            rArc = node;\n          } else if (dxr > -ε) {\n            lArc = node;\n            rArc = node.N;\n          } else {\n            lArc = rArc = node;\n          }\n          break;\n        }\n      }\n    }\n    var newArc = d3_geom_voronoiCreateBeach(site);\n    d3_geom_voronoiBeaches.insert(lArc, newArc);\n    if (!lArc && !rArc) return;\n    if (lArc === rArc) {\n      d3_geom_voronoiDetachCircle(lArc);\n      rArc = d3_geom_voronoiCreateBeach(lArc.site);\n      d3_geom_voronoiBeaches.insert(newArc, rArc);\n      newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n      d3_geom_voronoiAttachCircle(lArc);\n      d3_geom_voronoiAttachCircle(rArc);\n      return;\n    }\n    if (!rArc) {\n      newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site);\n      return;\n    }\n    d3_geom_voronoiDetachCircle(lArc);\n    d3_geom_voronoiDetachCircle(rArc);\n    var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = {\n      x: (cy * hb - by * hc) / d + ax,\n      y: (bx * hc - cx * hb) / d + ay\n    };\n    d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex);\n    newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex);\n    rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex);\n    d3_geom_voronoiAttachCircle(lArc);\n    d3_geom_voronoiAttachCircle(rArc);\n  }\n  function d3_geom_voronoiLeftBreakPoint(arc, directrix) {\n    var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix;\n    if (!pby2) return rfocx;\n    var lArc = arc.P;\n    if (!lArc) return -Infinity;\n    site = lArc.site;\n    var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix;\n    if (!plby2) return lfocx;\n    var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2;\n    if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;\n    return (rfocx + lfocx) / 2;\n  }\n  function d3_geom_voronoiRightBreakPoint(arc, directrix) {\n    var rArc = arc.N;\n    if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix);\n    var site = arc.site;\n    return site.y === directrix ? site.x : Infinity;\n  }\n  function d3_geom_voronoiCell(site) {\n    this.site = site;\n    this.edges = [];\n  }\n  d3_geom_voronoiCell.prototype.prepare = function() {\n    var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge;\n    while (iHalfEdge--) {\n      edge = halfEdges[iHalfEdge].edge;\n      if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1);\n    }\n    halfEdges.sort(d3_geom_voronoiHalfEdgeOrder);\n    return halfEdges.length;\n  };\n  function d3_geom_voronoiCloseCells(extent) {\n    var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end;\n    while (iCell--) {\n      cell = cells[iCell];\n      if (!cell || !cell.prepare()) continue;\n      halfEdges = cell.edges;\n      nHalfEdges = halfEdges.length;\n      iHalfEdge = 0;\n      while (iHalfEdge < nHalfEdges) {\n        end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y;\n        start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y;\n        if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) {\n          halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? {\n            x: x0,\n            y: abs(x2 - x0) < ε ? y2 : y1\n          } : abs(y3 - y1) < ε && x1 - x3 > ε ? {\n            x: abs(y2 - y1) < ε ? x2 : x1,\n            y: y1\n          } : abs(x3 - x1) < ε && y3 - y0 > ε ? {\n            x: x1,\n            y: abs(x2 - x1) < ε ? y2 : y0\n          } : abs(y3 - y0) < ε && x3 - x0 > ε ? {\n            x: abs(y2 - y0) < ε ? x2 : x0,\n            y: y0\n          } : null), cell.site, null));\n          ++nHalfEdges;\n        }\n      }\n    }\n  }\n  function d3_geom_voronoiHalfEdgeOrder(a, b) {\n    return b.angle - a.angle;\n  }\n  function d3_geom_voronoiCircle() {\n    d3_geom_voronoiRedBlackNode(this);\n    this.x = this.y = this.arc = this.site = this.cy = null;\n  }\n  function d3_geom_voronoiAttachCircle(arc) {\n    var lArc = arc.P, rArc = arc.N;\n    if (!lArc || !rArc) return;\n    var lSite = lArc.site, cSite = arc.site, rSite = rArc.site;\n    if (lSite === rSite) return;\n    var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by;\n    var d = 2 * (ax * cy - ay * cx);\n    if (d >= -ε2) return;\n    var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by;\n    var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle();\n    circle.arc = arc;\n    circle.site = cSite;\n    circle.x = x + bx;\n    circle.y = cy + Math.sqrt(x * x + y * y);\n    circle.cy = cy;\n    arc.circle = circle;\n    var before = null, node = d3_geom_voronoiCircles._;\n    while (node) {\n      if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) {\n        if (node.L) node = node.L; else {\n          before = node.P;\n          break;\n        }\n      } else {\n        if (node.R) node = node.R; else {\n          before = node;\n          break;\n        }\n      }\n    }\n    d3_geom_voronoiCircles.insert(before, circle);\n    if (!before) d3_geom_voronoiFirstCircle = circle;\n  }\n  function d3_geom_voronoiDetachCircle(arc) {\n    var circle = arc.circle;\n    if (circle) {\n      if (!circle.P) d3_geom_voronoiFirstCircle = circle.N;\n      d3_geom_voronoiCircles.remove(circle);\n      d3_geom_voronoiCirclePool.push(circle);\n      d3_geom_voronoiRedBlackNode(circle);\n      arc.circle = null;\n    }\n  }\n  function d3_geom_voronoiClipEdges(extent) {\n    var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e;\n    while (i--) {\n      e = edges[i];\n      if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) {\n        e.a = e.b = null;\n        edges.splice(i, 1);\n      }\n    }\n  }\n  function d3_geom_voronoiConnectEdge(edge, extent) {\n    var vb = edge.b;\n    if (vb) return true;\n    var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb;\n    if (ry === ly) {\n      if (fx < x0 || fx >= x1) return;\n      if (lx > rx) {\n        if (!va) va = {\n          x: fx,\n          y: y0\n        }; else if (va.y >= y1) return;\n        vb = {\n          x: fx,\n          y: y1\n        };\n      } else {\n        if (!va) va = {\n          x: fx,\n          y: y1\n        }; else if (va.y < y0) return;\n        vb = {\n          x: fx,\n          y: y0\n        };\n      }\n    } else {\n      fm = (lx - rx) / (ry - ly);\n      fb = fy - fm * fx;\n      if (fm < -1 || fm > 1) {\n        if (lx > rx) {\n          if (!va) va = {\n            x: (y0 - fb) / fm,\n            y: y0\n          }; else if (va.y >= y1) return;\n          vb = {\n            x: (y1 - fb) / fm,\n            y: y1\n          };\n        } else {\n          if (!va) va = {\n            x: (y1 - fb) / fm,\n            y: y1\n          }; else if (va.y < y0) return;\n          vb = {\n            x: (y0 - fb) / fm,\n            y: y0\n          };\n        }\n      } else {\n        if (ly < ry) {\n          if (!va) va = {\n            x: x0,\n            y: fm * x0 + fb\n          }; else if (va.x >= x1) return;\n          vb = {\n            x: x1,\n            y: fm * x1 + fb\n          };\n        } else {\n          if (!va) va = {\n            x: x1,\n            y: fm * x1 + fb\n          }; else if (va.x < x0) return;\n          vb = {\n            x: x0,\n            y: fm * x0 + fb\n          };\n        }\n      }\n    }\n    edge.a = va;\n    edge.b = vb;\n    return true;\n  }\n  function d3_geom_voronoiEdge(lSite, rSite) {\n    this.l = lSite;\n    this.r = rSite;\n    this.a = this.b = null;\n  }\n  function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) {\n    var edge = new d3_geom_voronoiEdge(lSite, rSite);\n    d3_geom_voronoiEdges.push(edge);\n    if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va);\n    if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb);\n    d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite));\n    d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite));\n    return edge;\n  }\n  function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) {\n    var edge = new d3_geom_voronoiEdge(lSite, null);\n    edge.a = va;\n    edge.b = vb;\n    d3_geom_voronoiEdges.push(edge);\n    return edge;\n  }\n  function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) {\n    if (!edge.a && !edge.b) {\n      edge.a = vertex;\n      edge.l = lSite;\n      edge.r = rSite;\n    } else if (edge.l === rSite) {\n      edge.b = vertex;\n    } else {\n      edge.a = vertex;\n    }\n  }\n  function d3_geom_voronoiHalfEdge(edge, lSite, rSite) {\n    var va = edge.a, vb = edge.b;\n    this.edge = edge;\n    this.site = lSite;\n    this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y);\n  }\n  d3_geom_voronoiHalfEdge.prototype = {\n    start: function() {\n      return this.edge.l === this.site ? this.edge.a : this.edge.b;\n    },\n    end: function() {\n      return this.edge.l === this.site ? this.edge.b : this.edge.a;\n    }\n  };\n  function d3_geom_voronoiRedBlackTree() {\n    this._ = null;\n  }\n  function d3_geom_voronoiRedBlackNode(node) {\n    node.U = node.C = node.L = node.R = node.P = node.N = null;\n  }\n  d3_geom_voronoiRedBlackTree.prototype = {\n    insert: function(after, node) {\n      var parent, grandpa, uncle;\n      if (after) {\n        node.P = after;\n        node.N = after.N;\n        if (after.N) after.N.P = node;\n        after.N = node;\n        if (after.R) {\n          after = after.R;\n          while (after.L) after = after.L;\n          after.L = node;\n        } else {\n          after.R = node;\n        }\n        parent = after;\n      } else if (this._) {\n        after = d3_geom_voronoiRedBlackFirst(this._);\n        node.P = null;\n        node.N = after;\n        after.P = after.L = node;\n        parent = after;\n      } else {\n        node.P = node.N = null;\n        this._ = node;\n        parent = null;\n      }\n      node.L = node.R = null;\n      node.U = parent;\n      node.C = true;\n      after = node;\n      while (parent && parent.C) {\n        grandpa = parent.U;\n        if (parent === grandpa.L) {\n          uncle = grandpa.R;\n          if (uncle && uncle.C) {\n            parent.C = uncle.C = false;\n            grandpa.C = true;\n            after = grandpa;\n          } else {\n            if (after === parent.R) {\n              d3_geom_voronoiRedBlackRotateLeft(this, parent);\n              after = parent;\n              parent = after.U;\n            }\n            parent.C = false;\n            grandpa.C = true;\n            d3_geom_voronoiRedBlackRotateRight(this, grandpa);\n          }\n        } else {\n          uncle = grandpa.L;\n          if (uncle && uncle.C) {\n            parent.C = uncle.C = false;\n            grandpa.C = true;\n            after = grandpa;\n          } else {\n            if (after === parent.L) {\n              d3_geom_voronoiRedBlackRotateRight(this, parent);\n              after = parent;\n              parent = after.U;\n            }\n            parent.C = false;\n            grandpa.C = true;\n            d3_geom_voronoiRedBlackRotateLeft(this, grandpa);\n          }\n        }\n        parent = after.U;\n      }\n      this._.C = false;\n    },\n    remove: function(node) {\n      if (node.N) node.N.P = node.P;\n      if (node.P) node.P.N = node.N;\n      node.N = node.P = null;\n      var parent = node.U, sibling, left = node.L, right = node.R, next, red;\n      if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right);\n      if (parent) {\n        if (parent.L === node) parent.L = next; else parent.R = next;\n      } else {\n        this._ = next;\n      }\n      if (left && right) {\n        red = next.C;\n        next.C = node.C;\n        next.L = left;\n        left.U = next;\n        if (next !== right) {\n          parent = next.U;\n          next.U = node.U;\n          node = next.R;\n          parent.L = node;\n          next.R = right;\n          right.U = next;\n        } else {\n          next.U = parent;\n          parent = next;\n          node = next.R;\n        }\n      } else {\n        red = node.C;\n        node = next;\n      }\n      if (node) node.U = parent;\n      if (red) return;\n      if (node && node.C) {\n        node.C = false;\n        return;\n      }\n      do {\n        if (node === this._) break;\n        if (node === parent.L) {\n          sibling = parent.R;\n          if (sibling.C) {\n            sibling.C = false;\n            parent.C = true;\n            d3_geom_voronoiRedBlackRotateLeft(this, parent);\n            sibling = parent.R;\n          }\n          if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n            if (!sibling.R || !sibling.R.C) {\n              sibling.L.C = false;\n              sibling.C = true;\n              d3_geom_voronoiRedBlackRotateRight(this, sibling);\n              sibling = parent.R;\n            }\n            sibling.C = parent.C;\n            parent.C = sibling.R.C = false;\n            d3_geom_voronoiRedBlackRotateLeft(this, parent);\n            node = this._;\n            break;\n          }\n        } else {\n          sibling = parent.L;\n          if (sibling.C) {\n            sibling.C = false;\n            parent.C = true;\n            d3_geom_voronoiRedBlackRotateRight(this, parent);\n            sibling = parent.L;\n          }\n          if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) {\n            if (!sibling.L || !sibling.L.C) {\n              sibling.R.C = false;\n              sibling.C = true;\n              d3_geom_voronoiRedBlackRotateLeft(this, sibling);\n              sibling = parent.L;\n            }\n            sibling.C = parent.C;\n            parent.C = sibling.L.C = false;\n            d3_geom_voronoiRedBlackRotateRight(this, parent);\n            node = this._;\n            break;\n          }\n        }\n        sibling.C = true;\n        node = parent;\n        parent = parent.U;\n      } while (!node.C);\n      if (node) node.C = false;\n    }\n  };\n  function d3_geom_voronoiRedBlackRotateLeft(tree, node) {\n    var p = node, q = node.R, parent = p.U;\n    if (parent) {\n      if (parent.L === p) parent.L = q; else parent.R = q;\n    } else {\n      tree._ = q;\n    }\n    q.U = parent;\n    p.U = q;\n    p.R = q.L;\n    if (p.R) p.R.U = p;\n    q.L = p;\n  }\n  function d3_geom_voronoiRedBlackRotateRight(tree, node) {\n    var p = node, q = node.L, parent = p.U;\n    if (parent) {\n      if (parent.L === p) parent.L = q; else parent.R = q;\n    } else {\n      tree._ = q;\n    }\n    q.U = parent;\n    p.U = q;\n    p.L = q.R;\n    if (p.L) p.L.U = p;\n    q.R = p;\n  }\n  function d3_geom_voronoiRedBlackFirst(node) {\n    while (node.L) node = node.L;\n    return node;\n  }\n  function d3_geom_voronoi(sites, bbox) {\n    var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle;\n    d3_geom_voronoiEdges = [];\n    d3_geom_voronoiCells = new Array(sites.length);\n    d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree();\n    d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree();\n    while (true) {\n      circle = d3_geom_voronoiFirstCircle;\n      if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) {\n        if (site.x !== x0 || site.y !== y0) {\n          d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site);\n          d3_geom_voronoiAddBeach(site);\n          x0 = site.x, y0 = site.y;\n        }\n        site = sites.pop();\n      } else if (circle) {\n        d3_geom_voronoiRemoveBeach(circle.arc);\n      } else {\n        break;\n      }\n    }\n    if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);\n    var diagram = {\n      cells: d3_geom_voronoiCells,\n      edges: d3_geom_voronoiEdges\n    };\n    d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null;\n    return diagram;\n  }\n  function d3_geom_voronoiVertexOrder(a, b) {\n    return b.y - a.y || b.x - a.x;\n  }\n  d3.geom.voronoi = function(points) {\n    var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;\n    if (points) return voronoi(points);\n    function voronoi(data) {\n      var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1];\n      d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {\n        var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) {\n          var s = e.start();\n          return [ s.x, s.y ];\n        }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : [];\n        polygon.point = data[i];\n      });\n      return polygons;\n    }\n    function sites(data) {\n      return data.map(function(d, i) {\n        return {\n          x: Math.round(fx(d, i) / ε) * ε,\n          y: Math.round(fy(d, i) / ε) * ε,\n          i: i\n        };\n      });\n    }\n    voronoi.links = function(data) {\n      return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {\n        return edge.l && edge.r;\n      }).map(function(edge) {\n        return {\n          source: data[edge.l.i],\n          target: data[edge.r.i]\n        };\n      });\n    };\n    voronoi.triangles = function(data) {\n      var triangles = [];\n      d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) {\n        var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l;\n        while (++j < m) {\n          e0 = e1;\n          s0 = s1;\n          e1 = edges[j].edge;\n          s1 = e1.l === site ? e1.r : e1.l;\n          if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) {\n            triangles.push([ data[i], data[s0.i], data[s1.i] ]);\n          }\n        }\n      });\n      return triangles;\n    };\n    voronoi.x = function(_) {\n      return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;\n    };\n    voronoi.y = function(_) {\n      return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;\n    };\n    voronoi.clipExtent = function(_) {\n      if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;\n      clipExtent = _ == null ? d3_geom_voronoiClipExtent : _;\n      return voronoi;\n    };\n    voronoi.size = function(_) {\n      if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1];\n      return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]);\n    };\n    return voronoi;\n  };\n  var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ];\n  function d3_geom_voronoiTriangleArea(a, b, c) {\n    return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y);\n  }\n  d3.geom.delaunay = function(vertices) {\n    return d3.geom.voronoi().triangles(vertices);\n  };\n  d3.geom.quadtree = function(points, x1, y1, x2, y2) {\n    var x = d3_geom_pointX, y = d3_geom_pointY, compat;\n    if (compat = arguments.length) {\n      x = d3_geom_quadtreeCompatX;\n      y = d3_geom_quadtreeCompatY;\n      if (compat === 3) {\n        y2 = y1;\n        x2 = x1;\n        y1 = x1 = 0;\n      }\n      return quadtree(points);\n    }\n    function quadtree(data) {\n      var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_;\n      if (x1 != null) {\n        x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2;\n      } else {\n        x2_ = y2_ = -(x1_ = y1_ = Infinity);\n        xs = [], ys = [];\n        n = data.length;\n        if (compat) for (i = 0; i < n; ++i) {\n          d = data[i];\n          if (d.x < x1_) x1_ = d.x;\n          if (d.y < y1_) y1_ = d.y;\n          if (d.x > x2_) x2_ = d.x;\n          if (d.y > y2_) y2_ = d.y;\n          xs.push(d.x);\n          ys.push(d.y);\n        } else for (i = 0; i < n; ++i) {\n          var x_ = +fx(d = data[i], i), y_ = +fy(d, i);\n          if (x_ < x1_) x1_ = x_;\n          if (y_ < y1_) y1_ = y_;\n          if (x_ > x2_) x2_ = x_;\n          if (y_ > y2_) y2_ = y_;\n          xs.push(x_);\n          ys.push(y_);\n        }\n      }\n      var dx = x2_ - x1_, dy = y2_ - y1_;\n      if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy;\n      function insert(n, d, x, y, x1, y1, x2, y2) {\n        if (isNaN(x) || isNaN(y)) return;\n        if (n.leaf) {\n          var nx = n.x, ny = n.y;\n          if (nx != null) {\n            if (abs(nx - x) + abs(ny - y) < .01) {\n              insertChild(n, d, x, y, x1, y1, x2, y2);\n            } else {\n              var nPoint = n.point;\n              n.x = n.y = n.point = null;\n              insertChild(n, nPoint, nx, ny, x1, y1, x2, y2);\n              insertChild(n, d, x, y, x1, y1, x2, y2);\n            }\n          } else {\n            n.x = x, n.y = y, n.point = d;\n          }\n        } else {\n          insertChild(n, d, x, y, x1, y1, x2, y2);\n        }\n      }\n      function insertChild(n, d, x, y, x1, y1, x2, y2) {\n        var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right;\n        n.leaf = false;\n        n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());\n        if (right) x1 = xm; else x2 = xm;\n        if (below) y1 = ym; else y2 = ym;\n        insert(n, d, x, y, x1, y1, x2, y2);\n      }\n      var root = d3_geom_quadtreeNode();\n      root.add = function(d) {\n        insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_);\n      };\n      root.visit = function(f) {\n        d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_);\n      };\n      root.find = function(point) {\n        return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_);\n      };\n      i = -1;\n      if (x1 == null) {\n        while (++i < n) {\n          insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_);\n        }\n        --i;\n      } else data.forEach(root.add);\n      xs = ys = data = d = null;\n      return root;\n    }\n    quadtree.x = function(_) {\n      return arguments.length ? (x = _, quadtree) : x;\n    };\n    quadtree.y = function(_) {\n      return arguments.length ? (y = _, quadtree) : y;\n    };\n    quadtree.extent = function(_) {\n      if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];\n      if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], \n      y2 = +_[1][1];\n      return quadtree;\n    };\n    quadtree.size = function(_) {\n      if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ];\n      if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1];\n      return quadtree;\n    };\n    return quadtree;\n  };\n  function d3_geom_quadtreeCompatX(d) {\n    return d.x;\n  }\n  function d3_geom_quadtreeCompatY(d) {\n    return d.y;\n  }\n  function d3_geom_quadtreeNode() {\n    return {\n      leaf: true,\n      nodes: [],\n      point: null,\n      x: null,\n      y: null\n    };\n  }\n  function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {\n    if (!f(node, x1, y1, x2, y2)) {\n      var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;\n      if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);\n      if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);\n      if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);\n      if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);\n    }\n  }\n  function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) {\n    var minDistance2 = Infinity, closestPoint;\n    (function find(node, x1, y1, x2, y2) {\n      if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return;\n      if (point = node.point) {\n        var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy;\n        if (distance2 < minDistance2) {\n          var distance = Math.sqrt(minDistance2 = distance2);\n          x0 = x - distance, y0 = y - distance;\n          x3 = x + distance, y3 = y + distance;\n          closestPoint = point;\n        }\n      }\n      var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym;\n      for (var i = below << 1 | right, j = i + 4; i < j; ++i) {\n        if (node = children[i & 3]) switch (i & 3) {\n         case 0:\n          find(node, x1, y1, xm, ym);\n          break;\n\n         case 1:\n          find(node, xm, y1, x2, ym);\n          break;\n\n         case 2:\n          find(node, x1, ym, xm, y2);\n          break;\n\n         case 3:\n          find(node, xm, ym, x2, y2);\n          break;\n        }\n      }\n    })(root, x0, y0, x3, y3);\n    return closestPoint;\n  }\n  d3.interpolateRgb = d3_interpolateRgb;\n  function d3_interpolateRgb(a, b) {\n    a = d3.rgb(a);\n    b = d3.rgb(b);\n    var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;\n    return function(t) {\n      return \"#\" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t));\n    };\n  }\n  d3.interpolateObject = d3_interpolateObject;\n  function d3_interpolateObject(a, b) {\n    var i = {}, c = {}, k;\n    for (k in a) {\n      if (k in b) {\n        i[k] = d3_interpolate(a[k], b[k]);\n      } else {\n        c[k] = a[k];\n      }\n    }\n    for (k in b) {\n      if (!(k in a)) {\n        c[k] = b[k];\n      }\n    }\n    return function(t) {\n      for (k in i) c[k] = i[k](t);\n      return c;\n    };\n  }\n  d3.interpolateNumber = d3_interpolateNumber;\n  function d3_interpolateNumber(a, b) {\n    a = +a, b = +b;\n    return function(t) {\n      return a * (1 - t) + b * t;\n    };\n  }\n  d3.interpolateString = d3_interpolateString;\n  function d3_interpolateString(a, b) {\n    var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = [];\n    a = a + \"\", b = b + \"\";\n    while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) {\n      if ((bs = bm.index) > bi) {\n        bs = b.slice(bi, bs);\n        if (s[i]) s[i] += bs; else s[++i] = bs;\n      }\n      if ((am = am[0]) === (bm = bm[0])) {\n        if (s[i]) s[i] += bm; else s[++i] = bm;\n      } else {\n        s[++i] = null;\n        q.push({\n          i: i,\n          x: d3_interpolateNumber(am, bm)\n        });\n      }\n      bi = d3_interpolate_numberB.lastIndex;\n    }\n    if (bi < b.length) {\n      bs = b.slice(bi);\n      if (s[i]) s[i] += bs; else s[++i] = bs;\n    }\n    return s.length < 2 ? q[0] ? (b = q[0].x, function(t) {\n      return b(t) + \"\";\n    }) : function() {\n      return b;\n    } : (b = q.length, function(t) {\n      for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t);\n      return s.join(\"\");\n    });\n  }\n  var d3_interpolate_numberA = /[-+]?(?:\\d+\\.?\\d*|\\.?\\d+)(?:[eE][-+]?\\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, \"g\");\n  d3.interpolate = d3_interpolate;\n  function d3_interpolate(a, b) {\n    var i = d3.interpolators.length, f;\n    while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;\n    return f;\n  }\n  d3.interpolators = [ function(a, b) {\n    var t = typeof b;\n    return (t === \"string\" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\\(|hsl\\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === \"object\" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b);\n  } ];\n  d3.interpolateArray = d3_interpolateArray;\n  function d3_interpolateArray(a, b) {\n    var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;\n    for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i]));\n    for (;i < na; ++i) c[i] = a[i];\n    for (;i < nb; ++i) c[i] = b[i];\n    return function(t) {\n      for (i = 0; i < n0; ++i) c[i] = x[i](t);\n      return c;\n    };\n  }\n  var d3_ease_default = function() {\n    return d3_identity;\n  };\n  var d3_ease = d3.map({\n    linear: d3_ease_default,\n    poly: d3_ease_poly,\n    quad: function() {\n      return d3_ease_quad;\n    },\n    cubic: function() {\n      return d3_ease_cubic;\n    },\n    sin: function() {\n      return d3_ease_sin;\n    },\n    exp: function() {\n      return d3_ease_exp;\n    },\n    circle: function() {\n      return d3_ease_circle;\n    },\n    elastic: d3_ease_elastic,\n    back: d3_ease_back,\n    bounce: function() {\n      return d3_ease_bounce;\n    }\n  });\n  var d3_ease_mode = d3.map({\n    \"in\": d3_identity,\n    out: d3_ease_reverse,\n    \"in-out\": d3_ease_reflect,\n    \"out-in\": function(f) {\n      return d3_ease_reflect(d3_ease_reverse(f));\n    }\n  });\n  d3.ease = function(name) {\n    var i = name.indexOf(\"-\"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : \"in\";\n    t = d3_ease.get(t) || d3_ease_default;\n    m = d3_ease_mode.get(m) || d3_identity;\n    return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1))));\n  };\n  function d3_ease_clamp(f) {\n    return function(t) {\n      return t <= 0 ? 0 : t >= 1 ? 1 : f(t);\n    };\n  }\n  function d3_ease_reverse(f) {\n    return function(t) {\n      return 1 - f(1 - t);\n    };\n  }\n  function d3_ease_reflect(f) {\n    return function(t) {\n      return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));\n    };\n  }\n  function d3_ease_quad(t) {\n    return t * t;\n  }\n  function d3_ease_cubic(t) {\n    return t * t * t;\n  }\n  function d3_ease_cubicInOut(t) {\n    if (t <= 0) return 0;\n    if (t >= 1) return 1;\n    var t2 = t * t, t3 = t2 * t;\n    return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);\n  }\n  function d3_ease_poly(e) {\n    return function(t) {\n      return Math.pow(t, e);\n    };\n  }\n  function d3_ease_sin(t) {\n    return 1 - Math.cos(t * halfπ);\n  }\n  function d3_ease_exp(t) {\n    return Math.pow(2, 10 * (t - 1));\n  }\n  function d3_ease_circle(t) {\n    return 1 - Math.sqrt(1 - t * t);\n  }\n  function d3_ease_elastic(a, p) {\n    var s;\n    if (arguments.length < 2) p = .45;\n    if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4;\n    return function(t) {\n      return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p);\n    };\n  }\n  function d3_ease_back(s) {\n    if (!s) s = 1.70158;\n    return function(t) {\n      return t * t * ((s + 1) * t - s);\n    };\n  }\n  function d3_ease_bounce(t) {\n    return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;\n  }\n  d3.interpolateHcl = d3_interpolateHcl;\n  function d3_interpolateHcl(a, b) {\n    a = d3.hcl(a);\n    b = d3.hcl(b);\n    var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;\n    if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;\n    if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n    return function(t) {\n      return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + \"\";\n    };\n  }\n  d3.interpolateHsl = d3_interpolateHsl;\n  function d3_interpolateHsl(a, b) {\n    a = d3.hsl(a);\n    b = d3.hsl(b);\n    var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;\n    if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;\n    if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;\n    return function(t) {\n      return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + \"\";\n    };\n  }\n  d3.interpolateLab = d3_interpolateLab;\n  function d3_interpolateLab(a, b) {\n    a = d3.lab(a);\n    b = d3.lab(b);\n    var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;\n    return function(t) {\n      return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + \"\";\n    };\n  }\n  d3.interpolateRound = d3_interpolateRound;\n  function d3_interpolateRound(a, b) {\n    b -= a;\n    return function(t) {\n      return Math.round(a + b * t);\n    };\n  }\n  d3.transform = function(string) {\n    var g = d3_document.createElementNS(d3.ns.prefix.svg, \"g\");\n    return (d3.transform = function(string) {\n      if (string != null) {\n        g.setAttribute(\"transform\", string);\n        var t = g.transform.baseVal.consolidate();\n      }\n      return new d3_transform(t ? t.matrix : d3_transformIdentity);\n    })(string);\n  };\n  function d3_transform(m) {\n    var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;\n    if (r0[0] * r1[1] < r1[0] * r0[1]) {\n      r0[0] *= -1;\n      r0[1] *= -1;\n      kx *= -1;\n      kz *= -1;\n    }\n    this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;\n    this.translate = [ m.e, m.f ];\n    this.scale = [ kx, ky ];\n    this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;\n  }\n  d3_transform.prototype.toString = function() {\n    return \"translate(\" + this.translate + \")rotate(\" + this.rotate + \")skewX(\" + this.skew + \")scale(\" + this.scale + \")\";\n  };\n  function d3_transformDot(a, b) {\n    return a[0] * b[0] + a[1] * b[1];\n  }\n  function d3_transformNormalize(a) {\n    var k = Math.sqrt(d3_transformDot(a, a));\n    if (k) {\n      a[0] /= k;\n      a[1] /= k;\n    }\n    return k;\n  }\n  function d3_transformCombine(a, b, k) {\n    a[0] += k * b[0];\n    a[1] += k * b[1];\n    return a;\n  }\n  var d3_transformIdentity = {\n    a: 1,\n    b: 0,\n    c: 0,\n    d: 1,\n    e: 0,\n    f: 0\n  };\n  d3.interpolateTransform = d3_interpolateTransform;\n  function d3_interpolateTransformPop(s) {\n    return s.length ? s.pop() + \",\" : \"\";\n  }\n  function d3_interpolateTranslate(ta, tb, s, q) {\n    if (ta[0] !== tb[0] || ta[1] !== tb[1]) {\n      var i = s.push(\"translate(\", null, \",\", null, \")\");\n      q.push({\n        i: i - 4,\n        x: d3_interpolateNumber(ta[0], tb[0])\n      }, {\n        i: i - 2,\n        x: d3_interpolateNumber(ta[1], tb[1])\n      });\n    } else if (tb[0] || tb[1]) {\n      s.push(\"translate(\" + tb + \")\");\n    }\n  }\n  function d3_interpolateRotate(ra, rb, s, q) {\n    if (ra !== rb) {\n      if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;\n      q.push({\n        i: s.push(d3_interpolateTransformPop(s) + \"rotate(\", null, \")\") - 2,\n        x: d3_interpolateNumber(ra, rb)\n      });\n    } else if (rb) {\n      s.push(d3_interpolateTransformPop(s) + \"rotate(\" + rb + \")\");\n    }\n  }\n  function d3_interpolateSkew(wa, wb, s, q) {\n    if (wa !== wb) {\n      q.push({\n        i: s.push(d3_interpolateTransformPop(s) + \"skewX(\", null, \")\") - 2,\n        x: d3_interpolateNumber(wa, wb)\n      });\n    } else if (wb) {\n      s.push(d3_interpolateTransformPop(s) + \"skewX(\" + wb + \")\");\n    }\n  }\n  function d3_interpolateScale(ka, kb, s, q) {\n    if (ka[0] !== kb[0] || ka[1] !== kb[1]) {\n      var i = s.push(d3_interpolateTransformPop(s) + \"scale(\", null, \",\", null, \")\");\n      q.push({\n        i: i - 4,\n        x: d3_interpolateNumber(ka[0], kb[0])\n      }, {\n        i: i - 2,\n        x: d3_interpolateNumber(ka[1], kb[1])\n      });\n    } else if (kb[0] !== 1 || kb[1] !== 1) {\n      s.push(d3_interpolateTransformPop(s) + \"scale(\" + kb + \")\");\n    }\n  }\n  function d3_interpolateTransform(a, b) {\n    var s = [], q = [];\n    a = d3.transform(a), b = d3.transform(b);\n    d3_interpolateTranslate(a.translate, b.translate, s, q);\n    d3_interpolateRotate(a.rotate, b.rotate, s, q);\n    d3_interpolateSkew(a.skew, b.skew, s, q);\n    d3_interpolateScale(a.scale, b.scale, s, q);\n    a = b = null;\n    return function(t) {\n      var i = -1, n = q.length, o;\n      while (++i < n) s[(o = q[i]).i] = o.x(t);\n      return s.join(\"\");\n    };\n  }\n  function d3_uninterpolateNumber(a, b) {\n    b = (b -= a = +a) || 1 / b;\n    return function(x) {\n      return (x - a) / b;\n    };\n  }\n  function d3_uninterpolateClamp(a, b) {\n    b = (b -= a = +a) || 1 / b;\n    return function(x) {\n      return Math.max(0, Math.min(1, (x - a) / b));\n    };\n  }\n  d3.layout = {};\n  d3.layout.bundle = function() {\n    return function(links) {\n      var paths = [], i = -1, n = links.length;\n      while (++i < n) paths.push(d3_layout_bundlePath(links[i]));\n      return paths;\n    };\n  };\n  function d3_layout_bundlePath(link) {\n    var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];\n    while (start !== lca) {\n      start = start.parent;\n      points.push(start);\n    }\n    var k = points.length;\n    while (end !== lca) {\n      points.splice(k, 0, end);\n      end = end.parent;\n    }\n    return points;\n  }\n  function d3_layout_bundleAncestors(node) {\n    var ancestors = [], parent = node.parent;\n    while (parent != null) {\n      ancestors.push(node);\n      node = parent;\n      parent = parent.parent;\n    }\n    ancestors.push(node);\n    return ancestors;\n  }\n  function d3_layout_bundleLeastCommonAncestor(a, b) {\n    if (a === b) return a;\n    var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;\n    while (aNode === bNode) {\n      sharedNode = aNode;\n      aNode = aNodes.pop();\n      bNode = bNodes.pop();\n    }\n    return sharedNode;\n  }\n  d3.layout.chord = function() {\n    var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;\n    function relayout() {\n      var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;\n      chords = [];\n      groups = [];\n      k = 0, i = -1;\n      while (++i < n) {\n        x = 0, j = -1;\n        while (++j < n) {\n          x += matrix[i][j];\n        }\n        groupSums.push(x);\n        subgroupIndex.push(d3.range(n));\n        k += x;\n      }\n      if (sortGroups) {\n        groupIndex.sort(function(a, b) {\n          return sortGroups(groupSums[a], groupSums[b]);\n        });\n      }\n      if (sortSubgroups) {\n        subgroupIndex.forEach(function(d, i) {\n          d.sort(function(a, b) {\n            return sortSubgroups(matrix[i][a], matrix[i][b]);\n          });\n        });\n      }\n      k = (τ - padding * n) / k;\n      x = 0, i = -1;\n      while (++i < n) {\n        x0 = x, j = -1;\n        while (++j < n) {\n          var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;\n          subgroups[di + \"-\" + dj] = {\n            index: di,\n            subindex: dj,\n            startAngle: a0,\n            endAngle: a1,\n            value: v\n          };\n        }\n        groups[di] = {\n          index: di,\n          startAngle: x0,\n          endAngle: x,\n          value: groupSums[di]\n        };\n        x += padding;\n      }\n      i = -1;\n      while (++i < n) {\n        j = i - 1;\n        while (++j < n) {\n          var source = subgroups[i + \"-\" + j], target = subgroups[j + \"-\" + i];\n          if (source.value || target.value) {\n            chords.push(source.value < target.value ? {\n              source: target,\n              target: source\n            } : {\n              source: source,\n              target: target\n            });\n          }\n        }\n      }\n      if (sortChords) resort();\n    }\n    function resort() {\n      chords.sort(function(a, b) {\n        return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);\n      });\n    }\n    chord.matrix = function(x) {\n      if (!arguments.length) return matrix;\n      n = (matrix = x) && matrix.length;\n      chords = groups = null;\n      return chord;\n    };\n    chord.padding = function(x) {\n      if (!arguments.length) return padding;\n      padding = x;\n      chords = groups = null;\n      return chord;\n    };\n    chord.sortGroups = function(x) {\n      if (!arguments.length) return sortGroups;\n      sortGroups = x;\n      chords = groups = null;\n      return chord;\n    };\n    chord.sortSubgroups = function(x) {\n      if (!arguments.length) return sortSubgroups;\n      sortSubgroups = x;\n      chords = null;\n      return chord;\n    };\n    chord.sortChords = function(x) {\n      if (!arguments.length) return sortChords;\n      sortChords = x;\n      if (chords) resort();\n      return chord;\n    };\n    chord.chords = function() {\n      if (!chords) relayout();\n      return chords;\n    };\n    chord.groups = function() {\n      if (!groups) relayout();\n      return groups;\n    };\n    return chord;\n  };\n  d3.layout.force = function() {\n    var force = {}, event = d3.dispatch(\"start\", \"tick\", \"end\"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges;\n    function repulse(node) {\n      return function(quad, x1, _, x2) {\n        if (quad.point !== node) {\n          var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy;\n          if (dw * dw / theta2 < dn) {\n            if (dn < chargeDistance2) {\n              var k = quad.charge / dn;\n              node.px -= dx * k;\n              node.py -= dy * k;\n            }\n            return true;\n          }\n          if (quad.point && dn && dn < chargeDistance2) {\n            var k = quad.pointCharge / dn;\n            node.px -= dx * k;\n            node.py -= dy * k;\n          }\n        }\n        return !quad.charge;\n      };\n    }\n    force.tick = function() {\n      if ((alpha *= .99) < .005) {\n        timer = null;\n        event.end({\n          type: \"end\",\n          alpha: alpha = 0\n        });\n        return true;\n      }\n      var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;\n      for (i = 0; i < m; ++i) {\n        o = links[i];\n        s = o.source;\n        t = o.target;\n        x = t.x - s.x;\n        y = t.y - s.y;\n        if (l = x * x + y * y) {\n          l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;\n          x *= l;\n          y *= l;\n          t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5);\n          t.y -= y * k;\n          s.x += x * (k = 1 - k);\n          s.y += y * k;\n        }\n      }\n      if (k = alpha * gravity) {\n        x = size[0] / 2;\n        y = size[1] / 2;\n        i = -1;\n        if (k) while (++i < n) {\n          o = nodes[i];\n          o.x += (x - o.x) * k;\n          o.y += (y - o.y) * k;\n        }\n      }\n      if (charge) {\n        d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);\n        i = -1;\n        while (++i < n) {\n          if (!(o = nodes[i]).fixed) {\n            q.visit(repulse(o));\n          }\n        }\n      }\n      i = -1;\n      while (++i < n) {\n        o = nodes[i];\n        if (o.fixed) {\n          o.x = o.px;\n          o.y = o.py;\n        } else {\n          o.x -= (o.px - (o.px = o.x)) * friction;\n          o.y -= (o.py - (o.py = o.y)) * friction;\n        }\n      }\n      event.tick({\n        type: \"tick\",\n        alpha: alpha\n      });\n    };\n    force.nodes = function(x) {\n      if (!arguments.length) return nodes;\n      nodes = x;\n      return force;\n    };\n    force.links = function(x) {\n      if (!arguments.length) return links;\n      links = x;\n      return force;\n    };\n    force.size = function(x) {\n      if (!arguments.length) return size;\n      size = x;\n      return force;\n    };\n    force.linkDistance = function(x) {\n      if (!arguments.length) return linkDistance;\n      linkDistance = typeof x === \"function\" ? x : +x;\n      return force;\n    };\n    force.distance = force.linkDistance;\n    force.linkStrength = function(x) {\n      if (!arguments.length) return linkStrength;\n      linkStrength = typeof x === \"function\" ? x : +x;\n      return force;\n    };\n    force.friction = function(x) {\n      if (!arguments.length) return friction;\n      friction = +x;\n      return force;\n    };\n    force.charge = function(x) {\n      if (!arguments.length) return charge;\n      charge = typeof x === \"function\" ? x : +x;\n      return force;\n    };\n    force.chargeDistance = function(x) {\n      if (!arguments.length) return Math.sqrt(chargeDistance2);\n      chargeDistance2 = x * x;\n      return force;\n    };\n    force.gravity = function(x) {\n      if (!arguments.length) return gravity;\n      gravity = +x;\n      return force;\n    };\n    force.theta = function(x) {\n      if (!arguments.length) return Math.sqrt(theta2);\n      theta2 = x * x;\n      return force;\n    };\n    force.alpha = function(x) {\n      if (!arguments.length) return alpha;\n      x = +x;\n      if (alpha) {\n        if (x > 0) {\n          alpha = x;\n        } else {\n          timer.c = null, timer.t = NaN, timer = null;\n          event.end({\n            type: \"end\",\n            alpha: alpha = 0\n          });\n        }\n      } else if (x > 0) {\n        event.start({\n          type: \"start\",\n          alpha: alpha = x\n        });\n        timer = d3_timer(force.tick);\n      }\n      return force;\n    };\n    force.start = function() {\n      var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;\n      for (i = 0; i < n; ++i) {\n        (o = nodes[i]).index = i;\n        o.weight = 0;\n      }\n      for (i = 0; i < m; ++i) {\n        o = links[i];\n        if (typeof o.source == \"number\") o.source = nodes[o.source];\n        if (typeof o.target == \"number\") o.target = nodes[o.target];\n        ++o.source.weight;\n        ++o.target.weight;\n      }\n      for (i = 0; i < n; ++i) {\n        o = nodes[i];\n        if (isNaN(o.x)) o.x = position(\"x\", w);\n        if (isNaN(o.y)) o.y = position(\"y\", h);\n        if (isNaN(o.px)) o.px = o.x;\n        if (isNaN(o.py)) o.py = o.y;\n      }\n      distances = [];\n      if (typeof linkDistance === \"function\") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance;\n      strengths = [];\n      if (typeof linkStrength === \"function\") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength;\n      charges = [];\n      if (typeof charge === \"function\") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge;\n      function position(dimension, size) {\n        if (!neighbors) {\n          neighbors = new Array(n);\n          for (j = 0; j < n; ++j) {\n            neighbors[j] = [];\n          }\n          for (j = 0; j < m; ++j) {\n            var o = links[j];\n            neighbors[o.source.index].push(o.target);\n            neighbors[o.target.index].push(o.source);\n          }\n        }\n        var candidates = neighbors[i], j = -1, l = candidates.length, x;\n        while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x;\n        return Math.random() * size;\n      }\n      return force.resume();\n    };\n    force.resume = function() {\n      return force.alpha(.1);\n    };\n    force.stop = function() {\n      return force.alpha(0);\n    };\n    force.drag = function() {\n      if (!drag) drag = d3.behavior.drag().origin(d3_identity).on(\"dragstart.force\", d3_layout_forceDragstart).on(\"drag.force\", dragmove).on(\"dragend.force\", d3_layout_forceDragend);\n      if (!arguments.length) return drag;\n      this.on(\"mouseover.force\", d3_layout_forceMouseover).on(\"mouseout.force\", d3_layout_forceMouseout).call(drag);\n    };\n    function dragmove(d) {\n      d.px = d3.event.x, d.py = d3.event.y;\n      force.resume();\n    }\n    return d3.rebind(force, event, \"on\");\n  };\n  function d3_layout_forceDragstart(d) {\n    d.fixed |= 2;\n  }\n  function d3_layout_forceDragend(d) {\n    d.fixed &= ~6;\n  }\n  function d3_layout_forceMouseover(d) {\n    d.fixed |= 4;\n    d.px = d.x, d.py = d.y;\n  }\n  function d3_layout_forceMouseout(d) {\n    d.fixed &= ~4;\n  }\n  function d3_layout_forceAccumulate(quad, alpha, charges) {\n    var cx = 0, cy = 0;\n    quad.charge = 0;\n    if (!quad.leaf) {\n      var nodes = quad.nodes, n = nodes.length, i = -1, c;\n      while (++i < n) {\n        c = nodes[i];\n        if (c == null) continue;\n        d3_layout_forceAccumulate(c, alpha, charges);\n        quad.charge += c.charge;\n        cx += c.charge * c.cx;\n        cy += c.charge * c.cy;\n      }\n    }\n    if (quad.point) {\n      if (!quad.leaf) {\n        quad.point.x += Math.random() - .5;\n        quad.point.y += Math.random() - .5;\n      }\n      var k = alpha * charges[quad.point.index];\n      quad.charge += quad.pointCharge = k;\n      cx += k * quad.point.x;\n      cy += k * quad.point.y;\n    }\n    quad.cx = cx / quad.charge;\n    quad.cy = cy / quad.charge;\n  }\n  var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity;\n  d3.layout.hierarchy = function() {\n    var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;\n    function hierarchy(root) {\n      var stack = [ root ], nodes = [], node;\n      root.depth = 0;\n      while ((node = stack.pop()) != null) {\n        nodes.push(node);\n        if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) {\n          var n, childs, child;\n          while (--n >= 0) {\n            stack.push(child = childs[n]);\n            child.parent = node;\n            child.depth = node.depth + 1;\n          }\n          if (value) node.value = 0;\n          node.children = childs;\n        } else {\n          if (value) node.value = +value.call(hierarchy, node, node.depth) || 0;\n          delete node.children;\n        }\n      }\n      d3_layout_hierarchyVisitAfter(root, function(node) {\n        var childs, parent;\n        if (sort && (childs = node.children)) childs.sort(sort);\n        if (value && (parent = node.parent)) parent.value += node.value;\n      });\n      return nodes;\n    }\n    hierarchy.sort = function(x) {\n      if (!arguments.length) return sort;\n      sort = x;\n      return hierarchy;\n    };\n    hierarchy.children = function(x) {\n      if (!arguments.length) return children;\n      children = x;\n      return hierarchy;\n    };\n    hierarchy.value = function(x) {\n      if (!arguments.length) return value;\n      value = x;\n      return hierarchy;\n    };\n    hierarchy.revalue = function(root) {\n      if (value) {\n        d3_layout_hierarchyVisitBefore(root, function(node) {\n          if (node.children) node.value = 0;\n        });\n        d3_layout_hierarchyVisitAfter(root, function(node) {\n          var parent;\n          if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;\n          if (parent = node.parent) parent.value += node.value;\n        });\n      }\n      return root;\n    };\n    return hierarchy;\n  };\n  function d3_layout_hierarchyRebind(object, hierarchy) {\n    d3.rebind(object, hierarchy, \"sort\", \"children\", \"value\");\n    object.nodes = object;\n    object.links = d3_layout_hierarchyLinks;\n    return object;\n  }\n  function d3_layout_hierarchyVisitBefore(node, callback) {\n    var nodes = [ node ];\n    while ((node = nodes.pop()) != null) {\n      callback(node);\n      if ((children = node.children) && (n = children.length)) {\n        var n, children;\n        while (--n >= 0) nodes.push(children[n]);\n      }\n    }\n  }\n  function d3_layout_hierarchyVisitAfter(node, callback) {\n    var nodes = [ node ], nodes2 = [];\n    while ((node = nodes.pop()) != null) {\n      nodes2.push(node);\n      if ((children = node.children) && (n = children.length)) {\n        var i = -1, n, children;\n        while (++i < n) nodes.push(children[i]);\n      }\n    }\n    while ((node = nodes2.pop()) != null) {\n      callback(node);\n    }\n  }\n  function d3_layout_hierarchyChildren(d) {\n    return d.children;\n  }\n  function d3_layout_hierarchyValue(d) {\n    return d.value;\n  }\n  function d3_layout_hierarchySort(a, b) {\n    return b.value - a.value;\n  }\n  function d3_layout_hierarchyLinks(nodes) {\n    return d3.merge(nodes.map(function(parent) {\n      return (parent.children || []).map(function(child) {\n        return {\n          source: parent,\n          target: child\n        };\n      });\n    }));\n  }\n  d3.layout.partition = function() {\n    var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];\n    function position(node, x, dx, dy) {\n      var children = node.children;\n      node.x = x;\n      node.y = node.depth * dy;\n      node.dx = dx;\n      node.dy = dy;\n      if (children && (n = children.length)) {\n        var i = -1, n, c, d;\n        dx = node.value ? dx / node.value : 0;\n        while (++i < n) {\n          position(c = children[i], x, d = c.value * dx, dy);\n          x += d;\n        }\n      }\n    }\n    function depth(node) {\n      var children = node.children, d = 0;\n      if (children && (n = children.length)) {\n        var i = -1, n;\n        while (++i < n) d = Math.max(d, depth(children[i]));\n      }\n      return 1 + d;\n    }\n    function partition(d, i) {\n      var nodes = hierarchy.call(this, d, i);\n      position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));\n      return nodes;\n    }\n    partition.size = function(x) {\n      if (!arguments.length) return size;\n      size = x;\n      return partition;\n    };\n    return d3_layout_hierarchyRebind(partition, hierarchy);\n  };\n  d3.layout.pie = function() {\n    var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0;\n    function pie(data) {\n      var n = data.length, values = data.map(function(d, i) {\n        return +value.call(pie, d, i);\n      }), a = +(typeof startAngle === \"function\" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === \"function\" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === \"function\" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v;\n      if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {\n        return values[j] - values[i];\n      } : function(i, j) {\n        return sort(data[i], data[j]);\n      });\n      index.forEach(function(i) {\n        arcs[i] = {\n          data: data[i],\n          value: v = values[i],\n          startAngle: a,\n          endAngle: a += v * k + pa,\n          padAngle: p\n        };\n      });\n      return arcs;\n    }\n    pie.value = function(_) {\n      if (!arguments.length) return value;\n      value = _;\n      return pie;\n    };\n    pie.sort = function(_) {\n      if (!arguments.length) return sort;\n      sort = _;\n      return pie;\n    };\n    pie.startAngle = function(_) {\n      if (!arguments.length) return startAngle;\n      startAngle = _;\n      return pie;\n    };\n    pie.endAngle = function(_) {\n      if (!arguments.length) return endAngle;\n      endAngle = _;\n      return pie;\n    };\n    pie.padAngle = function(_) {\n      if (!arguments.length) return padAngle;\n      padAngle = _;\n      return pie;\n    };\n    return pie;\n  };\n  var d3_layout_pieSortByValue = {};\n  d3.layout.stack = function() {\n    var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;\n    function stack(data, index) {\n      if (!(n = data.length)) return data;\n      var series = data.map(function(d, i) {\n        return values.call(stack, d, i);\n      });\n      var points = series.map(function(d) {\n        return d.map(function(v, i) {\n          return [ x.call(stack, v, i), y.call(stack, v, i) ];\n        });\n      });\n      var orders = order.call(stack, points, index);\n      series = d3.permute(series, orders);\n      points = d3.permute(points, orders);\n      var offsets = offset.call(stack, points, index);\n      var m = series[0].length, n, i, j, o;\n      for (j = 0; j < m; ++j) {\n        out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);\n        for (i = 1; i < n; ++i) {\n          out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);\n        }\n      }\n      return data;\n    }\n    stack.values = function(x) {\n      if (!arguments.length) return values;\n      values = x;\n      return stack;\n    };\n    stack.order = function(x) {\n      if (!arguments.length) return order;\n      order = typeof x === \"function\" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;\n      return stack;\n    };\n    stack.offset = function(x) {\n      if (!arguments.length) return offset;\n      offset = typeof x === \"function\" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;\n      return stack;\n    };\n    stack.x = function(z) {\n      if (!arguments.length) return x;\n      x = z;\n      return stack;\n    };\n    stack.y = function(z) {\n      if (!arguments.length) return y;\n      y = z;\n      return stack;\n    };\n    stack.out = function(z) {\n      if (!arguments.length) return out;\n      out = z;\n      return stack;\n    };\n    return stack;\n  };\n  function d3_layout_stackX(d) {\n    return d.x;\n  }\n  function d3_layout_stackY(d) {\n    return d.y;\n  }\n  function d3_layout_stackOut(d, y0, y) {\n    d.y0 = y0;\n    d.y = y;\n  }\n  var d3_layout_stackOrders = d3.map({\n    \"inside-out\": function(data) {\n      var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) {\n        return max[a] - max[b];\n      }), top = 0, bottom = 0, tops = [], bottoms = [];\n      for (i = 0; i < n; ++i) {\n        j = index[i];\n        if (top < bottom) {\n          top += sums[j];\n          tops.push(j);\n        } else {\n          bottom += sums[j];\n          bottoms.push(j);\n        }\n      }\n      return bottoms.reverse().concat(tops);\n    },\n    reverse: function(data) {\n      return d3.range(data.length).reverse();\n    },\n    \"default\": d3_layout_stackOrderDefault\n  });\n  var d3_layout_stackOffsets = d3.map({\n    silhouette: function(data) {\n      var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];\n      for (j = 0; j < m; ++j) {\n        for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n        if (o > max) max = o;\n        sums.push(o);\n      }\n      for (j = 0; j < m; ++j) {\n        y0[j] = (max - sums[j]) / 2;\n      }\n      return y0;\n    },\n    wiggle: function(data) {\n      var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];\n      y0[0] = o = o0 = 0;\n      for (j = 1; j < m; ++j) {\n        for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];\n        for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {\n          for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {\n            s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;\n          }\n          s2 += s3 * data[i][j][1];\n        }\n        y0[j] = o -= s1 ? s2 / s1 * dx : 0;\n        if (o < o0) o0 = o;\n      }\n      for (j = 0; j < m; ++j) y0[j] -= o0;\n      return y0;\n    },\n    expand: function(data) {\n      var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];\n      for (j = 0; j < m; ++j) {\n        for (i = 0, o = 0; i < n; i++) o += data[i][j][1];\n        if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k;\n      }\n      for (j = 0; j < m; ++j) y0[j] = 0;\n      return y0;\n    },\n    zero: d3_layout_stackOffsetZero\n  });\n  function d3_layout_stackOrderDefault(data) {\n    return d3.range(data.length);\n  }\n  function d3_layout_stackOffsetZero(data) {\n    var j = -1, m = data[0].length, y0 = [];\n    while (++j < m) y0[j] = 0;\n    return y0;\n  }\n  function d3_layout_stackMaxIndex(array) {\n    var i = 1, j = 0, v = array[0][1], k, n = array.length;\n    for (;i < n; ++i) {\n      if ((k = array[i][1]) > v) {\n        j = i;\n        v = k;\n      }\n    }\n    return j;\n  }\n  function d3_layout_stackReduceSum(d) {\n    return d.reduce(d3_layout_stackSum, 0);\n  }\n  function d3_layout_stackSum(p, d) {\n    return p + d[1];\n  }\n  d3.layout.histogram = function() {\n    var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;\n    function histogram(data, i) {\n      var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x;\n      while (++i < m) {\n        bin = bins[i] = [];\n        bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);\n        bin.y = 0;\n      }\n      if (m > 0) {\n        i = -1;\n        while (++i < n) {\n          x = values[i];\n          if (x >= range[0] && x <= range[1]) {\n            bin = bins[d3.bisect(thresholds, x, 1, m) - 1];\n            bin.y += k;\n            bin.push(data[i]);\n          }\n        }\n      }\n      return bins;\n    }\n    histogram.value = function(x) {\n      if (!arguments.length) return valuer;\n      valuer = x;\n      return histogram;\n    };\n    histogram.range = function(x) {\n      if (!arguments.length) return ranger;\n      ranger = d3_functor(x);\n      return histogram;\n    };\n    histogram.bins = function(x) {\n      if (!arguments.length) return binner;\n      binner = typeof x === \"number\" ? function(range) {\n        return d3_layout_histogramBinFixed(range, x);\n      } : d3_functor(x);\n      return histogram;\n    };\n    histogram.frequency = function(x) {\n      if (!arguments.length) return frequency;\n      frequency = !!x;\n      return histogram;\n    };\n    return histogram;\n  };\n  function d3_layout_histogramBinSturges(range, values) {\n    return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));\n  }\n  function d3_layout_histogramBinFixed(range, n) {\n    var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];\n    while (++x <= n) f[x] = m * x + b;\n    return f;\n  }\n  function d3_layout_histogramRange(values) {\n    return [ d3.min(values), d3.max(values) ];\n  }\n  d3.layout.pack = function() {\n    var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius;\n    function pack(d, i) {\n      var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === \"function\" ? radius : function() {\n        return radius;\n      };\n      root.x = root.y = 0;\n      d3_layout_hierarchyVisitAfter(root, function(d) {\n        d.r = +r(d.value);\n      });\n      d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n      if (padding) {\n        var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2;\n        d3_layout_hierarchyVisitAfter(root, function(d) {\n          d.r += dr;\n        });\n        d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings);\n        d3_layout_hierarchyVisitAfter(root, function(d) {\n          d.r -= dr;\n        });\n      }\n      d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h));\n      return nodes;\n    }\n    pack.size = function(_) {\n      if (!arguments.length) return size;\n      size = _;\n      return pack;\n    };\n    pack.radius = function(_) {\n      if (!arguments.length) return radius;\n      radius = _ == null || typeof _ === \"function\" ? _ : +_;\n      return pack;\n    };\n    pack.padding = function(_) {\n      if (!arguments.length) return padding;\n      padding = +_;\n      return pack;\n    };\n    return d3_layout_hierarchyRebind(pack, hierarchy);\n  };\n  function d3_layout_packSort(a, b) {\n    return a.value - b.value;\n  }\n  function d3_layout_packInsert(a, b) {\n    var c = a._pack_next;\n    a._pack_next = b;\n    b._pack_prev = a;\n    b._pack_next = c;\n    c._pack_prev = b;\n  }\n  function d3_layout_packSplice(a, b) {\n    a._pack_next = b;\n    b._pack_prev = a;\n  }\n  function d3_layout_packIntersects(a, b) {\n    var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;\n    return .999 * dr * dr > dx * dx + dy * dy;\n  }\n  function d3_layout_packSiblings(node) {\n    if (!(nodes = node.children) || !(n = nodes.length)) return;\n    var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;\n    function bound(node) {\n      xMin = Math.min(node.x - node.r, xMin);\n      xMax = Math.max(node.x + node.r, xMax);\n      yMin = Math.min(node.y - node.r, yMin);\n      yMax = Math.max(node.y + node.r, yMax);\n    }\n    nodes.forEach(d3_layout_packLink);\n    a = nodes[0];\n    a.x = -a.r;\n    a.y = 0;\n    bound(a);\n    if (n > 1) {\n      b = nodes[1];\n      b.x = b.r;\n      b.y = 0;\n      bound(b);\n      if (n > 2) {\n        c = nodes[2];\n        d3_layout_packPlace(a, b, c);\n        bound(c);\n        d3_layout_packInsert(a, c);\n        a._pack_prev = c;\n        d3_layout_packInsert(c, b);\n        b = a._pack_next;\n        for (i = 3; i < n; i++) {\n          d3_layout_packPlace(a, b, c = nodes[i]);\n          var isect = 0, s1 = 1, s2 = 1;\n          for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {\n            if (d3_layout_packIntersects(j, c)) {\n              isect = 1;\n              break;\n            }\n          }\n          if (isect == 1) {\n            for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {\n              if (d3_layout_packIntersects(k, c)) {\n                break;\n              }\n            }\n          }\n          if (isect) {\n            if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);\n            i--;\n          } else {\n            d3_layout_packInsert(a, c);\n            b = c;\n            bound(c);\n          }\n        }\n      }\n    }\n    var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;\n    for (i = 0; i < n; i++) {\n      c = nodes[i];\n      c.x -= cx;\n      c.y -= cy;\n      cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));\n    }\n    node.r = cr;\n    nodes.forEach(d3_layout_packUnlink);\n  }\n  function d3_layout_packLink(node) {\n    node._pack_next = node._pack_prev = node;\n  }\n  function d3_layout_packUnlink(node) {\n    delete node._pack_next;\n    delete node._pack_prev;\n  }\n  function d3_layout_packTransform(node, x, y, k) {\n    var children = node.children;\n    node.x = x += k * node.x;\n    node.y = y += k * node.y;\n    node.r *= k;\n    if (children) {\n      var i = -1, n = children.length;\n      while (++i < n) d3_layout_packTransform(children[i], x, y, k);\n    }\n  }\n  function d3_layout_packPlace(a, b, c) {\n    var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;\n    if (db && (dx || dy)) {\n      var da = b.r + c.r, dc = dx * dx + dy * dy;\n      da *= da;\n      db *= db;\n      var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);\n      c.x = a.x + x * dx + y * dy;\n      c.y = a.y + x * dy - y * dx;\n    } else {\n      c.x = a.x + db;\n      c.y = a.y;\n    }\n  }\n  d3.layout.tree = function() {\n    var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null;\n    function tree(d, i) {\n      var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0);\n      d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z;\n      d3_layout_hierarchyVisitBefore(root1, secondWalk);\n      if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else {\n        var left = root0, right = root0, bottom = root0;\n        d3_layout_hierarchyVisitBefore(root0, function(node) {\n          if (node.x < left.x) left = node;\n          if (node.x > right.x) right = node;\n          if (node.depth > bottom.depth) bottom = node;\n        });\n        var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1);\n        d3_layout_hierarchyVisitBefore(root0, function(node) {\n          node.x = (node.x + tx) * kx;\n          node.y = node.depth * ky;\n        });\n      }\n      return nodes;\n    }\n    function wrapTree(root0) {\n      var root1 = {\n        A: null,\n        children: [ root0 ]\n      }, queue = [ root1 ], node1;\n      while ((node1 = queue.pop()) != null) {\n        for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) {\n          queue.push((children[i] = child = {\n            _: children[i],\n            parent: node1,\n            children: (child = children[i].children) && child.slice() || [],\n            A: null,\n            a: null,\n            z: 0,\n            m: 0,\n            c: 0,\n            s: 0,\n            t: null,\n            i: i\n          }).a = child);\n        }\n      }\n      return root1.children[0];\n    }\n    function firstWalk(v) {\n      var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null;\n      if (children.length) {\n        d3_layout_treeShift(v);\n        var midpoint = (children[0].z + children[children.length - 1].z) / 2;\n        if (w) {\n          v.z = w.z + separation(v._, w._);\n          v.m = v.z - midpoint;\n        } else {\n          v.z = midpoint;\n        }\n      } else if (w) {\n        v.z = w.z + separation(v._, w._);\n      }\n      v.parent.A = apportion(v, w, v.parent.A || siblings[0]);\n    }\n    function secondWalk(v) {\n      v._.x = v.z + v.parent.m;\n      v.m += v.parent.m;\n    }\n    function apportion(v, w, ancestor) {\n      if (w) {\n        var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift;\n        while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {\n          vom = d3_layout_treeLeft(vom);\n          vop = d3_layout_treeRight(vop);\n          vop.a = v;\n          shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);\n          if (shift > 0) {\n            d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift);\n            sip += shift;\n            sop += shift;\n          }\n          sim += vim.m;\n          sip += vip.m;\n          som += vom.m;\n          sop += vop.m;\n        }\n        if (vim && !d3_layout_treeRight(vop)) {\n          vop.t = vim;\n          vop.m += sim - sop;\n        }\n        if (vip && !d3_layout_treeLeft(vom)) {\n          vom.t = vip;\n          vom.m += sip - som;\n          ancestor = v;\n        }\n      }\n      return ancestor;\n    }\n    function sizeNode(node) {\n      node.x *= size[0];\n      node.y = node.depth * size[1];\n    }\n    tree.separation = function(x) {\n      if (!arguments.length) return separation;\n      separation = x;\n      return tree;\n    };\n    tree.size = function(x) {\n      if (!arguments.length) return nodeSize ? null : size;\n      nodeSize = (size = x) == null ? sizeNode : null;\n      return tree;\n    };\n    tree.nodeSize = function(x) {\n      if (!arguments.length) return nodeSize ? size : null;\n      nodeSize = (size = x) == null ? null : sizeNode;\n      return tree;\n    };\n    return d3_layout_hierarchyRebind(tree, hierarchy);\n  };\n  function d3_layout_treeSeparation(a, b) {\n    return a.parent == b.parent ? 1 : 2;\n  }\n  function d3_layout_treeLeft(v) {\n    var children = v.children;\n    return children.length ? children[0] : v.t;\n  }\n  function d3_layout_treeRight(v) {\n    var children = v.children, n;\n    return (n = children.length) ? children[n - 1] : v.t;\n  }\n  function d3_layout_treeMove(wm, wp, shift) {\n    var change = shift / (wp.i - wm.i);\n    wp.c -= change;\n    wp.s += shift;\n    wm.c += change;\n    wp.z += shift;\n    wp.m += shift;\n  }\n  function d3_layout_treeShift(v) {\n    var shift = 0, change = 0, children = v.children, i = children.length, w;\n    while (--i >= 0) {\n      w = children[i];\n      w.z += shift;\n      w.m += shift;\n      shift += w.s + (change += w.c);\n    }\n  }\n  function d3_layout_treeAncestor(vim, v, ancestor) {\n    return vim.a.parent === v.parent ? vim.a : ancestor;\n  }\n  d3.layout.cluster = function() {\n    var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false;\n    function cluster(d, i) {\n      var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;\n      d3_layout_hierarchyVisitAfter(root, function(node) {\n        var children = node.children;\n        if (children && children.length) {\n          node.x = d3_layout_clusterX(children);\n          node.y = d3_layout_clusterY(children);\n        } else {\n          node.x = previousNode ? x += separation(node, previousNode) : 0;\n          node.y = 0;\n          previousNode = node;\n        }\n      });\n      var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2;\n      d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) {\n        node.x = (node.x - root.x) * size[0];\n        node.y = (root.y - node.y) * size[1];\n      } : function(node) {\n        node.x = (node.x - x0) / (x1 - x0) * size[0];\n        node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];\n      });\n      return nodes;\n    }\n    cluster.separation = function(x) {\n      if (!arguments.length) return separation;\n      separation = x;\n      return cluster;\n    };\n    cluster.size = function(x) {\n      if (!arguments.length) return nodeSize ? null : size;\n      nodeSize = (size = x) == null;\n      return cluster;\n    };\n    cluster.nodeSize = function(x) {\n      if (!arguments.length) return nodeSize ? size : null;\n      nodeSize = (size = x) != null;\n      return cluster;\n    };\n    return d3_layout_hierarchyRebind(cluster, hierarchy);\n  };\n  function d3_layout_clusterY(children) {\n    return 1 + d3.max(children, function(child) {\n      return child.y;\n    });\n  }\n  function d3_layout_clusterX(children) {\n    return children.reduce(function(x, child) {\n      return x + child.x;\n    }, 0) / children.length;\n  }\n  function d3_layout_clusterLeft(node) {\n    var children = node.children;\n    return children && children.length ? d3_layout_clusterLeft(children[0]) : node;\n  }\n  function d3_layout_clusterRight(node) {\n    var children = node.children, n;\n    return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;\n  }\n  d3.layout.treemap = function() {\n    var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = \"squarify\", ratio = .5 * (1 + Math.sqrt(5));\n    function scale(children, k) {\n      var i = -1, n = children.length, child, area;\n      while (++i < n) {\n        area = (child = children[i]).value * (k < 0 ? 0 : k);\n        child.area = isNaN(area) || area <= 0 ? 0 : area;\n      }\n    }\n    function squarify(node) {\n      var children = node.children;\n      if (children && children.length) {\n        var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === \"slice\" ? rect.dx : mode === \"dice\" ? rect.dy : mode === \"slice-dice\" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n;\n        scale(remaining, rect.dx * rect.dy / node.value);\n        row.area = 0;\n        while ((n = remaining.length) > 0) {\n          row.push(child = remaining[n - 1]);\n          row.area += child.area;\n          if (mode !== \"squarify\" || (score = worst(row, u)) <= best) {\n            remaining.pop();\n            best = score;\n          } else {\n            row.area -= row.pop().area;\n            position(row, u, rect, false);\n            u = Math.min(rect.dx, rect.dy);\n            row.length = row.area = 0;\n            best = Infinity;\n          }\n        }\n        if (row.length) {\n          position(row, u, rect, true);\n          row.length = row.area = 0;\n        }\n        children.forEach(squarify);\n      }\n    }\n    function stickify(node) {\n      var children = node.children;\n      if (children && children.length) {\n        var rect = pad(node), remaining = children.slice(), child, row = [];\n        scale(remaining, rect.dx * rect.dy / node.value);\n        row.area = 0;\n        while (child = remaining.pop()) {\n          row.push(child);\n          row.area += child.area;\n          if (child.z != null) {\n            position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);\n            row.length = row.area = 0;\n          }\n        }\n        children.forEach(stickify);\n      }\n    }\n    function worst(row, u) {\n      var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;\n      while (++i < n) {\n        if (!(r = row[i].area)) continue;\n        if (r < rmin) rmin = r;\n        if (r > rmax) rmax = r;\n      }\n      s *= s;\n      u *= u;\n      return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;\n    }\n    function position(row, u, rect, flush) {\n      var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;\n      if (u == rect.dx) {\n        if (flush || v > rect.dy) v = rect.dy;\n        while (++i < n) {\n          o = row[i];\n          o.x = x;\n          o.y = y;\n          o.dy = v;\n          x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);\n        }\n        o.z = true;\n        o.dx += rect.x + rect.dx - x;\n        rect.y += v;\n        rect.dy -= v;\n      } else {\n        if (flush || v > rect.dx) v = rect.dx;\n        while (++i < n) {\n          o = row[i];\n          o.x = x;\n          o.y = y;\n          o.dx = v;\n          y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);\n        }\n        o.z = false;\n        o.dy += rect.y + rect.dy - y;\n        rect.x += v;\n        rect.dx -= v;\n      }\n    }\n    function treemap(d) {\n      var nodes = stickies || hierarchy(d), root = nodes[0];\n      root.x = root.y = 0;\n      if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0;\n      if (stickies) hierarchy.revalue(root);\n      scale([ root ], root.dx * root.dy / root.value);\n      (stickies ? stickify : squarify)(root);\n      if (sticky) stickies = nodes;\n      return nodes;\n    }\n    treemap.size = function(x) {\n      if (!arguments.length) return size;\n      size = x;\n      return treemap;\n    };\n    treemap.padding = function(x) {\n      if (!arguments.length) return padding;\n      function padFunction(node) {\n        var p = x.call(treemap, node, node.depth);\n        return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === \"number\" ? [ p, p, p, p ] : p);\n      }\n      function padConstant(node) {\n        return d3_layout_treemapPad(node, x);\n      }\n      var type;\n      pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === \"function\" ? padFunction : type === \"number\" ? (x = [ x, x, x, x ], \n      padConstant) : padConstant;\n      return treemap;\n    };\n    treemap.round = function(x) {\n      if (!arguments.length) return round != Number;\n      round = x ? Math.round : Number;\n      return treemap;\n    };\n    treemap.sticky = function(x) {\n      if (!arguments.length) return sticky;\n      sticky = x;\n      stickies = null;\n      return treemap;\n    };\n    treemap.ratio = function(x) {\n      if (!arguments.length) return ratio;\n      ratio = x;\n      return treemap;\n    };\n    treemap.mode = function(x) {\n      if (!arguments.length) return mode;\n      mode = x + \"\";\n      return treemap;\n    };\n    return d3_layout_hierarchyRebind(treemap, hierarchy);\n  };\n  function d3_layout_treemapPadNull(node) {\n    return {\n      x: node.x,\n      y: node.y,\n      dx: node.dx,\n      dy: node.dy\n    };\n  }\n  function d3_layout_treemapPad(node, padding) {\n    var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2];\n    if (dx < 0) {\n      x += dx / 2;\n      dx = 0;\n    }\n    if (dy < 0) {\n      y += dy / 2;\n      dy = 0;\n    }\n    return {\n      x: x,\n      y: y,\n      dx: dx,\n      dy: dy\n    };\n  }\n  d3.random = {\n    normal: function(µ, σ) {\n      var n = arguments.length;\n      if (n < 2) σ = 1;\n      if (n < 1) µ = 0;\n      return function() {\n        var x, y, r;\n        do {\n          x = Math.random() * 2 - 1;\n          y = Math.random() * 2 - 1;\n          r = x * x + y * y;\n        } while (!r || r > 1);\n        return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);\n      };\n    },\n    logNormal: function() {\n      var random = d3.random.normal.apply(d3, arguments);\n      return function() {\n        return Math.exp(random());\n      };\n    },\n    bates: function(m) {\n      var random = d3.random.irwinHall(m);\n      return function() {\n        return random() / m;\n      };\n    },\n    irwinHall: function(m) {\n      return function() {\n        for (var s = 0, j = 0; j < m; j++) s += Math.random();\n        return s;\n      };\n    }\n  };\n  d3.scale = {};\n  function d3_scaleExtent(domain) {\n    var start = domain[0], stop = domain[domain.length - 1];\n    return start < stop ? [ start, stop ] : [ stop, start ];\n  }\n  function d3_scaleRange(scale) {\n    return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());\n  }\n  function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {\n    var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);\n    return function(x) {\n      return i(u(x));\n    };\n  }\n  function d3_scale_nice(domain, nice) {\n    var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;\n    if (x1 < x0) {\n      dx = i0, i0 = i1, i1 = dx;\n      dx = x0, x0 = x1, x1 = dx;\n    }\n    domain[i0] = nice.floor(x0);\n    domain[i1] = nice.ceil(x1);\n    return domain;\n  }\n  function d3_scale_niceStep(step) {\n    return step ? {\n      floor: function(x) {\n        return Math.floor(x / step) * step;\n      },\n      ceil: function(x) {\n        return Math.ceil(x / step) * step;\n      }\n    } : d3_scale_niceIdentity;\n  }\n  var d3_scale_niceIdentity = {\n    floor: d3_identity,\n    ceil: d3_identity\n  };\n  function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {\n    var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;\n    if (domain[k] < domain[0]) {\n      domain = domain.slice().reverse();\n      range = range.slice().reverse();\n    }\n    while (++j <= k) {\n      u.push(uninterpolate(domain[j - 1], domain[j]));\n      i.push(interpolate(range[j - 1], range[j]));\n    }\n    return function(x) {\n      var j = d3.bisect(domain, x, 1, k) - 1;\n      return i[j](u[j](x));\n    };\n  }\n  d3.scale.linear = function() {\n    return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false);\n  };\n  function d3_scale_linear(domain, range, interpolate, clamp) {\n    var output, input;\n    function rescale() {\n      var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;\n      output = linear(domain, range, uninterpolate, interpolate);\n      input = linear(range, domain, uninterpolate, d3_interpolate);\n      return scale;\n    }\n    function scale(x) {\n      return output(x);\n    }\n    scale.invert = function(y) {\n      return input(y);\n    };\n    scale.domain = function(x) {\n      if (!arguments.length) return domain;\n      domain = x.map(Number);\n      return rescale();\n    };\n    scale.range = function(x) {\n      if (!arguments.length) return range;\n      range = x;\n      return rescale();\n    };\n    scale.rangeRound = function(x) {\n      return scale.range(x).interpolate(d3_interpolateRound);\n    };\n    scale.clamp = function(x) {\n      if (!arguments.length) return clamp;\n      clamp = x;\n      return rescale();\n    };\n    scale.interpolate = function(x) {\n      if (!arguments.length) return interpolate;\n      interpolate = x;\n      return rescale();\n    };\n    scale.ticks = function(m) {\n      return d3_scale_linearTicks(domain, m);\n    };\n    scale.tickFormat = function(m, format) {\n      return d3_scale_linearTickFormat(domain, m, format);\n    };\n    scale.nice = function(m) {\n      d3_scale_linearNice(domain, m);\n      return rescale();\n    };\n    scale.copy = function() {\n      return d3_scale_linear(domain, range, interpolate, clamp);\n    };\n    return rescale();\n  }\n  function d3_scale_linearRebind(scale, linear) {\n    return d3.rebind(scale, linear, \"range\", \"rangeRound\", \"interpolate\", \"clamp\");\n  }\n  function d3_scale_linearNice(domain, m) {\n    d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n    d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));\n    return domain;\n  }\n  function d3_scale_linearTickRange(domain, m) {\n    if (m == null) m = 10;\n    var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;\n    if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;\n    extent[0] = Math.ceil(extent[0] / step) * step;\n    extent[1] = Math.floor(extent[1] / step) * step + step * .5;\n    extent[2] = step;\n    return extent;\n  }\n  function d3_scale_linearTicks(domain, m) {\n    return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));\n  }\n  function d3_scale_linearTickFormat(domain, m, format) {\n    var range = d3_scale_linearTickRange(domain, m);\n    if (format) {\n      var match = d3_format_re.exec(format);\n      match.shift();\n      if (match[8] === \"s\") {\n        var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1])));\n        if (!match[7]) match[7] = \".\" + d3_scale_linearPrecision(prefix.scale(range[2]));\n        match[8] = \"f\";\n        format = d3.format(match.join(\"\"));\n        return function(d) {\n          return format(prefix.scale(d)) + prefix.symbol;\n        };\n      }\n      if (!match[7]) match[7] = \".\" + d3_scale_linearFormatPrecision(match[8], range);\n      format = match.join(\"\");\n    } else {\n      format = \",.\" + d3_scale_linearPrecision(range[2]) + \"f\";\n    }\n    return d3.format(format);\n  }\n  var d3_scale_linearFormatSignificant = {\n    s: 1,\n    g: 1,\n    p: 1,\n    r: 1,\n    e: 1\n  };\n  function d3_scale_linearPrecision(value) {\n    return -Math.floor(Math.log(value) / Math.LN10 + .01);\n  }\n  function d3_scale_linearFormatPrecision(type, range) {\n    var p = d3_scale_linearPrecision(range[2]);\n    return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== \"e\") : p - (type === \"%\") * 2;\n  }\n  d3.scale.log = function() {\n    return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]);\n  };\n  function d3_scale_log(linear, base, positive, domain) {\n    function log(x) {\n      return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base);\n    }\n    function pow(x) {\n      return positive ? Math.pow(base, x) : -Math.pow(base, -x);\n    }\n    function scale(x) {\n      return linear(log(x));\n    }\n    scale.invert = function(x) {\n      return pow(linear.invert(x));\n    };\n    scale.domain = function(x) {\n      if (!arguments.length) return domain;\n      positive = x[0] >= 0;\n      linear.domain((domain = x.map(Number)).map(log));\n      return scale;\n    };\n    scale.base = function(_) {\n      if (!arguments.length) return base;\n      base = +_;\n      linear.domain(domain.map(log));\n      return scale;\n    };\n    scale.nice = function() {\n      var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative);\n      linear.domain(niced);\n      domain = niced.map(pow);\n      return scale;\n    };\n    scale.ticks = function() {\n      var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base;\n      if (isFinite(j - i)) {\n        if (positive) {\n          for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k);\n          ticks.push(pow(i));\n        } else {\n          ticks.push(pow(i));\n          for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k);\n        }\n        for (i = 0; ticks[i] < u; i++) {}\n        for (j = ticks.length; ticks[j - 1] > v; j--) {}\n        ticks = ticks.slice(i, j);\n      }\n      return ticks;\n    };\n    scale.tickFormat = function(n, format) {\n      if (!arguments.length) return d3_scale_logFormat;\n      if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== \"function\") format = d3.format(format);\n      var k = Math.max(1, base * n / scale.ticks().length);\n      return function(d) {\n        var i = d / pow(Math.round(log(d)));\n        if (i * base < base - .5) i *= base;\n        return i <= k ? format(d) : \"\";\n      };\n    };\n    scale.copy = function() {\n      return d3_scale_log(linear.copy(), base, positive, domain);\n    };\n    return d3_scale_linearRebind(scale, linear);\n  }\n  var d3_scale_logFormat = d3.format(\".0e\"), d3_scale_logNiceNegative = {\n    floor: function(x) {\n      return -Math.ceil(-x);\n    },\n    ceil: function(x) {\n      return -Math.floor(-x);\n    }\n  };\n  d3.scale.pow = function() {\n    return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]);\n  };\n  function d3_scale_pow(linear, exponent, domain) {\n    var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);\n    function scale(x) {\n      return linear(powp(x));\n    }\n    scale.invert = function(x) {\n      return powb(linear.invert(x));\n    };\n    scale.domain = function(x) {\n      if (!arguments.length) return domain;\n      linear.domain((domain = x.map(Number)).map(powp));\n      return scale;\n    };\n    scale.ticks = function(m) {\n      return d3_scale_linearTicks(domain, m);\n    };\n    scale.tickFormat = function(m, format) {\n      return d3_scale_linearTickFormat(domain, m, format);\n    };\n    scale.nice = function(m) {\n      return scale.domain(d3_scale_linearNice(domain, m));\n    };\n    scale.exponent = function(x) {\n      if (!arguments.length) return exponent;\n      powp = d3_scale_powPow(exponent = x);\n      powb = d3_scale_powPow(1 / exponent);\n      linear.domain(domain.map(powp));\n      return scale;\n    };\n    scale.copy = function() {\n      return d3_scale_pow(linear.copy(), exponent, domain);\n    };\n    return d3_scale_linearRebind(scale, linear);\n  }\n  function d3_scale_powPow(e) {\n    return function(x) {\n      return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);\n    };\n  }\n  d3.scale.sqrt = function() {\n    return d3.scale.pow().exponent(.5);\n  };\n  d3.scale.ordinal = function() {\n    return d3_scale_ordinal([], {\n      t: \"range\",\n      a: [ [] ]\n    });\n  };\n  function d3_scale_ordinal(domain, ranger) {\n    var index, range, rangeBand;\n    function scale(x) {\n      return range[((index.get(x) || (ranger.t === \"range\" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length];\n    }\n    function steps(start, step) {\n      return d3.range(domain.length).map(function(i) {\n        return start + step * i;\n      });\n    }\n    scale.domain = function(x) {\n      if (!arguments.length) return domain;\n      domain = [];\n      index = new d3_Map();\n      var i = -1, n = x.length, xi;\n      while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));\n      return scale[ranger.t].apply(scale, ranger.a);\n    };\n    scale.range = function(x) {\n      if (!arguments.length) return range;\n      range = x;\n      rangeBand = 0;\n      ranger = {\n        t: \"range\",\n        a: arguments\n      };\n      return scale;\n    };\n    scale.rangePoints = function(x, padding) {\n      if (arguments.length < 2) padding = 0;\n      var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, \n      0) : (stop - start) / (domain.length - 1 + padding);\n      range = steps(start + step * padding / 2, step);\n      rangeBand = 0;\n      ranger = {\n        t: \"rangePoints\",\n        a: arguments\n      };\n      return scale;\n    };\n    scale.rangeRoundPoints = function(x, padding) {\n      if (arguments.length < 2) padding = 0;\n      var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), \n      0) : (stop - start) / (domain.length - 1 + padding) | 0;\n      range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step);\n      rangeBand = 0;\n      ranger = {\n        t: \"rangeRoundPoints\",\n        a: arguments\n      };\n      return scale;\n    };\n    scale.rangeBands = function(x, padding, outerPadding) {\n      if (arguments.length < 2) padding = 0;\n      if (arguments.length < 3) outerPadding = padding;\n      var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);\n      range = steps(start + step * outerPadding, step);\n      if (reverse) range.reverse();\n      rangeBand = step * (1 - padding);\n      ranger = {\n        t: \"rangeBands\",\n        a: arguments\n      };\n      return scale;\n    };\n    scale.rangeRoundBands = function(x, padding, outerPadding) {\n      if (arguments.length < 2) padding = 0;\n      if (arguments.length < 3) outerPadding = padding;\n      var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding));\n      range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step);\n      if (reverse) range.reverse();\n      rangeBand = Math.round(step * (1 - padding));\n      ranger = {\n        t: \"rangeRoundBands\",\n        a: arguments\n      };\n      return scale;\n    };\n    scale.rangeBand = function() {\n      return rangeBand;\n    };\n    scale.rangeExtent = function() {\n      return d3_scaleExtent(ranger.a[0]);\n    };\n    scale.copy = function() {\n      return d3_scale_ordinal(domain, ranger);\n    };\n    return scale.domain(domain);\n  }\n  d3.scale.category10 = function() {\n    return d3.scale.ordinal().range(d3_category10);\n  };\n  d3.scale.category20 = function() {\n    return d3.scale.ordinal().range(d3_category20);\n  };\n  d3.scale.category20b = function() {\n    return d3.scale.ordinal().range(d3_category20b);\n  };\n  d3.scale.category20c = function() {\n    return d3.scale.ordinal().range(d3_category20c);\n  };\n  var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString);\n  var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString);\n  var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString);\n  var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString);\n  d3.scale.quantile = function() {\n    return d3_scale_quantile([], []);\n  };\n  function d3_scale_quantile(domain, range) {\n    var thresholds;\n    function rescale() {\n      var k = 0, q = range.length;\n      thresholds = [];\n      while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);\n      return scale;\n    }\n    function scale(x) {\n      if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)];\n    }\n    scale.domain = function(x) {\n      if (!arguments.length) return domain;\n      domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending);\n      return rescale();\n    };\n    scale.range = function(x) {\n      if (!arguments.length) return range;\n      range = x;\n      return rescale();\n    };\n    scale.quantiles = function() {\n      return thresholds;\n    };\n    scale.invertExtent = function(y) {\n      y = range.indexOf(y);\n      return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ];\n    };\n    scale.copy = function() {\n      return d3_scale_quantile(domain, range);\n    };\n    return rescale();\n  }\n  d3.scale.quantize = function() {\n    return d3_scale_quantize(0, 1, [ 0, 1 ]);\n  };\n  function d3_scale_quantize(x0, x1, range) {\n    var kx, i;\n    function scale(x) {\n      return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];\n    }\n    function rescale() {\n      kx = range.length / (x1 - x0);\n      i = range.length - 1;\n      return scale;\n    }\n    scale.domain = function(x) {\n      if (!arguments.length) return [ x0, x1 ];\n      x0 = +x[0];\n      x1 = +x[x.length - 1];\n      return rescale();\n    };\n    scale.range = function(x) {\n      if (!arguments.length) return range;\n      range = x;\n      return rescale();\n    };\n    scale.invertExtent = function(y) {\n      y = range.indexOf(y);\n      y = y < 0 ? NaN : y / kx + x0;\n      return [ y, y + 1 / kx ];\n    };\n    scale.copy = function() {\n      return d3_scale_quantize(x0, x1, range);\n    };\n    return rescale();\n  }\n  d3.scale.threshold = function() {\n    return d3_scale_threshold([ .5 ], [ 0, 1 ]);\n  };\n  function d3_scale_threshold(domain, range) {\n    function scale(x) {\n      if (x <= x) return range[d3.bisect(domain, x)];\n    }\n    scale.domain = function(_) {\n      if (!arguments.length) return domain;\n      domain = _;\n      return scale;\n    };\n    scale.range = function(_) {\n      if (!arguments.length) return range;\n      range = _;\n      return scale;\n    };\n    scale.invertExtent = function(y) {\n      y = range.indexOf(y);\n      return [ domain[y - 1], domain[y] ];\n    };\n    scale.copy = function() {\n      return d3_scale_threshold(domain, range);\n    };\n    return scale;\n  }\n  d3.scale.identity = function() {\n    return d3_scale_identity([ 0, 1 ]);\n  };\n  function d3_scale_identity(domain) {\n    function identity(x) {\n      return +x;\n    }\n    identity.invert = identity;\n    identity.domain = identity.range = function(x) {\n      if (!arguments.length) return domain;\n      domain = x.map(identity);\n      return identity;\n    };\n    identity.ticks = function(m) {\n      return d3_scale_linearTicks(domain, m);\n    };\n    identity.tickFormat = function(m, format) {\n      return d3_scale_linearTickFormat(domain, m, format);\n    };\n    identity.copy = function() {\n      return d3_scale_identity(domain);\n    };\n    return identity;\n  }\n  d3.svg = {};\n  function d3_zero() {\n    return 0;\n  }\n  d3.svg.arc = function() {\n    var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle;\n    function arc() {\n      var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1;\n      if (r1 < r0) rc = r1, r1 = r0, r0 = rc;\n      if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : \"\") + \"Z\";\n      var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = [];\n      if (ap = (+padAngle.apply(this, arguments) || 0) / 2) {\n        rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments);\n        if (!cw) p1 *= -1;\n        if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap));\n        if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap));\n      }\n      if (r1) {\n        x0 = r1 * Math.cos(a0 + p1);\n        y0 = r1 * Math.sin(a0 + p1);\n        x1 = r1 * Math.cos(a1 - p1);\n        y1 = r1 * Math.sin(a1 - p1);\n        var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1;\n        if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) {\n          var h1 = (a0 + a1) / 2;\n          x0 = r1 * Math.cos(h1);\n          y0 = r1 * Math.sin(h1);\n          x1 = y1 = null;\n        }\n      } else {\n        x0 = y0 = 0;\n      }\n      if (r0) {\n        x2 = r0 * Math.cos(a1 - p0);\n        y2 = r0 * Math.sin(a1 - p0);\n        x3 = r0 * Math.cos(a0 + p0);\n        y3 = r0 * Math.sin(a0 + p0);\n        var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1;\n        if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) {\n          var h0 = (a0 + a1) / 2;\n          x2 = r0 * Math.cos(h0);\n          y2 = r0 * Math.sin(h0);\n          x3 = y3 = null;\n        }\n      } else {\n        x2 = y2 = 0;\n      }\n      if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {\n        cr = r0 < r1 ^ cw ? 0 : 1;\n        var rc1 = rc, rc0 = rc;\n        if (da < π) {\n          var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);\n          rc0 = Math.min(rc, (r0 - lc) / (kc - 1));\n          rc1 = Math.min(rc, (r1 - lc) / (kc + 1));\n        }\n        if (x1 != null) {\n          var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);\n          if (rc === rc1) {\n            path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t30[1], \"A\", r1, \",\", r1, \" 0 \", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), \",\", cw, \" \", t12[1], \"A\", rc1, \",\", rc1, \" 0 0,\", cr, \" \", t12[0]);\n          } else {\n            path.push(\"M\", t30[0], \"A\", rc1, \",\", rc1, \" 0 1,\", cr, \" \", t12[0]);\n          }\n        } else {\n          path.push(\"M\", x0, \",\", y0);\n        }\n        if (x3 != null) {\n          var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);\n          if (rc === rc0) {\n            path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t21[1], \"A\", r0, \",\", r0, \" 0 \", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), \",\", 1 - cw, \" \", t03[1], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n          } else {\n            path.push(\"L\", t21[0], \"A\", rc0, \",\", rc0, \" 0 0,\", cr, \" \", t03[0]);\n          }\n        } else {\n          path.push(\"L\", x2, \",\", y2);\n        }\n      } else {\n        path.push(\"M\", x0, \",\", y0);\n        if (x1 != null) path.push(\"A\", r1, \",\", r1, \" 0 \", l1, \",\", cw, \" \", x1, \",\", y1);\n        path.push(\"L\", x2, \",\", y2);\n        if (x3 != null) path.push(\"A\", r0, \",\", r0, \" 0 \", l0, \",\", 1 - cw, \" \", x3, \",\", y3);\n      }\n      path.push(\"Z\");\n      return path.join(\"\");\n    }\n    function circleSegment(r1, cw) {\n      return \"M0,\" + r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + -r1 + \"A\" + r1 + \",\" + r1 + \" 0 1,\" + cw + \" 0,\" + r1;\n    }\n    arc.innerRadius = function(v) {\n      if (!arguments.length) return innerRadius;\n      innerRadius = d3_functor(v);\n      return arc;\n    };\n    arc.outerRadius = function(v) {\n      if (!arguments.length) return outerRadius;\n      outerRadius = d3_functor(v);\n      return arc;\n    };\n    arc.cornerRadius = function(v) {\n      if (!arguments.length) return cornerRadius;\n      cornerRadius = d3_functor(v);\n      return arc;\n    };\n    arc.padRadius = function(v) {\n      if (!arguments.length) return padRadius;\n      padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v);\n      return arc;\n    };\n    arc.startAngle = function(v) {\n      if (!arguments.length) return startAngle;\n      startAngle = d3_functor(v);\n      return arc;\n    };\n    arc.endAngle = function(v) {\n      if (!arguments.length) return endAngle;\n      endAngle = d3_functor(v);\n      return arc;\n    };\n    arc.padAngle = function(v) {\n      if (!arguments.length) return padAngle;\n      padAngle = d3_functor(v);\n      return arc;\n    };\n    arc.centroid = function() {\n      var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ;\n      return [ Math.cos(a) * r, Math.sin(a) * r ];\n    };\n    return arc;\n  };\n  var d3_svg_arcAuto = \"auto\";\n  function d3_svg_arcInnerRadius(d) {\n    return d.innerRadius;\n  }\n  function d3_svg_arcOuterRadius(d) {\n    return d.outerRadius;\n  }\n  function d3_svg_arcStartAngle(d) {\n    return d.startAngle;\n  }\n  function d3_svg_arcEndAngle(d) {\n    return d.endAngle;\n  }\n  function d3_svg_arcPadAngle(d) {\n    return d && d.padAngle;\n  }\n  function d3_svg_arcSweep(x0, y0, x1, y1) {\n    return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;\n  }\n  function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {\n    var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;\n    if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;\n    return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];\n  }\n  function d3_svg_line(projection) {\n    var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;\n    function line(data) {\n      var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);\n      function segment() {\n        segments.push(\"M\", interpolate(projection(points), tension));\n      }\n      while (++i < n) {\n        if (defined.call(this, d = data[i], i)) {\n          points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);\n        } else if (points.length) {\n          segment();\n          points = [];\n        }\n      }\n      if (points.length) segment();\n      return segments.length ? segments.join(\"\") : null;\n    }\n    line.x = function(_) {\n      if (!arguments.length) return x;\n      x = _;\n      return line;\n    };\n    line.y = function(_) {\n      if (!arguments.length) return y;\n      y = _;\n      return line;\n    };\n    line.defined = function(_) {\n      if (!arguments.length) return defined;\n      defined = _;\n      return line;\n    };\n    line.interpolate = function(_) {\n      if (!arguments.length) return interpolateKey;\n      if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n      return line;\n    };\n    line.tension = function(_) {\n      if (!arguments.length) return tension;\n      tension = _;\n      return line;\n    };\n    return line;\n  }\n  d3.svg.line = function() {\n    return d3_svg_line(d3_identity);\n  };\n  var d3_svg_lineInterpolators = d3.map({\n    linear: d3_svg_lineLinear,\n    \"linear-closed\": d3_svg_lineLinearClosed,\n    step: d3_svg_lineStep,\n    \"step-before\": d3_svg_lineStepBefore,\n    \"step-after\": d3_svg_lineStepAfter,\n    basis: d3_svg_lineBasis,\n    \"basis-open\": d3_svg_lineBasisOpen,\n    \"basis-closed\": d3_svg_lineBasisClosed,\n    bundle: d3_svg_lineBundle,\n    cardinal: d3_svg_lineCardinal,\n    \"cardinal-open\": d3_svg_lineCardinalOpen,\n    \"cardinal-closed\": d3_svg_lineCardinalClosed,\n    monotone: d3_svg_lineMonotone\n  });\n  d3_svg_lineInterpolators.forEach(function(key, value) {\n    value.key = key;\n    value.closed = /-closed$/.test(key);\n  });\n  function d3_svg_lineLinear(points) {\n    return points.length > 1 ? points.join(\"L\") : points + \"Z\";\n  }\n  function d3_svg_lineLinearClosed(points) {\n    return points.join(\"L\") + \"Z\";\n  }\n  function d3_svg_lineStep(points) {\n    var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n    while (++i < n) path.push(\"H\", (p[0] + (p = points[i])[0]) / 2, \"V\", p[1]);\n    if (n > 1) path.push(\"H\", p[0]);\n    return path.join(\"\");\n  }\n  function d3_svg_lineStepBefore(points) {\n    var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n    while (++i < n) path.push(\"V\", (p = points[i])[1], \"H\", p[0]);\n    return path.join(\"\");\n  }\n  function d3_svg_lineStepAfter(points) {\n    var i = 0, n = points.length, p = points[0], path = [ p[0], \",\", p[1] ];\n    while (++i < n) path.push(\"H\", (p = points[i])[0], \"V\", p[1]);\n    return path.join(\"\");\n  }\n  function d3_svg_lineCardinalOpen(points, tension) {\n    return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));\n  }\n  function d3_svg_lineCardinalClosed(points, tension) {\n    return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), \n    points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));\n  }\n  function d3_svg_lineCardinal(points, tension) {\n    return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));\n  }\n  function d3_svg_lineHermite(points, tangents) {\n    if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {\n      return d3_svg_lineLinear(points);\n    }\n    var quad = points.length != tangents.length, path = \"\", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;\n    if (quad) {\n      path += \"Q\" + (p[0] - t0[0] * 2 / 3) + \",\" + (p[1] - t0[1] * 2 / 3) + \",\" + p[0] + \",\" + p[1];\n      p0 = points[1];\n      pi = 2;\n    }\n    if (tangents.length > 1) {\n      t = tangents[1];\n      p = points[pi];\n      pi++;\n      path += \"C\" + (p0[0] + t0[0]) + \",\" + (p0[1] + t0[1]) + \",\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n      for (var i = 2; i < tangents.length; i++, pi++) {\n        p = points[pi];\n        t = tangents[i];\n        path += \"S\" + (p[0] - t[0]) + \",\" + (p[1] - t[1]) + \",\" + p[0] + \",\" + p[1];\n      }\n    }\n    if (quad) {\n      var lp = points[pi];\n      path += \"Q\" + (p[0] + t[0] * 2 / 3) + \",\" + (p[1] + t[1] * 2 / 3) + \",\" + lp[0] + \",\" + lp[1];\n    }\n    return path;\n  }\n  function d3_svg_lineCardinalTangents(points, tension) {\n    var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;\n    while (++i < n) {\n      p0 = p1;\n      p1 = p2;\n      p2 = points[i];\n      tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);\n    }\n    return tangents;\n  }\n  function d3_svg_lineBasis(points) {\n    if (points.length < 3) return d3_svg_lineLinear(points);\n    var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, \",\", y0, \"L\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n    points.push(points[n - 1]);\n    while (++i <= n) {\n      pi = points[i];\n      px.shift();\n      px.push(pi[0]);\n      py.shift();\n      py.push(pi[1]);\n      d3_svg_lineBasisBezier(path, px, py);\n    }\n    points.pop();\n    path.push(\"L\", pi);\n    return path.join(\"\");\n  }\n  function d3_svg_lineBasisOpen(points) {\n    if (points.length < 4) return d3_svg_lineLinear(points);\n    var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];\n    while (++i < 3) {\n      pi = points[i];\n      px.push(pi[0]);\n      py.push(pi[1]);\n    }\n    path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + \",\" + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));\n    --i;\n    while (++i < n) {\n      pi = points[i];\n      px.shift();\n      px.push(pi[0]);\n      py.shift();\n      py.push(pi[1]);\n      d3_svg_lineBasisBezier(path, px, py);\n    }\n    return path.join(\"\");\n  }\n  function d3_svg_lineBasisClosed(points) {\n    var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];\n    while (++i < 4) {\n      pi = points[i % n];\n      px.push(pi[0]);\n      py.push(pi[1]);\n    }\n    path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];\n    --i;\n    while (++i < m) {\n      pi = points[i % n];\n      px.shift();\n      px.push(pi[0]);\n      py.shift();\n      py.push(pi[1]);\n      d3_svg_lineBasisBezier(path, px, py);\n    }\n    return path.join(\"\");\n  }\n  function d3_svg_lineBundle(points, tension) {\n    var n = points.length - 1;\n    if (n) {\n      var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;\n      while (++i <= n) {\n        p = points[i];\n        t = i / n;\n        p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);\n        p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);\n      }\n    }\n    return d3_svg_lineBasis(points);\n  }\n  function d3_svg_lineDot4(a, b) {\n    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\n  }\n  var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ];\n  function d3_svg_lineBasisBezier(path, x, y) {\n    path.push(\"C\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), \",\", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));\n  }\n  function d3_svg_lineSlope(p0, p1) {\n    return (p1[1] - p0[1]) / (p1[0] - p0[0]);\n  }\n  function d3_svg_lineFiniteDifferences(points) {\n    var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);\n    while (++i < j) {\n      m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;\n    }\n    m[i] = d;\n    return m;\n  }\n  function d3_svg_lineMonotoneTangents(points) {\n    var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;\n    while (++i < j) {\n      d = d3_svg_lineSlope(points[i], points[i + 1]);\n      if (abs(d) < ε) {\n        m[i] = m[i + 1] = 0;\n      } else {\n        a = m[i] / d;\n        b = m[i + 1] / d;\n        s = a * a + b * b;\n        if (s > 9) {\n          s = d * 3 / Math.sqrt(s);\n          m[i] = s * a;\n          m[i + 1] = s * b;\n        }\n      }\n    }\n    i = -1;\n    while (++i <= j) {\n      s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));\n      tangents.push([ s || 0, m[i] * s || 0 ]);\n    }\n    return tangents;\n  }\n  function d3_svg_lineMonotone(points) {\n    return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));\n  }\n  d3.svg.line.radial = function() {\n    var line = d3_svg_line(d3_svg_lineRadial);\n    line.radius = line.x, delete line.x;\n    line.angle = line.y, delete line.y;\n    return line;\n  };\n  function d3_svg_lineRadial(points) {\n    var point, i = -1, n = points.length, r, a;\n    while (++i < n) {\n      point = points[i];\n      r = point[0];\n      a = point[1] - halfπ;\n      point[0] = r * Math.cos(a);\n      point[1] = r * Math.sin(a);\n    }\n    return points;\n  }\n  function d3_svg_area(projection) {\n    var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = \"L\", tension = .7;\n    function area(data) {\n      var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {\n        return x;\n      } : d3_functor(x1), fy1 = y0 === y1 ? function() {\n        return y;\n      } : d3_functor(y1), x, y;\n      function segment() {\n        segments.push(\"M\", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), \"Z\");\n      }\n      while (++i < n) {\n        if (defined.call(this, d = data[i], i)) {\n          points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);\n          points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);\n        } else if (points0.length) {\n          segment();\n          points0 = [];\n          points1 = [];\n        }\n      }\n      if (points0.length) segment();\n      return segments.length ? segments.join(\"\") : null;\n    }\n    area.x = function(_) {\n      if (!arguments.length) return x1;\n      x0 = x1 = _;\n      return area;\n    };\n    area.x0 = function(_) {\n      if (!arguments.length) return x0;\n      x0 = _;\n      return area;\n    };\n    area.x1 = function(_) {\n      if (!arguments.length) return x1;\n      x1 = _;\n      return area;\n    };\n    area.y = function(_) {\n      if (!arguments.length) return y1;\n      y0 = y1 = _;\n      return area;\n    };\n    area.y0 = function(_) {\n      if (!arguments.length) return y0;\n      y0 = _;\n      return area;\n    };\n    area.y1 = function(_) {\n      if (!arguments.length) return y1;\n      y1 = _;\n      return area;\n    };\n    area.defined = function(_) {\n      if (!arguments.length) return defined;\n      defined = _;\n      return area;\n    };\n    area.interpolate = function(_) {\n      if (!arguments.length) return interpolateKey;\n      if (typeof _ === \"function\") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;\n      interpolateReverse = interpolate.reverse || interpolate;\n      L = interpolate.closed ? \"M\" : \"L\";\n      return area;\n    };\n    area.tension = function(_) {\n      if (!arguments.length) return tension;\n      tension = _;\n      return area;\n    };\n    return area;\n  }\n  d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;\n  d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;\n  d3.svg.area = function() {\n    return d3_svg_area(d3_identity);\n  };\n  d3.svg.area.radial = function() {\n    var area = d3_svg_area(d3_svg_lineRadial);\n    area.radius = area.x, delete area.x;\n    area.innerRadius = area.x0, delete area.x0;\n    area.outerRadius = area.x1, delete area.x1;\n    area.angle = area.y, delete area.y;\n    area.startAngle = area.y0, delete area.y0;\n    area.endAngle = area.y1, delete area.y1;\n    return area;\n  };\n  d3.svg.chord = function() {\n    var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;\n    function chord(d, i) {\n      var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);\n      return \"M\" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + \"Z\";\n    }\n    function subgroup(self, f, d, i) {\n      var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ;\n      return {\n        r: r,\n        a0: a0,\n        a1: a1,\n        p0: [ r * Math.cos(a0), r * Math.sin(a0) ],\n        p1: [ r * Math.cos(a1), r * Math.sin(a1) ]\n      };\n    }\n    function equals(a, b) {\n      return a.a0 == b.a0 && a.a1 == b.a1;\n    }\n    function arc(r, p, a) {\n      return \"A\" + r + \",\" + r + \" 0 \" + +(a > π) + \",1 \" + p;\n    }\n    function curve(r0, p0, r1, p1) {\n      return \"Q 0,0 \" + p1;\n    }\n    chord.radius = function(v) {\n      if (!arguments.length) return radius;\n      radius = d3_functor(v);\n      return chord;\n    };\n    chord.source = function(v) {\n      if (!arguments.length) return source;\n      source = d3_functor(v);\n      return chord;\n    };\n    chord.target = function(v) {\n      if (!arguments.length) return target;\n      target = d3_functor(v);\n      return chord;\n    };\n    chord.startAngle = function(v) {\n      if (!arguments.length) return startAngle;\n      startAngle = d3_functor(v);\n      return chord;\n    };\n    chord.endAngle = function(v) {\n      if (!arguments.length) return endAngle;\n      endAngle = d3_functor(v);\n      return chord;\n    };\n    return chord;\n  };\n  function d3_svg_chordRadius(d) {\n    return d.radius;\n  }\n  d3.svg.diagonal = function() {\n    var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;\n    function diagonal(d, i) {\n      var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {\n        x: p0.x,\n        y: m\n      }, {\n        x: p3.x,\n        y: m\n      }, p3 ];\n      p = p.map(projection);\n      return \"M\" + p[0] + \"C\" + p[1] + \" \" + p[2] + \" \" + p[3];\n    }\n    diagonal.source = function(x) {\n      if (!arguments.length) return source;\n      source = d3_functor(x);\n      return diagonal;\n    };\n    diagonal.target = function(x) {\n      if (!arguments.length) return target;\n      target = d3_functor(x);\n      return diagonal;\n    };\n    diagonal.projection = function(x) {\n      if (!arguments.length) return projection;\n      projection = x;\n      return diagonal;\n    };\n    return diagonal;\n  };\n  function d3_svg_diagonalProjection(d) {\n    return [ d.x, d.y ];\n  }\n  d3.svg.diagonal.radial = function() {\n    var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;\n    diagonal.projection = function(x) {\n      return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;\n    };\n    return diagonal;\n  };\n  function d3_svg_diagonalRadialProjection(projection) {\n    return function() {\n      var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ;\n      return [ r * Math.cos(a), r * Math.sin(a) ];\n    };\n  }\n  d3.svg.symbol = function() {\n    var type = d3_svg_symbolType, size = d3_svg_symbolSize;\n    function symbol(d, i) {\n      return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));\n    }\n    symbol.type = function(x) {\n      if (!arguments.length) return type;\n      type = d3_functor(x);\n      return symbol;\n    };\n    symbol.size = function(x) {\n      if (!arguments.length) return size;\n      size = d3_functor(x);\n      return symbol;\n    };\n    return symbol;\n  };\n  function d3_svg_symbolSize() {\n    return 64;\n  }\n  function d3_svg_symbolType() {\n    return \"circle\";\n  }\n  function d3_svg_symbolCircle(size) {\n    var r = Math.sqrt(size / π);\n    return \"M0,\" + r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + -r + \"A\" + r + \",\" + r + \" 0 1,1 0,\" + r + \"Z\";\n  }\n  var d3_svg_symbols = d3.map({\n    circle: d3_svg_symbolCircle,\n    cross: function(size) {\n      var r = Math.sqrt(size / 5) / 2;\n      return \"M\" + -3 * r + \",\" + -r + \"H\" + -r + \"V\" + -3 * r + \"H\" + r + \"V\" + -r + \"H\" + 3 * r + \"V\" + r + \"H\" + r + \"V\" + 3 * r + \"H\" + -r + \"V\" + r + \"H\" + -3 * r + \"Z\";\n    },\n    diamond: function(size) {\n      var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;\n      return \"M0,\" + -ry + \"L\" + rx + \",0\" + \" 0,\" + ry + \" \" + -rx + \",0\" + \"Z\";\n    },\n    square: function(size) {\n      var r = Math.sqrt(size) / 2;\n      return \"M\" + -r + \",\" + -r + \"L\" + r + \",\" + -r + \" \" + r + \",\" + r + \" \" + -r + \",\" + r + \"Z\";\n    },\n    \"triangle-down\": function(size) {\n      var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n      return \"M0,\" + ry + \"L\" + rx + \",\" + -ry + \" \" + -rx + \",\" + -ry + \"Z\";\n    },\n    \"triangle-up\": function(size) {\n      var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;\n      return \"M0,\" + -ry + \"L\" + rx + \",\" + ry + \" \" + -rx + \",\" + ry + \"Z\";\n    }\n  });\n  d3.svg.symbolTypes = d3_svg_symbols.keys();\n  var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);\n  d3_selectionPrototype.transition = function(name) {\n    var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || {\n      time: Date.now(),\n      ease: d3_ease_cubicInOut,\n      delay: 0,\n      duration: 250\n    };\n    for (var j = -1, m = this.length; ++j < m; ) {\n      subgroups.push(subgroup = []);\n      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n        if (node = group[i]) d3_transitionNode(node, i, ns, id, transition);\n        subgroup.push(node);\n      }\n    }\n    return d3_transition(subgroups, ns, id);\n  };\n  d3_selectionPrototype.interrupt = function(name) {\n    return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name)));\n  };\n  var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());\n  function d3_selection_interruptNS(ns) {\n    return function() {\n      var lock, activeId, active;\n      if ((lock = this[ns]) && (active = lock[activeId = lock.active])) {\n        active.timer.c = null;\n        active.timer.t = NaN;\n        if (--lock.count) delete lock[activeId]; else delete this[ns];\n        lock.active += .5;\n        active.event && active.event.interrupt.call(this, this.__data__, active.index);\n      }\n    };\n  }\n  function d3_transition(groups, ns, id) {\n    d3_subclass(groups, d3_transitionPrototype);\n    groups.namespace = ns;\n    groups.id = id;\n    return groups;\n  }\n  var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit;\n  d3_transitionPrototype.call = d3_selectionPrototype.call;\n  d3_transitionPrototype.empty = d3_selectionPrototype.empty;\n  d3_transitionPrototype.node = d3_selectionPrototype.node;\n  d3_transitionPrototype.size = d3_selectionPrototype.size;\n  d3.transition = function(selection, name) {\n    return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection);\n  };\n  d3.transition.prototype = d3_transitionPrototype;\n  d3_transitionPrototype.select = function(selector) {\n    var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node;\n    selector = d3_selection_selector(selector);\n    for (var j = -1, m = this.length; ++j < m; ) {\n      subgroups.push(subgroup = []);\n      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n        if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) {\n          if (\"__data__\" in node) subnode.__data__ = node.__data__;\n          d3_transitionNode(subnode, i, ns, id, node[ns][id]);\n          subgroup.push(subnode);\n        } else {\n          subgroup.push(null);\n        }\n      }\n    }\n    return d3_transition(subgroups, ns, id);\n  };\n  d3_transitionPrototype.selectAll = function(selector) {\n    var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition;\n    selector = d3_selection_selectorAll(selector);\n    for (var j = -1, m = this.length; ++j < m; ) {\n      for (var group = this[j], i = -1, n = group.length; ++i < n; ) {\n        if (node = group[i]) {\n          transition = node[ns][id];\n          subnodes = selector.call(node, node.__data__, i, j);\n          subgroups.push(subgroup = []);\n          for (var k = -1, o = subnodes.length; ++k < o; ) {\n            if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition);\n            subgroup.push(subnode);\n          }\n        }\n      }\n    }\n    return d3_transition(subgroups, ns, id);\n  };\n  d3_transitionPrototype.filter = function(filter) {\n    var subgroups = [], subgroup, group, node;\n    if (typeof filter !== \"function\") filter = d3_selection_filter(filter);\n    for (var j = 0, m = this.length; j < m; j++) {\n      subgroups.push(subgroup = []);\n      for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n        if ((node = group[i]) && filter.call(node, node.__data__, i, j)) {\n          subgroup.push(node);\n        }\n      }\n    }\n    return d3_transition(subgroups, this.namespace, this.id);\n  };\n  d3_transitionPrototype.tween = function(name, tween) {\n    var id = this.id, ns = this.namespace;\n    if (arguments.length < 2) return this.node()[ns][id].tween.get(name);\n    return d3_selection_each(this, tween == null ? function(node) {\n      node[ns][id].tween.remove(name);\n    } : function(node) {\n      node[ns][id].tween.set(name, tween);\n    });\n  };\n  function d3_transition_tween(groups, name, value, tween) {\n    var id = groups.id, ns = groups.namespace;\n    return d3_selection_each(groups, typeof value === \"function\" ? function(node, i, j) {\n      node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j)));\n    } : (value = tween(value), function(node) {\n      node[ns][id].tween.set(name, value);\n    }));\n  }\n  d3_transitionPrototype.attr = function(nameNS, value) {\n    if (arguments.length < 2) {\n      for (value in nameNS) this.attr(value, nameNS[value]);\n      return this;\n    }\n    var interpolate = nameNS == \"transform\" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS);\n    function attrNull() {\n      this.removeAttribute(name);\n    }\n    function attrNullNS() {\n      this.removeAttributeNS(name.space, name.local);\n    }\n    function attrTween(b) {\n      return b == null ? attrNull : (b += \"\", function() {\n        var a = this.getAttribute(name), i;\n        return a !== b && (i = interpolate(a, b), function(t) {\n          this.setAttribute(name, i(t));\n        });\n      });\n    }\n    function attrTweenNS(b) {\n      return b == null ? attrNullNS : (b += \"\", function() {\n        var a = this.getAttributeNS(name.space, name.local), i;\n        return a !== b && (i = interpolate(a, b), function(t) {\n          this.setAttributeNS(name.space, name.local, i(t));\n        });\n      });\n    }\n    return d3_transition_tween(this, \"attr.\" + nameNS, value, name.local ? attrTweenNS : attrTween);\n  };\n  d3_transitionPrototype.attrTween = function(nameNS, tween) {\n    var name = d3.ns.qualify(nameNS);\n    function attrTween(d, i) {\n      var f = tween.call(this, d, i, this.getAttribute(name));\n      return f && function(t) {\n        this.setAttribute(name, f(t));\n      };\n    }\n    function attrTweenNS(d, i) {\n      var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));\n      return f && function(t) {\n        this.setAttributeNS(name.space, name.local, f(t));\n      };\n    }\n    return this.tween(\"attr.\" + nameNS, name.local ? attrTweenNS : attrTween);\n  };\n  d3_transitionPrototype.style = function(name, value, priority) {\n    var n = arguments.length;\n    if (n < 3) {\n      if (typeof name !== \"string\") {\n        if (n < 2) value = \"\";\n        for (priority in name) this.style(priority, name[priority], value);\n        return this;\n      }\n      priority = \"\";\n    }\n    function styleNull() {\n      this.style.removeProperty(name);\n    }\n    function styleString(b) {\n      return b == null ? styleNull : (b += \"\", function() {\n        var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i;\n        return a !== b && (i = d3_interpolate(a, b), function(t) {\n          this.style.setProperty(name, i(t), priority);\n        });\n      });\n    }\n    return d3_transition_tween(this, \"style.\" + name, value, styleString);\n  };\n  d3_transitionPrototype.styleTween = function(name, tween, priority) {\n    if (arguments.length < 3) priority = \"\";\n    function styleTween(d, i) {\n      var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name));\n      return f && function(t) {\n        this.style.setProperty(name, f(t), priority);\n      };\n    }\n    return this.tween(\"style.\" + name, styleTween);\n  };\n  d3_transitionPrototype.text = function(value) {\n    return d3_transition_tween(this, \"text\", value, d3_transition_text);\n  };\n  function d3_transition_text(b) {\n    if (b == null) b = \"\";\n    return function() {\n      this.textContent = b;\n    };\n  }\n  d3_transitionPrototype.remove = function() {\n    var ns = this.namespace;\n    return this.each(\"end.transition\", function() {\n      var p;\n      if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this);\n    });\n  };\n  d3_transitionPrototype.ease = function(value) {\n    var id = this.id, ns = this.namespace;\n    if (arguments.length < 1) return this.node()[ns][id].ease;\n    if (typeof value !== \"function\") value = d3.ease.apply(d3, arguments);\n    return d3_selection_each(this, function(node) {\n      node[ns][id].ease = value;\n    });\n  };\n  d3_transitionPrototype.delay = function(value) {\n    var id = this.id, ns = this.namespace;\n    if (arguments.length < 1) return this.node()[ns][id].delay;\n    return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n      node[ns][id].delay = +value.call(node, node.__data__, i, j);\n    } : (value = +value, function(node) {\n      node[ns][id].delay = value;\n    }));\n  };\n  d3_transitionPrototype.duration = function(value) {\n    var id = this.id, ns = this.namespace;\n    if (arguments.length < 1) return this.node()[ns][id].duration;\n    return d3_selection_each(this, typeof value === \"function\" ? function(node, i, j) {\n      node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j));\n    } : (value = Math.max(1, value), function(node) {\n      node[ns][id].duration = value;\n    }));\n  };\n  d3_transitionPrototype.each = function(type, listener) {\n    var id = this.id, ns = this.namespace;\n    if (arguments.length < 2) {\n      var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;\n      try {\n        d3_transitionInheritId = id;\n        d3_selection_each(this, function(node, i, j) {\n          d3_transitionInherit = node[ns][id];\n          type.call(node, node.__data__, i, j);\n        });\n      } finally {\n        d3_transitionInherit = inherit;\n        d3_transitionInheritId = inheritId;\n      }\n    } else {\n      d3_selection_each(this, function(node) {\n        var transition = node[ns][id];\n        (transition.event || (transition.event = d3.dispatch(\"start\", \"end\", \"interrupt\"))).on(type, listener);\n      });\n    }\n    return this;\n  };\n  d3_transitionPrototype.transition = function() {\n    var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition;\n    for (var j = 0, m = this.length; j < m; j++) {\n      subgroups.push(subgroup = []);\n      for (var group = this[j], i = 0, n = group.length; i < n; i++) {\n        if (node = group[i]) {\n          transition = node[ns][id0];\n          d3_transitionNode(node, i, ns, id1, {\n            time: transition.time,\n            ease: transition.ease,\n            delay: transition.delay + transition.duration,\n            duration: transition.duration\n          });\n        }\n        subgroup.push(node);\n      }\n    }\n    return d3_transition(subgroups, ns, id1);\n  };\n  function d3_transitionNamespace(name) {\n    return name == null ? \"__transition__\" : \"__transition_\" + name + \"__\";\n  }\n  function d3_transitionNode(node, i, ns, id, inherit) {\n    var lock = node[ns] || (node[ns] = {\n      active: 0,\n      count: 0\n    }), transition = lock[id], time, timer, duration, ease, tweens;\n    function schedule(elapsed) {\n      var delay = transition.delay;\n      timer.t = delay + time;\n      if (delay <= elapsed) return start(elapsed - delay);\n      timer.c = start;\n    }\n    function start(elapsed) {\n      var activeId = lock.active, active = lock[activeId];\n      if (active) {\n        active.timer.c = null;\n        active.timer.t = NaN;\n        --lock.count;\n        delete lock[activeId];\n        active.event && active.event.interrupt.call(node, node.__data__, active.index);\n      }\n      for (var cancelId in lock) {\n        if (+cancelId < id) {\n          var cancel = lock[cancelId];\n          cancel.timer.c = null;\n          cancel.timer.t = NaN;\n          --lock.count;\n          delete lock[cancelId];\n        }\n      }\n      timer.c = tick;\n      d3_timer(function() {\n        if (timer.c && tick(elapsed || 1)) {\n          timer.c = null;\n          timer.t = NaN;\n        }\n        return 1;\n      }, 0, time);\n      lock.active = id;\n      transition.event && transition.event.start.call(node, node.__data__, i);\n      tweens = [];\n      transition.tween.forEach(function(key, value) {\n        if (value = value.call(node, node.__data__, i)) {\n          tweens.push(value);\n        }\n      });\n      ease = transition.ease;\n      duration = transition.duration;\n    }\n    function tick(elapsed) {\n      var t = elapsed / duration, e = ease(t), n = tweens.length;\n      while (n > 0) {\n        tweens[--n].call(node, e);\n      }\n      if (t >= 1) {\n        transition.event && transition.event.end.call(node, node.__data__, i);\n        if (--lock.count) delete lock[id]; else delete node[ns];\n        return 1;\n      }\n    }\n    if (!transition) {\n      time = inherit.time;\n      timer = d3_timer(schedule, 0, time);\n      transition = lock[id] = {\n        tween: new d3_Map(),\n        time: time,\n        timer: timer,\n        delay: inherit.delay,\n        duration: inherit.duration,\n        ease: inherit.ease,\n        index: i\n      };\n      inherit = null;\n      ++lock.count;\n    }\n  }\n  d3.svg.axis = function() {\n    var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_;\n    function axis(g) {\n      g.each(function() {\n        var g = d3.select(this);\n        var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();\n        var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(\".tick\").data(ticks, scale1), tickEnter = tick.enter().insert(\"g\", \".domain\").attr(\"class\", \"tick\").style(\"opacity\", ε), tickExit = d3.transition(tick.exit()).style(\"opacity\", ε).remove(), tickUpdate = d3.transition(tick.order()).style(\"opacity\", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform;\n        var range = d3_scaleRange(scale1), path = g.selectAll(\".domain\").data([ 0 ]), pathUpdate = (path.enter().append(\"path\").attr(\"class\", \"domain\"), \n        d3.transition(path));\n        tickEnter.append(\"line\");\n        tickEnter.append(\"text\");\n        var lineEnter = tickEnter.select(\"line\"), lineUpdate = tickUpdate.select(\"line\"), text = tick.select(\"text\").text(tickFormat), textEnter = tickEnter.select(\"text\"), textUpdate = tickUpdate.select(\"text\"), sign = orient === \"top\" || orient === \"left\" ? -1 : 1, x1, x2, y1, y2;\n        if (orient === \"bottom\" || orient === \"top\") {\n          tickTransform = d3_svg_axisX, x1 = \"x\", y1 = \"y\", x2 = \"x2\", y2 = \"y2\";\n          text.attr(\"dy\", sign < 0 ? \"0em\" : \".71em\").style(\"text-anchor\", \"middle\");\n          pathUpdate.attr(\"d\", \"M\" + range[0] + \",\" + sign * outerTickSize + \"V0H\" + range[1] + \"V\" + sign * outerTickSize);\n        } else {\n          tickTransform = d3_svg_axisY, x1 = \"y\", y1 = \"x\", x2 = \"y2\", y2 = \"x2\";\n          text.attr(\"dy\", \".32em\").style(\"text-anchor\", sign < 0 ? \"end\" : \"start\");\n          pathUpdate.attr(\"d\", \"M\" + sign * outerTickSize + \",\" + range[0] + \"H0V\" + range[1] + \"H\" + sign * outerTickSize);\n        }\n        lineEnter.attr(y2, sign * innerTickSize);\n        textEnter.attr(y1, sign * tickSpacing);\n        lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize);\n        textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing);\n        if (scale1.rangeBand) {\n          var x = scale1, dx = x.rangeBand() / 2;\n          scale0 = scale1 = function(d) {\n            return x(d) + dx;\n          };\n        } else if (scale0.rangeBand) {\n          scale0 = scale1;\n        } else {\n          tickExit.call(tickTransform, scale1, scale0);\n        }\n        tickEnter.call(tickTransform, scale0, scale1);\n        tickUpdate.call(tickTransform, scale1, scale1);\n      });\n    }\n    axis.scale = function(x) {\n      if (!arguments.length) return scale;\n      scale = x;\n      return axis;\n    };\n    axis.orient = function(x) {\n      if (!arguments.length) return orient;\n      orient = x in d3_svg_axisOrients ? x + \"\" : d3_svg_axisDefaultOrient;\n      return axis;\n    };\n    axis.ticks = function() {\n      if (!arguments.length) return tickArguments_;\n      tickArguments_ = d3_array(arguments);\n      return axis;\n    };\n    axis.tickValues = function(x) {\n      if (!arguments.length) return tickValues;\n      tickValues = x;\n      return axis;\n    };\n    axis.tickFormat = function(x) {\n      if (!arguments.length) return tickFormat_;\n      tickFormat_ = x;\n      return axis;\n    };\n    axis.tickSize = function(x) {\n      var n = arguments.length;\n      if (!n) return innerTickSize;\n      innerTickSize = +x;\n      outerTickSize = +arguments[n - 1];\n      return axis;\n    };\n    axis.innerTickSize = function(x) {\n      if (!arguments.length) return innerTickSize;\n      innerTickSize = +x;\n      return axis;\n    };\n    axis.outerTickSize = function(x) {\n      if (!arguments.length) return outerTickSize;\n      outerTickSize = +x;\n      return axis;\n    };\n    axis.tickPadding = function(x) {\n      if (!arguments.length) return tickPadding;\n      tickPadding = +x;\n      return axis;\n    };\n    axis.tickSubdivide = function() {\n      return arguments.length && axis;\n    };\n    return axis;\n  };\n  var d3_svg_axisDefaultOrient = \"bottom\", d3_svg_axisOrients = {\n    top: 1,\n    right: 1,\n    bottom: 1,\n    left: 1\n  };\n  function d3_svg_axisX(selection, x0, x1) {\n    selection.attr(\"transform\", function(d) {\n      var v0 = x0(d);\n      return \"translate(\" + (isFinite(v0) ? v0 : x1(d)) + \",0)\";\n    });\n  }\n  function d3_svg_axisY(selection, y0, y1) {\n    selection.attr(\"transform\", function(d) {\n      var v0 = y0(d);\n      return \"translate(0,\" + (isFinite(v0) ? v0 : y1(d)) + \")\";\n    });\n  }\n  d3.svg.brush = function() {\n    var event = d3_eventDispatch(brush, \"brushstart\", \"brush\", \"brushend\"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0];\n    function brush(g) {\n      g.each(function() {\n        var g = d3.select(this).style(\"pointer-events\", \"all\").style(\"-webkit-tap-highlight-color\", \"rgba(0,0,0,0)\").on(\"mousedown.brush\", brushstart).on(\"touchstart.brush\", brushstart);\n        var background = g.selectAll(\".background\").data([ 0 ]);\n        background.enter().append(\"rect\").attr(\"class\", \"background\").style(\"visibility\", \"hidden\").style(\"cursor\", \"crosshair\");\n        g.selectAll(\".extent\").data([ 0 ]).enter().append(\"rect\").attr(\"class\", \"extent\").style(\"cursor\", \"move\");\n        var resize = g.selectAll(\".resize\").data(resizes, d3_identity);\n        resize.exit().remove();\n        resize.enter().append(\"g\").attr(\"class\", function(d) {\n          return \"resize \" + d;\n        }).style(\"cursor\", function(d) {\n          return d3_svg_brushCursor[d];\n        }).append(\"rect\").attr(\"x\", function(d) {\n          return /[ew]$/.test(d) ? -3 : null;\n        }).attr(\"y\", function(d) {\n          return /^[ns]/.test(d) ? -3 : null;\n        }).attr(\"width\", 6).attr(\"height\", 6).style(\"visibility\", \"hidden\");\n        resize.style(\"display\", brush.empty() ? \"none\" : null);\n        var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range;\n        if (x) {\n          range = d3_scaleRange(x);\n          backgroundUpdate.attr(\"x\", range[0]).attr(\"width\", range[1] - range[0]);\n          redrawX(gUpdate);\n        }\n        if (y) {\n          range = d3_scaleRange(y);\n          backgroundUpdate.attr(\"y\", range[0]).attr(\"height\", range[1] - range[0]);\n          redrawY(gUpdate);\n        }\n        redraw(gUpdate);\n      });\n    }\n    brush.event = function(g) {\n      g.each(function() {\n        var event_ = event.of(this, arguments), extent1 = {\n          x: xExtent,\n          y: yExtent,\n          i: xExtentDomain,\n          j: yExtentDomain\n        }, extent0 = this.__chart__ || extent1;\n        this.__chart__ = extent1;\n        if (d3_transitionInheritId) {\n          d3.select(this).transition().each(\"start.brush\", function() {\n            xExtentDomain = extent0.i;\n            yExtentDomain = extent0.j;\n            xExtent = extent0.x;\n            yExtent = extent0.y;\n            event_({\n              type: \"brushstart\"\n            });\n          }).tween(\"brush:brush\", function() {\n            var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y);\n            xExtentDomain = yExtentDomain = null;\n            return function(t) {\n              xExtent = extent1.x = xi(t);\n              yExtent = extent1.y = yi(t);\n              event_({\n                type: \"brush\",\n                mode: \"resize\"\n              });\n            };\n          }).each(\"end.brush\", function() {\n            xExtentDomain = extent1.i;\n            yExtentDomain = extent1.j;\n            event_({\n              type: \"brush\",\n              mode: \"resize\"\n            });\n            event_({\n              type: \"brushend\"\n            });\n          });\n        } else {\n          event_({\n            type: \"brushstart\"\n          });\n          event_({\n            type: \"brush\",\n            mode: \"resize\"\n          });\n          event_({\n            type: \"brushend\"\n          });\n        }\n      });\n    };\n    function redraw(g) {\n      g.selectAll(\".resize\").attr(\"transform\", function(d) {\n        return \"translate(\" + xExtent[+/e$/.test(d)] + \",\" + yExtent[+/^s/.test(d)] + \")\";\n      });\n    }\n    function redrawX(g) {\n      g.select(\".extent\").attr(\"x\", xExtent[0]);\n      g.selectAll(\".extent,.n>rect,.s>rect\").attr(\"width\", xExtent[1] - xExtent[0]);\n    }\n    function redrawY(g) {\n      g.select(\".extent\").attr(\"y\", yExtent[0]);\n      g.selectAll(\".extent,.e>rect,.w>rect\").attr(\"height\", yExtent[1] - yExtent[0]);\n    }\n    function brushstart() {\n      var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed(\"extent\"), dragRestore = d3_event_dragSuppress(target), center, origin = d3.mouse(target), offset;\n      var w = d3.select(d3_window(target)).on(\"keydown.brush\", keydown).on(\"keyup.brush\", keyup);\n      if (d3.event.changedTouches) {\n        w.on(\"touchmove.brush\", brushmove).on(\"touchend.brush\", brushend);\n      } else {\n        w.on(\"mousemove.brush\", brushmove).on(\"mouseup.brush\", brushend);\n      }\n      g.interrupt().selectAll(\"*\").interrupt();\n      if (dragging) {\n        origin[0] = xExtent[0] - origin[0];\n        origin[1] = yExtent[0] - origin[1];\n      } else if (resizing) {\n        var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);\n        offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ];\n        origin[0] = xExtent[ex];\n        origin[1] = yExtent[ey];\n      } else if (d3.event.altKey) center = origin.slice();\n      g.style(\"pointer-events\", \"none\").selectAll(\".resize\").style(\"display\", null);\n      d3.select(\"body\").style(\"cursor\", eventTarget.style(\"cursor\"));\n      event_({\n        type: \"brushstart\"\n      });\n      brushmove();\n      function keydown() {\n        if (d3.event.keyCode == 32) {\n          if (!dragging) {\n            center = null;\n            origin[0] -= xExtent[1];\n            origin[1] -= yExtent[1];\n            dragging = 2;\n          }\n          d3_eventPreventDefault();\n        }\n      }\n      function keyup() {\n        if (d3.event.keyCode == 32 && dragging == 2) {\n          origin[0] += xExtent[1];\n          origin[1] += yExtent[1];\n          dragging = 0;\n          d3_eventPreventDefault();\n        }\n      }\n      function brushmove() {\n        var point = d3.mouse(target), moved = false;\n        if (offset) {\n          point[0] += offset[0];\n          point[1] += offset[1];\n        }\n        if (!dragging) {\n          if (d3.event.altKey) {\n            if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ];\n            origin[0] = xExtent[+(point[0] < center[0])];\n            origin[1] = yExtent[+(point[1] < center[1])];\n          } else center = null;\n        }\n        if (resizingX && move1(point, x, 0)) {\n          redrawX(g);\n          moved = true;\n        }\n        if (resizingY && move1(point, y, 1)) {\n          redrawY(g);\n          moved = true;\n        }\n        if (moved) {\n          redraw(g);\n          event_({\n            type: \"brush\",\n            mode: dragging ? \"move\" : \"resize\"\n          });\n        }\n      }\n      function move1(point, scale, i) {\n        var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max;\n        if (dragging) {\n          r0 -= position;\n          r1 -= size + position;\n        }\n        min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i];\n        if (dragging) {\n          max = (min += position) + size;\n        } else {\n          if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));\n          if (position < min) {\n            max = min;\n            min = position;\n          } else {\n            max = position;\n          }\n        }\n        if (extent[0] != min || extent[1] != max) {\n          if (i) yExtentDomain = null; else xExtentDomain = null;\n          extent[0] = min;\n          extent[1] = max;\n          return true;\n        }\n      }\n      function brushend() {\n        brushmove();\n        g.style(\"pointer-events\", \"all\").selectAll(\".resize\").style(\"display\", brush.empty() ? \"none\" : null);\n        d3.select(\"body\").style(\"cursor\", null);\n        w.on(\"mousemove.brush\", null).on(\"mouseup.brush\", null).on(\"touchmove.brush\", null).on(\"touchend.brush\", null).on(\"keydown.brush\", null).on(\"keyup.brush\", null);\n        dragRestore();\n        event_({\n          type: \"brushend\"\n        });\n      }\n    }\n    brush.x = function(z) {\n      if (!arguments.length) return x;\n      x = z;\n      resizes = d3_svg_brushResizes[!x << 1 | !y];\n      return brush;\n    };\n    brush.y = function(z) {\n      if (!arguments.length) return y;\n      y = z;\n      resizes = d3_svg_brushResizes[!x << 1 | !y];\n      return brush;\n    };\n    brush.clamp = function(z) {\n      if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null;\n      if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z;\n      return brush;\n    };\n    brush.extent = function(z) {\n      var x0, x1, y0, y1, t;\n      if (!arguments.length) {\n        if (x) {\n          if (xExtentDomain) {\n            x0 = xExtentDomain[0], x1 = xExtentDomain[1];\n          } else {\n            x0 = xExtent[0], x1 = xExtent[1];\n            if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);\n            if (x1 < x0) t = x0, x0 = x1, x1 = t;\n          }\n        }\n        if (y) {\n          if (yExtentDomain) {\n            y0 = yExtentDomain[0], y1 = yExtentDomain[1];\n          } else {\n            y0 = yExtent[0], y1 = yExtent[1];\n            if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);\n            if (y1 < y0) t = y0, y0 = y1, y1 = t;\n          }\n        }\n        return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];\n      }\n      if (x) {\n        x0 = z[0], x1 = z[1];\n        if (y) x0 = x0[0], x1 = x1[0];\n        xExtentDomain = [ x0, x1 ];\n        if (x.invert) x0 = x(x0), x1 = x(x1);\n        if (x1 < x0) t = x0, x0 = x1, x1 = t;\n        if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ];\n      }\n      if (y) {\n        y0 = z[0], y1 = z[1];\n        if (x) y0 = y0[1], y1 = y1[1];\n        yExtentDomain = [ y0, y1 ];\n        if (y.invert) y0 = y(y0), y1 = y(y1);\n        if (y1 < y0) t = y0, y0 = y1, y1 = t;\n        if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ];\n      }\n      return brush;\n    };\n    brush.clear = function() {\n      if (!brush.empty()) {\n        xExtent = [ 0, 0 ], yExtent = [ 0, 0 ];\n        xExtentDomain = yExtentDomain = null;\n      }\n      return brush;\n    };\n    brush.empty = function() {\n      return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1];\n    };\n    return d3.rebind(brush, event, \"on\");\n  };\n  var d3_svg_brushCursor = {\n    n: \"ns-resize\",\n    e: \"ew-resize\",\n    s: \"ns-resize\",\n    w: \"ew-resize\",\n    nw: \"nwse-resize\",\n    ne: \"nesw-resize\",\n    se: \"nwse-resize\",\n    sw: \"nesw-resize\"\n  };\n  var d3_svg_brushResizes = [ [ \"n\", \"e\", \"s\", \"w\", \"nw\", \"ne\", \"se\", \"sw\" ], [ \"e\", \"w\" ], [ \"n\", \"s\" ], [] ];\n  var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat;\n  var d3_time_formatUtc = d3_time_format.utc;\n  var d3_time_formatIso = d3_time_formatUtc(\"%Y-%m-%dT%H:%M:%S.%LZ\");\n  d3_time_format.iso = Date.prototype.toISOString && +new Date(\"2000-01-01T00:00:00.000Z\") ? d3_time_formatIsoNative : d3_time_formatIso;\n  function d3_time_formatIsoNative(date) {\n    return date.toISOString();\n  }\n  d3_time_formatIsoNative.parse = function(string) {\n    var date = new Date(string);\n    return isNaN(date) ? null : date;\n  };\n  d3_time_formatIsoNative.toString = d3_time_formatIso.toString;\n  d3_time.second = d3_time_interval(function(date) {\n    return new d3_date(Math.floor(date / 1e3) * 1e3);\n  }, function(date, offset) {\n    date.setTime(date.getTime() + Math.floor(offset) * 1e3);\n  }, function(date) {\n    return date.getSeconds();\n  });\n  d3_time.seconds = d3_time.second.range;\n  d3_time.seconds.utc = d3_time.second.utc.range;\n  d3_time.minute = d3_time_interval(function(date) {\n    return new d3_date(Math.floor(date / 6e4) * 6e4);\n  }, function(date, offset) {\n    date.setTime(date.getTime() + Math.floor(offset) * 6e4);\n  }, function(date) {\n    return date.getMinutes();\n  });\n  d3_time.minutes = d3_time.minute.range;\n  d3_time.minutes.utc = d3_time.minute.utc.range;\n  d3_time.hour = d3_time_interval(function(date) {\n    var timezone = date.getTimezoneOffset() / 60;\n    return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);\n  }, function(date, offset) {\n    date.setTime(date.getTime() + Math.floor(offset) * 36e5);\n  }, function(date) {\n    return date.getHours();\n  });\n  d3_time.hours = d3_time.hour.range;\n  d3_time.hours.utc = d3_time.hour.utc.range;\n  d3_time.month = d3_time_interval(function(date) {\n    date = d3_time.day(date);\n    date.setDate(1);\n    return date;\n  }, function(date, offset) {\n    date.setMonth(date.getMonth() + offset);\n  }, function(date) {\n    return date.getMonth();\n  });\n  d3_time.months = d3_time.month.range;\n  d3_time.months.utc = d3_time.month.utc.range;\n  function d3_time_scale(linear, methods, format) {\n    function scale(x) {\n      return linear(x);\n    }\n    scale.invert = function(x) {\n      return d3_time_scaleDate(linear.invert(x));\n    };\n    scale.domain = function(x) {\n      if (!arguments.length) return linear.domain().map(d3_time_scaleDate);\n      linear.domain(x);\n      return scale;\n    };\n    function tickMethod(extent, count) {\n      var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target);\n      return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) {\n        return d / 31536e6;\n      }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i];\n    }\n    scale.nice = function(interval, skip) {\n      var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" && tickMethod(extent, interval);\n      if (method) interval = method[0], skip = method[1];\n      function skipped(date) {\n        return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length;\n      }\n      return scale.domain(d3_scale_nice(domain, skip > 1 ? {\n        floor: function(date) {\n          while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1);\n          return date;\n        },\n        ceil: function(date) {\n          while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1);\n          return date;\n        }\n      } : interval));\n    };\n    scale.ticks = function(interval, skip) {\n      var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === \"number\" ? tickMethod(extent, interval) : !interval.range && [ {\n        range: interval\n      }, skip ];\n      if (method) interval = method[0], skip = method[1];\n      return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);\n    };\n    scale.tickFormat = function() {\n      return format;\n    };\n    scale.copy = function() {\n      return d3_time_scale(linear.copy(), methods, format);\n    };\n    return d3_scale_linearRebind(scale, linear);\n  }\n  function d3_time_scaleDate(t) {\n    return new Date(t);\n  }\n  var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];\n  var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ];\n  var d3_time_scaleLocalFormat = d3_time_format.multi([ [ \".%L\", function(d) {\n    return d.getMilliseconds();\n  } ], [ \":%S\", function(d) {\n    return d.getSeconds();\n  } ], [ \"%I:%M\", function(d) {\n    return d.getMinutes();\n  } ], [ \"%I %p\", function(d) {\n    return d.getHours();\n  } ], [ \"%a %d\", function(d) {\n    return d.getDay() && d.getDate() != 1;\n  } ], [ \"%b %d\", function(d) {\n    return d.getDate() != 1;\n  } ], [ \"%B\", function(d) {\n    return d.getMonth();\n  } ], [ \"%Y\", d3_true ] ]);\n  var d3_time_scaleMilliseconds = {\n    range: function(start, stop, step) {\n      return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate);\n    },\n    floor: d3_identity,\n    ceil: d3_identity\n  };\n  d3_time_scaleLocalMethods.year = d3_time.year;\n  d3_time.scale = function() {\n    return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);\n  };\n  var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) {\n    return [ m[0].utc, m[1] ];\n  });\n  var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ \".%L\", function(d) {\n    return d.getUTCMilliseconds();\n  } ], [ \":%S\", function(d) {\n    return d.getUTCSeconds();\n  } ], [ \"%I:%M\", function(d) {\n    return d.getUTCMinutes();\n  } ], [ \"%I %p\", function(d) {\n    return d.getUTCHours();\n  } ], [ \"%a %d\", function(d) {\n    return d.getUTCDay() && d.getUTCDate() != 1;\n  } ], [ \"%b %d\", function(d) {\n    return d.getUTCDate() != 1;\n  } ], [ \"%B\", function(d) {\n    return d.getUTCMonth();\n  } ], [ \"%Y\", d3_true ] ]);\n  d3_time_scaleUtcMethods.year = d3_time.year.utc;\n  d3_time.scale.utc = function() {\n    return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat);\n  };\n  d3.text = d3_xhrType(function(request) {\n    return request.responseText;\n  });\n  d3.json = function(url, callback) {\n    return d3_xhr(url, \"application/json\", d3_json, callback);\n  };\n  function d3_json(request) {\n    return JSON.parse(request.responseText);\n  }\n  d3.html = function(url, callback) {\n    return d3_xhr(url, \"text/html\", d3_html, callback);\n  };\n  function d3_html(request) {\n    var range = d3_document.createRange();\n    range.selectNode(d3_document.body);\n    return range.createContextualFragment(request.responseText);\n  }\n  d3.xml = d3_xhrType(function(request) {\n    return request.responseXML;\n  });\n  if (typeof define === \"function\" && define.amd) this.d3 = d3, define(d3); else if (typeof module === \"object\" && module.exports) module.exports = d3; else this.d3 = d3;\n}();"
  },
  {
    "path": "html/lib/flotr2/CONTRIBUTING.md",
    "content": "# Flotr2 Contribution Guidelines\n\nFlotr2 requires community involvement to be a successful project.  Please \nreach out via the community or http://humblesoftware.com/ if you are \ninterested in contributing.\n\n## Help\n\nFor questions about the usage of Flotr2, please visit the Google Group at \nhttps://groups.google.com/group/flotr2/.  If appropriate, please include a fork of http://jsfiddle.net/cesutherland/ZFBj5/ with your\nquestion.\n\n## Bugs\n\n* Create an example of your issue in a fork of http://jsfiddle.net/cesutherland/ZFBj5/\n* File a ticket at https://github.com/HumbleSoftware/Flotr2/issues\n\n## Submitting Changes\n\n* Push changes to a topic branch in your fork of Flotr2\n* Submit a pull request to https://github.com/HumbleSoftware/Flotr2\n"
  },
  {
    "path": "html/lib/flotr2/README.md",
    "content": "Flotr2\n======\n\nThe Canvas graphing library.\n\n![Google Groups](http://groups.google.com/intl/en/images/logos/groups_logo_sm.gif)\n\nhttp://groups.google.com/group/flotr2/\n\nPlease fork http://jsfiddle.net/cesutherland/ZFBj5/ with your question or bug reproduction case.\n\n\nAPI\n---\n\nThe API consists of a primary draw method which accepts a configuration object, helper methods, and several microlibs.\n\n### Example\n\n```javascript\n  var\n    // Container div:\n    container = document.getElementById(\"flotr-example-graph\"),\n    // First data series:\n    d1 = [[0, 3], [4, 8], [8, 5], [9, 13]],\n    // Second data series:\n    d2 = [],\n    // A couple flotr configuration options:\n    options = {\n      xaxis: {\n        minorTickFreq: 4\n      }, \n      grid: {\n        minorVerticalLines: true\n      }\n    },\n    i, graph;\n\n  // Generated second data set:\n  for (i = 0; i < 14; i += 0.5) {\n    d2.push([i, Math.sin(i)]);\n  }\n\n  // Draw the graph:\n  graph = Flotr.draw(\n    container,  // Container element\n    [ d1, d2 ], // Array of data series\n    options     // Configuration options\n  );\n```\n\n### Microlibs\n\n* [underscore.js](http://documentcloud.github.com/underscore/)\n* [bean.js](https://github.com/fat/bean)\n\nExtending\n---------\n\nFlotr may be extended by adding new plugins and graph types.\n\n### Graph Types\n\nGraph types define how a particular chart is rendered.  Examples include line, bar, pie.\n\nExisting graph types are found in `js/types/`.\n\n### Plugins\n\nPlugins extend the core of flotr with new functionality.  They can add interactions, new decorations, etc.  Examples \ninclude titles, labels and selection.\n\nThe plugins included are found in `js/plugins/`.\n\nDevelopment\n-----------\n\nThis project uses [smoosh](https://github.com/fat/smoosh) to build and [jasmine](http://pivotal.github.com/jasmine/) \nwith [js-imagediff](https://github.com/HumbleSoftware/js-imagediff) to test.  Tests may be executed by \n[jasmine-headless-webkit](http://johnbintz.github.com/jasmine-headless-webkit/) with \n`cd spec; jasmine-headless-webkit -j jasmine.yml -c` or by a browser by navigating to \n`flotr2/spec/SpecRunner.html`.\n\nShoutouts\n---------\n\nThanks to Bas Wenneker, Fabien Ménager and others for all the work on the original Flotr.\nThanks to Jochen Berger and Jordan Santell for their contributions to Flotr2.\n\n"
  },
  {
    "path": "html/lib/flotr2/flotr2.amd.js",
    "content": "(function (root, factory) {\n    if (typeof define === 'function' && define.amd) {\n        // AMD. Register as an anonymous module.\n        define(['bean', 'underscore'], function (bean, _) {\n            // Also create a global in case some scripts\n            // that are loaded still are looking for\n            // a global even when an AMD loader is in use.\n            return (root.Flotr = factory(bean, _));\n        });\n    } else {\n        // Browser globals\n        root.Flotr = factory(root.bean, root._);\n    }\n}(this, function (bean, _) {\n\n/**\n * Flotr2 (c) 2012 Carl Sutherland\n * MIT License\n * Special thanks to:\n * Flotr: http://code.google.com/p/flotr/ (fork)\n * Flot: https://github.com/flot/flot (original fork)\n */\n(function () {\n\nvar\n  global = this,\n  previousFlotr = this.Flotr,\n  Flotr;\n\nFlotr = {\n  _: _,\n  bean: bean,\n  isIphone: /iphone/i.test(navigator.userAgent),\n  isIE: (navigator.appVersion.indexOf(\"MSIE\") != -1 ? parseFloat(navigator.appVersion.split(\"MSIE\")[1]) : false),\n  \n  /**\n   * An object of the registered graph types. Use Flotr.addType(type, object)\n   * to add your own type.\n   */\n  graphTypes: {},\n  \n  /**\n   * The list of the registered plugins\n   */\n  plugins: {},\n  \n  /**\n   * Can be used to add your own chart type. \n   * @param {String} name - Type of chart, like 'pies', 'bars' etc.\n   * @param {String} graphType - The object containing the basic drawing functions (draw, etc)\n   */\n  addType: function(name, graphType){\n    Flotr.graphTypes[name] = graphType;\n    Flotr.defaultOptions[name] = graphType.options || {};\n    Flotr.defaultOptions.defaultType = Flotr.defaultOptions.defaultType || name;\n  },\n  \n  /**\n   * Can be used to add a plugin\n   * @param {String} name - The name of the plugin\n   * @param {String} plugin - The object containing the plugin's data (callbacks, options, function1, function2, ...)\n   */\n  addPlugin: function(name, plugin){\n    Flotr.plugins[name] = plugin;\n    Flotr.defaultOptions[name] = plugin.options || {};\n  },\n  \n  /**\n   * Draws the graph. This function is here for backwards compatibility with Flotr version 0.1.0alpha.\n   * You could also draw graphs by directly calling Flotr.Graph(element, data, options).\n   * @param {Element} el - element to insert the graph into\n   * @param {Object} data - an array or object of dataseries\n   * @param {Object} options - an object containing options\n   * @param {Class} _GraphKlass_ - (optional) Class to pass the arguments to, defaults to Flotr.Graph\n   * @return {Object} returns a new graph object and of course draws the graph.\n   */\n  draw: function(el, data, options, GraphKlass){  \n    GraphKlass = GraphKlass || Flotr.Graph;\n    return new GraphKlass(el, data, options);\n  },\n  \n  /**\n   * Recursively merges two objects.\n   * @param {Object} src - source object (likely the object with the least properties)\n   * @param {Object} dest - destination object (optional, object with the most properties)\n   * @return {Object} recursively merged Object\n   * @TODO See if we can't remove this.\n   */\n  merge: function(src, dest){\n    var i, v, result = dest || {};\n\n    for (i in src) {\n      v = src[i];\n      if (v && typeof(v) === 'object') {\n        if (v.constructor === Array) {\n          result[i] = this._.clone(v);\n        } else if (v.constructor !== RegExp && !this._.isElement(v)) {\n          result[i] = Flotr.merge(v, (dest ? dest[i] : undefined));\n        } else {\n          result[i] = v;\n        }\n      } else {\n        result[i] = v;\n      }\n    }\n\n    return result;\n  },\n  \n  /**\n   * Recursively clones an object.\n   * @param {Object} object - The object to clone\n   * @return {Object} the clone\n   * @TODO See if we can't remove this.\n   */\n  clone: function(object){\n    return Flotr.merge(object, {});\n  },\n  \n  /**\n   * Function calculates the ticksize and returns it.\n   * @param {Integer} noTicks - number of ticks\n   * @param {Integer} min - lower bound integer value for the current axis\n   * @param {Integer} max - upper bound integer value for the current axis\n   * @param {Integer} decimals - number of decimals for the ticks\n   * @return {Integer} returns the ticksize in pixels\n   */\n  getTickSize: function(noTicks, min, max, decimals){\n    var delta = (max - min) / noTicks,\n        magn = Flotr.getMagnitude(delta),\n        tickSize = 10,\n        norm = delta / magn; // Norm is between 1.0 and 10.0.\n        \n    if(norm < 1.5) tickSize = 1;\n    else if(norm < 2.25) tickSize = 2;\n    else if(norm < 3) tickSize = ((decimals === 0) ? 2 : 2.5);\n    else if(norm < 7.5) tickSize = 5;\n    \n    return tickSize * magn;\n  },\n  \n  /**\n   * Default tick formatter.\n   * @param {String, Integer} val - tick value integer\n   * @param {Object} axisOpts - the axis' options\n   * @return {String} formatted tick string\n   */\n  defaultTickFormatter: function(val, axisOpts){\n    return val+'';\n  },\n  \n  /**\n   * Formats the mouse tracker values.\n   * @param {Object} obj - Track value Object {x:..,y:..}\n   * @return {String} Formatted track string\n   */\n  defaultTrackFormatter: function(obj){\n    return '('+obj.x+', '+obj.y+')';\n  }, \n  \n  /**\n   * Utility function to convert file size values in bytes to kB, MB, ...\n   * @param value {Number} - The value to convert\n   * @param precision {Number} - The number of digits after the comma (default: 2)\n   * @param base {Number} - The base (default: 1000)\n   */\n  engineeringNotation: function(value, precision, base){\n    var sizes =         ['Y','Z','E','P','T','G','M','k',''],\n        fractionSizes = ['y','z','a','f','p','n','µ','m',''],\n        total = sizes.length;\n\n    base = base || 1000;\n    precision = Math.pow(10, precision || 2);\n\n    if (value === 0) return 0;\n\n    if (value > 1) {\n      while (total-- && (value >= base)) value /= base;\n    }\n    else {\n      sizes = fractionSizes;\n      total = sizes.length;\n      while (total-- && (value < 1)) value *= base;\n    }\n\n    return (Math.round(value * precision) / precision) + sizes[total];\n  },\n  \n  /**\n   * Returns the magnitude of the input value.\n   * @param {Integer, Float} x - integer or float value\n   * @return {Integer, Float} returns the magnitude of the input value\n   */\n  getMagnitude: function(x){\n    return Math.pow(10, Math.floor(Math.log(x) / Math.LN10));\n  },\n  toPixel: function(val){\n    return Math.floor(val)+0.5;//((val-Math.round(val) < 0.4) ? (Math.floor(val)-0.5) : val);\n  },\n  toRad: function(angle){\n    return -angle * (Math.PI/180);\n  },\n  floorInBase: function(n, base) {\n    return base * Math.floor(n / base);\n  },\n  drawText: function(ctx, text, x, y, style) {\n    if (!ctx.fillText) {\n      ctx.drawText(text, x, y, style);\n      return;\n    }\n    \n    style = this._.extend({\n      size: Flotr.defaultOptions.fontSize,\n      color: '#000000',\n      textAlign: 'left',\n      textBaseline: 'bottom',\n      weight: 1,\n      angle: 0\n    }, style);\n    \n    ctx.save();\n    ctx.translate(x, y);\n    ctx.rotate(style.angle);\n    ctx.fillStyle = style.color;\n    ctx.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    ctx.textAlign = style.textAlign;\n    ctx.textBaseline = style.textBaseline;\n    ctx.fillText(text, 0, 0);\n    ctx.restore();\n  },\n  getBestTextAlign: function(angle, style) {\n    style = style || {textAlign: 'center', textBaseline: 'middle'};\n    angle += Flotr.getTextAngleFromAlign(style);\n    \n    if (Math.abs(Math.cos(angle)) > 10e-3) \n      style.textAlign    = (Math.cos(angle) > 0 ? 'right' : 'left');\n    \n    if (Math.abs(Math.sin(angle)) > 10e-3) \n      style.textBaseline = (Math.sin(angle) > 0 ? 'top' : 'bottom');\n    \n    return style;\n  },\n  alignTable: {\n    'right middle' : 0,\n    'right top'    : Math.PI/4,\n    'center top'   : Math.PI/2,\n    'left top'     : 3*(Math.PI/4),\n    'left middle'  : Math.PI,\n    'left bottom'  : -3*(Math.PI/4),\n    'center bottom': -Math.PI/2,\n    'right bottom' : -Math.PI/4,\n    'center middle': 0\n  },\n  getTextAngleFromAlign: function(style) {\n    return Flotr.alignTable[style.textAlign+' '+style.textBaseline] || 0;\n  },\n  noConflict : function () {\n    global.Flotr = previousFlotr;\n    return this;\n  }\n};\n\nglobal.Flotr = Flotr;\n\n})();\n\n/**\n * Flotr Defaults\n */\nFlotr.defaultOptions = {\n  colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.\n  ieBackgroundColor: '#FFFFFF', // Background color for excanvas clipping\n  title: null,             // => The graph's title\n  subtitle: null,          // => The graph's subtitle\n  shadowSize: 4,           // => size of the 'fake' shadow\n  defaultType: null,       // => default series type\n  HtmlText: true,          // => wether to draw the text using HTML or on the canvas\n  fontColor: '#545454',    // => default font color\n  fontSize: 7.5,           // => canvas' text font size\n  resolution: 1,           // => resolution of the graph, to have printer-friendly graphs !\n  parseFloat: true,        // => whether to preprocess data for floats (ie. if input is string)\n  preventDefault: true,    // => preventDefault by default for mobile events.  Turn off to enable scroll.\n  xaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 0,         // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => color of the ticks\n    mode: 'normal',        // => can be 'time' or 'normal'\n    timeFormat: null,\n    timeMode:'UTC',        // => For UTC time ('local' for local time).\n    timeUnit:'millisecond',// => Unit for time (millisecond, second, minute, hour, day, month, year)\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  x2axis: {},\n  yaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 90,        // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => The color of the ticks\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  y2axis: {\n    titleAngle: 270\n  },\n  grid: {\n    color: '#545454',      // => primary color used for outline and labels\n    backgroundColor: null, // => null for transparent, else color\n    backgroundImage: null, // => background image. String or object with src, left and top\n    watermarkAlpha: 0.4,   // => \n    tickColor: '#DDDDDD',  // => color used for the ticks\n    labelMargin: 3,        // => margin in pixels\n    verticalLines: true,   // => whether to show gridlines in vertical direction\n    minorVerticalLines: null, // => whether to show gridlines for minor ticks in vertical dir.\n    horizontalLines: true, // => whether to show gridlines in horizontal direction\n    minorHorizontalLines: null, // => whether to show gridlines for minor ticks in horizontal dir.\n    outlineWidth: 1,       // => width of the grid outline/border in pixels\n    outline : 'nsew',      // => walls of the outline to display\n    circular: false        // => if set to true, the grid will be circular, must be used when radars are drawn\n  },\n  mouse: {\n    track: false,          // => true to track the mouse, no tracking otherwise\n    trackAll: false,\n    position: 'se',        // => position of the value box (default south-east)\n    relative: false,       // => next to the mouse cursor\n    trackFormatter: Flotr.defaultTrackFormatter, // => formats the values in the value box\n    margin: 5,             // => margin in pixels of the valuebox\n    lineColor: '#FF3F19',  // => line color of points that are drawn when mouse comes near a value of a series\n    trackDecimals: 1,      // => decimals for the track values\n    sensibility: 2,        // => the lower this number, the more precise you have to aim to show a value\n    trackY: true,          // => whether or not to track the mouse in the y axis\n    radius: 3,             // => radius of the track point\n    fillColor: null,       // => color to fill our select bar with only applies to bar and similar graphs (only bars for now)\n    fillOpacity: 0.4       // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill \n  }\n};\n\n/**\n * Flotr Color\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\n// Constructor\nfunction Color (r, g, b, a) {\n  this.rgba = ['r','g','b','a'];\n  var x = 4;\n  while(-1<--x){\n    this[this.rgba[x]] = arguments[x] || ((x==3) ? 1.0 : 0);\n  }\n  this.normalize();\n}\n\n// Constants\nvar COLOR_NAMES = {\n  aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],\n  brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],\n  darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],\n  darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],\n  darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],\n  khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],\n  lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],\n  maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],\n  violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]\n};\n\nColor.prototype = {\n  scale: function(rf, gf, bf, af){\n    var x = 4;\n    while (-1 < --x) {\n      if (!_.isUndefined(arguments[x])) this[this.rgba[x]] *= arguments[x];\n    }\n    return this.normalize();\n  },\n  alpha: function(alpha) {\n    if (!_.isUndefined(alpha) && !_.isNull(alpha)) {\n      this.a = alpha;\n    }\n    return this.normalize();\n  },\n  clone: function(){\n    return new Color(this.r, this.b, this.g, this.a);\n  },\n  limit: function(val,minVal,maxVal){\n    return Math.max(Math.min(val, maxVal), minVal);\n  },\n  normalize: function(){\n    var limit = this.limit;\n    this.r = limit(parseInt(this.r, 10), 0, 255);\n    this.g = limit(parseInt(this.g, 10), 0, 255);\n    this.b = limit(parseInt(this.b, 10), 0, 255);\n    this.a = limit(this.a, 0, 1);\n    return this;\n  },\n  distance: function(color){\n    if (!color) return;\n    color = new Color.parse(color);\n    var dist = 0, x = 3;\n    while(-1<--x){\n      dist += Math.abs(this[this.rgba[x]] - color[this.rgba[x]]);\n    }\n    return dist;\n  },\n  toString: function(){\n    return (this.a >= 1.0) ? 'rgb('+[this.r,this.g,this.b].join(',')+')' : 'rgba('+[this.r,this.g,this.b,this.a].join(',')+')';\n  },\n  contrast: function () {\n    var\n      test = 1 - ( 0.299 * this.r + 0.587 * this.g + 0.114 * this.b) / 255;\n    return (test < 0.5 ? '#000000' : '#ffffff');\n  }\n};\n\n_.extend(Color, {\n  /**\n   * Parses a color string and returns a corresponding Color.\n   * The different tests are in order of probability to improve speed.\n   * @param {String, Color} str - string thats representing a color\n   * @return {Color} returns a Color object or false\n   */\n  parse: function(color){\n    if (color instanceof Color) return color;\n\n    var result;\n\n    // #a0b1c2\n    if((result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)))\n      return new Color(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16));\n\n    // rgb(num,num,num)\n    if((result = /rgb\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10));\n  \n    // #fff\n    if((result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)))\n      return new Color(parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16));\n  \n    // rgba(num,num,num,num)\n    if((result = /rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10), parseFloat(result[4]));\n      \n    // rgb(num%,num%,num%)\n    if((result = /rgb\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55);\n  \n    // rgba(num%,num%,num%,num)\n    if((result = /rgba\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));\n\n    // Otherwise, we're most likely dealing with a named color.\n    var name = (color+'').replace(/^\\s*([\\S\\s]*?)\\s*$/, '$1').toLowerCase();\n    if(name == 'transparent'){\n      return new Color(255, 255, 255, 0);\n    }\n    return (result = COLOR_NAMES[name]) ? new Color(result[0], result[1], result[2]) : new Color(0, 0, 0, 0);\n  },\n\n  /**\n   * Process color and options into color style.\n   */\n  processColor: function(color, options) {\n\n    var opacity = options.opacity;\n    if (!color) return 'rgba(0, 0, 0, 0)';\n    if (color instanceof Color) return color.alpha(opacity).toString();\n    if (_.isString(color)) return Color.parse(color).alpha(opacity).toString();\n    \n    var grad = color.colors ? color : {colors: color};\n    \n    if (!options.ctx) {\n      if (!_.isArray(grad.colors)) return 'rgba(0, 0, 0, 0)';\n      return Color.parse(_.isArray(grad.colors[0]) ? grad.colors[0][1] : grad.colors[0]).alpha(opacity).toString();\n    }\n    grad = _.extend({start: 'top', end: 'bottom'}, grad); \n    \n    if (/top/i.test(grad.start))  options.x1 = 0;\n    if (/left/i.test(grad.start)) options.y1 = 0;\n    if (/bottom/i.test(grad.end)) options.x2 = 0;\n    if (/right/i.test(grad.end))  options.y2 = 0;\n\n    var i, c, stop, gradient = options.ctx.createLinearGradient(options.x1, options.y1, options.x2, options.y2);\n    for (i = 0; i < grad.colors.length; i++) {\n      c = grad.colors[i];\n      if (_.isArray(c)) {\n        stop = c[0];\n        c = c[1];\n      }\n      else stop = i / (grad.colors.length-1);\n      gradient.addColorStop(stop, Color.parse(c).alpha(opacity));\n    }\n    return gradient;\n  }\n});\n\nFlotr.Color = Color;\n\n})();\n\n/**\n * Flotr Date\n */\nFlotr.Date = {\n\n  set : function (date, name, mode, value) {\n    mode = mode || 'UTC';\n    name = 'set' + (mode === 'UTC' ? 'UTC' : '') + name;\n    date[name](value);\n  },\n\n  get : function (date, name, mode) {\n    mode = mode || 'UTC';\n    name = 'get' + (mode === 'UTC' ? 'UTC' : '') + name;\n    return date[name]();\n  },\n\n  format: function(d, format, mode) {\n    if (!d) return;\n\n    // We should maybe use an \"official\" date format spec, like PHP date() or ColdFusion \n    // http://fr.php.net/manual/en/function.date.php\n    // http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_29.html\n    var\n      get = this.get,\n      tokens = {\n        h: get(d, 'Hours', mode).toString(),\n        H: leftPad(get(d, 'Hours', mode)),\n        M: leftPad(get(d, 'Minutes', mode)),\n        S: leftPad(get(d, 'Seconds', mode)),\n        s: get(d, 'Milliseconds', mode),\n        d: get(d, 'Date', mode).toString(),\n        m: (get(d, 'Month', mode) + 1).toString(),\n        y: get(d, 'FullYear', mode).toString(),\n        b: Flotr.Date.monthNames[get(d, 'Month', mode)]\n      };\n\n    function leftPad(n){\n      n += '';\n      return n.length == 1 ? \"0\" + n : n;\n    }\n    \n    var r = [], c,\n        escape = false;\n    \n    for (var i = 0; i < format.length; ++i) {\n      c = format.charAt(i);\n      \n      if (escape) {\n        r.push(tokens[c] || c);\n        escape = false;\n      }\n      else if (c == \"%\")\n        escape = true;\n      else\n        r.push(c);\n    }\n    return r.join('');\n  },\n  getFormat: function(time, span) {\n    var tu = Flotr.Date.timeUnits;\n         if (time < tu.second) return \"%h:%M:%S.%s\";\n    else if (time < tu.minute) return \"%h:%M:%S\";\n    else if (time < tu.day)    return (span < 2 * tu.day) ? \"%h:%M\" : \"%b %d %h:%M\";\n    else if (time < tu.month)  return \"%b %d\";\n    else if (time < tu.year)   return (span < tu.year) ? \"%b\" : \"%b %y\";\n    else                       return \"%y\";\n  },\n  formatter: function (v, axis) {\n    var\n      options = axis.options,\n      scale = Flotr.Date.timeUnits[options.timeUnit],\n      d = new Date(v * scale);\n\n    // first check global format\n    if (axis.options.timeFormat)\n      return Flotr.Date.format(d, options.timeFormat, options.timeMode);\n    \n    var span = (axis.max - axis.min) * scale,\n        t = axis.tickSize * Flotr.Date.timeUnits[axis.tickUnit];\n\n    return Flotr.Date.format(d, Flotr.Date.getFormat(t, span), options.timeMode);\n  },\n  generator: function(axis) {\n\n     var\n      set       = this.set,\n      get       = this.get,\n      timeUnits = this.timeUnits,\n      spec      = this.spec,\n      options   = axis.options,\n      mode      = options.timeMode,\n      scale     = timeUnits[options.timeUnit],\n      min       = axis.min * scale,\n      max       = axis.max * scale,\n      delta     = (max - min) / options.noTicks,\n      ticks     = [],\n      tickSize  = axis.tickSize,\n      tickUnit,\n      formatter, i;\n\n    // Use custom formatter or time tick formatter\n    formatter = (options.tickFormatter === Flotr.defaultTickFormatter ?\n      this.formatter : options.tickFormatter\n    );\n\n    for (i = 0; i < spec.length - 1; ++i) {\n      var d = spec[i][0] * timeUnits[spec[i][1]];\n      if (delta < (d + spec[i+1][0] * timeUnits[spec[i+1][1]]) / 2 && d >= tickSize)\n        break;\n    }\n    tickSize = spec[i][0];\n    tickUnit = spec[i][1];\n\n    // special-case the possibility of several years\n    if (tickUnit == \"year\") {\n      tickSize = Flotr.getTickSize(options.noTicks*timeUnits.year, min, max, 0);\n\n      // Fix for 0.5 year case\n      if (tickSize == 0.5) {\n        tickUnit = \"month\";\n        tickSize = 6;\n      }\n    }\n\n    axis.tickUnit = tickUnit;\n    axis.tickSize = tickSize;\n\n    var step = tickSize * timeUnits[tickUnit];\n    d = new Date(min);\n\n    function setTick (name) {\n      set(d, name, mode, Flotr.floorInBase(\n        get(d, name, mode), tickSize\n      ));\n    }\n\n    switch (tickUnit) {\n      case \"millisecond\": setTick('Milliseconds'); break;\n      case \"second\": setTick('Seconds'); break;\n      case \"minute\": setTick('Minutes'); break;\n      case \"hour\": setTick('Hours'); break;\n      case \"month\": setTick('Month'); break;\n      case \"year\": setTick('FullYear'); break;\n    }\n    \n    // reset smaller components\n    if (step >= timeUnits.second)  set(d, 'Milliseconds', mode, 0);\n    if (step >= timeUnits.minute)  set(d, 'Seconds', mode, 0);\n    if (step >= timeUnits.hour)    set(d, 'Minutes', mode, 0);\n    if (step >= timeUnits.day)     set(d, 'Hours', mode, 0);\n    if (step >= timeUnits.day * 4) set(d, 'Date', mode, 1);\n    if (step >= timeUnits.year)    set(d, 'Month', mode, 0);\n\n    var carry = 0, v = NaN, prev;\n    do {\n      prev = v;\n      v = d.getTime();\n      ticks.push({ v: v / scale, label: formatter(v / scale, axis) });\n      if (tickUnit == \"month\") {\n        if (tickSize < 1) {\n          /* a bit complicated - we'll divide the month up but we need to take care of fractions\n           so we don't end up in the middle of a day */\n          set(d, 'Date', mode, 1);\n          var start = d.getTime();\n          set(d, 'Month', mode, get(d, 'Month', mode) + 1);\n          var end = d.getTime();\n          d.setTime(v + carry * timeUnits.hour + (end - start) * tickSize);\n          carry = get(d, 'Hours', mode);\n          set(d, 'Hours', mode, 0);\n        }\n        else\n          set(d, 'Month', mode, get(d, 'Month', mode) + tickSize);\n      }\n      else if (tickUnit == \"year\") {\n        set(d, 'FullYear', mode, get(d, 'FullYear', mode) + tickSize);\n      }\n      else\n        d.setTime(v + step);\n\n    } while (v < max && v != prev);\n\n    return ticks;\n  },\n  timeUnits: {\n    millisecond: 1,\n    second: 1000,\n    minute: 1000 * 60,\n    hour:   1000 * 60 * 60,\n    day:    1000 * 60 * 60 * 24,\n    month:  1000 * 60 * 60 * 24 * 30,\n    year:   1000 * 60 * 60 * 24 * 365.2425\n  },\n  // the allowed tick sizes, after 1 year we use an integer algorithm\n  spec: [\n    [1, \"millisecond\"], [20, \"millisecond\"], [50, \"millisecond\"], [100, \"millisecond\"], [200, \"millisecond\"], [500, \"millisecond\"], \n    [1, \"second\"],   [2, \"second\"],  [5, \"second\"], [10, \"second\"], [30, \"second\"], \n    [1, \"minute\"],   [2, \"minute\"],  [5, \"minute\"], [10, \"minute\"], [30, \"minute\"], \n    [1, \"hour\"],     [2, \"hour\"],    [4, \"hour\"],   [8, \"hour\"],    [12, \"hour\"],\n    [1, \"day\"],      [2, \"day\"],     [3, \"day\"],\n    [0.25, \"month\"], [0.5, \"month\"], [1, \"month\"],  [2, \"month\"],   [3, \"month\"], [6, \"month\"],\n    [1, \"year\"]\n  ],\n  monthNames: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n};\n\n(function () {\n\nvar _ = Flotr._;\n\nFlotr.DOM = {\n  addClass: function(element, name){\n    var classList = (element.className ? element.className : '');\n      if (_.include(classList.split(/\\s+/g), name)) return;\n    element.className = (classList ? classList + ' ' : '') + name;\n  },\n  /**\n   * Create an element.\n   */\n  create: function(tag){\n    return document.createElement(tag);\n  },\n  node: function(html) {\n    var div = Flotr.DOM.create('div'), n;\n    div.innerHTML = html;\n    n = div.children[0];\n    div.innerHTML = '';\n    return n;\n  },\n  /**\n   * Remove all children.\n   */\n  empty: function(element){\n    element.innerHTML = '';\n    /*\n    if (!element) return;\n    _.each(element.childNodes, function (e) {\n      Flotr.DOM.empty(e);\n      element.removeChild(e);\n    });\n    */\n  },\n  hide: function(element){\n    Flotr.DOM.setStyles(element, {display:'none'});\n  },\n  /**\n   * Insert a child.\n   * @param {Element} element\n   * @param {Element|String} Element or string to be appended.\n   */\n  insert: function(element, child){\n    if(_.isString(child))\n      element.innerHTML += child;\n    else if (_.isElement(child))\n      element.appendChild(child);\n  },\n  // @TODO find xbrowser implementation\n  opacity: function(element, opacity) {\n    element.style.opacity = opacity;\n  },\n  position: function(element, p){\n    if (!element.offsetParent)\n      return {left: (element.offsetLeft || 0), top: (element.offsetTop || 0)};\n\n    p = this.position(element.offsetParent);\n    p.left  += element.offsetLeft;\n    p.top   += element.offsetTop;\n    return p;\n  },\n  removeClass: function(element, name) {\n    var classList = (element.className ? element.className : '');\n    element.className = _.filter(classList.split(/\\s+/g), function (c) {\n      if (c != name) return true; }\n    ).join(' ');\n  },\n  setStyles: function(element, o) {\n    _.each(o, function (value, key) {\n      element.style[key] = value;\n    });\n  },\n  show: function(element){\n    Flotr.DOM.setStyles(element, {display:''});\n  },\n  /**\n   * Return element size.\n   */\n  size: function(element){\n    return {\n      height : element.offsetHeight,\n      width : element.offsetWidth };\n  }\n};\n\n})();\n\n/**\n * Flotr Event Adapter\n */\n(function () {\nvar\n  F = Flotr,\n  bean = F.bean;\nF.EventAdapter = {\n  observe: function(object, name, callback) {\n    bean.add(object, name, callback);\n    return this;\n  },\n  fire: function(object, name, args) {\n    bean.fire(object, name, args);\n    if (typeof(Prototype) != 'undefined')\n      Event.fire(object, name, args);\n    // @TODO Someone who uses mootools, add mootools adapter for existing applciations.\n    return this;\n  },\n  stopObserving: function(object, name, callback) {\n    bean.remove(object, name, callback);\n    return this;\n  },\n  eventPointer: function(e) {\n    if (!F._.isUndefined(e.touches) && e.touches.length > 0) {\n      return {\n        x : e.touches[0].pageX,\n        y : e.touches[0].pageY\n      };\n    } else if (!F._.isUndefined(e.changedTouches) && e.changedTouches.length > 0) {\n      return {\n        x : e.changedTouches[0].pageX,\n        y : e.changedTouches[0].pageY\n      };\n    } else if (e.pageX || e.pageY) {\n      return {\n        x : e.pageX,\n        y : e.pageY\n      };\n    } else if (e.clientX || e.clientY) {\n      var\n        d = document,\n        b = d.body,\n        de = d.documentElement;\n      return {\n        x: e.clientX + b.scrollLeft + de.scrollLeft,\n        y: e.clientY + b.scrollTop + de.scrollTop\n      };\n    }\n  }\n};\n})();\n\n/**\n * Text Utilities\n */\n(function () {\n\nvar\n  F = Flotr,\n  D = F.DOM,\n  _ = F._,\n\nText = function (o) {\n  this.o = o;\n};\n\nText.prototype = {\n\n  dimensions : function (text, canvasStyle, htmlStyle, className) {\n\n    if (!text) return { width : 0, height : 0 };\n    \n    return (this.o.html) ?\n      this.html(text, this.o.element, htmlStyle, className) : \n      this.canvas(text, canvasStyle);\n  },\n\n  canvas : function (text, style) {\n\n    if (!this.o.textEnabled) return;\n    style = style || {};\n\n    var\n      metrics = this.measureText(text, style),\n      width = metrics.width,\n      height = style.size || F.defaultOptions.fontSize,\n      angle = style.angle || 0,\n      cosAngle = Math.cos(angle),\n      sinAngle = Math.sin(angle),\n      widthPadding = 2,\n      heightPadding = 6,\n      bounds;\n\n    bounds = {\n      width: Math.abs(cosAngle * width) + Math.abs(sinAngle * height) + widthPadding,\n      height: Math.abs(sinAngle * width) + Math.abs(cosAngle * height) + heightPadding\n    };\n\n    return bounds;\n  },\n\n  html : function (text, element, style, className) {\n\n    var div = D.create('div');\n\n    D.setStyles(div, { 'position' : 'absolute', 'top' : '-10000px' });\n    D.insert(div, '<div style=\"'+style+'\" class=\"'+className+' flotr-dummy-div\">' + text + '</div>');\n    D.insert(this.o.element, div);\n\n    return D.size(div);\n  },\n\n  measureText : function (text, style) {\n\n    var\n      context = this.o.ctx,\n      metrics;\n\n    if (!context.fillText || (F.isIphone && context.measure)) {\n      return { width : context.measure(text, style)};\n    }\n\n    style = _.extend({\n      size: F.defaultOptions.fontSize,\n      weight: 1,\n      angle: 0\n    }, style);\n\n    context.save();\n    context.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    metrics = context.measureText(text);\n    context.restore();\n\n    return metrics;\n  }\n};\n\nFlotr.Text = Text;\n\n})();\n\n/**\n * Flotr Graph class that plots a graph on creation.\n */\n(function () {\n\nvar\n  D     = Flotr.DOM,\n  E     = Flotr.EventAdapter,\n  _     = Flotr._,\n  flotr = Flotr;\n/**\n * Flotr Graph constructor.\n * @param {Element} el - element to insert the graph into\n * @param {Object} data - an array or object of dataseries\n * @param {Object} options - an object containing options\n */\nGraph = function(el, data, options){\n// Let's see if we can get away with out this [JS]\n//  try {\n    this._setEl(el);\n    this._initMembers();\n    this._initPlugins();\n\n    E.fire(this.el, 'flotr:beforeinit', [this]);\n\n    this.data = data;\n    this.series = flotr.Series.getSeries(data);\n    this._initOptions(options);\n    this._initGraphTypes();\n    this._initCanvas();\n    this._text = new flotr.Text({\n      element : this.el,\n      ctx : this.ctx,\n      html : this.options.HtmlText,\n      textEnabled : this.textEnabled\n    });\n    E.fire(this.el, 'flotr:afterconstruct', [this]);\n    this._initEvents();\n\n    this.findDataRanges();\n    this.calculateSpacing();\n\n    this.draw(_.bind(function() {\n      E.fire(this.el, 'flotr:afterinit', [this]);\n    }, this));\n/*\n    try {\n  } catch (e) {\n    try {\n      console.error(e);\n    } catch (e2) {}\n  }*/\n};\n\nfunction observe (object, name, callback) {\n  E.observe.apply(this, arguments);\n  this._handles.push(arguments);\n  return this;\n}\n\nGraph.prototype = {\n\n  destroy: function () {\n    E.fire(this.el, 'flotr:destroy');\n    _.each(this._handles, function (handle) {\n      E.stopObserving.apply(this, handle);\n    });\n    this._handles = [];\n    this.el.graph = null;\n  },\n\n  observe : observe,\n\n  /**\n   * @deprecated\n   */\n  _observe : observe,\n\n  processColor: function(color, options){\n    var o = { x1: 0, y1: 0, x2: this.plotWidth, y2: this.plotHeight, opacity: 1, ctx: this.ctx };\n    _.extend(o, options);\n    return flotr.Color.processColor(color, o);\n  },\n  /**\n   * Function determines the min and max values for the xaxis and yaxis.\n   *\n   * TODO logarithmic range validation (consideration of 0)\n   */\n  findDataRanges: function(){\n    var a = this.axes,\n      xaxis, yaxis, range;\n\n    _.each(this.series, function (series) {\n      range = series.getRange();\n      if (range) {\n        xaxis = series.xaxis;\n        yaxis = series.yaxis;\n        xaxis.datamin = Math.min(range.xmin, xaxis.datamin);\n        xaxis.datamax = Math.max(range.xmax, xaxis.datamax);\n        yaxis.datamin = Math.min(range.ymin, yaxis.datamin);\n        yaxis.datamax = Math.max(range.ymax, yaxis.datamax);\n        xaxis.used = (xaxis.used || range.xused);\n        yaxis.used = (yaxis.used || range.yused);\n      }\n    }, this);\n\n    // Check for empty data, no data case (none used)\n    if (!a.x.used && !a.x2.used) a.x.used = true;\n    if (!a.y.used && !a.y2.used) a.y.used = true;\n\n    _.each(a, function (axis) {\n      axis.calculateRange();\n    });\n\n    var\n      types = _.keys(flotr.graphTypes),\n      drawn = false;\n\n    _.each(this.series, function (series) {\n      if (series.hide) return;\n      _.each(types, function (type) {\n        if (series[type] && series[type].show) {\n          this.extendRange(type, series);\n          drawn = true;\n        }\n      }, this);\n      if (!drawn) {\n        this.extendRange(this.options.defaultType, series);\n      }\n    }, this);\n  },\n\n  extendRange : function (type, series) {\n    if (this[type].extendRange) this[type].extendRange(series, series.data, series[type], this[type]);\n    if (this[type].extendYRange) this[type].extendYRange(series.yaxis, series.data, series[type], this[type]);\n    if (this[type].extendXRange) this[type].extendXRange(series.xaxis, series.data, series[type], this[type]);\n  },\n\n  /**\n   * Calculates axis label sizes.\n   */\n  calculateSpacing: function(){\n\n    var a = this.axes,\n        options = this.options,\n        series = this.series,\n        margin = options.grid.labelMargin,\n        T = this._text,\n        x = a.x,\n        x2 = a.x2,\n        y = a.y,\n        y2 = a.y2,\n        maxOutset = options.grid.outlineWidth,\n        i, j, l, dim;\n\n    // TODO post refactor, fix this\n    _.each(a, function (axis) {\n      axis.calculateTicks();\n      axis.calculateTextDimensions(T, options);\n    });\n\n    // Title height\n    dim = T.dimensions(\n      options.title,\n      {size: options.fontSize*1.5},\n      'font-size:1em;font-weight:bold;',\n      'flotr-title'\n    );\n    this.titleHeight = dim.height;\n\n    // Subtitle height\n    dim = T.dimensions(\n      options.subtitle,\n      {size: options.fontSize},\n      'font-size:smaller;',\n      'flotr-subtitle'\n    );\n    this.subtitleHeight = dim.height;\n\n    for(j = 0; j < options.length; ++j){\n      if (series[j].points.show){\n        maxOutset = Math.max(maxOutset, series[j].points.radius + series[j].points.lineWidth/2);\n      }\n    }\n\n    var p = this.plotOffset;\n    if (x.options.margin === false) {\n      p.bottom = 0;\n      p.top    = 0;\n    } else {\n      p.bottom += (options.grid.circular ? 0 : (x.used && x.options.showLabels ?  (x.maxLabel.height + margin) : 0)) +\n                  (x.used && x.options.title ? (x.titleSize.height + margin) : 0) + maxOutset;\n\n      p.top    += (options.grid.circular ? 0 : (x2.used && x2.options.showLabels ? (x2.maxLabel.height + margin) : 0)) +\n                  (x2.used && x2.options.title ? (x2.titleSize.height + margin) : 0) + this.subtitleHeight + this.titleHeight + maxOutset;\n    }\n    if (y.options.margin === false) {\n      p.left  = 0;\n      p.right = 0;\n    } else {\n      p.left   += (options.grid.circular ? 0 : (y.used && y.options.showLabels ?  (y.maxLabel.width + margin) : 0)) +\n                  (y.used && y.options.title ? (y.titleSize.width + margin) : 0) + maxOutset;\n\n      p.right  += (options.grid.circular ? 0 : (y2.used && y2.options.showLabels ? (y2.maxLabel.width + margin) : 0)) +\n                  (y2.used && y2.options.title ? (y2.titleSize.width + margin) : 0) + maxOutset;\n    }\n\n    p.top = Math.floor(p.top); // In order the outline not to be blured\n\n    this.plotWidth  = this.canvasWidth - p.left - p.right;\n    this.plotHeight = this.canvasHeight - p.bottom - p.top;\n\n    // TODO post refactor, fix this\n    x.length = x2.length = this.plotWidth;\n    y.length = y2.length = this.plotHeight;\n    y.offset = y2.offset = this.plotHeight;\n    x.setScale();\n    x2.setScale();\n    y.setScale();\n    y2.setScale();\n  },\n  /**\n   * Draws grid, labels, series and outline.\n   */\n  draw: function(after) {\n\n    var\n      context = this.ctx,\n      i;\n\n    E.fire(this.el, 'flotr:beforedraw', [this.series, this]);\n\n    if (this.series.length) {\n\n      context.save();\n      context.translate(this.plotOffset.left, this.plotOffset.top);\n\n      for (i = 0; i < this.series.length; i++) {\n        if (!this.series[i].hide) this.drawSeries(this.series[i]);\n      }\n\n      context.restore();\n      this.clip();\n    }\n\n    E.fire(this.el, 'flotr:afterdraw', [this.series, this]);\n    if (after) after();\n  },\n  /**\n   * Actually draws the graph.\n   * @param {Object} series - series to draw\n   */\n  drawSeries: function(series){\n\n    function drawChart (series, typeKey) {\n      var options = this.getOptions(series, typeKey);\n      this[typeKey].draw(options);\n    }\n\n    var drawn = false;\n    series = series || this.series;\n\n    _.each(flotr.graphTypes, function (type, typeKey) {\n      if (series[typeKey] && series[typeKey].show && this[typeKey]) {\n        drawn = true;\n        drawChart.call(this, series, typeKey);\n      }\n    }, this);\n\n    if (!drawn) drawChart.call(this, series, this.options.defaultType);\n  },\n\n  getOptions : function (series, typeKey) {\n    var\n      type = series[typeKey],\n      graphType = this[typeKey],\n      xaxis = series.xaxis,\n      yaxis = series.yaxis,\n      options = {\n        context     : this.ctx,\n        width       : this.plotWidth,\n        height      : this.plotHeight,\n        fontSize    : this.options.fontSize,\n        fontColor   : this.options.fontColor,\n        textEnabled : this.textEnabled,\n        htmlText    : this.options.HtmlText,\n        text        : this._text, // TODO Is this necessary?\n        element     : this.el,\n        data        : series.data,\n        color       : series.color,\n        shadowSize  : series.shadowSize,\n        xScale      : xaxis.d2p,\n        yScale      : yaxis.d2p,\n        xInverse    : xaxis.p2d,\n        yInverse    : yaxis.p2d\n      };\n\n    options = flotr.merge(type, options);\n\n    // Fill\n    options.fillStyle = this.processColor(\n      type.fillColor || series.color,\n      {opacity: type.fillOpacity}\n    );\n\n    return options;\n  },\n  /**\n   * Calculates the coordinates from a mouse event object.\n   * @param {Event} event - Mouse Event object.\n   * @return {Object} Object with coordinates of the mouse.\n   */\n  getEventPosition: function (e){\n\n    var\n      d = document,\n      b = d.body,\n      de = d.documentElement,\n      axes = this.axes,\n      plotOffset = this.plotOffset,\n      lastMousePos = this.lastMousePos,\n      pointer = E.eventPointer(e),\n      dx = pointer.x - lastMousePos.pageX,\n      dy = pointer.y - lastMousePos.pageY,\n      r, rx, ry;\n\n    if ('ontouchstart' in this.el) {\n      r = D.position(this.overlay);\n      rx = pointer.x - r.left - plotOffset.left;\n      ry = pointer.y - r.top - plotOffset.top;\n    } else {\n      r = this.overlay.getBoundingClientRect();\n      rx = e.clientX - r.left - plotOffset.left - b.scrollLeft - de.scrollLeft;\n      ry = e.clientY - r.top - plotOffset.top - b.scrollTop - de.scrollTop;\n    }\n\n    return {\n      x:  axes.x.p2d(rx),\n      x2: axes.x2.p2d(rx),\n      y:  axes.y.p2d(ry),\n      y2: axes.y2.p2d(ry),\n      relX: rx,\n      relY: ry,\n      dX: dx,\n      dY: dy,\n      absX: pointer.x,\n      absY: pointer.y,\n      pageX: pointer.x,\n      pageY: pointer.y\n    };\n  },\n  /**\n   * Observes the 'click' event and fires the 'flotr:click' event.\n   * @param {Event} event - 'click' Event object.\n   */\n  clickHandler: function(event){\n    if(this.ignoreClick){\n      this.ignoreClick = false;\n      return this.ignoreClick;\n    }\n    E.fire(this.el, 'flotr:click', [this.getEventPosition(event), this]);\n  },\n  /**\n   * Observes mouse movement over the graph area. Fires the 'flotr:mousemove' event.\n   * @param {Event} event - 'mousemove' Event object.\n   */\n  mouseMoveHandler: function(event){\n    if (this.mouseDownMoveHandler) return;\n    var pos = this.getEventPosition(event);\n    E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n    this.lastMousePos = pos;\n  },\n  /**\n   * Observes the 'mousedown' event.\n   * @param {Event} event - 'mousedown' Event object.\n   */\n  mouseDownHandler: function (event){\n\n    /*\n    // @TODO Context menu?\n    if(event.isRightClick()) {\n      event.stop();\n\n      var overlay = this.overlay;\n      overlay.hide();\n\n      function cancelContextMenu () {\n        overlay.show();\n        E.stopObserving(document, 'mousemove', cancelContextMenu);\n      }\n      E.observe(document, 'mousemove', cancelContextMenu);\n      return;\n    }\n    */\n\n    if (this.mouseUpHandler) return;\n    this.mouseUpHandler = _.bind(function (e) {\n      E.stopObserving(document, 'mouseup', this.mouseUpHandler);\n      E.stopObserving(document, 'mousemove', this.mouseDownMoveHandler);\n      this.mouseDownMoveHandler = null;\n      this.mouseUpHandler = null;\n      // @TODO why?\n      //e.stop();\n      E.fire(this.el, 'flotr:mouseup', [e, this]);\n    }, this);\n    this.mouseDownMoveHandler = _.bind(function (e) {\n        var pos = this.getEventPosition(e);\n        E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n        this.lastMousePos = pos;\n    }, this);\n    E.observe(document, 'mouseup', this.mouseUpHandler);\n    E.observe(document, 'mousemove', this.mouseDownMoveHandler);\n    E.fire(this.el, 'flotr:mousedown', [event, this]);\n    this.ignoreClick = false;\n  },\n  drawTooltip: function(content, x, y, options) {\n    var mt = this.getMouseTrack(),\n        style = 'opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;',\n        p = options.position,\n        m = options.margin,\n        plotOffset = this.plotOffset;\n\n    if(x !== null && y !== null){\n      if (!options.relative) { // absolute to the canvas\n             if(p.charAt(0) == 'n') style += 'top:' + (m + plotOffset.top) + 'px;bottom:auto;';\n        else if(p.charAt(0) == 's') style += 'bottom:' + (m + plotOffset.bottom) + 'px;top:auto;';\n             if(p.charAt(1) == 'e') style += 'right:' + (m + plotOffset.right) + 'px;left:auto;';\n        else if(p.charAt(1) == 'w') style += 'left:' + (m + plotOffset.left) + 'px;right:auto;';\n      }\n      else { // relative to the mouse\n             if(p.charAt(0) == 'n') style += 'bottom:' + (m - plotOffset.top - y + this.canvasHeight) + 'px;top:auto;';\n        else if(p.charAt(0) == 's') style += 'top:' + (m + plotOffset.top + y) + 'px;bottom:auto;';\n             if(p.charAt(1) == 'e') style += 'left:' + (m + plotOffset.left + x) + 'px;right:auto;';\n        else if(p.charAt(1) == 'w') style += 'right:' + (m - plotOffset.left - x + this.canvasWidth) + 'px;left:auto;';\n      }\n\n      mt.style.cssText = style;\n      D.empty(mt);\n      D.insert(mt, content);\n      D.show(mt);\n    }\n    else {\n      D.hide(mt);\n    }\n  },\n\n  clip: function (ctx) {\n\n    var\n      o   = this.plotOffset,\n      w   = this.canvasWidth,\n      h   = this.canvasHeight;\n\n    ctx = ctx || this.ctx;\n\n    if (flotr.isIE && flotr.isIE < 9) {\n      // Clipping for excanvas :-(\n      ctx.save();\n      ctx.fillStyle = this.processColor(this.options.ieBackgroundColor);\n      ctx.fillRect(0, 0, w, o.top);\n      ctx.fillRect(0, 0, o.left, h);\n      ctx.fillRect(0, h - o.bottom, w, o.bottom);\n      ctx.fillRect(w - o.right, 0, o.right,h);\n      ctx.restore();\n    } else {\n      ctx.clearRect(0, 0, w, o.top);\n      ctx.clearRect(0, 0, o.left, h);\n      ctx.clearRect(0, h - o.bottom, w, o.bottom);\n      ctx.clearRect(w - o.right, 0, o.right,h);\n    }\n  },\n\n  _initMembers: function() {\n    this._handles = [];\n    this.lastMousePos = {pageX: null, pageY: null };\n    this.plotOffset = {left: 0, right: 0, top: 0, bottom: 0};\n    this.ignoreClick = true;\n    this.prevHit = null;\n  },\n\n  _initGraphTypes: function() {\n    _.each(flotr.graphTypes, function(handler, graphType){\n      this[graphType] = flotr.clone(handler);\n    }, this);\n  },\n\n  _initEvents: function () {\n\n    var\n      el = this.el,\n      touchendHandler, movement, touchend;\n\n    if ('ontouchstart' in el) {\n\n      touchendHandler = _.bind(function (e) {\n        touchend = true;\n        E.stopObserving(document, 'touchend', touchendHandler);\n        E.fire(el, 'flotr:mouseup', [event, this]);\n        this.multitouches = null;\n\n        if (!movement) {\n          this.clickHandler(e);\n        }\n      }, this);\n\n      this.observe(this.overlay, 'touchstart', _.bind(function (e) {\n        movement = false;\n        touchend = false;\n        this.ignoreClick = false;\n\n        if (e.touches && e.touches.length > 1) {\n          this.multitouches = e.touches;\n        }\n\n        E.fire(el, 'flotr:mousedown', [event, this]);\n        this.observe(document, 'touchend', touchendHandler);\n      }, this));\n\n      this.observe(this.overlay, 'touchmove', _.bind(function (e) {\n\n        var pos = this.getEventPosition(e);\n\n        if (this.options.preventDefault) {\n          e.preventDefault();\n        }\n\n        movement = true;\n\n        if (this.multitouches || (e.touches && e.touches.length > 1)) {\n          this.multitouches = e.touches;\n        } else {\n          if (!touchend) {\n            E.fire(el, 'flotr:mousemove', [event, pos, this]);\n          }\n        }\n        this.lastMousePos = pos;\n      }, this));\n\n    } else {\n      this.\n        observe(this.overlay, 'mousedown', _.bind(this.mouseDownHandler, this)).\n        observe(el, 'mousemove', _.bind(this.mouseMoveHandler, this)).\n        observe(this.overlay, 'click', _.bind(this.clickHandler, this)).\n        observe(el, 'mouseout', function () {\n          E.fire(el, 'flotr:mouseout');\n        });\n    }\n  },\n\n  /**\n   * Initializes the canvas and it's overlay canvas element. When the browser is IE, this makes use\n   * of excanvas. The overlay canvas is inserted for displaying interactions. After the canvas elements\n   * are created, the elements are inserted into the container element.\n   */\n  _initCanvas: function(){\n    var el = this.el,\n      o = this.options,\n      children = el.children,\n      removedChildren = [],\n      child, i,\n      size, style;\n\n    // Empty the el\n    for (i = children.length; i--;) {\n      child = children[i];\n      if (!this.canvas && child.className === 'flotr-canvas') {\n        this.canvas = child;\n      } else if (!this.overlay && child.className === 'flotr-overlay') {\n        this.overlay = child;\n      } else {\n        removedChildren.push(child);\n      }\n    }\n    for (i = removedChildren.length; i--;) {\n      el.removeChild(removedChildren[i]);\n    }\n\n    D.setStyles(el, {position: 'relative'}); // For positioning labels and overlay.\n    size = {};\n    size.width = el.clientWidth;\n    size.height = el.clientHeight;\n\n    if(size.width <= 0 || size.height <= 0 || o.resolution <= 0){\n      throw 'Invalid dimensions for plot, width = ' + size.width + ', height = ' + size.height + ', resolution = ' + o.resolution;\n    }\n\n    // Main canvas for drawing graph types\n    this.canvas = getCanvas(this.canvas, 'canvas');\n    // Overlay canvas for interactive features\n    this.overlay = getCanvas(this.overlay, 'overlay');\n    this.ctx = getContext(this.canvas);\n    this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n    this.octx = getContext(this.overlay);\n    this.octx.clearRect(0, 0, this.overlay.width, this.overlay.height);\n    this.canvasHeight = size.height;\n    this.canvasWidth = size.width;\n    this.textEnabled = !!this.ctx.drawText || !!this.ctx.fillText; // Enable text functions\n\n    function getCanvas(canvas, name){\n      if(!canvas){\n        canvas = D.create('canvas');\n        if (typeof FlashCanvas != \"undefined\" && typeof canvas.getContext === 'function') {\n          FlashCanvas.initElement(canvas);\n        }\n        canvas.className = 'flotr-'+name;\n        canvas.style.cssText = 'position:absolute;left:0px;top:0px;';\n        D.insert(el, canvas);\n      }\n      _.each(size, function(size, attribute){\n        D.show(canvas);\n        if (name == 'canvas' && canvas.getAttribute(attribute) === size) {\n          return;\n        }\n        canvas.setAttribute(attribute, size * o.resolution);\n        canvas.style[attribute] = size + 'px';\n      });\n      canvas.context_ = null; // Reset the ExCanvas context\n      return canvas;\n    }\n\n    function getContext(canvas){\n      if(window.G_vmlCanvasManager) window.G_vmlCanvasManager.initElement(canvas); // For ExCanvas\n      var context = canvas.getContext('2d');\n      if(!window.G_vmlCanvasManager) context.scale(o.resolution, o.resolution);\n      return context;\n    }\n  },\n\n  _initPlugins: function(){\n    // TODO Should be moved to flotr and mixed in.\n    _.each(flotr.plugins, function(plugin, name){\n      _.each(plugin.callbacks, function(fn, c){\n        this.observe(this.el, c, _.bind(fn, this));\n      }, this);\n      this[name] = flotr.clone(plugin);\n      _.each(this[name], function(fn, p){\n        if (_.isFunction(fn))\n          this[name][p] = _.bind(fn, this);\n      }, this);\n    }, this);\n  },\n\n  /**\n   * Sets options and initializes some variables and color specific values, used by the constructor.\n   * @param {Object} opts - options object\n   */\n  _initOptions: function(opts){\n    var options = flotr.clone(flotr.defaultOptions);\n    options.x2axis = _.extend(_.clone(options.xaxis), options.x2axis);\n    options.y2axis = _.extend(_.clone(options.yaxis), options.y2axis);\n    this.options = flotr.merge(opts || {}, options);\n\n    if (this.options.grid.minorVerticalLines === null &&\n      this.options.xaxis.scaling === 'logarithmic') {\n      this.options.grid.minorVerticalLines = true;\n    }\n    if (this.options.grid.minorHorizontalLines === null &&\n      this.options.yaxis.scaling === 'logarithmic') {\n      this.options.grid.minorHorizontalLines = true;\n    }\n\n    E.fire(this.el, 'flotr:afterinitoptions', [this]);\n\n    this.axes = flotr.Axis.getAxes(this.options);\n\n    // Initialize some variables used throughout this function.\n    var assignedColors = [],\n        colors = [],\n        ln = this.series.length,\n        neededColors = this.series.length,\n        oc = this.options.colors,\n        usedColors = [],\n        variation = 0,\n        c, i, j, s;\n\n    // Collect user-defined colors from series.\n    for(i = neededColors - 1; i > -1; --i){\n      c = this.series[i].color;\n      if(c){\n        --neededColors;\n        if(_.isNumber(c)) assignedColors.push(c);\n        else usedColors.push(flotr.Color.parse(c));\n      }\n    }\n\n    // Calculate the number of colors that need to be generated.\n    for(i = assignedColors.length - 1; i > -1; --i)\n      neededColors = Math.max(neededColors, assignedColors[i] + 1);\n\n    // Generate needed number of colors.\n    for(i = 0; colors.length < neededColors;){\n      c = (oc.length == i) ? new flotr.Color(100, 100, 100) : flotr.Color.parse(oc[i]);\n\n      // Make sure each serie gets a different color.\n      var sign = variation % 2 == 1 ? -1 : 1,\n          factor = 1 + sign * Math.ceil(variation / 2) * 0.2;\n      c.scale(factor, factor, factor);\n\n      /**\n       * @todo if we're getting too close to something else, we should probably skip this one\n       */\n      colors.push(c);\n\n      if(++i >= oc.length){\n        i = 0;\n        ++variation;\n      }\n    }\n\n    // Fill the options with the generated colors.\n    for(i = 0, j = 0; i < ln; ++i){\n      s = this.series[i];\n\n      // Assign the color.\n      if (!s.color){\n        s.color = colors[j++].toString();\n      }else if(_.isNumber(s.color)){\n        s.color = colors[s.color].toString();\n      }\n\n      // Every series needs an axis\n      if (!s.xaxis) s.xaxis = this.axes.x;\n           if (s.xaxis == 1) s.xaxis = this.axes.x;\n      else if (s.xaxis == 2) s.xaxis = this.axes.x2;\n\n      if (!s.yaxis) s.yaxis = this.axes.y;\n           if (s.yaxis == 1) s.yaxis = this.axes.y;\n      else if (s.yaxis == 2) s.yaxis = this.axes.y2;\n\n      // Apply missing options to the series.\n      for (var t in flotr.graphTypes){\n        s[t] = _.extend(_.clone(this.options[t]), s[t]);\n      }\n      s.mouse = _.extend(_.clone(this.options.mouse), s.mouse);\n\n      if (_.isUndefined(s.shadowSize)) s.shadowSize = this.options.shadowSize;\n    }\n  },\n\n  _setEl: function(el) {\n    if (!el) throw 'The target container doesn\\'t exist';\n    else if (el.graph instanceof Graph) el.graph.destroy();\n    else if (!el.clientWidth) throw 'The target container must be visible';\n\n    el.graph = this;\n    this.el = el;\n  }\n};\n\nFlotr.Graph = Graph;\n\n})();\n\n/**\n * Flotr Axis Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._,\n  LOGARITHMIC = 'logarithmic';\n\nfunction Axis (o) {\n\n  this.orientation = 1;\n  this.offset = 0;\n  this.datamin = Number.MAX_VALUE;\n  this.datamax = -Number.MAX_VALUE;\n\n  _.extend(this, o);\n}\n\n\n// Prototype\nAxis.prototype = {\n\n  setScale : function () {\n    var\n      length = this.length,\n      max = this.max,\n      min = this.min,\n      offset = this.offset,\n      orientation = this.orientation,\n      options = this.options,\n      logarithmic = options.scaling === LOGARITHMIC,\n      scale;\n\n    if (logarithmic) {\n      scale = length / (log(max, options.base) - log(min, options.base));\n    } else {\n      scale = length / (max - min);\n    }\n    this.scale = scale;\n\n    // Logarithmic?\n    if (logarithmic) {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (log(dataValue, options.base) - log(min, options.base)) * scale;\n      }\n      this.p2d = function (pointValue) {\n        return exp((offset + orientation * pointValue) / scale + log(min, options.base), options.base);\n      }\n    } else {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (dataValue - min) * scale;\n      }\n      this.p2d = function (pointValue) {\n        return (offset + orientation * pointValue) / scale + min;\n      }\n    }\n  },\n\n  calculateTicks : function () {\n    var options = this.options;\n\n    this.ticks = [];\n    this.minorTicks = [];\n    \n    // User Ticks\n    if(options.ticks){\n      this._cleanUserTicks(options.ticks, this.ticks);\n      this._cleanUserTicks(options.minorTicks || [], this.minorTicks);\n    }\n    else {\n      if (options.mode == 'time') {\n        this._calculateTimeTicks();\n      } else if (options.scaling === 'logarithmic') {\n        this._calculateLogTicks();\n      } else {\n        this._calculateTicks();\n      }\n    }\n\n    // Ticks to strings\n    _.each(this.ticks, function (tick) { tick.label += ''; });\n    _.each(this.minorTicks, function (tick) { tick.label += ''; });\n  },\n\n  /**\n   * Calculates the range of an axis to apply autoscaling.\n   */\n  calculateRange: function () {\n\n    if (!this.used) return;\n\n    var axis  = this,\n      o       = axis.options,\n      min     = o.min !== null ? o.min : axis.datamin,\n      max     = o.max !== null ? o.max : axis.datamax,\n      margin  = o.autoscaleMargin;\n        \n    if (o.scaling == 'logarithmic') {\n      if (min <= 0) min = axis.datamin;\n\n      // Let it widen later on\n      if (max <= 0) max = min;\n    }\n\n    if (max == min) {\n      var widen = max ? 0.01 : 1.00;\n      if (o.min === null) min -= widen;\n      if (o.max === null) max += widen;\n    }\n\n    if (o.scaling === 'logarithmic') {\n      if (min < 0) min = max / o.base;  // Could be the result of widening\n\n      var maxexp = Math.log(max);\n      if (o.base != Math.E) maxexp /= Math.log(o.base);\n      maxexp = Math.ceil(maxexp);\n\n      var minexp = Math.log(min);\n      if (o.base != Math.E) minexp /= Math.log(o.base);\n      minexp = Math.ceil(minexp);\n      \n      axis.tickSize = Flotr.getTickSize(o.noTicks, minexp, maxexp, o.tickDecimals === null ? 0 : o.tickDecimals);\n                        \n      // Try to determine a suitable amount of miniticks based on the length of a decade\n      if (o.minorTickFreq === null) {\n        if (maxexp - minexp > 10)\n          o.minorTickFreq = 0;\n        else if (maxexp - minexp > 5)\n          o.minorTickFreq = 2;\n        else\n          o.minorTickFreq = 5;\n      }\n    } else {\n      axis.tickSize = Flotr.getTickSize(o.noTicks, min, max, o.tickDecimals);\n    }\n\n    axis.min = min;\n    axis.max = max; //extendRange may use axis.min or axis.max, so it should be set before it is caled\n\n    // Autoscaling. @todo This probably fails with log scale. Find a testcase and fix it\n    if(o.min === null && o.autoscale){\n      axis.min -= axis.tickSize * margin;\n      // Make sure we don't go below zero if all values are positive.\n      if(axis.min < 0 && axis.datamin >= 0) axis.min = 0;\n      axis.min = axis.tickSize * Math.floor(axis.min / axis.tickSize);\n    }\n    \n    if(o.max === null && o.autoscale){\n      axis.max += axis.tickSize * margin;\n      if(axis.max > 0 && axis.datamax <= 0 && axis.datamax != axis.datamin) axis.max = 0;        \n      axis.max = axis.tickSize * Math.ceil(axis.max / axis.tickSize);\n    }\n\n    if (axis.min == axis.max) axis.max = axis.min + 1;\n  },\n\n  calculateTextDimensions : function (T, options) {\n\n    var maxLabel = '',\n      length,\n      i;\n\n    if (this.options.showLabels) {\n      for (i = 0; i < this.ticks.length; ++i) {\n        length = this.ticks[i].label.length;\n        if (length > maxLabel.length){\n          maxLabel = this.ticks[i].label;\n        }\n      }\n    }\n\n    this.maxLabel = T.dimensions(\n      maxLabel,\n      {size:options.fontSize, angle: Flotr.toRad(this.options.labelsAngle)},\n      'font-size:smaller;',\n      'flotr-grid-label'\n    );\n\n    this.titleSize = T.dimensions(\n      this.options.title, \n      {size:options.fontSize*1.2, angle: Flotr.toRad(this.options.titleAngle)},\n      'font-weight:bold;',\n      'flotr-axis-title'\n    );\n  },\n\n  _cleanUserTicks : function (ticks, axisTicks) {\n\n    var axis = this, options = this.options,\n      v, i, label, tick;\n\n    if(_.isFunction(ticks)) ticks = ticks({min : axis.min, max : axis.max});\n\n    for(i = 0; i < ticks.length; ++i){\n      tick = ticks[i];\n      if(typeof(tick) === 'object'){\n        v = tick[0];\n        label = (tick.length > 1) ? tick[1] : options.tickFormatter(v, {min : axis.min, max : axis.max});\n      } else {\n        v = tick;\n        label = options.tickFormatter(v, {min : this.min, max : this.max});\n      }\n      axisTicks[i] = { v: v, label: label };\n    }\n  },\n\n  _calculateTimeTicks : function () {\n    this.ticks = Flotr.Date.generator(this);\n  },\n\n  _calculateLogTicks : function () {\n\n    var axis = this,\n      o = axis.options,\n      v,\n      decadeStart;\n\n    var max = Math.log(axis.max);\n    if (o.base != Math.E) max /= Math.log(o.base);\n    max = Math.ceil(max);\n\n    var min = Math.log(axis.min);\n    if (o.base != Math.E) min /= Math.log(o.base);\n    min = Math.ceil(min);\n    \n    for (i = min; i < max; i += axis.tickSize) {\n      decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n      // Next decade begins here:\n      var decadeEnd = decadeStart * ((o.base == Math.E) ? Math.exp(axis.tickSize) : Math.pow(o.base, axis.tickSize));\n      var stepSize = (decadeEnd - decadeStart) / o.minorTickFreq;\n      \n      axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n      for (v = decadeStart + stepSize; v < decadeEnd; v += stepSize)\n        axis.minorTicks.push({v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max})});\n    }\n    \n    // Always show the value at the would-be start of next decade (end of this decade)\n    decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n    axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n  },\n\n  _calculateTicks : function () {\n\n    var axis      = this,\n        o         = axis.options,\n        tickSize  = axis.tickSize,\n        min       = axis.min,\n        max       = axis.max,\n        start     = tickSize * Math.ceil(min / tickSize), // Round to nearest multiple of tick size.\n        decimals,\n        minorTickSize,\n        v, v2,\n        i, j;\n    \n    if (o.minorTickFreq)\n      minorTickSize = tickSize / o.minorTickFreq;\n                      \n    // Then store all possible ticks.\n    for (i = 0; (v = v2 = start + i * tickSize) <= max; ++i){\n      \n      // Round (this is always needed to fix numerical instability).\n      decimals = o.tickDecimals;\n      if (decimals === null) decimals = 1 - Math.floor(Math.log(tickSize) / Math.LN10);\n      if (decimals < 0) decimals = 0;\n      \n      v = v.toFixed(decimals);\n      axis.ticks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n\n      if (o.minorTickFreq) {\n        for (j = 0; j < o.minorTickFreq && (i * tickSize + j * minorTickSize) < max; ++j) {\n          v = v2 + j * minorTickSize;\n          axis.minorTicks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n        }\n      }\n    }\n\n  }\n};\n\n\n// Static Methods\n_.extend(Axis, {\n  getAxes : function (options) {\n    return {\n      x:  new Axis({options: options.xaxis,  n: 1, length: this.plotWidth}),\n      x2: new Axis({options: options.x2axis, n: 2, length: this.plotWidth}),\n      y:  new Axis({options: options.yaxis,  n: 1, length: this.plotHeight, offset: this.plotHeight, orientation: -1}),\n      y2: new Axis({options: options.y2axis, n: 2, length: this.plotHeight, offset: this.plotHeight, orientation: -1})\n    };\n  }\n});\n\n\n// Helper Methods\n\n\nfunction log (value, base) {\n  value = Math.log(Math.max(value, Number.MIN_VALUE));\n  if (base !== Math.E) \n    value /= Math.log(base);\n  return value;\n}\n\nfunction exp (value, base) {\n  return (base === Math.E) ? Math.exp(value) : Math.pow(base, value);\n}\n\nFlotr.Axis = Axis;\n\n})();\n\n/**\n * Flotr Series Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\nfunction Series (o) {\n  _.extend(this, o);\n}\n\nSeries.prototype = {\n\n  getRange: function () {\n\n    var\n      data = this.data,\n      length = data.length,\n      xmin = Number.MAX_VALUE,\n      ymin = Number.MAX_VALUE,\n      xmax = -Number.MAX_VALUE,\n      ymax = -Number.MAX_VALUE,\n      xused = false,\n      yused = false,\n      x, y, i;\n\n    if (length < 0 || this.hide) return false;\n\n    for (i = 0; i < length; i++) {\n      x = data[i][0];\n      y = data[i][1];\n      if (x !== null) {\n        if (x < xmin) { xmin = x; xused = true; }\n        if (x > xmax) { xmax = x; xused = true; }\n      }\n      if (y !== null) {\n        if (y < ymin) { ymin = y; yused = true; }\n        if (y > ymax) { ymax = y; yused = true; }\n      }\n    }\n\n    return {\n      xmin : xmin,\n      xmax : xmax,\n      ymin : ymin,\n      ymax : ymax,\n      xused : xused,\n      yused : yused\n    };\n  }\n};\n\n_.extend(Series, {\n  /**\n   * Collects dataseries from input and parses the series into the right format. It returns an Array \n   * of Objects each having at least the 'data' key set.\n   * @param {Array, Object} data - Object or array of dataseries\n   * @return {Array} Array of Objects parsed into the right format ({(...,) data: [[x1,y1], [x2,y2], ...] (, ...)})\n   */\n  getSeries: function(data){\n    return _.map(data, function(s){\n      var series;\n      if (s.data) {\n        series = new Series();\n        _.extend(series, s);\n      } else {\n        series = new Series({data:s});\n      }\n      return series;\n    });\n  }\n});\n\nFlotr.Series = Series;\n\n})();\n\n/** Lines **/\nFlotr.addType('lines', {\n  options: {\n    show: false,           // => setting to true will show lines, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: false,           // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillBorder: false,     // => draw a border around the fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    steps: false,          // => draw steps\n    stacked: false         // => setting to true will show stacked lines, false will show normal lines\n  },\n\n  stack : {\n    values : []\n  },\n\n  /**\n   * Draws lines series in the canvas element.\n   * @param {Object} options\n   */\n  draw : function (options) {\n\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize,\n      offset;\n\n    context.save();\n    context.lineJoin = 'round';\n\n    if (shadowSize) {\n\n      context.lineWidth = shadowSize / 2;\n      offset = lineWidth / 2 + context.lineWidth / 2;\n      \n      // @TODO do this instead with a linear gradient\n      context.strokeStyle = \"rgba(0,0,0,0.1)\";\n      this.plot(options, offset + shadowSize / 2, false);\n\n      context.strokeStyle = \"rgba(0,0,0,0.2)\";\n      this.plot(options, offset, false);\n    }\n\n    context.lineWidth = lineWidth;\n    context.strokeStyle = options.color;\n\n    this.plot(options, 0, true);\n\n    context.restore();\n  },\n\n  plot : function (options, shadowOffset, incStack) {\n\n    var\n      context   = options.context,\n      width     = options.width, \n      height    = options.height,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      data      = options.data, \n      stack     = options.stacked ? this.stack : false,\n      length    = data.length - 1,\n      prevx     = null,\n      prevy     = null,\n      zero      = yScale(0),\n      start     = null,\n      x1, x2, y1, y2, stack1, stack2, i;\n      \n    if (length < 1) return;\n\n    context.beginPath();\n\n    for (i = 0; i < length; ++i) {\n\n      // To allow empty values\n      if (data[i][1] === null || data[i+1][1] === null) {\n        if (options.fill) {\n          if (i > 0 && data[i][1]) {\n            context.stroke();\n            fill();\n            start = null;\n            context.closePath();\n            context.beginPath();\n          }\n        }\n        continue;\n      }\n\n      // Zero is infinity for log scales\n      // TODO handle zero for logarithmic\n      // if (xa.options.scaling === 'logarithmic' && (data[i][0] <= 0 || data[i+1][0] <= 0)) continue;\n      // if (ya.options.scaling === 'logarithmic' && (data[i][1] <= 0 || data[i+1][1] <= 0)) continue;\n      \n      x1 = xScale(data[i][0]);\n      x2 = xScale(data[i+1][0]);\n\n      if (start === null) start = data[i];\n      \n      if (stack) {\n\n        stack1 = stack.values[data[i][0]] || 0;\n        stack2 = stack.values[data[i+1][0]] || stack.values[data[i][0]] || 0;\n\n        y1 = yScale(data[i][1] + stack1);\n        y2 = yScale(data[i+1][1] + stack2);\n        \n        if(incStack){\n          stack.values[data[i][0]] = data[i][1]+stack1;\n            \n          if(i == length-1)\n            stack.values[data[i+1][0]] = data[i+1][1]+stack2;\n        }\n      }\n      else{\n        y1 = yScale(data[i][1]);\n        y2 = yScale(data[i+1][1]);\n      }\n\n      if (\n        (y1 > height && y2 > height) ||\n        (y1 < 0 && y2 < 0) ||\n        (x1 < 0 && x2 < 0) ||\n        (x1 > width && x2 > width)\n      ) continue;\n\n      if((prevx != x1) || (prevy != y1 + shadowOffset))\n        context.moveTo(x1, y1 + shadowOffset);\n      \n      prevx = x2;\n      prevy = y2 + shadowOffset;\n      if (options.steps) {\n        context.lineTo(prevx + shadowOffset / 2, y1 + shadowOffset);\n        context.lineTo(prevx + shadowOffset / 2, prevy);\n      } else {\n        context.lineTo(prevx, prevy);\n      }\n    }\n    \n    if (!options.fill || options.fill && !options.fillBorder) context.stroke();\n\n    fill();\n\n    function fill () {\n      // TODO stacked lines\n      if(!shadowOffset && options.fill && start){\n        x1 = xScale(start[0]);\n        context.fillStyle = options.fillStyle;\n        context.lineTo(x2, zero);\n        context.lineTo(x1, zero);\n        context.lineTo(x1, yScale(start[1]));\n        context.fill();\n        if (options.fillBorder) {\n          context.stroke();\n        }\n      }\n    }\n\n    context.closePath();\n  },\n\n  // Perform any pre-render precalculations (this should be run on data first)\n  // - Pie chart total for calculating measures\n  // - Stacks for lines and bars\n  // precalculate : function () {\n  // }\n  //\n  //\n  // Get any bounds after pre calculation (axis can fetch this if does not have explicit min/max)\n  // getBounds : function () {\n  // }\n  // getMin : function () {\n  // }\n  // getMax : function () {\n  // }\n  //\n  //\n  // Padding around rendered elements\n  // getPadding : function () {\n  // }\n\n  extendYRange : function (axis, data, options, lines) {\n\n    var o = axis.options;\n\n    // If stacked and auto-min\n    if (options.stacked && ((!o.max && o.max !== 0) || (!o.min && o.min !== 0))) {\n\n      var\n        newmax = axis.max,\n        newmin = axis.min,\n        positiveSums = lines.positiveSums || {},\n        negativeSums = lines.negativeSums || {},\n        x, j;\n\n      for (j = 0; j < data.length; j++) {\n\n        x = data[j][0] + '';\n\n        // Positive\n        if (data[j][1] > 0) {\n          positiveSums[x] = (positiveSums[x] || 0) + data[j][1];\n          newmax = Math.max(newmax, positiveSums[x]);\n        }\n\n        // Negative\n        else {\n          negativeSums[x] = (negativeSums[x] || 0) + data[j][1];\n          newmin = Math.min(newmin, negativeSums[x]);\n        }\n      }\n\n      lines.negativeSums = negativeSums;\n      lines.positiveSums = positiveSums;\n\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n\n    if (options.steps) {\n\n      this.hit = function (options) {\n        var\n          data = options.data,\n          args = options.args,\n          yScale = options.yScale,\n          mouse = args[0],\n          length = data.length,\n          n = args[1],\n          x = options.xInverse(mouse.relX),\n          relY = mouse.relY,\n          i;\n\n        for (i = 0; i < length - 1; i++) {\n          if (x >= data[i][0] && x <= data[i+1][0]) {\n            if (Math.abs(yScale(data[i][1]) - relY) < 8) {\n              n.x = data[i][0];\n              n.y = data[i][1];\n              n.index = i;\n              n.seriesIndex = options.index;\n            }\n            break;\n          }\n        }\n      };\n\n      this.drawHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.save();\n          context.strokeStyle = options.color;\n          context.lineWidth = options.lineWidth;\n          context.beginPath();\n          context.moveTo(x, y);\n          context.lineTo(x2, y);\n          context.stroke();\n          context.closePath();\n          context.restore();\n        }\n      };\n\n      this.clearHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          width   = options.lineWidth,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.clearRect(x - width, y - width, x2 - x + 2 * width, 2 * width);\n        }\n      };\n    }\n  }\n\n});\n\n/** Bars **/\nFlotr.addType('bars', {\n\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    horizontal: false,     // => horizontal bars (x and y inverted)\n    stacked: false,        // => stacked bar charts\n    centered: true,        // => center the bars to their x axis value\n    topPadding: 0.1,       // => top padding in percent\n    grouped: false         // => groups bars together which share x value, hit not supported.\n  },\n\n  stack : { \n    positive : [],\n    negative : [],\n    _positive : [], // Shadow\n    _negative : []  // Shadow\n  },\n\n  draw : function (options) {\n    var\n      context = options.context;\n\n    this.current += 1;\n\n    context.save();\n    context.lineJoin = 'miter';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n    \n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      shadowSize      = options.shadowSize,\n      i, geometry, left, top, width, height;\n\n    if (data.length < 1) return;\n\n    this.translate(context, options.horizontal);\n\n    for (i = 0; i < data.length; i++) {\n\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (geometry === null) continue;\n\n      left    = geometry.left;\n      top     = geometry.top;\n      width   = geometry.width;\n      height  = geometry.height;\n\n      if (options.fill) context.fillRect(left, top, width, height);\n      if (shadowSize) {\n        context.save();\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top + shadowSize, width, height);\n        context.restore();\n      }\n      if (options.lineWidth) {\n        context.strokeRect(left, top, width, height);\n      }\n    }\n  },\n\n  translate : function (context, horizontal) {\n    if (horizontal) {\n      context.rotate(-Math.PI / 2);\n      context.scale(-1, 1);\n    }\n  },\n\n  getBarGeometry : function (x, y, options) {\n\n    var\n      horizontal    = options.horizontal,\n      barWidth      = options.barWidth,\n      centered      = options.centered,\n      stack         = options.stacked ? this.stack : false,\n      lineWidth     = options.lineWidth,\n      bisection     = centered ? barWidth / 2 : 0,\n      xScale        = horizontal ? options.yScale : options.xScale,\n      yScale        = horizontal ? options.xScale : options.yScale,\n      xValue        = horizontal ? y : x,\n      yValue        = horizontal ? x : y,\n      stackOffset   = 0,\n      stackValue, left, right, top, bottom;\n\n    if (options.grouped) {\n      this.current / this.groups;\n      xValue = xValue - bisection;\n      barWidth = barWidth / this.groups;\n      bisection = barWidth / 2;\n      xValue = xValue + barWidth * this.current - bisection;\n    }\n\n    // Stacked bars\n    if (stack) {\n      stackValue          = yValue > 0 ? stack.positive : stack.negative;\n      stackOffset         = stackValue[xValue] || stackOffset;\n      stackValue[xValue]  = stackOffset + yValue;\n    }\n\n    left    = xScale(xValue - bisection);\n    right   = xScale(xValue + barWidth - bisection);\n    top     = yScale(yValue + stackOffset);\n    bottom  = yScale(stackOffset);\n\n    // TODO for test passing... probably looks better without this\n    if (bottom < 0) bottom = 0;\n\n    // TODO Skipping...\n    // if (right < xa.min || left > xa.max || top < ya.min || bottom > ya.max) continue;\n\n    return (x === null || y === null) ? null : {\n      x         : xValue,\n      y         : yValue,\n      xScale    : xScale,\n      yScale    : yScale,\n      top       : top,\n      left      : Math.min(left, right) - lineWidth / 2,\n      width     : Math.abs(right - left) - lineWidth,\n      height    : bottom - top\n    };\n  },\n\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      x = options.xInverse(mouse.relX),\n      y = options.yInverse(mouse.relY),\n      hitGeometry = this.getBarGeometry(x, y, options),\n      width = hitGeometry.width / 2,\n      left = hitGeometry.left,\n      height = hitGeometry.y,\n      geometry, i;\n\n    for (i = data.length; i--;) {\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (\n        // Height:\n        (\n          // Positive Bars:\n          (height > 0 && height < geometry.y) ||\n          // Negative Bars:\n          (height < 0 && height > geometry.y)\n        ) &&\n        // Width:\n        (Math.abs(left - geometry.left) < width)\n      ) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n      }\n    }\n  },\n\n  drawHit : function (options) {\n    // TODO hits for stacked bars; implement using calculateStack option?\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      top         = geometry.top,\n      width       = geometry.width,\n      height      = geometry.height;\n\n    context.save();\n    context.strokeStyle = options.color;\n    context.lineWidth = options.lineWidth;\n    this.translate(context, options.horizontal);\n\n    // Draw highlight\n    context.beginPath();\n    context.moveTo(left, top + height);\n    context.lineTo(left, top);\n    context.lineTo(left + width, top);\n    context.lineTo(left + width, top + height);\n    if (options.fill) {\n      context.fillStyle = options.fillStyle;\n      context.fill();\n    }\n    context.stroke();\n    context.closePath();\n\n    context.restore();\n  },\n\n  clearHit: function (options) {\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      width       = geometry.width,\n      top         = geometry.top,\n      height      = geometry.height,\n      lineWidth   = 2 * options.lineWidth;\n\n    context.save();\n    this.translate(context, options.horizontal);\n    context.clearRect(\n      left - lineWidth,\n      Math.min(top, top + height) - lineWidth,\n      width + 2 * lineWidth,\n      Math.abs(height) + 2 * lineWidth\n    );\n    context.restore();\n  },\n\n  extendXRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n    this.groups = (this.groups + 1) || 1;\n    this.current = 0;\n  },\n\n  extendYRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n  },\n  _extendRange: function (axis, data, options, bars) {\n\n    var\n      max = axis.options.max;\n\n    if (_.isNumber(max) || _.isString(max)) return; \n\n    var\n      newmin = axis.min,\n      newmax = axis.max,\n      horizontal = options.horizontal,\n      orientation = axis.orientation,\n      positiveSums = this.positiveSums || {},\n      negativeSums = this.negativeSums || {},\n      value, datum, index, j;\n\n    // Sides of bars\n    if ((orientation == 1 && !horizontal) || (orientation == -1 && horizontal)) {\n      if (options.centered) {\n        newmax = Math.max(axis.datamax + options.barWidth, newmax);\n        newmin = Math.min(axis.datamin - options.barWidth, newmin);\n      }\n    }\n\n    if (options.stacked && \n        ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal))){\n\n      for (j = data.length; j--;) {\n        value = data[j][(orientation == 1 ? 1 : 0)]+'';\n        datum = data[j][(orientation == 1 ? 0 : 1)];\n\n        // Positive\n        if (datum > 0) {\n          positiveSums[value] = (positiveSums[value] || 0) + datum;\n          newmax = Math.max(newmax, positiveSums[value]);\n        }\n\n        // Negative\n        else {\n          negativeSums[value] = (negativeSums[value] || 0) + datum;\n          newmin = Math.min(newmin, negativeSums[value]);\n        }\n      }\n    }\n\n    // End of bars\n    if ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal)) {\n      if (options.topPadding && (axis.max === axis.datamax || (options.stacked && this.stackMax !== newmax))) {\n        newmax += options.topPadding * (newmax - newmin);\n      }\n    }\n\n    this.stackMin = newmin;\n    this.stackMax = newmax;\n    this.negativeSums = negativeSums;\n    this.positiveSums = positiveSums;\n\n    axis.max = newmax;\n    axis.min = newmin;\n  }\n\n});\n\n/** Bubbles **/\nFlotr.addType('bubbles', {\n  options: {\n    show: false,      // => setting to true will show radar chart, false will hide\n    lineWidth: 2,     // => line width in pixels\n    fill: true,       // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4, // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    baseRadius: 2     // => ratio of the radar, against the plot size\n  },\n  draw : function (options) {\n    var\n      context     = options.context,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    \n    // Shadows\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n\n    var\n      data    = options.data,\n      context = options.context,\n      geometry,\n      i, x, y, z;\n\n    offset = offset || 0;\n    \n    for (i = 0; i < data.length; ++i){\n\n      geometry = this.getGeometry(data[i], options);\n\n      context.beginPath();\n      context.arc(geometry.x + offset, geometry.y + offset, geometry.z, 0, 2 * Math.PI, true);\n      context.stroke();\n      if (options.fill) context.fill();\n      context.closePath();\n    }\n  },\n  getGeometry : function (point, options) {\n    return {\n      x : options.xScale(point[0]),\n      y : options.yScale(point[1]),\n      z : point[2] * options.baseRadius\n    };\n  },\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      relX = mouse.relX,\n      relY = mouse.relY,\n      distance,\n      geometry,\n      dx, dy;\n\n    n.best = n.best || Number.MAX_VALUE;\n\n    for (i = data.length; i--;) {\n      geometry = this.getGeometry(data[i], options);\n\n      dx = geometry.x - relX;\n      dy = geometry.y - relY;\n      distance = Math.sqrt(dx * dx + dy * dy);\n\n      if (distance < geometry.z && geometry.z < n.best) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n        n.best = geometry.z;\n      }\n    }\n  },\n  drawHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options);\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    context.fillStyle = options.fillStyle;\n    context.strokeStyle = options.color;\n    context.beginPath();\n    context.arc(geometry.x, geometry.y, geometry.z, 0, 2 * Math.PI, true);\n    context.fill();\n    context.stroke();\n    context.closePath();\n    context.restore();\n  },\n  clearHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options),\n      offset = geometry.z + options.lineWidth;\n\n    context.save();\n    context.clearRect(\n      geometry.x - offset, \n      geometry.y - offset,\n      2 * offset,\n      2 * offset\n    );\n    context.restore();\n  }\n  // TODO Add a hit calculation method (like pie)\n});\n\n/** Candles **/\nFlotr.addType('candles', {\n  options: {\n    show: false,           // => setting to true will show candle sticks, false will hide\n    lineWidth: 1,          // => in pixels\n    wickLineWidth: 1,      // => in pixels\n    candleWidth: 0.6,      // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    upFillColor: '#00A8F0',// => up sticks fill color\n    downFillColor: '#CB4B4B',// => down sticks fill color\n    fillOpacity: 0.5,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    // TODO Test this barcharts option.\n    barcharts: false       // => draw as barcharts (not standard bars but financial barcharts)\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin = 'miter';\n    context.lineCap = 'butt';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.wickLineWidth || options.lineWidth;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data          = options.data,\n      context       = options.context,\n      xScale        = options.xScale,\n      yScale        = options.yScale,\n      width         = options.candleWidth / 2,\n      shadowSize    = options.shadowSize,\n      lineWidth     = options.lineWidth,\n      wickLineWidth = options.wickLineWidth,\n      pixelOffset   = (wickLineWidth % 2) / 2,\n      color,\n      datum, x, y,\n      open, high, low, close,\n      left, right, bottom, top, bottom2, top2,\n      i;\n\n    if (data.length < 1) return;\n\n    for (i = 0; i < data.length; i++) {\n      datum   = data[i];\n      x       = datum[0];\n      open    = datum[1];\n      high    = datum[2];\n      low     = datum[3];\n      close   = datum[4];\n      left    = xScale(x - width);\n      right   = xScale(x + width);\n      bottom  = yScale(low);\n      top     = yScale(high);\n      bottom2 = yScale(Math.min(open, close));\n      top2    = yScale(Math.max(open, close));\n\n      /*\n      // TODO skipping\n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      */\n\n      color = options[open > close ? 'downFillColor' : 'upFillColor'];\n\n      // Fill the candle.\n      // TODO Test the barcharts option\n      if (options.fill && !options.barcharts) {\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top2 + shadowSize, right - left, bottom2 - top2);\n        context.save();\n        context.globalAlpha = options.fillOpacity;\n        context.fillStyle = color;\n        context.fillRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n        context.restore();\n      }\n\n      // Draw candle outline/border, high, low.\n      if (lineWidth || wickLineWidth) {\n\n        x = Math.floor((left + right) / 2) + pixelOffset;\n\n        context.strokeStyle = color;\n        context.beginPath();\n\n        // TODO Again with the bartcharts\n        if (options.barcharts) {\n          \n          context.moveTo(x, Math.floor(top + width));\n          context.lineTo(x, Math.floor(bottom + width));\n          \n          y = Math.floor(open + width) + 0.5;\n          context.moveTo(Math.floor(left) + pixelOffset, y);\n          context.lineTo(x, y);\n          \n          y = Math.floor(close + width) + 0.5;\n          context.moveTo(Math.floor(right) + pixelOffset, y);\n          context.lineTo(x, y);\n        } else {\n          context.strokeRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n\n          context.moveTo(x, Math.floor(top2 + lineWidth));\n          context.lineTo(x, Math.floor(top + lineWidth));\n          context.moveTo(x, Math.floor(bottom2 + lineWidth));\n          context.lineTo(x, Math.floor(bottom + lineWidth));\n        }\n        \n        context.closePath();\n        context.stroke();\n      }\n    }\n  },\n  extendXRange: function (axis, data, options) {\n    if (axis.options.max === null) {\n      axis.max = Math.max(axis.datamax + 0.5, axis.max);\n      axis.min = Math.min(axis.datamin - 0.5, axis.min);\n    }\n  }\n});\n\n/** Gantt\n * Base on data in form [s,y,d] where:\n * y - executor or simply y value\n * s - task start value\n * d - task duration\n * **/\nFlotr.addType('gantt', {\n  options: {\n    show: false,           // => setting to true will show gantt, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    centered: true         // => center the bars to their x axis value\n  },\n  /**\n   * Draws gantt series in the canvas element.\n   * @param {Object} series - Series with options.gantt.show = true.\n   */\n  draw: function(series) {\n    var ctx = this.ctx,\n      bw = series.gantt.barWidth,\n      lw = Math.min(series.gantt.lineWidth, bw);\n    \n    ctx.save();\n    ctx.translate(this.plotOffset.left, this.plotOffset.top);\n    ctx.lineJoin = 'miter';\n\n    /**\n     * @todo linewidth not interpreted the right way.\n     */\n    ctx.lineWidth = lw;\n    ctx.strokeStyle = series.color;\n    \n    ctx.save();\n    this.gantt.plotShadows(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n    \n    if(series.gantt.fill){\n      var color = series.gantt.fillColor || series.color;\n      ctx.fillStyle = this.processColor(color, {opacity: series.gantt.fillOpacity});\n    }\n    \n    this.gantt.plot(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n  },\n  plot: function(series, barWidth, offset, fill){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx, i;\n\n    for(i = 0; i < data.length; i++){\n      var y = data[i][0],\n          s = data[i][1],\n          d = data[i][2],\n          drawLeft = true, drawTop = true, drawRight = true;\n      \n      if (s === null || d === null) continue;\n\n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n      \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n\n      if(left < xa.min){\n        left = xa.min;\n        drawLeft = false;\n      }\n\n      if(right > xa.max){\n        right = xa.max;\n        if (xa.lastSerie != series)\n          drawTop = false;\n      }\n\n      if(bottom < ya.min)\n        bottom = ya.min;\n\n      if(top > ya.max){\n        top = ya.max;\n        if (ya.lastSerie != series)\n          drawTop = false;\n      }\n      \n      /**\n       * Fill the bar.\n       */\n      if(fill){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        ctx.lineTo(xa.d2p(left), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(bottom) + offset);\n        ctx.fill();\n        ctx.closePath();\n      }\n\n      /**\n       * Draw bar outline/border.\n       */\n      if(series.gantt.lineWidth && (drawLeft || drawRight || drawTop)){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        \n        ctx[drawLeft ?'lineTo':'moveTo'](xa.d2p(left), ya.d2p(top) + offset);\n        ctx[drawTop  ?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(top) + offset);\n        ctx[drawRight?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(bottom) + offset);\n                 \n        ctx.stroke();\n        ctx.closePath();\n      }\n    }\n  },\n  plotShadows: function(series, barWidth, offset){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var i, y, s, d,\n        xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx,\n        sw = this.options.shadowSize;\n    \n    for(i = 0; i < data.length; i++){\n      y = data[i][0];\n      s = data[i][1];\n      d = data[i][2];\n        \n      if (s === null || d === null) continue;\n            \n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      \n      if(left < xa.min)   left = xa.min;\n      if(right > xa.max)  right = xa.max;\n      if(bottom < ya.min) bottom = ya.min;\n      if(top > ya.max)    top = ya.max;\n      \n      var width =  xa.d2p(right)-xa.d2p(left)-((xa.d2p(right)+sw <= this.plotWidth) ? 0 : sw);\n      var height = ya.d2p(bottom)-ya.d2p(top)-((ya.d2p(bottom)+sw <= this.plotHeight) ? 0 : sw );\n      \n      ctx.fillStyle = 'rgba(0,0,0,0.05)';\n      ctx.fillRect(Math.min(xa.d2p(left)+sw, this.plotWidth), Math.min(ya.d2p(top)+sw, this.plotHeight), width, height);\n    }\n  },\n  extendXRange: function(axis) {\n    if(axis.options.max === null){\n      var newmin = axis.min,\n          newmax = axis.max,\n          i, j, x, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n\n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if(g.show && s.xaxis == axis) {\n            for (j = 0; j < s.data.length; j++) {\n              if (g.show) {\n                y = s.data[j][0]+'';\n                stackedSumsPos[y] = Math.max((stackedSumsPos[y] || 0), s.data[j][1]+s.data[j][2]);\n                lastSerie = s;\n              }\n            }\n            for (j in stackedSumsPos) {\n              newmax = Math.max(stackedSumsPos[j], newmax);\n            }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n  },\n  extendYRange: function(axis){\n    if(axis.options.max === null){\n      var newmax = Number.MIN_VALUE,\n          newmin = Number.MAX_VALUE,\n          i, j, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n                  \n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if (g.show && !s.hide && s.yaxis == axis) {\n          var datamax = Number.MIN_VALUE, datamin = Number.MAX_VALUE;\n          for(j=0; j < s.data.length; j++){\n            datamax = Math.max(datamax,s.data[j][0]);\n            datamin = Math.min(datamin,s.data[j][0]);\n          }\n            \n          if (g.centered) {\n            newmax = Math.max(datamax + 0.5, newmax);\n            newmin = Math.min(datamin - 0.5, newmin);\n          }\n        else {\n          newmax = Math.max(datamax + 1, newmax);\n            newmin = Math.min(datamin, newmin);\n          }\n          // For normal horizontal bars\n          if (g.barWidth + datamax > newmax){\n            newmax = axis.max + g.barWidth;\n          }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n      axis.tickSize = Flotr.getTickSize(axis.options.noTicks, newmin, newmax, axis.options.tickDecimals);\n    }\n  }\n});\n\n/** Markers **/\n/**\n * Formats the marker labels.\n * @param {Object} obj - Marker value Object {x:..,y:..}\n * @return {String} Formatted marker string\n */\n(function () {\n\nFlotr.defaultMarkerFormatter = function(obj){\n  return (Math.round(obj.y*100)/100)+'';\n};\n\nFlotr.addType('markers', {\n  options: {\n    show: false,           // => setting to true will show markers, false will hide\n    lineWidth: 1,          // => line width of the rectangle around the marker\n    color: '#000000',      // => text color\n    fill: false,           // => fill or not the marekers' rectangles\n    fillColor: \"#FFFFFF\",  // => fill color\n    fillOpacity: 0.4,      // => fill opacity\n    stroke: false,         // => draw the rectangle around the markers\n    position: 'ct',        // => the markers position (vertical align: b, m, t, horizontal align: l, c, r)\n    verticalMargin: 0,     // => the margin between the point and the text.\n    labelFormatter: Flotr.defaultMarkerFormatter,\n    fontSize: Flotr.defaultOptions.fontSize,\n    stacked: false,        // => true if markers should be stacked\n    stackingType: 'b',     // => define staching behavior, (b- bars like, a - area like) (see Issue 125 for details)\n    horizontal: false      // => true if markers should be horizontal (For now only in a case on horizontal stacked bars, stacks should be calculated horizontaly)\n  },\n\n  // TODO test stacked markers.\n  stack : {\n      positive : [],\n      negative : [],\n      values : []\n  },\n\n  draw : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      stack           = options.stacked ? options.stack : false,\n      stackType       = options.stackingType,\n      stackOffsetNeg,\n      stackOffsetPos,\n      stackOffset,\n      i, x, y, label;\n\n    context.save();\n    context.lineJoin = 'round';\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = 'rgba(0,0,0,0.5)';\n    context.fillStyle = options.fillStyle;\n\n    function stackPos (a, b) {\n      stackOffsetPos = stack.negative[a] || 0;\n      stackOffsetNeg = stack.positive[a] || 0;\n      if (b > 0) {\n        stack.positive[a] = stackOffsetPos + b;\n        return stackOffsetPos + b;\n      } else {\n        stack.negative[a] = stackOffsetNeg + b;\n        return stackOffsetNeg + b;\n      }\n    }\n\n    for (i = 0; i < data.length; ++i) {\n    \n      x = data[i][0];\n      y = data[i][1];\n        \n      if (stack) {\n        if (stackType == 'b') {\n          if (options.horizontal) y = stackPos(y, x);\n          else x = stackPos(x, y);\n        } else if (stackType == 'a') {\n          stackOffset = stack.values[x] || 0;\n          stack.values[x] = stackOffset + y;\n          y = stackOffset + y;\n        }\n      }\n\n      label = options.labelFormatter({x: x, y: y, index: i, data : data});\n      this.plot(options.xScale(x), options.yScale(y), label, options);\n    }\n    context.restore();\n  },\n  plot: function(x, y, label, options) {\n    var context = options.context;\n    if (isImage(label) && !label.complete) {\n      throw 'Marker image not loaded.';\n    } else {\n      this._plot(x, y, label, options);\n    }\n  },\n\n  _plot: function(x, y, label, options) {\n    var context = options.context,\n        margin = 2,\n        left = x,\n        top = y,\n        dim;\n\n    if (isImage(label))\n      dim = {height : label.height, width: label.width};\n    else\n      dim = options.text.canvas(label);\n\n    dim.width = Math.floor(dim.width+margin*2);\n    dim.height = Math.floor(dim.height+margin*2);\n\n         if (options.position.indexOf('c') != -1) left -= dim.width/2 + margin;\n    else if (options.position.indexOf('l') != -1) left -= dim.width;\n    \n         if (options.position.indexOf('m') != -1) top -= dim.height/2 + margin;\n    else if (options.position.indexOf('t') != -1) top -= dim.height + options.verticalMargin;\n    else top += options.verticalMargin;\n    \n    left = Math.floor(left)+0.5;\n    top = Math.floor(top)+0.5;\n    \n    if(options.fill)\n      context.fillRect(left, top, dim.width, dim.height);\n      \n    if(options.stroke)\n      context.strokeRect(left, top, dim.width, dim.height);\n    \n    if (isImage(label))\n      context.drawImage(label, left+margin, top+margin);\n    else\n      Flotr.drawText(context, label, left+margin, top+margin, {textBaseline: 'top', textAlign: 'left', size: options.fontSize, color: options.color});\n  }\n});\n\nfunction isImage (i) {\n  return typeof i === 'object' && i.constructor && (Image ? true : i.constructor === Image);\n}\n\n})();\n\n/**\n * Pie\n *\n * Formats the pies labels.\n * @param {Object} slice - Slice object\n * @return {String} Formatted pie label string\n */\n(function () {\n\nvar\n  _ = Flotr._;\n\nFlotr.defaultPieLabelFormatter = function (total, value) {\n  return (100 * value / total).toFixed(2)+'%';\n};\n\nFlotr.addType('pie', {\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 1,          // => in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.6,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    explode: 6,            // => the number of pixels the splices will be far from the center\n    sizeRatio: 0.6,        // => the size ratio of the pie relative to the plot \n    startAngle: Math.PI/4, // => the first slice start angle\n    labelFormatter: Flotr.defaultPieLabelFormatter,\n    pie3D: false,          // => whether to draw the pie in 3 dimenstions or not (ineffective) \n    pie3DviewAngle: (Math.PI/2 * 0.8),\n    pie3DspliceThickness: 20,\n    epsilon: 0.1           // => how close do you have to get to hit empty slice\n  },\n\n  draw : function (options) {\n\n    // TODO 3D charts what?\n\n    var\n      data          = options.data,\n      context       = options.context,\n      canvas        = context.canvas,\n      lineWidth     = options.lineWidth,\n      shadowSize    = options.shadowSize,\n      sizeRatio     = options.sizeRatio,\n      height        = options.height,\n      width         = options.width,\n      explode       = options.explode,\n      color         = options.color,\n      fill          = options.fill,\n      fillStyle     = options.fillStyle,\n      radius        = Math.min(canvas.width, canvas.height) * sizeRatio / 2,\n      value         = data[0][1],\n      html          = [],\n      vScale        = 1,//Math.cos(series.pie.viewAngle);\n      measure       = Math.PI * 2 * value / this.total,\n      startAngle    = this.startAngle || (2 * Math.PI * options.startAngle), // TODO: this initial startAngle is already in radians (fixing will be test-unstable)\n      endAngle      = startAngle + measure,\n      bisection     = startAngle + measure / 2,\n      label         = options.labelFormatter(this.total, value),\n      //plotTickness  = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;\n      explodeCoeff  = explode + radius + 4,\n      distX         = Math.cos(bisection) * explodeCoeff,\n      distY         = Math.sin(bisection) * explodeCoeff,\n      textAlign     = distX < 0 ? 'right' : 'left',\n      textBaseline  = distY > 0 ? 'top' : 'bottom',\n      style,\n      x, y;\n    \n    context.save();\n    context.translate(width / 2, height / 2);\n    context.scale(1, vScale);\n\n    x = Math.cos(bisection) * explode;\n    y = Math.sin(bisection) * explode;\n\n    // Shadows\n    if (shadowSize > 0) {\n      this.plotSlice(x + shadowSize, y + shadowSize, radius, startAngle, endAngle, context);\n      if (fill) {\n        context.fillStyle = 'rgba(0,0,0,0.1)';\n        context.fill();\n      }\n    }\n\n    this.plotSlice(x, y, radius, startAngle, endAngle, context);\n    if (fill) {\n      context.fillStyle = fillStyle;\n      context.fill();\n    }\n    context.lineWidth = lineWidth;\n    context.strokeStyle = color;\n    context.stroke();\n\n    style = {\n      size : options.fontSize * 1.2,\n      color : options.fontColor,\n      weight : 1.5\n    };\n\n    if (label) {\n      if (options.htmlText || !options.textEnabled) {\n        divStyle = 'position:absolute;' + textBaseline + ':' + (height / 2 + (textBaseline === 'top' ? distY : -distY)) + 'px;';\n        divStyle += textAlign + ':' + (width / 2 + (textAlign === 'right' ? -distX : distX)) + 'px;';\n        html.push('<div style=\"', divStyle, '\" class=\"flotr-grid-label\">', label, '</div>');\n      }\n      else {\n        style.textAlign = textAlign;\n        style.textBaseline = textBaseline;\n        Flotr.drawText(context, label, distX, distY, style);\n      }\n    }\n    \n    if (options.htmlText || !options.textEnabled) {\n      var div = Flotr.DOM.node('<div style=\"color:' + options.fontColor + '\" class=\"flotr-labels\"></div>');\n      Flotr.DOM.insert(div, html.join(''));\n      Flotr.DOM.insert(options.element, div);\n    }\n    \n    context.restore();\n\n    // New start angle\n    this.startAngle = endAngle;\n    this.slices = this.slices || [];\n    this.slices.push({\n      radius : Math.min(canvas.width, canvas.height) * sizeRatio / 2,\n      x : x,\n      y : y,\n      explode : explode,\n      start : startAngle,\n      end : endAngle\n    });\n  },\n  plotSlice : function (x, y, radius, startAngle, endAngle, context) {\n    context.beginPath();\n    context.moveTo(x, y);\n    context.arc(x, y, radius, startAngle, endAngle, false);\n    context.lineTo(x, y);\n    context.closePath();\n  },\n  hit : function (options) {\n\n    var\n      data      = options.data[0],\n      args      = options.args,\n      index     = options.index,\n      mouse     = args[0],\n      n         = args[1],\n      slice     = this.slices[index],\n      x         = mouse.relX - options.width / 2,\n      y         = mouse.relY - options.height / 2,\n      r         = Math.sqrt(x * x + y * y),\n      theta     = Math.atan(y / x),\n      circle    = Math.PI * 2,\n      explode   = slice.explode || options.explode,\n      start     = slice.start % circle,\n      end       = slice.end % circle,\n      epsilon   = options.epsilon;\n\n    if (x < 0) {\n      theta += Math.PI;\n    } else if (x > 0 && y < 0) {\n      theta += circle;\n    }\n\n    if (r < slice.radius + explode && r > explode) {\n      if (\n          (theta > start && theta < end) || // Normal Slice\n          (start > end && (theta < end || theta > start)) || // First slice\n          // TODO: Document the two cases at the end:\n          (start === end && ((slice.start === slice.end && Math.abs(theta - start) < epsilon) || (slice.start !== slice.end && Math.abs(theta-start) > epsilon)))\n         ) {\n          \n          // TODO Decouple this from hit plugin (chart shouldn't know what n means)\n         n.x = data[0];\n         n.y = data[1];\n         n.sAngle = start;\n         n.eAngle = end;\n         n.index = 0;\n         n.seriesIndex = index;\n         n.fraction = data[1] / this.total;\n      }\n    }\n  },\n  drawHit: function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex];\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    this.plotSlice(slice.x, slice.y, slice.radius, slice.start, slice.end, context);\n    context.stroke();\n    context.restore();\n  },\n  clearHit : function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex],\n      padding = 2 * options.lineWidth,\n      radius = slice.radius + padding;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.clearRect(\n      slice.x - radius,\n      slice.y - radius,\n      2 * radius + padding,\n      2 * radius + padding \n    );\n    context.restore();\n  },\n  extendYRange : function (axis, data) {\n    this.total = (this.total || 0) + data[0][1];\n  }\n});\n})();\n\n/** Points **/\nFlotr.addType('points', {\n  options: {\n    show: false,           // => setting to true will show points, false will hide\n    radius: 3,             // => point radius (pixels)\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the points with a color, false for (transparent) no fill\n    fillColor: '#FFFFFF',  // => fill color.  Null to use series color.\n    fillOpacity: 1,        // => opacity of color inside the points\n    hitRadius: null        // => override for points hit radius\n  },\n\n  draw : function (options) {\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n\n    if (shadowSize > 0) {\n      context.lineWidth = shadowSize / 2;\n      \n      context.strokeStyle = 'rgba(0,0,0,0.1)';\n      this.plot(options, shadowSize / 2 + context.lineWidth / 2);\n\n      context.strokeStyle = 'rgba(0,0,0,0.2)';\n      this.plot(options, context.lineWidth / 2);\n    }\n\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n\n    this.plot(options);\n    context.restore();\n  },\n\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      xScale  = options.xScale,\n      yScale  = options.yScale,\n      i, x, y;\n      \n    for (i = data.length - 1; i > -1; --i) {\n      y = data[i][1];\n      if (y === null) continue;\n\n      x = xScale(data[i][0]);\n      y = yScale(y);\n\n      if (x < 0 || x > options.width || y < 0 || y > options.height) continue;\n      \n      context.beginPath();\n      if (offset) {\n        context.arc(x, y + offset, options.radius, 0, Math.PI, false);\n      } else {\n        context.arc(x, y, options.radius, 0, 2 * Math.PI, true);\n        if (options.fill) context.fill();\n      }\n      context.stroke();\n      context.closePath();\n    }\n  }\n});\n\n/** Radar **/\nFlotr.addType('radar', {\n  options: {\n    show: false,           // => setting to true will show radar chart, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    radiusRatio: 0.90      // => ratio of the radar, against the plot size\n  },\n  draw : function (options) {\n    var\n      context = options.context,\n      shadowSize = options.shadowSize;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.lineWidth = options.lineWidth;\n    \n    // Shadow\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      radius  = Math.min(options.height, options.width) * options.radiusRatio / 2,\n      step    = 2 * Math.PI / data.length,\n      angle   = -Math.PI / 2,\n      i, ratio;\n\n    offset = offset || 0;\n\n    context.beginPath();\n    for (i = 0; i < data.length; ++i) {\n      ratio = data[i][1] / this.max;\n\n      context[i === 0 ? 'moveTo' : 'lineTo'](\n        Math.cos(i * step + angle) * radius * ratio + offset,\n        Math.sin(i * step + angle) * radius * ratio + offset\n      );\n    }\n    context.closePath();\n    if (options.fill) context.fill();\n    context.stroke();\n  },\n  extendYRange : function (axis, data) {\n    this.max = Math.max(axis.max, this.max || -Number.MAX_VALUE);\n  }\n});\n\nFlotr.addType('timeline', {\n  options: {\n    show: false,\n    lineWidth: 1,\n    barWidth: 0.2,\n    fill: true,\n    fillColor: null,\n    fillOpacity: 0.4,\n    centered: true\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin    = 'miter';\n    context.lineWidth   = options.lineWidth;\n    context.strokeStyle = options.color;\n    context.fillStyle   = options.fillStyle;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data      = options.data,\n      context   = options.context,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      barWidth  = options.barWidth,\n      lineWidth = options.lineWidth,\n      i;\n\n    Flotr._.each(data, function (timeline) {\n\n      var \n        x   = timeline[0],\n        y   = timeline[1],\n        w   = timeline[2],\n        h   = barWidth,\n\n        xt  = Math.ceil(xScale(x)),\n        wt  = Math.ceil(xScale(x + w)) - xt,\n        yt  = Math.round(yScale(y)),\n        ht  = Math.round(yScale(y - h)) - yt,\n\n        x0  = xt - lineWidth / 2,\n        y0  = Math.round(yt - ht / 2) - lineWidth / 2;\n\n      context.strokeRect(x0, y0, wt, ht);\n      context.fillRect(x0, y0, wt, ht);\n\n    });\n  },\n\n  extendRange : function (series) {\n\n    var\n      data  = series.data,\n      xa    = series.xaxis,\n      ya    = series.yaxis,\n      w     = series.timeline.barWidth;\n\n    if (xa.options.min === null)\n      xa.min = xa.datamin - w / 2;\n\n    if (xa.options.max === null) {\n\n      var\n        max = xa.max;\n\n      Flotr._.each(data, function (timeline) {\n        max = Math.max(max, timeline[0] + timeline[2]);\n      }, this);\n\n      xa.max = max + w / 2;\n    }\n\n    if (ya.options.min === null)\n      ya.min = ya.datamin - w;\n    if (ya.options.min === null)\n      ya.max = ya.datamax + w;\n  }\n\n});\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('crosshair', {\n  options: {\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#FF0000',      // => crosshair color\n    hideCursor: true       // => hide the cursor when the crosshair is shown\n  },\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      if (this.options.crosshair.mode) {\n        this.crosshair.clearCrosshair();\n        this.crosshair.drawCrosshair(pos);\n      }\n    }\n  },\n  /**   \n   * Draws the selection box.\n   */\n  drawCrosshair: function(pos) {\n    var octx = this.octx,\n      options = this.options.crosshair,\n      plotOffset = this.plotOffset,\n      x = plotOffset.left + Math.round(pos.relX) + 0.5,\n      y = plotOffset.top + Math.round(pos.relY) + 0.5;\n    \n    if (pos.relX < 0 || pos.relY < 0 || pos.relX > this.plotWidth || pos.relY > this.plotHeight) {\n      this.el.style.cursor = null;\n      D.removeClass(this.el, 'flotr-crosshair');\n      return; \n    }\n    \n    if (options.hideCursor) {\n      this.el.style.cursor = 'none';\n      D.addClass(this.el, 'flotr-crosshair');\n    }\n    \n    octx.save();\n    octx.strokeStyle = options.color;\n    octx.lineWidth = 1;\n    octx.beginPath();\n    \n    if (options.mode.indexOf('x') != -1) {\n      octx.moveTo(x, plotOffset.top);\n      octx.lineTo(x, plotOffset.top + this.plotHeight);\n    }\n    \n    if (options.mode.indexOf('y') != -1) {\n      octx.moveTo(plotOffset.left, y);\n      octx.lineTo(plotOffset.left + this.plotWidth, y);\n    }\n    \n    octx.stroke();\n    octx.restore();\n  },\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearCrosshair: function() {\n\n    var\n      plotOffset = this.plotOffset,\n      position = this.lastMousePos,\n      context = this.octx;\n\n    if (position) {\n      context.clearRect(\n        Math.round(position.relX) + plotOffset.left,\n        plotOffset.top,\n        1,\n        this.plotHeight + 1\n      );\n      context.clearRect(\n        plotOffset.left,\n        Math.round(position.relY) + plotOffset.top,\n        this.plotWidth + 1,\n        1\n      );    \n    }\n  }\n});\n})();\n\n(function() {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nfunction getImage (type, canvas, width, height) {\n\n  // TODO add scaling for w / h\n  var\n    mime = 'image/'+type,\n    data = canvas.toDataURL(mime),\n    image = new Image();\n  image.src = data;\n  return image;\n}\n\nFlotr.addPlugin('download', {\n\n  saveImage: function (type, width, height, replaceCanvas) {\n    var image = null;\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      image = '<html><body>'+this.canvas.firstChild.innerHTML+'</body></html>';\n      return window.open().document.write(image);\n    }\n\n    if (type !== 'jpeg' && type !== 'png') return;\n\n    image = getImage(type, this.canvas, width, height);\n\n    if (_.isElement(image) && replaceCanvas) {\n      this.download.restoreCanvas();\n      D.hide(this.canvas);\n      D.hide(this.overlay);\n      D.setStyles({position: 'absolute'});\n      D.insert(this.el, image);\n      this.saveImageElement = image;\n    } else {\n      return window.open(image.src);\n    }\n  },\n\n  restoreCanvas: function() {\n    D.show(this.canvas);\n    D.show(this.overlay);\n    if (this.saveImageElement) this.el.removeChild(this.saveImageElement);\n    this.saveImageElement = null;\n  }\n});\n\n})();\n\n(function () {\n\nvar E = Flotr.EventAdapter,\n    _ = Flotr._;\n\nFlotr.addPlugin('graphGrid', {\n\n  callbacks: {\n    'flotr:beforedraw' : function () {\n      this.graphGrid.drawGrid();\n    },\n    'flotr:afterdraw' : function () {\n      this.graphGrid.drawOutline();\n    }\n  },\n\n  drawGrid: function(){\n\n    var\n      ctx = this.ctx,\n      options = this.options,\n      grid = options.grid,\n      verticalLines = grid.verticalLines,\n      horizontalLines = grid.horizontalLines,\n      minorVerticalLines = grid.minorVerticalLines,\n      minorHorizontalLines = grid.minorHorizontalLines,\n      plotHeight = this.plotHeight,\n      plotWidth = this.plotWidth,\n      a, v, i, j;\n        \n    if(verticalLines || minorVerticalLines || \n           horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:beforegrid', [this.axes.x, this.axes.y, options, this]);\n    }\n    ctx.save();\n    ctx.lineWidth = 1;\n    ctx.strokeStyle = grid.tickColor;\n    \n    function circularHorizontalTicks (ticks) {\n      for(i = 0; i < ticks.length; ++i){\n        var ratio = ticks[i].v / a.max;\n        for(j = 0; j <= sides; ++j){\n          ctx[j === 0 ? 'moveTo' : 'lineTo'](\n            Math.cos(j*coeff+angle)*radius*ratio,\n            Math.sin(j*coeff+angle)*radius*ratio\n          );\n        }\n      }\n    }\n    function drawGridLines (ticks, callback) {\n      _.each(_.pluck(ticks, 'v'), function(v){\n        // Don't show lines on upper and lower bounds.\n        if ((v <= a.min || v >= a.max) || \n            (v == a.min || v == a.max) && grid.outlineWidth)\n          return;\n        callback(Math.floor(a.d2p(v)) + ctx.lineWidth/2);\n      });\n    }\n    function drawVerticalLines (x) {\n      ctx.moveTo(x, 0);\n      ctx.lineTo(x, plotHeight);\n    }\n    function drawHorizontalLines (y) {\n      ctx.moveTo(0, y);\n      ctx.lineTo(plotWidth, y);\n    }\n\n    if (grid.circular) {\n      ctx.translate(this.plotOffset.left+plotWidth/2, this.plotOffset.top+plotHeight/2);\n      var radius = Math.min(plotHeight, plotWidth)*options.radar.radiusRatio/2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw grid lines in vertical direction.\n      ctx.beginPath();\n      \n      a = this.axes.y;\n\n      if(horizontalLines){\n        circularHorizontalTicks(a.ticks);\n      }\n      if(minorHorizontalLines){\n        circularHorizontalTicks(a.minorTicks);\n      }\n      \n      if(verticalLines){\n        _.times(sides, function(i){\n          ctx.moveTo(0, 0);\n          ctx.lineTo(Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n        });\n      }\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(this.plotOffset.left, this.plotOffset.top);\n  \n      // Draw grid background, if present in options.\n      if(grid.backgroundColor){\n        ctx.fillStyle = this.processColor(grid.backgroundColor, {x1: 0, y1: 0, x2: plotWidth, y2: plotHeight});\n        ctx.fillRect(0, 0, plotWidth, plotHeight);\n      }\n      \n      ctx.beginPath();\n\n      a = this.axes.x;\n      if (verticalLines)        drawGridLines(a.ticks, drawVerticalLines);\n      if (minorVerticalLines)   drawGridLines(a.minorTicks, drawVerticalLines);\n\n      a = this.axes.y;\n      if (horizontalLines)      drawGridLines(a.ticks, drawHorizontalLines);\n      if (minorHorizontalLines) drawGridLines(a.minorTicks, drawHorizontalLines);\n\n      ctx.stroke();\n    }\n    \n    ctx.restore();\n    if(verticalLines || minorVerticalLines ||\n       horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:aftergrid', [this.axes.x, this.axes.y, options, this]);\n    }\n  }, \n\n  drawOutline: function(){\n    var\n      that = this,\n      options = that.options,\n      grid = options.grid,\n      outline = grid.outline,\n      ctx = that.ctx,\n      backgroundImage = grid.backgroundImage,\n      plotOffset = that.plotOffset,\n      leftOffset = plotOffset.left,\n      topOffset = plotOffset.top,\n      plotWidth = that.plotWidth,\n      plotHeight = that.plotHeight,\n      v, img, src, left, top, globalAlpha;\n    \n    if (!grid.outlineWidth) return;\n    \n    ctx.save();\n    \n    if (grid.circular) {\n      ctx.translate(leftOffset + plotWidth / 2, topOffset + plotHeight / 2);\n      var radius = Math.min(plotHeight, plotWidth) * options.radar.radiusRatio / 2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw axis/grid border.\n      ctx.beginPath();\n      ctx.lineWidth = grid.outlineWidth;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'round';\n      \n      for(i = 0; i <= sides; ++i){\n        ctx[i === 0 ? 'moveTo' : 'lineTo'](Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n      }\n      //ctx.arc(0, 0, radius, 0, Math.PI*2, true);\n\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(leftOffset, topOffset);\n      \n      // Draw axis/grid border.\n      var lw = grid.outlineWidth,\n          orig = 0.5-lw+((lw+1)%2/2),\n          lineTo = 'lineTo',\n          moveTo = 'moveTo';\n      ctx.lineWidth = lw;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'miter';\n      ctx.beginPath();\n      ctx.moveTo(orig, orig);\n      plotWidth = plotWidth - (lw / 2) % 1;\n      plotHeight = plotHeight + lw / 2;\n      ctx[outline.indexOf('n') !== -1 ? lineTo : moveTo](plotWidth, orig);\n      ctx[outline.indexOf('e') !== -1 ? lineTo : moveTo](plotWidth, plotHeight);\n      ctx[outline.indexOf('s') !== -1 ? lineTo : moveTo](orig, plotHeight);\n      ctx[outline.indexOf('w') !== -1 ? lineTo : moveTo](orig, orig);\n      ctx.stroke();\n      ctx.closePath();\n    }\n    \n    ctx.restore();\n\n    if (backgroundImage) {\n\n      src = backgroundImage.src || backgroundImage;\n      left = (parseInt(backgroundImage.left, 10) || 0) + plotOffset.left;\n      top = (parseInt(backgroundImage.top, 10) || 0) + plotOffset.top;\n      img = new Image();\n\n      img.onload = function() {\n        ctx.save();\n        if (backgroundImage.alpha) ctx.globalAlpha = backgroundImage.alpha;\n        ctx.globalCompositeOperation = 'destination-over';\n        ctx.drawImage(img, 0, 0, img.width, img.height, left, top, plotWidth, plotHeight);\n        ctx.restore();\n      };\n\n      img.src = src;\n    }\n  }\n});\n\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._,\n  flotr = Flotr,\n  S_MOUSETRACK = 'opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;';\n\nFlotr.addPlugin('hit', {\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      this.hit.track(pos);\n    },\n    'flotr:click': function(pos) {\n      var\n        hit = this.hit.track(pos);\n      _.defaults(pos, hit);\n    },\n    'flotr:mouseout': function() {\n      this.hit.clearHit();\n    },\n    'flotr:destroy': function() {\n      this.mouseTrack = null;\n    }\n  },\n  track : function (pos) {\n    if (this.options.mouse.track || _.any(this.series, function(s){return s.mouse && s.mouse.track;})) {\n      return this.hit.hit(pos);\n    }\n  },\n  /**\n   * Try a method on a graph type.  If the method exists, execute it.\n   * @param {Object} series\n   * @param {String} method  Method name.\n   * @param {Array} args  Arguments applied to method.\n   * @return executed successfully or failed.\n   */\n  executeOnType: function(s, method, args){\n    var\n      success = false,\n      options;\n\n    if (!_.isArray(s)) s = [s];\n\n    function e(s, index) {\n      _.each(_.keys(flotr.graphTypes), function (type) {\n        if (s[type] && s[type].show && this[type][method]) {\n          options = this.getOptions(s, type);\n\n          options.fill = !!s.mouse.fillColor;\n          options.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n          options.color = s.mouse.lineColor;\n          options.context = this.octx;\n          options.index = index;\n\n          if (args) options.args = args;\n          this[type][method].call(this[type], options);\n          success = true;\n        }\n      }, this);\n    }\n    _.each(s, e, this);\n\n    return success;\n  },\n  /**\n   * Updates the mouse tracking point on the overlay.\n   */\n  drawHit: function(n){\n    var octx = this.octx,\n      s = n.series;\n\n    if (s.mouse.lineColor) {\n      octx.save();\n      octx.lineWidth = (s.points ? s.points.lineWidth : 1);\n      octx.strokeStyle = s.mouse.lineColor;\n      octx.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n      octx.translate(this.plotOffset.left, this.plotOffset.top);\n\n      if (!this.hit.executeOnType(s, 'drawHit', n)) {\n        var\n          xa = n.xaxis,\n          ya = n.yaxis;\n\n        octx.beginPath();\n          // TODO fix this (points) should move to general testable graph mixin\n          octx.arc(xa.d2p(n.x), ya.d2p(n.y), s.points.hitRadius || s.points.radius || s.mouse.radius, 0, 2 * Math.PI, true);\n          octx.fill();\n          octx.stroke();\n        octx.closePath();\n      }\n      octx.restore();\n      this.clip(octx);\n    }\n    this.prevHit = n;\n  },\n  /**\n   * Removes the mouse tracking point from the overlay.\n   */\n  clearHit: function(){\n    var prev = this.prevHit,\n        octx = this.octx,\n        plotOffset = this.plotOffset;\n    octx.save();\n    octx.translate(plotOffset.left, plotOffset.top);\n    if (prev) {\n      if (!this.hit.executeOnType(prev.series, 'clearHit', this.prevHit)) {\n        // TODO fix this (points) should move to general testable graph mixin\n        var\n          s = prev.series,\n          lw = (s.points ? s.points.lineWidth : 1);\n          offset = (s.points.hitRadius || s.points.radius || s.mouse.radius) + lw;\n        octx.clearRect(\n          prev.xaxis.d2p(prev.x) - offset,\n          prev.yaxis.d2p(prev.y) - offset,\n          offset*2,\n          offset*2\n        );\n      }\n      D.hide(this.mouseTrack);\n      this.prevHit = null;\n    }\n    octx.restore();\n  },\n  /**\n   * Retrieves the nearest data point from the mouse cursor. If it's within\n   * a certain range, draw a point on the overlay canvas and display the x and y\n   * value of the data.\n   * @param {Object} mouse - Object that holds the relative x and y coordinates of the cursor.\n   */\n  hit : function (mouse) {\n\n    var\n      options = this.options,\n      prevHit = this.prevHit,\n      closest, sensibility, dataIndex, seriesIndex, series, value, xaxis, yaxis, n;\n\n    if (this.series.length === 0) return;\n\n    // Nearest data element.\n    // dist, x, y, relX, relY, absX, absY, sAngle, eAngle, fraction, mouse,\n    // xaxis, yaxis, series, index, seriesIndex\n    n = {\n      relX : mouse.relX,\n      relY : mouse.relY,\n      absX : mouse.absX,\n      absY : mouse.absY\n    };\n\n    if (options.mouse.trackY &&\n        !options.mouse.trackAll &&\n        this.hit.executeOnType(this.series, 'hit', [mouse, n]) &&\n        !_.isUndefined(n.seriesIndex))\n      {\n      series    = this.series[n.seriesIndex];\n      n.series  = series;\n      n.mouse   = series.mouse;\n      n.xaxis   = series.xaxis;\n      n.yaxis   = series.yaxis;\n    } else {\n\n      closest = this.hit.closest(mouse);\n\n      if (closest) {\n\n        closest     = options.mouse.trackY ? closest.point : closest.x;\n        seriesIndex = closest.seriesIndex;\n        series      = this.series[seriesIndex];\n        xaxis       = series.xaxis;\n        yaxis       = series.yaxis;\n        sensibility = 2 * series.mouse.sensibility;\n\n        if\n          (options.mouse.trackAll ||\n          (closest.distanceX < sensibility / xaxis.scale &&\n          (!options.mouse.trackY || closest.distanceY < sensibility / yaxis.scale)))\n        {\n          n.series      = series;\n          n.xaxis       = series.xaxis;\n          n.yaxis       = series.yaxis;\n          n.mouse       = series.mouse;\n          n.x           = closest.x;\n          n.y           = closest.y;\n          n.dist        = closest.distance;\n          n.index       = closest.dataIndex;\n          n.seriesIndex = seriesIndex;\n        }\n      }\n    }\n\n    if (!prevHit || (prevHit.index !== n.index || prevHit.seriesIndex !== n.seriesIndex)) {\n      this.hit.clearHit();\n      if (n.series && n.mouse && n.mouse.track) {\n        this.hit.drawMouseTrack(n);\n        this.hit.drawHit(n);\n        Flotr.EventAdapter.fire(this.el, 'flotr:hit', [n, this]);\n      }\n    }\n\n    return n;\n  },\n\n  closest : function (mouse) {\n\n    var\n      series    = this.series,\n      options   = this.options,\n      relX      = mouse.relX,\n      relY      = mouse.relY,\n      compare   = Number.MAX_VALUE,\n      compareX  = Number.MAX_VALUE,\n      closest   = {},\n      closestX  = {},\n      check     = false,\n      serie, data,\n      distance, distanceX, distanceY,\n      mouseX, mouseY,\n      x, y, i, j;\n\n    function setClosest (o) {\n      o.distance = distance;\n      o.distanceX = distanceX;\n      o.distanceY = distanceY;\n      o.seriesIndex = i;\n      o.dataIndex = j;\n      o.x = x;\n      o.y = y;\n      check = true;\n    }\n\n    for (i = 0; i < series.length; i++) {\n\n      serie = series[i];\n      data = serie.data;\n      mouseX = serie.xaxis.p2d(relX);\n      mouseY = serie.yaxis.p2d(relY);\n\n      for (j = data.length; j--;) {\n\n        x = data[j][0];\n        y = data[j][1];\n\n        if (x === null || y === null) continue;\n\n        // don't check if the point isn't visible in the current range\n        if (x < serie.xaxis.min || x > serie.xaxis.max) continue;\n\n        distanceX = Math.abs(x - mouseX);\n        distanceY = Math.abs(y - mouseY);\n\n        // Skip square root for speed\n        distance = distanceX * distanceX + distanceY * distanceY;\n\n        if (distance < compare) {\n          compare = distance;\n          setClosest(closest);\n        }\n\n        if (distanceX < compareX) {\n          compareX = distanceX;\n          setClosest(closestX);\n        }\n      }\n    }\n\n    return check ? {\n      point : closest,\n      x : closestX\n    } : false;\n  },\n\n  drawMouseTrack : function (n) {\n\n    var\n      pos         = '', \n      s           = n.series,\n      p           = n.mouse.position, \n      m           = n.mouse.margin,\n      x           = n.x,\n      y           = n.y,\n      elStyle     = S_MOUSETRACK,\n      mouseTrack  = this.mouseTrack,\n      plotOffset  = this.plotOffset,\n      left        = plotOffset.left,\n      right       = plotOffset.right,\n      bottom      = plotOffset.bottom,\n      top         = plotOffset.top,\n      decimals    = n.mouse.trackDecimals,\n      options     = this.options;\n\n    // Create\n    if (!mouseTrack) {\n      mouseTrack = D.node('<div class=\"flotr-mouse-value\"></div>');\n      this.mouseTrack = mouseTrack;\n      D.insert(this.el, mouseTrack);\n    }\n\n    if (!n.mouse.relative) { // absolute to the canvas\n\n      if      (p.charAt(0) == 'n') pos += 'top:' + (m + top) + 'px;bottom:auto;';\n      else if (p.charAt(0) == 's') pos += 'bottom:' + (m + bottom) + 'px;top:auto;';\n      if      (p.charAt(1) == 'e') pos += 'right:' + (m + right) + 'px;left:auto;';\n      else if (p.charAt(1) == 'w') pos += 'left:' + (m + left) + 'px;right:auto;';\n\n    // Pie\n    } else if (s.pie && s.pie.show) {\n      var center = {\n          x: (this.plotWidth)/2,\n          y: (this.plotHeight)/2\n        },\n        radius = (Math.min(this.canvasWidth, this.canvasHeight) * s.pie.sizeRatio) / 2,\n        bisection = n.sAngle<n.eAngle ? (n.sAngle + n.eAngle) / 2: (n.sAngle + n.eAngle + 2* Math.PI) / 2;\n      \n      pos += 'bottom:' + (m - top - center.y - Math.sin(bisection) * radius/2 + this.canvasHeight) + 'px;top:auto;';\n      pos += 'left:' + (m + left + center.x + Math.cos(bisection) * radius/2) + 'px;right:auto;';\n\n    // Default\n    } else {    \n      if (/n/.test(p)) pos += 'bottom:' + (m - top - n.yaxis.d2p(n.y) + this.canvasHeight) + 'px;top:auto;';\n      else             pos += 'top:' + (m + top + n.yaxis.d2p(n.y)) + 'px;bottom:auto;';\n      if (/w/.test(p)) pos += 'right:' + (m - left - n.xaxis.d2p(n.x) + this.canvasWidth) + 'px;left:auto;';\n      else             pos += 'left:' + (m + left + n.xaxis.d2p(n.x)) + 'px;right:auto;';\n    }\n\n    elStyle += pos;\n    mouseTrack.style.cssText = elStyle;\n    if (!decimals || decimals < 0) decimals = 0;\n    \n    if (x && x.toFixed) x = x.toFixed(decimals);\n\n    if (y && y.toFixed) y = y.toFixed(decimals);\n\n    mouseTrack.innerHTML = n.mouse.trackFormatter({\n      x: x ,\n      y: y, \n      series: n.series, \n      index: n.index,\n      nearest: n,\n      fraction: n.fraction\n    });\n\n    D.show(mouseTrack);\n\n    if (n.mouse.relative) {\n      if (!/[ew]/.test(p)) {\n        // Center Horizontally\n        mouseTrack.style.left =\n          (left + n.xaxis.d2p(n.x) - D.size(mouseTrack).width / 2) + 'px';\n      } else\n      if (!/[ns]/.test(p)) {\n        // Center Vertically\n        mouseTrack.style.top =\n          (top + n.yaxis.d2p(n.y) - D.size(mouseTrack).height / 2) + 'px';\n      }\n    }\n  }\n\n});\n})();\n\n/** \n * Selection Handles Plugin\n *\n *\n * Options\n *  show - True enables the handles plugin.\n *  drag - Left and Right drag handles\n *  scroll - Scrolling handle\n */\n(function () {\n\nfunction isLeftClick (e, type) {\n  return (e.which ? (e.which === 1) : (e.button === 0 || e.button === 1));\n}\n\nfunction boundX(x, graph) {\n  return Math.min(Math.max(0, x), graph.plotWidth - 1);\n}\n\nfunction boundY(y, graph) {\n  return Math.min(Math.max(0, y), graph.plotHeight);\n}\n\nvar\n  D = Flotr.DOM,\n  E = Flotr.EventAdapter,\n  _ = Flotr._;\n\n\nFlotr.addPlugin('selection', {\n\n  options: {\n    pinchOnly: null,       // Only select on pinch\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#B6D9FF',      // => selection box color\n    fps: 20                // => frames-per-second\n  },\n\n  callbacks: {\n    'flotr:mouseup' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (selection.interval) clearInterval(selection.interval);\n\n      if (this.multitouches) {\n        selection.updateSelection();\n      } else\n      if (!options.pinchOnly) {\n        selection.setSelectionPos(selection.selection.second, pointer);\n      }\n      selection.clearSelection();\n\n      if(selection.selecting && selection.selectionIsSane()){\n        selection.drawSelection();\n        selection.fireSelectEvent();\n        this.ignoreClick = true;\n      }\n    },\n    'flotr:mousedown' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (!options.mode || (!isLeftClick(event) && _.isUndefined(event.touches))) return;\n      if (!options.pinchOnly) selection.setSelectionPos(selection.selection.first, pointer);\n      if (selection.interval) clearInterval(selection.interval);\n\n      this.lastMousePos.pageX = null;\n      selection.selecting = false;\n      selection.interval = setInterval(\n        _.bind(selection.updateSelection, this),\n        1000 / options.fps\n      );\n    },\n    'flotr:destroy' : function (event) {\n      clearInterval(this.selection.interval);\n    }\n  },\n\n  // TODO This isn't used.  Maybe it belongs in the draw area and fire select event methods?\n  getArea: function() {\n\n    var\n      s = this.selection.selection,\n      a = this.axes,\n      first = s.first,\n      second = s.second,\n      x1, x2, y1, y2;\n\n    x1 = a.x.p2d(s.first.x);\n    x2 = a.x.p2d(s.second.x);\n    y1 = a.y.p2d(s.first.y);\n    y2 = a.y.p2d(s.second.y);\n\n    return {\n      x1 : Math.min(x1, x2),\n      y1 : Math.min(y1, y2),\n      x2 : Math.max(x1, x2),\n      y2 : Math.max(y1, y2),\n      xfirst : x1,\n      xsecond : x2,\n      yfirst : y1,\n      ysecond : y2\n    };\n  },\n\n  selection: {first: {x: -1, y: -1}, second: {x: -1, y: -1}},\n  prevSelection: null,\n  interval: null,\n\n  /**\n   * Fires the 'flotr:select' event when the user made a selection.\n   */\n  fireSelectEvent: function(name){\n    var\n      area = this.selection.getArea();\n    name = name || 'select';\n    area.selection = this.selection.selection;\n    E.fire(this.el, 'flotr:'+name, [area, this]);\n  },\n\n  /**\n   * Allows the user the manually select an area.\n   * @param {Object} area - Object with coordinates to select.\n   */\n  setSelection: function(area, preventEvent){\n    var options = this.options,\n      xa = this.axes.x,\n      ya = this.axes.y,\n      vertScale = ya.scale,\n      hozScale = xa.scale,\n      selX = options.selection.mode.indexOf('x') != -1,\n      selY = options.selection.mode.indexOf('y') != -1,\n      s = this.selection.selection;\n    \n    this.selection.clearSelection();\n\n    s.first.y  = boundY((selX && !selY) ? 0 : (ya.max - area.y1) * vertScale, this);\n    s.second.y = boundY((selX && !selY) ? this.plotHeight - 1: (ya.max - area.y2) * vertScale, this);\n    s.first.x  = boundX((selY && !selX) ? 0 : (area.x1 - xa.min) * hozScale, this);\n    s.second.x = boundX((selY && !selX) ? this.plotWidth : (area.x2 - xa.min) * hozScale, this);\n    \n    this.selection.drawSelection();\n    if (!preventEvent)\n      this.selection.fireSelectEvent();\n  },\n\n  /**\n   * Calculates the position of the selection.\n   * @param {Object} pos - Position object.\n   * @param {Event} event - Event object.\n   */\n  setSelectionPos: function(pos, pointer) {\n    var mode = this.options.selection.mode,\n        selection = this.selection.selection;\n\n    if(mode.indexOf('x') == -1) {\n      pos.x = (pos == selection.first) ? 0 : this.plotWidth;         \n    }else{\n      pos.x = boundX(pointer.relX, this);\n    }\n\n    if (mode.indexOf('y') == -1) {\n      pos.y = (pos == selection.first) ? 0 : this.plotHeight - 1;\n    }else{\n      pos.y = boundY(pointer.relY, this);\n    }\n  },\n  /**\n   * Draws the selection box.\n   */\n  drawSelection: function() {\n\n    this.selection.fireSelectEvent('selecting');\n\n    var s = this.selection.selection,\n      octx = this.octx,\n      options = this.options,\n      plotOffset = this.plotOffset,\n      prevSelection = this.selection.prevSelection;\n    \n    if (prevSelection &&\n      s.first.x == prevSelection.first.x &&\n      s.first.y == prevSelection.first.y && \n      s.second.x == prevSelection.second.x &&\n      s.second.y == prevSelection.second.y) {\n      return;\n    }\n\n    octx.save();\n    octx.strokeStyle = this.processColor(options.selection.color, {opacity: 0.8});\n    octx.lineWidth = 1;\n    octx.lineJoin = 'miter';\n    octx.fillStyle = this.processColor(options.selection.color, {opacity: 0.4});\n\n    this.selection.prevSelection = {\n      first: { x: s.first.x, y: s.first.y },\n      second: { x: s.second.x, y: s.second.y }\n    };\n\n    var x = Math.min(s.first.x, s.second.x),\n        y = Math.min(s.first.y, s.second.y),\n        w = Math.abs(s.second.x - s.first.x),\n        h = Math.abs(s.second.y - s.first.y);\n\n    octx.fillRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.strokeRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.restore();\n  },\n\n  /**\n   * Updates (draws) the selection box.\n   */\n  updateSelection: function(){\n    if (!this.lastMousePos.pageX) return;\n\n    this.selection.selecting = true;\n\n    if (this.multitouches) {\n      this.selection.setSelectionPos(this.selection.selection.first,  this.getEventPosition(this.multitouches[0]));\n      this.selection.setSelectionPos(this.selection.selection.second,  this.getEventPosition(this.multitouches[1]));\n    } else\n    if (this.options.selection.pinchOnly) {\n      return;\n    } else {\n      this.selection.setSelectionPos(this.selection.selection.second, this.lastMousePos);\n    }\n\n    this.selection.clearSelection();\n    \n    if(this.selection.selectionIsSane()) {\n      this.selection.drawSelection();\n    }\n  },\n\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearSelection: function() {\n    if (!this.selection.prevSelection) return;\n      \n    var prevSelection = this.selection.prevSelection,\n      lw = 1,\n      plotOffset = this.plotOffset,\n      x = Math.min(prevSelection.first.x, prevSelection.second.x),\n      y = Math.min(prevSelection.first.y, prevSelection.second.y),\n      w = Math.abs(prevSelection.second.x - prevSelection.first.x),\n      h = Math.abs(prevSelection.second.y - prevSelection.first.y);\n    \n    this.octx.clearRect(x + plotOffset.left - lw + 0.5,\n                        y + plotOffset.top - lw,\n                        w + 2 * lw + 0.5,\n                        h + 2 * lw + 0.5);\n    \n    this.selection.prevSelection = null;\n  },\n  /**\n   * Determines whether or not the selection is sane and should be drawn.\n   * @return {Boolean} - True when sane, false otherwise.\n   */\n  selectionIsSane: function(){\n    var s = this.selection.selection;\n    return Math.abs(s.second.x - s.first.x) >= 5 || \n           Math.abs(s.second.y - s.first.y) >= 5;\n  }\n\n});\n\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('labels', {\n\n  callbacks : {\n    'flotr:afterdraw' : function () {\n      this.labels.draw();\n    }\n  },\n\n  draw: function(){\n    // Construct fixed width label boxes, which can be styled easily.\n    var\n      axis, tick, left, top, xBoxWidth,\n      radius, sides, coeff, angle,\n      div, i, html = '',\n      noLabels = 0,\n      options  = this.options,\n      ctx      = this.ctx,\n      a        = this.axes,\n      style    = { size: options.fontSize };\n\n    for (i = 0; i < a.x.ticks.length; ++i){\n      if (a.x.ticks[i].label) { ++noLabels; }\n    }\n    xBoxWidth = this.plotWidth / noLabels;\n\n    if (options.grid.circular) {\n      ctx.save();\n      ctx.translate(this.plotOffset.left + this.plotWidth / 2,\n          this.plotOffset.top + this.plotHeight / 2);\n\n      radius = this.plotHeight * options.radar.radiusRatio / 2 + options.fontSize;\n      sides  = this.axes.x.ticks.length;\n      coeff  = 2 * (Math.PI / sides);\n      angle  = -Math.PI / 2;\n\n      drawLabelCircular(this, a.x, false);\n      drawLabelCircular(this, a.x, true);\n      drawLabelCircular(this, a.y, false);\n      drawLabelCircular(this, a.y, true);\n      ctx.restore();\n    }\n\n    if (!options.HtmlText && this.textEnabled) {\n      drawLabelNoHtmlText(this, a.x, 'center', 'top');\n      drawLabelNoHtmlText(this, a.x2, 'center', 'bottom');\n      drawLabelNoHtmlText(this, a.y, 'right', 'middle');\n      drawLabelNoHtmlText(this, a.y2, 'left', 'middle');\n    \n    } else if ((\n        a.x.options.showLabels ||\n        a.x2.options.showLabels ||\n        a.y.options.showLabels ||\n        a.y2.options.showLabels) &&\n        !options.grid.circular\n      ) {\n\n      html = '';\n\n      drawLabelHtml(this, a.x);\n      drawLabelHtml(this, a.x2);\n      drawLabelHtml(this, a.y);\n      drawLabelHtml(this, a.y2);\n\n      ctx.stroke();\n      ctx.restore();\n      div = D.create('div');\n      D.setStyles(div, {\n        fontSize: 'smaller',\n        color: options.grid.color\n      });\n      div.className = 'flotr-labels';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n\n    function drawLabelCircular (graph, axis, minorTicks) {\n      var\n        ticks   = minorTicks ? axis.minorTicks : axis.ticks,\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        angle        : Flotr.toRad(axis.options.labelsAngle),\n        textBaseline : 'middle'\n      };\n\n      for (i = 0; i < ticks.length &&\n          (minorTicks ? axis.options.showMinorLabels : axis.options.showLabels); ++i){\n        tick = ticks[i];\n        tick.label += '';\n        if (!tick.label || !tick.label.length) { continue; }\n\n        x = Math.cos(i * coeff + angle) * radius;\n        y = Math.sin(i * coeff + angle) * radius;\n\n        style.textAlign = isX ? (Math.abs(x) < 0.1 ? 'center' : (x < 0 ? 'right' : 'left')) : 'left';\n\n        Flotr.drawText(\n          ctx, tick.label,\n          isX ? x : 3,\n          isX ? y : -(axis.ticks[i].v / axis.max) * (radius - options.fontSize),\n          style\n        );\n      }\n    }\n\n    function drawLabelNoHtmlText (graph, axis, textAlign, textBaseline)  {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        textAlign    : textAlign,\n        textBaseline : textBaseline,\n        angle : Flotr.toRad(axis.options.labelsAngle)\n      };\n      style = Flotr.getBestTextAlign(style.angle, style);\n\n      for (i = 0; i < axis.ticks.length && continueShowingLabels(axis); ++i) {\n\n        tick = axis.ticks[i];\n        if (!tick.label || !tick.label.length) { continue; }\n\n        offset = axis.d2p(tick.v);\n        if (offset < 0 ||\n            offset > (isX ? graph.plotWidth : graph.plotHeight)) { continue; }\n\n        Flotr.drawText(\n          ctx, tick.label,\n          leftOffset(graph, isX, isFirst, offset),\n          topOffset(graph, isX, isFirst, offset),\n          style\n        );\n\n        // Only draw on axis y2\n        if (!isX && !isFirst) {\n          ctx.save();\n          ctx.strokeStyle = style.color;\n          ctx.beginPath();\n          ctx.moveTo(graph.plotOffset.left + graph.plotWidth - 8, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.lineTo(graph.plotOffset.left + graph.plotWidth, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.stroke();\n          ctx.restore();\n        }\n      }\n\n      function continueShowingLabels (axis) {\n        return axis.options.showLabels && axis.used;\n      }\n      function leftOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.left +\n          (isX ? offset :\n            (isFirst ?\n              -options.grid.labelMargin :\n              options.grid.labelMargin + graph.plotWidth));\n      }\n      function topOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.top +\n          (isX ? options.grid.labelMargin : offset) +\n          ((isX && isFirst) ? graph.plotHeight : 0);\n      }\n    }\n\n    function drawLabelHtml (graph, axis) {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        name = '',\n        left, style, top,\n        offset = graph.plotOffset;\n\n      if (!isX && !isFirst) {\n        ctx.save();\n        ctx.strokeStyle = axis.options.color || options.grid.color;\n        ctx.beginPath();\n      }\n\n      if (axis.options.showLabels && (isFirst ? true : axis.used)) {\n        for (i = 0; i < axis.ticks.length; ++i) {\n          tick = axis.ticks[i];\n          if (!tick.label || !tick.label.length ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) < 0) ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) > (isX ? graph.canvasWidth : graph.canvasHeight))) {\n            continue;\n          }\n          top = offset.top +\n            (isX ?\n              ((isFirst ? 1 : -1 ) * (graph.plotHeight + options.grid.labelMargin)) :\n              axis.d2p(tick.v) - axis.maxLabel.height / 2);\n          left = isX ? (offset.left + axis.d2p(tick.v) - xBoxWidth / 2) : 0;\n\n          name = '';\n          if (i === 0) {\n            name = ' first';\n          } else if (i === axis.ticks.length - 1) {\n            name = ' last';\n          }\n          name += isX ? ' flotr-grid-label-x' : ' flotr-grid-label-y';\n\n          html += [\n            '<div style=\"position:absolute; text-align:' + (isX ? 'center' : 'right') + '; ',\n            'top:' + top + 'px; ',\n            ((!isX && !isFirst) ? 'right:' : 'left:') + left + 'px; ',\n            'width:' + (isX ? xBoxWidth : ((isFirst ? offset.left : offset.right) - options.grid.labelMargin)) + 'px; ',\n            axis.options.color ? ('color:' + axis.options.color + '; ') : ' ',\n            '\" class=\"flotr-grid-label' + name + '\">' + tick.label + '</div>'\n          ].join(' ');\n          \n          if (!isX && !isFirst) {\n            ctx.moveTo(offset.left + graph.plotWidth - 8, offset.top + axis.d2p(tick.v));\n            ctx.lineTo(offset.left + graph.plotWidth, offset.top + axis.d2p(tick.v));\n          }\n        }\n      }\n    }\n  }\n\n});\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('legend', {\n  options: {\n    show: true,            // => setting to true will show the legend, hide otherwise\n    noColumns: 1,          // => number of colums in legend table // @todo: doesn't work for HtmlText = false\n    labelFormatter: function(v){return v;}, // => fn: string -> string\n    labelBoxBorderColor: '#CCCCCC', // => border color for the little label boxes\n    labelBoxWidth: 14,\n    labelBoxHeight: 10,\n    labelBoxMargin: 5,\n    container: null,       // => container (as jQuery object) to put legend in, null means default on top of graph\n    position: 'nw',        // => position of default legend container within plot\n    margin: 5,             // => distance from grid edge to default legend container within plot\n    backgroundColor: '#F0F0F0', // => Legend background color.\n    backgroundOpacity: 0.85// => set to 0 to avoid background, set to 1 for a solid background\n  },\n  callbacks: {\n    'flotr:afterinit': function() {\n      this.legend.insertLegend();\n    }\n  },\n  /**\n   * Adds a legend div to the canvas container or draws it on the canvas.\n   */\n  insertLegend: function(){\n\n    if(!this.options.legend.show)\n      return;\n\n    var series      = this.series,\n      plotOffset    = this.plotOffset,\n      options       = this.options,\n      legend        = options.legend,\n      fragments     = [],\n      rowStarted    = false, \n      ctx           = this.ctx,\n      itemCount     = _.filter(series, function(s) {return (s.label && !s.hide);}).length,\n      p             = legend.position, \n      m             = legend.margin,\n      opacity       = legend.backgroundOpacity,\n      i, label, color;\n\n    if (itemCount) {\n\n      var lbw = legend.labelBoxWidth,\n          lbh = legend.labelBoxHeight,\n          lbm = legend.labelBoxMargin,\n          offsetX = plotOffset.left + m,\n          offsetY = plotOffset.top + m,\n          labelMaxWidth = 0,\n          style = {\n            size: options.fontSize*1.1,\n            color: options.grid.color\n          };\n\n      // We calculate the labels' max width\n      for(i = series.length - 1; i > -1; --i){\n        if(!series[i].label || series[i].hide) continue;\n        label = legend.labelFormatter(series[i].label);\n        labelMaxWidth = Math.max(labelMaxWidth, this._text.measureText(label, style).width);\n      }\n\n      var legendWidth  = Math.round(lbw + lbm*3 + labelMaxWidth),\n          legendHeight = Math.round(itemCount*(lbm+lbh) + lbm);\n\n      // Default Opacity\n      if (!opacity && opacity !== 0) {\n        opacity = 0.1;\n      }\n\n      if (!options.HtmlText && this.textEnabled && !legend.container) {\n        \n        if(p.charAt(0) == 's') offsetY = plotOffset.top + this.plotHeight - (m + legendHeight);\n        if(p.charAt(0) == 'c') offsetY = plotOffset.top + (this.plotHeight/2) - (m + (legendHeight/2));\n        if(p.charAt(1) == 'e') offsetX = plotOffset.left + this.plotWidth - (m + legendWidth);\n        \n        // Legend box\n        color = this.processColor(legend.backgroundColor, { opacity : opacity });\n\n        ctx.fillStyle = color;\n        ctx.fillRect(offsetX, offsetY, legendWidth, legendHeight);\n        ctx.strokeStyle = legend.labelBoxBorderColor;\n        ctx.strokeRect(Flotr.toPixel(offsetX), Flotr.toPixel(offsetY), legendWidth, legendHeight);\n        \n        // Legend labels\n        var x = offsetX + lbm;\n        var y = offsetY + lbm;\n        for(i = 0; i < series.length; i++){\n          if(!series[i].label || series[i].hide) continue;\n          label = legend.labelFormatter(series[i].label);\n          \n          ctx.fillStyle = series[i].color;\n          ctx.fillRect(x, y, lbw-1, lbh-1);\n          \n          ctx.strokeStyle = legend.labelBoxBorderColor;\n          ctx.lineWidth = 1;\n          ctx.strokeRect(Math.ceil(x)-1.5, Math.ceil(y)-1.5, lbw+2, lbh+2);\n          \n          // Legend text\n          Flotr.drawText(ctx, label, x + lbw + lbm, y + lbh, style);\n          \n          y += lbh + lbm;\n        }\n      }\n      else {\n        for(i = 0; i < series.length; ++i){\n          if(!series[i].label || series[i].hide) continue;\n          \n          if(i % legend.noColumns === 0){\n            fragments.push(rowStarted ? '</tr><tr>' : '<tr>');\n            rowStarted = true;\n          }\n\n          var s = series[i],\n            boxWidth = legend.labelBoxWidth,\n            boxHeight = legend.labelBoxHeight;\n\n          label = legend.labelFormatter(s.label);\n          color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';\n          \n          fragments.push(\n            '<td class=\"flotr-legend-color-box\">',\n              '<div style=\"border:1px solid ', legend.labelBoxBorderColor, ';padding:1px\">',\n                '<div style=\"width:', (boxWidth-1), 'px;height:', (boxHeight-1), 'px;border:1px solid ', series[i].color, '\">', // Border\n                  '<div style=\"width:', boxWidth, 'px;height:', boxHeight, 'px;', color, '\"></div>', // Background\n                '</div>',\n              '</div>',\n            '</td>',\n            '<td class=\"flotr-legend-label\">', label, '</td>'\n          );\n        }\n        if(rowStarted) fragments.push('</tr>');\n          \n        if(fragments.length > 0){\n          var table = '<table style=\"font-size:smaller;color:' + options.grid.color + '\">' + fragments.join('') + '</table>';\n          if(legend.container){\n            D.empty(legend.container);\n            D.insert(legend.container, table);\n          }\n          else {\n            var styles = {position: 'absolute', 'zIndex': '2', 'border' : '1px solid ' + legend.labelBoxBorderColor};\n\n                 if(p.charAt(0) == 'n') { styles.top = (m + plotOffset.top) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 'c') { styles.top = (m + (this.plotHeight - legendHeight) / 2) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 's') { styles.bottom = (m + plotOffset.bottom) + 'px'; styles.top = 'auto'; }\n                 if(p.charAt(1) == 'e') { styles.right = (m + plotOffset.right) + 'px'; styles.left = 'auto'; }\n            else if(p.charAt(1) == 'w') { styles.left = (m + plotOffset.left) + 'px'; styles.right = 'auto'; }\n\n            var div = D.create('div'), size;\n            div.className = 'flotr-legend';\n            D.setStyles(div, styles);\n            D.insert(div, table);\n            D.insert(this.el, div);\n            \n            if (!opacity) return;\n\n            var c = legend.backgroundColor || options.grid.backgroundColor || '#ffffff';\n\n            _.extend(styles, D.size(div), {\n              'backgroundColor': c,\n              'zIndex' : '',\n              'border' : ''\n            });\n            styles.width += 'px';\n            styles.height += 'px';\n\n             // Put in the transparent background separately to avoid blended labels and\n            div = D.create('div');\n            div.className = 'flotr-legend-bg';\n            D.setStyles(div, styles);\n            D.opacity(div, opacity);\n            D.insert(div, ' ');\n            D.insert(this.el, div);\n          }\n        }\n      }\n    }\n  }\n});\n})();\n\n/** Spreadsheet **/\n(function() {\n\nfunction getRowLabel(value){\n  if (this.options.spreadsheet.tickFormatter){\n    //TODO maybe pass the xaxis formatter to the custom tick formatter as an opt-out?\n    return this.options.spreadsheet.tickFormatter(value);\n  }\n  else {\n    var t = _.find(this.axes.x.ticks, function(t){return t.v == value;});\n    if (t) {\n      return t.label;\n    }\n    return value;\n  }\n}\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('spreadsheet', {\n  options: {\n    show: false,           // => show the data grid using two tabs\n    tabGraphLabel: 'Graph',\n    tabDataLabel: 'Data',\n    toolbarDownload: 'Download CSV', // @todo: add better language support\n    toolbarSelectAll: 'Select all',\n    csvFileSeparator: ',',\n    decimalSeparator: '.',\n    tickFormatter: null,\n    initialTab: 'graph'\n  },\n  /**\n   * Builds the tabs in the DOM\n   */\n  callbacks: {\n    'flotr:afterconstruct': function(){\n      // @TODO necessary?\n      //this.el.select('.flotr-tabs-group,.flotr-datagrid-container').invoke('remove');\n      \n      if (!this.options.spreadsheet.show) return;\n      \n      var ss = this.spreadsheet,\n        container = D.node('<div class=\"flotr-tabs-group\" style=\"position:absolute;left:0px;width:'+this.canvasWidth+'px\"></div>'),\n        graph = D.node('<div style=\"float:left\" class=\"flotr-tab selected\">'+this.options.spreadsheet.tabGraphLabel+'</div>'),\n        data = D.node('<div style=\"float:left\" class=\"flotr-tab\">'+this.options.spreadsheet.tabDataLabel+'</div>'),\n        offset;\n\n      ss.tabsContainer = container;\n      ss.tabs = { graph : graph, data : data };\n\n      D.insert(container, graph);\n      D.insert(container, data);\n      D.insert(this.el, container);\n\n      offset = D.size(data).height + 2;\n      this.plotOffset.bottom += offset;\n\n      D.setStyles(container, {top: this.canvasHeight-offset+'px'});\n\n      this.\n        observe(graph, 'click',  function(){ss.showTab('graph');}).\n        observe(data, 'click', function(){ss.showTab('data');});\n      if (this.options.spreadsheet.initialTab !== 'graph'){\n        ss.showTab(this.options.spreadsheet.initialTab);\n      }\n    }\n  },\n  /**\n   * Builds a matrix of the data to make the correspondance between the x values and the y values :\n   * X value => Y values from the axes\n   * @return {Array} The data grid\n   */\n  loadDataGrid: function(){\n    if (this.seriesData) return this.seriesData;\n\n    var s = this.series,\n        rows = {};\n\n    /* The data grid is a 2 dimensions array. There is a row for each X value.\n     * Each row contains the x value and the corresponding y value for each serie ('undefined' if there isn't one)\n    **/\n    _.each(s, function(serie, i){\n      _.each(serie.data, function (v) {\n        var x = v[0],\n            y = v[1],\n            r = rows[x];\n        if (r) {\n          r[i+1] = y;\n        } else {\n          var newRow = [];\n          newRow[0] = x;\n          newRow[i+1] = y;\n          rows[x] = newRow;\n        }\n      });\n    });\n\n    // The data grid is sorted by x value\n    this.seriesData = _.sortBy(rows, function(row, x){\n      return parseInt(x, 10);\n    });\n    return this.seriesData;\n  },\n  /**\n   * Constructs the data table for the spreadsheet\n   * @todo make a spreadsheet manager (Flotr.Spreadsheet)\n   * @return {Element} The resulting table element\n   */\n  constructDataGrid: function(){\n    // If the data grid has already been built, nothing to do here\n    if (this.spreadsheet.datagrid) return this.spreadsheet.datagrid;\n    \n    var s = this.series,\n        datagrid = this.spreadsheet.loadDataGrid(),\n        colgroup = ['<colgroup><col />'],\n        buttonDownload, buttonSelect, t;\n    \n    // First row : series' labels\n    var html = ['<table class=\"flotr-datagrid\"><tr class=\"first-row\">'];\n    html.push('<th>&nbsp;</th>');\n    _.each(s, function(serie,i){\n      html.push('<th scope=\"col\">'+(serie.label || String.fromCharCode(65+i))+'</th>');\n      colgroup.push('<col />');\n    });\n    html.push('</tr>');\n    // Data rows\n    _.each(datagrid, function(row){\n      html.push('<tr>');\n      _.times(s.length+1, function(i){\n        var tag = 'td',\n            value = row[i],\n            // TODO: do we really want to handle problems with floating point\n            // precision here?\n            content = (!_.isUndefined(value) ? Math.round(value*100000)/100000 : '');\n        if (i === 0) {\n          tag = 'th';\n          var label = getRowLabel.call(this, content);\n          if (label) content = label;\n        }\n\n        html.push('<'+tag+(tag=='th'?' scope=\"row\"':'')+'>'+content+'</'+tag+'>');\n      }, this);\n      html.push('</tr>');\n    }, this);\n    colgroup.push('</colgroup>');\n    t = D.node(html.join(''));\n\n    /**\n     * @TODO disabled this\n    if (!Flotr.isIE || Flotr.isIE == 9) {\n      function handleMouseout(){\n        t.select('colgroup col.hover, th.hover').invoke('removeClassName', 'hover');\n      }\n      function handleMouseover(e){\n        var td = e.element(),\n          siblings = td.previousSiblings();\n        t.select('th[scope=col]')[siblings.length-1].addClassName('hover');\n        t.select('colgroup col')[siblings.length].addClassName('hover');\n      }\n      _.each(t.select('td'), function(td) {\n        Flotr.EventAdapter.\n          observe(td, 'mouseover', handleMouseover).\n          observe(td, 'mouseout', handleMouseout);\n      });\n    }\n    */\n\n    buttonDownload = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarDownload +\n      '</button>');\n\n    buttonSelect = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarSelectAll+\n      '</button>');\n\n    this.\n      observe(buttonDownload, 'click', _.bind(this.spreadsheet.downloadCSV, this)).\n      observe(buttonSelect, 'click', _.bind(this.spreadsheet.selectAllData, this));\n\n    var toolbar = D.node('<div class=\"flotr-datagrid-toolbar\"></div>');\n    D.insert(toolbar, buttonDownload);\n    D.insert(toolbar, buttonSelect);\n\n    var containerHeight =this.canvasHeight - D.size(this.spreadsheet.tabsContainer).height-2,\n        container = D.node('<div class=\"flotr-datagrid-container\" style=\"position:absolute;left:0px;top:0px;width:'+\n          this.canvasWidth+'px;height:'+containerHeight+'px;overflow:auto;z-index:10\"></div>');\n\n    D.insert(container, toolbar);\n    D.insert(container, t);\n    D.insert(this.el, container);\n    this.spreadsheet.datagrid = t;\n    this.spreadsheet.container = container;\n\n    return t;\n  },  \n  /**\n   * Shows the specified tab, by its name\n   * @todo make a tab manager (Flotr.Tabs)\n   * @param {String} tabName - The tab name\n   */\n  showTab: function(tabName){\n    if (this.spreadsheet.activeTab === tabName){\n      return;\n    }\n    switch(tabName) {\n      case 'graph':\n        D.hide(this.spreadsheet.container);\n        D.removeClass(this.spreadsheet.tabs.data, 'selected');\n        D.addClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      case 'data':\n        if (!this.spreadsheet.datagrid)\n          this.spreadsheet.constructDataGrid();\n        D.show(this.spreadsheet.container);\n        D.addClass(this.spreadsheet.tabs.data, 'selected');\n        D.removeClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      default:\n        throw 'Illegal tab name: ' + tabName;\n    }\n    this.spreadsheet.activeTab = tabName;\n  },\n  /**\n   * Selects the data table in the DOM for copy/paste\n   */\n  selectAllData: function(){\n    if (this.spreadsheet.tabs) {\n      var selection, range, doc, win, node = this.spreadsheet.constructDataGrid();\n\n      this.spreadsheet.showTab('data');\n      \n      // deferred to be able to select the table\n      setTimeout(function () {\n        if ((doc = node.ownerDocument) && (win = doc.defaultView) && \n            win.getSelection && doc.createRange && \n            (selection = window.getSelection()) && \n            selection.removeAllRanges) {\n            range = doc.createRange();\n            range.selectNode(node);\n            selection.removeAllRanges();\n            selection.addRange(range);\n        }\n        else if (document.body && document.body.createTextRange && \n                (range = document.body.createTextRange())) {\n            range.moveToElementText(node);\n            range.select();\n        }\n      }, 0);\n      return true;\n    }\n    else return false;\n  },\n  /**\n   * Converts the data into CSV in order to download a file\n   */\n  downloadCSV: function(){\n    var csv = '',\n        series = this.series,\n        options = this.options,\n        dg = this.spreadsheet.loadDataGrid(),\n        separator = encodeURIComponent(options.spreadsheet.csvFileSeparator);\n    \n    if (options.spreadsheet.decimalSeparator === options.spreadsheet.csvFileSeparator) {\n      throw \"The decimal separator is the same as the column separator (\"+options.spreadsheet.decimalSeparator+\")\";\n    }\n    \n    // The first row\n    _.each(series, function(serie, i){\n      csv += separator+'\"'+(serie.label || String.fromCharCode(65+i)).replace(/\\\"/g, '\\\\\"')+'\"';\n    });\n\n    csv += \"%0D%0A\"; // \\r\\n\n    \n    // For each row\n    csv += _.reduce(dg, function(memo, row){\n      var rowLabel = getRowLabel.call(this, row[0]) || '';\n      rowLabel = '\"'+(rowLabel+'').replace(/\\\"/g, '\\\\\"')+'\"';\n      var numbers = row.slice(1).join(separator);\n      if (options.spreadsheet.decimalSeparator !== '.') {\n        numbers = numbers.replace(/\\./g, options.spreadsheet.decimalSeparator);\n      }\n      return memo + rowLabel+separator+numbers+\"%0D%0A\"; // \\t and \\r\\n\n    }, '', this);\n\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      csv = csv.replace(new RegExp(separator, 'g'), decodeURIComponent(separator)).replace(/%0A/g, '\\n').replace(/%0D/g, '\\r');\n      window.open().document.write(csv);\n    }\n    else window.open('data:text/csv,'+csv);\n  }\n});\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('titles', {\n  callbacks: {\n    'flotr:afterdraw': function() {\n      this.titles.drawTitles();\n    }\n  },\n  /**\n   * Draws the title and the subtitle\n   */\n  drawTitles : function () {\n    var html,\n        options = this.options,\n        margin = options.grid.labelMargin,\n        ctx = this.ctx,\n        a = this.axes;\n    \n    if (!options.HtmlText && this.textEnabled) {\n      var style = {\n        size: options.fontSize,\n        color: options.grid.color,\n        textAlign: 'center'\n      };\n      \n      // Add subtitle\n      if (options.subtitle){\n        Flotr.drawText(\n          ctx, options.subtitle,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight + this.subtitleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.5;\n      style.size *= 1.5;\n      \n      // Add title\n      if (options.title){\n        Flotr.drawText(\n          ctx, options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.8;\n      style.size *= 0.8;\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used){\n        style.textAlign = a.x.options.titleAlign || 'center';\n        style.textBaseline = 'top';\n        style.angle = Flotr.toRad(a.x.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top + a.x.maxLabel.height + this.plotHeight + 2 * margin,\n          style\n        );\n      }\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used){\n        style.textAlign = a.x2.options.titleAlign || 'center';\n        style.textBaseline = 'bottom';\n        style.angle = Flotr.toRad(a.x2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x2.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top - a.x2.maxLabel.height - 2 * margin,\n          style\n        );\n      }\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used){\n        style.textAlign = a.y.options.titleAlign || 'right';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y.options.title,\n          this.plotOffset.left - a.y.maxLabel.width - 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used){\n        style.textAlign = a.y2.options.titleAlign || 'left';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y2.options.title,\n          this.plotOffset.left + this.plotWidth + a.y2.maxLabel.width + 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n    } \n    else {\n      html = [];\n      \n      // Add title\n      if (options.title)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', \n          this.plotOffset.left, 'px;font-size:1em;font-weight:bold;text-align:center;width:',\n          this.plotWidth,'px;\" class=\"flotr-title\">', options.title, '</div>'\n        );\n      \n      // Add subtitle\n      if (options.subtitle)\n        html.push(\n          '<div style=\"position:absolute;top:', this.titleHeight, 'px;left:', \n          this.plotOffset.left, 'px;font-size:smaller;text-align:center;width:',\n          this.plotWidth, 'px;\" class=\"flotr-subtitle\">', options.subtitle, '</div>'\n        );\n\n      html.push('</div>');\n      \n      html.push('<div class=\"flotr-axis-title\" style=\"font-weight:bold;\">');\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight + options.grid.labelMargin + a.x.titleSize.height), \n          'px;left:', this.plotOffset.left, 'px;width:', this.plotWidth, \n          'px;text-align:', a.x.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x1\">', a.x.options.title, '</div>'\n        );\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', this.plotOffset.left, 'px;width:', \n          this.plotWidth, 'px;text-align:', a.x2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x2\">', a.x2.options.title, '</div>'\n        );\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;left:0;text-align:', a.y.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y1\">', a.y.options.title, '</div>'\n        );\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;right:0;text-align:', a.y2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y2\">', a.y2.options.title, '</div>'\n        );\n      \n      html = html.join('');\n\n      var div = D.create('div');\n      D.setStyles({\n        color: options.grid.color \n      });\n      div.className = 'flotr-titles';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n  }\n});\n})();\n\n  return Flotr;\n\n}));"
  },
  {
    "path": "html/lib/flotr2/flotr2.examples.types.js",
    "content": "(function () {\n\nvar ExampleList = function () {\n\n  // Map of examples.\n  this.examples = {};\n\n};\n\nExampleList.prototype = {\n\n  add : function (example) {\n    this.examples[example.key] = example;\n  },\n\n  get : function (key) {\n    return key ? (this.examples[key] || null) : this.examples;\n  },\n\n  getType : function (type) {\n    return Flotr._.select(this.examples, function (example) {\n      return (example.type === type);\n    });\n  }\n}\n\nFlotr.ExampleList = new ExampleList();\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic',\n  name : 'Basic',\n  callback : basic\n});\n\nfunction basic (container) {\n\n  var\n    d1 = [[0, 3], [4, 8], [8, 5], [9, 13]], // First data series\n    d2 = [],                                // Second data series\n    i, graph;\n\n  // Generate first data set\n  for (i = 0; i < 14; i += 0.5) {\n    d2.push([i, Math.sin(i)]);\n  }\n\n  // Draw Graph\n  graph = Flotr.draw(container, [ d1, d2 ], {\n    xaxis: {\n      minorTickFreq: 4\n    }, \n    grid: {\n      minorVerticalLines: true\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-stacked',\n  name : 'Basic Stacked',\n  callback : basic_stacked,\n  type : 'test'\n});\n\nfunction basic_stacked (container) {\n\n  var\n    d1 = [[0, 3], [4, 8], [8, 2], [9, 3]], // First data series\n    d2 = [[0, 2], [4, 3], [8, 8], [9, 4]], // Second data series\n    i, graph;\n\n  // Draw Graph\n  graph = Flotr.draw(container, [ d1, d2 ], {\n    lines: {\n      show : true,\n      stacked: true\n    },\n    xaxis: {\n      minorTickFreq: 4\n    }, \n    grid: {\n      minorVerticalLines: true\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-stepped',\n  name : 'Basic Stepped',\n  callback : basic_stepped,\n  type : 'test'\n});\n\nfunction basic_stepped (container) {\n\n  var\n    d1 = [[0, 3], [4, 8], [8, 5], [9, 13]], // First data series\n    d2 = [],                                // Second data series\n    i, graph;\n\n  // Generate first data set\n  for (i = 0; i < 14; i += 0.5) {\n    d2.push([i, Math.sin(i)]);\n  }\n\n  // Draw Graph\n  graph = Flotr.draw(container, [ d1, d2 ], {\n    lines: {\n      steps : true,\n      show : true\n    },\n    xaxis: {\n      minorTickFreq: 4\n    }, \n    yaxis: {\n      autoscale: true\n    },\n    grid: {\n      minorVerticalLines: true\n    },\n    mouse : {\n      track : true,\n      relative : true\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-axis',\n  name : 'Basic Axis',\n  callback : basic_axis\n});\n\nfunction basic_axis (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    d4 = [],\n    d5 = [],                        // Data\n    ticks = [[ 0, \"Lower\"], 10, 20, 30, [40, \"Upper\"]], // Ticks for the Y-Axis\n    graph;\n        \n  for(var i = 0; i <= 10; i += 0.1){\n    d1.push([i, 4 + Math.pow(i,1.5)]);\n    d2.push([i, Math.pow(i,3)]);\n    d3.push([i, i*5+3*Math.sin(i*4)]);\n    d4.push([i, i]);\n    if( i.toFixed(1)%1 == 0 ){\n      d5.push([i, 2*i]);\n    }\n  }\n        \n  d3[30][1] = null;\n  d3[31][1] = null;\n\n  function ticksFn (n) { return '('+n+')'; }\n\n  graph = Flotr.draw(container, [ \n      { data : d1, label : 'y = 4 + x^(1.5)', lines : { fill : true } }, \n      { data : d2, label : 'y = x^3'}, \n      { data : d3, label : 'y = 5x + 3sin(4x)'}, \n      { data : d4, label : 'y = x'},\n      { data : d5, label : 'y = 2x', lines : { show : true }, points : { show : true } }\n    ], {\n      xaxis : {\n        noTicks : 7,              // Display 7 ticks.\n        tickFormatter : ticksFn,  // Displays tick values between brackets.\n        min : 1,                  // Part of the series is not displayed.\n        max : 7.5                 // Part of the series is not displayed.\n      },\n      yaxis : {\n        ticks : ticks,            // Set Y-Axis ticks\n        max : 40                  // Maximum value along Y-Axis\n      },\n      grid : {\n        verticalLines : false,\n        backgroundColor : {\n          colors : [[0,'#fff'], [1,'#ccc']],\n          start : 'top',\n          end : 'bottom'\n        }\n      },\n      legend : {\n        position : 'nw'\n      },\n      title : 'Basic Axis example',\n      subtitle : 'This is a subtitle'\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-bars',\n  name : 'Basic Bars',\n  callback : basic_bars\n});\n\nFlotr.ExampleList.add({\n  key : 'basic-bars-horizontal',\n  name : 'Horizontal Bars',\n  args : [true],\n  callback : basic_bars,\n  tolerance : 5\n});\n\nfunction basic_bars (container, horizontal) {\n\n  var\n    horizontal = (horizontal ? true : false), // Show horizontal bars\n    d1 = [],                                  // First data series\n    d2 = [],                                  // Second data series\n    point,                                    // Data point variable declaration\n    i;\n\n  for (i = 0; i < 4; i++) {\n\n    if (horizontal) { \n      point = [Math.ceil(Math.random()*10), i];\n    } else {\n      point = [i, Math.ceil(Math.random()*10)];\n    }\n\n    d1.push(point);\n        \n    if (horizontal) { \n      point = [Math.ceil(Math.random()*10), i+0.5];\n    } else {\n      point = [i+0.5, Math.ceil(Math.random()*10)];\n    }\n\n    d2.push(point);\n  };\n              \n  // Draw the graph\n  Flotr.draw(\n    container,\n    [d1, d2],\n    {\n      bars : {\n        show : true,\n        horizontal : horizontal,\n        shadowSize : 0,\n        barWidth : 0.5\n      },\n      mouse : {\n        track : true,\n        relative : true\n      },\n      yaxis : {\n        min : 0,\n        autoscaleMargin : 1\n      }\n    }\n  );\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-bar-stacked',\n  name : 'Stacked Bars',\n  callback : bars_stacked\n});\n\nFlotr.ExampleList.add({\n  key : 'basic-stacked-horizontal',\n  name : 'Stacked Horizontal Bars',\n  args : [true],\n  callback : bars_stacked,\n  tolerance : 5\n});\n\nfunction bars_stacked (container, horizontal) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    graph, i;\n\n  for (i = -10; i < 10; i++) {\n    if (horizontal) {\n      d1.push([Math.random(), i]);\n      d2.push([Math.random(), i]);\n      d3.push([Math.random(), i]);\n    } else {\n      d1.push([i, Math.random()]);\n      d2.push([i, Math.random()]);\n      d3.push([i, Math.random()]);\n    }\n  }\n\n  graph = Flotr.draw(container,[\n    { data : d1, label : 'Serie 1' },\n    { data : d2, label : 'Serie 2' },\n    { data : d3, label : 'Serie 3' }\n  ], {\n    legend : {\n      backgroundColor : '#D2E8FF' // Light blue \n    },\n    bars : {\n      show : true,\n      stacked : true,\n      horizontal : horizontal,\n      barWidth : 0.6,\n      lineWidth : 1,\n      shadowSize : 0\n    },\n    grid : {\n      verticalLines : horizontal,\n      horizontalLines : !horizontal\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-pie',\n  name : 'Basic Pie',\n  callback : basic_pie\n});\n\nfunction basic_pie (container) {\n\n  var\n    d1 = [[0, 4]],\n    d2 = [[0, 3]],\n    d3 = [[0, 1.03]],\n    d4 = [[0, 3.5]],\n    graph;\n  \n  graph = Flotr.draw(container, [\n    { data : d1, label : 'Comedy' },\n    { data : d2, label : 'Action' },\n    { data : d3, label : 'Romance',\n      pie : {\n        explode : 50\n      }\n    },\n    { data : d4, label : 'Drama' }\n  ], {\n    HtmlText : false,\n    grid : {\n      verticalLines : false,\n      horizontalLines : false\n    },\n    xaxis : { showLabels : false },\n    yaxis : { showLabels : false },\n    pie : {\n      show : true, \n      explode : 6\n    },\n    mouse : { track : true },\n    legend : {\n      position : 'se',\n      backgroundColor : '#D2E8FF'\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-radar',\n  name : 'Basic Radar',\n  callback : basic_radar\n});\n\nfunction basic_radar (container) {\n\n  // Fill series s1 and s2.\n  var\n    s1 = { label : 'Actual', data : [[0, 3], [1, 8], [2, 5], [3, 5], [4, 3], [5, 9]] },\n    s2 = { label : 'Target', data : [[0, 8], [1, 7], [2, 8], [3, 2], [4, 4], [5, 7]] },\n    graph, ticks;\n\n  // Radar Labels\n  ticks = [\n    [0, \"Statutory\"],\n    [1, \"External\"],\n    [2, \"Videos\"],\n    [3, \"Yippy\"],\n    [4, \"Management\"],\n    [5, \"oops\"]\n  ];\n    \n  // Draw the graph.\n  graph = Flotr.draw(container, [ s1, s2 ], {\n    radar : { show : true}, \n    grid  : { circular : true, minorHorizontalLines : true}, \n    yaxis : { min : 0, max : 10, minorTickFreq : 2}, \n    xaxis : { ticks : ticks},\n    mouse : { track : true}\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-bubble',\n  name : 'Basic Bubble',\n  callback : basic_bubble\n});\n\nfunction basic_bubble (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    point, graph, i;\n      \n  for (i = 0; i < 10; i++ ){\n    point = [i, Math.ceil(Math.random()*10), Math.ceil(Math.random()*10)];\n    d1.push(point);\n    \n    point = [i, Math.ceil(Math.random()*10), Math.ceil(Math.random()*10)];\n    d2.push(point);\n  }\n  \n  // Draw the graph\n  graph = Flotr.draw(container, [d1, d2], {\n    bubbles : { show : true, baseRadius : 5 },\n    xaxis   : { min : -4, max : 14 },\n    yaxis   : { min : -4, max : 14 }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-candle',\n  name : 'Basic Candle',\n  callback : basic_candle\n});\n\nfunction basic_candle (container) {\n\n  var\n    d1 = [],\n    price = 3.206,\n    graph,\n    i, a, b, c;\n\n  for (i = 0; i < 50; i++) {\n      a = Math.random();\n      b = Math.random();\n      c = (Math.random() * (a + b)) - b;\n      d1.push([i, price, price + a, price - b, price + c]);\n      price = price + c;\n  }\n    \n  // Graph\n  graph = Flotr.draw(container, [ d1 ], { \n    candles : { show : true, candleWidth : 0.6 },\n    xaxis   : { noTicks : 10 }\n  });\n}\n\n})();\n\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-candle-barchart',\n  name : 'Basic Candle Barchart',\n  callback : basic_candle\n});\n\nfunction basic_candle (container) {\n\n  var\n    d1 = [],\n    price = 3.206,\n    graph,\n    i, a, b, c;\n\n  for (i = 0; i < 50; i++) {\n      a = Math.random();\n      b = Math.random();\n      c = (Math.random() * (a + b)) - b;\n      d1.push([i, price, price + a, price - b, price + c]);\n      price = price + c;\n  }\n    \n  // Graph\n  graph = Flotr.draw(container, [ d1 ], { \n    candles : { \n      show : true, \n      candleWidth : 0.6, \n      barcharts: true, \n      upFillColor: '#00A048', \n      downFillColor: '#CB2020' \n    },\n    xaxis   : { noTicks : 10 }\n  });\n}\n\n})();\n\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-legend',\n  name : 'Basic Legend',\n  callback : basic_legend\n});\n\nfunction basic_legend (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    data,\n    graph, i;\n\n  // Data Generation\n  for (i = 0; i < 15; i += 0.5) {\n    d1.push([i, i + Math.sin(i+Math.PI)]);\n    d2.push([i, i]);\n    d3.push([i, 15-Math.cos(i)]);\n  }\n\n  data = [\n    { data : d1, label :'x + sin(x+&pi;)' },\n    { data : d2, label :'x' },\n    { data : d3, label :'15 - cos(x)' }\n  ];\n\n\n  // This function prepend each label with 'y = '\n  function labelFn (label) {\n    return 'y = ' + label;\n  }\n\n  // Draw graph\n  graph = Flotr.draw(container, data, {\n    legend : {\n      position : 'se',            // Position the legend 'south-east'.\n      labelFormatter : labelFn,   // Format the labels.\n      backgroundColor : '#D2E8FF' // A light blue background color.\n    },\n    HtmlText : false\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'mouse-tracking',\n  name : 'Mouse Tracking',\n  callback : mouse_tracking\n});\n\nfunction mouse_tracking (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    graph, i;\n\n  for (i = 0; i < 20; i += 0.5) {\n    d1.push([i, 2*i]);\n    d2.push([i, i*1.5+1.5*Math.sin(i)]);\n    d3.push([i, 3*Math.cos(i)+10]);\n  }\n\n  graph = Flotr.draw(\n    container, \n    [\n      {\n        data : d1,\n        mouse : { track : false } // Disable mouse tracking for d1\n      },\n      d2,\n      d3\n    ],\n    {\n      mouse : {\n        track           : true, // Enable mouse tracking\n        lineColor       : 'purple',\n        relative        : true,\n        position        : 'ne',\n        sensibility     : 1,\n        trackDecimals   : 2,\n        trackFormatter  : function (o) { return 'x = ' + o.x +', y = ' + o.y; }\n      },\n      crosshair : {\n        mode : 'xy'\n      }\n    }\n  );\n\n};      \n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'mouse-zoom',\n  name : 'Mouse Zoom',\n  callback : mouse_zoom,\n  description : \"<p>Select an area of the graph to zoom.  Click to reset the chart.</p>\"\n});\n\nfunction mouse_zoom (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    options,\n    graph,\n    i;\n\n  for (i = 0; i < 40; i += 0.5) {\n    d1.push([i, Math.sin(i)+3*Math.cos(i)]);\n    d2.push([i, Math.pow(1.1, i)]);\n    d3.push([i, 40 - i+Math.random()*10]);\n  }\n      \n  options = {\n    selection : { mode : 'x', fps : 30 },\n    title : 'Mouse Zoom'\n  };\n    \n  // Draw graph with default options, overwriting with passed options\n  function drawGraph (opts) {\n\n    // Clone the options, so the 'options' variable always keeps intact.\n    var o = Flotr._.extend(Flotr._.clone(options), opts || {});\n\n    // Return a new graph.\n    return Flotr.draw(\n      container,\n      [ d1, d2, d3 ],\n      o\n    );\n  }\n\n  // Actually draw the graph.\n  graph = drawGraph();      \n    \n  // Hook into the 'flotr:select' event.\n  Flotr.EventAdapter.observe(container, 'flotr:select', function (area) {\n\n    // Draw graph with new area\n    graph = drawGraph({\n      xaxis: {min:area.x1, max:area.x2},\n      yaxis: {min:area.y1, max:area.y2}\n    });\n  });\n    \n  // When graph is clicked, draw the graph with default area.\n  Flotr.EventAdapter.observe(container, 'flotr:click', function () { drawGraph(); });\n};\n\n})();\n\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'mouse-drag',\n  name : 'Mouse Drag',\n  callback : mouse_drag\n});\n\nfunction mouse_drag (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    options,\n    graph,\n    start,\n    i;\n\n  for (i = -40; i < 40; i += 0.5) {\n    d1.push([i, Math.sin(i)+3*Math.cos(i)]);\n    d2.push([i, Math.pow(1.1, i)]);\n    d3.push([i, 40 - i+Math.random()*10]);\n  }\n      \n  options = {\n    xaxis: {min: 0, max: 20},\n      title : 'Mouse Drag'\n  };\n\n  // Draw graph with default options, overwriting with passed options\n  function drawGraph (opts) {\n\n    // Clone the options, so the 'options' variable always keeps intact.\n    var o = Flotr._.extend(Flotr._.clone(options), opts || {});\n\n    // Return a new graph.\n    return Flotr.draw(\n      container,\n      [ d1, d2, d3 ],\n      o\n    );\n  }\n\n  graph = drawGraph();      \n\n  function initializeDrag (e) {\n    start = graph.getEventPosition(e);\n    Flotr.EventAdapter.observe(container, 'flotr:mousemove', move);\n    Flotr.EventAdapter.observe(container, 'flotr:mouseup', stopDrag);\n  }\n\n  function move (e, o) {\n    var\n      xaxis   = graph.axes.x,\n      offset  = start.x - o.x;\n    graph = drawGraph({\n      xaxis : {\n        min : xaxis.min + offset,\n        max : xaxis.max + offset\n      }\n    });\n  }\n\n  function stopDrag () {\n    Flotr.EventAdapter.stopObserving(container, 'flotr:mousemove', move);\n  }\n\n  Flotr.EventAdapter.observe(container, 'flotr:mousedown', initializeDrag);\n\n};\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-time',\n  name : 'Basic Time',\n  callback : basic_time,\n  description : \"<p>Select an area of the graph to zoom.  Click to reset the chart.</p>\"\n});\n\nfunction basic_time (container) {\n\n  var\n    d1    = [],\n    start = new Date(\"2009/01/01 01:00\").getTime(),\n    options,\n    graph,\n    i, x, o;\n\n  for (i = 0; i < 100; i++) {\n    x = start+(i*1000*3600*24*36.5);\n    d1.push([x, i+Math.random()*30+Math.sin(i/20+Math.random()*2)*20+Math.sin(i/10+Math.random())*10]);\n  }\n        \n  options = {\n    xaxis : {\n      mode : 'time', \n      labelsAngle : 45\n    },\n    selection : {\n      mode : 'x'\n    },\n    HtmlText : false,\n    title : 'Time'\n  };\n        \n  // Draw graph with default options, overwriting with passed options\n  function drawGraph (opts) {\n\n    // Clone the options, so the 'options' variable always keeps intact.\n    o = Flotr._.extend(Flotr._.clone(options), opts || {});\n\n    // Return a new graph.\n    return Flotr.draw(\n      container,\n      [ d1 ],\n      o\n    );\n  }\n\n  graph = drawGraph();      \n        \n  Flotr.EventAdapter.observe(container, 'flotr:select', function(area){\n    // Draw selected area\n    graph = drawGraph({\n      xaxis : { min : area.x1, max : area.x2, mode : 'time', labelsAngle : 45 },\n      yaxis : { min : area.y1, max : area.y2 }\n    });\n  });\n        \n  // When graph is clicked, draw the graph with default area.\n  Flotr.EventAdapter.observe(container, 'flotr:click', function () { graph = drawGraph(); });\n};      \n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'negative-values',\n  name : 'Negative Values',\n  callback : negative_values\n});\n\nfunction negative_values (container) {\n\n  var\n    d0    = [], // Line through y = 0\n    d1    = [], // Random data presented as a scatter plot. \n    d2    = [], // A regression line for the scatter. \n    sx    = 0,\n    sy    = 0,\n    sxy   = 0,\n    sxsq  = 0,\n    xmean,\n    ymean,\n    alpha,\n    beta,\n    n, x, y;\n\n  for (n = 0; n < 20; n++){\n\n    x = n;\n    y = x + Math.random()*8 - 15;\n\n    d0.push([x, 0]);\n    d1.push([x, y]);\n\n    // Computations used for regression line\n    sx += x;\n    sy += y;\n    sxy += x*y;\n    sxsq += Math.pow(x,2);\n  }\n\n  xmean = sx/n;\n  ymean = sy/n;\n  beta  = ((n*sxy) - (sx*sy))/((n*sxsq)-(Math.pow(sx,2)));\n  alpha = ymean - (beta * xmean);\n  \n  // Compute the regression line.\n  for (n = 0; n < 20; n++){\n    d2.push([n, alpha + beta*n])\n  }     \n\n  // Draw the graph\n  graph = Flotr.draw(\n    container, [ \n      { data : d0, shadowSize : 0, color : '#545454' }, // Horizontal\n      { data : d1, label : 'y = x + (Math.random() * 8) - 15', points : { show : true } },  // Scatter\n      { data : d2, label : 'y = ' + alpha.toFixed(2) + ' + ' + beta.toFixed(2) + '*x' }  // Regression\n    ],\n    {\n      legend : { position : 'se', backgroundColor : '#D2E8FF' },\n      title : 'Negative Values'\n    }\n  );\n};\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'click-example',\n  name : 'Click Example',\n  callback : click_example\n});\n\nfunction click_example (container) {\n\n  var\n    d1 = [[0,0]], // Point at origin\n    options,\n    graph;\n\n  options = {\n    xaxis: {min: 0, max: 15},\n    yaxis: {min: 0, max: 15},\n    lines: {show: true},\n    points: {show: true},\n    mouse: {track:true},\n    title: 'Click Example'\n  };\n\n  graph = Flotr.draw(container, [d1], options);\n\n  // Add a point to the series and redraw the graph\n  Flotr.EventAdapter.observe(container, 'flotr:click', function(position){\n\n    // Add a point to the series at the location of the click\n    d1.push([position.x, position.y]);\n    \n    // Sort the series.\n    d1 = d1.sort(function (a, b) { return a[0] - b[0]; });\n    \n    // Redraw the graph, with the new series.\n    graph = Flotr.draw(container, [d1], options);\n  });\n};      \n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'download-image',\n  name : 'Download Image',\n  callback : download_image,\n  description : '' + \n    '<form name=\"image-download\" id=\"image-download\" action=\"\" onsubmit=\"return false\">' +\n      '<label><input type=\"radio\" name=\"format\" value=\"png\" checked=\"checked\" /> PNG</label>' +\n      '<label><input type=\"radio\" name=\"format\" value=\"jpeg\" /> JPEG</label>' +\n\n      '<button name=\"to-image\" onclick=\"CurrentExample(\\'to-image\\')\">To Image</button>' +\n      '<button name=\"download\" onclick=\"CurrentExample(\\'download\\')\">Download</button>' +\n      '<button name=\"reset\" onclick=\"CurrentExample(\\'reset\\')\">Reset</button>' +\n    '</form>'\n});\n\nfunction download_image (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    d4 = [],\n    d5 = [],\n    graph,\n    i;\n  \n  for (i = 0; i <= 10; i += 0.1) {\n    d1.push([i, 4 + Math.pow(i,1.5)]);\n    d2.push([i, Math.pow(i,3)]);\n    d3.push([i, i*5+3*Math.sin(i*4)]);\n    d4.push([i, i]);\n    if( i.toFixed(1)%1 == 0 ){\n      d5.push([i, 2*i]);\n    }\n  }\n\n  // Draw the graph\n  graph = Flotr.draw(\n    container,[ \n      {data:d1, label:'y = 4 + x^(1.5)', lines:{fill:true}}, \n      {data:d2, label:'y = x^3', yaxis:2}, \n      {data:d3, label:'y = 5x + 3sin(4x)'}, \n      {data:d4, label:'y = x'},\n      {data:d5, label:'y = 2x', lines: {show: true}, points: {show: true}}\n    ],{\n      title: 'Download Image Example',\n      subtitle: 'You can save me as an image',\n      xaxis:{\n        noTicks: 7, // Display 7 ticks.\n        tickFormatter: function(n){ return '('+n+')'; }, // => displays tick values between brackets.\n        min: 1,  // => part of the series is not displayed.\n        max: 7.5, // => part of the series is not displayed.\n        labelsAngle: 45,\n        title: 'x Axis'\n      },\n      yaxis:{\n        ticks: [[0, \"Lower\"], 10, 20, 30, [40, \"Upper\"]],\n        max: 40,\n        title: 'y = f(x)'\n      },\n      y2axis:{color:'#FF0000', max: 500, title: 'y = x^3'},\n      grid:{\n        verticalLines: false,\n        backgroundColor: 'white'\n      },\n      HtmlText: false,\n      legend: {\n        position: 'nw'\n      }\n  });\n\n  this.CurrentExample = function (operation) {\n\n    var\n      format = $('#image-download input:radio[name=format]:checked').val();\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      alert(\n        \"Your browser doesn't allow you to get a bitmap image from the plot, \" +\n        \"you can only get a VML image that you can use in Microsoft Office.<br />\"\n      );\n    }\n\n    if (operation == 'to-image') {\n      graph.download.saveImage(format, null, null, true)\n    } else if (operation == 'download') {\n      graph.download.saveImage(format);\n    } else if (operation == 'reset') {\n      graph.download.restoreCanvas();\n    }\n  };\n\n  return graph;\n};\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'download-data',\n  name : 'Download Data',\n  callback : download_data\n});\n\nfunction download_data (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    d4 = [],\n    d5 = [],\n    graph,\n    i,x;\n  \n  for (i = 0; i <= 100; i += 1) {\n    x = i / 10;\n    d1.push([x, 4 + Math.pow(x,1.5)]);\n    d2.push([x, Math.pow(x,3)]);\n    d3.push([x, i*5+3*Math.sin(x*4)]);\n    d4.push([x, x]);\n    if(x%1 === 0 ){\n      d5.push([x, 2*x]);\n    }\n  }\n          \n  // Draw the graph.\n  graph = Flotr.draw(\n    container, [ \n      { data : d1, label : 'y = 4 + x^(1.5)', lines : { fill : true } },\n      { data : d2, label : 'y = x^3' },\n      { data : d3, label : 'y = 5x + 3sin(4x)' },\n      { data : d4, label : 'y = x' },\n      { data : d5, label : 'y = 2x', lines : { show : true }, points : { show : true } }\n    ],{\n      xaxis : {\n        noTicks : 7,\n        tickFormatter : function (n) { return '('+n+')'; },\n        min: 1,   // Part of the series is not displayed.\n        max: 7.5\n      },\n      yaxis : {\n        ticks : [[ 0, \"Lower\"], 10, 20, 30, [40, \"Upper\"]],\n        max : 40\n      },\n      grid : {\n        verticalLines : false,\n        backgroundColor : 'white'\n      },\n      legend : {\n        position : 'nw'\n      },\n      spreadsheet : {\n        show : true,\n        tickFormatter : function (e) { return e+''; }\n      }\n  });\n};\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'advanced-titles',\n  name : 'Advanced Titles',\n  callback : advanced_titles\n});\n\nfunction advanced_titles (container) {\n\n  var\n    d1 = [],\n    d2 = [],\n    d3 = [],\n    d4 = [],\n    d5 = [],\n    graph,\n    i;\n\n  for (i = 0; i <= 10; i += 0.1) {\n    d1.push([i, 4 + Math.pow(i,1.5)]);\n    d2.push([i, Math.pow(i,3)]);\n    d3.push([i, i*5+3*Math.sin(i*4)]);\n    d4.push([i, i]);\n    if (i.toFixed(1)%1 == 0) {\n      d5.push([i, 2*i]);\n    }\n  }\n\n  // Draw the graph.\n  graph = Flotr.draw(\n    container,[ \n      { data : d1, label : 'y = 4 + x^(1.5)', lines : { fill : true } },\n      { data : d2, label : 'y = x^3', yaxis : 2 },\n      { data : d3, label : 'y = 5x + 3sin(4x)' },\n      { data : d4, label : 'y = x' },\n      { data : d5, label : 'y = 2x', lines : { show : true }, points : { show : true } }\n    ], {\n      title : 'Advanced Titles Example',\n      subtitle : 'You can save me as an image',\n      xaxis : {\n        noTicks : 7,\n        tickFormatter : function (n) { return '('+n+')'; },\n        min : 1,\n        max : 7.5,\n        labelsAngle : 45,\n        title : 'x Axis'\n      },\n      yaxis : {\n        ticks : [[0, \"Lower\"], 10, 20, 30, [40, \"Upper\"]],\n        max : 40,\n        title : 'y = f(x)'\n      },\n      y2axis : { color : '#FF0000', max : 500, title : 'y = x^3' },\n      grid : {\n        verticalLines : false,\n        backgroundColor : 'white'\n      },\n      HtmlText : false,\n      legend : {\n        position : 'nw'\n      }\n  });\n};\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'color-gradients',\n  name : 'Color Gradients',\n  callback : color_gradients\n});\n\nfunction color_gradients (container) {\n\n  var\n    bars = {\n      data: [],\n      bars: {\n        show: true,\n        barWidth: 0.8,\n        lineWidth: 0,\n        fillColor: {\n          colors: ['#CB4B4B', '#fff'],\n          start: 'top',\n          end: 'bottom'\n        },\n        fillOpacity: 0.8\n      }\n    }, markers = {\n      data: [],\n      markers: {\n        show: true,\n        position: 'ct'\n      }\n    }, lines = {\n      data: [],\n      lines: {\n        show: true,\n        fillColor: ['#00A8F0', '#fff'],\n        fill: true,\n        fillOpacity: 1\n      }\n    },\n    point,\n    graph,\n    i;\n  \n  for (i = 0; i < 8; i++) {\n    point = [i, Math.ceil(Math.random() * 10)];\n    bars.data.push(point);\n    markers.data.push(point);\n  }\n  \n  for (i = -1; i < 9; i += 0.01){\n    lines.data.push([i, i*i/8+2]);\n  }\n  \n  graph = Flotr.draw(\n    container,\n    [lines, bars, markers], {\n      yaxis: {\n        min: 0,\n        max: 11\n      },\n      xaxis: {\n        min: -0.5,\n        max: 7.5\n      },\n      grid: {\n        verticalLines: false,\n        backgroundColor: ['#fff', '#ccc']\n      }\n    }\n  );\n};\n\n})();\n\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'profile-bars',\n  name : 'Profile Bars',\n  type : 'profile',\n  callback : profile_bars\n});\n\n/*\nFlotr.ExampleList.add({\n  key : 'basic-bars-horizontal',\n  name : 'Horizontal Bars',\n  args : [true],\n  callback : basic_bars\n});\n*/\n\nfunction profile_bars (container, horizontal) {\n\n  var\n    horizontal = (horizontal ? true : false), // Show horizontal bars\n    d1 = [],                                  // First data series\n    d2 = [],                                  // Second data series\n    point,                                    // Data point variable declaration\n    i;\n\n  for (i = 0; i < 5000; i++) {\n\n    if (horizontal) { \n      point = [Math.ceil(Math.random()*10), i];\n    } else {\n      point = [i, Math.ceil(Math.random()*10)];\n    }\n\n    d1.push(point);\n        \n    if (horizontal) { \n      point = [Math.ceil(Math.random()*10), i+0.5];\n    } else {\n      point = [i+0.5, Math.ceil(Math.random()*10)];\n    }\n\n    d2.push(point);\n  };\n              \n  // Draw the graph\n  Flotr.draw(\n    container,\n    [d1, d2],\n    {\n      bars : {\n        show : true,\n        horizontal : horizontal,\n        barWidth : 0.5\n      },\n      mouse : {\n        track : true,\n        relative : true\n      },\n      yaxis : {\n        min : 0,\n        autoscaleMargin : 1\n      }\n    }\n  );\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'basic-timeline',\n  name : 'Basic Timeline',\n  callback : basic_timeline\n});\n\nfunction basic_timeline (container) {\n\n  var\n    d1        = [[1, 4, 5]],\n    d2        = [[3.2, 3, 4]],\n    d3        = [[1.9, 2, 2], [5, 2, 3.3]],\n    d4        = [[1.55, 1, 9]],\n    d5        = [[5, 0, 2.3]],\n    data      = [],\n    timeline  = { show : true, barWidth : .5 },\n    markers   = [],\n    labels    = ['Obama', 'Bush', 'Clinton', 'Palin', 'McCain'],\n    i, graph, point;\n\n  // Timeline\n  Flotr._.each([d1, d2, d3, d4, d5], function (d) {\n    data.push({\n      data : d,\n      timeline : Flotr._.clone(timeline)\n    });\n  });\n\n  // Markers\n  Flotr._.each([d1, d2, d3, d4, d5], function (d) {\n    point = d[0];\n    markers.push([point[0], point[1]]);\n  });\n  data.push({\n    data: markers,\n    markers: {\n      show: true,\n      position: 'rm',\n      fontSize: 11,\n      labelFormatter : function (o) { return labels[o.index]; }\n    }\n  });\n  \n  // Draw Graph\n  graph = Flotr.draw(container, data, {\n    xaxis: {\n      noTicks: 3,\n      tickFormatter: function (x) {\n        var\n          x = parseInt(x),\n          months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n        return months[(x-1)%12];\n      }\n    }, \n    yaxis: {\n      showLabels : false\n    },\n    grid: {\n      horizontalLines : false\n    }\n  });\n}\n\n})();\n\n(function () {\n\nFlotr.ExampleList.add({\n  key : 'advanced-markers',\n  name : 'Advanced Markers',\n  callback : advanced_markers,\n  timeout : 150\n});\n\nfunction advanced_markers (container) {\n\n  var\n    xmark = new Image(),\n    checkmark = new Image(),\n    bars = {\n      data: [],\n      bars: {\n        show: true,\n        barWidth: 0.6,\n        lineWidth: 0,\n        fillOpacity: 0.8\n      }\n    }, markers = {\n      data: [],\n      markers: {\n        show: true,\n        position: 'ct',\n        labelFormatter: function (o) {\n          return (o.y >= 5) ? checkmark : xmark;\n        }\n      }\n    },\n    flotr = Flotr,\n    point,\n    graph,\n    i;\n\n\n  for (i = 0; i < 8; i++) {\n    point = [i, Math.ceil(Math.random() * 10)];\n    bars.data.push(point);\n    markers.data.push(point);\n  }\n\n  var runner = function () {\n    if (!xmark.complete || !checkmark.complete) {\n        setTimeout(runner, 50);\n        return;\n    }\n\n    graph = flotr.draw(\n      container,\n      [bars, markers], {\n        yaxis: {\n          min: 0,\n          max: 11\n        },\n        xaxis: {\n          min: -0.5,\n          max: 7.5\n        },\n        grid: {\n          verticalLines: false\n        }\n      }\n    );\n  }\n\n  xmark.onload = runner;\n  xmark.src = 'images/xmark.png';\n  checkmark.src = 'images/checkmark.png';\n};\n\n})();\n\n"
  },
  {
    "path": "html/lib/flotr2/flotr2.js",
    "content": "/*!\n  * bean.js - copyright Jacob Thornton 2011\n  * https://github.com/fat/bean\n  * MIT License\n  * special thanks to:\n  * dean edwards: http://dean.edwards.name/\n  * dperini: https://github.com/dperini/nwevents\n  * the entire mootools team: github.com/mootools/mootools-core\n  */\n/*global module:true, define:true*/\n!function (name, context, definition) {\n  if (typeof module !== 'undefined') module.exports = definition(name, context);\n  else if (typeof define === 'function' && typeof define.amd  === 'object') define(definition);\n  else context[name] = definition(name, context);\n}('bean', this, function (name, context) {\n  var win = window\n    , old = context[name]\n    , overOut = /over|out/\n    , namespaceRegex = /[^\\.]*(?=\\..*)\\.|.*/\n    , nameRegex = /\\..*/\n    , addEvent = 'addEventListener'\n    , attachEvent = 'attachEvent'\n    , removeEvent = 'removeEventListener'\n    , detachEvent = 'detachEvent'\n    , doc = document || {}\n    , root = doc.documentElement || {}\n    , W3C_MODEL = root[addEvent]\n    , eventSupport = W3C_MODEL ? addEvent : attachEvent\n    , slice = Array.prototype.slice\n    , mouseTypeRegex = /click|mouse|menu|drag|drop/i\n    , touchTypeRegex = /^touch|^gesture/i\n    , ONE = { one: 1 } // singleton for quick matching making add() do one()\n\n    , nativeEvents = (function (hash, events, i) {\n        for (i = 0; i < events.length; i++)\n          hash[events[i]] = 1\n        return hash\n      })({}, (\n          'click dblclick mouseup mousedown contextmenu ' +                  // mouse buttons\n          'mousewheel DOMMouseScroll ' +                                     // mouse wheel\n          'mouseover mouseout mousemove selectstart selectend ' +            // mouse movement\n          'keydown keypress keyup ' +                                        // keyboard\n          'orientationchange ' +                                             // mobile\n          'focus blur change reset select submit ' +                         // form elements\n          'load unload beforeunload resize move DOMContentLoaded readystatechange ' + // window\n          'error abort scroll ' +                                            // misc\n          (W3C_MODEL ? // element.fireEvent('onXYZ'... is not forgiving if we try to fire an event\n                       // that doesn't actually exist, so make sure we only do these on newer browsers\n            'show ' +                                                          // mouse buttons\n            'input invalid ' +                                                 // form elements\n            'touchstart touchmove touchend touchcancel ' +                     // touch\n            'gesturestart gesturechange gestureend ' +                         // gesture\n            'message readystatechange pageshow pagehide popstate ' +           // window\n            'hashchange offline online ' +                                     // window\n            'afterprint beforeprint ' +                                        // printing\n            'dragstart dragenter dragover dragleave drag drop dragend ' +      // dnd\n            'loadstart progress suspend emptied stalled loadmetadata ' +       // media\n            'loadeddata canplay canplaythrough playing waiting seeking ' +     // media\n            'seeked ended durationchange timeupdate play pause ratechange ' +  // media\n            'volumechange cuechange ' +                                        // media\n            'checking noupdate downloading cached updateready obsolete ' +     // appcache\n            '' : '')\n        ).split(' ')\n      )\n\n    , customEvents = (function () {\n        function isDescendant(parent, node) {\n          while ((node = node.parentNode) !== null) {\n            if (node === parent) return true\n          }\n          return false\n        }\n\n        function check(event) {\n          var related = event.relatedTarget\n          if (!related) return related === null\n          return (related !== this && related.prefix !== 'xul' && !/document/.test(this.toString()) && !isDescendant(this, related))\n        }\n\n        return {\n            mouseenter: { base: 'mouseover', condition: check }\n          , mouseleave: { base: 'mouseout', condition: check }\n          , mousewheel: { base: /Firefox/.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel' }\n        }\n      })()\n\n    , fixEvent = (function () {\n        var commonProps = 'altKey attrChange attrName bubbles cancelable ctrlKey currentTarget detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey srcElement target timeStamp type view which'.split(' ')\n          , mouseProps = commonProps.concat('button buttons clientX clientY dataTransfer fromElement offsetX offsetY pageX pageY screenX screenY toElement'.split(' '))\n          , keyProps = commonProps.concat('char charCode key keyCode'.split(' '))\n          , touchProps = commonProps.concat('touches targetTouches changedTouches scale rotation'.split(' '))\n          , preventDefault = 'preventDefault'\n          , createPreventDefault = function (event) {\n              return function () {\n                if (event[preventDefault])\n                  event[preventDefault]()\n                else\n                  event.returnValue = false\n              }\n            }\n          , stopPropagation = 'stopPropagation'\n          , createStopPropagation = function (event) {\n              return function () {\n                if (event[stopPropagation])\n                  event[stopPropagation]()\n                else\n                  event.cancelBubble = true\n              }\n            }\n          , createStop = function (synEvent) {\n              return function () {\n                synEvent[preventDefault]()\n                synEvent[stopPropagation]()\n                synEvent.stopped = true\n              }\n            }\n          , copyProps = function (event, result, props) {\n              var i, p\n              for (i = props.length; i--;) {\n                p = props[i]\n                if (!(p in result) && p in event) result[p] = event[p]\n              }\n            }\n\n        return function (event, isNative) {\n          var result = { originalEvent: event, isNative: isNative }\n          if (!event)\n            return result\n\n          var props\n            , type = event.type\n            , target = event.target || event.srcElement\n\n          result[preventDefault] = createPreventDefault(event)\n          result[stopPropagation] = createStopPropagation(event)\n          result.stop = createStop(result)\n          result.target = target && target.nodeType === 3 ? target.parentNode : target\n\n          if (isNative) { // we only need basic augmentation on custom events, the rest is too expensive\n            if (type.indexOf('key') !== -1) {\n              props = keyProps\n              result.keyCode = event.which || event.keyCode\n            } else if (mouseTypeRegex.test(type)) {\n              props = mouseProps\n              result.rightClick = event.which === 3 || event.button === 2\n              result.pos = { x: 0, y: 0 }\n              if (event.pageX || event.pageY) {\n                result.clientX = event.pageX\n                result.clientY = event.pageY\n              } else if (event.clientX || event.clientY) {\n                result.clientX = event.clientX + doc.body.scrollLeft + root.scrollLeft\n                result.clientY = event.clientY + doc.body.scrollTop + root.scrollTop\n              }\n              if (overOut.test(type))\n                result.relatedTarget = event.relatedTarget || event[(type === 'mouseover' ? 'from' : 'to') + 'Element']\n            } else if (touchTypeRegex.test(type)) {\n              props = touchProps\n            }\n            copyProps(event, result, props || commonProps)\n          }\n          return result\n        }\n      })()\n\n      // if we're in old IE we can't do onpropertychange on doc or win so we use doc.documentElement for both\n    , targetElement = function (element, isNative) {\n        return !W3C_MODEL && !isNative && (element === doc || element === win) ? root : element\n      }\n\n      // we use one of these per listener, of any type\n    , RegEntry = (function () {\n        function entry(element, type, handler, original, namespaces) {\n          this.element = element\n          this.type = type\n          this.handler = handler\n          this.original = original\n          this.namespaces = namespaces\n          this.custom = customEvents[type]\n          this.isNative = nativeEvents[type] && element[eventSupport]\n          this.eventType = W3C_MODEL || this.isNative ? type : 'propertychange'\n          this.customType = !W3C_MODEL && !this.isNative && type\n          this.target = targetElement(element, this.isNative)\n          this.eventSupport = this.target[eventSupport]\n        }\n\n        entry.prototype = {\n            // given a list of namespaces, is our entry in any of them?\n            inNamespaces: function (checkNamespaces) {\n              var i, j\n              if (!checkNamespaces)\n                return true\n              if (!this.namespaces)\n                return false\n              for (i = checkNamespaces.length; i--;) {\n                for (j = this.namespaces.length; j--;) {\n                  if (checkNamespaces[i] === this.namespaces[j])\n                    return true\n                }\n              }\n              return false\n            }\n\n            // match by element, original fn (opt), handler fn (opt)\n          , matches: function (checkElement, checkOriginal, checkHandler) {\n              return this.element === checkElement &&\n                (!checkOriginal || this.original === checkOriginal) &&\n                (!checkHandler || this.handler === checkHandler)\n            }\n        }\n\n        return entry\n      })()\n\n    , registry = (function () {\n        // our map stores arrays by event type, just because it's better than storing\n        // everything in a single array. uses '$' as a prefix for the keys for safety\n        var map = {}\n\n          // generic functional search of our registry for matching listeners,\n          // `fn` returns false to break out of the loop\n          , forAll = function (element, type, original, handler, fn) {\n              if (!type || type === '*') {\n                // search the whole registry\n                for (var t in map) {\n                  if (t.charAt(0) === '$')\n                    forAll(element, t.substr(1), original, handler, fn)\n                }\n              } else {\n                var i = 0, l, list = map['$' + type], all = element === '*'\n                if (!list)\n                  return\n                for (l = list.length; i < l; i++) {\n                  if (all || list[i].matches(element, original, handler))\n                    if (!fn(list[i], list, i, type))\n                      return\n                }\n              }\n            }\n\n          , has = function (element, type, original) {\n              // we're not using forAll here simply because it's a bit slower and this\n              // needs to be fast\n              var i, list = map['$' + type]\n              if (list) {\n                for (i = list.length; i--;) {\n                  if (list[i].matches(element, original, null))\n                    return true\n                }\n              }\n              return false\n            }\n\n          , get = function (element, type, original) {\n              var entries = []\n              forAll(element, type, original, null, function (entry) { return entries.push(entry) })\n              return entries\n            }\n\n          , put = function (entry) {\n              (map['$' + entry.type] || (map['$' + entry.type] = [])).push(entry)\n              return entry\n            }\n\n          , del = function (entry) {\n              forAll(entry.element, entry.type, null, entry.handler, function (entry, list, i) {\n                list.splice(i, 1)\n                if (list.length === 0)\n                  delete map['$' + entry.type]\n                return false\n              })\n            }\n\n            // dump all entries, used for onunload\n          , entries = function () {\n              var t, entries = []\n              for (t in map) {\n                if (t.charAt(0) === '$')\n                  entries = entries.concat(map[t])\n              }\n              return entries\n            }\n\n        return { has: has, get: get, put: put, del: del, entries: entries }\n      })()\n\n      // add and remove listeners to DOM elements\n    , listener = W3C_MODEL ? function (element, type, fn, add) {\n        element[add ? addEvent : removeEvent](type, fn, false)\n      } : function (element, type, fn, add, custom) {\n        if (custom && add && element['_on' + custom] === null)\n          element['_on' + custom] = 0\n        element[add ? attachEvent : detachEvent]('on' + type, fn)\n      }\n\n    , nativeHandler = function (element, fn, args) {\n        return function (event) {\n          event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event, true)\n          return fn.apply(element, [event].concat(args))\n        }\n      }\n\n    , customHandler = function (element, fn, type, condition, args, isNative) {\n        return function (event) {\n          if (condition ? condition.apply(this, arguments) : W3C_MODEL ? true : event && event.propertyName === '_on' + type || !event) {\n            if (event)\n              event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || win).event, isNative)\n            fn.apply(element, event && (!args || args.length === 0) ? arguments : slice.call(arguments, event ? 0 : 1).concat(args))\n          }\n        }\n      }\n\n    , once = function (rm, element, type, fn, originalFn) {\n        // wrap the handler in a handler that does a remove as well\n        return function () {\n          rm(element, type, originalFn)\n          fn.apply(this, arguments)\n        }\n      }\n\n    , removeListener = function (element, orgType, handler, namespaces) {\n        var i, l, entry\n          , type = (orgType && orgType.replace(nameRegex, ''))\n          , handlers = registry.get(element, type, handler)\n\n        for (i = 0, l = handlers.length; i < l; i++) {\n          if (handlers[i].inNamespaces(namespaces)) {\n            if ((entry = handlers[i]).eventSupport)\n              listener(entry.target, entry.eventType, entry.handler, false, entry.type)\n            // TODO: this is problematic, we have a registry.get() and registry.del() that\n            // both do registry searches so we waste cycles doing this. Needs to be rolled into\n            // a single registry.forAll(fn) that removes while finding, but the catch is that\n            // we'll be splicing the arrays that we're iterating over. Needs extra tests to\n            // make sure we don't screw it up. @rvagg\n            registry.del(entry)\n          }\n        }\n      }\n\n    , addListener = function (element, orgType, fn, originalFn, args) {\n        var entry\n          , type = orgType.replace(nameRegex, '')\n          , namespaces = orgType.replace(namespaceRegex, '').split('.')\n\n        if (registry.has(element, type, fn))\n          return element // no dupe\n        if (type === 'unload')\n          fn = once(removeListener, element, type, fn, originalFn) // self clean-up\n        if (customEvents[type]) {\n          if (customEvents[type].condition)\n            fn = customHandler(element, fn, type, customEvents[type].condition, true)\n          type = customEvents[type].base || type\n        }\n        entry = registry.put(new RegEntry(element, type, fn, originalFn, namespaces[0] && namespaces))\n        entry.handler = entry.isNative ?\n          nativeHandler(element, entry.handler, args) :\n          customHandler(element, entry.handler, type, false, args, false)\n        if (entry.eventSupport)\n          listener(entry.target, entry.eventType, entry.handler, true, entry.customType)\n      }\n\n    , del = function (selector, fn, $) {\n        return function (e) {\n          var target, i, array = typeof selector === 'string' ? $(selector, this) : selector\n          for (target = e.target; target && target !== this; target = target.parentNode) {\n            for (i = array.length; i--;) {\n              if (array[i] === target) {\n                return fn.apply(target, arguments)\n              }\n            }\n          }\n        }\n      }\n\n    , remove = function (element, typeSpec, fn) {\n        var k, m, type, namespaces, i\n          , rm = removeListener\n          , isString = typeSpec && typeof typeSpec === 'string'\n\n        if (isString && typeSpec.indexOf(' ') > 0) {\n          // remove(el, 't1 t2 t3', fn) or remove(el, 't1 t2 t3')\n          typeSpec = typeSpec.split(' ')\n          for (i = typeSpec.length; i--;)\n            remove(element, typeSpec[i], fn)\n          return element\n        }\n        type = isString && typeSpec.replace(nameRegex, '')\n        if (type && customEvents[type])\n          type = customEvents[type].type\n        if (!typeSpec || isString) {\n          // remove(el) or remove(el, t1.ns) or remove(el, .ns) or remove(el, .ns1.ns2.ns3)\n          if (namespaces = isString && typeSpec.replace(namespaceRegex, ''))\n            namespaces = namespaces.split('.')\n          rm(element, type, fn, namespaces)\n        } else if (typeof typeSpec === 'function') {\n          // remove(el, fn)\n          rm(element, null, typeSpec)\n        } else {\n          // remove(el, { t1: fn1, t2, fn2 })\n          for (k in typeSpec) {\n            if (typeSpec.hasOwnProperty(k))\n              remove(element, k, typeSpec[k])\n          }\n        }\n        return element\n      }\n\n    , add = function (element, events, fn, delfn, $) {\n        var type, types, i, args\n          , originalFn = fn\n          , isDel = fn && typeof fn === 'string'\n\n        if (events && !fn && typeof events === 'object') {\n          for (type in events) {\n            if (events.hasOwnProperty(type))\n              add.apply(this, [ element, type, events[type] ])\n          }\n        } else {\n          args = arguments.length > 3 ? slice.call(arguments, 3) : []\n          types = (isDel ? fn : events).split(' ')\n          isDel && (fn = del(events, (originalFn = delfn), $)) && (args = slice.call(args, 1))\n          // special case for one()\n          this === ONE && (fn = once(remove, element, events, fn, originalFn))\n          for (i = types.length; i--;) addListener(element, types[i], fn, originalFn, args)\n        }\n        return element\n      }\n\n    , one = function () {\n        return add.apply(ONE, arguments)\n      }\n\n    , fireListener = W3C_MODEL ? function (isNative, type, element) {\n        var evt = doc.createEvent(isNative ? 'HTMLEvents' : 'UIEvents')\n        evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, win, 1)\n        element.dispatchEvent(evt)\n      } : function (isNative, type, element) {\n        element = targetElement(element, isNative)\n        // if not-native then we're using onpropertychange so we just increment a custom property\n        isNative ? element.fireEvent('on' + type, doc.createEventObject()) : element['_on' + type]++\n      }\n\n    , fire = function (element, type, args) {\n        var i, j, l, names, handlers\n          , types = type.split(' ')\n\n        for (i = types.length; i--;) {\n          type = types[i].replace(nameRegex, '')\n          if (names = types[i].replace(namespaceRegex, ''))\n            names = names.split('.')\n          if (!names && !args && element[eventSupport]) {\n            fireListener(nativeEvents[type], type, element)\n          } else {\n            // non-native event, either because of a namespace, arguments or a non DOM element\n            // iterate over all listeners and manually 'fire'\n            handlers = registry.get(element, type)\n            args = [false].concat(args)\n            for (j = 0, l = handlers.length; j < l; j++) {\n              if (handlers[j].inNamespaces(names))\n                handlers[j].handler.apply(element, args)\n            }\n          }\n        }\n        return element\n      }\n\n    , clone = function (element, from, type) {\n        var i = 0\n          , handlers = registry.get(from, type)\n          , l = handlers.length\n\n        for (;i < l; i++)\n          handlers[i].original && add(element, handlers[i].type, handlers[i].original)\n        return element\n      }\n\n    , bean = {\n          add: add\n        , one: one\n        , remove: remove\n        , clone: clone\n        , fire: fire\n        , noConflict: function () {\n            context[name] = old\n            return this\n          }\n      }\n\n  if (win[attachEvent]) {\n    // for IE, clean up on unload to avoid leaks\n    var cleanup = function () {\n      var i, entries = registry.entries()\n      for (i in entries) {\n        if (entries[i].type && entries[i].type !== 'unload')\n          remove(entries[i].element, entries[i].type)\n      }\n      win[detachEvent]('onunload', cleanup)\n      win.CollectGarbage && win.CollectGarbage()\n    }\n    win[attachEvent]('onunload', cleanup)\n  }\n\n  return bean\n});\n//     Underscore.js 1.1.7\n//     (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.\n//     Underscore is freely distributable under the MIT license.\n//     Portions of Underscore are inspired or borrowed from Prototype,\n//     Oliver Steele's Functional, and John Resig's Micro-Templating.\n//     For all details and documentation:\n//     http://documentcloud.github.com/underscore\n\n(function() {\n\n  // Baseline setup\n  // --------------\n\n  // Establish the root object, `window` in the browser, or `global` on the server.\n  var root = this;\n\n  // Save the previous value of the `_` variable.\n  var previousUnderscore = root._;\n\n  // Establish the object that gets returned to break out of a loop iteration.\n  var breaker = {};\n\n  // Save bytes in the minified (but not gzipped) version:\n  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;\n\n  // Create quick reference variables for speed access to core prototypes.\n  var slice            = ArrayProto.slice,\n      unshift          = ArrayProto.unshift,\n      toString         = ObjProto.toString,\n      hasOwnProperty   = ObjProto.hasOwnProperty;\n\n  // All **ECMAScript 5** native function implementations that we hope to use\n  // are declared here.\n  var\n    nativeForEach      = ArrayProto.forEach,\n    nativeMap          = ArrayProto.map,\n    nativeReduce       = ArrayProto.reduce,\n    nativeReduceRight  = ArrayProto.reduceRight,\n    nativeFilter       = ArrayProto.filter,\n    nativeEvery        = ArrayProto.every,\n    nativeSome         = ArrayProto.some,\n    nativeIndexOf      = ArrayProto.indexOf,\n    nativeLastIndexOf  = ArrayProto.lastIndexOf,\n    nativeIsArray      = Array.isArray,\n    nativeKeys         = Object.keys,\n    nativeBind         = FuncProto.bind;\n\n  // Create a safe reference to the Underscore object for use below.\n  var _ = function(obj) { return new wrapper(obj); };\n\n  // Export the Underscore object for **CommonJS**, with backwards-compatibility\n  // for the old `require()` API. If we're not in CommonJS, add `_` to the\n  // global object.\n  if (typeof module !== 'undefined' && module.exports) {\n    module.exports = _;\n    _._ = _;\n  } else {\n    // Exported as a string, for Closure Compiler \"advanced\" mode.\n    root['_'] = _;\n  }\n\n  // Current version.\n  _.VERSION = '1.1.7';\n\n  // Collection Functions\n  // --------------------\n\n  // The cornerstone, an `each` implementation, aka `forEach`.\n  // Handles objects with the built-in `forEach`, arrays, and raw objects.\n  // Delegates to **ECMAScript 5**'s native `forEach` if available.\n  var each = _.each = _.forEach = function(obj, iterator, context) {\n    if (obj == null) return;\n    if (nativeForEach && obj.forEach === nativeForEach) {\n      obj.forEach(iterator, context);\n    } else if (obj.length === +obj.length) {\n      for (var i = 0, l = obj.length; i < l; i++) {\n        if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;\n      }\n    } else {\n      for (var key in obj) {\n        if (hasOwnProperty.call(obj, key)) {\n          if (iterator.call(context, obj[key], key, obj) === breaker) return;\n        }\n      }\n    }\n  };\n\n  // Return the results of applying the iterator to each element.\n  // Delegates to **ECMAScript 5**'s native `map` if available.\n  _.map = function(obj, iterator, context) {\n    var results = [];\n    if (obj == null) return results;\n    if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);\n    each(obj, function(value, index, list) {\n      results[results.length] = iterator.call(context, value, index, list);\n    });\n    return results;\n  };\n\n  // **Reduce** builds up a single result from a list of values, aka `inject`,\n  // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.\n  _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {\n    var initial = memo !== void 0;\n    if (obj == null) obj = [];\n    if (nativeReduce && obj.reduce === nativeReduce) {\n      if (context) iterator = _.bind(iterator, context);\n      return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);\n    }\n    each(obj, function(value, index, list) {\n      if (!initial) {\n        memo = value;\n        initial = true;\n      } else {\n        memo = iterator.call(context, memo, value, index, list);\n      }\n    });\n    if (!initial) throw new TypeError(\"Reduce of empty array with no initial value\");\n    return memo;\n  };\n\n  // The right-associative version of reduce, also known as `foldr`.\n  // Delegates to **ECMAScript 5**'s native `reduceRight` if available.\n  _.reduceRight = _.foldr = function(obj, iterator, memo, context) {\n    if (obj == null) obj = [];\n    if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {\n      if (context) iterator = _.bind(iterator, context);\n      return memo !== void 0 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);\n    }\n    var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();\n    return _.reduce(reversed, iterator, memo, context);\n  };\n\n  // Return the first value which passes a truth test. Aliased as `detect`.\n  _.find = _.detect = function(obj, iterator, context) {\n    var result;\n    any(obj, function(value, index, list) {\n      if (iterator.call(context, value, index, list)) {\n        result = value;\n        return true;\n      }\n    });\n    return result;\n  };\n\n  // Return all the elements that pass a truth test.\n  // Delegates to **ECMAScript 5**'s native `filter` if available.\n  // Aliased as `select`.\n  _.filter = _.select = function(obj, iterator, context) {\n    var results = [];\n    if (obj == null) return results;\n    if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);\n    each(obj, function(value, index, list) {\n      if (iterator.call(context, value, index, list)) results[results.length] = value;\n    });\n    return results;\n  };\n\n  // Return all the elements for which a truth test fails.\n  _.reject = function(obj, iterator, context) {\n    var results = [];\n    if (obj == null) return results;\n    each(obj, function(value, index, list) {\n      if (!iterator.call(context, value, index, list)) results[results.length] = value;\n    });\n    return results;\n  };\n\n  // Determine whether all of the elements match a truth test.\n  // Delegates to **ECMAScript 5**'s native `every` if available.\n  // Aliased as `all`.\n  _.every = _.all = function(obj, iterator, context) {\n    var result = true;\n    if (obj == null) return result;\n    if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);\n    each(obj, function(value, index, list) {\n      if (!(result = result && iterator.call(context, value, index, list))) return breaker;\n    });\n    return result;\n  };\n\n  // Determine if at least one element in the object matches a truth test.\n  // Delegates to **ECMAScript 5**'s native `some` if available.\n  // Aliased as `any`.\n  var any = _.some = _.any = function(obj, iterator, context) {\n    iterator = iterator || _.identity;\n    var result = false;\n    if (obj == null) return result;\n    if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);\n    each(obj, function(value, index, list) {\n      if (result |= iterator.call(context, value, index, list)) return breaker;\n    });\n    return !!result;\n  };\n\n  // Determine if a given value is included in the array or object using `===`.\n  // Aliased as `contains`.\n  _.include = _.contains = function(obj, target) {\n    var found = false;\n    if (obj == null) return found;\n    if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;\n    any(obj, function(value) {\n      if (found = value === target) return true;\n    });\n    return found;\n  };\n\n  // Invoke a method (with arguments) on every item in a collection.\n  _.invoke = function(obj, method) {\n    var args = slice.call(arguments, 2);\n    return _.map(obj, function(value) {\n      return (method.call ? method || value : value[method]).apply(value, args);\n    });\n  };\n\n  // Convenience version of a common use case of `map`: fetching a property.\n  _.pluck = function(obj, key) {\n    return _.map(obj, function(value){ return value[key]; });\n  };\n\n  // Return the maximum element or (element-based computation).\n  _.max = function(obj, iterator, context) {\n    if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);\n    var result = {computed : -Infinity};\n    each(obj, function(value, index, list) {\n      var computed = iterator ? iterator.call(context, value, index, list) : value;\n      computed >= result.computed && (result = {value : value, computed : computed});\n    });\n    return result.value;\n  };\n\n  // Return the minimum element (or element-based computation).\n  _.min = function(obj, iterator, context) {\n    if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);\n    var result = {computed : Infinity};\n    each(obj, function(value, index, list) {\n      var computed = iterator ? iterator.call(context, value, index, list) : value;\n      computed < result.computed && (result = {value : value, computed : computed});\n    });\n    return result.value;\n  };\n\n  // Sort the object's values by a criterion produced by an iterator.\n  _.sortBy = function(obj, iterator, context) {\n    return _.pluck(_.map(obj, function(value, index, list) {\n      return {\n        value : value,\n        criteria : iterator.call(context, value, index, list)\n      };\n    }).sort(function(left, right) {\n      var a = left.criteria, b = right.criteria;\n      return a < b ? -1 : a > b ? 1 : 0;\n    }), 'value');\n  };\n\n  // Groups the object's values by a criterion produced by an iterator\n  _.groupBy = function(obj, iterator) {\n    var result = {};\n    each(obj, function(value, index) {\n      var key = iterator(value, index);\n      (result[key] || (result[key] = [])).push(value);\n    });\n    return result;\n  };\n\n  // Use a comparator function to figure out at what index an object should\n  // be inserted so as to maintain order. Uses binary search.\n  _.sortedIndex = function(array, obj, iterator) {\n    iterator || (iterator = _.identity);\n    var low = 0, high = array.length;\n    while (low < high) {\n      var mid = (low + high) >> 1;\n      iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;\n    }\n    return low;\n  };\n\n  // Safely convert anything iterable into a real, live array.\n  _.toArray = function(iterable) {\n    if (!iterable)                return [];\n    if (iterable.toArray)         return iterable.toArray();\n    if (_.isArray(iterable))      return slice.call(iterable);\n    if (_.isArguments(iterable))  return slice.call(iterable);\n    return _.values(iterable);\n  };\n\n  // Return the number of elements in an object.\n  _.size = function(obj) {\n    return _.toArray(obj).length;\n  };\n\n  // Array Functions\n  // ---------------\n\n  // Get the first element of an array. Passing **n** will return the first N\n  // values in the array. Aliased as `head`. The **guard** check allows it to work\n  // with `_.map`.\n  _.first = _.head = function(array, n, guard) {\n    return (n != null) && !guard ? slice.call(array, 0, n) : array[0];\n  };\n\n  // Returns everything but the first entry of the array. Aliased as `tail`.\n  // Especially useful on the arguments object. Passing an **index** will return\n  // the rest of the values in the array from that index onward. The **guard**\n  // check allows it to work with `_.map`.\n  _.rest = _.tail = function(array, index, guard) {\n    return slice.call(array, (index == null) || guard ? 1 : index);\n  };\n\n  // Get the last element of an array.\n  _.last = function(array) {\n    return array[array.length - 1];\n  };\n\n  // Trim out all falsy values from an array.\n  _.compact = function(array) {\n    return _.filter(array, function(value){ return !!value; });\n  };\n\n  // Return a completely flattened version of an array.\n  _.flatten = function(array) {\n    return _.reduce(array, function(memo, value) {\n      if (_.isArray(value)) return memo.concat(_.flatten(value));\n      memo[memo.length] = value;\n      return memo;\n    }, []);\n  };\n\n  // Return a version of the array that does not contain the specified value(s).\n  _.without = function(array) {\n    return _.difference(array, slice.call(arguments, 1));\n  };\n\n  // Produce a duplicate-free version of the array. If the array has already\n  // been sorted, you have the option of using a faster algorithm.\n  // Aliased as `unique`.\n  _.uniq = _.unique = function(array, isSorted) {\n    return _.reduce(array, function(memo, el, i) {\n      if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo[memo.length] = el;\n      return memo;\n    }, []);\n  };\n\n  // Produce an array that contains the union: each distinct element from all of\n  // the passed-in arrays.\n  _.union = function() {\n    return _.uniq(_.flatten(arguments));\n  };\n\n  // Produce an array that contains every item shared between all the\n  // passed-in arrays. (Aliased as \"intersect\" for back-compat.)\n  _.intersection = _.intersect = function(array) {\n    var rest = slice.call(arguments, 1);\n    return _.filter(_.uniq(array), function(item) {\n      return _.every(rest, function(other) {\n        return _.indexOf(other, item) >= 0;\n      });\n    });\n  };\n\n  // Take the difference between one array and another.\n  // Only the elements present in just the first array will remain.\n  _.difference = function(array, other) {\n    return _.filter(array, function(value){ return !_.include(other, value); });\n  };\n\n  // Zip together multiple lists into a single array -- elements that share\n  // an index go together.\n  _.zip = function() {\n    var args = slice.call(arguments);\n    var length = _.max(_.pluck(args, 'length'));\n    var results = new Array(length);\n    for (var i = 0; i < length; i++) results[i] = _.pluck(args, \"\" + i);\n    return results;\n  };\n\n  // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),\n  // we need this function. Return the position of the first occurrence of an\n  // item in an array, or -1 if the item is not included in the array.\n  // Delegates to **ECMAScript 5**'s native `indexOf` if available.\n  // If the array is large and already in sort order, pass `true`\n  // for **isSorted** to use binary search.\n  _.indexOf = function(array, item, isSorted) {\n    if (array == null) return -1;\n    var i, l;\n    if (isSorted) {\n      i = _.sortedIndex(array, item);\n      return array[i] === item ? i : -1;\n    }\n    if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);\n    for (i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;\n    return -1;\n  };\n\n\n  // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.\n  _.lastIndexOf = function(array, item) {\n    if (array == null) return -1;\n    if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);\n    var i = array.length;\n    while (i--) if (array[i] === item) return i;\n    return -1;\n  };\n\n  // Generate an integer Array containing an arithmetic progression. A port of\n  // the native Python `range()` function. See\n  // [the Python documentation](http://docs.python.org/library/functions.html#range).\n  _.range = function(start, stop, step) {\n    if (arguments.length <= 1) {\n      stop = start || 0;\n      start = 0;\n    }\n    step = arguments[2] || 1;\n\n    var len = Math.max(Math.ceil((stop - start) / step), 0);\n    var idx = 0;\n    var range = new Array(len);\n\n    while(idx < len) {\n      range[idx++] = start;\n      start += step;\n    }\n\n    return range;\n  };\n\n  // Function (ahem) Functions\n  // ------------------\n\n  // Create a function bound to a given object (assigning `this`, and arguments,\n  // optionally). Binding with arguments is also known as `curry`.\n  // Delegates to **ECMAScript 5**'s native `Function.bind` if available.\n  // We check for `func.bind` first, to fail fast when `func` is undefined.\n  _.bind = function(func, obj) {\n    if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));\n    var args = slice.call(arguments, 2);\n    return function() {\n      return func.apply(obj, args.concat(slice.call(arguments)));\n    };\n  };\n\n  // Bind all of an object's methods to that object. Useful for ensuring that\n  // all callbacks defined on an object belong to it.\n  _.bindAll = function(obj) {\n    var funcs = slice.call(arguments, 1);\n    if (funcs.length == 0) funcs = _.functions(obj);\n    each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });\n    return obj;\n  };\n\n  // Memoize an expensive function by storing its results.\n  _.memoize = function(func, hasher) {\n    var memo = {};\n    hasher || (hasher = _.identity);\n    return function() {\n      var key = hasher.apply(this, arguments);\n      return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));\n    };\n  };\n\n  // Delays a function for the given number of milliseconds, and then calls\n  // it with the arguments supplied.\n  _.delay = function(func, wait) {\n    var args = slice.call(arguments, 2);\n    return setTimeout(function(){ return func.apply(func, args); }, wait);\n  };\n\n  // Defers a function, scheduling it to run after the current call stack has\n  // cleared.\n  _.defer = function(func) {\n    return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));\n  };\n\n  // Internal function used to implement `_.throttle` and `_.debounce`.\n  var limit = function(func, wait, debounce) {\n    var timeout;\n    return function() {\n      var context = this, args = arguments;\n      var throttler = function() {\n        timeout = null;\n        func.apply(context, args);\n      };\n      if (debounce) clearTimeout(timeout);\n      if (debounce || !timeout) timeout = setTimeout(throttler, wait);\n    };\n  };\n\n  // Returns a function, that, when invoked, will only be triggered at most once\n  // during a given window of time.\n  _.throttle = function(func, wait) {\n    return limit(func, wait, false);\n  };\n\n  // Returns a function, that, as long as it continues to be invoked, will not\n  // be triggered. The function will be called after it stops being called for\n  // N milliseconds.\n  _.debounce = function(func, wait) {\n    return limit(func, wait, true);\n  };\n\n  // Returns a function that will be executed at most one time, no matter how\n  // often you call it. Useful for lazy initialization.\n  _.once = function(func) {\n    var ran = false, memo;\n    return function() {\n      if (ran) return memo;\n      ran = true;\n      return memo = func.apply(this, arguments);\n    };\n  };\n\n  // Returns the first function passed as an argument to the second,\n  // allowing you to adjust arguments, run code before and after, and\n  // conditionally execute the original function.\n  _.wrap = function(func, wrapper) {\n    return function() {\n      var args = [func].concat(slice.call(arguments));\n      return wrapper.apply(this, args);\n    };\n  };\n\n  // Returns a function that is the composition of a list of functions, each\n  // consuming the return value of the function that follows.\n  _.compose = function() {\n    var funcs = slice.call(arguments);\n    return function() {\n      var args = slice.call(arguments);\n      for (var i = funcs.length - 1; i >= 0; i--) {\n        args = [funcs[i].apply(this, args)];\n      }\n      return args[0];\n    };\n  };\n\n  // Returns a function that will only be executed after being called N times.\n  _.after = function(times, func) {\n    return function() {\n      if (--times < 1) { return func.apply(this, arguments); }\n    };\n  };\n\n\n  // Object Functions\n  // ----------------\n\n  // Retrieve the names of an object's properties.\n  // Delegates to **ECMAScript 5**'s native `Object.keys`\n  _.keys = nativeKeys || function(obj) {\n    if (obj !== Object(obj)) throw new TypeError('Invalid object');\n    var keys = [];\n    for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;\n    return keys;\n  };\n\n  // Retrieve the values of an object's properties.\n  _.values = function(obj) {\n    return _.map(obj, _.identity);\n  };\n\n  // Return a sorted list of the function names available on the object.\n  // Aliased as `methods`\n  _.functions = _.methods = function(obj) {\n    var names = [];\n    for (var key in obj) {\n      if (_.isFunction(obj[key])) names.push(key);\n    }\n    return names.sort();\n  };\n\n  // Extend a given object with all the properties in passed-in object(s).\n  _.extend = function(obj) {\n    each(slice.call(arguments, 1), function(source) {\n      for (var prop in source) {\n        if (source[prop] !== void 0) obj[prop] = source[prop];\n      }\n    });\n    return obj;\n  };\n\n  // Fill in a given object with default properties.\n  _.defaults = function(obj) {\n    each(slice.call(arguments, 1), function(source) {\n      for (var prop in source) {\n        if (obj[prop] == null) obj[prop] = source[prop];\n      }\n    });\n    return obj;\n  };\n\n  // Create a (shallow-cloned) duplicate of an object.\n  _.clone = function(obj) {\n    return _.isArray(obj) ? obj.slice() : _.extend({}, obj);\n  };\n\n  // Invokes interceptor with the obj, and then returns obj.\n  // The primary purpose of this method is to \"tap into\" a method chain, in\n  // order to perform operations on intermediate results within the chain.\n  _.tap = function(obj, interceptor) {\n    interceptor(obj);\n    return obj;\n  };\n\n  // Perform a deep comparison to check if two objects are equal.\n  _.isEqual = function(a, b) {\n    // Check object identity.\n    if (a === b) return true;\n    // Different types?\n    var atype = typeof(a), btype = typeof(b);\n    if (atype != btype) return false;\n    // Basic equality test (watch out for coercions).\n    if (a == b) return true;\n    // One is falsy and the other truthy.\n    if ((!a && b) || (a && !b)) return false;\n    // Unwrap any wrapped objects.\n    if (a._chain) a = a._wrapped;\n    if (b._chain) b = b._wrapped;\n    // One of them implements an isEqual()?\n    if (a.isEqual) return a.isEqual(b);\n    if (b.isEqual) return b.isEqual(a);\n    // Check dates' integer values.\n    if (_.isDate(a) && _.isDate(b)) return a.getTime() === b.getTime();\n    // Both are NaN?\n    if (_.isNaN(a) && _.isNaN(b)) return false;\n    // Compare regular expressions.\n    if (_.isRegExp(a) && _.isRegExp(b))\n      return a.source     === b.source &&\n             a.global     === b.global &&\n             a.ignoreCase === b.ignoreCase &&\n             a.multiline  === b.multiline;\n    // If a is not an object by this point, we can't handle it.\n    if (atype !== 'object') return false;\n    // Check for different array lengths before comparing contents.\n    if (a.length && (a.length !== b.length)) return false;\n    // Nothing else worked, deep compare the contents.\n    var aKeys = _.keys(a), bKeys = _.keys(b);\n    // Different object sizes?\n    if (aKeys.length != bKeys.length) return false;\n    // Recursive comparison of contents.\n    for (var key in a) if (!(key in b) || !_.isEqual(a[key], b[key])) return false;\n    return true;\n  };\n\n  // Is a given array or object empty?\n  _.isEmpty = function(obj) {\n    if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;\n    for (var key in obj) if (hasOwnProperty.call(obj, key)) return false;\n    return true;\n  };\n\n  // Is a given value a DOM element?\n  _.isElement = function(obj) {\n    return !!(obj && obj.nodeType == 1);\n  };\n\n  // Is a given value an array?\n  // Delegates to ECMA5's native Array.isArray\n  _.isArray = nativeIsArray || function(obj) {\n    return toString.call(obj) === '[object Array]';\n  };\n\n  // Is a given variable an object?\n  _.isObject = function(obj) {\n    return obj === Object(obj);\n  };\n\n  // Is a given variable an arguments object?\n  _.isArguments = function(obj) {\n    return !!(obj && hasOwnProperty.call(obj, 'callee'));\n  };\n\n  // Is a given value a function?\n  _.isFunction = function(obj) {\n    return !!(obj && obj.constructor && obj.call && obj.apply);\n  };\n\n  // Is a given value a string?\n  _.isString = function(obj) {\n    return !!(obj === '' || (obj && obj.charCodeAt && obj.substr));\n  };\n\n  // Is a given value a number?\n  _.isNumber = function(obj) {\n    return !!(obj === 0 || (obj && obj.toExponential && obj.toFixed));\n  };\n\n  // Is the given value `NaN`? `NaN` happens to be the only value in JavaScript\n  // that does not equal itself.\n  _.isNaN = function(obj) {\n    return obj !== obj;\n  };\n\n  // Is a given value a boolean?\n  _.isBoolean = function(obj) {\n    return obj === true || obj === false;\n  };\n\n  // Is a given value a date?\n  _.isDate = function(obj) {\n    return !!(obj && obj.getTimezoneOffset && obj.setUTCFullYear);\n  };\n\n  // Is the given value a regular expression?\n  _.isRegExp = function(obj) {\n    return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false));\n  };\n\n  // Is a given value equal to null?\n  _.isNull = function(obj) {\n    return obj === null;\n  };\n\n  // Is a given variable undefined?\n  _.isUndefined = function(obj) {\n    return obj === void 0;\n  };\n\n  // Utility Functions\n  // -----------------\n\n  // Run Underscore.js in *noConflict* mode, returning the `_` variable to its\n  // previous owner. Returns a reference to the Underscore object.\n  _.noConflict = function() {\n    root._ = previousUnderscore;\n    return this;\n  };\n\n  // Keep the identity function around for default iterators.\n  _.identity = function(value) {\n    return value;\n  };\n\n  // Run a function **n** times.\n  _.times = function (n, iterator, context) {\n    for (var i = 0; i < n; i++) iterator.call(context, i);\n  };\n\n  // Add your own custom functions to the Underscore object, ensuring that\n  // they're correctly added to the OOP wrapper as well.\n  _.mixin = function(obj) {\n    each(_.functions(obj), function(name){\n      addToWrapper(name, _[name] = obj[name]);\n    });\n  };\n\n  // Generate a unique integer id (unique within the entire client session).\n  // Useful for temporary DOM ids.\n  var idCounter = 0;\n  _.uniqueId = function(prefix) {\n    var id = idCounter++;\n    return prefix ? prefix + id : id;\n  };\n\n  // By default, Underscore uses ERB-style template delimiters, change the\n  // following template settings to use alternative delimiters.\n  _.templateSettings = {\n    evaluate    : /<%([\\s\\S]+?)%>/g,\n    interpolate : /<%=([\\s\\S]+?)%>/g\n  };\n\n  // JavaScript micro-templating, similar to John Resig's implementation.\n  // Underscore templating handles arbitrary delimiters, preserves whitespace,\n  // and correctly escapes quotes within interpolated code.\n  _.template = function(str, data) {\n    var c  = _.templateSettings;\n    var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +\n      'with(obj||{}){__p.push(\\'' +\n      str.replace(/\\\\/g, '\\\\\\\\')\n         .replace(/'/g, \"\\\\'\")\n         .replace(c.interpolate, function(match, code) {\n           return \"',\" + code.replace(/\\\\'/g, \"'\") + \",'\";\n         })\n         .replace(c.evaluate || null, function(match, code) {\n           return \"');\" + code.replace(/\\\\'/g, \"'\")\n                              .replace(/[\\r\\n\\t]/g, ' ') + \"__p.push('\";\n         })\n         .replace(/\\r/g, '\\\\r')\n         .replace(/\\n/g, '\\\\n')\n         .replace(/\\t/g, '\\\\t')\n         + \"');}return __p.join('');\";\n    var func = new Function('obj', tmpl);\n    return data ? func(data) : func;\n  };\n\n  // The OOP Wrapper\n  // ---------------\n\n  // If Underscore is called as a function, it returns a wrapped object that\n  // can be used OO-style. This wrapper holds altered versions of all the\n  // underscore functions. Wrapped objects may be chained.\n  var wrapper = function(obj) { this._wrapped = obj; };\n\n  // Expose `wrapper.prototype` as `_.prototype`\n  _.prototype = wrapper.prototype;\n\n  // Helper function to continue chaining intermediate results.\n  var result = function(obj, chain) {\n    return chain ? _(obj).chain() : obj;\n  };\n\n  // A method to easily add functions to the OOP wrapper.\n  var addToWrapper = function(name, func) {\n    wrapper.prototype[name] = function() {\n      var args = slice.call(arguments);\n      unshift.call(args, this._wrapped);\n      return result(func.apply(_, args), this._chain);\n    };\n  };\n\n  // Add all of the Underscore functions to the wrapper object.\n  _.mixin(_);\n\n  // Add all mutator Array functions to the wrapper.\n  each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {\n    var method = ArrayProto[name];\n    wrapper.prototype[name] = function() {\n      method.apply(this._wrapped, arguments);\n      return result(this._wrapped, this._chain);\n    };\n  });\n\n  // Add all accessor Array functions to the wrapper.\n  each(['concat', 'join', 'slice'], function(name) {\n    var method = ArrayProto[name];\n    wrapper.prototype[name] = function() {\n      return result(method.apply(this._wrapped, arguments), this._chain);\n    };\n  });\n\n  // Start chaining a wrapped Underscore object.\n  wrapper.prototype.chain = function() {\n    this._chain = true;\n    return this;\n  };\n\n  // Extracts the result from a wrapped and chained object.\n  wrapper.prototype.value = function() {\n    return this._wrapped;\n  };\n\n})();\n/**\n * Flotr2 (c) 2012 Carl Sutherland\n * MIT License\n * Special thanks to:\n * Flotr: http://code.google.com/p/flotr/ (fork)\n * Flot: https://github.com/flot/flot (original fork)\n */\n(function () {\n\nvar\n  global = this,\n  previousFlotr = this.Flotr,\n  Flotr;\n\nFlotr = {\n  _: _,\n  bean: bean,\n  isIphone: /iphone/i.test(navigator.userAgent),\n  isIE: (navigator.appVersion.indexOf(\"MSIE\") != -1 ? parseFloat(navigator.appVersion.split(\"MSIE\")[1]) : false),\n  \n  /**\n   * An object of the registered graph types. Use Flotr.addType(type, object)\n   * to add your own type.\n   */\n  graphTypes: {},\n  \n  /**\n   * The list of the registered plugins\n   */\n  plugins: {},\n  \n  /**\n   * Can be used to add your own chart type. \n   * @param {String} name - Type of chart, like 'pies', 'bars' etc.\n   * @param {String} graphType - The object containing the basic drawing functions (draw, etc)\n   */\n  addType: function(name, graphType){\n    Flotr.graphTypes[name] = graphType;\n    Flotr.defaultOptions[name] = graphType.options || {};\n    Flotr.defaultOptions.defaultType = Flotr.defaultOptions.defaultType || name;\n  },\n  \n  /**\n   * Can be used to add a plugin\n   * @param {String} name - The name of the plugin\n   * @param {String} plugin - The object containing the plugin's data (callbacks, options, function1, function2, ...)\n   */\n  addPlugin: function(name, plugin){\n    Flotr.plugins[name] = plugin;\n    Flotr.defaultOptions[name] = plugin.options || {};\n  },\n  \n  /**\n   * Draws the graph. This function is here for backwards compatibility with Flotr version 0.1.0alpha.\n   * You could also draw graphs by directly calling Flotr.Graph(element, data, options).\n   * @param {Element} el - element to insert the graph into\n   * @param {Object} data - an array or object of dataseries\n   * @param {Object} options - an object containing options\n   * @param {Class} _GraphKlass_ - (optional) Class to pass the arguments to, defaults to Flotr.Graph\n   * @return {Object} returns a new graph object and of course draws the graph.\n   */\n  draw: function(el, data, options, GraphKlass){  \n    GraphKlass = GraphKlass || Flotr.Graph;\n    return new GraphKlass(el, data, options);\n  },\n  \n  /**\n   * Recursively merges two objects.\n   * @param {Object} src - source object (likely the object with the least properties)\n   * @param {Object} dest - destination object (optional, object with the most properties)\n   * @return {Object} recursively merged Object\n   * @TODO See if we can't remove this.\n   */\n  merge: function(src, dest){\n    var i, v, result = dest || {};\n\n    for (i in src) {\n      v = src[i];\n      if (v && typeof(v) === 'object') {\n        if (v.constructor === Array) {\n          result[i] = this._.clone(v);\n        } else if (\n            v.constructor !== RegExp &&\n            !this._.isElement(v) &&\n            !v.jquery\n        ) {\n          result[i] = Flotr.merge(v, (dest ? dest[i] : undefined));\n        } else {\n          result[i] = v;\n        }\n      } else {\n        result[i] = v;\n      }\n    }\n\n    return result;\n  },\n  \n  /**\n   * Recursively clones an object.\n   * @param {Object} object - The object to clone\n   * @return {Object} the clone\n   * @TODO See if we can't remove this.\n   */\n  clone: function(object){\n    return Flotr.merge(object, {});\n  },\n  \n  /**\n   * Function calculates the ticksize and returns it.\n   * @param {Integer} noTicks - number of ticks\n   * @param {Integer} min - lower bound integer value for the current axis\n   * @param {Integer} max - upper bound integer value for the current axis\n   * @param {Integer} decimals - number of decimals for the ticks\n   * @return {Integer} returns the ticksize in pixels\n   */\n  getTickSize: function(noTicks, min, max, decimals){\n    var delta = (max - min) / noTicks,\n        magn = Flotr.getMagnitude(delta),\n        tickSize = 10,\n        norm = delta / magn; // Norm is between 1.0 and 10.0.\n        \n    if(norm < 1.5) tickSize = 1;\n    else if(norm < 2.25) tickSize = 2;\n    else if(norm < 3) tickSize = ((decimals === 0) ? 2 : 2.5);\n    else if(norm < 7.5) tickSize = 5;\n    \n    return tickSize * magn;\n  },\n  \n  /**\n   * Default tick formatter.\n   * @param {String, Integer} val - tick value integer\n   * @param {Object} axisOpts - the axis' options\n   * @return {String} formatted tick string\n   */\n  defaultTickFormatter: function(val, axisOpts){\n    return val+'';\n  },\n  \n  /**\n   * Formats the mouse tracker values.\n   * @param {Object} obj - Track value Object {x:..,y:..}\n   * @return {String} Formatted track string\n   */\n  defaultTrackFormatter: function(obj){\n    return '('+obj.x+', '+obj.y+')';\n  }, \n  \n  /**\n   * Utility function to convert file size values in bytes to kB, MB, ...\n   * @param value {Number} - The value to convert\n   * @param precision {Number} - The number of digits after the comma (default: 2)\n   * @param base {Number} - The base (default: 1000)\n   */\n  engineeringNotation: function(value, precision, base){\n    var sizes =         ['Y','Z','E','P','T','G','M','k',''],\n        fractionSizes = ['y','z','a','f','p','n','µ','m',''],\n        total = sizes.length;\n\n    base = base || 1000;\n    precision = Math.pow(10, precision || 2);\n\n    if (value === 0) return 0;\n\n    if (value > 1) {\n      while (total-- && (value >= base)) value /= base;\n    }\n    else {\n      sizes = fractionSizes;\n      total = sizes.length;\n      while (total-- && (value < 1)) value *= base;\n    }\n\n    return (Math.round(value * precision) / precision) + sizes[total];\n  },\n  \n  /**\n   * Returns the magnitude of the input value.\n   * @param {Integer, Float} x - integer or float value\n   * @return {Integer, Float} returns the magnitude of the input value\n   */\n  getMagnitude: function(x){\n    return Math.pow(10, Math.floor(Math.log(x) / Math.LN10));\n  },\n  toPixel: function(val){\n    return Math.floor(val)+0.5;//((val-Math.round(val) < 0.4) ? (Math.floor(val)-0.5) : val);\n  },\n  toRad: function(angle){\n    return -angle * (Math.PI/180);\n  },\n  floorInBase: function(n, base) {\n    return base * Math.floor(n / base);\n  },\n  drawText: function(ctx, text, x, y, style) {\n    if (!ctx.fillText) {\n      ctx.drawText(text, x, y, style);\n      return;\n    }\n    \n    style = this._.extend({\n      size: Flotr.defaultOptions.fontSize,\n      color: '#000000',\n      textAlign: 'left',\n      textBaseline: 'bottom',\n      weight: 1,\n      angle: 0\n    }, style);\n    \n    ctx.save();\n    ctx.translate(x, y);\n    ctx.rotate(style.angle);\n    ctx.fillStyle = style.color;\n    ctx.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    ctx.textAlign = style.textAlign;\n    ctx.textBaseline = style.textBaseline;\n    ctx.fillText(text, 0, 0);\n    ctx.restore();\n  },\n  getBestTextAlign: function(angle, style) {\n    style = style || {textAlign: 'center', textBaseline: 'middle'};\n    angle += Flotr.getTextAngleFromAlign(style);\n    \n    if (Math.abs(Math.cos(angle)) > 10e-3) \n      style.textAlign    = (Math.cos(angle) > 0 ? 'right' : 'left');\n    \n    if (Math.abs(Math.sin(angle)) > 10e-3) \n      style.textBaseline = (Math.sin(angle) > 0 ? 'top' : 'bottom');\n    \n    return style;\n  },\n  alignTable: {\n    'right middle' : 0,\n    'right top'    : Math.PI/4,\n    'center top'   : Math.PI/2,\n    'left top'     : 3*(Math.PI/4),\n    'left middle'  : Math.PI,\n    'left bottom'  : -3*(Math.PI/4),\n    'center bottom': -Math.PI/2,\n    'right bottom' : -Math.PI/4,\n    'center middle': 0\n  },\n  getTextAngleFromAlign: function(style) {\n    return Flotr.alignTable[style.textAlign+' '+style.textBaseline] || 0;\n  },\n  noConflict : function () {\n    global.Flotr = previousFlotr;\n    return this;\n  }\n};\n\nglobal.Flotr = Flotr;\n\n})();\n\n/**\n * Flotr Defaults\n */\nFlotr.defaultOptions = {\n  colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.\n  ieBackgroundColor: '#FFFFFF', // Background color for excanvas clipping\n  title: null,             // => The graph's title\n  subtitle: null,          // => The graph's subtitle\n  shadowSize: 4,           // => size of the 'fake' shadow\n  defaultType: null,       // => default series type\n  HtmlText: true,          // => wether to draw the text using HTML or on the canvas\n  fontColor: '#545454',    // => default font color\n  fontSize: 7.5,           // => canvas' text font size\n  resolution: 1,           // => resolution of the graph, to have printer-friendly graphs !\n  parseFloat: true,        // => whether to preprocess data for floats (ie. if input is string)\n  preventDefault: true,    // => preventDefault by default for mobile events.  Turn off to enable scroll.\n  xaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 0,         // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => color of the ticks\n    mode: 'normal',        // => can be 'time' or 'normal'\n    timeFormat: null,\n    timeMode:'UTC',        // => For UTC time ('local' for local time).\n    timeUnit:'millisecond',// => Unit for time (millisecond, second, minute, hour, day, month, year)\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  x2axis: {},\n  yaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 90,        // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => The color of the ticks\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  y2axis: {\n    titleAngle: 270\n  },\n  grid: {\n    color: '#545454',      // => primary color used for outline and labels\n    backgroundColor: null, // => null for transparent, else color\n    backgroundImage: null, // => background image. String or object with src, left and top\n    watermarkAlpha: 0.4,   // => \n    tickColor: '#DDDDDD',  // => color used for the ticks\n    labelMargin: 3,        // => margin in pixels\n    verticalLines: true,   // => whether to show gridlines in vertical direction\n    minorVerticalLines: null, // => whether to show gridlines for minor ticks in vertical dir.\n    horizontalLines: true, // => whether to show gridlines in horizontal direction\n    minorHorizontalLines: null, // => whether to show gridlines for minor ticks in horizontal dir.\n    outlineWidth: 1,       // => width of the grid outline/border in pixels\n    outline : 'nsew',      // => walls of the outline to display\n    circular: false        // => if set to true, the grid will be circular, must be used when radars are drawn\n  },\n  mouse: {\n    track: false,          // => true to track the mouse, no tracking otherwise\n    trackAll: false,\n    position: 'se',        // => position of the value box (default south-east).  False disables.\n    relative: false,       // => next to the mouse cursor\n    trackFormatter: Flotr.defaultTrackFormatter, // => formats the values in the value box\n    margin: 5,             // => margin in pixels of the valuebox\n    lineColor: '#FF3F19',  // => line color of points that are drawn when mouse comes near a value of a series\n    trackDecimals: 1,      // => decimals for the track values\n    sensibility: 2,        // => the lower this number, the more precise you have to aim to show a value\n    trackY: true,          // => whether or not to track the mouse in the y axis\n    radius: 3,             // => radius of the track point\n    fillColor: null,       // => color to fill our select bar with only applies to bar and similar graphs (only bars for now)\n    fillOpacity: 0.4       // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill \n  }\n};\n\n/**\n * Flotr Color\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\n// Constructor\nfunction Color (r, g, b, a) {\n  this.rgba = ['r','g','b','a'];\n  var x = 4;\n  while(-1<--x){\n    this[this.rgba[x]] = arguments[x] || ((x==3) ? 1.0 : 0);\n  }\n  this.normalize();\n}\n\n// Constants\nvar COLOR_NAMES = {\n  aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],\n  brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],\n  darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],\n  darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],\n  darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],\n  khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],\n  lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],\n  maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],\n  violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]\n};\n\nColor.prototype = {\n  scale: function(rf, gf, bf, af){\n    var x = 4;\n    while (-1 < --x) {\n      if (!_.isUndefined(arguments[x])) this[this.rgba[x]] *= arguments[x];\n    }\n    return this.normalize();\n  },\n  alpha: function(alpha) {\n    if (!_.isUndefined(alpha) && !_.isNull(alpha)) {\n      this.a = alpha;\n    }\n    return this.normalize();\n  },\n  clone: function(){\n    return new Color(this.r, this.b, this.g, this.a);\n  },\n  limit: function(val,minVal,maxVal){\n    return Math.max(Math.min(val, maxVal), minVal);\n  },\n  normalize: function(){\n    var limit = this.limit;\n    this.r = limit(parseInt(this.r, 10), 0, 255);\n    this.g = limit(parseInt(this.g, 10), 0, 255);\n    this.b = limit(parseInt(this.b, 10), 0, 255);\n    this.a = limit(this.a, 0, 1);\n    return this;\n  },\n  distance: function(color){\n    if (!color) return;\n    color = new Color.parse(color);\n    var dist = 0, x = 3;\n    while(-1<--x){\n      dist += Math.abs(this[this.rgba[x]] - color[this.rgba[x]]);\n    }\n    return dist;\n  },\n  toString: function(){\n    return (this.a >= 1.0) ? 'rgb('+[this.r,this.g,this.b].join(',')+')' : 'rgba('+[this.r,this.g,this.b,this.a].join(',')+')';\n  },\n  contrast: function () {\n    var\n      test = 1 - ( 0.299 * this.r + 0.587 * this.g + 0.114 * this.b) / 255;\n    return (test < 0.5 ? '#000000' : '#ffffff');\n  }\n};\n\n_.extend(Color, {\n  /**\n   * Parses a color string and returns a corresponding Color.\n   * The different tests are in order of probability to improve speed.\n   * @param {String, Color} str - string thats representing a color\n   * @return {Color} returns a Color object or false\n   */\n  parse: function(color){\n    if (color instanceof Color) return color;\n\n    var result;\n\n    // #a0b1c2\n    if((result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)))\n      return new Color(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16));\n\n    // rgb(num,num,num)\n    if((result = /rgb\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10));\n  \n    // #fff\n    if((result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)))\n      return new Color(parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16));\n  \n    // rgba(num,num,num,num)\n    if((result = /rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10), parseFloat(result[4]));\n      \n    // rgb(num%,num%,num%)\n    if((result = /rgb\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55);\n  \n    // rgba(num%,num%,num%,num)\n    if((result = /rgba\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));\n\n    // Otherwise, we're most likely dealing with a named color.\n    var name = (color+'').replace(/^\\s*([\\S\\s]*?)\\s*$/, '$1').toLowerCase();\n    if(name == 'transparent'){\n      return new Color(255, 255, 255, 0);\n    }\n    return (result = COLOR_NAMES[name]) ? new Color(result[0], result[1], result[2]) : new Color(0, 0, 0, 0);\n  },\n\n  /**\n   * Process color and options into color style.\n   */\n  processColor: function(color, options) {\n\n    var opacity = options.opacity;\n    if (!color) return 'rgba(0, 0, 0, 0)';\n    if (color instanceof Color) return color.alpha(opacity).toString();\n    if (_.isString(color)) return Color.parse(color).alpha(opacity).toString();\n    \n    var grad = color.colors ? color : {colors: color};\n    \n    if (!options.ctx) {\n      if (!_.isArray(grad.colors)) return 'rgba(0, 0, 0, 0)';\n      return Color.parse(_.isArray(grad.colors[0]) ? grad.colors[0][1] : grad.colors[0]).alpha(opacity).toString();\n    }\n    grad = _.extend({start: 'top', end: 'bottom'}, grad); \n    \n    if (/top/i.test(grad.start))  options.x1 = 0;\n    if (/left/i.test(grad.start)) options.y1 = 0;\n    if (/bottom/i.test(grad.end)) options.x2 = 0;\n    if (/right/i.test(grad.end))  options.y2 = 0;\n\n    var i, c, stop, gradient = options.ctx.createLinearGradient(options.x1, options.y1, options.x2, options.y2);\n    for (i = 0; i < grad.colors.length; i++) {\n      c = grad.colors[i];\n      if (_.isArray(c)) {\n        stop = c[0];\n        c = c[1];\n      }\n      else stop = i / (grad.colors.length-1);\n      gradient.addColorStop(stop, Color.parse(c).alpha(opacity));\n    }\n    return gradient;\n  }\n});\n\nFlotr.Color = Color;\n\n})();\n\n/**\n * Flotr Date\n */\nFlotr.Date = {\n\n  set : function (date, name, mode, value) {\n    mode = mode || 'UTC';\n    name = 'set' + (mode === 'UTC' ? 'UTC' : '') + name;\n    date[name](value);\n  },\n\n  get : function (date, name, mode) {\n    mode = mode || 'UTC';\n    name = 'get' + (mode === 'UTC' ? 'UTC' : '') + name;\n    return date[name]();\n  },\n\n  format: function(d, format, mode) {\n    if (!d) return;\n\n    // We should maybe use an \"official\" date format spec, like PHP date() or ColdFusion \n    // http://fr.php.net/manual/en/function.date.php\n    // http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_29.html\n    var\n      get = this.get,\n      tokens = {\n        h: get(d, 'Hours', mode).toString(),\n        H: leftPad(get(d, 'Hours', mode)),\n        M: leftPad(get(d, 'Minutes', mode)),\n        S: leftPad(get(d, 'Seconds', mode)),\n        s: get(d, 'Milliseconds', mode),\n        d: get(d, 'Date', mode).toString(),\n        m: (get(d, 'Month', mode) + 1).toString(),\n        y: get(d, 'FullYear', mode).toString(),\n        b: Flotr.Date.monthNames[get(d, 'Month', mode)]\n      };\n\n    function leftPad(n){\n      n += '';\n      return n.length == 1 ? \"0\" + n : n;\n    }\n    \n    var r = [], c,\n        escape = false;\n    \n    for (var i = 0; i < format.length; ++i) {\n      c = format.charAt(i);\n      \n      if (escape) {\n        r.push(tokens[c] || c);\n        escape = false;\n      }\n      else if (c == \"%\")\n        escape = true;\n      else\n        r.push(c);\n    }\n    return r.join('');\n  },\n  getFormat: function(time, span) {\n    var tu = Flotr.Date.timeUnits;\n         if (time < tu.second) return \"%h:%M:%S.%s\";\n    else if (time < tu.minute) return \"%h:%M:%S\";\n    else if (time < tu.day)    return (span < 2 * tu.day) ? \"%h:%M\" : \"%b %d %h:%M\";\n    else if (time < tu.month)  return \"%b %d\";\n    else if (time < tu.year)   return (span < tu.year) ? \"%b\" : \"%b %y\";\n    else                       return \"%y\";\n  },\n  formatter: function (v, axis) {\n    var\n      options = axis.options,\n      scale = Flotr.Date.timeUnits[options.timeUnit],\n      d = new Date(v * scale);\n\n    // first check global format\n    if (axis.options.timeFormat)\n      return Flotr.Date.format(d, options.timeFormat, options.timeMode);\n    \n    var span = (axis.max - axis.min) * scale,\n        t = axis.tickSize * Flotr.Date.timeUnits[axis.tickUnit];\n\n    return Flotr.Date.format(d, Flotr.Date.getFormat(t, span), options.timeMode);\n  },\n  generator: function(axis) {\n\n     var\n      set       = this.set,\n      get       = this.get,\n      timeUnits = this.timeUnits,\n      spec      = this.spec,\n      options   = axis.options,\n      mode      = options.timeMode,\n      scale     = timeUnits[options.timeUnit],\n      min       = axis.min * scale,\n      max       = axis.max * scale,\n      delta     = (max - min) / options.noTicks,\n      ticks     = [],\n      tickSize  = axis.tickSize,\n      tickUnit,\n      formatter, i;\n\n    // Use custom formatter or time tick formatter\n    formatter = (options.tickFormatter === Flotr.defaultTickFormatter ?\n      this.formatter : options.tickFormatter\n    );\n\n    for (i = 0; i < spec.length - 1; ++i) {\n      var d = spec[i][0] * timeUnits[spec[i][1]];\n      if (delta < (d + spec[i+1][0] * timeUnits[spec[i+1][1]]) / 2 && d >= tickSize)\n        break;\n    }\n    tickSize = spec[i][0];\n    tickUnit = spec[i][1];\n\n    // special-case the possibility of several years\n    if (tickUnit == \"year\") {\n      tickSize = Flotr.getTickSize(options.noTicks*timeUnits.year, min, max, 0);\n\n      // Fix for 0.5 year case\n      if (tickSize == 0.5) {\n        tickUnit = \"month\";\n        tickSize = 6;\n      }\n    }\n\n    axis.tickUnit = tickUnit;\n    axis.tickSize = tickSize;\n\n    var step = tickSize * timeUnits[tickUnit];\n    d = new Date(min);\n\n    function setTick (name) {\n      set(d, name, mode, Flotr.floorInBase(\n        get(d, name, mode), tickSize\n      ));\n    }\n\n    switch (tickUnit) {\n      case \"millisecond\": setTick('Milliseconds'); break;\n      case \"second\": setTick('Seconds'); break;\n      case \"minute\": setTick('Minutes'); break;\n      case \"hour\": setTick('Hours'); break;\n      case \"month\": setTick('Month'); break;\n      case \"year\": setTick('FullYear'); break;\n    }\n    \n    // reset smaller components\n    if (step >= timeUnits.second)  set(d, 'Milliseconds', mode, 0);\n    if (step >= timeUnits.minute)  set(d, 'Seconds', mode, 0);\n    if (step >= timeUnits.hour)    set(d, 'Minutes', mode, 0);\n    if (step >= timeUnits.day)     set(d, 'Hours', mode, 0);\n    if (step >= timeUnits.day * 4) set(d, 'Date', mode, 1);\n    if (step >= timeUnits.year)    set(d, 'Month', mode, 0);\n\n    var carry = 0, v = NaN, prev;\n    do {\n      prev = v;\n      v = d.getTime();\n      ticks.push({ v: v / scale, label: formatter(v / scale, axis) });\n      if (tickUnit == \"month\") {\n        if (tickSize < 1) {\n          /* a bit complicated - we'll divide the month up but we need to take care of fractions\n           so we don't end up in the middle of a day */\n          set(d, 'Date', mode, 1);\n          var start = d.getTime();\n          set(d, 'Month', mode, get(d, 'Month', mode) + 1);\n          var end = d.getTime();\n          d.setTime(v + carry * timeUnits.hour + (end - start) * tickSize);\n          carry = get(d, 'Hours', mode);\n          set(d, 'Hours', mode, 0);\n        }\n        else\n          set(d, 'Month', mode, get(d, 'Month', mode) + tickSize);\n      }\n      else if (tickUnit == \"year\") {\n        set(d, 'FullYear', mode, get(d, 'FullYear', mode) + tickSize);\n      }\n      else\n        d.setTime(v + step);\n\n    } while (v < max && v != prev);\n\n    return ticks;\n  },\n  timeUnits: {\n    millisecond: 1,\n    second: 1000,\n    minute: 1000 * 60,\n    hour:   1000 * 60 * 60,\n    day:    1000 * 60 * 60 * 24,\n    month:  1000 * 60 * 60 * 24 * 30,\n    year:   1000 * 60 * 60 * 24 * 365.2425\n  },\n  // the allowed tick sizes, after 1 year we use an integer algorithm\n  spec: [\n    [1, \"millisecond\"], [20, \"millisecond\"], [50, \"millisecond\"], [100, \"millisecond\"], [200, \"millisecond\"], [500, \"millisecond\"], \n    [1, \"second\"],   [2, \"second\"],  [5, \"second\"], [10, \"second\"], [30, \"second\"], \n    [1, \"minute\"],   [2, \"minute\"],  [5, \"minute\"], [10, \"minute\"], [30, \"minute\"], \n    [1, \"hour\"],     [2, \"hour\"],    [4, \"hour\"],   [8, \"hour\"],    [12, \"hour\"],\n    [1, \"day\"],      [2, \"day\"],     [3, \"day\"],\n    [0.25, \"month\"], [0.5, \"month\"], [1, \"month\"],  [2, \"month\"],   [3, \"month\"], [6, \"month\"],\n    [1, \"year\"]\n  ],\n  monthNames: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n};\n\n(function () {\n\nvar _ = Flotr._;\n\nfunction getEl (el) {\n  return (el && el.jquery) ? el[0] : el;\n}\n\nFlotr.DOM = {\n  addClass: function(element, name){\n    element = getEl(element);\n    var classList = (element.className ? element.className : '');\n      if (_.include(classList.split(/\\s+/g), name)) return;\n    element.className = (classList ? classList + ' ' : '') + name;\n  },\n  /**\n   * Create an element.\n   */\n  create: function(tag){\n    return document.createElement(tag);\n  },\n  node: function(html) {\n    var div = Flotr.DOM.create('div'), n;\n    div.innerHTML = html;\n    n = div.children[0];\n    div.innerHTML = '';\n    return n;\n  },\n  /**\n   * Remove all children.\n   */\n  empty: function(element){\n    element = getEl(element);\n    element.innerHTML = '';\n    /*\n    if (!element) return;\n    _.each(element.childNodes, function (e) {\n      Flotr.DOM.empty(e);\n      element.removeChild(e);\n    });\n    */\n  },\n  remove: function (element) {\n    element = getEl(element);\n    element.parentNode.removeChild(element);\n  },\n  hide: function(element){\n    element = getEl(element);\n    Flotr.DOM.setStyles(element, {display:'none'});\n  },\n  /**\n   * Insert a child.\n   * @param {Element} element\n   * @param {Element|String} Element or string to be appended.\n   */\n  insert: function(element, child){\n    element = getEl(element);\n    if(_.isString(child))\n      element.innerHTML += child;\n    else if (_.isElement(child))\n      element.appendChild(child);\n  },\n  // @TODO find xbrowser implementation\n  opacity: function(element, opacity) {\n    element = getEl(element);\n    element.style.opacity = opacity;\n  },\n  position: function(element, p){\n    element = getEl(element);\n    if (!element.offsetParent)\n      return {left: (element.offsetLeft || 0), top: (element.offsetTop || 0)};\n\n    p = this.position(element.offsetParent);\n    p.left  += element.offsetLeft;\n    p.top   += element.offsetTop;\n    return p;\n  },\n  removeClass: function(element, name) {\n    var classList = (element.className ? element.className : '');\n    element = getEl(element);\n    element.className = _.filter(classList.split(/\\s+/g), function (c) {\n      if (c != name) return true; }\n    ).join(' ');\n  },\n  setStyles: function(element, o) {\n    element = getEl(element);\n    _.each(o, function (value, key) {\n      element.style[key] = value;\n    });\n  },\n  show: function(element){\n    element = getEl(element);\n    Flotr.DOM.setStyles(element, {display:''});\n  },\n  /**\n   * Return element size.\n   */\n  size: function(element){\n    element = getEl(element);\n    return {\n      height : element.offsetHeight,\n      width : element.offsetWidth };\n  }\n};\n\n})();\n\n/**\n * Flotr Event Adapter\n */\n(function () {\nvar\n  F = Flotr,\n  bean = F.bean;\nF.EventAdapter = {\n  observe: function(object, name, callback) {\n    bean.add(object, name, callback);\n    return this;\n  },\n  fire: function(object, name, args) {\n    bean.fire(object, name, args);\n    if (typeof(Prototype) != 'undefined')\n      Event.fire(object, name, args);\n    // @TODO Someone who uses mootools, add mootools adapter for existing applciations.\n    return this;\n  },\n  stopObserving: function(object, name, callback) {\n    bean.remove(object, name, callback);\n    return this;\n  },\n  eventPointer: function(e) {\n    if (!F._.isUndefined(e.touches) && e.touches.length > 0) {\n      return {\n        x : e.touches[0].pageX,\n        y : e.touches[0].pageY\n      };\n    } else if (!F._.isUndefined(e.changedTouches) && e.changedTouches.length > 0) {\n      return {\n        x : e.changedTouches[0].pageX,\n        y : e.changedTouches[0].pageY\n      };\n    } else if (e.pageX || e.pageY) {\n      return {\n        x : e.pageX,\n        y : e.pageY\n      };\n    } else if (e.clientX || e.clientY) {\n      var\n        d = document,\n        b = d.body,\n        de = d.documentElement;\n      return {\n        x: e.clientX + b.scrollLeft + de.scrollLeft,\n        y: e.clientY + b.scrollTop + de.scrollTop\n      };\n    }\n  }\n};\n})();\n\n/**\n * Text Utilities\n */\n(function () {\n\nvar\n  F = Flotr,\n  D = F.DOM,\n  _ = F._,\n\nText = function (o) {\n  this.o = o;\n};\n\nText.prototype = {\n\n  dimensions : function (text, canvasStyle, htmlStyle, className) {\n\n    if (!text) return { width : 0, height : 0 };\n    \n    return (this.o.html) ?\n      this.html(text, this.o.element, htmlStyle, className) : \n      this.canvas(text, canvasStyle);\n  },\n\n  canvas : function (text, style) {\n\n    if (!this.o.textEnabled) return;\n    style = style || {};\n\n    var\n      metrics = this.measureText(text, style),\n      width = metrics.width,\n      height = style.size || F.defaultOptions.fontSize,\n      angle = style.angle || 0,\n      cosAngle = Math.cos(angle),\n      sinAngle = Math.sin(angle),\n      widthPadding = 2,\n      heightPadding = 6,\n      bounds;\n\n    bounds = {\n      width: Math.abs(cosAngle * width) + Math.abs(sinAngle * height) + widthPadding,\n      height: Math.abs(sinAngle * width) + Math.abs(cosAngle * height) + heightPadding\n    };\n\n    return bounds;\n  },\n\n  html : function (text, element, style, className) {\n\n    var div = D.create('div');\n\n    D.setStyles(div, { 'position' : 'absolute', 'top' : '-10000px' });\n    D.insert(div, '<div style=\"'+style+'\" class=\"'+className+' flotr-dummy-div\">' + text + '</div>');\n    D.insert(this.o.element, div);\n\n    return D.size(div);\n  },\n\n  measureText : function (text, style) {\n\n    var\n      context = this.o.ctx,\n      metrics;\n\n    if (!context.fillText || (F.isIphone && context.measure)) {\n      return { width : context.measure(text, style)};\n    }\n\n    style = _.extend({\n      size: F.defaultOptions.fontSize,\n      weight: 1,\n      angle: 0\n    }, style);\n\n    context.save();\n    context.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    metrics = context.measureText(text);\n    context.restore();\n\n    return metrics;\n  }\n};\n\nFlotr.Text = Text;\n\n})();\n\n/**\n * Flotr Graph class that plots a graph on creation.\n */\n(function () {\n\nvar\n  D     = Flotr.DOM,\n  E     = Flotr.EventAdapter,\n  _     = Flotr._,\n  flotr = Flotr;\n/**\n * Flotr Graph constructor.\n * @param {Element} el - element to insert the graph into\n * @param {Object} data - an array or object of dataseries\n * @param {Object} options - an object containing options\n */\nGraph = function(el, data, options){\n// Let's see if we can get away with out this [JS]\n//  try {\n    this._setEl(el);\n    this._initMembers();\n    this._initPlugins();\n\n    E.fire(this.el, 'flotr:beforeinit', [this]);\n\n    this.data = data;\n    this.series = flotr.Series.getSeries(data);\n    this._initOptions(options);\n    this._initGraphTypes();\n    this._initCanvas();\n    this._text = new flotr.Text({\n      element : this.el,\n      ctx : this.ctx,\n      html : this.options.HtmlText,\n      textEnabled : this.textEnabled\n    });\n    E.fire(this.el, 'flotr:afterconstruct', [this]);\n    this._initEvents();\n\n    this.findDataRanges();\n    this.calculateSpacing();\n\n    this.draw(_.bind(function() {\n      E.fire(this.el, 'flotr:afterinit', [this]);\n    }, this));\n/*\n    try {\n  } catch (e) {\n    try {\n      console.error(e);\n    } catch (e2) {}\n  }*/\n};\n\nfunction observe (object, name, callback) {\n  E.observe.apply(this, arguments);\n  this._handles.push(arguments);\n  return this;\n}\n\nGraph.prototype = {\n\n  destroy: function () {\n    E.fire(this.el, 'flotr:destroy');\n    _.each(this._handles, function (handle) {\n      E.stopObserving.apply(this, handle);\n    });\n    this._handles = [];\n    this.el.graph = null;\n  },\n\n  observe : observe,\n\n  /**\n   * @deprecated\n   */\n  _observe : observe,\n\n  processColor: function(color, options){\n    var o = { x1: 0, y1: 0, x2: this.plotWidth, y2: this.plotHeight, opacity: 1, ctx: this.ctx };\n    _.extend(o, options);\n    return flotr.Color.processColor(color, o);\n  },\n  /**\n   * Function determines the min and max values for the xaxis and yaxis.\n   *\n   * TODO logarithmic range validation (consideration of 0)\n   */\n  findDataRanges: function(){\n    var a = this.axes,\n      xaxis, yaxis, range;\n\n    _.each(this.series, function (series) {\n      range = series.getRange();\n      if (range) {\n        xaxis = series.xaxis;\n        yaxis = series.yaxis;\n        xaxis.datamin = Math.min(range.xmin, xaxis.datamin);\n        xaxis.datamax = Math.max(range.xmax, xaxis.datamax);\n        yaxis.datamin = Math.min(range.ymin, yaxis.datamin);\n        yaxis.datamax = Math.max(range.ymax, yaxis.datamax);\n        xaxis.used = (xaxis.used || range.xused);\n        yaxis.used = (yaxis.used || range.yused);\n      }\n    }, this);\n\n    // Check for empty data, no data case (none used)\n    if (!a.x.used && !a.x2.used) a.x.used = true;\n    if (!a.y.used && !a.y2.used) a.y.used = true;\n\n    _.each(a, function (axis) {\n      axis.calculateRange();\n    });\n\n    var\n      types = _.keys(flotr.graphTypes),\n      drawn = false;\n\n    _.each(this.series, function (series) {\n      if (series.hide) return;\n      _.each(types, function (type) {\n        if (series[type] && series[type].show) {\n          this.extendRange(type, series);\n          drawn = true;\n        }\n      }, this);\n      if (!drawn) {\n        this.extendRange(this.options.defaultType, series);\n      }\n    }, this);\n  },\n\n  extendRange : function (type, series) {\n    if (this[type].extendRange) this[type].extendRange(series, series.data, series[type], this[type]);\n    if (this[type].extendYRange) this[type].extendYRange(series.yaxis, series.data, series[type], this[type]);\n    if (this[type].extendXRange) this[type].extendXRange(series.xaxis, series.data, series[type], this[type]);\n  },\n\n  /**\n   * Calculates axis label sizes.\n   */\n  calculateSpacing: function(){\n\n    var a = this.axes,\n        options = this.options,\n        series = this.series,\n        margin = options.grid.labelMargin,\n        T = this._text,\n        x = a.x,\n        x2 = a.x2,\n        y = a.y,\n        y2 = a.y2,\n        maxOutset = options.grid.outlineWidth,\n        i, j, l, dim;\n\n    // TODO post refactor, fix this\n    _.each(a, function (axis) {\n      axis.calculateTicks();\n      axis.calculateTextDimensions(T, options);\n    });\n\n    // Title height\n    dim = T.dimensions(\n      options.title,\n      {size: options.fontSize*1.5},\n      'font-size:1em;font-weight:bold;',\n      'flotr-title'\n    );\n    this.titleHeight = dim.height;\n\n    // Subtitle height\n    dim = T.dimensions(\n      options.subtitle,\n      {size: options.fontSize},\n      'font-size:smaller;',\n      'flotr-subtitle'\n    );\n    this.subtitleHeight = dim.height;\n\n    for(j = 0; j < options.length; ++j){\n      if (series[j].points.show){\n        maxOutset = Math.max(maxOutset, series[j].points.radius + series[j].points.lineWidth/2);\n      }\n    }\n\n    var p = this.plotOffset;\n    if (x.options.margin === false) {\n      p.bottom = 0;\n      p.top    = 0;\n    } else\n    if (x.options.margin === true) {\n      p.bottom += (options.grid.circular ? 0 : (x.used && x.options.showLabels ?  (x.maxLabel.height + margin) : 0)) +\n                  (x.used && x.options.title ? (x.titleSize.height + margin) : 0) + maxOutset;\n\n      p.top    += (options.grid.circular ? 0 : (x2.used && x2.options.showLabels ? (x2.maxLabel.height + margin) : 0)) +\n                  (x2.used && x2.options.title ? (x2.titleSize.height + margin) : 0) + this.subtitleHeight + this.titleHeight + maxOutset;\n    } else {\n      p.bottom = x.options.margin;\n      p.top = x.options.margin;\n    }\n    if (y.options.margin === false) {\n      p.left  = 0;\n      p.right = 0;\n    } else\n    if (y.options.margin === true) {\n      p.left   += (options.grid.circular ? 0 : (y.used && y.options.showLabels ?  (y.maxLabel.width + margin) : 0)) +\n                  (y.used && y.options.title ? (y.titleSize.width + margin) : 0) + maxOutset;\n\n      p.right  += (options.grid.circular ? 0 : (y2.used && y2.options.showLabels ? (y2.maxLabel.width + margin) : 0)) +\n                  (y2.used && y2.options.title ? (y2.titleSize.width + margin) : 0) + maxOutset;\n    } else {\n      p.left = y.options.margin;\n      p.right = y.options.margin;\n    }\n\n    p.top = Math.floor(p.top); // In order the outline not to be blured\n\n    this.plotWidth  = this.canvasWidth - p.left - p.right;\n    this.plotHeight = this.canvasHeight - p.bottom - p.top;\n\n    // TODO post refactor, fix this\n    x.length = x2.length = this.plotWidth;\n    y.length = y2.length = this.plotHeight;\n    y.offset = y2.offset = this.plotHeight;\n    x.setScale();\n    x2.setScale();\n    y.setScale();\n    y2.setScale();\n  },\n  /**\n   * Draws grid, labels, series and outline.\n   */\n  draw: function(after) {\n\n    var\n      context = this.ctx,\n      i;\n\n    E.fire(this.el, 'flotr:beforedraw', [this.series, this]);\n\n    if (this.series.length) {\n\n      context.save();\n      context.translate(this.plotOffset.left, this.plotOffset.top);\n\n      for (i = 0; i < this.series.length; i++) {\n        if (!this.series[i].hide) this.drawSeries(this.series[i]);\n      }\n\n      context.restore();\n      this.clip();\n    }\n\n    E.fire(this.el, 'flotr:afterdraw', [this.series, this]);\n    if (after) after();\n  },\n  /**\n   * Actually draws the graph.\n   * @param {Object} series - series to draw\n   */\n  drawSeries: function(series){\n\n    function drawChart (series, typeKey) {\n      var options = this.getOptions(series, typeKey);\n      this[typeKey].draw(options);\n    }\n\n    var drawn = false;\n    series = series || this.series;\n\n    _.each(flotr.graphTypes, function (type, typeKey) {\n      if (series[typeKey] && series[typeKey].show && this[typeKey]) {\n        drawn = true;\n        drawChart.call(this, series, typeKey);\n      }\n    }, this);\n\n    if (!drawn) drawChart.call(this, series, this.options.defaultType);\n  },\n\n  getOptions : function (series, typeKey) {\n    var\n      type = series[typeKey],\n      graphType = this[typeKey],\n      xaxis = series.xaxis,\n      yaxis = series.yaxis,\n      options = {\n        context     : this.ctx,\n        width       : this.plotWidth,\n        height      : this.plotHeight,\n        fontSize    : this.options.fontSize,\n        fontColor   : this.options.fontColor,\n        textEnabled : this.textEnabled,\n        htmlText    : this.options.HtmlText,\n        text        : this._text, // TODO Is this necessary?\n        element     : this.el,\n        data        : series.data,\n        color       : series.color,\n        shadowSize  : series.shadowSize,\n        xScale      : xaxis.d2p,\n        yScale      : yaxis.d2p,\n        xInverse    : xaxis.p2d,\n        yInverse    : yaxis.p2d\n      };\n\n    options = flotr.merge(type, options);\n\n    // Fill\n    options.fillStyle = this.processColor(\n      type.fillColor || series.color,\n      {opacity: type.fillOpacity}\n    );\n\n    return options;\n  },\n  /**\n   * Calculates the coordinates from a mouse event object.\n   * @param {Event} event - Mouse Event object.\n   * @return {Object} Object with coordinates of the mouse.\n   */\n  getEventPosition: function (e){\n\n    var\n      d = document,\n      b = d.body,\n      de = d.documentElement,\n      axes = this.axes,\n      plotOffset = this.plotOffset,\n      lastMousePos = this.lastMousePos,\n      pointer = E.eventPointer(e),\n      dx = pointer.x - lastMousePos.pageX,\n      dy = pointer.y - lastMousePos.pageY,\n      r, rx, ry;\n\n    if ('ontouchstart' in this.el) {\n      r = D.position(this.overlay);\n      rx = pointer.x - r.left - plotOffset.left;\n      ry = pointer.y - r.top - plotOffset.top;\n    } else {\n      r = this.overlay.getBoundingClientRect();\n      rx = e.clientX - r.left - plotOffset.left - b.scrollLeft - de.scrollLeft;\n      ry = e.clientY - r.top - plotOffset.top - b.scrollTop - de.scrollTop;\n    }\n\n    return {\n      x:  axes.x.p2d(rx),\n      x2: axes.x2.p2d(rx),\n      y:  axes.y.p2d(ry),\n      y2: axes.y2.p2d(ry),\n      relX: rx,\n      relY: ry,\n      dX: dx,\n      dY: dy,\n      absX: pointer.x,\n      absY: pointer.y,\n      pageX: pointer.x,\n      pageY: pointer.y\n    };\n  },\n  /**\n   * Observes the 'click' event and fires the 'flotr:click' event.\n   * @param {Event} event - 'click' Event object.\n   */\n  clickHandler: function(event){\n    if(this.ignoreClick){\n      this.ignoreClick = false;\n      return this.ignoreClick;\n    }\n    E.fire(this.el, 'flotr:click', [this.getEventPosition(event), this]);\n  },\n  /**\n   * Observes mouse movement over the graph area. Fires the 'flotr:mousemove' event.\n   * @param {Event} event - 'mousemove' Event object.\n   */\n  mouseMoveHandler: function(event){\n    if (this.mouseDownMoveHandler) return;\n    var pos = this.getEventPosition(event);\n    E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n    this.lastMousePos = pos;\n  },\n  /**\n   * Observes the 'mousedown' event.\n   * @param {Event} event - 'mousedown' Event object.\n   */\n  mouseDownHandler: function (event){\n\n    /*\n    // @TODO Context menu?\n    if(event.isRightClick()) {\n      event.stop();\n\n      var overlay = this.overlay;\n      overlay.hide();\n\n      function cancelContextMenu () {\n        overlay.show();\n        E.stopObserving(document, 'mousemove', cancelContextMenu);\n      }\n      E.observe(document, 'mousemove', cancelContextMenu);\n      return;\n    }\n    */\n\n    if (this.mouseUpHandler) return;\n    this.mouseUpHandler = _.bind(function (e) {\n      E.stopObserving(document, 'mouseup', this.mouseUpHandler);\n      E.stopObserving(document, 'mousemove', this.mouseDownMoveHandler);\n      this.mouseDownMoveHandler = null;\n      this.mouseUpHandler = null;\n      // @TODO why?\n      //e.stop();\n      E.fire(this.el, 'flotr:mouseup', [e, this]);\n    }, this);\n    this.mouseDownMoveHandler = _.bind(function (e) {\n        var pos = this.getEventPosition(e);\n        E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n        this.lastMousePos = pos;\n    }, this);\n    E.observe(document, 'mouseup', this.mouseUpHandler);\n    E.observe(document, 'mousemove', this.mouseDownMoveHandler);\n    E.fire(this.el, 'flotr:mousedown', [event, this]);\n    this.ignoreClick = false;\n  },\n  drawTooltip: function(content, x, y, options) {\n    var mt = this.getMouseTrack(),\n        style = 'opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;',\n        p = options.position,\n        m = options.margin,\n        plotOffset = this.plotOffset;\n\n    if(x !== null && y !== null){\n      if (!options.relative) { // absolute to the canvas\n             if(p.charAt(0) == 'n') style += 'top:' + (m + plotOffset.top) + 'px;bottom:auto;';\n        else if(p.charAt(0) == 's') style += 'bottom:' + (m + plotOffset.bottom) + 'px;top:auto;';\n             if(p.charAt(1) == 'e') style += 'right:' + (m + plotOffset.right) + 'px;left:auto;';\n        else if(p.charAt(1) == 'w') style += 'left:' + (m + plotOffset.left) + 'px;right:auto;';\n      }\n      else { // relative to the mouse\n             if(p.charAt(0) == 'n') style += 'bottom:' + (m - plotOffset.top - y + this.canvasHeight) + 'px;top:auto;';\n        else if(p.charAt(0) == 's') style += 'top:' + (m + plotOffset.top + y) + 'px;bottom:auto;';\n             if(p.charAt(1) == 'e') style += 'left:' + (m + plotOffset.left + x) + 'px;right:auto;';\n        else if(p.charAt(1) == 'w') style += 'right:' + (m - plotOffset.left - x + this.canvasWidth) + 'px;left:auto;';\n      }\n\n      mt.style.cssText = style;\n      D.empty(mt);\n      D.insert(mt, content);\n      D.show(mt);\n    }\n    else {\n      D.hide(mt);\n    }\n  },\n\n  clip: function (ctx) {\n\n    var\n      o   = this.plotOffset,\n      w   = this.canvasWidth,\n      h   = this.canvasHeight;\n\n    ctx = ctx || this.ctx;\n\n    if (\n      flotr.isIE && flotr.isIE < 9 && // IE w/o canvas\n      !flotr.isFlashCanvas // But not flash canvas\n    ) {\n\n      // Do not clip excanvas on overlay context\n      // Allow hits to overflow.\n      if (ctx === this.octx) {\n        return;\n      }\n\n      // Clipping for excanvas :-(\n      ctx.save();\n      ctx.fillStyle = this.processColor(this.options.ieBackgroundColor);\n      ctx.fillRect(0, 0, w, o.top);\n      ctx.fillRect(0, 0, o.left, h);\n      ctx.fillRect(0, h - o.bottom, w, o.bottom);\n      ctx.fillRect(w - o.right, 0, o.right,h);\n      ctx.restore();\n    } else {\n      ctx.clearRect(0, 0, w, o.top);\n      ctx.clearRect(0, 0, o.left, h);\n      ctx.clearRect(0, h - o.bottom, w, o.bottom);\n      ctx.clearRect(w - o.right, 0, o.right,h);\n    }\n  },\n\n  _initMembers: function() {\n    this._handles = [];\n    this.lastMousePos = {pageX: null, pageY: null };\n    this.plotOffset = {left: 0, right: 0, top: 0, bottom: 0};\n    this.ignoreClick = true;\n    this.prevHit = null;\n  },\n\n  _initGraphTypes: function() {\n    _.each(flotr.graphTypes, function(handler, graphType){\n      this[graphType] = flotr.clone(handler);\n    }, this);\n  },\n\n  _initEvents: function () {\n\n    var\n      el = this.el,\n      touchendHandler, movement, touchend;\n\n    if ('ontouchstart' in el) {\n\n      touchendHandler = _.bind(function (e) {\n        touchend = true;\n        E.stopObserving(document, 'touchend', touchendHandler);\n        E.fire(el, 'flotr:mouseup', [event, this]);\n        this.multitouches = null;\n\n        if (!movement) {\n          this.clickHandler(e);\n        }\n      }, this);\n\n      this.observe(this.overlay, 'touchstart', _.bind(function (e) {\n        movement = false;\n        touchend = false;\n        this.ignoreClick = false;\n\n        if (e.touches && e.touches.length > 1) {\n          this.multitouches = e.touches;\n        }\n\n        E.fire(el, 'flotr:mousedown', [event, this]);\n        this.observe(document, 'touchend', touchendHandler);\n      }, this));\n\n      this.observe(this.overlay, 'touchmove', _.bind(function (e) {\n\n        var pos = this.getEventPosition(e);\n\n        if (this.options.preventDefault) {\n          e.preventDefault();\n        }\n\n        movement = true;\n\n        if (this.multitouches || (e.touches && e.touches.length > 1)) {\n          this.multitouches = e.touches;\n        } else {\n          if (!touchend) {\n            E.fire(el, 'flotr:mousemove', [event, pos, this]);\n          }\n        }\n        this.lastMousePos = pos;\n      }, this));\n\n    } else {\n      this.\n        observe(this.overlay, 'mousedown', _.bind(this.mouseDownHandler, this)).\n        observe(el, 'mousemove', _.bind(this.mouseMoveHandler, this)).\n        observe(this.overlay, 'click', _.bind(this.clickHandler, this)).\n        observe(el, 'mouseout', function (e) {\n          E.fire(el, 'flotr:mouseout', e);\n        });\n    }\n  },\n\n  /**\n   * Initializes the canvas and it's overlay canvas element. When the browser is IE, this makes use\n   * of excanvas. The overlay canvas is inserted for displaying interactions. After the canvas elements\n   * are created, the elements are inserted into the container element.\n   */\n  _initCanvas: function(){\n    var el = this.el,\n      o = this.options,\n      children = el.children,\n      removedChildren = [],\n      child, i,\n      size, style;\n\n    // Empty the el\n    for (i = children.length; i--;) {\n      child = children[i];\n      if (!this.canvas && child.className === 'flotr-canvas') {\n        this.canvas = child;\n      } else if (!this.overlay && child.className === 'flotr-overlay') {\n        this.overlay = child;\n      } else {\n        removedChildren.push(child);\n      }\n    }\n    for (i = removedChildren.length; i--;) {\n      el.removeChild(removedChildren[i]);\n    }\n\n    D.setStyles(el, {position: 'relative'}); // For positioning labels and overlay.\n    size = {};\n    size.width = el.clientWidth;\n    size.height = el.clientHeight;\n\n    if(size.width <= 0 || size.height <= 0 || o.resolution <= 0){\n      throw 'Invalid dimensions for plot, width = ' + size.width + ', height = ' + size.height + ', resolution = ' + o.resolution;\n    }\n\n    // Main canvas for drawing graph types\n    this.canvas = getCanvas(this.canvas, 'canvas');\n    // Overlay canvas for interactive features\n    this.overlay = getCanvas(this.overlay, 'overlay');\n    this.ctx = getContext(this.canvas);\n    this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n    this.octx = getContext(this.overlay);\n    this.octx.clearRect(0, 0, this.overlay.width, this.overlay.height);\n    this.canvasHeight = size.height;\n    this.canvasWidth = size.width;\n    this.textEnabled = !!this.ctx.drawText || !!this.ctx.fillText; // Enable text functions\n\n    function getCanvas(canvas, name){\n      if(!canvas){\n        canvas = D.create('canvas');\n        if (typeof FlashCanvas != \"undefined\" && typeof canvas.getContext === 'function') {\n          FlashCanvas.initElement(canvas);\n          this.isFlashCanvas = true;\n        }\n        canvas.className = 'flotr-'+name;\n        canvas.style.cssText = 'position:absolute;left:0px;top:0px;';\n        D.insert(el, canvas);\n      }\n      _.each(size, function(size, attribute){\n        D.show(canvas);\n        if (name == 'canvas' && canvas.getAttribute(attribute) === size) {\n          return;\n        }\n        canvas.setAttribute(attribute, size * o.resolution);\n        canvas.style[attribute] = size + 'px';\n      });\n      canvas.context_ = null; // Reset the ExCanvas context\n      return canvas;\n    }\n\n    function getContext(canvas){\n      if(window.G_vmlCanvasManager) window.G_vmlCanvasManager.initElement(canvas); // For ExCanvas\n      var context = canvas.getContext('2d');\n      if(!window.G_vmlCanvasManager) context.scale(o.resolution, o.resolution);\n      return context;\n    }\n  },\n\n  _initPlugins: function(){\n    // TODO Should be moved to flotr and mixed in.\n    _.each(flotr.plugins, function(plugin, name){\n      _.each(plugin.callbacks, function(fn, c){\n        this.observe(this.el, c, _.bind(fn, this));\n      }, this);\n      this[name] = flotr.clone(plugin);\n      _.each(this[name], function(fn, p){\n        if (_.isFunction(fn))\n          this[name][p] = _.bind(fn, this);\n      }, this);\n    }, this);\n  },\n\n  /**\n   * Sets options and initializes some variables and color specific values, used by the constructor.\n   * @param {Object} opts - options object\n   */\n  _initOptions: function(opts){\n    var options = flotr.clone(flotr.defaultOptions);\n    options.x2axis = _.extend(_.clone(options.xaxis), options.x2axis);\n    options.y2axis = _.extend(_.clone(options.yaxis), options.y2axis);\n    this.options = flotr.merge(opts || {}, options);\n\n    if (this.options.grid.minorVerticalLines === null &&\n      this.options.xaxis.scaling === 'logarithmic') {\n      this.options.grid.minorVerticalLines = true;\n    }\n    if (this.options.grid.minorHorizontalLines === null &&\n      this.options.yaxis.scaling === 'logarithmic') {\n      this.options.grid.minorHorizontalLines = true;\n    }\n\n    E.fire(this.el, 'flotr:afterinitoptions', [this]);\n\n    this.axes = flotr.Axis.getAxes(this.options);\n\n    // Initialize some variables used throughout this function.\n    var assignedColors = [],\n        colors = [],\n        ln = this.series.length,\n        neededColors = this.series.length,\n        oc = this.options.colors,\n        usedColors = [],\n        variation = 0,\n        c, i, j, s;\n\n    // Collect user-defined colors from series.\n    for(i = neededColors - 1; i > -1; --i){\n      c = this.series[i].color;\n      if(c){\n        --neededColors;\n        if(_.isNumber(c)) assignedColors.push(c);\n        else usedColors.push(flotr.Color.parse(c));\n      }\n    }\n\n    // Calculate the number of colors that need to be generated.\n    for(i = assignedColors.length - 1; i > -1; --i)\n      neededColors = Math.max(neededColors, assignedColors[i] + 1);\n\n    // Generate needed number of colors.\n    for(i = 0; colors.length < neededColors;){\n      c = (oc.length == i) ? new flotr.Color(100, 100, 100) : flotr.Color.parse(oc[i]);\n\n      // Make sure each serie gets a different color.\n      var sign = variation % 2 == 1 ? -1 : 1,\n          factor = 1 + sign * Math.ceil(variation / 2) * 0.2;\n      c.scale(factor, factor, factor);\n\n      /**\n       * @todo if we're getting too close to something else, we should probably skip this one\n       */\n      colors.push(c);\n\n      if(++i >= oc.length){\n        i = 0;\n        ++variation;\n      }\n    }\n\n    // Fill the options with the generated colors.\n    for(i = 0, j = 0; i < ln; ++i){\n      s = this.series[i];\n\n      // Assign the color.\n      if (!s.color){\n        s.color = colors[j++].toString();\n      }else if(_.isNumber(s.color)){\n        s.color = colors[s.color].toString();\n      }\n\n      // Every series needs an axis\n      if (!s.xaxis) s.xaxis = this.axes.x;\n           if (s.xaxis == 1) s.xaxis = this.axes.x;\n      else if (s.xaxis == 2) s.xaxis = this.axes.x2;\n\n      if (!s.yaxis) s.yaxis = this.axes.y;\n           if (s.yaxis == 1) s.yaxis = this.axes.y;\n      else if (s.yaxis == 2) s.yaxis = this.axes.y2;\n\n      // Apply missing options to the series.\n      for (var t in flotr.graphTypes){\n        s[t] = _.extend(_.clone(this.options[t]), s[t]);\n      }\n      s.mouse = _.extend(_.clone(this.options.mouse), s.mouse);\n\n      if (_.isUndefined(s.shadowSize)) s.shadowSize = this.options.shadowSize;\n    }\n  },\n\n  _setEl: function(el) {\n    if (!el) throw 'The target container doesn\\'t exist';\n    else if (el.graph instanceof Graph) el.graph.destroy();\n    else if (!el.clientWidth) throw 'The target container must be visible';\n\n    el.graph = this;\n    this.el = el;\n  }\n};\n\nFlotr.Graph = Graph;\n\n})();\n\n/**\n * Flotr Axis Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._,\n  LOGARITHMIC = 'logarithmic';\n\nfunction Axis (o) {\n\n  this.orientation = 1;\n  this.offset = 0;\n  this.datamin = Number.MAX_VALUE;\n  this.datamax = -Number.MAX_VALUE;\n\n  _.extend(this, o);\n}\n\n\n// Prototype\nAxis.prototype = {\n\n  setScale : function () {\n    var\n      length = this.length,\n      max = this.max,\n      min = this.min,\n      offset = this.offset,\n      orientation = this.orientation,\n      options = this.options,\n      logarithmic = options.scaling === LOGARITHMIC,\n      scale;\n\n    if (logarithmic) {\n      scale = length / (log(max, options.base) - log(min, options.base));\n    } else {\n      scale = length / (max - min);\n    }\n    this.scale = scale;\n\n    // Logarithmic?\n    if (logarithmic) {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (log(dataValue, options.base) - log(min, options.base)) * scale;\n      };\n      this.p2d = function (pointValue) {\n        return exp((offset + orientation * pointValue) / scale + log(min, options.base), options.base);\n      };\n    } else {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (dataValue - min) * scale;\n      };\n      this.p2d = function (pointValue) {\n        return (offset + orientation * pointValue) / scale + min;\n      };\n    }\n  },\n\n  calculateTicks : function () {\n    var options = this.options;\n\n    this.ticks = [];\n    this.minorTicks = [];\n    \n    // User Ticks\n    if(options.ticks){\n      this._cleanUserTicks(options.ticks, this.ticks);\n      this._cleanUserTicks(options.minorTicks || [], this.minorTicks);\n    }\n    else {\n      if (options.mode == 'time') {\n        this._calculateTimeTicks();\n      } else if (options.scaling === 'logarithmic') {\n        this._calculateLogTicks();\n      } else {\n        this._calculateTicks();\n      }\n    }\n\n    // Ticks to strings\n    _.each(this.ticks, function (tick) { tick.label += ''; });\n    _.each(this.minorTicks, function (tick) { tick.label += ''; });\n  },\n\n  /**\n   * Calculates the range of an axis to apply autoscaling.\n   */\n  calculateRange: function () {\n\n    if (!this.used) return;\n\n    var axis  = this,\n      o       = axis.options,\n      min     = o.min !== null ? o.min : axis.datamin,\n      max     = o.max !== null ? o.max : axis.datamax,\n      margin  = o.autoscaleMargin;\n        \n    if (o.scaling == 'logarithmic') {\n      if (min <= 0) min = axis.datamin;\n\n      // Let it widen later on\n      if (max <= 0) max = min;\n    }\n\n    if (max == min) {\n      var widen = max ? 0.01 : 1.00;\n      if (o.min === null) min -= widen;\n      if (o.max === null) max += widen;\n    }\n\n    if (o.scaling === 'logarithmic') {\n      if (min < 0) min = max / o.base;  // Could be the result of widening\n\n      var maxexp = Math.log(max);\n      if (o.base != Math.E) maxexp /= Math.log(o.base);\n      maxexp = Math.ceil(maxexp);\n\n      var minexp = Math.log(min);\n      if (o.base != Math.E) minexp /= Math.log(o.base);\n      minexp = Math.ceil(minexp);\n      \n      axis.tickSize = Flotr.getTickSize(o.noTicks, minexp, maxexp, o.tickDecimals === null ? 0 : o.tickDecimals);\n                        \n      // Try to determine a suitable amount of miniticks based on the length of a decade\n      if (o.minorTickFreq === null) {\n        if (maxexp - minexp > 10)\n          o.minorTickFreq = 0;\n        else if (maxexp - minexp > 5)\n          o.minorTickFreq = 2;\n        else\n          o.minorTickFreq = 5;\n      }\n    } else {\n      axis.tickSize = Flotr.getTickSize(o.noTicks, min, max, o.tickDecimals);\n    }\n\n    axis.min = min;\n    axis.max = max; //extendRange may use axis.min or axis.max, so it should be set before it is caled\n\n    // Autoscaling. @todo This probably fails with log scale. Find a testcase and fix it\n    if(o.min === null && o.autoscale){\n      axis.min -= axis.tickSize * margin;\n      // Make sure we don't go below zero if all values are positive.\n      if(axis.min < 0 && axis.datamin >= 0) axis.min = 0;\n      axis.min = axis.tickSize * Math.floor(axis.min / axis.tickSize);\n    }\n    \n    if(o.max === null && o.autoscale){\n      axis.max += axis.tickSize * margin;\n      if(axis.max > 0 && axis.datamax <= 0 && axis.datamax != axis.datamin) axis.max = 0;        \n      axis.max = axis.tickSize * Math.ceil(axis.max / axis.tickSize);\n    }\n\n    if (axis.min == axis.max) axis.max = axis.min + 1;\n  },\n\n  calculateTextDimensions : function (T, options) {\n\n    var maxLabel = '',\n      length,\n      i;\n\n    if (this.options.showLabels) {\n      for (i = 0; i < this.ticks.length; ++i) {\n        length = this.ticks[i].label.length;\n        if (length > maxLabel.length){\n          maxLabel = this.ticks[i].label;\n        }\n      }\n    }\n\n    this.maxLabel = T.dimensions(\n      maxLabel,\n      {size:options.fontSize, angle: Flotr.toRad(this.options.labelsAngle)},\n      'font-size:smaller;',\n      'flotr-grid-label'\n    );\n\n    this.titleSize = T.dimensions(\n      this.options.title, \n      {size:options.fontSize*1.2, angle: Flotr.toRad(this.options.titleAngle)},\n      'font-weight:bold;',\n      'flotr-axis-title'\n    );\n  },\n\n  _cleanUserTicks : function (ticks, axisTicks) {\n\n    var axis = this, options = this.options,\n      v, i, label, tick;\n\n    if(_.isFunction(ticks)) ticks = ticks({min : axis.min, max : axis.max});\n\n    for(i = 0; i < ticks.length; ++i){\n      tick = ticks[i];\n      if(typeof(tick) === 'object'){\n        v = tick[0];\n        label = (tick.length > 1) ? tick[1] : options.tickFormatter(v, {min : axis.min, max : axis.max});\n      } else {\n        v = tick;\n        label = options.tickFormatter(v, {min : this.min, max : this.max});\n      }\n      axisTicks[i] = { v: v, label: label };\n    }\n  },\n\n  _calculateTimeTicks : function () {\n    this.ticks = Flotr.Date.generator(this);\n  },\n\n  _calculateLogTicks : function () {\n\n    var axis = this,\n      o = axis.options,\n      v,\n      decadeStart;\n\n    var max = Math.log(axis.max);\n    if (o.base != Math.E) max /= Math.log(o.base);\n    max = Math.ceil(max);\n\n    var min = Math.log(axis.min);\n    if (o.base != Math.E) min /= Math.log(o.base);\n    min = Math.ceil(min);\n    \n    for (i = min; i < max; i += axis.tickSize) {\n      decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n      // Next decade begins here:\n      var decadeEnd = decadeStart * ((o.base == Math.E) ? Math.exp(axis.tickSize) : Math.pow(o.base, axis.tickSize));\n      var stepSize = (decadeEnd - decadeStart) / o.minorTickFreq;\n      \n      axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n      for (v = decadeStart + stepSize; v < decadeEnd; v += stepSize)\n        axis.minorTicks.push({v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max})});\n    }\n    \n    // Always show the value at the would-be start of next decade (end of this decade)\n    decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n    axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n  },\n\n  _calculateTicks : function () {\n\n    var axis      = this,\n        o         = axis.options,\n        tickSize  = axis.tickSize,\n        min       = axis.min,\n        max       = axis.max,\n        start     = tickSize * Math.ceil(min / tickSize), // Round to nearest multiple of tick size.\n        decimals,\n        minorTickSize,\n        v, v2,\n        i, j;\n    \n    if (o.minorTickFreq)\n      minorTickSize = tickSize / o.minorTickFreq;\n                      \n    // Then store all possible ticks.\n    for (i = 0; (v = v2 = start + i * tickSize) <= max; ++i){\n      \n      // Round (this is always needed to fix numerical instability).\n      decimals = o.tickDecimals;\n      if (decimals === null) decimals = 1 - Math.floor(Math.log(tickSize) / Math.LN10);\n      if (decimals < 0) decimals = 0;\n      \n      v = v.toFixed(decimals);\n      axis.ticks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n\n      if (o.minorTickFreq) {\n        for (j = 0; j < o.minorTickFreq && (i * tickSize + j * minorTickSize) < max; ++j) {\n          v = v2 + j * minorTickSize;\n          axis.minorTicks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n        }\n      }\n    }\n\n  }\n};\n\n\n// Static Methods\n_.extend(Axis, {\n  getAxes : function (options) {\n    return {\n      x:  new Axis({options: options.xaxis,  n: 1, length: this.plotWidth}),\n      x2: new Axis({options: options.x2axis, n: 2, length: this.plotWidth}),\n      y:  new Axis({options: options.yaxis,  n: 1, length: this.plotHeight, offset: this.plotHeight, orientation: -1}),\n      y2: new Axis({options: options.y2axis, n: 2, length: this.plotHeight, offset: this.plotHeight, orientation: -1})\n    };\n  }\n});\n\n\n// Helper Methods\n\n\nfunction log (value, base) {\n  value = Math.log(Math.max(value, Number.MIN_VALUE));\n  if (base !== Math.E) \n    value /= Math.log(base);\n  return value;\n}\n\nfunction exp (value, base) {\n  return (base === Math.E) ? Math.exp(value) : Math.pow(base, value);\n}\n\nFlotr.Axis = Axis;\n\n})();\n\n/**\n * Flotr Series Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\nfunction Series (o) {\n  _.extend(this, o);\n}\n\nSeries.prototype = {\n\n  getRange: function () {\n\n    var\n      data = this.data,\n      length = data.length,\n      xmin = Number.MAX_VALUE,\n      ymin = Number.MAX_VALUE,\n      xmax = -Number.MAX_VALUE,\n      ymax = -Number.MAX_VALUE,\n      xused = false,\n      yused = false,\n      x, y, i;\n\n    if (length < 0 || this.hide) return false;\n\n    for (i = 0; i < length; i++) {\n      x = data[i][0];\n      y = data[i][1];\n      if (x !== null) {\n        if (x < xmin) { xmin = x; xused = true; }\n        if (x > xmax) { xmax = x; xused = true; }\n      }\n      if (y !== null) {\n        if (y < ymin) { ymin = y; yused = true; }\n        if (y > ymax) { ymax = y; yused = true; }\n      }\n    }\n\n    return {\n      xmin : xmin,\n      xmax : xmax,\n      ymin : ymin,\n      ymax : ymax,\n      xused : xused,\n      yused : yused\n    };\n  }\n};\n\n_.extend(Series, {\n  /**\n   * Collects dataseries from input and parses the series into the right format. It returns an Array \n   * of Objects each having at least the 'data' key set.\n   * @param {Array, Object} data - Object or array of dataseries\n   * @return {Array} Array of Objects parsed into the right format ({(...,) data: [[x1,y1], [x2,y2], ...] (, ...)})\n   */\n  getSeries: function(data){\n    return _.map(data, function(s){\n      var series;\n      if (s.data) {\n        series = new Series();\n        _.extend(series, s);\n      } else {\n        series = new Series({data:s});\n      }\n      return series;\n    });\n  }\n});\n\nFlotr.Series = Series;\n\n})();\n\n/** Lines **/\nFlotr.addType('lines', {\n  options: {\n    show: false,           // => setting to true will show lines, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: false,           // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillBorder: false,     // => draw a border around the fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    steps: false,          // => draw steps\n    stacked: false         // => setting to true will show stacked lines, false will show normal lines\n  },\n\n  stack : {\n    values : []\n  },\n\n  /**\n   * Draws lines series in the canvas element.\n   * @param {Object} options\n   */\n  draw : function (options) {\n\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize,\n      offset;\n\n    context.save();\n    context.lineJoin = 'round';\n\n    if (shadowSize) {\n\n      context.lineWidth = shadowSize / 2;\n      offset = lineWidth / 2 + context.lineWidth / 2;\n      \n      // @TODO do this instead with a linear gradient\n      context.strokeStyle = \"rgba(0,0,0,0.1)\";\n      this.plot(options, offset + shadowSize / 2, false);\n\n      context.strokeStyle = \"rgba(0,0,0,0.2)\";\n      this.plot(options, offset, false);\n    }\n\n    context.lineWidth = lineWidth;\n    context.strokeStyle = options.color;\n\n    this.plot(options, 0, true);\n\n    context.restore();\n  },\n\n  plot : function (options, shadowOffset, incStack) {\n\n    var\n      context   = options.context,\n      width     = options.width, \n      height    = options.height,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      data      = options.data, \n      stack     = options.stacked ? this.stack : false,\n      length    = data.length - 1,\n      prevx     = null,\n      prevy     = null,\n      zero      = yScale(0),\n      start     = null,\n      x1, x2, y1, y2, stack1, stack2, i;\n      \n    if (length < 1) return;\n\n    context.beginPath();\n\n    for (i = 0; i < length; ++i) {\n\n      // To allow empty values\n      if (data[i][1] === null || data[i+1][1] === null) {\n        if (options.fill) {\n          if (i > 0 && data[i][1] !== null) {\n            context.stroke();\n            fill();\n            start = null;\n            context.closePath();\n            context.beginPath();\n          }\n        }\n        continue;\n      }\n\n      // Zero is infinity for log scales\n      // TODO handle zero for logarithmic\n      // if (xa.options.scaling === 'logarithmic' && (data[i][0] <= 0 || data[i+1][0] <= 0)) continue;\n      // if (ya.options.scaling === 'logarithmic' && (data[i][1] <= 0 || data[i+1][1] <= 0)) continue;\n      \n      x1 = xScale(data[i][0]);\n      x2 = xScale(data[i+1][0]);\n\n      if (start === null) start = data[i];\n      \n      if (stack) {\n        stack1 = stack.values[data[i][0]] || 0;\n        stack2 = stack.values[data[i+1][0]] || stack.values[data[i][0]] || 0;\n        y1 = yScale(data[i][1] + stack1);\n        y2 = yScale(data[i+1][1] + stack2);\n        if (incStack) {\n          data[i].y0 = stack1;\n          stack.values[data[i][0]] = data[i][1] + stack1;\n          if (i == length-1) {\n            data[i+1].y0 = stack2;\n            stack.values[data[i+1][0]] = data[i+1][1] + stack2;\n          }\n        }\n      } else {\n        y1 = yScale(data[i][1]);\n        y2 = yScale(data[i+1][1]);\n      }\n\n      if (\n        (y1 > height && y2 > height) ||\n        (y1 < 0 && y2 < 0) ||\n        (x1 < 0 && x2 < 0) ||\n        (x1 > width && x2 > width)\n      ) continue;\n\n      if ((prevx != x1) || (prevy != y1 + shadowOffset)) {\n        context.moveTo(x1, y1 + shadowOffset);\n      }\n      \n      prevx = x2;\n      prevy = y2 + shadowOffset;\n      if (options.steps) {\n        context.lineTo(prevx + shadowOffset / 2, y1 + shadowOffset);\n        context.lineTo(prevx + shadowOffset / 2, prevy);\n      } else {\n        context.lineTo(prevx, prevy);\n      }\n    }\n    \n    if (!options.fill || options.fill && !options.fillBorder) context.stroke();\n\n    fill();\n\n    function fill () {\n      // TODO stacked lines\n      if(!shadowOffset && options.fill && start){\n        x1 = xScale(start[0]);\n        context.fillStyle = options.fillStyle;\n        context.lineTo(x2, zero);\n        context.lineTo(x1, zero);\n        context.lineTo(x1, yScale(start[1]));\n        context.fill();\n        if (options.fillBorder) {\n          context.stroke();\n        }\n      }\n    }\n\n    context.closePath();\n  },\n\n  // Perform any pre-render precalculations (this should be run on data first)\n  // - Pie chart total for calculating measures\n  // - Stacks for lines and bars\n  // precalculate : function () {\n  // }\n  //\n  //\n  // Get any bounds after pre calculation (axis can fetch this if does not have explicit min/max)\n  // getBounds : function () {\n  // }\n  // getMin : function () {\n  // }\n  // getMax : function () {\n  // }\n  //\n  //\n  // Padding around rendered elements\n  // getPadding : function () {\n  // }\n\n  extendYRange : function (axis, data, options, lines) {\n\n    var o = axis.options;\n\n    // If stacked and auto-min\n    if (options.stacked && ((!o.max && o.max !== 0) || (!o.min && o.min !== 0))) {\n\n      var\n        newmax = axis.max,\n        newmin = axis.min,\n        positiveSums = lines.positiveSums || {},\n        negativeSums = lines.negativeSums || {},\n        x, j;\n\n      for (j = 0; j < data.length; j++) {\n\n        x = data[j][0] + '';\n\n        // Positive\n        if (data[j][1] > 0) {\n          positiveSums[x] = (positiveSums[x] || 0) + data[j][1];\n          newmax = Math.max(newmax, positiveSums[x]);\n        }\n\n        // Negative\n        else {\n          negativeSums[x] = (negativeSums[x] || 0) + data[j][1];\n          newmin = Math.min(newmin, negativeSums[x]);\n        }\n      }\n\n      lines.negativeSums = negativeSums;\n      lines.positiveSums = positiveSums;\n\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n\n    if (options.steps) {\n\n      this.hit = function (options) {\n        var\n          data = options.data,\n          args = options.args,\n          yScale = options.yScale,\n          mouse = args[0],\n          length = data.length,\n          n = args[1],\n          x = options.xInverse(mouse.relX),\n          relY = mouse.relY,\n          i;\n\n        for (i = 0; i < length - 1; i++) {\n          if (x >= data[i][0] && x <= data[i+1][0]) {\n            if (Math.abs(yScale(data[i][1]) - relY) < 8) {\n              n.x = data[i][0];\n              n.y = data[i][1];\n              n.index = i;\n              n.seriesIndex = options.index;\n            }\n            break;\n          }\n        }\n      };\n\n      this.drawHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.save();\n          context.strokeStyle = options.color;\n          context.lineWidth = options.lineWidth;\n          context.beginPath();\n          context.moveTo(x, y);\n          context.lineTo(x2, y);\n          context.stroke();\n          context.closePath();\n          context.restore();\n        }\n      };\n\n      this.clearHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          width   = options.lineWidth,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.clearRect(x - width, y - width, x2 - x + 2 * width, 2 * width);\n        }\n      };\n    }\n  }\n\n});\n\n/** Bars **/\nFlotr.addType('bars', {\n\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    horizontal: false,     // => horizontal bars (x and y inverted)\n    stacked: false,        // => stacked bar charts\n    centered: true,        // => center the bars to their x axis value\n    topPadding: 0.1,       // => top padding in percent\n    grouped: false         // => groups bars together which share x value, hit not supported.\n  },\n\n  stack : { \n    positive : [],\n    negative : [],\n    _positive : [], // Shadow\n    _negative : []  // Shadow\n  },\n\n  draw : function (options) {\n    var\n      context = options.context;\n\n    this.current += 1;\n\n    context.save();\n    context.lineJoin = 'miter';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n    \n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      shadowSize      = options.shadowSize,\n      i, geometry, left, top, width, height;\n\n    if (data.length < 1) return;\n\n    this.translate(context, options.horizontal);\n\n    for (i = 0; i < data.length; i++) {\n\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (geometry === null) continue;\n\n      left    = geometry.left;\n      top     = geometry.top;\n      width   = geometry.width;\n      height  = geometry.height;\n\n      if (options.fill) context.fillRect(left, top, width, height);\n      if (shadowSize) {\n        context.save();\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top + shadowSize, width, height);\n        context.restore();\n      }\n      if (options.lineWidth) {\n        context.strokeRect(left, top, width, height);\n      }\n    }\n  },\n\n  translate : function (context, horizontal) {\n    if (horizontal) {\n      context.rotate(-Math.PI / 2);\n      context.scale(-1, 1);\n    }\n  },\n\n  getBarGeometry : function (x, y, options) {\n\n    var\n      horizontal    = options.horizontal,\n      barWidth      = options.barWidth,\n      centered      = options.centered,\n      stack         = options.stacked ? this.stack : false,\n      lineWidth     = options.lineWidth,\n      bisection     = centered ? barWidth / 2 : 0,\n      xScale        = horizontal ? options.yScale : options.xScale,\n      yScale        = horizontal ? options.xScale : options.yScale,\n      xValue        = horizontal ? y : x,\n      yValue        = horizontal ? x : y,\n      stackOffset   = 0,\n      stackValue, left, right, top, bottom;\n\n    if (options.grouped) {\n      this.current / this.groups;\n      xValue = xValue - bisection;\n      barWidth = barWidth / this.groups;\n      bisection = barWidth / 2;\n      xValue = xValue + barWidth * this.current - bisection;\n    }\n\n    // Stacked bars\n    if (stack) {\n      stackValue          = yValue > 0 ? stack.positive : stack.negative;\n      stackOffset         = stackValue[xValue] || stackOffset;\n      stackValue[xValue]  = stackOffset + yValue;\n    }\n\n    left    = xScale(xValue - bisection);\n    right   = xScale(xValue + barWidth - bisection);\n    top     = yScale(yValue + stackOffset);\n    bottom  = yScale(stackOffset);\n\n    // TODO for test passing... probably looks better without this\n    if (bottom < 0) bottom = 0;\n\n    // TODO Skipping...\n    // if (right < xa.min || left > xa.max || top < ya.min || bottom > ya.max) continue;\n\n    return (x === null || y === null) ? null : {\n      x         : xValue,\n      y         : yValue,\n      xScale    : xScale,\n      yScale    : yScale,\n      top       : top,\n      left      : Math.min(left, right) - lineWidth / 2,\n      width     : Math.abs(right - left) - lineWidth,\n      height    : bottom - top\n    };\n  },\n\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      x = options.xInverse(mouse.relX),\n      y = options.yInverse(mouse.relY),\n      hitGeometry = this.getBarGeometry(x, y, options),\n      width = hitGeometry.width / 2,\n      left = hitGeometry.left,\n      height = hitGeometry.y,\n      geometry, i;\n\n    for (i = data.length; i--;) {\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (\n        // Height:\n        (\n          // Positive Bars:\n          (height > 0 && height < geometry.y) ||\n          // Negative Bars:\n          (height < 0 && height > geometry.y)\n        ) &&\n        // Width:\n        (Math.abs(left - geometry.left) < width)\n      ) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n      }\n    }\n  },\n\n  drawHit : function (options) {\n    // TODO hits for stacked bars; implement using calculateStack option?\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      top         = geometry.top,\n      width       = geometry.width,\n      height      = geometry.height;\n\n    context.save();\n    context.strokeStyle = options.color;\n    context.lineWidth = options.lineWidth;\n    this.translate(context, options.horizontal);\n\n    // Draw highlight\n    context.beginPath();\n    context.moveTo(left, top + height);\n    context.lineTo(left, top);\n    context.lineTo(left + width, top);\n    context.lineTo(left + width, top + height);\n    if (options.fill) {\n      context.fillStyle = options.fillStyle;\n      context.fill();\n    }\n    context.stroke();\n    context.closePath();\n\n    context.restore();\n  },\n\n  clearHit: function (options) {\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      width       = geometry.width,\n      top         = geometry.top,\n      height      = geometry.height,\n      lineWidth   = 2 * options.lineWidth;\n\n    context.save();\n    this.translate(context, options.horizontal);\n    context.clearRect(\n      left - lineWidth,\n      Math.min(top, top + height) - lineWidth,\n      width + 2 * lineWidth,\n      Math.abs(height) + 2 * lineWidth\n    );\n    context.restore();\n  },\n\n  extendXRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n    this.groups = (this.groups + 1) || 1;\n    this.current = 0;\n  },\n\n  extendYRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n  },\n  _extendRange: function (axis, data, options, bars) {\n\n    var\n      max = axis.options.max;\n\n    if (_.isNumber(max) || _.isString(max)) return; \n\n    var\n      newmin = axis.min,\n      newmax = axis.max,\n      horizontal = options.horizontal,\n      orientation = axis.orientation,\n      positiveSums = this.positiveSums || {},\n      negativeSums = this.negativeSums || {},\n      value, datum, index, j;\n\n    // Sides of bars\n    if ((orientation == 1 && !horizontal) || (orientation == -1 && horizontal)) {\n      if (options.centered) {\n        newmax = Math.max(axis.datamax + options.barWidth, newmax);\n        newmin = Math.min(axis.datamin - options.barWidth, newmin);\n      }\n    }\n\n    if (options.stacked && \n        ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal))){\n\n      for (j = data.length; j--;) {\n        value = data[j][(orientation == 1 ? 1 : 0)]+'';\n        datum = data[j][(orientation == 1 ? 0 : 1)];\n\n        // Positive\n        if (datum > 0) {\n          positiveSums[value] = (positiveSums[value] || 0) + datum;\n          newmax = Math.max(newmax, positiveSums[value]);\n        }\n\n        // Negative\n        else {\n          negativeSums[value] = (negativeSums[value] || 0) + datum;\n          newmin = Math.min(newmin, negativeSums[value]);\n        }\n      }\n    }\n\n    // End of bars\n    if ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal)) {\n      if (options.topPadding && (axis.max === axis.datamax || (options.stacked && this.stackMax !== newmax))) {\n        newmax += options.topPadding * (newmax - newmin);\n      }\n    }\n\n    this.stackMin = newmin;\n    this.stackMax = newmax;\n    this.negativeSums = negativeSums;\n    this.positiveSums = positiveSums;\n\n    axis.max = newmax;\n    axis.min = newmin;\n  }\n\n});\n\n/** Bubbles **/\nFlotr.addType('bubbles', {\n  options: {\n    show: false,      // => setting to true will show radar chart, false will hide\n    lineWidth: 2,     // => line width in pixels\n    fill: true,       // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4, // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    baseRadius: 2     // => ratio of the radar, against the plot size\n  },\n  draw : function (options) {\n    var\n      context     = options.context,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    \n    // Shadows\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n\n    var\n      data    = options.data,\n      context = options.context,\n      geometry,\n      i, x, y, z;\n\n    offset = offset || 0;\n    \n    for (i = 0; i < data.length; ++i){\n\n      geometry = this.getGeometry(data[i], options);\n\n      context.beginPath();\n      context.arc(geometry.x + offset, geometry.y + offset, geometry.z, 0, 2 * Math.PI, true);\n      context.stroke();\n      if (options.fill) context.fill();\n      context.closePath();\n    }\n  },\n  getGeometry : function (point, options) {\n    return {\n      x : options.xScale(point[0]),\n      y : options.yScale(point[1]),\n      z : point[2] * options.baseRadius\n    };\n  },\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      relX = mouse.relX,\n      relY = mouse.relY,\n      distance,\n      geometry,\n      dx, dy;\n\n    n.best = n.best || Number.MAX_VALUE;\n\n    for (i = data.length; i--;) {\n      geometry = this.getGeometry(data[i], options);\n\n      dx = geometry.x - relX;\n      dy = geometry.y - relY;\n      distance = Math.sqrt(dx * dx + dy * dy);\n\n      if (distance < geometry.z && geometry.z < n.best) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n        n.best = geometry.z;\n      }\n    }\n  },\n  drawHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options);\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    context.fillStyle = options.fillStyle;\n    context.strokeStyle = options.color;\n    context.beginPath();\n    context.arc(geometry.x, geometry.y, geometry.z, 0, 2 * Math.PI, true);\n    context.fill();\n    context.stroke();\n    context.closePath();\n    context.restore();\n  },\n  clearHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options),\n      offset = geometry.z + options.lineWidth;\n\n    context.save();\n    context.clearRect(\n      geometry.x - offset, \n      geometry.y - offset,\n      2 * offset,\n      2 * offset\n    );\n    context.restore();\n  }\n  // TODO Add a hit calculation method (like pie)\n});\n\n/** Candles **/\nFlotr.addType('candles', {\n  options: {\n    show: false,           // => setting to true will show candle sticks, false will hide\n    lineWidth: 1,          // => in pixels\n    wickLineWidth: 1,      // => in pixels\n    candleWidth: 0.6,      // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    upFillColor: '#00A8F0',// => up sticks fill color\n    downFillColor: '#CB4B4B',// => down sticks fill color\n    fillOpacity: 0.5,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    barcharts: false       // => draw as barcharts (not standard bars but financial barcharts)\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin = 'miter';\n    context.lineCap = 'butt';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.wickLineWidth || options.lineWidth;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data          = options.data,\n      context       = options.context,\n      xScale        = options.xScale,\n      yScale        = options.yScale,\n      width         = options.candleWidth / 2,\n      shadowSize    = options.shadowSize,\n      lineWidth     = options.lineWidth,\n      wickLineWidth = options.wickLineWidth,\n      pixelOffset   = (wickLineWidth % 2) / 2,\n      color,\n      datum, x, y,\n      open, high, low, close,\n      left, right, bottom, top, bottom2, top2, reverseLines,\n      i;\n\n    if (data.length < 1) return;\n\n    for (i = 0; i < data.length; i++) {\n      datum   = data[i];\n      x       = datum[0];\n      open    = datum[1];\n      high    = datum[2];\n      low     = datum[3];\n      close   = datum[4];\n      left    = xScale(x - width);\n      right   = xScale(x + width);\n      bottom  = yScale(low);\n      top     = yScale(high);\n      bottom2 = yScale(Math.min(open, close));\n      top2    = yScale(Math.max(open, close));\n\n      /*\n      // TODO skipping\n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      */\n\n      color = options[open > close ? 'downFillColor' : 'upFillColor'];\n\n      // Fill the candle.\n      if (options.fill && !options.barcharts) {\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top2 + shadowSize, right - left, bottom2 - top2);\n        context.save();\n        context.globalAlpha = options.fillOpacity;\n        context.fillStyle = color;\n        context.fillRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n        context.restore();\n      }\n\n      // Draw candle outline/border, high, low.\n      if (lineWidth || wickLineWidth) {\n\n        x = Math.floor((left + right) / 2) + pixelOffset;\n\n        context.strokeStyle = color;\n        context.beginPath();\n\n        if (options.barcharts) {\n          context.moveTo(x, Math.floor(top + lineWidth));\n          context.lineTo(x, Math.floor(bottom + lineWidth));\n\n          reverseLines = open < close;\n          context.moveTo(reverseLines ? right : left, Math.floor(top2 + lineWidth));\n          context.lineTo(x, Math.floor(top2 + lineWidth));\n          context.moveTo(x, Math.floor(bottom2 + lineWidth));\n          context.lineTo(reverseLines ? left : right, Math.floor(bottom2 + lineWidth));\n        } else {\n          context.strokeRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n          context.moveTo(x, Math.floor(top2 + lineWidth));\n          context.lineTo(x, Math.floor(top + lineWidth));\n          context.moveTo(x, Math.floor(bottom2 + lineWidth));\n          context.lineTo(x, Math.floor(bottom + lineWidth));\n        }\n        \n        context.closePath();\n        context.stroke();\n      }\n    }\n  },\n\n  hit : function (options) {\n    var\n      xScale = options.xScale,\n      yScale = options.yScale,\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      width = options.candleWidth / 2,\n      n = args[1],\n      x = mouse.relX,\n      y = mouse.relY,\n      length = data.length,\n      i, datum,\n      high, low,\n      left, right, top, bottom;\n\n    for (i = 0; i < length; i++) {\n      datum   = data[i],\n      high    = datum[2];\n      low     = datum[3];\n      left    = xScale(datum[0] - width);\n      right   = xScale(datum[0] + width);\n      bottom  = yScale(low);\n      top     = yScale(high);\n\n      if (x > left && x < right && y > top && y < bottom) {\n        n.x = datum[0];\n        n.index = i;\n        n.seriesIndex = options.index;\n        return;\n      }\n    }\n  },\n\n  drawHit : function (options) {\n    var\n      context = options.context;\n    context.save();\n    this.plot(\n      _.defaults({\n        fill : !!options.fillColor,\n        upFillColor : options.color,\n        downFillColor : options.color,\n        data : [options.data[options.args.index]]\n      }, options)\n    );\n    context.restore();\n  },\n\n  clearHit : function (options) {\n    var\n      args = options.args,\n      context = options.context,\n      xScale = options.xScale,\n      yScale = options.yScale,\n      lineWidth = options.lineWidth,\n      width = options.candleWidth / 2,\n      bar = options.data[args.index],\n      left = xScale(bar[0] - width) - lineWidth,\n      right = xScale(bar[0] + width) + lineWidth,\n      top = yScale(bar[2]),\n      bottom = yScale(bar[3]) + lineWidth;\n    context.clearRect(left, top, right - left, bottom - top);\n  },\n\n  extendXRange: function (axis, data, options) {\n    if (axis.options.max === null) {\n      axis.max = Math.max(axis.datamax + 0.5, axis.max);\n      axis.min = Math.min(axis.datamin - 0.5, axis.min);\n    }\n  }\n});\n\n/** Gantt\n * Base on data in form [s,y,d] where:\n * y - executor or simply y value\n * s - task start value\n * d - task duration\n * **/\nFlotr.addType('gantt', {\n  options: {\n    show: false,           // => setting to true will show gantt, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    centered: true         // => center the bars to their x axis value\n  },\n  /**\n   * Draws gantt series in the canvas element.\n   * @param {Object} series - Series with options.gantt.show = true.\n   */\n  draw: function(series) {\n    var ctx = this.ctx,\n      bw = series.gantt.barWidth,\n      lw = Math.min(series.gantt.lineWidth, bw);\n    \n    ctx.save();\n    ctx.translate(this.plotOffset.left, this.plotOffset.top);\n    ctx.lineJoin = 'miter';\n\n    /**\n     * @todo linewidth not interpreted the right way.\n     */\n    ctx.lineWidth = lw;\n    ctx.strokeStyle = series.color;\n    \n    ctx.save();\n    this.gantt.plotShadows(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n    \n    if(series.gantt.fill){\n      var color = series.gantt.fillColor || series.color;\n      ctx.fillStyle = this.processColor(color, {opacity: series.gantt.fillOpacity});\n    }\n    \n    this.gantt.plot(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n  },\n  plot: function(series, barWidth, offset, fill){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx, i;\n\n    for(i = 0; i < data.length; i++){\n      var y = data[i][0],\n          s = data[i][1],\n          d = data[i][2],\n          drawLeft = true, drawTop = true, drawRight = true;\n      \n      if (s === null || d === null) continue;\n\n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n      \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n\n      if(left < xa.min){\n        left = xa.min;\n        drawLeft = false;\n      }\n\n      if(right > xa.max){\n        right = xa.max;\n        if (xa.lastSerie != series)\n          drawTop = false;\n      }\n\n      if(bottom < ya.min)\n        bottom = ya.min;\n\n      if(top > ya.max){\n        top = ya.max;\n        if (ya.lastSerie != series)\n          drawTop = false;\n      }\n      \n      /**\n       * Fill the bar.\n       */\n      if(fill){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        ctx.lineTo(xa.d2p(left), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(bottom) + offset);\n        ctx.fill();\n        ctx.closePath();\n      }\n\n      /**\n       * Draw bar outline/border.\n       */\n      if(series.gantt.lineWidth && (drawLeft || drawRight || drawTop)){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        \n        ctx[drawLeft ?'lineTo':'moveTo'](xa.d2p(left), ya.d2p(top) + offset);\n        ctx[drawTop  ?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(top) + offset);\n        ctx[drawRight?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(bottom) + offset);\n                 \n        ctx.stroke();\n        ctx.closePath();\n      }\n    }\n  },\n  plotShadows: function(series, barWidth, offset){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var i, y, s, d,\n        xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx,\n        sw = this.options.shadowSize;\n    \n    for(i = 0; i < data.length; i++){\n      y = data[i][0];\n      s = data[i][1];\n      d = data[i][2];\n        \n      if (s === null || d === null) continue;\n            \n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      \n      if(left < xa.min)   left = xa.min;\n      if(right > xa.max)  right = xa.max;\n      if(bottom < ya.min) bottom = ya.min;\n      if(top > ya.max)    top = ya.max;\n      \n      var width =  xa.d2p(right)-xa.d2p(left)-((xa.d2p(right)+sw <= this.plotWidth) ? 0 : sw);\n      var height = ya.d2p(bottom)-ya.d2p(top)-((ya.d2p(bottom)+sw <= this.plotHeight) ? 0 : sw );\n      \n      ctx.fillStyle = 'rgba(0,0,0,0.05)';\n      ctx.fillRect(Math.min(xa.d2p(left)+sw, this.plotWidth), Math.min(ya.d2p(top)+sw, this.plotHeight), width, height);\n    }\n  },\n  extendXRange: function(axis) {\n    if(axis.options.max === null){\n      var newmin = axis.min,\n          newmax = axis.max,\n          i, j, x, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n\n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if(g.show && s.xaxis == axis) {\n            for (j = 0; j < s.data.length; j++) {\n              if (g.show) {\n                y = s.data[j][0]+'';\n                stackedSumsPos[y] = Math.max((stackedSumsPos[y] || 0), s.data[j][1]+s.data[j][2]);\n                lastSerie = s;\n              }\n            }\n            for (j in stackedSumsPos) {\n              newmax = Math.max(stackedSumsPos[j], newmax);\n            }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n  },\n  extendYRange: function(axis){\n    if(axis.options.max === null){\n      var newmax = Number.MIN_VALUE,\n          newmin = Number.MAX_VALUE,\n          i, j, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n                  \n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if (g.show && !s.hide && s.yaxis == axis) {\n          var datamax = Number.MIN_VALUE, datamin = Number.MAX_VALUE;\n          for(j=0; j < s.data.length; j++){\n            datamax = Math.max(datamax,s.data[j][0]);\n            datamin = Math.min(datamin,s.data[j][0]);\n          }\n            \n          if (g.centered) {\n            newmax = Math.max(datamax + 0.5, newmax);\n            newmin = Math.min(datamin - 0.5, newmin);\n          }\n        else {\n          newmax = Math.max(datamax + 1, newmax);\n            newmin = Math.min(datamin, newmin);\n          }\n          // For normal horizontal bars\n          if (g.barWidth + datamax > newmax){\n            newmax = axis.max + g.barWidth;\n          }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n      axis.tickSize = Flotr.getTickSize(axis.options.noTicks, newmin, newmax, axis.options.tickDecimals);\n    }\n  }\n});\n\n/** Markers **/\n/**\n * Formats the marker labels.\n * @param {Object} obj - Marker value Object {x:..,y:..}\n * @return {String} Formatted marker string\n */\n(function () {\n\nFlotr.defaultMarkerFormatter = function(obj){\n  return (Math.round(obj.y*100)/100)+'';\n};\n\nFlotr.addType('markers', {\n  options: {\n    show: false,           // => setting to true will show markers, false will hide\n    lineWidth: 1,          // => line width of the rectangle around the marker\n    color: '#000000',      // => text color\n    fill: false,           // => fill or not the marekers' rectangles\n    fillColor: \"#FFFFFF\",  // => fill color\n    fillOpacity: 0.4,      // => fill opacity\n    stroke: false,         // => draw the rectangle around the markers\n    position: 'ct',        // => the markers position (vertical align: b, m, t, horizontal align: l, c, r)\n    verticalMargin: 0,     // => the margin between the point and the text.\n    labelFormatter: Flotr.defaultMarkerFormatter,\n    fontSize: Flotr.defaultOptions.fontSize,\n    stacked: false,        // => true if markers should be stacked\n    stackingType: 'b',     // => define staching behavior, (b- bars like, a - area like) (see Issue 125 for details)\n    horizontal: false      // => true if markers should be horizontal (For now only in a case on horizontal stacked bars, stacks should be calculated horizontaly)\n  },\n\n  // TODO test stacked markers.\n  stack : {\n      positive : [],\n      negative : [],\n      values : []\n  },\n\n  draw : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      stack           = options.stacked ? options.stack : false,\n      stackType       = options.stackingType,\n      stackOffsetNeg,\n      stackOffsetPos,\n      stackOffset,\n      i, x, y, label;\n\n    context.save();\n    context.lineJoin = 'round';\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = 'rgba(0,0,0,0.5)';\n    context.fillStyle = options.fillStyle;\n\n    function stackPos (a, b) {\n      stackOffsetPos = stack.negative[a] || 0;\n      stackOffsetNeg = stack.positive[a] || 0;\n      if (b > 0) {\n        stack.positive[a] = stackOffsetPos + b;\n        return stackOffsetPos + b;\n      } else {\n        stack.negative[a] = stackOffsetNeg + b;\n        return stackOffsetNeg + b;\n      }\n    }\n\n    for (i = 0; i < data.length; ++i) {\n    \n      x = data[i][0];\n      y = data[i][1];\n        \n      if (stack) {\n        if (stackType == 'b') {\n          if (options.horizontal) y = stackPos(y, x);\n          else x = stackPos(x, y);\n        } else if (stackType == 'a') {\n          stackOffset = stack.values[x] || 0;\n          stack.values[x] = stackOffset + y;\n          y = stackOffset + y;\n        }\n      }\n\n      label = options.labelFormatter({x: x, y: y, index: i, data : data});\n      this.plot(options.xScale(x), options.yScale(y), label, options);\n    }\n    context.restore();\n  },\n  plot: function(x, y, label, options) {\n    var context = options.context;\n    if (isImage(label) && !label.complete) {\n      throw 'Marker image not loaded.';\n    } else {\n      this._plot(x, y, label, options);\n    }\n  },\n\n  _plot: function(x, y, label, options) {\n    var context = options.context,\n        margin = 2,\n        left = x,\n        top = y,\n        dim;\n\n    if (isImage(label))\n      dim = {height : label.height, width: label.width};\n    else\n      dim = options.text.canvas(label);\n\n    dim.width = Math.floor(dim.width+margin*2);\n    dim.height = Math.floor(dim.height+margin*2);\n\n         if (options.position.indexOf('c') != -1) left -= dim.width/2 + margin;\n    else if (options.position.indexOf('l') != -1) left -= dim.width;\n    \n         if (options.position.indexOf('m') != -1) top -= dim.height/2 + margin;\n    else if (options.position.indexOf('t') != -1) top -= dim.height + options.verticalMargin;\n    else top += options.verticalMargin;\n    \n    left = Math.floor(left)+0.5;\n    top = Math.floor(top)+0.5;\n    \n    if(options.fill)\n      context.fillRect(left, top, dim.width, dim.height);\n      \n    if(options.stroke)\n      context.strokeRect(left, top, dim.width, dim.height);\n    \n    if (isImage(label))\n      context.drawImage(label, parseInt(left+margin, 10), parseInt(top+margin, 10));\n    else\n      Flotr.drawText(context, label, left+margin, top+margin, {textBaseline: 'top', textAlign: 'left', size: options.fontSize, color: options.color});\n  }\n});\n\nfunction isImage (i) {\n  return typeof i === 'object' && i.constructor && (Image ? true : i.constructor === Image);\n}\n\n})();\n\n/**\n * Pie\n *\n * Formats the pies labels.\n * @param {Object} slice - Slice object\n * @return {String} Formatted pie label string\n */\n(function () {\n\nvar\n  _ = Flotr._;\n\nFlotr.defaultPieLabelFormatter = function (total, value) {\n  return (100 * value / total).toFixed(2)+'%';\n};\n\nFlotr.addType('pie', {\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 1,          // => in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.6,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    explode: 6,            // => the number of pixels the splices will be far from the center\n    sizeRatio: 0.6,        // => the size ratio of the pie relative to the plot \n    startAngle: Math.PI/4, // => the first slice start angle\n    labelFormatter: Flotr.defaultPieLabelFormatter,\n    pie3D: false,          // => whether to draw the pie in 3 dimenstions or not (ineffective) \n    pie3DviewAngle: (Math.PI/2 * 0.8),\n    pie3DspliceThickness: 20,\n    epsilon: 0.1           // => how close do you have to get to hit empty slice\n  },\n\n  draw : function (options) {\n\n    // TODO 3D charts what?\n    var\n      data          = options.data,\n      context       = options.context,\n      lineWidth     = options.lineWidth,\n      shadowSize    = options.shadowSize,\n      sizeRatio     = options.sizeRatio,\n      height        = options.height,\n      width         = options.width,\n      explode       = options.explode,\n      color         = options.color,\n      fill          = options.fill,\n      fillStyle     = options.fillStyle,\n      radius        = Math.min(width, height) * sizeRatio / 2,\n      value         = data[0][1],\n      html          = [],\n      vScale        = 1,//Math.cos(series.pie.viewAngle);\n      measure       = Math.PI * 2 * value / this.total,\n      startAngle    = this.startAngle || (2 * Math.PI * options.startAngle), // TODO: this initial startAngle is already in radians (fixing will be test-unstable)\n      endAngle      = startAngle + measure,\n      bisection     = startAngle + measure / 2,\n      label         = options.labelFormatter(this.total, value),\n      //plotTickness  = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;\n      explodeCoeff  = explode + radius + 4,\n      distX         = Math.cos(bisection) * explodeCoeff,\n      distY         = Math.sin(bisection) * explodeCoeff,\n      textAlign     = distX < 0 ? 'right' : 'left',\n      textBaseline  = distY > 0 ? 'top' : 'bottom',\n      style,\n      x, y;\n    \n    context.save();\n    context.translate(width / 2, height / 2);\n    context.scale(1, vScale);\n\n    x = Math.cos(bisection) * explode;\n    y = Math.sin(bisection) * explode;\n\n    // Shadows\n    if (shadowSize > 0) {\n      this.plotSlice(x + shadowSize, y + shadowSize, radius, startAngle, endAngle, context);\n      if (fill) {\n        context.fillStyle = 'rgba(0,0,0,0.1)';\n        context.fill();\n      }\n    }\n\n    this.plotSlice(x, y, radius, startAngle, endAngle, context);\n    if (fill) {\n      context.fillStyle = fillStyle;\n      context.fill();\n    }\n    context.lineWidth = lineWidth;\n    context.strokeStyle = color;\n    context.stroke();\n\n    style = {\n      size : options.fontSize * 1.2,\n      color : options.fontColor,\n      weight : 1.5\n    };\n\n    if (label) {\n      if (options.htmlText || !options.textEnabled) {\n        divStyle = 'position:absolute;' + textBaseline + ':' + (height / 2 + (textBaseline === 'top' ? distY : -distY)) + 'px;';\n        divStyle += textAlign + ':' + (width / 2 + (textAlign === 'right' ? -distX : distX)) + 'px;';\n        html.push('<div style=\"', divStyle, '\" class=\"flotr-grid-label\">', label, '</div>');\n      }\n      else {\n        style.textAlign = textAlign;\n        style.textBaseline = textBaseline;\n        Flotr.drawText(context, label, distX, distY, style);\n      }\n    }\n    \n    if (options.htmlText || !options.textEnabled) {\n      var div = Flotr.DOM.node('<div style=\"color:' + options.fontColor + '\" class=\"flotr-labels\"></div>');\n      Flotr.DOM.insert(div, html.join(''));\n      Flotr.DOM.insert(options.element, div);\n    }\n    \n    context.restore();\n\n    // New start angle\n    this.startAngle = endAngle;\n    this.slices = this.slices || [];\n    this.slices.push({\n      radius : radius,\n      x : x,\n      y : y,\n      explode : explode,\n      start : startAngle,\n      end : endAngle\n    });\n  },\n  plotSlice : function (x, y, radius, startAngle, endAngle, context) {\n    context.beginPath();\n    context.moveTo(x, y);\n    context.arc(x, y, radius, startAngle, endAngle, false);\n    context.lineTo(x, y);\n    context.closePath();\n  },\n  hit : function (options) {\n\n    var\n      data      = options.data[0],\n      args      = options.args,\n      index     = options.index,\n      mouse     = args[0],\n      n         = args[1],\n      slice     = this.slices[index],\n      x         = mouse.relX - options.width / 2,\n      y         = mouse.relY - options.height / 2,\n      r         = Math.sqrt(x * x + y * y),\n      theta     = Math.atan(y / x),\n      circle    = Math.PI * 2,\n      explode   = slice.explode || options.explode,\n      start     = slice.start % circle,\n      end       = slice.end % circle,\n      epsilon   = options.epsilon;\n\n    if (x < 0) {\n      theta += Math.PI;\n    } else if (x > 0 && y < 0) {\n      theta += circle;\n    }\n\n    if (r < slice.radius + explode && r > explode) {\n      if (\n          (theta > start && theta < end) || // Normal Slice\n          (start > end && (theta < end || theta > start)) || // First slice\n          // TODO: Document the two cases at the end:\n          (start === end && ((slice.start === slice.end && Math.abs(theta - start) < epsilon) || (slice.start !== slice.end && Math.abs(theta-start) > epsilon)))\n         ) {\n          \n          // TODO Decouple this from hit plugin (chart shouldn't know what n means)\n         n.x = data[0];\n         n.y = data[1];\n         n.sAngle = start;\n         n.eAngle = end;\n         n.index = 0;\n         n.seriesIndex = index;\n         n.fraction = data[1] / this.total;\n      }\n    }\n  },\n  drawHit: function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex];\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    this.plotSlice(slice.x, slice.y, slice.radius, slice.start, slice.end, context);\n    context.stroke();\n    context.restore();\n  },\n  clearHit : function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex],\n      padding = 2 * options.lineWidth,\n      radius = slice.radius + padding;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.clearRect(\n      slice.x - radius,\n      slice.y - radius,\n      2 * radius + padding,\n      2 * radius + padding \n    );\n    context.restore();\n  },\n  extendYRange : function (axis, data) {\n    this.total = (this.total || 0) + data[0][1];\n  }\n});\n})();\n\n/** Points **/\nFlotr.addType('points', {\n  options: {\n    show: false,           // => setting to true will show points, false will hide\n    radius: 3,             // => point radius (pixels)\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the points with a color, false for (transparent) no fill\n    fillColor: '#FFFFFF',  // => fill color.  Null to use series color.\n    fillOpacity: 1,        // => opacity of color inside the points\n    hitRadius: null        // => override for points hit radius\n  },\n\n  draw : function (options) {\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n\n    if (shadowSize > 0) {\n      context.lineWidth = shadowSize / 2;\n      \n      context.strokeStyle = 'rgba(0,0,0,0.1)';\n      this.plot(options, shadowSize / 2 + context.lineWidth / 2);\n\n      context.strokeStyle = 'rgba(0,0,0,0.2)';\n      this.plot(options, context.lineWidth / 2);\n    }\n\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n\n    this.plot(options);\n    context.restore();\n  },\n\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      xScale  = options.xScale,\n      yScale  = options.yScale,\n      i, x, y;\n      \n    for (i = data.length - 1; i > -1; --i) {\n      y = data[i][1];\n      if (y === null) continue;\n\n      x = xScale(data[i][0]);\n      y = yScale(y);\n\n      if (x < 0 || x > options.width || y < 0 || y > options.height) continue;\n      \n      context.beginPath();\n      if (offset) {\n        context.arc(x, y + offset, options.radius, 0, Math.PI, false);\n      } else {\n        context.arc(x, y, options.radius, 0, 2 * Math.PI, true);\n        if (options.fill) context.fill();\n      }\n      context.stroke();\n      context.closePath();\n    }\n  }\n});\n\n/** Radar **/\nFlotr.addType('radar', {\n  options: {\n    show: false,           // => setting to true will show radar chart, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    radiusRatio: 0.90,      // => ratio of the radar, against the plot size\n    sensibility: 2         // => the lower this number, the more precise you have to aim to show a value.\n  },\n  draw : function (options) {\n    var\n      context = options.context,\n      shadowSize = options.shadowSize;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.lineWidth = options.lineWidth;\n    \n    // Shadow\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      radius  = Math.min(options.height, options.width) * options.radiusRatio / 2,\n      step    = 2 * Math.PI / data.length,\n      angle   = -Math.PI / 2,\n      i, ratio;\n\n    offset = offset || 0;\n\n    context.beginPath();\n    for (i = 0; i < data.length; ++i) {\n      ratio = data[i][1] / this.max;\n\n      context[i === 0 ? 'moveTo' : 'lineTo'](\n        Math.cos(i * step + angle) * radius * ratio + offset,\n        Math.sin(i * step + angle) * radius * ratio + offset\n      );\n    }\n    context.closePath();\n    if (options.fill) context.fill();\n    context.stroke();\n  },\n  getGeometry : function (point, options) {\n    var\n      radius  = Math.min(options.height, options.width) * options.radiusRatio / 2,\n      step    = 2 * Math.PI / options.data.length,\n      angle   = -Math.PI / 2,\n      ratio = point[1] / this.max;\n\n    return {\n      x : (Math.cos(point[0] * step + angle) * radius * ratio) + options.width / 2,\n      y : (Math.sin(point[0] * step + angle) * radius * ratio) + options.height / 2\n    };\n  },\n  hit : function (options) {\n    var\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      relX = mouse.relX,\n      relY = mouse.relY,\n      distance,\n      geometry,\n      dx, dy;\n\n      for (var i = 0; i < n.series.length; i++) {\n        var serie = n.series[i];\n        var data = serie.data;\n\n        for (var j = data.length; j--;) {\n          geometry = this.getGeometry(data[j], options);\n\n          dx = geometry.x - relX;\n          dy = geometry.y - relY;\n          distance = Math.sqrt(dx * dx + dy * dy);\n\n          if (distance <  options.sensibility*2) {\n            n.x = data[j][0];\n            n.y = data[j][1];\n            n.index = j;\n            n.seriesIndex = i;\n            return n;\n          }\n        }\n      }\n    },\n  drawHit : function (options) {\n    var step = 2 * Math.PI / options.data.length;\n    var angle   = -Math.PI / 2;\n    var radius  = Math.min(options.height, options.width) * options.radiusRatio / 2;\n\n    var s = options.args.series;\n    var point_radius = s.points.hitRadius || s.points.radius || s.mouse.radius;\n\n    var context = options.context;\n\n    context.translate(options.width / 2, options.height / 2);\n\n    var j = options.args.index;\n    var ratio = options.data[j][1] / this.max;\n    var x = Math.cos(j * step + angle) * radius * ratio;\n    var y = Math.sin(j * step + angle) * radius * ratio;\n    context.beginPath();\n    context.arc(x, y, point_radius , 0, 2 * Math.PI, true);\n    context.closePath();\n    context.stroke();\n  },\n  clearHit : function (options) {\n    var step = 2 * Math.PI / options.data.length;\n    var angle   = -Math.PI / 2;\n    var radius  = Math.min(options.height, options.width) * options.radiusRatio / 2;\n\n    var context = options.context;\n\n    var\n        s = options.args.series,\n        lw = (s.points ? s.points.lineWidth : 1);\n        offset = (s.points.hitRadius || s.points.radius || s.mouse.radius) + lw;\n\n    context.translate(options.width / 2, options.height / 2);\n\n    var j = options.args.index;\n    var ratio = options.data[j][1] / this.max;\n    var x = Math.cos(j * step + angle) * radius * ratio;\n    var y = Math.sin(j * step + angle) * radius * ratio;\n    context.clearRect(x-offset,y-offset,offset*2,offset*2);\n  },\n  extendYRange : function (axis, data) {\n    this.max = Math.max(axis.max, this.max || -Number.MAX_VALUE);\n  }\n});\n\nFlotr.addType('timeline', {\n  options: {\n    show: false,\n    lineWidth: 1,\n    barWidth: 0.2,\n    fill: true,\n    fillColor: null,\n    fillOpacity: 0.4,\n    centered: true\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin    = 'miter';\n    context.lineWidth   = options.lineWidth;\n    context.strokeStyle = options.color;\n    context.fillStyle   = options.fillStyle;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data      = options.data,\n      context   = options.context,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      barWidth  = options.barWidth,\n      lineWidth = options.lineWidth,\n      i;\n\n    Flotr._.each(data, function (timeline) {\n\n      var \n        x   = timeline[0],\n        y   = timeline[1],\n        w   = timeline[2],\n        h   = barWidth,\n\n        xt  = Math.ceil(xScale(x)),\n        wt  = Math.ceil(xScale(x + w)) - xt,\n        yt  = Math.round(yScale(y)),\n        ht  = Math.round(yScale(y - h)) - yt,\n\n        x0  = xt - lineWidth / 2,\n        y0  = Math.round(yt - ht / 2) - lineWidth / 2;\n\n      context.strokeRect(x0, y0, wt, ht);\n      context.fillRect(x0, y0, wt, ht);\n\n    });\n  },\n\n  extendRange : function (series) {\n\n    var\n      data  = series.data,\n      xa    = series.xaxis,\n      ya    = series.yaxis,\n      w     = series.timeline.barWidth;\n\n    if (xa.options.min === null)\n      xa.min = xa.datamin - w / 2;\n\n    if (xa.options.max === null) {\n\n      var\n        max = xa.max;\n\n      Flotr._.each(data, function (timeline) {\n        max = Math.max(max, timeline[0] + timeline[2]);\n      }, this);\n\n      xa.max = max + w / 2;\n    }\n\n    if (ya.options.min === null)\n      ya.min = ya.datamin - w;\n    if (ya.options.min === null)\n      ya.max = ya.datamax + w;\n  }\n\n});\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('crosshair', {\n  options: {\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#FF0000',      // => crosshair color\n    hideCursor: true       // => hide the cursor when the crosshair is shown\n  },\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      if (this.options.crosshair.mode) {\n        this.crosshair.clearCrosshair();\n        this.crosshair.drawCrosshair(pos);\n      }\n    }\n  },\n  /**   \n   * Draws the selection box.\n   */\n  drawCrosshair: function(pos) {\n    var octx = this.octx,\n      options = this.options.crosshair,\n      plotOffset = this.plotOffset,\n      x = plotOffset.left + Math.round(pos.relX) + 0.5,\n      y = plotOffset.top + Math.round(pos.relY) + 0.5;\n    \n    if (pos.relX < 0 || pos.relY < 0 || pos.relX > this.plotWidth || pos.relY > this.plotHeight) {\n      this.el.style.cursor = null;\n      D.removeClass(this.el, 'flotr-crosshair');\n      return; \n    }\n    \n    if (options.hideCursor) {\n      this.el.style.cursor = 'none';\n      D.addClass(this.el, 'flotr-crosshair');\n    }\n    \n    octx.save();\n    octx.strokeStyle = options.color;\n    octx.lineWidth = 1;\n    octx.beginPath();\n    \n    if (options.mode.indexOf('x') != -1) {\n      octx.moveTo(x, plotOffset.top);\n      octx.lineTo(x, plotOffset.top + this.plotHeight);\n    }\n    \n    if (options.mode.indexOf('y') != -1) {\n      octx.moveTo(plotOffset.left, y);\n      octx.lineTo(plotOffset.left + this.plotWidth, y);\n    }\n    \n    octx.stroke();\n    octx.restore();\n  },\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearCrosshair: function() {\n\n    var\n      plotOffset = this.plotOffset,\n      position = this.lastMousePos,\n      context = this.octx;\n\n    if (position) {\n      context.clearRect(\n        Math.round(position.relX) + plotOffset.left,\n        plotOffset.top,\n        1,\n        this.plotHeight + 1\n      );\n      context.clearRect(\n        plotOffset.left,\n        Math.round(position.relY) + plotOffset.top,\n        this.plotWidth + 1,\n        1\n      );    \n    }\n  }\n});\n})();\n\n(function() {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nfunction getImage (type, canvas, context, width, height, background) {\n\n  // TODO add scaling for w / h\n  var\n    mime = 'image/'+type,\n    data = context.getImageData(0, 0, width, height),\n    image = new Image();\n\n  context.save();\n  context.globalCompositeOperation = 'destination-over';\n  context.fillStyle = background;\n  context.fillRect(0, 0, width, height);\n  image.src = canvas.toDataURL(mime);\n  context.restore();\n\n  context.clearRect(0, 0, width, height);\n  context.putImageData(data, 0, 0);\n\n  return image;\n}\n\nFlotr.addPlugin('download', {\n\n  saveImage: function (type, width, height, replaceCanvas) {\n    var\n      grid = this.options.grid,\n      image;\n\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      image = '<html><body>'+this.canvas.firstChild.innerHTML+'</body></html>';\n      return window.open().document.write(image);\n    }\n\n    if (type !== 'jpeg' && type !== 'png') return;\n\n    image = getImage(\n      type, this.canvas, this.ctx,\n      this.canvasWidth, this.canvasHeight,\n      grid && grid.backgroundColor || '#ffffff'\n    );\n\n    if (_.isElement(image) && replaceCanvas) {\n      this.download.restoreCanvas();\n      D.hide(this.canvas);\n      D.hide(this.overlay);\n      D.setStyles({position: 'absolute'});\n      D.insert(this.el, image);\n      this.saveImageElement = image;\n    } else {\n      return window.open(image.src);\n    }\n  },\n\n  restoreCanvas: function() {\n    D.show(this.canvas);\n    D.show(this.overlay);\n    if (this.saveImageElement) this.el.removeChild(this.saveImageElement);\n    this.saveImageElement = null;\n  }\n});\n\n})();\n\n(function () {\n\nvar E = Flotr.EventAdapter,\n    _ = Flotr._;\n\nFlotr.addPlugin('graphGrid', {\n\n  callbacks: {\n    'flotr:beforedraw' : function () {\n      this.graphGrid.drawGrid();\n    },\n    'flotr:afterdraw' : function () {\n      this.graphGrid.drawOutline();\n    }\n  },\n\n  drawGrid: function(){\n\n    var\n      ctx = this.ctx,\n      options = this.options,\n      grid = options.grid,\n      verticalLines = grid.verticalLines,\n      horizontalLines = grid.horizontalLines,\n      minorVerticalLines = grid.minorVerticalLines,\n      minorHorizontalLines = grid.minorHorizontalLines,\n      plotHeight = this.plotHeight,\n      plotWidth = this.plotWidth,\n      a, v, i, j;\n        \n    if(verticalLines || minorVerticalLines || \n           horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:beforegrid', [this.axes.x, this.axes.y, options, this]);\n    }\n    ctx.save();\n    ctx.lineWidth = 1;\n    ctx.strokeStyle = grid.tickColor;\n    \n    function circularHorizontalTicks (ticks) {\n      for(i = 0; i < ticks.length; ++i){\n        var ratio = ticks[i].v / a.max;\n        for(j = 0; j <= sides; ++j){\n          ctx[j === 0 ? 'moveTo' : 'lineTo'](\n            Math.cos(j*coeff+angle)*radius*ratio,\n            Math.sin(j*coeff+angle)*radius*ratio\n          );\n        }\n      }\n    }\n    function drawGridLines (ticks, callback) {\n      _.each(_.pluck(ticks, 'v'), function(v){\n        // Don't show lines on upper and lower bounds.\n        if ((v <= a.min || v >= a.max) || \n            (v == a.min || v == a.max) && grid.outlineWidth)\n          return;\n        callback(Math.floor(a.d2p(v)) + ctx.lineWidth/2);\n      });\n    }\n    function drawVerticalLines (x) {\n      ctx.moveTo(x, 0);\n      ctx.lineTo(x, plotHeight);\n    }\n    function drawHorizontalLines (y) {\n      ctx.moveTo(0, y);\n      ctx.lineTo(plotWidth, y);\n    }\n\n    if (grid.circular) {\n      ctx.translate(this.plotOffset.left+plotWidth/2, this.plotOffset.top+plotHeight/2);\n      var radius = Math.min(plotHeight, plotWidth)*options.radar.radiusRatio/2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw grid lines in vertical direction.\n      ctx.beginPath();\n      \n      a = this.axes.y;\n\n      if(horizontalLines){\n        circularHorizontalTicks(a.ticks);\n      }\n      if(minorHorizontalLines){\n        circularHorizontalTicks(a.minorTicks);\n      }\n      \n      if(verticalLines){\n        _.times(sides, function(i){\n          ctx.moveTo(0, 0);\n          ctx.lineTo(Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n        });\n      }\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(this.plotOffset.left, this.plotOffset.top);\n  \n      // Draw grid background, if present in options.\n      if(grid.backgroundColor){\n        ctx.fillStyle = this.processColor(grid.backgroundColor, {x1: 0, y1: 0, x2: plotWidth, y2: plotHeight});\n        ctx.fillRect(0, 0, plotWidth, plotHeight);\n      }\n      \n      ctx.beginPath();\n\n      a = this.axes.x;\n      if (verticalLines)        drawGridLines(a.ticks, drawVerticalLines);\n      if (minorVerticalLines)   drawGridLines(a.minorTicks, drawVerticalLines);\n\n      a = this.axes.y;\n      if (horizontalLines)      drawGridLines(a.ticks, drawHorizontalLines);\n      if (minorHorizontalLines) drawGridLines(a.minorTicks, drawHorizontalLines);\n\n      ctx.stroke();\n    }\n    \n    ctx.restore();\n    if(verticalLines || minorVerticalLines ||\n       horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:aftergrid', [this.axes.x, this.axes.y, options, this]);\n    }\n  }, \n\n  drawOutline: function(){\n    var\n      that = this,\n      options = that.options,\n      grid = options.grid,\n      outline = grid.outline,\n      ctx = that.ctx,\n      backgroundImage = grid.backgroundImage,\n      plotOffset = that.plotOffset,\n      leftOffset = plotOffset.left,\n      topOffset = plotOffset.top,\n      plotWidth = that.plotWidth,\n      plotHeight = that.plotHeight,\n      v, img, src, left, top, globalAlpha;\n    \n    if (!grid.outlineWidth) return;\n    \n    ctx.save();\n    \n    if (grid.circular) {\n      ctx.translate(leftOffset + plotWidth / 2, topOffset + plotHeight / 2);\n      var radius = Math.min(plotHeight, plotWidth) * options.radar.radiusRatio / 2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw axis/grid border.\n      ctx.beginPath();\n      ctx.lineWidth = grid.outlineWidth;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'round';\n      \n      for(i = 0; i <= sides; ++i){\n        ctx[i === 0 ? 'moveTo' : 'lineTo'](Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n      }\n      //ctx.arc(0, 0, radius, 0, Math.PI*2, true);\n\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(leftOffset, topOffset);\n      \n      // Draw axis/grid border.\n      var lw = grid.outlineWidth,\n          orig = 0.5-lw+((lw+1)%2/2),\n          lineTo = 'lineTo',\n          moveTo = 'moveTo';\n      ctx.lineWidth = lw;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'miter';\n      ctx.beginPath();\n      ctx.moveTo(orig, orig);\n      plotWidth = plotWidth - (lw / 2) % 1;\n      plotHeight = plotHeight + lw / 2;\n      ctx[outline.indexOf('n') !== -1 ? lineTo : moveTo](plotWidth, orig);\n      ctx[outline.indexOf('e') !== -1 ? lineTo : moveTo](plotWidth, plotHeight);\n      ctx[outline.indexOf('s') !== -1 ? lineTo : moveTo](orig, plotHeight);\n      ctx[outline.indexOf('w') !== -1 ? lineTo : moveTo](orig, orig);\n      ctx.stroke();\n      ctx.closePath();\n    }\n    \n    ctx.restore();\n\n    if (backgroundImage) {\n\n      src = backgroundImage.src || backgroundImage;\n      left = (parseInt(backgroundImage.left, 10) || 0) + plotOffset.left;\n      top = (parseInt(backgroundImage.top, 10) || 0) + plotOffset.top;\n      img = new Image();\n\n      img.onload = function() {\n        ctx.save();\n        if (backgroundImage.alpha) ctx.globalAlpha = backgroundImage.alpha;\n        ctx.globalCompositeOperation = 'destination-over';\n        ctx.drawImage(img, 0, 0, img.width, img.height, left, top, plotWidth, plotHeight);\n        ctx.restore();\n      };\n\n      img.src = src;\n    }\n  }\n});\n\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._,\n  flotr = Flotr,\n  S_MOUSETRACK = 'opacity:0.7;background-color:#000;color:#fff;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;';\n\nFlotr.addPlugin('hit', {\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      this.hit.track(pos);\n    },\n    'flotr:click': function(pos) {\n      var\n        hit = this.hit.track(pos);\n      if (hit && !_.isUndefined(hit.index)) pos.hit = hit;\n    },\n    'flotr:mouseout': function(e) {\n      if (e.relatedTarget !== this.mouseTrack) {\n        this.hit.clearHit();\n      }\n    },\n    'flotr:destroy': function() {\n      if (this.options.mouse.container) {\n        D.remove(this.mouseTrack);\n      }\n      this.mouseTrack = null;\n    }\n  },\n  track : function (pos) {\n    if (this.options.mouse.track || _.any(this.series, function(s){return s.mouse && s.mouse.track;})) {\n      return this.hit.hit(pos);\n    }\n  },\n  /**\n   * Try a method on a graph type.  If the method exists, execute it.\n   * @param {Object} series\n   * @param {String} method  Method name.\n   * @param {Array} args  Arguments applied to method.\n   * @return executed successfully or failed.\n   */\n  executeOnType: function(s, method, args){\n    var\n      success = false,\n      options;\n\n    if (!_.isArray(s)) s = [s];\n\n    function e(s, index) {\n      _.each(_.keys(flotr.graphTypes), function (type) {\n        if (s[type] && s[type].show && !s.hide && this[type][method]) {\n          options = this.getOptions(s, type);\n\n          options.fill = !!s.mouse.fillColor;\n          options.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n          options.color = s.mouse.lineColor;\n          options.context = this.octx;\n          options.index = index;\n\n          if (args) options.args = args;\n          this[type][method].call(this[type], options);\n          success = true;\n        }\n      }, this);\n    }\n    _.each(s, e, this);\n\n    return success;\n  },\n  /**\n   * Updates the mouse tracking point on the overlay.\n   */\n  drawHit: function(n){\n    var octx = this.octx,\n      s = n.series;\n\n    if (s.mouse.lineColor) {\n      octx.save();\n      octx.lineWidth = (s.points ? s.points.lineWidth : 1);\n      octx.strokeStyle = s.mouse.lineColor;\n      octx.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n      octx.translate(this.plotOffset.left, this.plotOffset.top);\n\n      if (!this.hit.executeOnType(s, 'drawHit', n)) {\n        var\n          xa = n.xaxis,\n          ya = n.yaxis;\n\n        octx.beginPath();\n          // TODO fix this (points) should move to general testable graph mixin\n          octx.arc(xa.d2p(n.x), ya.d2p(n.y), s.points.hitRadius || s.points.radius || s.mouse.radius, 0, 2 * Math.PI, true);\n          octx.fill();\n          octx.stroke();\n        octx.closePath();\n      }\n      octx.restore();\n      this.clip(octx);\n    }\n    this.prevHit = n;\n  },\n  /**\n   * Removes the mouse tracking point from the overlay.\n   */\n  clearHit: function(){\n    var prev = this.prevHit,\n        octx = this.octx,\n        plotOffset = this.plotOffset;\n    octx.save();\n    octx.translate(plotOffset.left, plotOffset.top);\n    if (prev) {\n      if (!this.hit.executeOnType(prev.series, 'clearHit', this.prevHit)) {\n        // TODO fix this (points) should move to general testable graph mixin\n        var\n          s = prev.series,\n          lw = (s.points ? s.points.lineWidth : 1);\n          offset = (s.points.hitRadius || s.points.radius || s.mouse.radius) + lw;\n        octx.clearRect(\n          prev.xaxis.d2p(prev.x) - offset,\n          prev.yaxis.d2p(prev.y) - offset,\n          offset*2,\n          offset*2\n        );\n      }\n      D.hide(this.mouseTrack);\n      this.prevHit = null;\n    }\n    octx.restore();\n  },\n  /**\n   * Retrieves the nearest data point from the mouse cursor. If it's within\n   * a certain range, draw a point on the overlay canvas and display the x and y\n   * value of the data.\n   * @param {Object} mouse - Object that holds the relative x and y coordinates of the cursor.\n   */\n  hit : function (mouse) {\n\n    var\n      options = this.options,\n      prevHit = this.prevHit,\n      closest, sensibility, dataIndex, seriesIndex, series, value, xaxis, yaxis, n;\n\n    if (this.series.length === 0) return;\n\n    // Nearest data element.\n    // dist, x, y, relX, relY, absX, absY, sAngle, eAngle, fraction, mouse,\n    // xaxis, yaxis, series, index, seriesIndex\n    n = {\n      relX : mouse.relX,\n      relY : mouse.relY,\n      absX : mouse.absX,\n      absY : mouse.absY,\n      series: this.series\n    };\n\n    if (options.mouse.trackY &&\n        !options.mouse.trackAll &&\n        this.hit.executeOnType(this.series, 'hit', [mouse, n]) &&\n        !_.isUndefined(n.seriesIndex))\n      {\n      series    = this.series[n.seriesIndex];\n      n.series  = series;\n      n.mouse   = series.mouse;\n      n.xaxis   = series.xaxis;\n      n.yaxis   = series.yaxis;\n    } else {\n\n      closest = this.hit.closest(mouse);\n\n      if (closest) {\n\n        closest     = options.mouse.trackY ? closest.point : closest.x;\n        seriesIndex = closest.seriesIndex;\n        series      = this.series[seriesIndex];\n        xaxis       = series.xaxis;\n        yaxis       = series.yaxis;\n        sensibility = 2 * series.mouse.sensibility;\n\n        if\n          (options.mouse.trackAll ||\n          (closest.distanceX < sensibility / xaxis.scale &&\n          (!options.mouse.trackY || closest.distanceY < sensibility / yaxis.scale)))\n        {\n          n.series      = series;\n          n.xaxis       = series.xaxis;\n          n.yaxis       = series.yaxis;\n          n.mouse       = series.mouse;\n          n.x           = closest.x;\n          n.y           = closest.y;\n          n.dist        = closest.distance;\n          n.index       = closest.dataIndex;\n          n.seriesIndex = seriesIndex;\n        }\n      }\n    }\n\n    if (!prevHit || (prevHit.index !== n.index || prevHit.seriesIndex !== n.seriesIndex)) {\n      this.hit.clearHit();\n      if (n.series && n.mouse && n.mouse.track) {\n        this.hit.drawMouseTrack(n);\n        this.hit.drawHit(n);\n        Flotr.EventAdapter.fire(this.el, 'flotr:hit', [n, this]);\n      }\n    }\n\n    return n;\n  },\n\n  closest : function (mouse) {\n\n    var\n      series    = this.series,\n      options   = this.options,\n      relX      = mouse.relX,\n      relY      = mouse.relY,\n      compare   = Number.MAX_VALUE,\n      compareX  = Number.MAX_VALUE,\n      closest   = {},\n      closestX  = {},\n      check     = false,\n      serie, data,\n      distance, distanceX, distanceY,\n      mouseX, mouseY,\n      x, y, i, j;\n\n    function setClosest (o) {\n      o.distance = distance;\n      o.distanceX = distanceX;\n      o.distanceY = distanceY;\n      o.seriesIndex = i;\n      o.dataIndex = j;\n      o.x = x;\n      o.y = y;\n      check = true;\n    }\n\n    for (i = 0; i < series.length; i++) {\n\n      serie = series[i];\n      data = serie.data;\n      mouseX = serie.xaxis.p2d(relX);\n      mouseY = serie.yaxis.p2d(relY);\n\n      if (serie.hide) continue;\n\n      for (j = data.length; j--;) {\n\n        x = data[j][0];\n        y = data[j][1];\n        // Add stack offset if exists\n        if (data[j].y0) y += data[j].y0;\n\n        if (x === null || y === null) continue;\n\n        // don't check if the point isn't visible in the current range\n        if (x < serie.xaxis.min || x > serie.xaxis.max) continue;\n\n        distanceX = Math.abs(x - mouseX);\n        distanceY = Math.abs(y - mouseY);\n\n        // Skip square root for speed\n        distance = distanceX * distanceX + distanceY * distanceY;\n\n        if (distance < compare) {\n          compare = distance;\n          setClosest(closest);\n        }\n\n        if (distanceX < compareX) {\n          compareX = distanceX;\n          setClosest(closestX);\n        }\n      }\n    }\n\n    return check ? {\n      point : closest,\n      x : closestX\n    } : false;\n  },\n\n  drawMouseTrack : function (n) {\n\n    var\n      pos         = '', \n      s           = n.series,\n      p           = n.mouse.position, \n      m           = n.mouse.margin,\n      x           = n.x,\n      y           = n.y,\n      elStyle     = S_MOUSETRACK,\n      mouseTrack  = this.mouseTrack,\n      plotOffset  = this.plotOffset,\n      left        = plotOffset.left,\n      right       = plotOffset.right,\n      bottom      = plotOffset.bottom,\n      top         = plotOffset.top,\n      decimals    = n.mouse.trackDecimals,\n      options     = this.options,\n      container   = options.mouse.container,\n      oTop        = 0,\n      oLeft       = 0,\n      offset, size, content;\n\n    // Create\n    if (!mouseTrack) {\n      mouseTrack = D.node('<div class=\"flotr-mouse-value\" style=\"'+elStyle+'\"></div>');\n      this.mouseTrack = mouseTrack;\n      D.insert(container || this.el, mouseTrack);\n    }\n\n    // Fill tracker:\n    if (!decimals || decimals < 0) decimals = 0;\n    if (x && x.toFixed) x = x.toFixed(decimals);\n    if (y && y.toFixed) y = y.toFixed(decimals);\n    content = n.mouse.trackFormatter({\n      x: x,\n      y: y,\n      series: n.series,\n      index: n.index,\n      nearest: n,\n      fraction: n.fraction\n    });\n    if (_.isNull(content) || _.isUndefined(content)) {\n      D.hide(mouseTrack);\n      return;\n    } else {\n      mouseTrack.innerHTML = content;\n      D.show(mouseTrack);\n    }\n\n    // Positioning\n    if (!p) {\n      return;\n    }\n    size = D.size(mouseTrack);\n    if (container) {\n      offset = D.position(this.el);\n      oTop = offset.top;\n      oLeft = offset.left;\n    }\n\n    if (!n.mouse.relative) { // absolute to the canvas\n      pos += 'top:';\n      if      (p.charAt(0) == 'n') pos += (oTop + m + top);\n      else if (p.charAt(0) == 's') pos += (oTop - m + top + this.plotHeight - size.height);\n      pos += 'px;bottom:auto;left:';\n      if      (p.charAt(1) == 'e') pos += (oLeft - m + left + this.plotWidth - size.width);\n      else if (p.charAt(1) == 'w') pos += (oLeft + m + left);\n      pos += 'px;right:auto;';\n\n    // Pie\n    } else if (s.pie && s.pie.show) {\n      var center = {\n          x: (this.plotWidth)/2,\n          y: (this.plotHeight)/2\n        },\n        radius = (Math.min(this.canvasWidth, this.canvasHeight) * s.pie.sizeRatio) / 2,\n        bisection = n.sAngle<n.eAngle ? (n.sAngle + n.eAngle) / 2: (n.sAngle + n.eAngle + 2* Math.PI) / 2;\n      \n      pos += 'bottom:' + (m - top - center.y - Math.sin(bisection) * radius/2 + this.canvasHeight) + 'px;top:auto;';\n      pos += 'left:' + (m + left + center.x + Math.cos(bisection) * radius/2) + 'px;right:auto;';\n\n    // Default\n    } else {\n      pos += 'top:';\n      if (/n/.test(p)) pos += (oTop - m + top + n.yaxis.d2p(n.y) - size.height);\n      else             pos += (oTop + m + top + n.yaxis.d2p(n.y));\n      pos += 'px;bottom:auto;left:';\n      if (/w/.test(p)) pos += (oLeft - m + left + n.xaxis.d2p(n.x) - size.width);\n      else             pos += (oLeft + m + left + n.xaxis.d2p(n.x));\n      pos += 'px;right:auto;';\n    }\n\n    // Set position\n    mouseTrack.style.cssText = elStyle + pos;\n\n    if (n.mouse.relative) {\n      if (!/[ew]/.test(p)) {\n        // Center Horizontally\n        mouseTrack.style.left =\n          (oLeft + left + n.xaxis.d2p(n.x) - D.size(mouseTrack).width / 2) + 'px';\n      } else\n      if (!/[ns]/.test(p)) {\n        // Center Vertically\n        mouseTrack.style.top =\n          (oTop + top + n.yaxis.d2p(n.y) - D.size(mouseTrack).height / 2) + 'px';\n      }\n    }\n  }\n\n});\n})();\n\n/** \n * Selection Handles Plugin\n *\n *\n * Options\n *  show - True enables the handles plugin.\n *  drag - Left and Right drag handles\n *  scroll - Scrolling handle\n */\n(function () {\n\nfunction isLeftClick (e, type) {\n  return (e.which ? (e.which === 1) : (e.button === 0 || e.button === 1));\n}\n\nfunction boundX(x, graph) {\n  return Math.min(Math.max(0, x), graph.plotWidth - 1);\n}\n\nfunction boundY(y, graph) {\n  return Math.min(Math.max(0, y), graph.plotHeight);\n}\n\nvar\n  D = Flotr.DOM,\n  E = Flotr.EventAdapter,\n  _ = Flotr._;\n\n\nFlotr.addPlugin('selection', {\n\n  options: {\n    pinchOnly: null,       // Only select on pinch\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#B6D9FF',      // => selection box color\n    fps: 20                // => frames-per-second\n  },\n\n  callbacks: {\n    'flotr:mouseup' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (selection.interval) clearInterval(selection.interval);\n\n      if (this.multitouches) {\n        selection.updateSelection();\n      } else\n      if (!options.pinchOnly) {\n        selection.setSelectionPos(selection.selection.second, pointer);\n      }\n      selection.clearSelection();\n\n      if(selection.selecting && selection.selectionIsSane()){\n        selection.drawSelection();\n        selection.fireSelectEvent();\n        this.ignoreClick = true;\n      }\n    },\n    'flotr:mousedown' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (!options.mode || (!isLeftClick(event) && _.isUndefined(event.touches))) return;\n      if (!options.pinchOnly) selection.setSelectionPos(selection.selection.first, pointer);\n      if (selection.interval) clearInterval(selection.interval);\n\n      this.lastMousePos.pageX = null;\n      selection.selecting = false;\n      selection.interval = setInterval(\n        _.bind(selection.updateSelection, this),\n        1000 / options.fps\n      );\n    },\n    'flotr:destroy' : function (event) {\n      clearInterval(this.selection.interval);\n    }\n  },\n\n  // TODO This isn't used.  Maybe it belongs in the draw area and fire select event methods?\n  getArea: function() {\n\n    var\n      s = this.selection.selection,\n      a = this.axes,\n      first = s.first,\n      second = s.second,\n      x1, x2, y1, y2;\n\n    x1 = a.x.p2d(s.first.x);\n    x2 = a.x.p2d(s.second.x);\n    y1 = a.y.p2d(s.first.y);\n    y2 = a.y.p2d(s.second.y);\n\n    return {\n      x1 : Math.min(x1, x2),\n      y1 : Math.min(y1, y2),\n      x2 : Math.max(x1, x2),\n      y2 : Math.max(y1, y2),\n      xfirst : x1,\n      xsecond : x2,\n      yfirst : y1,\n      ysecond : y2\n    };\n  },\n\n  selection: {first: {x: -1, y: -1}, second: {x: -1, y: -1}},\n  prevSelection: null,\n  interval: null,\n\n  /**\n   * Fires the 'flotr:select' event when the user made a selection.\n   */\n  fireSelectEvent: function(name){\n    var\n      area = this.selection.getArea();\n    name = name || 'select';\n    area.selection = this.selection.selection;\n    E.fire(this.el, 'flotr:'+name, [area, this]);\n  },\n\n  /**\n   * Allows the user the manually select an area.\n   * @param {Object} area - Object with coordinates to select.\n   */\n  setSelection: function(area, preventEvent){\n    var options = this.options,\n      xa = this.axes.x,\n      ya = this.axes.y,\n      vertScale = ya.scale,\n      hozScale = xa.scale,\n      selX = options.selection.mode.indexOf('x') != -1,\n      selY = options.selection.mode.indexOf('y') != -1,\n      s = this.selection.selection;\n    \n    this.selection.clearSelection();\n\n    s.first.y  = boundY((selX && !selY) ? 0 : (ya.max - area.y1) * vertScale, this);\n    s.second.y = boundY((selX && !selY) ? this.plotHeight - 1: (ya.max - area.y2) * vertScale, this);\n    s.first.x  = boundX((selY && !selX) ? 0 : (area.x1 - xa.min) * hozScale, this);\n    s.second.x = boundX((selY && !selX) ? this.plotWidth : (area.x2 - xa.min) * hozScale, this);\n    \n    this.selection.drawSelection();\n    if (!preventEvent)\n      this.selection.fireSelectEvent();\n  },\n\n  /**\n   * Calculates the position of the selection.\n   * @param {Object} pos - Position object.\n   * @param {Event} event - Event object.\n   */\n  setSelectionPos: function(pos, pointer) {\n    var mode = this.options.selection.mode,\n        selection = this.selection.selection;\n\n    if(mode.indexOf('x') == -1) {\n      pos.x = (pos == selection.first) ? 0 : this.plotWidth;         \n    }else{\n      pos.x = boundX(pointer.relX, this);\n    }\n\n    if (mode.indexOf('y') == -1) {\n      pos.y = (pos == selection.first) ? 0 : this.plotHeight - 1;\n    }else{\n      pos.y = boundY(pointer.relY, this);\n    }\n  },\n  /**\n   * Draws the selection box.\n   */\n  drawSelection: function() {\n\n    this.selection.fireSelectEvent('selecting');\n\n    var s = this.selection.selection,\n      octx = this.octx,\n      options = this.options,\n      plotOffset = this.plotOffset,\n      prevSelection = this.selection.prevSelection;\n    \n    if (prevSelection &&\n      s.first.x == prevSelection.first.x &&\n      s.first.y == prevSelection.first.y && \n      s.second.x == prevSelection.second.x &&\n      s.second.y == prevSelection.second.y) {\n      return;\n    }\n\n    octx.save();\n    octx.strokeStyle = this.processColor(options.selection.color, {opacity: 0.8});\n    octx.lineWidth = 1;\n    octx.lineJoin = 'miter';\n    octx.fillStyle = this.processColor(options.selection.color, {opacity: 0.4});\n\n    this.selection.prevSelection = {\n      first: { x: s.first.x, y: s.first.y },\n      second: { x: s.second.x, y: s.second.y }\n    };\n\n    var x = Math.min(s.first.x, s.second.x),\n        y = Math.min(s.first.y, s.second.y),\n        w = Math.abs(s.second.x - s.first.x),\n        h = Math.abs(s.second.y - s.first.y);\n\n    octx.fillRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.strokeRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.restore();\n  },\n\n  /**\n   * Updates (draws) the selection box.\n   */\n  updateSelection: function(){\n    if (!this.lastMousePos.pageX) return;\n\n    this.selection.selecting = true;\n\n    if (this.multitouches) {\n      this.selection.setSelectionPos(this.selection.selection.first,  this.getEventPosition(this.multitouches[0]));\n      this.selection.setSelectionPos(this.selection.selection.second,  this.getEventPosition(this.multitouches[1]));\n    } else\n    if (this.options.selection.pinchOnly) {\n      return;\n    } else {\n      this.selection.setSelectionPos(this.selection.selection.second, this.lastMousePos);\n    }\n\n    this.selection.clearSelection();\n    \n    if(this.selection.selectionIsSane()) {\n      this.selection.drawSelection();\n    }\n  },\n\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearSelection: function() {\n    if (!this.selection.prevSelection) return;\n      \n    var prevSelection = this.selection.prevSelection,\n      lw = 1,\n      plotOffset = this.plotOffset,\n      x = Math.min(prevSelection.first.x, prevSelection.second.x),\n      y = Math.min(prevSelection.first.y, prevSelection.second.y),\n      w = Math.abs(prevSelection.second.x - prevSelection.first.x),\n      h = Math.abs(prevSelection.second.y - prevSelection.first.y);\n    \n    this.octx.clearRect(x + plotOffset.left - lw + 0.5,\n                        y + plotOffset.top - lw,\n                        w + 2 * lw + 0.5,\n                        h + 2 * lw + 0.5);\n    \n    this.selection.prevSelection = null;\n  },\n  /**\n   * Determines whether or not the selection is sane and should be drawn.\n   * @return {Boolean} - True when sane, false otherwise.\n   */\n  selectionIsSane: function(){\n    var s = this.selection.selection;\n    return Math.abs(s.second.x - s.first.x) >= 5 || \n           Math.abs(s.second.y - s.first.y) >= 5;\n  }\n\n});\n\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('labels', {\n\n  callbacks : {\n    'flotr:afterdraw' : function () {\n      this.labels.draw();\n    }\n  },\n\n  draw: function(){\n    // Construct fixed width label boxes, which can be styled easily.\n    var\n      axis, tick, left, top, xBoxWidth,\n      radius, sides, coeff, angle,\n      div, i, html = '',\n      noLabels = 0,\n      options  = this.options,\n      ctx      = this.ctx,\n      a        = this.axes,\n      style    = { size: options.fontSize };\n\n    for (i = 0; i < a.x.ticks.length; ++i){\n      if (a.x.ticks[i].label) { ++noLabels; }\n    }\n    xBoxWidth = this.plotWidth / noLabels;\n\n    if (options.grid.circular) {\n      ctx.save();\n      ctx.translate(this.plotOffset.left + this.plotWidth / 2,\n          this.plotOffset.top + this.plotHeight / 2);\n\n      radius = this.plotHeight * options.radar.radiusRatio / 2 + options.fontSize;\n      sides  = this.axes.x.ticks.length;\n      coeff  = 2 * (Math.PI / sides);\n      angle  = -Math.PI / 2;\n\n      drawLabelCircular(this, a.x, false);\n      drawLabelCircular(this, a.x, true);\n      drawLabelCircular(this, a.y, false);\n      drawLabelCircular(this, a.y, true);\n      ctx.restore();\n    }\n\n    if (!options.HtmlText && this.textEnabled) {\n      drawLabelNoHtmlText(this, a.x, 'center', 'top');\n      drawLabelNoHtmlText(this, a.x2, 'center', 'bottom');\n      drawLabelNoHtmlText(this, a.y, 'right', 'middle');\n      drawLabelNoHtmlText(this, a.y2, 'left', 'middle');\n    \n    } else if ((\n        a.x.options.showLabels ||\n        a.x2.options.showLabels ||\n        a.y.options.showLabels ||\n        a.y2.options.showLabels) &&\n        !options.grid.circular\n      ) {\n\n      html = '';\n\n      drawLabelHtml(this, a.x);\n      drawLabelHtml(this, a.x2);\n      drawLabelHtml(this, a.y);\n      drawLabelHtml(this, a.y2);\n\n      ctx.stroke();\n      ctx.restore();\n      div = D.create('div');\n      D.setStyles(div, {\n        fontSize: 'smaller',\n        color: options.grid.color\n      });\n      div.className = 'flotr-labels';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n\n    function drawLabelCircular (graph, axis, minorTicks) {\n      var\n        ticks   = minorTicks ? axis.minorTicks : axis.ticks,\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        angle        : Flotr.toRad(axis.options.labelsAngle),\n        textBaseline : 'middle'\n      };\n\n      for (i = 0; i < ticks.length &&\n          (minorTicks ? axis.options.showMinorLabels : axis.options.showLabels); ++i){\n        tick = ticks[i];\n        tick.label += '';\n        if (!tick.label || !tick.label.length) { continue; }\n\n        x = Math.cos(i * coeff + angle) * radius;\n        y = Math.sin(i * coeff + angle) * radius;\n\n        style.textAlign = isX ? (Math.abs(x) < 0.1 ? 'center' : (x < 0 ? 'right' : 'left')) : 'left';\n\n        Flotr.drawText(\n          ctx, tick.label,\n          isX ? x : 3,\n          isX ? y : -(axis.ticks[i].v / axis.max) * (radius - options.fontSize),\n          style\n        );\n      }\n    }\n\n    function drawLabelNoHtmlText (graph, axis, textAlign, textBaseline)  {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        textAlign    : textAlign,\n        textBaseline : textBaseline,\n        angle : Flotr.toRad(axis.options.labelsAngle)\n      };\n      style = Flotr.getBestTextAlign(style.angle, style);\n\n      for (i = 0; i < axis.ticks.length && continueShowingLabels(axis); ++i) {\n\n        tick = axis.ticks[i];\n        if (!tick.label || !tick.label.length) { continue; }\n\n        offset = axis.d2p(tick.v);\n        if (offset < 0 ||\n            offset > (isX ? graph.plotWidth : graph.plotHeight)) { continue; }\n\n        Flotr.drawText(\n          ctx, tick.label,\n          leftOffset(graph, isX, isFirst, offset),\n          topOffset(graph, isX, isFirst, offset),\n          style\n        );\n\n        // Only draw on axis y2\n        if (!isX && !isFirst) {\n          ctx.save();\n          ctx.strokeStyle = style.color;\n          ctx.beginPath();\n          ctx.moveTo(graph.plotOffset.left + graph.plotWidth - 8, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.lineTo(graph.plotOffset.left + graph.plotWidth, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.stroke();\n          ctx.restore();\n        }\n      }\n\n      function continueShowingLabels (axis) {\n        return axis.options.showLabels && axis.used;\n      }\n      function leftOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.left +\n          (isX ? offset :\n            (isFirst ?\n              -options.grid.labelMargin :\n              options.grid.labelMargin + graph.plotWidth));\n      }\n      function topOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.top +\n          (isX ? options.grid.labelMargin : offset) +\n          ((isX && isFirst) ? graph.plotHeight : 0);\n      }\n    }\n\n    function drawLabelHtml (graph, axis) {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        name = '',\n        left, style, top,\n        offset = graph.plotOffset;\n\n      if (!isX && !isFirst) {\n        ctx.save();\n        ctx.strokeStyle = axis.options.color || options.grid.color;\n        ctx.beginPath();\n      }\n\n      if (axis.options.showLabels && (isFirst ? true : axis.used)) {\n        for (i = 0; i < axis.ticks.length; ++i) {\n          tick = axis.ticks[i];\n          if (!tick.label || !tick.label.length ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) < 0) ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) > (isX ? graph.canvasWidth : graph.canvasHeight))) {\n            continue;\n          }\n          top = offset.top +\n            (isX ?\n              ((isFirst ? 1 : -1 ) * (graph.plotHeight + options.grid.labelMargin)) :\n              axis.d2p(tick.v) - axis.maxLabel.height / 2);\n          left = isX ? (offset.left + axis.d2p(tick.v) - xBoxWidth / 2) : 0;\n\n          name = '';\n          if (i === 0) {\n            name = ' first';\n          } else if (i === axis.ticks.length - 1) {\n            name = ' last';\n          }\n          name += isX ? ' flotr-grid-label-x' : ' flotr-grid-label-y';\n\n          html += [\n            '<div style=\"position:absolute; text-align:' + (isX ? 'center' : 'right') + '; ',\n            'top:' + top + 'px; ',\n            ((!isX && !isFirst) ? 'right:' : 'left:') + left + 'px; ',\n            'width:' + (isX ? xBoxWidth : ((isFirst ? offset.left : offset.right) - options.grid.labelMargin)) + 'px; ',\n            axis.options.color ? ('color:' + axis.options.color + '; ') : ' ',\n            '\" class=\"flotr-grid-label' + name + '\">' + tick.label + '</div>'\n          ].join(' ');\n          \n          if (!isX && !isFirst) {\n            ctx.moveTo(offset.left + graph.plotWidth - 8, offset.top + axis.d2p(tick.v));\n            ctx.lineTo(offset.left + graph.plotWidth, offset.top + axis.d2p(tick.v));\n          }\n        }\n      }\n    }\n  }\n\n});\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('legend', {\n  options: {\n    show: true,            // => setting to true will show the legend, hide otherwise\n    noColumns: 1,          // => number of colums in legend table // @todo: doesn't work for HtmlText = false\n    labelFormatter: function(v){return v;}, // => fn: string -> string\n    labelBoxBorderColor: '#CCCCCC', // => border color for the little label boxes\n    labelBoxWidth: 14,\n    labelBoxHeight: 10,\n    labelBoxMargin: 5,\n    container: null,       // => container (as jQuery object) to put legend in, null means default on top of graph\n    position: 'nw',        // => position of default legend container within plot\n    margin: 5,             // => distance from grid edge to default legend container within plot\n    backgroundColor: '#F0F0F0', // => Legend background color.\n    backgroundOpacity: 0.85// => set to 0 to avoid background, set to 1 for a solid background\n  },\n  callbacks: {\n    'flotr:afterinit': function() {\n      this.legend.insertLegend();\n    },\n    'flotr:destroy': function() {\n      var markup = this.legend.markup;\n      if (markup) {\n        this.legend.markup = null;\n        D.remove(markup);\n      }\n    }\n  },\n  /**\n   * Adds a legend div to the canvas container or draws it on the canvas.\n   */\n  insertLegend: function(){\n\n    if(!this.options.legend.show)\n      return;\n\n    var series      = this.series,\n      plotOffset    = this.plotOffset,\n      options       = this.options,\n      legend        = options.legend,\n      fragments     = [],\n      rowStarted    = false, \n      ctx           = this.ctx,\n      itemCount     = _.filter(series, function(s) {return (s.label && !s.hide);}).length,\n      p             = legend.position, \n      m             = legend.margin,\n      opacity       = legend.backgroundOpacity,\n      i, label, color;\n\n    if (itemCount) {\n\n      var lbw = legend.labelBoxWidth,\n          lbh = legend.labelBoxHeight,\n          lbm = legend.labelBoxMargin,\n          offsetX = plotOffset.left + m,\n          offsetY = plotOffset.top + m,\n          labelMaxWidth = 0,\n          style = {\n            size: options.fontSize*1.1,\n            color: options.grid.color\n          };\n\n      // We calculate the labels' max width\n      for(i = series.length - 1; i > -1; --i){\n        if(!series[i].label || series[i].hide) continue;\n        label = legend.labelFormatter(series[i].label);\n        labelMaxWidth = Math.max(labelMaxWidth, this._text.measureText(label, style).width);\n      }\n\n      var legendWidth  = Math.round(lbw + lbm*3 + labelMaxWidth),\n          legendHeight = Math.round(itemCount*(lbm+lbh) + lbm);\n\n      // Default Opacity\n      if (!opacity && opacity !== 0) {\n        opacity = 0.1;\n      }\n\n      if (!options.HtmlText && this.textEnabled && !legend.container) {\n        \n        if(p.charAt(0) == 's') offsetY = plotOffset.top + this.plotHeight - (m + legendHeight);\n        if(p.charAt(0) == 'c') offsetY = plotOffset.top + (this.plotHeight/2) - (m + (legendHeight/2));\n        if(p.charAt(1) == 'e') offsetX = plotOffset.left + this.plotWidth - (m + legendWidth);\n        \n        // Legend box\n        color = this.processColor(legend.backgroundColor, { opacity : opacity });\n\n        ctx.fillStyle = color;\n        ctx.fillRect(offsetX, offsetY, legendWidth, legendHeight);\n        ctx.strokeStyle = legend.labelBoxBorderColor;\n        ctx.strokeRect(Flotr.toPixel(offsetX), Flotr.toPixel(offsetY), legendWidth, legendHeight);\n        \n        // Legend labels\n        var x = offsetX + lbm;\n        var y = offsetY + lbm;\n        for(i = 0; i < series.length; i++){\n          if(!series[i].label || series[i].hide) continue;\n          label = legend.labelFormatter(series[i].label);\n          \n          ctx.fillStyle = series[i].color;\n          ctx.fillRect(x, y, lbw-1, lbh-1);\n          \n          ctx.strokeStyle = legend.labelBoxBorderColor;\n          ctx.lineWidth = 1;\n          ctx.strokeRect(Math.ceil(x)-1.5, Math.ceil(y)-1.5, lbw+2, lbh+2);\n          \n          // Legend text\n          Flotr.drawText(ctx, label, x + lbw + lbm, y + lbh, style);\n          \n          y += lbh + lbm;\n        }\n      }\n      else {\n        for(i = 0; i < series.length; ++i){\n          if(!series[i].label || series[i].hide) continue;\n          \n          if(i % legend.noColumns === 0){\n            fragments.push(rowStarted ? '</tr><tr>' : '<tr>');\n            rowStarted = true;\n          }\n\n          var s = series[i],\n            boxWidth = legend.labelBoxWidth,\n            boxHeight = legend.labelBoxHeight;\n\n          label = legend.labelFormatter(s.label);\n          color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';\n          \n          fragments.push(\n            '<td class=\"flotr-legend-color-box\">',\n              '<div style=\"border:1px solid ', legend.labelBoxBorderColor, ';padding:1px\">',\n                '<div style=\"width:', (boxWidth-1), 'px;height:', (boxHeight-1), 'px;border:1px solid ', series[i].color, '\">', // Border\n                  '<div style=\"width:', boxWidth, 'px;height:', boxHeight, 'px;', color, '\"></div>', // Background\n                '</div>',\n              '</div>',\n            '</td>',\n            '<td class=\"flotr-legend-label\">', label, '</td>'\n          );\n        }\n        if(rowStarted) fragments.push('</tr>');\n          \n        if(fragments.length > 0){\n          var table = '<table style=\"font-size:smaller;color:' + options.grid.color + '\">' + fragments.join('') + '</table>';\n          if(legend.container){\n            table = D.node(table);\n            this.legend.markup = table;\n            D.insert(legend.container, table);\n          }\n          else {\n            var styles = {position: 'absolute', 'zIndex': '2', 'border' : '1px solid ' + legend.labelBoxBorderColor};\n\n                 if(p.charAt(0) == 'n') { styles.top = (m + plotOffset.top) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 'c') { styles.top = (m + (this.plotHeight - legendHeight) / 2) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 's') { styles.bottom = (m + plotOffset.bottom) + 'px'; styles.top = 'auto'; }\n                 if(p.charAt(1) == 'e') { styles.right = (m + plotOffset.right) + 'px'; styles.left = 'auto'; }\n            else if(p.charAt(1) == 'w') { styles.left = (m + plotOffset.left) + 'px'; styles.right = 'auto'; }\n\n            var div = D.create('div'), size;\n            div.className = 'flotr-legend';\n            D.setStyles(div, styles);\n            D.insert(div, table);\n            D.insert(this.el, div);\n            \n            if (!opacity) return;\n\n            var c = legend.backgroundColor || options.grid.backgroundColor || '#ffffff';\n\n            _.extend(styles, D.size(div), {\n              'backgroundColor': c,\n              'zIndex' : '',\n              'border' : ''\n            });\n            styles.width += 'px';\n            styles.height += 'px';\n\n             // Put in the transparent background separately to avoid blended labels and\n            div = D.create('div');\n            div.className = 'flotr-legend-bg';\n            D.setStyles(div, styles);\n            D.opacity(div, opacity);\n            D.insert(div, ' ');\n            D.insert(this.el, div);\n          }\n        }\n      }\n    }\n  }\n});\n})();\n\n/** Spreadsheet **/\n(function() {\n\nfunction getRowLabel(value){\n  if (this.options.spreadsheet.tickFormatter){\n    //TODO maybe pass the xaxis formatter to the custom tick formatter as an opt-out?\n    return this.options.spreadsheet.tickFormatter(value);\n  }\n  else {\n    var t = _.find(this.axes.x.ticks, function(t){return t.v == value;});\n    if (t) {\n      return t.label;\n    }\n    return value;\n  }\n}\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('spreadsheet', {\n  options: {\n    show: false,           // => show the data grid using two tabs\n    tabGraphLabel: 'Graph',\n    tabDataLabel: 'Data',\n    toolbarDownload: 'Download CSV', // @todo: add better language support\n    toolbarSelectAll: 'Select all',\n    csvFileSeparator: ',',\n    decimalSeparator: '.',\n    tickFormatter: null,\n    initialTab: 'graph'\n  },\n  /**\n   * Builds the tabs in the DOM\n   */\n  callbacks: {\n    'flotr:afterconstruct': function(){\n      // @TODO necessary?\n      //this.el.select('.flotr-tabs-group,.flotr-datagrid-container').invoke('remove');\n      \n      if (!this.options.spreadsheet.show) return;\n      \n      var ss = this.spreadsheet,\n        container = D.node('<div class=\"flotr-tabs-group\" style=\"position:absolute;left:0px;width:'+this.canvasWidth+'px\"></div>'),\n        graph = D.node('<div style=\"float:left\" class=\"flotr-tab selected\">'+this.options.spreadsheet.tabGraphLabel+'</div>'),\n        data = D.node('<div style=\"float:left\" class=\"flotr-tab\">'+this.options.spreadsheet.tabDataLabel+'</div>'),\n        offset;\n\n      ss.tabsContainer = container;\n      ss.tabs = { graph : graph, data : data };\n\n      D.insert(container, graph);\n      D.insert(container, data);\n      D.insert(this.el, container);\n\n      offset = D.size(data).height + 2;\n      this.plotOffset.bottom += offset;\n\n      D.setStyles(container, {top: this.canvasHeight-offset+'px'});\n\n      this.\n        observe(graph, 'click',  function(){ss.showTab('graph');}).\n        observe(data, 'click', function(){ss.showTab('data');});\n      if (this.options.spreadsheet.initialTab !== 'graph'){\n        ss.showTab(this.options.spreadsheet.initialTab);\n      }\n    }\n  },\n  /**\n   * Builds a matrix of the data to make the correspondance between the x values and the y values :\n   * X value => Y values from the axes\n   * @return {Array} The data grid\n   */\n  loadDataGrid: function(){\n    if (this.seriesData) return this.seriesData;\n\n    var s = this.series,\n        rows = {};\n\n    /* The data grid is a 2 dimensions array. There is a row for each X value.\n     * Each row contains the x value and the corresponding y value for each serie ('undefined' if there isn't one)\n    **/\n    _.each(s, function(serie, i){\n      _.each(serie.data, function (v) {\n        var x = v[0],\n            y = v[1],\n            r = rows[x];\n        if (r) {\n          r[i+1] = y;\n        } else {\n          var newRow = [];\n          newRow[0] = x;\n          newRow[i+1] = y;\n          rows[x] = newRow;\n        }\n      });\n    });\n\n    // The data grid is sorted by x value\n    this.seriesData = _.sortBy(rows, function(row, x){\n      return parseInt(x, 10);\n    });\n    return this.seriesData;\n  },\n  /**\n   * Constructs the data table for the spreadsheet\n   * @todo make a spreadsheet manager (Flotr.Spreadsheet)\n   * @return {Element} The resulting table element\n   */\n  constructDataGrid: function(){\n    // If the data grid has already been built, nothing to do here\n    if (this.spreadsheet.datagrid) return this.spreadsheet.datagrid;\n    \n    var s = this.series,\n        datagrid = this.spreadsheet.loadDataGrid(),\n        colgroup = ['<colgroup><col />'],\n        buttonDownload, buttonSelect, t;\n    \n    // First row : series' labels\n    var html = ['<table class=\"flotr-datagrid\"><tr class=\"first-row\">'];\n    html.push('<th>&nbsp;</th>');\n    _.each(s, function(serie,i){\n      html.push('<th scope=\"col\">'+(serie.label || String.fromCharCode(65+i))+'</th>');\n      colgroup.push('<col />');\n    });\n    html.push('</tr>');\n    // Data rows\n    _.each(datagrid, function(row){\n      html.push('<tr>');\n      _.times(s.length+1, function(i){\n        var tag = 'td',\n            value = row[i],\n            // TODO: do we really want to handle problems with floating point\n            // precision here?\n            content = (!_.isUndefined(value) ? Math.round(value*100000)/100000 : '');\n        if (i === 0) {\n          tag = 'th';\n          var label = getRowLabel.call(this, content);\n          if (label) content = label;\n        }\n\n        html.push('<'+tag+(tag=='th'?' scope=\"row\"':'')+'>'+content+'</'+tag+'>');\n      }, this);\n      html.push('</tr>');\n    }, this);\n    colgroup.push('</colgroup>');\n    t = D.node(html.join(''));\n\n    /**\n     * @TODO disabled this\n    if (!Flotr.isIE || Flotr.isIE == 9) {\n      function handleMouseout(){\n        t.select('colgroup col.hover, th.hover').invoke('removeClassName', 'hover');\n      }\n      function handleMouseover(e){\n        var td = e.element(),\n          siblings = td.previousSiblings();\n        t.select('th[scope=col]')[siblings.length-1].addClassName('hover');\n        t.select('colgroup col')[siblings.length].addClassName('hover');\n      }\n      _.each(t.select('td'), function(td) {\n        Flotr.EventAdapter.\n          observe(td, 'mouseover', handleMouseover).\n          observe(td, 'mouseout', handleMouseout);\n      });\n    }\n    */\n\n    buttonDownload = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarDownload +\n      '</button>');\n\n    buttonSelect = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarSelectAll+\n      '</button>');\n\n    this.\n      observe(buttonDownload, 'click', _.bind(this.spreadsheet.downloadCSV, this)).\n      observe(buttonSelect, 'click', _.bind(this.spreadsheet.selectAllData, this));\n\n    var toolbar = D.node('<div class=\"flotr-datagrid-toolbar\"></div>');\n    D.insert(toolbar, buttonDownload);\n    D.insert(toolbar, buttonSelect);\n\n    var containerHeight =this.canvasHeight - D.size(this.spreadsheet.tabsContainer).height-2,\n        container = D.node('<div class=\"flotr-datagrid-container\" style=\"position:absolute;left:0px;top:0px;width:'+\n          this.canvasWidth+'px;height:'+containerHeight+'px;overflow:auto;z-index:10\"></div>');\n\n    D.insert(container, toolbar);\n    D.insert(container, t);\n    D.insert(this.el, container);\n    this.spreadsheet.datagrid = t;\n    this.spreadsheet.container = container;\n\n    return t;\n  },  \n  /**\n   * Shows the specified tab, by its name\n   * @todo make a tab manager (Flotr.Tabs)\n   * @param {String} tabName - The tab name\n   */\n  showTab: function(tabName){\n    if (this.spreadsheet.activeTab === tabName){\n      return;\n    }\n    switch(tabName) {\n      case 'graph':\n        D.hide(this.spreadsheet.container);\n        D.removeClass(this.spreadsheet.tabs.data, 'selected');\n        D.addClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      case 'data':\n        if (!this.spreadsheet.datagrid)\n          this.spreadsheet.constructDataGrid();\n        D.show(this.spreadsheet.container);\n        D.addClass(this.spreadsheet.tabs.data, 'selected');\n        D.removeClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      default:\n        throw 'Illegal tab name: ' + tabName;\n    }\n    this.spreadsheet.activeTab = tabName;\n  },\n  /**\n   * Selects the data table in the DOM for copy/paste\n   */\n  selectAllData: function(){\n    if (this.spreadsheet.tabs) {\n      var selection, range, doc, win, node = this.spreadsheet.constructDataGrid();\n\n      this.spreadsheet.showTab('data');\n      \n      // deferred to be able to select the table\n      setTimeout(function () {\n        if ((doc = node.ownerDocument) && (win = doc.defaultView) && \n            win.getSelection && doc.createRange && \n            (selection = window.getSelection()) && \n            selection.removeAllRanges) {\n            range = doc.createRange();\n            range.selectNode(node);\n            selection.removeAllRanges();\n            selection.addRange(range);\n        }\n        else if (document.body && document.body.createTextRange && \n                (range = document.body.createTextRange())) {\n            range.moveToElementText(node);\n            range.select();\n        }\n      }, 0);\n      return true;\n    }\n    else return false;\n  },\n  /**\n   * Converts the data into CSV in order to download a file\n   */\n  downloadCSV: function(){\n    var csv = '',\n        series = this.series,\n        options = this.options,\n        dg = this.spreadsheet.loadDataGrid(),\n        separator = encodeURIComponent(options.spreadsheet.csvFileSeparator);\n    \n    if (options.spreadsheet.decimalSeparator === options.spreadsheet.csvFileSeparator) {\n      throw \"The decimal separator is the same as the column separator (\"+options.spreadsheet.decimalSeparator+\")\";\n    }\n    \n    // The first row\n    _.each(series, function(serie, i){\n      csv += separator+'\"'+(serie.label || String.fromCharCode(65+i)).replace(/\\\"/g, '\\\\\"')+'\"';\n    });\n\n    csv += \"%0D%0A\"; // \\r\\n\n    \n    // For each row\n    csv += _.reduce(dg, function(memo, row){\n      var rowLabel = getRowLabel.call(this, row[0]) || '';\n      rowLabel = '\"'+(rowLabel+'').replace(/\\\"/g, '\\\\\"')+'\"';\n      var numbers = row.slice(1).join(separator);\n      if (options.spreadsheet.decimalSeparator !== '.') {\n        numbers = numbers.replace(/\\./g, options.spreadsheet.decimalSeparator);\n      }\n      return memo + rowLabel+separator+numbers+\"%0D%0A\"; // \\t and \\r\\n\n    }, '', this);\n\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      csv = csv.replace(new RegExp(separator, 'g'), decodeURIComponent(separator)).replace(/%0A/g, '\\n').replace(/%0D/g, '\\r');\n      window.open().document.write(csv);\n    }\n    else window.open('data:text/csv,'+csv);\n  }\n});\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('titles', {\n  callbacks: {\n    'flotr:afterdraw': function() {\n      this.titles.drawTitles();\n    }\n  },\n  /**\n   * Draws the title and the subtitle\n   */\n  drawTitles : function () {\n    var html,\n        options = this.options,\n        margin = options.grid.labelMargin,\n        ctx = this.ctx,\n        a = this.axes;\n    \n    if (!options.HtmlText && this.textEnabled) {\n      var style = {\n        size: options.fontSize,\n        color: options.grid.color,\n        textAlign: 'center'\n      };\n      \n      // Add subtitle\n      if (options.subtitle){\n        Flotr.drawText(\n          ctx, options.subtitle,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight + this.subtitleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.5;\n      style.size *= 1.5;\n      \n      // Add title\n      if (options.title){\n        Flotr.drawText(\n          ctx, options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.8;\n      style.size *= 0.8;\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used){\n        style.textAlign = a.x.options.titleAlign || 'center';\n        style.textBaseline = 'top';\n        style.angle = Flotr.toRad(a.x.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top + a.x.maxLabel.height + this.plotHeight + 2 * margin,\n          style\n        );\n      }\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used){\n        style.textAlign = a.x2.options.titleAlign || 'center';\n        style.textBaseline = 'bottom';\n        style.angle = Flotr.toRad(a.x2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x2.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top - a.x2.maxLabel.height - 2 * margin,\n          style\n        );\n      }\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used){\n        style.textAlign = a.y.options.titleAlign || 'right';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y.options.title,\n          this.plotOffset.left - a.y.maxLabel.width - 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used){\n        style.textAlign = a.y2.options.titleAlign || 'left';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y2.options.title,\n          this.plotOffset.left + this.plotWidth + a.y2.maxLabel.width + 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n    } \n    else {\n      html = [];\n      \n      // Add title\n      if (options.title)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', \n          this.plotOffset.left, 'px;font-size:1em;font-weight:bold;text-align:center;width:',\n          this.plotWidth,'px;\" class=\"flotr-title\">', options.title, '</div>'\n        );\n      \n      // Add subtitle\n      if (options.subtitle)\n        html.push(\n          '<div style=\"position:absolute;top:', this.titleHeight, 'px;left:', \n          this.plotOffset.left, 'px;font-size:smaller;text-align:center;width:',\n          this.plotWidth, 'px;\" class=\"flotr-subtitle\">', options.subtitle, '</div>'\n        );\n\n      html.push('</div>');\n      \n      html.push('<div class=\"flotr-axis-title\" style=\"font-weight:bold;\">');\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight + options.grid.labelMargin + a.x.titleSize.height), \n          'px;left:', this.plotOffset.left, 'px;width:', this.plotWidth, \n          'px;text-align:', a.x.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x1\">', a.x.options.title, '</div>'\n        );\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', this.plotOffset.left, 'px;width:', \n          this.plotWidth, 'px;text-align:', a.x2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x2\">', a.x2.options.title, '</div>'\n        );\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;left:0;text-align:', a.y.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y1\">', a.y.options.title, '</div>'\n        );\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;right:0;text-align:', a.y2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y2\">', a.y2.options.title, '</div>'\n        );\n      \n      html = html.join('');\n\n      var div = D.create('div');\n      D.setStyles({\n        color: options.grid.color \n      });\n      div.className = 'flotr-titles';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n  }\n});\n})();\n"
  },
  {
    "path": "html/lib/flotr2/flotr2.nolibs.js",
    "content": "/**\n * Flotr2 (c) 2012 Carl Sutherland\n * MIT License\n * Special thanks to:\n * Flotr: http://code.google.com/p/flotr/ (fork)\n * Flot: https://github.com/flot/flot (original fork)\n */\n(function () {\n\nvar\n  global = this,\n  previousFlotr = this.Flotr,\n  Flotr;\n\nFlotr = {\n  _: _,\n  bean: bean,\n  isIphone: /iphone/i.test(navigator.userAgent),\n  isIE: (navigator.appVersion.indexOf(\"MSIE\") != -1 ? parseFloat(navigator.appVersion.split(\"MSIE\")[1]) : false),\n  \n  /**\n   * An object of the registered graph types. Use Flotr.addType(type, object)\n   * to add your own type.\n   */\n  graphTypes: {},\n  \n  /**\n   * The list of the registered plugins\n   */\n  plugins: {},\n  \n  /**\n   * Can be used to add your own chart type. \n   * @param {String} name - Type of chart, like 'pies', 'bars' etc.\n   * @param {String} graphType - The object containing the basic drawing functions (draw, etc)\n   */\n  addType: function(name, graphType){\n    Flotr.graphTypes[name] = graphType;\n    Flotr.defaultOptions[name] = graphType.options || {};\n    Flotr.defaultOptions.defaultType = Flotr.defaultOptions.defaultType || name;\n  },\n  \n  /**\n   * Can be used to add a plugin\n   * @param {String} name - The name of the plugin\n   * @param {String} plugin - The object containing the plugin's data (callbacks, options, function1, function2, ...)\n   */\n  addPlugin: function(name, plugin){\n    Flotr.plugins[name] = plugin;\n    Flotr.defaultOptions[name] = plugin.options || {};\n  },\n  \n  /**\n   * Draws the graph. This function is here for backwards compatibility with Flotr version 0.1.0alpha.\n   * You could also draw graphs by directly calling Flotr.Graph(element, data, options).\n   * @param {Element} el - element to insert the graph into\n   * @param {Object} data - an array or object of dataseries\n   * @param {Object} options - an object containing options\n   * @param {Class} _GraphKlass_ - (optional) Class to pass the arguments to, defaults to Flotr.Graph\n   * @return {Object} returns a new graph object and of course draws the graph.\n   */\n  draw: function(el, data, options, GraphKlass){  \n    GraphKlass = GraphKlass || Flotr.Graph;\n    return new GraphKlass(el, data, options);\n  },\n  \n  /**\n   * Recursively merges two objects.\n   * @param {Object} src - source object (likely the object with the least properties)\n   * @param {Object} dest - destination object (optional, object with the most properties)\n   * @return {Object} recursively merged Object\n   * @TODO See if we can't remove this.\n   */\n  merge: function(src, dest){\n    var i, v, result = dest || {};\n\n    for (i in src) {\n      v = src[i];\n      if (v && typeof(v) === 'object') {\n        if (v.constructor === Array) {\n          result[i] = this._.clone(v);\n        } else if (\n            v.constructor !== RegExp &&\n            !this._.isElement(v) &&\n            !v.jquery\n        ) {\n          result[i] = Flotr.merge(v, (dest ? dest[i] : undefined));\n        } else {\n          result[i] = v;\n        }\n      } else {\n        result[i] = v;\n      }\n    }\n\n    return result;\n  },\n  \n  /**\n   * Recursively clones an object.\n   * @param {Object} object - The object to clone\n   * @return {Object} the clone\n   * @TODO See if we can't remove this.\n   */\n  clone: function(object){\n    return Flotr.merge(object, {});\n  },\n  \n  /**\n   * Function calculates the ticksize and returns it.\n   * @param {Integer} noTicks - number of ticks\n   * @param {Integer} min - lower bound integer value for the current axis\n   * @param {Integer} max - upper bound integer value for the current axis\n   * @param {Integer} decimals - number of decimals for the ticks\n   * @return {Integer} returns the ticksize in pixels\n   */\n  getTickSize: function(noTicks, min, max, decimals){\n    var delta = (max - min) / noTicks,\n        magn = Flotr.getMagnitude(delta),\n        tickSize = 10,\n        norm = delta / magn; // Norm is between 1.0 and 10.0.\n        \n    if(norm < 1.5) tickSize = 1;\n    else if(norm < 2.25) tickSize = 2;\n    else if(norm < 3) tickSize = ((decimals === 0) ? 2 : 2.5);\n    else if(norm < 7.5) tickSize = 5;\n    \n    return tickSize * magn;\n  },\n  \n  /**\n   * Default tick formatter.\n   * @param {String, Integer} val - tick value integer\n   * @param {Object} axisOpts - the axis' options\n   * @return {String} formatted tick string\n   */\n  defaultTickFormatter: function(val, axisOpts){\n    return val+'';\n  },\n  \n  /**\n   * Formats the mouse tracker values.\n   * @param {Object} obj - Track value Object {x:..,y:..}\n   * @return {String} Formatted track string\n   */\n  defaultTrackFormatter: function(obj){\n    return '('+obj.x+', '+obj.y+')';\n  }, \n  \n  /**\n   * Utility function to convert file size values in bytes to kB, MB, ...\n   * @param value {Number} - The value to convert\n   * @param precision {Number} - The number of digits after the comma (default: 2)\n   * @param base {Number} - The base (default: 1000)\n   */\n  engineeringNotation: function(value, precision, base){\n    var sizes =         ['Y','Z','E','P','T','G','M','k',''],\n        fractionSizes = ['y','z','a','f','p','n','µ','m',''],\n        total = sizes.length;\n\n    base = base || 1000;\n    precision = Math.pow(10, precision || 2);\n\n    if (value === 0) return 0;\n\n    if (value > 1) {\n      while (total-- && (value >= base)) value /= base;\n    }\n    else {\n      sizes = fractionSizes;\n      total = sizes.length;\n      while (total-- && (value < 1)) value *= base;\n    }\n\n    return (Math.round(value * precision) / precision) + sizes[total];\n  },\n  \n  /**\n   * Returns the magnitude of the input value.\n   * @param {Integer, Float} x - integer or float value\n   * @return {Integer, Float} returns the magnitude of the input value\n   */\n  getMagnitude: function(x){\n    return Math.pow(10, Math.floor(Math.log(x) / Math.LN10));\n  },\n  toPixel: function(val){\n    return Math.floor(val)+0.5;//((val-Math.round(val) < 0.4) ? (Math.floor(val)-0.5) : val);\n  },\n  toRad: function(angle){\n    return -angle * (Math.PI/180);\n  },\n  floorInBase: function(n, base) {\n    return base * Math.floor(n / base);\n  },\n  drawText: function(ctx, text, x, y, style) {\n    if (!ctx.fillText) {\n      ctx.drawText(text, x, y, style);\n      return;\n    }\n    \n    style = this._.extend({\n      size: Flotr.defaultOptions.fontSize,\n      color: '#000000',\n      textAlign: 'left',\n      textBaseline: 'bottom',\n      weight: 1,\n      angle: 0\n    }, style);\n    \n    ctx.save();\n    ctx.translate(x, y);\n    ctx.rotate(style.angle);\n    ctx.fillStyle = style.color;\n    ctx.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    ctx.textAlign = style.textAlign;\n    ctx.textBaseline = style.textBaseline;\n    ctx.fillText(text, 0, 0);\n    ctx.restore();\n  },\n  getBestTextAlign: function(angle, style) {\n    style = style || {textAlign: 'center', textBaseline: 'middle'};\n    angle += Flotr.getTextAngleFromAlign(style);\n    \n    if (Math.abs(Math.cos(angle)) > 10e-3) \n      style.textAlign    = (Math.cos(angle) > 0 ? 'right' : 'left');\n    \n    if (Math.abs(Math.sin(angle)) > 10e-3) \n      style.textBaseline = (Math.sin(angle) > 0 ? 'top' : 'bottom');\n    \n    return style;\n  },\n  alignTable: {\n    'right middle' : 0,\n    'right top'    : Math.PI/4,\n    'center top'   : Math.PI/2,\n    'left top'     : 3*(Math.PI/4),\n    'left middle'  : Math.PI,\n    'left bottom'  : -3*(Math.PI/4),\n    'center bottom': -Math.PI/2,\n    'right bottom' : -Math.PI/4,\n    'center middle': 0\n  },\n  getTextAngleFromAlign: function(style) {\n    return Flotr.alignTable[style.textAlign+' '+style.textBaseline] || 0;\n  },\n  noConflict : function () {\n    global.Flotr = previousFlotr;\n    return this;\n  }\n};\n\nglobal.Flotr = Flotr;\n\n})();\n\n/**\n * Flotr Defaults\n */\nFlotr.defaultOptions = {\n  colors: ['#00A8F0', '#C0D800', '#CB4B4B', '#4DA74D', '#9440ED'], //=> The default colorscheme. When there are > 5 series, additional colors are generated.\n  ieBackgroundColor: '#FFFFFF', // Background color for excanvas clipping\n  title: null,             // => The graph's title\n  subtitle: null,          // => The graph's subtitle\n  shadowSize: 4,           // => size of the 'fake' shadow\n  defaultType: null,       // => default series type\n  HtmlText: true,          // => wether to draw the text using HTML or on the canvas\n  fontColor: '#545454',    // => default font color\n  fontSize: 7.5,           // => canvas' text font size\n  resolution: 1,           // => resolution of the graph, to have printer-friendly graphs !\n  parseFloat: true,        // => whether to preprocess data for floats (ie. if input is string)\n  preventDefault: true,    // => preventDefault by default for mobile events.  Turn off to enable scroll.\n  xaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 0,         // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => color of the ticks\n    mode: 'normal',        // => can be 'time' or 'normal'\n    timeFormat: null,\n    timeMode:'UTC',        // => For UTC time ('local' for local time).\n    timeUnit:'millisecond',// => Unit for time (millisecond, second, minute, hour, day, month, year)\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  x2axis: {},\n  yaxis: {\n    ticks: null,           // => format: either [1, 3] or [[1, 'a'], 3]\n    minorTicks: null,      // => format: either [1, 3] or [[1, 'a'], 3]\n    showLabels: true,      // => setting to true will show the axis ticks labels, hide otherwise\n    showMinorLabels: false,// => true to show the axis minor ticks labels, false to hide\n    labelsAngle: 0,        // => labels' angle, in degrees\n    title: null,           // => axis title\n    titleAngle: 90,        // => axis title's angle, in degrees\n    noTicks: 5,            // => number of ticks for automagically generated ticks\n    minorTickFreq: null,   // => number of minor ticks between major ticks for autogenerated ticks\n    tickFormatter: Flotr.defaultTickFormatter, // => fn: number, Object -> string\n    tickDecimals: null,    // => no. of decimals, null means auto\n    min: null,             // => min. value to show, null means set automatically\n    max: null,             // => max. value to show, null means set automatically\n    autoscale: false,      // => Turns autoscaling on with true\n    autoscaleMargin: 0,    // => margin in % to add if auto-setting min/max\n    color: null,           // => The color of the ticks\n    scaling: 'linear',     // => Scaling, can be 'linear' or 'logarithmic'\n    base: Math.E,\n    titleAlign: 'center',\n    margin: true           // => Turn off margins with false\n  },\n  y2axis: {\n    titleAngle: 270\n  },\n  grid: {\n    color: '#545454',      // => primary color used for outline and labels\n    backgroundColor: null, // => null for transparent, else color\n    backgroundImage: null, // => background image. String or object with src, left and top\n    watermarkAlpha: 0.4,   // => \n    tickColor: '#DDDDDD',  // => color used for the ticks\n    labelMargin: 3,        // => margin in pixels\n    verticalLines: true,   // => whether to show gridlines in vertical direction\n    minorVerticalLines: null, // => whether to show gridlines for minor ticks in vertical dir.\n    horizontalLines: true, // => whether to show gridlines in horizontal direction\n    minorHorizontalLines: null, // => whether to show gridlines for minor ticks in horizontal dir.\n    outlineWidth: 1,       // => width of the grid outline/border in pixels\n    outline : 'nsew',      // => walls of the outline to display\n    circular: false        // => if set to true, the grid will be circular, must be used when radars are drawn\n  },\n  mouse: {\n    track: false,          // => true to track the mouse, no tracking otherwise\n    trackAll: false,\n    position: 'se',        // => position of the value box (default south-east).  False disables.\n    relative: false,       // => next to the mouse cursor\n    trackFormatter: Flotr.defaultTrackFormatter, // => formats the values in the value box\n    margin: 5,             // => margin in pixels of the valuebox\n    lineColor: '#FF3F19',  // => line color of points that are drawn when mouse comes near a value of a series\n    trackDecimals: 1,      // => decimals for the track values\n    sensibility: 2,        // => the lower this number, the more precise you have to aim to show a value\n    trackY: true,          // => whether or not to track the mouse in the y axis\n    radius: 3,             // => radius of the track point\n    fillColor: null,       // => color to fill our select bar with only applies to bar and similar graphs (only bars for now)\n    fillOpacity: 0.4       // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill \n  }\n};\n\n/**\n * Flotr Color\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\n// Constructor\nfunction Color (r, g, b, a) {\n  this.rgba = ['r','g','b','a'];\n  var x = 4;\n  while(-1<--x){\n    this[this.rgba[x]] = arguments[x] || ((x==3) ? 1.0 : 0);\n  }\n  this.normalize();\n}\n\n// Constants\nvar COLOR_NAMES = {\n  aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],\n  brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],\n  darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],\n  darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],\n  darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],\n  khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],\n  lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],\n  maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],\n  violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]\n};\n\nColor.prototype = {\n  scale: function(rf, gf, bf, af){\n    var x = 4;\n    while (-1 < --x) {\n      if (!_.isUndefined(arguments[x])) this[this.rgba[x]] *= arguments[x];\n    }\n    return this.normalize();\n  },\n  alpha: function(alpha) {\n    if (!_.isUndefined(alpha) && !_.isNull(alpha)) {\n      this.a = alpha;\n    }\n    return this.normalize();\n  },\n  clone: function(){\n    return new Color(this.r, this.b, this.g, this.a);\n  },\n  limit: function(val,minVal,maxVal){\n    return Math.max(Math.min(val, maxVal), minVal);\n  },\n  normalize: function(){\n    var limit = this.limit;\n    this.r = limit(parseInt(this.r, 10), 0, 255);\n    this.g = limit(parseInt(this.g, 10), 0, 255);\n    this.b = limit(parseInt(this.b, 10), 0, 255);\n    this.a = limit(this.a, 0, 1);\n    return this;\n  },\n  distance: function(color){\n    if (!color) return;\n    color = new Color.parse(color);\n    var dist = 0, x = 3;\n    while(-1<--x){\n      dist += Math.abs(this[this.rgba[x]] - color[this.rgba[x]]);\n    }\n    return dist;\n  },\n  toString: function(){\n    return (this.a >= 1.0) ? 'rgb('+[this.r,this.g,this.b].join(',')+')' : 'rgba('+[this.r,this.g,this.b,this.a].join(',')+')';\n  },\n  contrast: function () {\n    var\n      test = 1 - ( 0.299 * this.r + 0.587 * this.g + 0.114 * this.b) / 255;\n    return (test < 0.5 ? '#000000' : '#ffffff');\n  }\n};\n\n_.extend(Color, {\n  /**\n   * Parses a color string and returns a corresponding Color.\n   * The different tests are in order of probability to improve speed.\n   * @param {String, Color} str - string thats representing a color\n   * @return {Color} returns a Color object or false\n   */\n  parse: function(color){\n    if (color instanceof Color) return color;\n\n    var result;\n\n    // #a0b1c2\n    if((result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)))\n      return new Color(parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16));\n\n    // rgb(num,num,num)\n    if((result = /rgb\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10));\n  \n    // #fff\n    if((result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)))\n      return new Color(parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16));\n  \n    // rgba(num,num,num,num)\n    if((result = /rgba\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseInt(result[1], 10), parseInt(result[2], 10), parseInt(result[3], 10), parseFloat(result[4]));\n      \n    // rgb(num%,num%,num%)\n    if((result = /rgb\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55);\n  \n    // rgba(num%,num%,num%,num)\n    if((result = /rgba\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\s*\\)/.exec(color)))\n      return new Color(parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, parseFloat(result[4]));\n\n    // Otherwise, we're most likely dealing with a named color.\n    var name = (color+'').replace(/^\\s*([\\S\\s]*?)\\s*$/, '$1').toLowerCase();\n    if(name == 'transparent'){\n      return new Color(255, 255, 255, 0);\n    }\n    return (result = COLOR_NAMES[name]) ? new Color(result[0], result[1], result[2]) : new Color(0, 0, 0, 0);\n  },\n\n  /**\n   * Process color and options into color style.\n   */\n  processColor: function(color, options) {\n\n    var opacity = options.opacity;\n    if (!color) return 'rgba(0, 0, 0, 0)';\n    if (color instanceof Color) return color.alpha(opacity).toString();\n    if (_.isString(color)) return Color.parse(color).alpha(opacity).toString();\n    \n    var grad = color.colors ? color : {colors: color};\n    \n    if (!options.ctx) {\n      if (!_.isArray(grad.colors)) return 'rgba(0, 0, 0, 0)';\n      return Color.parse(_.isArray(grad.colors[0]) ? grad.colors[0][1] : grad.colors[0]).alpha(opacity).toString();\n    }\n    grad = _.extend({start: 'top', end: 'bottom'}, grad); \n    \n    if (/top/i.test(grad.start))  options.x1 = 0;\n    if (/left/i.test(grad.start)) options.y1 = 0;\n    if (/bottom/i.test(grad.end)) options.x2 = 0;\n    if (/right/i.test(grad.end))  options.y2 = 0;\n\n    var i, c, stop, gradient = options.ctx.createLinearGradient(options.x1, options.y1, options.x2, options.y2);\n    for (i = 0; i < grad.colors.length; i++) {\n      c = grad.colors[i];\n      if (_.isArray(c)) {\n        stop = c[0];\n        c = c[1];\n      }\n      else stop = i / (grad.colors.length-1);\n      gradient.addColorStop(stop, Color.parse(c).alpha(opacity));\n    }\n    return gradient;\n  }\n});\n\nFlotr.Color = Color;\n\n})();\n\n/**\n * Flotr Date\n */\nFlotr.Date = {\n\n  set : function (date, name, mode, value) {\n    mode = mode || 'UTC';\n    name = 'set' + (mode === 'UTC' ? 'UTC' : '') + name;\n    date[name](value);\n  },\n\n  get : function (date, name, mode) {\n    mode = mode || 'UTC';\n    name = 'get' + (mode === 'UTC' ? 'UTC' : '') + name;\n    return date[name]();\n  },\n\n  format: function(d, format, mode) {\n    if (!d) return;\n\n    // We should maybe use an \"official\" date format spec, like PHP date() or ColdFusion \n    // http://fr.php.net/manual/en/function.date.php\n    // http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_29.html\n    var\n      get = this.get,\n      tokens = {\n        h: get(d, 'Hours', mode).toString(),\n        H: leftPad(get(d, 'Hours', mode)),\n        M: leftPad(get(d, 'Minutes', mode)),\n        S: leftPad(get(d, 'Seconds', mode)),\n        s: get(d, 'Milliseconds', mode),\n        d: get(d, 'Date', mode).toString(),\n        m: (get(d, 'Month', mode) + 1).toString(),\n        y: get(d, 'FullYear', mode).toString(),\n        b: Flotr.Date.monthNames[get(d, 'Month', mode)]\n      };\n\n    function leftPad(n){\n      n += '';\n      return n.length == 1 ? \"0\" + n : n;\n    }\n    \n    var r = [], c,\n        escape = false;\n    \n    for (var i = 0; i < format.length; ++i) {\n      c = format.charAt(i);\n      \n      if (escape) {\n        r.push(tokens[c] || c);\n        escape = false;\n      }\n      else if (c == \"%\")\n        escape = true;\n      else\n        r.push(c);\n    }\n    return r.join('');\n  },\n  getFormat: function(time, span) {\n    var tu = Flotr.Date.timeUnits;\n         if (time < tu.second) return \"%h:%M:%S.%s\";\n    else if (time < tu.minute) return \"%h:%M:%S\";\n    else if (time < tu.day)    return (span < 2 * tu.day) ? \"%h:%M\" : \"%b %d %h:%M\";\n    else if (time < tu.month)  return \"%b %d\";\n    else if (time < tu.year)   return (span < tu.year) ? \"%b\" : \"%b %y\";\n    else                       return \"%y\";\n  },\n  formatter: function (v, axis) {\n    var\n      options = axis.options,\n      scale = Flotr.Date.timeUnits[options.timeUnit],\n      d = new Date(v * scale);\n\n    // first check global format\n    if (axis.options.timeFormat)\n      return Flotr.Date.format(d, options.timeFormat, options.timeMode);\n    \n    var span = (axis.max - axis.min) * scale,\n        t = axis.tickSize * Flotr.Date.timeUnits[axis.tickUnit];\n\n    return Flotr.Date.format(d, Flotr.Date.getFormat(t, span), options.timeMode);\n  },\n  generator: function(axis) {\n\n     var\n      set       = this.set,\n      get       = this.get,\n      timeUnits = this.timeUnits,\n      spec      = this.spec,\n      options   = axis.options,\n      mode      = options.timeMode,\n      scale     = timeUnits[options.timeUnit],\n      min       = axis.min * scale,\n      max       = axis.max * scale,\n      delta     = (max - min) / options.noTicks,\n      ticks     = [],\n      tickSize  = axis.tickSize,\n      tickUnit,\n      formatter, i;\n\n    // Use custom formatter or time tick formatter\n    formatter = (options.tickFormatter === Flotr.defaultTickFormatter ?\n      this.formatter : options.tickFormatter\n    );\n\n    for (i = 0; i < spec.length - 1; ++i) {\n      var d = spec[i][0] * timeUnits[spec[i][1]];\n      if (delta < (d + spec[i+1][0] * timeUnits[spec[i+1][1]]) / 2 && d >= tickSize)\n        break;\n    }\n    tickSize = spec[i][0];\n    tickUnit = spec[i][1];\n\n    // special-case the possibility of several years\n    if (tickUnit == \"year\") {\n      tickSize = Flotr.getTickSize(options.noTicks*timeUnits.year, min, max, 0);\n\n      // Fix for 0.5 year case\n      if (tickSize == 0.5) {\n        tickUnit = \"month\";\n        tickSize = 6;\n      }\n    }\n\n    axis.tickUnit = tickUnit;\n    axis.tickSize = tickSize;\n\n    var step = tickSize * timeUnits[tickUnit];\n    d = new Date(min);\n\n    function setTick (name) {\n      set(d, name, mode, Flotr.floorInBase(\n        get(d, name, mode), tickSize\n      ));\n    }\n\n    switch (tickUnit) {\n      case \"millisecond\": setTick('Milliseconds'); break;\n      case \"second\": setTick('Seconds'); break;\n      case \"minute\": setTick('Minutes'); break;\n      case \"hour\": setTick('Hours'); break;\n      case \"month\": setTick('Month'); break;\n      case \"year\": setTick('FullYear'); break;\n    }\n    \n    // reset smaller components\n    if (step >= timeUnits.second)  set(d, 'Milliseconds', mode, 0);\n    if (step >= timeUnits.minute)  set(d, 'Seconds', mode, 0);\n    if (step >= timeUnits.hour)    set(d, 'Minutes', mode, 0);\n    if (step >= timeUnits.day)     set(d, 'Hours', mode, 0);\n    if (step >= timeUnits.day * 4) set(d, 'Date', mode, 1);\n    if (step >= timeUnits.year)    set(d, 'Month', mode, 0);\n\n    var carry = 0, v = NaN, prev;\n    do {\n      prev = v;\n      v = d.getTime();\n      ticks.push({ v: v / scale, label: formatter(v / scale, axis) });\n      if (tickUnit == \"month\") {\n        if (tickSize < 1) {\n          /* a bit complicated - we'll divide the month up but we need to take care of fractions\n           so we don't end up in the middle of a day */\n          set(d, 'Date', mode, 1);\n          var start = d.getTime();\n          set(d, 'Month', mode, get(d, 'Month', mode) + 1);\n          var end = d.getTime();\n          d.setTime(v + carry * timeUnits.hour + (end - start) * tickSize);\n          carry = get(d, 'Hours', mode);\n          set(d, 'Hours', mode, 0);\n        }\n        else\n          set(d, 'Month', mode, get(d, 'Month', mode) + tickSize);\n      }\n      else if (tickUnit == \"year\") {\n        set(d, 'FullYear', mode, get(d, 'FullYear', mode) + tickSize);\n      }\n      else\n        d.setTime(v + step);\n\n    } while (v < max && v != prev);\n\n    return ticks;\n  },\n  timeUnits: {\n    millisecond: 1,\n    second: 1000,\n    minute: 1000 * 60,\n    hour:   1000 * 60 * 60,\n    day:    1000 * 60 * 60 * 24,\n    month:  1000 * 60 * 60 * 24 * 30,\n    year:   1000 * 60 * 60 * 24 * 365.2425\n  },\n  // the allowed tick sizes, after 1 year we use an integer algorithm\n  spec: [\n    [1, \"millisecond\"], [20, \"millisecond\"], [50, \"millisecond\"], [100, \"millisecond\"], [200, \"millisecond\"], [500, \"millisecond\"], \n    [1, \"second\"],   [2, \"second\"],  [5, \"second\"], [10, \"second\"], [30, \"second\"], \n    [1, \"minute\"],   [2, \"minute\"],  [5, \"minute\"], [10, \"minute\"], [30, \"minute\"], \n    [1, \"hour\"],     [2, \"hour\"],    [4, \"hour\"],   [8, \"hour\"],    [12, \"hour\"],\n    [1, \"day\"],      [2, \"day\"],     [3, \"day\"],\n    [0.25, \"month\"], [0.5, \"month\"], [1, \"month\"],  [2, \"month\"],   [3, \"month\"], [6, \"month\"],\n    [1, \"year\"]\n  ],\n  monthNames: [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n};\n\n(function () {\n\nvar _ = Flotr._;\n\nfunction getEl (el) {\n  return (el && el.jquery) ? el[0] : el;\n}\n\nFlotr.DOM = {\n  addClass: function(element, name){\n    element = getEl(element);\n    var classList = (element.className ? element.className : '');\n      if (_.include(classList.split(/\\s+/g), name)) return;\n    element.className = (classList ? classList + ' ' : '') + name;\n  },\n  /**\n   * Create an element.\n   */\n  create: function(tag){\n    return document.createElement(tag);\n  },\n  node: function(html) {\n    var div = Flotr.DOM.create('div'), n;\n    div.innerHTML = html;\n    n = div.children[0];\n    div.innerHTML = '';\n    return n;\n  },\n  /**\n   * Remove all children.\n   */\n  empty: function(element){\n    element = getEl(element);\n    element.innerHTML = '';\n    /*\n    if (!element) return;\n    _.each(element.childNodes, function (e) {\n      Flotr.DOM.empty(e);\n      element.removeChild(e);\n    });\n    */\n  },\n  remove: function (element) {\n    element = getEl(element);\n    element.parentNode.removeChild(element);\n  },\n  hide: function(element){\n    element = getEl(element);\n    Flotr.DOM.setStyles(element, {display:'none'});\n  },\n  /**\n   * Insert a child.\n   * @param {Element} element\n   * @param {Element|String} Element or string to be appended.\n   */\n  insert: function(element, child){\n    element = getEl(element);\n    if(_.isString(child))\n      element.innerHTML += child;\n    else if (_.isElement(child))\n      element.appendChild(child);\n  },\n  // @TODO find xbrowser implementation\n  opacity: function(element, opacity) {\n    element = getEl(element);\n    element.style.opacity = opacity;\n  },\n  position: function(element, p){\n    element = getEl(element);\n    if (!element.offsetParent)\n      return {left: (element.offsetLeft || 0), top: (element.offsetTop || 0)};\n\n    p = this.position(element.offsetParent);\n    p.left  += element.offsetLeft;\n    p.top   += element.offsetTop;\n    return p;\n  },\n  removeClass: function(element, name) {\n    var classList = (element.className ? element.className : '');\n    element = getEl(element);\n    element.className = _.filter(classList.split(/\\s+/g), function (c) {\n      if (c != name) return true; }\n    ).join(' ');\n  },\n  setStyles: function(element, o) {\n    element = getEl(element);\n    _.each(o, function (value, key) {\n      element.style[key] = value;\n    });\n  },\n  show: function(element){\n    element = getEl(element);\n    Flotr.DOM.setStyles(element, {display:''});\n  },\n  /**\n   * Return element size.\n   */\n  size: function(element){\n    element = getEl(element);\n    return {\n      height : element.offsetHeight,\n      width : element.offsetWidth };\n  }\n};\n\n})();\n\n/**\n * Flotr Event Adapter\n */\n(function () {\nvar\n  F = Flotr,\n  bean = F.bean;\nF.EventAdapter = {\n  observe: function(object, name, callback) {\n    bean.add(object, name, callback);\n    return this;\n  },\n  fire: function(object, name, args) {\n    bean.fire(object, name, args);\n    if (typeof(Prototype) != 'undefined')\n      Event.fire(object, name, args);\n    // @TODO Someone who uses mootools, add mootools adapter for existing applciations.\n    return this;\n  },\n  stopObserving: function(object, name, callback) {\n    bean.remove(object, name, callback);\n    return this;\n  },\n  eventPointer: function(e) {\n    if (!F._.isUndefined(e.touches) && e.touches.length > 0) {\n      return {\n        x : e.touches[0].pageX,\n        y : e.touches[0].pageY\n      };\n    } else if (!F._.isUndefined(e.changedTouches) && e.changedTouches.length > 0) {\n      return {\n        x : e.changedTouches[0].pageX,\n        y : e.changedTouches[0].pageY\n      };\n    } else if (e.pageX || e.pageY) {\n      return {\n        x : e.pageX,\n        y : e.pageY\n      };\n    } else if (e.clientX || e.clientY) {\n      var\n        d = document,\n        b = d.body,\n        de = d.documentElement;\n      return {\n        x: e.clientX + b.scrollLeft + de.scrollLeft,\n        y: e.clientY + b.scrollTop + de.scrollTop\n      };\n    }\n  }\n};\n})();\n\n/**\n * Text Utilities\n */\n(function () {\n\nvar\n  F = Flotr,\n  D = F.DOM,\n  _ = F._,\n\nText = function (o) {\n  this.o = o;\n};\n\nText.prototype = {\n\n  dimensions : function (text, canvasStyle, htmlStyle, className) {\n\n    if (!text) return { width : 0, height : 0 };\n    \n    return (this.o.html) ?\n      this.html(text, this.o.element, htmlStyle, className) : \n      this.canvas(text, canvasStyle);\n  },\n\n  canvas : function (text, style) {\n\n    if (!this.o.textEnabled) return;\n    style = style || {};\n\n    var\n      metrics = this.measureText(text, style),\n      width = metrics.width,\n      height = style.size || F.defaultOptions.fontSize,\n      angle = style.angle || 0,\n      cosAngle = Math.cos(angle),\n      sinAngle = Math.sin(angle),\n      widthPadding = 2,\n      heightPadding = 6,\n      bounds;\n\n    bounds = {\n      width: Math.abs(cosAngle * width) + Math.abs(sinAngle * height) + widthPadding,\n      height: Math.abs(sinAngle * width) + Math.abs(cosAngle * height) + heightPadding\n    };\n\n    return bounds;\n  },\n\n  html : function (text, element, style, className) {\n\n    var div = D.create('div');\n\n    D.setStyles(div, { 'position' : 'absolute', 'top' : '-10000px' });\n    D.insert(div, '<div style=\"'+style+'\" class=\"'+className+' flotr-dummy-div\">' + text + '</div>');\n    D.insert(this.o.element, div);\n\n    return D.size(div);\n  },\n\n  measureText : function (text, style) {\n\n    var\n      context = this.o.ctx,\n      metrics;\n\n    if (!context.fillText || (F.isIphone && context.measure)) {\n      return { width : context.measure(text, style)};\n    }\n\n    style = _.extend({\n      size: F.defaultOptions.fontSize,\n      weight: 1,\n      angle: 0\n    }, style);\n\n    context.save();\n    context.font = (style.weight > 1 ? \"bold \" : \"\") + (style.size*1.3) + \"px sans-serif\";\n    metrics = context.measureText(text);\n    context.restore();\n\n    return metrics;\n  }\n};\n\nFlotr.Text = Text;\n\n})();\n\n/**\n * Flotr Graph class that plots a graph on creation.\n */\n(function () {\n\nvar\n  D     = Flotr.DOM,\n  E     = Flotr.EventAdapter,\n  _     = Flotr._,\n  flotr = Flotr;\n/**\n * Flotr Graph constructor.\n * @param {Element} el - element to insert the graph into\n * @param {Object} data - an array or object of dataseries\n * @param {Object} options - an object containing options\n */\nGraph = function(el, data, options){\n// Let's see if we can get away with out this [JS]\n//  try {\n    this._setEl(el);\n    this._initMembers();\n    this._initPlugins();\n\n    E.fire(this.el, 'flotr:beforeinit', [this]);\n\n    this.data = data;\n    this.series = flotr.Series.getSeries(data);\n    this._initOptions(options);\n    this._initGraphTypes();\n    this._initCanvas();\n    this._text = new flotr.Text({\n      element : this.el,\n      ctx : this.ctx,\n      html : this.options.HtmlText,\n      textEnabled : this.textEnabled\n    });\n    E.fire(this.el, 'flotr:afterconstruct', [this]);\n    this._initEvents();\n\n    this.findDataRanges();\n    this.calculateSpacing();\n\n    this.draw(_.bind(function() {\n      E.fire(this.el, 'flotr:afterinit', [this]);\n    }, this));\n/*\n    try {\n  } catch (e) {\n    try {\n      console.error(e);\n    } catch (e2) {}\n  }*/\n};\n\nfunction observe (object, name, callback) {\n  E.observe.apply(this, arguments);\n  this._handles.push(arguments);\n  return this;\n}\n\nGraph.prototype = {\n\n  destroy: function () {\n    E.fire(this.el, 'flotr:destroy');\n    _.each(this._handles, function (handle) {\n      E.stopObserving.apply(this, handle);\n    });\n    this._handles = [];\n    this.el.graph = null;\n  },\n\n  observe : observe,\n\n  /**\n   * @deprecated\n   */\n  _observe : observe,\n\n  processColor: function(color, options){\n    var o = { x1: 0, y1: 0, x2: this.plotWidth, y2: this.plotHeight, opacity: 1, ctx: this.ctx };\n    _.extend(o, options);\n    return flotr.Color.processColor(color, o);\n  },\n  /**\n   * Function determines the min and max values for the xaxis and yaxis.\n   *\n   * TODO logarithmic range validation (consideration of 0)\n   */\n  findDataRanges: function(){\n    var a = this.axes,\n      xaxis, yaxis, range;\n\n    _.each(this.series, function (series) {\n      range = series.getRange();\n      if (range) {\n        xaxis = series.xaxis;\n        yaxis = series.yaxis;\n        xaxis.datamin = Math.min(range.xmin, xaxis.datamin);\n        xaxis.datamax = Math.max(range.xmax, xaxis.datamax);\n        yaxis.datamin = Math.min(range.ymin, yaxis.datamin);\n        yaxis.datamax = Math.max(range.ymax, yaxis.datamax);\n        xaxis.used = (xaxis.used || range.xused);\n        yaxis.used = (yaxis.used || range.yused);\n      }\n    }, this);\n\n    // Check for empty data, no data case (none used)\n    if (!a.x.used && !a.x2.used) a.x.used = true;\n    if (!a.y.used && !a.y2.used) a.y.used = true;\n\n    _.each(a, function (axis) {\n      axis.calculateRange();\n    });\n\n    var\n      types = _.keys(flotr.graphTypes),\n      drawn = false;\n\n    _.each(this.series, function (series) {\n      if (series.hide) return;\n      _.each(types, function (type) {\n        if (series[type] && series[type].show) {\n          this.extendRange(type, series);\n          drawn = true;\n        }\n      }, this);\n      if (!drawn) {\n        this.extendRange(this.options.defaultType, series);\n      }\n    }, this);\n  },\n\n  extendRange : function (type, series) {\n    if (this[type].extendRange) this[type].extendRange(series, series.data, series[type], this[type]);\n    if (this[type].extendYRange) this[type].extendYRange(series.yaxis, series.data, series[type], this[type]);\n    if (this[type].extendXRange) this[type].extendXRange(series.xaxis, series.data, series[type], this[type]);\n  },\n\n  /**\n   * Calculates axis label sizes.\n   */\n  calculateSpacing: function(){\n\n    var a = this.axes,\n        options = this.options,\n        series = this.series,\n        margin = options.grid.labelMargin,\n        T = this._text,\n        x = a.x,\n        x2 = a.x2,\n        y = a.y,\n        y2 = a.y2,\n        maxOutset = options.grid.outlineWidth,\n        i, j, l, dim;\n\n    // TODO post refactor, fix this\n    _.each(a, function (axis) {\n      axis.calculateTicks();\n      axis.calculateTextDimensions(T, options);\n    });\n\n    // Title height\n    dim = T.dimensions(\n      options.title,\n      {size: options.fontSize*1.5},\n      'font-size:1em;font-weight:bold;',\n      'flotr-title'\n    );\n    this.titleHeight = dim.height;\n\n    // Subtitle height\n    dim = T.dimensions(\n      options.subtitle,\n      {size: options.fontSize},\n      'font-size:smaller;',\n      'flotr-subtitle'\n    );\n    this.subtitleHeight = dim.height;\n\n    for(j = 0; j < options.length; ++j){\n      if (series[j].points.show){\n        maxOutset = Math.max(maxOutset, series[j].points.radius + series[j].points.lineWidth/2);\n      }\n    }\n\n    var p = this.plotOffset;\n    if (x.options.margin === false) {\n      p.bottom = 0;\n      p.top    = 0;\n    } else\n    if (x.options.margin === true) {\n      p.bottom += (options.grid.circular ? 0 : (x.used && x.options.showLabels ?  (x.maxLabel.height + margin) : 0)) +\n                  (x.used && x.options.title ? (x.titleSize.height + margin) : 0) + maxOutset;\n\n      p.top    += (options.grid.circular ? 0 : (x2.used && x2.options.showLabels ? (x2.maxLabel.height + margin) : 0)) +\n                  (x2.used && x2.options.title ? (x2.titleSize.height + margin) : 0) + this.subtitleHeight + this.titleHeight + maxOutset;\n    } else {\n      p.bottom = x.options.margin;\n      p.top = x.options.margin;\n    }\n    if (y.options.margin === false) {\n      p.left  = 0;\n      p.right = 0;\n    } else\n    if (y.options.margin === true) {\n      p.left   += (options.grid.circular ? 0 : (y.used && y.options.showLabels ?  (y.maxLabel.width + margin) : 0)) +\n                  (y.used && y.options.title ? (y.titleSize.width + margin) : 0) + maxOutset;\n\n      p.right  += (options.grid.circular ? 0 : (y2.used && y2.options.showLabels ? (y2.maxLabel.width + margin) : 0)) +\n                  (y2.used && y2.options.title ? (y2.titleSize.width + margin) : 0) + maxOutset;\n    } else {\n      p.left = y.options.margin;\n      p.right = y.options.margin;\n    }\n\n    p.top = Math.floor(p.top); // In order the outline not to be blured\n\n    this.plotWidth  = this.canvasWidth - p.left - p.right;\n    this.plotHeight = this.canvasHeight - p.bottom - p.top;\n\n    // TODO post refactor, fix this\n    x.length = x2.length = this.plotWidth;\n    y.length = y2.length = this.plotHeight;\n    y.offset = y2.offset = this.plotHeight;\n    x.setScale();\n    x2.setScale();\n    y.setScale();\n    y2.setScale();\n  },\n  /**\n   * Draws grid, labels, series and outline.\n   */\n  draw: function(after) {\n\n    var\n      context = this.ctx,\n      i;\n\n    E.fire(this.el, 'flotr:beforedraw', [this.series, this]);\n\n    if (this.series.length) {\n\n      context.save();\n      context.translate(this.plotOffset.left, this.plotOffset.top);\n\n      for (i = 0; i < this.series.length; i++) {\n        if (!this.series[i].hide) this.drawSeries(this.series[i]);\n      }\n\n      context.restore();\n      this.clip();\n    }\n\n    E.fire(this.el, 'flotr:afterdraw', [this.series, this]);\n    if (after) after();\n  },\n  /**\n   * Actually draws the graph.\n   * @param {Object} series - series to draw\n   */\n  drawSeries: function(series){\n\n    function drawChart (series, typeKey) {\n      var options = this.getOptions(series, typeKey);\n      this[typeKey].draw(options);\n    }\n\n    var drawn = false;\n    series = series || this.series;\n\n    _.each(flotr.graphTypes, function (type, typeKey) {\n      if (series[typeKey] && series[typeKey].show && this[typeKey]) {\n        drawn = true;\n        drawChart.call(this, series, typeKey);\n      }\n    }, this);\n\n    if (!drawn) drawChart.call(this, series, this.options.defaultType);\n  },\n\n  getOptions : function (series, typeKey) {\n    var\n      type = series[typeKey],\n      graphType = this[typeKey],\n      xaxis = series.xaxis,\n      yaxis = series.yaxis,\n      options = {\n        context     : this.ctx,\n        width       : this.plotWidth,\n        height      : this.plotHeight,\n        fontSize    : this.options.fontSize,\n        fontColor   : this.options.fontColor,\n        textEnabled : this.textEnabled,\n        htmlText    : this.options.HtmlText,\n        text        : this._text, // TODO Is this necessary?\n        element     : this.el,\n        data        : series.data,\n        color       : series.color,\n        shadowSize  : series.shadowSize,\n        xScale      : xaxis.d2p,\n        yScale      : yaxis.d2p,\n        xInverse    : xaxis.p2d,\n        yInverse    : yaxis.p2d\n      };\n\n    options = flotr.merge(type, options);\n\n    // Fill\n    options.fillStyle = this.processColor(\n      type.fillColor || series.color,\n      {opacity: type.fillOpacity}\n    );\n\n    return options;\n  },\n  /**\n   * Calculates the coordinates from a mouse event object.\n   * @param {Event} event - Mouse Event object.\n   * @return {Object} Object with coordinates of the mouse.\n   */\n  getEventPosition: function (e){\n\n    var\n      d = document,\n      b = d.body,\n      de = d.documentElement,\n      axes = this.axes,\n      plotOffset = this.plotOffset,\n      lastMousePos = this.lastMousePos,\n      pointer = E.eventPointer(e),\n      dx = pointer.x - lastMousePos.pageX,\n      dy = pointer.y - lastMousePos.pageY,\n      r, rx, ry;\n\n    if ('ontouchstart' in this.el) {\n      r = D.position(this.overlay);\n      rx = pointer.x - r.left - plotOffset.left;\n      ry = pointer.y - r.top - plotOffset.top;\n    } else {\n      r = this.overlay.getBoundingClientRect();\n      rx = e.clientX - r.left - plotOffset.left - b.scrollLeft - de.scrollLeft;\n      ry = e.clientY - r.top - plotOffset.top - b.scrollTop - de.scrollTop;\n    }\n\n    return {\n      x:  axes.x.p2d(rx),\n      x2: axes.x2.p2d(rx),\n      y:  axes.y.p2d(ry),\n      y2: axes.y2.p2d(ry),\n      relX: rx,\n      relY: ry,\n      dX: dx,\n      dY: dy,\n      absX: pointer.x,\n      absY: pointer.y,\n      pageX: pointer.x,\n      pageY: pointer.y\n    };\n  },\n  /**\n   * Observes the 'click' event and fires the 'flotr:click' event.\n   * @param {Event} event - 'click' Event object.\n   */\n  clickHandler: function(event){\n    if(this.ignoreClick){\n      this.ignoreClick = false;\n      return this.ignoreClick;\n    }\n    E.fire(this.el, 'flotr:click', [this.getEventPosition(event), this]);\n  },\n  /**\n   * Observes mouse movement over the graph area. Fires the 'flotr:mousemove' event.\n   * @param {Event} event - 'mousemove' Event object.\n   */\n  mouseMoveHandler: function(event){\n    if (this.mouseDownMoveHandler) return;\n    var pos = this.getEventPosition(event);\n    E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n    this.lastMousePos = pos;\n  },\n  /**\n   * Observes the 'mousedown' event.\n   * @param {Event} event - 'mousedown' Event object.\n   */\n  mouseDownHandler: function (event){\n\n    /*\n    // @TODO Context menu?\n    if(event.isRightClick()) {\n      event.stop();\n\n      var overlay = this.overlay;\n      overlay.hide();\n\n      function cancelContextMenu () {\n        overlay.show();\n        E.stopObserving(document, 'mousemove', cancelContextMenu);\n      }\n      E.observe(document, 'mousemove', cancelContextMenu);\n      return;\n    }\n    */\n\n    if (this.mouseUpHandler) return;\n    this.mouseUpHandler = _.bind(function (e) {\n      E.stopObserving(document, 'mouseup', this.mouseUpHandler);\n      E.stopObserving(document, 'mousemove', this.mouseDownMoveHandler);\n      this.mouseDownMoveHandler = null;\n      this.mouseUpHandler = null;\n      // @TODO why?\n      //e.stop();\n      E.fire(this.el, 'flotr:mouseup', [e, this]);\n    }, this);\n    this.mouseDownMoveHandler = _.bind(function (e) {\n        var pos = this.getEventPosition(e);\n        E.fire(this.el, 'flotr:mousemove', [event, pos, this]);\n        this.lastMousePos = pos;\n    }, this);\n    E.observe(document, 'mouseup', this.mouseUpHandler);\n    E.observe(document, 'mousemove', this.mouseDownMoveHandler);\n    E.fire(this.el, 'flotr:mousedown', [event, this]);\n    this.ignoreClick = false;\n  },\n  drawTooltip: function(content, x, y, options) {\n    var mt = this.getMouseTrack(),\n        style = 'opacity:0.7;background-color:#000;color:#fff;display:none;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;',\n        p = options.position,\n        m = options.margin,\n        plotOffset = this.plotOffset;\n\n    if(x !== null && y !== null){\n      if (!options.relative) { // absolute to the canvas\n             if(p.charAt(0) == 'n') style += 'top:' + (m + plotOffset.top) + 'px;bottom:auto;';\n        else if(p.charAt(0) == 's') style += 'bottom:' + (m + plotOffset.bottom) + 'px;top:auto;';\n             if(p.charAt(1) == 'e') style += 'right:' + (m + plotOffset.right) + 'px;left:auto;';\n        else if(p.charAt(1) == 'w') style += 'left:' + (m + plotOffset.left) + 'px;right:auto;';\n      }\n      else { // relative to the mouse\n             if(p.charAt(0) == 'n') style += 'bottom:' + (m - plotOffset.top - y + this.canvasHeight) + 'px;top:auto;';\n        else if(p.charAt(0) == 's') style += 'top:' + (m + plotOffset.top + y) + 'px;bottom:auto;';\n             if(p.charAt(1) == 'e') style += 'left:' + (m + plotOffset.left + x) + 'px;right:auto;';\n        else if(p.charAt(1) == 'w') style += 'right:' + (m - plotOffset.left - x + this.canvasWidth) + 'px;left:auto;';\n      }\n\n      mt.style.cssText = style;\n      D.empty(mt);\n      D.insert(mt, content);\n      D.show(mt);\n    }\n    else {\n      D.hide(mt);\n    }\n  },\n\n  clip: function (ctx) {\n\n    var\n      o   = this.plotOffset,\n      w   = this.canvasWidth,\n      h   = this.canvasHeight;\n\n    ctx = ctx || this.ctx;\n\n    if (\n      flotr.isIE && flotr.isIE < 9 && // IE w/o canvas\n      !flotr.isFlashCanvas // But not flash canvas\n    ) {\n\n      // Do not clip excanvas on overlay context\n      // Allow hits to overflow.\n      if (ctx === this.octx) {\n        return;\n      }\n\n      // Clipping for excanvas :-(\n      ctx.save();\n      ctx.fillStyle = this.processColor(this.options.ieBackgroundColor);\n      ctx.fillRect(0, 0, w, o.top);\n      ctx.fillRect(0, 0, o.left, h);\n      ctx.fillRect(0, h - o.bottom, w, o.bottom);\n      ctx.fillRect(w - o.right, 0, o.right,h);\n      ctx.restore();\n    } else {\n      ctx.clearRect(0, 0, w, o.top);\n      ctx.clearRect(0, 0, o.left, h);\n      ctx.clearRect(0, h - o.bottom, w, o.bottom);\n      ctx.clearRect(w - o.right, 0, o.right,h);\n    }\n  },\n\n  _initMembers: function() {\n    this._handles = [];\n    this.lastMousePos = {pageX: null, pageY: null };\n    this.plotOffset = {left: 0, right: 0, top: 0, bottom: 0};\n    this.ignoreClick = true;\n    this.prevHit = null;\n  },\n\n  _initGraphTypes: function() {\n    _.each(flotr.graphTypes, function(handler, graphType){\n      this[graphType] = flotr.clone(handler);\n    }, this);\n  },\n\n  _initEvents: function () {\n\n    var\n      el = this.el,\n      touchendHandler, movement, touchend;\n\n    if ('ontouchstart' in el) {\n\n      touchendHandler = _.bind(function (e) {\n        touchend = true;\n        E.stopObserving(document, 'touchend', touchendHandler);\n        E.fire(el, 'flotr:mouseup', [event, this]);\n        this.multitouches = null;\n\n        if (!movement) {\n          this.clickHandler(e);\n        }\n      }, this);\n\n      this.observe(this.overlay, 'touchstart', _.bind(function (e) {\n        movement = false;\n        touchend = false;\n        this.ignoreClick = false;\n\n        if (e.touches && e.touches.length > 1) {\n          this.multitouches = e.touches;\n        }\n\n        E.fire(el, 'flotr:mousedown', [event, this]);\n        this.observe(document, 'touchend', touchendHandler);\n      }, this));\n\n      this.observe(this.overlay, 'touchmove', _.bind(function (e) {\n\n        var pos = this.getEventPosition(e);\n\n        if (this.options.preventDefault) {\n          e.preventDefault();\n        }\n\n        movement = true;\n\n        if (this.multitouches || (e.touches && e.touches.length > 1)) {\n          this.multitouches = e.touches;\n        } else {\n          if (!touchend) {\n            E.fire(el, 'flotr:mousemove', [event, pos, this]);\n          }\n        }\n        this.lastMousePos = pos;\n      }, this));\n\n    } else {\n      this.\n        observe(this.overlay, 'mousedown', _.bind(this.mouseDownHandler, this)).\n        observe(el, 'mousemove', _.bind(this.mouseMoveHandler, this)).\n        observe(this.overlay, 'click', _.bind(this.clickHandler, this)).\n        observe(el, 'mouseout', function (e) {\n          E.fire(el, 'flotr:mouseout', e);\n        });\n    }\n  },\n\n  /**\n   * Initializes the canvas and it's overlay canvas element. When the browser is IE, this makes use\n   * of excanvas. The overlay canvas is inserted for displaying interactions. After the canvas elements\n   * are created, the elements are inserted into the container element.\n   */\n  _initCanvas: function(){\n    var el = this.el,\n      o = this.options,\n      children = el.children,\n      removedChildren = [],\n      child, i,\n      size, style;\n\n    // Empty the el\n    for (i = children.length; i--;) {\n      child = children[i];\n      if (!this.canvas && child.className === 'flotr-canvas') {\n        this.canvas = child;\n      } else if (!this.overlay && child.className === 'flotr-overlay') {\n        this.overlay = child;\n      } else {\n        removedChildren.push(child);\n      }\n    }\n    for (i = removedChildren.length; i--;) {\n      el.removeChild(removedChildren[i]);\n    }\n\n    D.setStyles(el, {position: 'relative'}); // For positioning labels and overlay.\n    size = {};\n    size.width = el.clientWidth;\n    size.height = el.clientHeight;\n\n    if(size.width <= 0 || size.height <= 0 || o.resolution <= 0){\n      throw 'Invalid dimensions for plot, width = ' + size.width + ', height = ' + size.height + ', resolution = ' + o.resolution;\n    }\n\n    // Main canvas for drawing graph types\n    this.canvas = getCanvas(this.canvas, 'canvas');\n    // Overlay canvas for interactive features\n    this.overlay = getCanvas(this.overlay, 'overlay');\n    this.ctx = getContext(this.canvas);\n    this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n    this.octx = getContext(this.overlay);\n    this.octx.clearRect(0, 0, this.overlay.width, this.overlay.height);\n    this.canvasHeight = size.height;\n    this.canvasWidth = size.width;\n    this.textEnabled = !!this.ctx.drawText || !!this.ctx.fillText; // Enable text functions\n\n    function getCanvas(canvas, name){\n      if(!canvas){\n        canvas = D.create('canvas');\n        if (typeof FlashCanvas != \"undefined\" && typeof canvas.getContext === 'function') {\n          FlashCanvas.initElement(canvas);\n          this.isFlashCanvas = true;\n        }\n        canvas.className = 'flotr-'+name;\n        canvas.style.cssText = 'position:absolute;left:0px;top:0px;';\n        D.insert(el, canvas);\n      }\n      _.each(size, function(size, attribute){\n        D.show(canvas);\n        if (name == 'canvas' && canvas.getAttribute(attribute) === size) {\n          return;\n        }\n        canvas.setAttribute(attribute, size * o.resolution);\n        canvas.style[attribute] = size + 'px';\n      });\n      canvas.context_ = null; // Reset the ExCanvas context\n      return canvas;\n    }\n\n    function getContext(canvas){\n      if(window.G_vmlCanvasManager) window.G_vmlCanvasManager.initElement(canvas); // For ExCanvas\n      var context = canvas.getContext('2d');\n      if(!window.G_vmlCanvasManager) context.scale(o.resolution, o.resolution);\n      return context;\n    }\n  },\n\n  _initPlugins: function(){\n    // TODO Should be moved to flotr and mixed in.\n    _.each(flotr.plugins, function(plugin, name){\n      _.each(plugin.callbacks, function(fn, c){\n        this.observe(this.el, c, _.bind(fn, this));\n      }, this);\n      this[name] = flotr.clone(plugin);\n      _.each(this[name], function(fn, p){\n        if (_.isFunction(fn))\n          this[name][p] = _.bind(fn, this);\n      }, this);\n    }, this);\n  },\n\n  /**\n   * Sets options and initializes some variables and color specific values, used by the constructor.\n   * @param {Object} opts - options object\n   */\n  _initOptions: function(opts){\n    var options = flotr.clone(flotr.defaultOptions);\n    options.x2axis = _.extend(_.clone(options.xaxis), options.x2axis);\n    options.y2axis = _.extend(_.clone(options.yaxis), options.y2axis);\n    this.options = flotr.merge(opts || {}, options);\n\n    if (this.options.grid.minorVerticalLines === null &&\n      this.options.xaxis.scaling === 'logarithmic') {\n      this.options.grid.minorVerticalLines = true;\n    }\n    if (this.options.grid.minorHorizontalLines === null &&\n      this.options.yaxis.scaling === 'logarithmic') {\n      this.options.grid.minorHorizontalLines = true;\n    }\n\n    E.fire(this.el, 'flotr:afterinitoptions', [this]);\n\n    this.axes = flotr.Axis.getAxes(this.options);\n\n    // Initialize some variables used throughout this function.\n    var assignedColors = [],\n        colors = [],\n        ln = this.series.length,\n        neededColors = this.series.length,\n        oc = this.options.colors,\n        usedColors = [],\n        variation = 0,\n        c, i, j, s;\n\n    // Collect user-defined colors from series.\n    for(i = neededColors - 1; i > -1; --i){\n      c = this.series[i].color;\n      if(c){\n        --neededColors;\n        if(_.isNumber(c)) assignedColors.push(c);\n        else usedColors.push(flotr.Color.parse(c));\n      }\n    }\n\n    // Calculate the number of colors that need to be generated.\n    for(i = assignedColors.length - 1; i > -1; --i)\n      neededColors = Math.max(neededColors, assignedColors[i] + 1);\n\n    // Generate needed number of colors.\n    for(i = 0; colors.length < neededColors;){\n      c = (oc.length == i) ? new flotr.Color(100, 100, 100) : flotr.Color.parse(oc[i]);\n\n      // Make sure each serie gets a different color.\n      var sign = variation % 2 == 1 ? -1 : 1,\n          factor = 1 + sign * Math.ceil(variation / 2) * 0.2;\n      c.scale(factor, factor, factor);\n\n      /**\n       * @todo if we're getting too close to something else, we should probably skip this one\n       */\n      colors.push(c);\n\n      if(++i >= oc.length){\n        i = 0;\n        ++variation;\n      }\n    }\n\n    // Fill the options with the generated colors.\n    for(i = 0, j = 0; i < ln; ++i){\n      s = this.series[i];\n\n      // Assign the color.\n      if (!s.color){\n        s.color = colors[j++].toString();\n      }else if(_.isNumber(s.color)){\n        s.color = colors[s.color].toString();\n      }\n\n      // Every series needs an axis\n      if (!s.xaxis) s.xaxis = this.axes.x;\n           if (s.xaxis == 1) s.xaxis = this.axes.x;\n      else if (s.xaxis == 2) s.xaxis = this.axes.x2;\n\n      if (!s.yaxis) s.yaxis = this.axes.y;\n           if (s.yaxis == 1) s.yaxis = this.axes.y;\n      else if (s.yaxis == 2) s.yaxis = this.axes.y2;\n\n      // Apply missing options to the series.\n      for (var t in flotr.graphTypes){\n        s[t] = _.extend(_.clone(this.options[t]), s[t]);\n      }\n      s.mouse = _.extend(_.clone(this.options.mouse), s.mouse);\n\n      if (_.isUndefined(s.shadowSize)) s.shadowSize = this.options.shadowSize;\n    }\n  },\n\n  _setEl: function(el) {\n    if (!el) throw 'The target container doesn\\'t exist';\n    else if (el.graph instanceof Graph) el.graph.destroy();\n    else if (!el.clientWidth) throw 'The target container must be visible';\n\n    el.graph = this;\n    this.el = el;\n  }\n};\n\nFlotr.Graph = Graph;\n\n})();\n\n/**\n * Flotr Axis Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._,\n  LOGARITHMIC = 'logarithmic';\n\nfunction Axis (o) {\n\n  this.orientation = 1;\n  this.offset = 0;\n  this.datamin = Number.MAX_VALUE;\n  this.datamax = -Number.MAX_VALUE;\n\n  _.extend(this, o);\n}\n\n\n// Prototype\nAxis.prototype = {\n\n  setScale : function () {\n    var\n      length = this.length,\n      max = this.max,\n      min = this.min,\n      offset = this.offset,\n      orientation = this.orientation,\n      options = this.options,\n      logarithmic = options.scaling === LOGARITHMIC,\n      scale;\n\n    if (logarithmic) {\n      scale = length / (log(max, options.base) - log(min, options.base));\n    } else {\n      scale = length / (max - min);\n    }\n    this.scale = scale;\n\n    // Logarithmic?\n    if (logarithmic) {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (log(dataValue, options.base) - log(min, options.base)) * scale;\n      };\n      this.p2d = function (pointValue) {\n        return exp((offset + orientation * pointValue) / scale + log(min, options.base), options.base);\n      };\n    } else {\n      this.d2p = function (dataValue) {\n        return offset + orientation * (dataValue - min) * scale;\n      };\n      this.p2d = function (pointValue) {\n        return (offset + orientation * pointValue) / scale + min;\n      };\n    }\n  },\n\n  calculateTicks : function () {\n    var options = this.options;\n\n    this.ticks = [];\n    this.minorTicks = [];\n    \n    // User Ticks\n    if(options.ticks){\n      this._cleanUserTicks(options.ticks, this.ticks);\n      this._cleanUserTicks(options.minorTicks || [], this.minorTicks);\n    }\n    else {\n      if (options.mode == 'time') {\n        this._calculateTimeTicks();\n      } else if (options.scaling === 'logarithmic') {\n        this._calculateLogTicks();\n      } else {\n        this._calculateTicks();\n      }\n    }\n\n    // Ticks to strings\n    _.each(this.ticks, function (tick) { tick.label += ''; });\n    _.each(this.minorTicks, function (tick) { tick.label += ''; });\n  },\n\n  /**\n   * Calculates the range of an axis to apply autoscaling.\n   */\n  calculateRange: function () {\n\n    if (!this.used) return;\n\n    var axis  = this,\n      o       = axis.options,\n      min     = o.min !== null ? o.min : axis.datamin,\n      max     = o.max !== null ? o.max : axis.datamax,\n      margin  = o.autoscaleMargin;\n        \n    if (o.scaling == 'logarithmic') {\n      if (min <= 0) min = axis.datamin;\n\n      // Let it widen later on\n      if (max <= 0) max = min;\n    }\n\n    if (max == min) {\n      var widen = max ? 0.01 : 1.00;\n      if (o.min === null) min -= widen;\n      if (o.max === null) max += widen;\n    }\n\n    if (o.scaling === 'logarithmic') {\n      if (min < 0) min = max / o.base;  // Could be the result of widening\n\n      var maxexp = Math.log(max);\n      if (o.base != Math.E) maxexp /= Math.log(o.base);\n      maxexp = Math.ceil(maxexp);\n\n      var minexp = Math.log(min);\n      if (o.base != Math.E) minexp /= Math.log(o.base);\n      minexp = Math.ceil(minexp);\n      \n      axis.tickSize = Flotr.getTickSize(o.noTicks, minexp, maxexp, o.tickDecimals === null ? 0 : o.tickDecimals);\n                        \n      // Try to determine a suitable amount of miniticks based on the length of a decade\n      if (o.minorTickFreq === null) {\n        if (maxexp - minexp > 10)\n          o.minorTickFreq = 0;\n        else if (maxexp - minexp > 5)\n          o.minorTickFreq = 2;\n        else\n          o.minorTickFreq = 5;\n      }\n    } else {\n      axis.tickSize = Flotr.getTickSize(o.noTicks, min, max, o.tickDecimals);\n    }\n\n    axis.min = min;\n    axis.max = max; //extendRange may use axis.min or axis.max, so it should be set before it is caled\n\n    // Autoscaling. @todo This probably fails with log scale. Find a testcase and fix it\n    if(o.min === null && o.autoscale){\n      axis.min -= axis.tickSize * margin;\n      // Make sure we don't go below zero if all values are positive.\n      if(axis.min < 0 && axis.datamin >= 0) axis.min = 0;\n      axis.min = axis.tickSize * Math.floor(axis.min / axis.tickSize);\n    }\n    \n    if(o.max === null && o.autoscale){\n      axis.max += axis.tickSize * margin;\n      if(axis.max > 0 && axis.datamax <= 0 && axis.datamax != axis.datamin) axis.max = 0;        \n      axis.max = axis.tickSize * Math.ceil(axis.max / axis.tickSize);\n    }\n\n    if (axis.min == axis.max) axis.max = axis.min + 1;\n  },\n\n  calculateTextDimensions : function (T, options) {\n\n    var maxLabel = '',\n      length,\n      i;\n\n    if (this.options.showLabels) {\n      for (i = 0; i < this.ticks.length; ++i) {\n        length = this.ticks[i].label.length;\n        if (length > maxLabel.length){\n          maxLabel = this.ticks[i].label;\n        }\n      }\n    }\n\n    this.maxLabel = T.dimensions(\n      maxLabel,\n      {size:options.fontSize, angle: Flotr.toRad(this.options.labelsAngle)},\n      'font-size:smaller;',\n      'flotr-grid-label'\n    );\n\n    this.titleSize = T.dimensions(\n      this.options.title, \n      {size:options.fontSize*1.2, angle: Flotr.toRad(this.options.titleAngle)},\n      'font-weight:bold;',\n      'flotr-axis-title'\n    );\n  },\n\n  _cleanUserTicks : function (ticks, axisTicks) {\n\n    var axis = this, options = this.options,\n      v, i, label, tick;\n\n    if(_.isFunction(ticks)) ticks = ticks({min : axis.min, max : axis.max});\n\n    for(i = 0; i < ticks.length; ++i){\n      tick = ticks[i];\n      if(typeof(tick) === 'object'){\n        v = tick[0];\n        label = (tick.length > 1) ? tick[1] : options.tickFormatter(v, {min : axis.min, max : axis.max});\n      } else {\n        v = tick;\n        label = options.tickFormatter(v, {min : this.min, max : this.max});\n      }\n      axisTicks[i] = { v: v, label: label };\n    }\n  },\n\n  _calculateTimeTicks : function () {\n    this.ticks = Flotr.Date.generator(this);\n  },\n\n  _calculateLogTicks : function () {\n\n    var axis = this,\n      o = axis.options,\n      v,\n      decadeStart;\n\n    var max = Math.log(axis.max);\n    if (o.base != Math.E) max /= Math.log(o.base);\n    max = Math.ceil(max);\n\n    var min = Math.log(axis.min);\n    if (o.base != Math.E) min /= Math.log(o.base);\n    min = Math.ceil(min);\n    \n    for (i = min; i < max; i += axis.tickSize) {\n      decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n      // Next decade begins here:\n      var decadeEnd = decadeStart * ((o.base == Math.E) ? Math.exp(axis.tickSize) : Math.pow(o.base, axis.tickSize));\n      var stepSize = (decadeEnd - decadeStart) / o.minorTickFreq;\n      \n      axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n      for (v = decadeStart + stepSize; v < decadeEnd; v += stepSize)\n        axis.minorTicks.push({v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max})});\n    }\n    \n    // Always show the value at the would-be start of next decade (end of this decade)\n    decadeStart = (o.base == Math.E) ? Math.exp(i) : Math.pow(o.base, i);\n    axis.ticks.push({v: decadeStart, label: o.tickFormatter(decadeStart, {min : axis.min, max : axis.max})});\n  },\n\n  _calculateTicks : function () {\n\n    var axis      = this,\n        o         = axis.options,\n        tickSize  = axis.tickSize,\n        min       = axis.min,\n        max       = axis.max,\n        start     = tickSize * Math.ceil(min / tickSize), // Round to nearest multiple of tick size.\n        decimals,\n        minorTickSize,\n        v, v2,\n        i, j;\n    \n    if (o.minorTickFreq)\n      minorTickSize = tickSize / o.minorTickFreq;\n                      \n    // Then store all possible ticks.\n    for (i = 0; (v = v2 = start + i * tickSize) <= max; ++i){\n      \n      // Round (this is always needed to fix numerical instability).\n      decimals = o.tickDecimals;\n      if (decimals === null) decimals = 1 - Math.floor(Math.log(tickSize) / Math.LN10);\n      if (decimals < 0) decimals = 0;\n      \n      v = v.toFixed(decimals);\n      axis.ticks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n\n      if (o.minorTickFreq) {\n        for (j = 0; j < o.minorTickFreq && (i * tickSize + j * minorTickSize) < max; ++j) {\n          v = v2 + j * minorTickSize;\n          axis.minorTicks.push({ v: v, label: o.tickFormatter(v, {min : axis.min, max : axis.max}) });\n        }\n      }\n    }\n\n  }\n};\n\n\n// Static Methods\n_.extend(Axis, {\n  getAxes : function (options) {\n    return {\n      x:  new Axis({options: options.xaxis,  n: 1, length: this.plotWidth}),\n      x2: new Axis({options: options.x2axis, n: 2, length: this.plotWidth}),\n      y:  new Axis({options: options.yaxis,  n: 1, length: this.plotHeight, offset: this.plotHeight, orientation: -1}),\n      y2: new Axis({options: options.y2axis, n: 2, length: this.plotHeight, offset: this.plotHeight, orientation: -1})\n    };\n  }\n});\n\n\n// Helper Methods\n\n\nfunction log (value, base) {\n  value = Math.log(Math.max(value, Number.MIN_VALUE));\n  if (base !== Math.E) \n    value /= Math.log(base);\n  return value;\n}\n\nfunction exp (value, base) {\n  return (base === Math.E) ? Math.exp(value) : Math.pow(base, value);\n}\n\nFlotr.Axis = Axis;\n\n})();\n\n/**\n * Flotr Series Library\n */\n\n(function () {\n\nvar\n  _ = Flotr._;\n\nfunction Series (o) {\n  _.extend(this, o);\n}\n\nSeries.prototype = {\n\n  getRange: function () {\n\n    var\n      data = this.data,\n      length = data.length,\n      xmin = Number.MAX_VALUE,\n      ymin = Number.MAX_VALUE,\n      xmax = -Number.MAX_VALUE,\n      ymax = -Number.MAX_VALUE,\n      xused = false,\n      yused = false,\n      x, y, i;\n\n    if (length < 0 || this.hide) return false;\n\n    for (i = 0; i < length; i++) {\n      x = data[i][0];\n      y = data[i][1];\n      if (x !== null) {\n        if (x < xmin) { xmin = x; xused = true; }\n        if (x > xmax) { xmax = x; xused = true; }\n      }\n      if (y !== null) {\n        if (y < ymin) { ymin = y; yused = true; }\n        if (y > ymax) { ymax = y; yused = true; }\n      }\n    }\n\n    return {\n      xmin : xmin,\n      xmax : xmax,\n      ymin : ymin,\n      ymax : ymax,\n      xused : xused,\n      yused : yused\n    };\n  }\n};\n\n_.extend(Series, {\n  /**\n   * Collects dataseries from input and parses the series into the right format. It returns an Array \n   * of Objects each having at least the 'data' key set.\n   * @param {Array, Object} data - Object or array of dataseries\n   * @return {Array} Array of Objects parsed into the right format ({(...,) data: [[x1,y1], [x2,y2], ...] (, ...)})\n   */\n  getSeries: function(data){\n    return _.map(data, function(s){\n      var series;\n      if (s.data) {\n        series = new Series();\n        _.extend(series, s);\n      } else {\n        series = new Series({data:s});\n      }\n      return series;\n    });\n  }\n});\n\nFlotr.Series = Series;\n\n})();\n\n/** Lines **/\nFlotr.addType('lines', {\n  options: {\n    show: false,           // => setting to true will show lines, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: false,           // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillBorder: false,     // => draw a border around the fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    steps: false,          // => draw steps\n    stacked: false         // => setting to true will show stacked lines, false will show normal lines\n  },\n\n  stack : {\n    values : []\n  },\n\n  /**\n   * Draws lines series in the canvas element.\n   * @param {Object} options\n   */\n  draw : function (options) {\n\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize,\n      offset;\n\n    context.save();\n    context.lineJoin = 'round';\n\n    if (shadowSize) {\n\n      context.lineWidth = shadowSize / 2;\n      offset = lineWidth / 2 + context.lineWidth / 2;\n      \n      // @TODO do this instead with a linear gradient\n      context.strokeStyle = \"rgba(0,0,0,0.1)\";\n      this.plot(options, offset + shadowSize / 2, false);\n\n      context.strokeStyle = \"rgba(0,0,0,0.2)\";\n      this.plot(options, offset, false);\n    }\n\n    context.lineWidth = lineWidth;\n    context.strokeStyle = options.color;\n\n    this.plot(options, 0, true);\n\n    context.restore();\n  },\n\n  plot : function (options, shadowOffset, incStack) {\n\n    var\n      context   = options.context,\n      width     = options.width, \n      height    = options.height,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      data      = options.data, \n      stack     = options.stacked ? this.stack : false,\n      length    = data.length - 1,\n      prevx     = null,\n      prevy     = null,\n      zero      = yScale(0),\n      start     = null,\n      x1, x2, y1, y2, stack1, stack2, i;\n      \n    if (length < 1) return;\n\n    context.beginPath();\n\n    for (i = 0; i < length; ++i) {\n\n      // To allow empty values\n      if (data[i][1] === null || data[i+1][1] === null) {\n        if (options.fill) {\n          if (i > 0 && data[i][1] !== null) {\n            context.stroke();\n            fill();\n            start = null;\n            context.closePath();\n            context.beginPath();\n          }\n        }\n        continue;\n      }\n\n      // Zero is infinity for log scales\n      // TODO handle zero for logarithmic\n      // if (xa.options.scaling === 'logarithmic' && (data[i][0] <= 0 || data[i+1][0] <= 0)) continue;\n      // if (ya.options.scaling === 'logarithmic' && (data[i][1] <= 0 || data[i+1][1] <= 0)) continue;\n      \n      x1 = xScale(data[i][0]);\n      x2 = xScale(data[i+1][0]);\n\n      if (start === null) start = data[i];\n      \n      if (stack) {\n        stack1 = stack.values[data[i][0]] || 0;\n        stack2 = stack.values[data[i+1][0]] || stack.values[data[i][0]] || 0;\n        y1 = yScale(data[i][1] + stack1);\n        y2 = yScale(data[i+1][1] + stack2);\n        if (incStack) {\n          data[i].y0 = stack1;\n          stack.values[data[i][0]] = data[i][1] + stack1;\n          if (i == length-1) {\n            data[i+1].y0 = stack2;\n            stack.values[data[i+1][0]] = data[i+1][1] + stack2;\n          }\n        }\n      } else {\n        y1 = yScale(data[i][1]);\n        y2 = yScale(data[i+1][1]);\n      }\n\n      if (\n        (y1 > height && y2 > height) ||\n        (y1 < 0 && y2 < 0) ||\n        (x1 < 0 && x2 < 0) ||\n        (x1 > width && x2 > width)\n      ) continue;\n\n      if ((prevx != x1) || (prevy != y1 + shadowOffset)) {\n        context.moveTo(x1, y1 + shadowOffset);\n      }\n      \n      prevx = x2;\n      prevy = y2 + shadowOffset;\n      if (options.steps) {\n        context.lineTo(prevx + shadowOffset / 2, y1 + shadowOffset);\n        context.lineTo(prevx + shadowOffset / 2, prevy);\n      } else {\n        context.lineTo(prevx, prevy);\n      }\n    }\n    \n    if (!options.fill || options.fill && !options.fillBorder) context.stroke();\n\n    fill();\n\n    function fill () {\n      // TODO stacked lines\n      if(!shadowOffset && options.fill && start){\n        x1 = xScale(start[0]);\n        context.fillStyle = options.fillStyle;\n        context.lineTo(x2, zero);\n        context.lineTo(x1, zero);\n        context.lineTo(x1, yScale(start[1]));\n        context.fill();\n        if (options.fillBorder) {\n          context.stroke();\n        }\n      }\n    }\n\n    context.closePath();\n  },\n\n  // Perform any pre-render precalculations (this should be run on data first)\n  // - Pie chart total for calculating measures\n  // - Stacks for lines and bars\n  // precalculate : function () {\n  // }\n  //\n  //\n  // Get any bounds after pre calculation (axis can fetch this if does not have explicit min/max)\n  // getBounds : function () {\n  // }\n  // getMin : function () {\n  // }\n  // getMax : function () {\n  // }\n  //\n  //\n  // Padding around rendered elements\n  // getPadding : function () {\n  // }\n\n  extendYRange : function (axis, data, options, lines) {\n\n    var o = axis.options;\n\n    // If stacked and auto-min\n    if (options.stacked && ((!o.max && o.max !== 0) || (!o.min && o.min !== 0))) {\n\n      var\n        newmax = axis.max,\n        newmin = axis.min,\n        positiveSums = lines.positiveSums || {},\n        negativeSums = lines.negativeSums || {},\n        x, j;\n\n      for (j = 0; j < data.length; j++) {\n\n        x = data[j][0] + '';\n\n        // Positive\n        if (data[j][1] > 0) {\n          positiveSums[x] = (positiveSums[x] || 0) + data[j][1];\n          newmax = Math.max(newmax, positiveSums[x]);\n        }\n\n        // Negative\n        else {\n          negativeSums[x] = (negativeSums[x] || 0) + data[j][1];\n          newmin = Math.min(newmin, negativeSums[x]);\n        }\n      }\n\n      lines.negativeSums = negativeSums;\n      lines.positiveSums = positiveSums;\n\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n\n    if (options.steps) {\n\n      this.hit = function (options) {\n        var\n          data = options.data,\n          args = options.args,\n          yScale = options.yScale,\n          mouse = args[0],\n          length = data.length,\n          n = args[1],\n          x = options.xInverse(mouse.relX),\n          relY = mouse.relY,\n          i;\n\n        for (i = 0; i < length - 1; i++) {\n          if (x >= data[i][0] && x <= data[i+1][0]) {\n            if (Math.abs(yScale(data[i][1]) - relY) < 8) {\n              n.x = data[i][0];\n              n.y = data[i][1];\n              n.index = i;\n              n.seriesIndex = options.index;\n            }\n            break;\n          }\n        }\n      };\n\n      this.drawHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.save();\n          context.strokeStyle = options.color;\n          context.lineWidth = options.lineWidth;\n          context.beginPath();\n          context.moveTo(x, y);\n          context.lineTo(x2, y);\n          context.stroke();\n          context.closePath();\n          context.restore();\n        }\n      };\n\n      this.clearHit = function (options) {\n        var\n          context = options.context,\n          args    = options.args,\n          data    = options.data,\n          xScale  = options.xScale,\n          width   = options.lineWidth,\n          index   = args.index,\n          x       = xScale(args.x),\n          y       = options.yScale(args.y),\n          x2;\n\n        if (data.length - 1 > index) {\n          x2 = options.xScale(data[index + 1][0]);\n          context.clearRect(x - width, y - width, x2 - x + 2 * width, 2 * width);\n        }\n      };\n    }\n  }\n\n});\n\n/** Bars **/\nFlotr.addType('bars', {\n\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    horizontal: false,     // => horizontal bars (x and y inverted)\n    stacked: false,        // => stacked bar charts\n    centered: true,        // => center the bars to their x axis value\n    topPadding: 0.1,       // => top padding in percent\n    grouped: false         // => groups bars together which share x value, hit not supported.\n  },\n\n  stack : { \n    positive : [],\n    negative : [],\n    _positive : [], // Shadow\n    _negative : []  // Shadow\n  },\n\n  draw : function (options) {\n    var\n      context = options.context;\n\n    this.current += 1;\n\n    context.save();\n    context.lineJoin = 'miter';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n    \n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      shadowSize      = options.shadowSize,\n      i, geometry, left, top, width, height;\n\n    if (data.length < 1) return;\n\n    this.translate(context, options.horizontal);\n\n    for (i = 0; i < data.length; i++) {\n\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (geometry === null) continue;\n\n      left    = geometry.left;\n      top     = geometry.top;\n      width   = geometry.width;\n      height  = geometry.height;\n\n      if (options.fill) context.fillRect(left, top, width, height);\n      if (shadowSize) {\n        context.save();\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top + shadowSize, width, height);\n        context.restore();\n      }\n      if (options.lineWidth) {\n        context.strokeRect(left, top, width, height);\n      }\n    }\n  },\n\n  translate : function (context, horizontal) {\n    if (horizontal) {\n      context.rotate(-Math.PI / 2);\n      context.scale(-1, 1);\n    }\n  },\n\n  getBarGeometry : function (x, y, options) {\n\n    var\n      horizontal    = options.horizontal,\n      barWidth      = options.barWidth,\n      centered      = options.centered,\n      stack         = options.stacked ? this.stack : false,\n      lineWidth     = options.lineWidth,\n      bisection     = centered ? barWidth / 2 : 0,\n      xScale        = horizontal ? options.yScale : options.xScale,\n      yScale        = horizontal ? options.xScale : options.yScale,\n      xValue        = horizontal ? y : x,\n      yValue        = horizontal ? x : y,\n      stackOffset   = 0,\n      stackValue, left, right, top, bottom;\n\n    if (options.grouped) {\n      this.current / this.groups;\n      xValue = xValue - bisection;\n      barWidth = barWidth / this.groups;\n      bisection = barWidth / 2;\n      xValue = xValue + barWidth * this.current - bisection;\n    }\n\n    // Stacked bars\n    if (stack) {\n      stackValue          = yValue > 0 ? stack.positive : stack.negative;\n      stackOffset         = stackValue[xValue] || stackOffset;\n      stackValue[xValue]  = stackOffset + yValue;\n    }\n\n    left    = xScale(xValue - bisection);\n    right   = xScale(xValue + barWidth - bisection);\n    top     = yScale(yValue + stackOffset);\n    bottom  = yScale(stackOffset);\n\n    // TODO for test passing... probably looks better without this\n    if (bottom < 0) bottom = 0;\n\n    // TODO Skipping...\n    // if (right < xa.min || left > xa.max || top < ya.min || bottom > ya.max) continue;\n\n    return (x === null || y === null) ? null : {\n      x         : xValue,\n      y         : yValue,\n      xScale    : xScale,\n      yScale    : yScale,\n      top       : top,\n      left      : Math.min(left, right) - lineWidth / 2,\n      width     : Math.abs(right - left) - lineWidth,\n      height    : bottom - top\n    };\n  },\n\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      x = options.xInverse(mouse.relX),\n      y = options.yInverse(mouse.relY),\n      hitGeometry = this.getBarGeometry(x, y, options),\n      width = hitGeometry.width / 2,\n      left = hitGeometry.left,\n      height = hitGeometry.y,\n      geometry, i;\n\n    for (i = data.length; i--;) {\n      geometry = this.getBarGeometry(data[i][0], data[i][1], options);\n      if (\n        // Height:\n        (\n          // Positive Bars:\n          (height > 0 && height < geometry.y) ||\n          // Negative Bars:\n          (height < 0 && height > geometry.y)\n        ) &&\n        // Width:\n        (Math.abs(left - geometry.left) < width)\n      ) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n      }\n    }\n  },\n\n  drawHit : function (options) {\n    // TODO hits for stacked bars; implement using calculateStack option?\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      top         = geometry.top,\n      width       = geometry.width,\n      height      = geometry.height;\n\n    context.save();\n    context.strokeStyle = options.color;\n    context.lineWidth = options.lineWidth;\n    this.translate(context, options.horizontal);\n\n    // Draw highlight\n    context.beginPath();\n    context.moveTo(left, top + height);\n    context.lineTo(left, top);\n    context.lineTo(left + width, top);\n    context.lineTo(left + width, top + height);\n    if (options.fill) {\n      context.fillStyle = options.fillStyle;\n      context.fill();\n    }\n    context.stroke();\n    context.closePath();\n\n    context.restore();\n  },\n\n  clearHit: function (options) {\n    var\n      context     = options.context,\n      args        = options.args,\n      geometry    = this.getBarGeometry(args.x, args.y, options),\n      left        = geometry.left,\n      width       = geometry.width,\n      top         = geometry.top,\n      height      = geometry.height,\n      lineWidth   = 2 * options.lineWidth;\n\n    context.save();\n    this.translate(context, options.horizontal);\n    context.clearRect(\n      left - lineWidth,\n      Math.min(top, top + height) - lineWidth,\n      width + 2 * lineWidth,\n      Math.abs(height) + 2 * lineWidth\n    );\n    context.restore();\n  },\n\n  extendXRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n    this.groups = (this.groups + 1) || 1;\n    this.current = 0;\n  },\n\n  extendYRange : function (axis, data, options, bars) {\n    this._extendRange(axis, data, options, bars);\n  },\n  _extendRange: function (axis, data, options, bars) {\n\n    var\n      max = axis.options.max;\n\n    if (_.isNumber(max) || _.isString(max)) return; \n\n    var\n      newmin = axis.min,\n      newmax = axis.max,\n      horizontal = options.horizontal,\n      orientation = axis.orientation,\n      positiveSums = this.positiveSums || {},\n      negativeSums = this.negativeSums || {},\n      value, datum, index, j;\n\n    // Sides of bars\n    if ((orientation == 1 && !horizontal) || (orientation == -1 && horizontal)) {\n      if (options.centered) {\n        newmax = Math.max(axis.datamax + options.barWidth, newmax);\n        newmin = Math.min(axis.datamin - options.barWidth, newmin);\n      }\n    }\n\n    if (options.stacked && \n        ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal))){\n\n      for (j = data.length; j--;) {\n        value = data[j][(orientation == 1 ? 1 : 0)]+'';\n        datum = data[j][(orientation == 1 ? 0 : 1)];\n\n        // Positive\n        if (datum > 0) {\n          positiveSums[value] = (positiveSums[value] || 0) + datum;\n          newmax = Math.max(newmax, positiveSums[value]);\n        }\n\n        // Negative\n        else {\n          negativeSums[value] = (negativeSums[value] || 0) + datum;\n          newmin = Math.min(newmin, negativeSums[value]);\n        }\n      }\n    }\n\n    // End of bars\n    if ((orientation == 1 && horizontal) || (orientation == -1 && !horizontal)) {\n      if (options.topPadding && (axis.max === axis.datamax || (options.stacked && this.stackMax !== newmax))) {\n        newmax += options.topPadding * (newmax - newmin);\n      }\n    }\n\n    this.stackMin = newmin;\n    this.stackMax = newmax;\n    this.negativeSums = negativeSums;\n    this.positiveSums = positiveSums;\n\n    axis.max = newmax;\n    axis.min = newmin;\n  }\n\n});\n\n/** Bubbles **/\nFlotr.addType('bubbles', {\n  options: {\n    show: false,      // => setting to true will show radar chart, false will hide\n    lineWidth: 2,     // => line width in pixels\n    fill: true,       // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4, // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    baseRadius: 2     // => ratio of the radar, against the plot size\n  },\n  draw : function (options) {\n    var\n      context     = options.context,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    \n    // Shadows\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n\n    var\n      data    = options.data,\n      context = options.context,\n      geometry,\n      i, x, y, z;\n\n    offset = offset || 0;\n    \n    for (i = 0; i < data.length; ++i){\n\n      geometry = this.getGeometry(data[i], options);\n\n      context.beginPath();\n      context.arc(geometry.x + offset, geometry.y + offset, geometry.z, 0, 2 * Math.PI, true);\n      context.stroke();\n      if (options.fill) context.fill();\n      context.closePath();\n    }\n  },\n  getGeometry : function (point, options) {\n    return {\n      x : options.xScale(point[0]),\n      y : options.yScale(point[1]),\n      z : point[2] * options.baseRadius\n    };\n  },\n  hit : function (options) {\n    var\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      relX = mouse.relX,\n      relY = mouse.relY,\n      distance,\n      geometry,\n      dx, dy;\n\n    n.best = n.best || Number.MAX_VALUE;\n\n    for (i = data.length; i--;) {\n      geometry = this.getGeometry(data[i], options);\n\n      dx = geometry.x - relX;\n      dy = geometry.y - relY;\n      distance = Math.sqrt(dx * dx + dy * dy);\n\n      if (distance < geometry.z && geometry.z < n.best) {\n        n.x = data[i][0];\n        n.y = data[i][1];\n        n.index = i;\n        n.seriesIndex = options.index;\n        n.best = geometry.z;\n      }\n    }\n  },\n  drawHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options);\n\n    context.save();\n    context.lineWidth = options.lineWidth;\n    context.fillStyle = options.fillStyle;\n    context.strokeStyle = options.color;\n    context.beginPath();\n    context.arc(geometry.x, geometry.y, geometry.z, 0, 2 * Math.PI, true);\n    context.fill();\n    context.stroke();\n    context.closePath();\n    context.restore();\n  },\n  clearHit : function (options) {\n\n    var\n      context = options.context,\n      geometry = this.getGeometry(options.data[options.args.index], options),\n      offset = geometry.z + options.lineWidth;\n\n    context.save();\n    context.clearRect(\n      geometry.x - offset, \n      geometry.y - offset,\n      2 * offset,\n      2 * offset\n    );\n    context.restore();\n  }\n  // TODO Add a hit calculation method (like pie)\n});\n\n/** Candles **/\nFlotr.addType('candles', {\n  options: {\n    show: false,           // => setting to true will show candle sticks, false will hide\n    lineWidth: 1,          // => in pixels\n    wickLineWidth: 1,      // => in pixels\n    candleWidth: 0.6,      // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    upFillColor: '#00A8F0',// => up sticks fill color\n    downFillColor: '#CB4B4B',// => down sticks fill color\n    fillOpacity: 0.5,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    barcharts: false       // => draw as barcharts (not standard bars but financial barcharts)\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin = 'miter';\n    context.lineCap = 'butt';\n    // @TODO linewidth not interpreted the right way.\n    context.lineWidth = options.wickLineWidth || options.lineWidth;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data          = options.data,\n      context       = options.context,\n      xScale        = options.xScale,\n      yScale        = options.yScale,\n      width         = options.candleWidth / 2,\n      shadowSize    = options.shadowSize,\n      lineWidth     = options.lineWidth,\n      wickLineWidth = options.wickLineWidth,\n      pixelOffset   = (wickLineWidth % 2) / 2,\n      color,\n      datum, x, y,\n      open, high, low, close,\n      left, right, bottom, top, bottom2, top2, reverseLines,\n      i;\n\n    if (data.length < 1) return;\n\n    for (i = 0; i < data.length; i++) {\n      datum   = data[i];\n      x       = datum[0];\n      open    = datum[1];\n      high    = datum[2];\n      low     = datum[3];\n      close   = datum[4];\n      left    = xScale(x - width);\n      right   = xScale(x + width);\n      bottom  = yScale(low);\n      top     = yScale(high);\n      bottom2 = yScale(Math.min(open, close));\n      top2    = yScale(Math.max(open, close));\n\n      /*\n      // TODO skipping\n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      */\n\n      color = options[open > close ? 'downFillColor' : 'upFillColor'];\n\n      // Fill the candle.\n      if (options.fill && !options.barcharts) {\n        context.fillStyle = 'rgba(0,0,0,0.05)';\n        context.fillRect(left + shadowSize, top2 + shadowSize, right - left, bottom2 - top2);\n        context.save();\n        context.globalAlpha = options.fillOpacity;\n        context.fillStyle = color;\n        context.fillRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n        context.restore();\n      }\n\n      // Draw candle outline/border, high, low.\n      if (lineWidth || wickLineWidth) {\n\n        x = Math.floor((left + right) / 2) + pixelOffset;\n\n        context.strokeStyle = color;\n        context.beginPath();\n\n        if (options.barcharts) {\n          context.moveTo(x, Math.floor(top + lineWidth));\n          context.lineTo(x, Math.floor(bottom + lineWidth));\n\n          reverseLines = open < close;\n          context.moveTo(reverseLines ? right : left, Math.floor(top2 + lineWidth));\n          context.lineTo(x, Math.floor(top2 + lineWidth));\n          context.moveTo(x, Math.floor(bottom2 + lineWidth));\n          context.lineTo(reverseLines ? left : right, Math.floor(bottom2 + lineWidth));\n        } else {\n          context.strokeRect(left, top2 + lineWidth, right - left, bottom2 - top2);\n          context.moveTo(x, Math.floor(top2 + lineWidth));\n          context.lineTo(x, Math.floor(top + lineWidth));\n          context.moveTo(x, Math.floor(bottom2 + lineWidth));\n          context.lineTo(x, Math.floor(bottom + lineWidth));\n        }\n        \n        context.closePath();\n        context.stroke();\n      }\n    }\n  },\n\n  hit : function (options) {\n    var\n      xScale = options.xScale,\n      yScale = options.yScale,\n      data = options.data,\n      args = options.args,\n      mouse = args[0],\n      width = options.candleWidth / 2,\n      n = args[1],\n      x = mouse.relX,\n      y = mouse.relY,\n      length = data.length,\n      i, datum,\n      high, low,\n      left, right, top, bottom;\n\n    for (i = 0; i < length; i++) {\n      datum   = data[i],\n      high    = datum[2];\n      low     = datum[3];\n      left    = xScale(datum[0] - width);\n      right   = xScale(datum[0] + width);\n      bottom  = yScale(low);\n      top     = yScale(high);\n\n      if (x > left && x < right && y > top && y < bottom) {\n        n.x = datum[0];\n        n.index = i;\n        n.seriesIndex = options.index;\n        return;\n      }\n    }\n  },\n\n  drawHit : function (options) {\n    var\n      context = options.context;\n    context.save();\n    this.plot(\n      _.defaults({\n        fill : !!options.fillColor,\n        upFillColor : options.color,\n        downFillColor : options.color,\n        data : [options.data[options.args.index]]\n      }, options)\n    );\n    context.restore();\n  },\n\n  clearHit : function (options) {\n    var\n      args = options.args,\n      context = options.context,\n      xScale = options.xScale,\n      yScale = options.yScale,\n      lineWidth = options.lineWidth,\n      width = options.candleWidth / 2,\n      bar = options.data[args.index],\n      left = xScale(bar[0] - width) - lineWidth,\n      right = xScale(bar[0] + width) + lineWidth,\n      top = yScale(bar[2]),\n      bottom = yScale(bar[3]) + lineWidth;\n    context.clearRect(left, top, right - left, bottom - top);\n  },\n\n  extendXRange: function (axis, data, options) {\n    if (axis.options.max === null) {\n      axis.max = Math.max(axis.datamax + 0.5, axis.max);\n      axis.min = Math.min(axis.datamin - 0.5, axis.min);\n    }\n  }\n});\n\n/** Gantt\n * Base on data in form [s,y,d] where:\n * y - executor or simply y value\n * s - task start value\n * d - task duration\n * **/\nFlotr.addType('gantt', {\n  options: {\n    show: false,           // => setting to true will show gantt, false will hide\n    lineWidth: 2,          // => in pixels\n    barWidth: 1,           // => in units of the x axis\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    centered: true         // => center the bars to their x axis value\n  },\n  /**\n   * Draws gantt series in the canvas element.\n   * @param {Object} series - Series with options.gantt.show = true.\n   */\n  draw: function(series) {\n    var ctx = this.ctx,\n      bw = series.gantt.barWidth,\n      lw = Math.min(series.gantt.lineWidth, bw);\n    \n    ctx.save();\n    ctx.translate(this.plotOffset.left, this.plotOffset.top);\n    ctx.lineJoin = 'miter';\n\n    /**\n     * @todo linewidth not interpreted the right way.\n     */\n    ctx.lineWidth = lw;\n    ctx.strokeStyle = series.color;\n    \n    ctx.save();\n    this.gantt.plotShadows(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n    \n    if(series.gantt.fill){\n      var color = series.gantt.fillColor || series.color;\n      ctx.fillStyle = this.processColor(color, {opacity: series.gantt.fillOpacity});\n    }\n    \n    this.gantt.plot(series, bw, 0, series.gantt.fill);\n    ctx.restore();\n  },\n  plot: function(series, barWidth, offset, fill){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx, i;\n\n    for(i = 0; i < data.length; i++){\n      var y = data[i][0],\n          s = data[i][1],\n          d = data[i][2],\n          drawLeft = true, drawTop = true, drawRight = true;\n      \n      if (s === null || d === null) continue;\n\n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n      \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n\n      if(left < xa.min){\n        left = xa.min;\n        drawLeft = false;\n      }\n\n      if(right > xa.max){\n        right = xa.max;\n        if (xa.lastSerie != series)\n          drawTop = false;\n      }\n\n      if(bottom < ya.min)\n        bottom = ya.min;\n\n      if(top > ya.max){\n        top = ya.max;\n        if (ya.lastSerie != series)\n          drawTop = false;\n      }\n      \n      /**\n       * Fill the bar.\n       */\n      if(fill){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        ctx.lineTo(xa.d2p(left), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(top) + offset);\n        ctx.lineTo(xa.d2p(right), ya.d2p(bottom) + offset);\n        ctx.fill();\n        ctx.closePath();\n      }\n\n      /**\n       * Draw bar outline/border.\n       */\n      if(series.gantt.lineWidth && (drawLeft || drawRight || drawTop)){\n        ctx.beginPath();\n        ctx.moveTo(xa.d2p(left), ya.d2p(bottom) + offset);\n        \n        ctx[drawLeft ?'lineTo':'moveTo'](xa.d2p(left), ya.d2p(top) + offset);\n        ctx[drawTop  ?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(top) + offset);\n        ctx[drawRight?'lineTo':'moveTo'](xa.d2p(right), ya.d2p(bottom) + offset);\n                 \n        ctx.stroke();\n        ctx.closePath();\n      }\n    }\n  },\n  plotShadows: function(series, barWidth, offset){\n    var data = series.data;\n    if(data.length < 1) return;\n    \n    var i, y, s, d,\n        xa = series.xaxis,\n        ya = series.yaxis,\n        ctx = this.ctx,\n        sw = this.options.shadowSize;\n    \n    for(i = 0; i < data.length; i++){\n      y = data[i][0];\n      s = data[i][1];\n      d = data[i][2];\n        \n      if (s === null || d === null) continue;\n            \n      var left = s, \n          right = s + d,\n          bottom = y - (series.gantt.centered ? barWidth/2 : 0), \n          top = y + barWidth - (series.gantt.centered ? barWidth/2 : 0);\n \n      if(right < xa.min || left > xa.max || top < ya.min || bottom > ya.max)\n        continue;\n      \n      if(left < xa.min)   left = xa.min;\n      if(right > xa.max)  right = xa.max;\n      if(bottom < ya.min) bottom = ya.min;\n      if(top > ya.max)    top = ya.max;\n      \n      var width =  xa.d2p(right)-xa.d2p(left)-((xa.d2p(right)+sw <= this.plotWidth) ? 0 : sw);\n      var height = ya.d2p(bottom)-ya.d2p(top)-((ya.d2p(bottom)+sw <= this.plotHeight) ? 0 : sw );\n      \n      ctx.fillStyle = 'rgba(0,0,0,0.05)';\n      ctx.fillRect(Math.min(xa.d2p(left)+sw, this.plotWidth), Math.min(ya.d2p(top)+sw, this.plotHeight), width, height);\n    }\n  },\n  extendXRange: function(axis) {\n    if(axis.options.max === null){\n      var newmin = axis.min,\n          newmax = axis.max,\n          i, j, x, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n\n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if(g.show && s.xaxis == axis) {\n            for (j = 0; j < s.data.length; j++) {\n              if (g.show) {\n                y = s.data[j][0]+'';\n                stackedSumsPos[y] = Math.max((stackedSumsPos[y] || 0), s.data[j][1]+s.data[j][2]);\n                lastSerie = s;\n              }\n            }\n            for (j in stackedSumsPos) {\n              newmax = Math.max(stackedSumsPos[j], newmax);\n            }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n    }\n  },\n  extendYRange: function(axis){\n    if(axis.options.max === null){\n      var newmax = Number.MIN_VALUE,\n          newmin = Number.MAX_VALUE,\n          i, j, s, g,\n          stackedSumsPos = {},\n          stackedSumsNeg = {},\n          lastSerie = null;\n                  \n      for(i = 0; i < this.series.length; ++i){\n        s = this.series[i];\n        g = s.gantt;\n        \n        if (g.show && !s.hide && s.yaxis == axis) {\n          var datamax = Number.MIN_VALUE, datamin = Number.MAX_VALUE;\n          for(j=0; j < s.data.length; j++){\n            datamax = Math.max(datamax,s.data[j][0]);\n            datamin = Math.min(datamin,s.data[j][0]);\n          }\n            \n          if (g.centered) {\n            newmax = Math.max(datamax + 0.5, newmax);\n            newmin = Math.min(datamin - 0.5, newmin);\n          }\n        else {\n          newmax = Math.max(datamax + 1, newmax);\n            newmin = Math.min(datamin, newmin);\n          }\n          // For normal horizontal bars\n          if (g.barWidth + datamax > newmax){\n            newmax = axis.max + g.barWidth;\n          }\n        }\n      }\n      axis.lastSerie = lastSerie;\n      axis.max = newmax;\n      axis.min = newmin;\n      axis.tickSize = Flotr.getTickSize(axis.options.noTicks, newmin, newmax, axis.options.tickDecimals);\n    }\n  }\n});\n\n/** Markers **/\n/**\n * Formats the marker labels.\n * @param {Object} obj - Marker value Object {x:..,y:..}\n * @return {String} Formatted marker string\n */\n(function () {\n\nFlotr.defaultMarkerFormatter = function(obj){\n  return (Math.round(obj.y*100)/100)+'';\n};\n\nFlotr.addType('markers', {\n  options: {\n    show: false,           // => setting to true will show markers, false will hide\n    lineWidth: 1,          // => line width of the rectangle around the marker\n    color: '#000000',      // => text color\n    fill: false,           // => fill or not the marekers' rectangles\n    fillColor: \"#FFFFFF\",  // => fill color\n    fillOpacity: 0.4,      // => fill opacity\n    stroke: false,         // => draw the rectangle around the markers\n    position: 'ct',        // => the markers position (vertical align: b, m, t, horizontal align: l, c, r)\n    verticalMargin: 0,     // => the margin between the point and the text.\n    labelFormatter: Flotr.defaultMarkerFormatter,\n    fontSize: Flotr.defaultOptions.fontSize,\n    stacked: false,        // => true if markers should be stacked\n    stackingType: 'b',     // => define staching behavior, (b- bars like, a - area like) (see Issue 125 for details)\n    horizontal: false      // => true if markers should be horizontal (For now only in a case on horizontal stacked bars, stacks should be calculated horizontaly)\n  },\n\n  // TODO test stacked markers.\n  stack : {\n      positive : [],\n      negative : [],\n      values : []\n  },\n\n  draw : function (options) {\n\n    var\n      data            = options.data,\n      context         = options.context,\n      stack           = options.stacked ? options.stack : false,\n      stackType       = options.stackingType,\n      stackOffsetNeg,\n      stackOffsetPos,\n      stackOffset,\n      i, x, y, label;\n\n    context.save();\n    context.lineJoin = 'round';\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = 'rgba(0,0,0,0.5)';\n    context.fillStyle = options.fillStyle;\n\n    function stackPos (a, b) {\n      stackOffsetPos = stack.negative[a] || 0;\n      stackOffsetNeg = stack.positive[a] || 0;\n      if (b > 0) {\n        stack.positive[a] = stackOffsetPos + b;\n        return stackOffsetPos + b;\n      } else {\n        stack.negative[a] = stackOffsetNeg + b;\n        return stackOffsetNeg + b;\n      }\n    }\n\n    for (i = 0; i < data.length; ++i) {\n    \n      x = data[i][0];\n      y = data[i][1];\n        \n      if (stack) {\n        if (stackType == 'b') {\n          if (options.horizontal) y = stackPos(y, x);\n          else x = stackPos(x, y);\n        } else if (stackType == 'a') {\n          stackOffset = stack.values[x] || 0;\n          stack.values[x] = stackOffset + y;\n          y = stackOffset + y;\n        }\n      }\n\n      label = options.labelFormatter({x: x, y: y, index: i, data : data});\n      this.plot(options.xScale(x), options.yScale(y), label, options);\n    }\n    context.restore();\n  },\n  plot: function(x, y, label, options) {\n    var context = options.context;\n    if (isImage(label) && !label.complete) {\n      throw 'Marker image not loaded.';\n    } else {\n      this._plot(x, y, label, options);\n    }\n  },\n\n  _plot: function(x, y, label, options) {\n    var context = options.context,\n        margin = 2,\n        left = x,\n        top = y,\n        dim;\n\n    if (isImage(label))\n      dim = {height : label.height, width: label.width};\n    else\n      dim = options.text.canvas(label);\n\n    dim.width = Math.floor(dim.width+margin*2);\n    dim.height = Math.floor(dim.height+margin*2);\n\n         if (options.position.indexOf('c') != -1) left -= dim.width/2 + margin;\n    else if (options.position.indexOf('l') != -1) left -= dim.width;\n    \n         if (options.position.indexOf('m') != -1) top -= dim.height/2 + margin;\n    else if (options.position.indexOf('t') != -1) top -= dim.height + options.verticalMargin;\n    else top += options.verticalMargin;\n    \n    left = Math.floor(left)+0.5;\n    top = Math.floor(top)+0.5;\n    \n    if(options.fill)\n      context.fillRect(left, top, dim.width, dim.height);\n      \n    if(options.stroke)\n      context.strokeRect(left, top, dim.width, dim.height);\n    \n    if (isImage(label))\n      context.drawImage(label, parseInt(left+margin, 10), parseInt(top+margin, 10));\n    else\n      Flotr.drawText(context, label, left+margin, top+margin, {textBaseline: 'top', textAlign: 'left', size: options.fontSize, color: options.color});\n  }\n});\n\nfunction isImage (i) {\n  return typeof i === 'object' && i.constructor && (Image ? true : i.constructor === Image);\n}\n\n})();\n\n/**\n * Pie\n *\n * Formats the pies labels.\n * @param {Object} slice - Slice object\n * @return {String} Formatted pie label string\n */\n(function () {\n\nvar\n  _ = Flotr._;\n\nFlotr.defaultPieLabelFormatter = function (total, value) {\n  return (100 * value / total).toFixed(2)+'%';\n};\n\nFlotr.addType('pie', {\n  options: {\n    show: false,           // => setting to true will show bars, false will hide\n    lineWidth: 1,          // => in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillColor: null,       // => fill color\n    fillOpacity: 0.6,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    explode: 6,            // => the number of pixels the splices will be far from the center\n    sizeRatio: 0.6,        // => the size ratio of the pie relative to the plot \n    startAngle: Math.PI/4, // => the first slice start angle\n    labelFormatter: Flotr.defaultPieLabelFormatter,\n    pie3D: false,          // => whether to draw the pie in 3 dimenstions or not (ineffective) \n    pie3DviewAngle: (Math.PI/2 * 0.8),\n    pie3DspliceThickness: 20,\n    epsilon: 0.1           // => how close do you have to get to hit empty slice\n  },\n\n  draw : function (options) {\n\n    // TODO 3D charts what?\n    var\n      data          = options.data,\n      context       = options.context,\n      lineWidth     = options.lineWidth,\n      shadowSize    = options.shadowSize,\n      sizeRatio     = options.sizeRatio,\n      height        = options.height,\n      width         = options.width,\n      explode       = options.explode,\n      color         = options.color,\n      fill          = options.fill,\n      fillStyle     = options.fillStyle,\n      radius        = Math.min(width, height) * sizeRatio / 2,\n      value         = data[0][1],\n      html          = [],\n      vScale        = 1,//Math.cos(series.pie.viewAngle);\n      measure       = Math.PI * 2 * value / this.total,\n      startAngle    = this.startAngle || (2 * Math.PI * options.startAngle), // TODO: this initial startAngle is already in radians (fixing will be test-unstable)\n      endAngle      = startAngle + measure,\n      bisection     = startAngle + measure / 2,\n      label         = options.labelFormatter(this.total, value),\n      //plotTickness  = Math.sin(series.pie.viewAngle)*series.pie.spliceThickness / vScale;\n      explodeCoeff  = explode + radius + 4,\n      distX         = Math.cos(bisection) * explodeCoeff,\n      distY         = Math.sin(bisection) * explodeCoeff,\n      textAlign     = distX < 0 ? 'right' : 'left',\n      textBaseline  = distY > 0 ? 'top' : 'bottom',\n      style,\n      x, y;\n    \n    context.save();\n    context.translate(width / 2, height / 2);\n    context.scale(1, vScale);\n\n    x = Math.cos(bisection) * explode;\n    y = Math.sin(bisection) * explode;\n\n    // Shadows\n    if (shadowSize > 0) {\n      this.plotSlice(x + shadowSize, y + shadowSize, radius, startAngle, endAngle, context);\n      if (fill) {\n        context.fillStyle = 'rgba(0,0,0,0.1)';\n        context.fill();\n      }\n    }\n\n    this.plotSlice(x, y, radius, startAngle, endAngle, context);\n    if (fill) {\n      context.fillStyle = fillStyle;\n      context.fill();\n    }\n    context.lineWidth = lineWidth;\n    context.strokeStyle = color;\n    context.stroke();\n\n    style = {\n      size : options.fontSize * 1.2,\n      color : options.fontColor,\n      weight : 1.5\n    };\n\n    if (label) {\n      if (options.htmlText || !options.textEnabled) {\n        divStyle = 'position:absolute;' + textBaseline + ':' + (height / 2 + (textBaseline === 'top' ? distY : -distY)) + 'px;';\n        divStyle += textAlign + ':' + (width / 2 + (textAlign === 'right' ? -distX : distX)) + 'px;';\n        html.push('<div style=\"', divStyle, '\" class=\"flotr-grid-label\">', label, '</div>');\n      }\n      else {\n        style.textAlign = textAlign;\n        style.textBaseline = textBaseline;\n        Flotr.drawText(context, label, distX, distY, style);\n      }\n    }\n    \n    if (options.htmlText || !options.textEnabled) {\n      var div = Flotr.DOM.node('<div style=\"color:' + options.fontColor + '\" class=\"flotr-labels\"></div>');\n      Flotr.DOM.insert(div, html.join(''));\n      Flotr.DOM.insert(options.element, div);\n    }\n    \n    context.restore();\n\n    // New start angle\n    this.startAngle = endAngle;\n    this.slices = this.slices || [];\n    this.slices.push({\n      radius : radius,\n      x : x,\n      y : y,\n      explode : explode,\n      start : startAngle,\n      end : endAngle\n    });\n  },\n  plotSlice : function (x, y, radius, startAngle, endAngle, context) {\n    context.beginPath();\n    context.moveTo(x, y);\n    context.arc(x, y, radius, startAngle, endAngle, false);\n    context.lineTo(x, y);\n    context.closePath();\n  },\n  hit : function (options) {\n\n    var\n      data      = options.data[0],\n      args      = options.args,\n      index     = options.index,\n      mouse     = args[0],\n      n         = args[1],\n      slice     = this.slices[index],\n      x         = mouse.relX - options.width / 2,\n      y         = mouse.relY - options.height / 2,\n      r         = Math.sqrt(x * x + y * y),\n      theta     = Math.atan(y / x),\n      circle    = Math.PI * 2,\n      explode   = slice.explode || options.explode,\n      start     = slice.start % circle,\n      end       = slice.end % circle,\n      epsilon   = options.epsilon;\n\n    if (x < 0) {\n      theta += Math.PI;\n    } else if (x > 0 && y < 0) {\n      theta += circle;\n    }\n\n    if (r < slice.radius + explode && r > explode) {\n      if (\n          (theta > start && theta < end) || // Normal Slice\n          (start > end && (theta < end || theta > start)) || // First slice\n          // TODO: Document the two cases at the end:\n          (start === end && ((slice.start === slice.end && Math.abs(theta - start) < epsilon) || (slice.start !== slice.end && Math.abs(theta-start) > epsilon)))\n         ) {\n          \n          // TODO Decouple this from hit plugin (chart shouldn't know what n means)\n         n.x = data[0];\n         n.y = data[1];\n         n.sAngle = start;\n         n.eAngle = end;\n         n.index = 0;\n         n.seriesIndex = index;\n         n.fraction = data[1] / this.total;\n      }\n    }\n  },\n  drawHit: function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex];\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    this.plotSlice(slice.x, slice.y, slice.radius, slice.start, slice.end, context);\n    context.stroke();\n    context.restore();\n  },\n  clearHit : function (options) {\n    var\n      context = options.context,\n      slice = this.slices[options.args.seriesIndex],\n      padding = 2 * options.lineWidth,\n      radius = slice.radius + padding;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.clearRect(\n      slice.x - radius,\n      slice.y - radius,\n      2 * radius + padding,\n      2 * radius + padding \n    );\n    context.restore();\n  },\n  extendYRange : function (axis, data) {\n    this.total = (this.total || 0) + data[0][1];\n  }\n});\n})();\n\n/** Points **/\nFlotr.addType('points', {\n  options: {\n    show: false,           // => setting to true will show points, false will hide\n    radius: 3,             // => point radius (pixels)\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the points with a color, false for (transparent) no fill\n    fillColor: '#FFFFFF',  // => fill color.  Null to use series color.\n    fillOpacity: 1,        // => opacity of color inside the points\n    hitRadius: null        // => override for points hit radius\n  },\n\n  draw : function (options) {\n    var\n      context     = options.context,\n      lineWidth   = options.lineWidth,\n      shadowSize  = options.shadowSize;\n\n    context.save();\n\n    if (shadowSize > 0) {\n      context.lineWidth = shadowSize / 2;\n      \n      context.strokeStyle = 'rgba(0,0,0,0.1)';\n      this.plot(options, shadowSize / 2 + context.lineWidth / 2);\n\n      context.strokeStyle = 'rgba(0,0,0,0.2)';\n      this.plot(options, context.lineWidth / 2);\n    }\n\n    context.lineWidth = options.lineWidth;\n    context.strokeStyle = options.color;\n    if (options.fill) context.fillStyle = options.fillStyle;\n\n    this.plot(options);\n    context.restore();\n  },\n\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      xScale  = options.xScale,\n      yScale  = options.yScale,\n      i, x, y;\n      \n    for (i = data.length - 1; i > -1; --i) {\n      y = data[i][1];\n      if (y === null) continue;\n\n      x = xScale(data[i][0]);\n      y = yScale(y);\n\n      if (x < 0 || x > options.width || y < 0 || y > options.height) continue;\n      \n      context.beginPath();\n      if (offset) {\n        context.arc(x, y + offset, options.radius, 0, Math.PI, false);\n      } else {\n        context.arc(x, y, options.radius, 0, 2 * Math.PI, true);\n        if (options.fill) context.fill();\n      }\n      context.stroke();\n      context.closePath();\n    }\n  }\n});\n\n/** Radar **/\nFlotr.addType('radar', {\n  options: {\n    show: false,           // => setting to true will show radar chart, false will hide\n    lineWidth: 2,          // => line width in pixels\n    fill: true,            // => true to fill the area from the line to the x axis, false for (transparent) no fill\n    fillOpacity: 0.4,      // => opacity of the fill color, set to 1 for a solid fill, 0 hides the fill\n    radiusRatio: 0.90,      // => ratio of the radar, against the plot size\n    sensibility: 2         // => the lower this number, the more precise you have to aim to show a value.\n  },\n  draw : function (options) {\n    var\n      context = options.context,\n      shadowSize = options.shadowSize;\n\n    context.save();\n    context.translate(options.width / 2, options.height / 2);\n    context.lineWidth = options.lineWidth;\n    \n    // Shadow\n    context.fillStyle = 'rgba(0,0,0,0.05)';\n    context.strokeStyle = 'rgba(0,0,0,0.05)';\n    this.plot(options, shadowSize / 2);\n    context.strokeStyle = 'rgba(0,0,0,0.1)';\n    this.plot(options, shadowSize / 4);\n\n    // Chart\n    context.strokeStyle = options.color;\n    context.fillStyle = options.fillStyle;\n    this.plot(options);\n    \n    context.restore();\n  },\n  plot : function (options, offset) {\n    var\n      data    = options.data,\n      context = options.context,\n      radius  = Math.min(options.height, options.width) * options.radiusRatio / 2,\n      step    = 2 * Math.PI / data.length,\n      angle   = -Math.PI / 2,\n      i, ratio;\n\n    offset = offset || 0;\n\n    context.beginPath();\n    for (i = 0; i < data.length; ++i) {\n      ratio = data[i][1] / this.max;\n\n      context[i === 0 ? 'moveTo' : 'lineTo'](\n        Math.cos(i * step + angle) * radius * ratio + offset,\n        Math.sin(i * step + angle) * radius * ratio + offset\n      );\n    }\n    context.closePath();\n    if (options.fill) context.fill();\n    context.stroke();\n  },\n  getGeometry : function (point, options) {\n    var\n      radius  = Math.min(options.height, options.width) * options.radiusRatio / 2,\n      step    = 2 * Math.PI / options.data.length,\n      angle   = -Math.PI / 2,\n      ratio = point[1] / this.max;\n\n    return {\n      x : (Math.cos(point[0] * step + angle) * radius * ratio) + options.width / 2,\n      y : (Math.sin(point[0] * step + angle) * radius * ratio) + options.height / 2\n    };\n  },\n  hit : function (options) {\n    var\n      args = options.args,\n      mouse = args[0],\n      n = args[1],\n      relX = mouse.relX,\n      relY = mouse.relY,\n      distance,\n      geometry,\n      dx, dy;\n\n      for (var i = 0; i < n.series.length; i++) {\n        var serie = n.series[i];\n        var data = serie.data;\n\n        for (var j = data.length; j--;) {\n          geometry = this.getGeometry(data[j], options);\n\n          dx = geometry.x - relX;\n          dy = geometry.y - relY;\n          distance = Math.sqrt(dx * dx + dy * dy);\n\n          if (distance <  options.sensibility*2) {\n            n.x = data[j][0];\n            n.y = data[j][1];\n            n.index = j;\n            n.seriesIndex = i;\n            return n;\n          }\n        }\n      }\n    },\n  drawHit : function (options) {\n    var step = 2 * Math.PI / options.data.length;\n    var angle   = -Math.PI / 2;\n    var radius  = Math.min(options.height, options.width) * options.radiusRatio / 2;\n\n    var s = options.args.series;\n    var point_radius = s.points.hitRadius || s.points.radius || s.mouse.radius;\n\n    var context = options.context;\n\n    context.translate(options.width / 2, options.height / 2);\n\n    var j = options.args.index;\n    var ratio = options.data[j][1] / this.max;\n    var x = Math.cos(j * step + angle) * radius * ratio;\n    var y = Math.sin(j * step + angle) * radius * ratio;\n    context.beginPath();\n    context.arc(x, y, point_radius , 0, 2 * Math.PI, true);\n    context.closePath();\n    context.stroke();\n  },\n  clearHit : function (options) {\n    var step = 2 * Math.PI / options.data.length;\n    var angle   = -Math.PI / 2;\n    var radius  = Math.min(options.height, options.width) * options.radiusRatio / 2;\n\n    var context = options.context;\n\n    var\n        s = options.args.series,\n        lw = (s.points ? s.points.lineWidth : 1);\n        offset = (s.points.hitRadius || s.points.radius || s.mouse.radius) + lw;\n\n    context.translate(options.width / 2, options.height / 2);\n\n    var j = options.args.index;\n    var ratio = options.data[j][1] / this.max;\n    var x = Math.cos(j * step + angle) * radius * ratio;\n    var y = Math.sin(j * step + angle) * radius * ratio;\n    context.clearRect(x-offset,y-offset,offset*2,offset*2);\n  },\n  extendYRange : function (axis, data) {\n    this.max = Math.max(axis.max, this.max || -Number.MAX_VALUE);\n  }\n});\n\nFlotr.addType('timeline', {\n  options: {\n    show: false,\n    lineWidth: 1,\n    barWidth: 0.2,\n    fill: true,\n    fillColor: null,\n    fillOpacity: 0.4,\n    centered: true\n  },\n\n  draw : function (options) {\n\n    var\n      context = options.context;\n\n    context.save();\n    context.lineJoin    = 'miter';\n    context.lineWidth   = options.lineWidth;\n    context.strokeStyle = options.color;\n    context.fillStyle   = options.fillStyle;\n\n    this.plot(options);\n\n    context.restore();\n  },\n\n  plot : function (options) {\n\n    var\n      data      = options.data,\n      context   = options.context,\n      xScale    = options.xScale,\n      yScale    = options.yScale,\n      barWidth  = options.barWidth,\n      lineWidth = options.lineWidth,\n      i;\n\n    Flotr._.each(data, function (timeline) {\n\n      var \n        x   = timeline[0],\n        y   = timeline[1],\n        w   = timeline[2],\n        h   = barWidth,\n\n        xt  = Math.ceil(xScale(x)),\n        wt  = Math.ceil(xScale(x + w)) - xt,\n        yt  = Math.round(yScale(y)),\n        ht  = Math.round(yScale(y - h)) - yt,\n\n        x0  = xt - lineWidth / 2,\n        y0  = Math.round(yt - ht / 2) - lineWidth / 2;\n\n      context.strokeRect(x0, y0, wt, ht);\n      context.fillRect(x0, y0, wt, ht);\n\n    });\n  },\n\n  extendRange : function (series) {\n\n    var\n      data  = series.data,\n      xa    = series.xaxis,\n      ya    = series.yaxis,\n      w     = series.timeline.barWidth;\n\n    if (xa.options.min === null)\n      xa.min = xa.datamin - w / 2;\n\n    if (xa.options.max === null) {\n\n      var\n        max = xa.max;\n\n      Flotr._.each(data, function (timeline) {\n        max = Math.max(max, timeline[0] + timeline[2]);\n      }, this);\n\n      xa.max = max + w / 2;\n    }\n\n    if (ya.options.min === null)\n      ya.min = ya.datamin - w;\n    if (ya.options.min === null)\n      ya.max = ya.datamax + w;\n  }\n\n});\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('crosshair', {\n  options: {\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#FF0000',      // => crosshair color\n    hideCursor: true       // => hide the cursor when the crosshair is shown\n  },\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      if (this.options.crosshair.mode) {\n        this.crosshair.clearCrosshair();\n        this.crosshair.drawCrosshair(pos);\n      }\n    }\n  },\n  /**   \n   * Draws the selection box.\n   */\n  drawCrosshair: function(pos) {\n    var octx = this.octx,\n      options = this.options.crosshair,\n      plotOffset = this.plotOffset,\n      x = plotOffset.left + Math.round(pos.relX) + 0.5,\n      y = plotOffset.top + Math.round(pos.relY) + 0.5;\n    \n    if (pos.relX < 0 || pos.relY < 0 || pos.relX > this.plotWidth || pos.relY > this.plotHeight) {\n      this.el.style.cursor = null;\n      D.removeClass(this.el, 'flotr-crosshair');\n      return; \n    }\n    \n    if (options.hideCursor) {\n      this.el.style.cursor = 'none';\n      D.addClass(this.el, 'flotr-crosshair');\n    }\n    \n    octx.save();\n    octx.strokeStyle = options.color;\n    octx.lineWidth = 1;\n    octx.beginPath();\n    \n    if (options.mode.indexOf('x') != -1) {\n      octx.moveTo(x, plotOffset.top);\n      octx.lineTo(x, plotOffset.top + this.plotHeight);\n    }\n    \n    if (options.mode.indexOf('y') != -1) {\n      octx.moveTo(plotOffset.left, y);\n      octx.lineTo(plotOffset.left + this.plotWidth, y);\n    }\n    \n    octx.stroke();\n    octx.restore();\n  },\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearCrosshair: function() {\n\n    var\n      plotOffset = this.plotOffset,\n      position = this.lastMousePos,\n      context = this.octx;\n\n    if (position) {\n      context.clearRect(\n        Math.round(position.relX) + plotOffset.left,\n        plotOffset.top,\n        1,\n        this.plotHeight + 1\n      );\n      context.clearRect(\n        plotOffset.left,\n        Math.round(position.relY) + plotOffset.top,\n        this.plotWidth + 1,\n        1\n      );    \n    }\n  }\n});\n})();\n\n(function() {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nfunction getImage (type, canvas, context, width, height, background) {\n\n  // TODO add scaling for w / h\n  var\n    mime = 'image/'+type,\n    data = context.getImageData(0, 0, width, height),\n    image = new Image();\n\n  context.save();\n  context.globalCompositeOperation = 'destination-over';\n  context.fillStyle = background;\n  context.fillRect(0, 0, width, height);\n  image.src = canvas.toDataURL(mime);\n  context.restore();\n\n  context.clearRect(0, 0, width, height);\n  context.putImageData(data, 0, 0);\n\n  return image;\n}\n\nFlotr.addPlugin('download', {\n\n  saveImage: function (type, width, height, replaceCanvas) {\n    var\n      grid = this.options.grid,\n      image;\n\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      image = '<html><body>'+this.canvas.firstChild.innerHTML+'</body></html>';\n      return window.open().document.write(image);\n    }\n\n    if (type !== 'jpeg' && type !== 'png') return;\n\n    image = getImage(\n      type, this.canvas, this.ctx,\n      this.canvasWidth, this.canvasHeight,\n      grid && grid.backgroundColor || '#ffffff'\n    );\n\n    if (_.isElement(image) && replaceCanvas) {\n      this.download.restoreCanvas();\n      D.hide(this.canvas);\n      D.hide(this.overlay);\n      D.setStyles({position: 'absolute'});\n      D.insert(this.el, image);\n      this.saveImageElement = image;\n    } else {\n      return window.open(image.src);\n    }\n  },\n\n  restoreCanvas: function() {\n    D.show(this.canvas);\n    D.show(this.overlay);\n    if (this.saveImageElement) this.el.removeChild(this.saveImageElement);\n    this.saveImageElement = null;\n  }\n});\n\n})();\n\n(function () {\n\nvar E = Flotr.EventAdapter,\n    _ = Flotr._;\n\nFlotr.addPlugin('graphGrid', {\n\n  callbacks: {\n    'flotr:beforedraw' : function () {\n      this.graphGrid.drawGrid();\n    },\n    'flotr:afterdraw' : function () {\n      this.graphGrid.drawOutline();\n    }\n  },\n\n  drawGrid: function(){\n\n    var\n      ctx = this.ctx,\n      options = this.options,\n      grid = options.grid,\n      verticalLines = grid.verticalLines,\n      horizontalLines = grid.horizontalLines,\n      minorVerticalLines = grid.minorVerticalLines,\n      minorHorizontalLines = grid.minorHorizontalLines,\n      plotHeight = this.plotHeight,\n      plotWidth = this.plotWidth,\n      a, v, i, j;\n        \n    if(verticalLines || minorVerticalLines || \n           horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:beforegrid', [this.axes.x, this.axes.y, options, this]);\n    }\n    ctx.save();\n    ctx.lineWidth = 1;\n    ctx.strokeStyle = grid.tickColor;\n    \n    function circularHorizontalTicks (ticks) {\n      for(i = 0; i < ticks.length; ++i){\n        var ratio = ticks[i].v / a.max;\n        for(j = 0; j <= sides; ++j){\n          ctx[j === 0 ? 'moveTo' : 'lineTo'](\n            Math.cos(j*coeff+angle)*radius*ratio,\n            Math.sin(j*coeff+angle)*radius*ratio\n          );\n        }\n      }\n    }\n    function drawGridLines (ticks, callback) {\n      _.each(_.pluck(ticks, 'v'), function(v){\n        // Don't show lines on upper and lower bounds.\n        if ((v <= a.min || v >= a.max) || \n            (v == a.min || v == a.max) && grid.outlineWidth)\n          return;\n        callback(Math.floor(a.d2p(v)) + ctx.lineWidth/2);\n      });\n    }\n    function drawVerticalLines (x) {\n      ctx.moveTo(x, 0);\n      ctx.lineTo(x, plotHeight);\n    }\n    function drawHorizontalLines (y) {\n      ctx.moveTo(0, y);\n      ctx.lineTo(plotWidth, y);\n    }\n\n    if (grid.circular) {\n      ctx.translate(this.plotOffset.left+plotWidth/2, this.plotOffset.top+plotHeight/2);\n      var radius = Math.min(plotHeight, plotWidth)*options.radar.radiusRatio/2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw grid lines in vertical direction.\n      ctx.beginPath();\n      \n      a = this.axes.y;\n\n      if(horizontalLines){\n        circularHorizontalTicks(a.ticks);\n      }\n      if(minorHorizontalLines){\n        circularHorizontalTicks(a.minorTicks);\n      }\n      \n      if(verticalLines){\n        _.times(sides, function(i){\n          ctx.moveTo(0, 0);\n          ctx.lineTo(Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n        });\n      }\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(this.plotOffset.left, this.plotOffset.top);\n  \n      // Draw grid background, if present in options.\n      if(grid.backgroundColor){\n        ctx.fillStyle = this.processColor(grid.backgroundColor, {x1: 0, y1: 0, x2: plotWidth, y2: plotHeight});\n        ctx.fillRect(0, 0, plotWidth, plotHeight);\n      }\n      \n      ctx.beginPath();\n\n      a = this.axes.x;\n      if (verticalLines)        drawGridLines(a.ticks, drawVerticalLines);\n      if (minorVerticalLines)   drawGridLines(a.minorTicks, drawVerticalLines);\n\n      a = this.axes.y;\n      if (horizontalLines)      drawGridLines(a.ticks, drawHorizontalLines);\n      if (minorHorizontalLines) drawGridLines(a.minorTicks, drawHorizontalLines);\n\n      ctx.stroke();\n    }\n    \n    ctx.restore();\n    if(verticalLines || minorVerticalLines ||\n       horizontalLines || minorHorizontalLines){\n      E.fire(this.el, 'flotr:aftergrid', [this.axes.x, this.axes.y, options, this]);\n    }\n  }, \n\n  drawOutline: function(){\n    var\n      that = this,\n      options = that.options,\n      grid = options.grid,\n      outline = grid.outline,\n      ctx = that.ctx,\n      backgroundImage = grid.backgroundImage,\n      plotOffset = that.plotOffset,\n      leftOffset = plotOffset.left,\n      topOffset = plotOffset.top,\n      plotWidth = that.plotWidth,\n      plotHeight = that.plotHeight,\n      v, img, src, left, top, globalAlpha;\n    \n    if (!grid.outlineWidth) return;\n    \n    ctx.save();\n    \n    if (grid.circular) {\n      ctx.translate(leftOffset + plotWidth / 2, topOffset + plotHeight / 2);\n      var radius = Math.min(plotHeight, plotWidth) * options.radar.radiusRatio / 2,\n          sides = this.axes.x.ticks.length,\n          coeff = 2*(Math.PI/sides),\n          angle = -Math.PI/2;\n      \n      // Draw axis/grid border.\n      ctx.beginPath();\n      ctx.lineWidth = grid.outlineWidth;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'round';\n      \n      for(i = 0; i <= sides; ++i){\n        ctx[i === 0 ? 'moveTo' : 'lineTo'](Math.cos(i*coeff+angle)*radius, Math.sin(i*coeff+angle)*radius);\n      }\n      //ctx.arc(0, 0, radius, 0, Math.PI*2, true);\n\n      ctx.stroke();\n    }\n    else {\n      ctx.translate(leftOffset, topOffset);\n      \n      // Draw axis/grid border.\n      var lw = grid.outlineWidth,\n          orig = 0.5-lw+((lw+1)%2/2),\n          lineTo = 'lineTo',\n          moveTo = 'moveTo';\n      ctx.lineWidth = lw;\n      ctx.strokeStyle = grid.color;\n      ctx.lineJoin = 'miter';\n      ctx.beginPath();\n      ctx.moveTo(orig, orig);\n      plotWidth = plotWidth - (lw / 2) % 1;\n      plotHeight = plotHeight + lw / 2;\n      ctx[outline.indexOf('n') !== -1 ? lineTo : moveTo](plotWidth, orig);\n      ctx[outline.indexOf('e') !== -1 ? lineTo : moveTo](plotWidth, plotHeight);\n      ctx[outline.indexOf('s') !== -1 ? lineTo : moveTo](orig, plotHeight);\n      ctx[outline.indexOf('w') !== -1 ? lineTo : moveTo](orig, orig);\n      ctx.stroke();\n      ctx.closePath();\n    }\n    \n    ctx.restore();\n\n    if (backgroundImage) {\n\n      src = backgroundImage.src || backgroundImage;\n      left = (parseInt(backgroundImage.left, 10) || 0) + plotOffset.left;\n      top = (parseInt(backgroundImage.top, 10) || 0) + plotOffset.top;\n      img = new Image();\n\n      img.onload = function() {\n        ctx.save();\n        if (backgroundImage.alpha) ctx.globalAlpha = backgroundImage.alpha;\n        ctx.globalCompositeOperation = 'destination-over';\n        ctx.drawImage(img, 0, 0, img.width, img.height, left, top, plotWidth, plotHeight);\n        ctx.restore();\n      };\n\n      img.src = src;\n    }\n  }\n});\n\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._,\n  flotr = Flotr,\n  S_MOUSETRACK = 'opacity:0.7;background-color:#000;color:#fff;position:absolute;padding:2px 8px;-moz-border-radius:4px;border-radius:4px;white-space:nowrap;';\n\nFlotr.addPlugin('hit', {\n  callbacks: {\n    'flotr:mousemove': function(e, pos) {\n      this.hit.track(pos);\n    },\n    'flotr:click': function(pos) {\n      var\n        hit = this.hit.track(pos);\n      if (hit && !_.isUndefined(hit.index)) pos.hit = hit;\n    },\n    'flotr:mouseout': function(e) {\n      if (e.relatedTarget !== this.mouseTrack) {\n        this.hit.clearHit();\n      }\n    },\n    'flotr:destroy': function() {\n      if (this.options.mouse.container) {\n        D.remove(this.mouseTrack);\n      }\n      this.mouseTrack = null;\n    }\n  },\n  track : function (pos) {\n    if (this.options.mouse.track || _.any(this.series, function(s){return s.mouse && s.mouse.track;})) {\n      return this.hit.hit(pos);\n    }\n  },\n  /**\n   * Try a method on a graph type.  If the method exists, execute it.\n   * @param {Object} series\n   * @param {String} method  Method name.\n   * @param {Array} args  Arguments applied to method.\n   * @return executed successfully or failed.\n   */\n  executeOnType: function(s, method, args){\n    var\n      success = false,\n      options;\n\n    if (!_.isArray(s)) s = [s];\n\n    function e(s, index) {\n      _.each(_.keys(flotr.graphTypes), function (type) {\n        if (s[type] && s[type].show && !s.hide && this[type][method]) {\n          options = this.getOptions(s, type);\n\n          options.fill = !!s.mouse.fillColor;\n          options.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n          options.color = s.mouse.lineColor;\n          options.context = this.octx;\n          options.index = index;\n\n          if (args) options.args = args;\n          this[type][method].call(this[type], options);\n          success = true;\n        }\n      }, this);\n    }\n    _.each(s, e, this);\n\n    return success;\n  },\n  /**\n   * Updates the mouse tracking point on the overlay.\n   */\n  drawHit: function(n){\n    var octx = this.octx,\n      s = n.series;\n\n    if (s.mouse.lineColor) {\n      octx.save();\n      octx.lineWidth = (s.points ? s.points.lineWidth : 1);\n      octx.strokeStyle = s.mouse.lineColor;\n      octx.fillStyle = this.processColor(s.mouse.fillColor || '#ffffff', {opacity: s.mouse.fillOpacity});\n      octx.translate(this.plotOffset.left, this.plotOffset.top);\n\n      if (!this.hit.executeOnType(s, 'drawHit', n)) {\n        var\n          xa = n.xaxis,\n          ya = n.yaxis;\n\n        octx.beginPath();\n          // TODO fix this (points) should move to general testable graph mixin\n          octx.arc(xa.d2p(n.x), ya.d2p(n.y), s.points.hitRadius || s.points.radius || s.mouse.radius, 0, 2 * Math.PI, true);\n          octx.fill();\n          octx.stroke();\n        octx.closePath();\n      }\n      octx.restore();\n      this.clip(octx);\n    }\n    this.prevHit = n;\n  },\n  /**\n   * Removes the mouse tracking point from the overlay.\n   */\n  clearHit: function(){\n    var prev = this.prevHit,\n        octx = this.octx,\n        plotOffset = this.plotOffset;\n    octx.save();\n    octx.translate(plotOffset.left, plotOffset.top);\n    if (prev) {\n      if (!this.hit.executeOnType(prev.series, 'clearHit', this.prevHit)) {\n        // TODO fix this (points) should move to general testable graph mixin\n        var\n          s = prev.series,\n          lw = (s.points ? s.points.lineWidth : 1);\n          offset = (s.points.hitRadius || s.points.radius || s.mouse.radius) + lw;\n        octx.clearRect(\n          prev.xaxis.d2p(prev.x) - offset,\n          prev.yaxis.d2p(prev.y) - offset,\n          offset*2,\n          offset*2\n        );\n      }\n      D.hide(this.mouseTrack);\n      this.prevHit = null;\n    }\n    octx.restore();\n  },\n  /**\n   * Retrieves the nearest data point from the mouse cursor. If it's within\n   * a certain range, draw a point on the overlay canvas and display the x and y\n   * value of the data.\n   * @param {Object} mouse - Object that holds the relative x and y coordinates of the cursor.\n   */\n  hit : function (mouse) {\n\n    var\n      options = this.options,\n      prevHit = this.prevHit,\n      closest, sensibility, dataIndex, seriesIndex, series, value, xaxis, yaxis, n;\n\n    if (this.series.length === 0) return;\n\n    // Nearest data element.\n    // dist, x, y, relX, relY, absX, absY, sAngle, eAngle, fraction, mouse,\n    // xaxis, yaxis, series, index, seriesIndex\n    n = {\n      relX : mouse.relX,\n      relY : mouse.relY,\n      absX : mouse.absX,\n      absY : mouse.absY,\n      series: this.series\n    };\n\n    if (options.mouse.trackY &&\n        !options.mouse.trackAll &&\n        this.hit.executeOnType(this.series, 'hit', [mouse, n]) &&\n        !_.isUndefined(n.seriesIndex))\n      {\n      series    = this.series[n.seriesIndex];\n      n.series  = series;\n      n.mouse   = series.mouse;\n      n.xaxis   = series.xaxis;\n      n.yaxis   = series.yaxis;\n    } else {\n\n      closest = this.hit.closest(mouse);\n\n      if (closest) {\n\n        closest     = options.mouse.trackY ? closest.point : closest.x;\n        seriesIndex = closest.seriesIndex;\n        series      = this.series[seriesIndex];\n        xaxis       = series.xaxis;\n        yaxis       = series.yaxis;\n        sensibility = 2 * series.mouse.sensibility;\n\n        if\n          (options.mouse.trackAll ||\n          (closest.distanceX < sensibility / xaxis.scale &&\n          (!options.mouse.trackY || closest.distanceY < sensibility / yaxis.scale)))\n        {\n          n.series      = series;\n          n.xaxis       = series.xaxis;\n          n.yaxis       = series.yaxis;\n          n.mouse       = series.mouse;\n          n.x           = closest.x;\n          n.y           = closest.y;\n          n.dist        = closest.distance;\n          n.index       = closest.dataIndex;\n          n.seriesIndex = seriesIndex;\n        }\n      }\n    }\n\n    if (!prevHit || (prevHit.index !== n.index || prevHit.seriesIndex !== n.seriesIndex)) {\n      this.hit.clearHit();\n      if (n.series && n.mouse && n.mouse.track) {\n        this.hit.drawMouseTrack(n);\n        this.hit.drawHit(n);\n        Flotr.EventAdapter.fire(this.el, 'flotr:hit', [n, this]);\n      }\n    }\n\n    return n;\n  },\n\n  closest : function (mouse) {\n\n    var\n      series    = this.series,\n      options   = this.options,\n      relX      = mouse.relX,\n      relY      = mouse.relY,\n      compare   = Number.MAX_VALUE,\n      compareX  = Number.MAX_VALUE,\n      closest   = {},\n      closestX  = {},\n      check     = false,\n      serie, data,\n      distance, distanceX, distanceY,\n      mouseX, mouseY,\n      x, y, i, j;\n\n    function setClosest (o) {\n      o.distance = distance;\n      o.distanceX = distanceX;\n      o.distanceY = distanceY;\n      o.seriesIndex = i;\n      o.dataIndex = j;\n      o.x = x;\n      o.y = y;\n      check = true;\n    }\n\n    for (i = 0; i < series.length; i++) {\n\n      serie = series[i];\n      data = serie.data;\n      mouseX = serie.xaxis.p2d(relX);\n      mouseY = serie.yaxis.p2d(relY);\n\n      if (serie.hide) continue;\n\n      for (j = data.length; j--;) {\n\n        x = data[j][0];\n        y = data[j][1];\n        // Add stack offset if exists\n        if (data[j].y0) y += data[j].y0;\n\n        if (x === null || y === null) continue;\n\n        // don't check if the point isn't visible in the current range\n        if (x < serie.xaxis.min || x > serie.xaxis.max) continue;\n\n        distanceX = Math.abs(x - mouseX);\n        distanceY = Math.abs(y - mouseY);\n\n        // Skip square root for speed\n        distance = distanceX * distanceX + distanceY * distanceY;\n\n        if (distance < compare) {\n          compare = distance;\n          setClosest(closest);\n        }\n\n        if (distanceX < compareX) {\n          compareX = distanceX;\n          setClosest(closestX);\n        }\n      }\n    }\n\n    return check ? {\n      point : closest,\n      x : closestX\n    } : false;\n  },\n\n  drawMouseTrack : function (n) {\n\n    var\n      pos         = '', \n      s           = n.series,\n      p           = n.mouse.position, \n      m           = n.mouse.margin,\n      x           = n.x,\n      y           = n.y,\n      elStyle     = S_MOUSETRACK,\n      mouseTrack  = this.mouseTrack,\n      plotOffset  = this.plotOffset,\n      left        = plotOffset.left,\n      right       = plotOffset.right,\n      bottom      = plotOffset.bottom,\n      top         = plotOffset.top,\n      decimals    = n.mouse.trackDecimals,\n      options     = this.options,\n      container   = options.mouse.container,\n      oTop        = 0,\n      oLeft       = 0,\n      offset, size, content;\n\n    // Create\n    if (!mouseTrack) {\n      mouseTrack = D.node('<div class=\"flotr-mouse-value\" style=\"'+elStyle+'\"></div>');\n      this.mouseTrack = mouseTrack;\n      D.insert(container || this.el, mouseTrack);\n    }\n\n    // Fill tracker:\n    if (!decimals || decimals < 0) decimals = 0;\n    if (x && x.toFixed) x = x.toFixed(decimals);\n    if (y && y.toFixed) y = y.toFixed(decimals);\n    content = n.mouse.trackFormatter({\n      x: x,\n      y: y,\n      series: n.series,\n      index: n.index,\n      nearest: n,\n      fraction: n.fraction\n    });\n    if (_.isNull(content) || _.isUndefined(content)) {\n      D.hide(mouseTrack);\n      return;\n    } else {\n      mouseTrack.innerHTML = content;\n      D.show(mouseTrack);\n    }\n\n    // Positioning\n    if (!p) {\n      return;\n    }\n    size = D.size(mouseTrack);\n    if (container) {\n      offset = D.position(this.el);\n      oTop = offset.top;\n      oLeft = offset.left;\n    }\n\n    if (!n.mouse.relative) { // absolute to the canvas\n      pos += 'top:';\n      if      (p.charAt(0) == 'n') pos += (oTop + m + top);\n      else if (p.charAt(0) == 's') pos += (oTop - m + top + this.plotHeight - size.height);\n      pos += 'px;bottom:auto;left:';\n      if      (p.charAt(1) == 'e') pos += (oLeft - m + left + this.plotWidth - size.width);\n      else if (p.charAt(1) == 'w') pos += (oLeft + m + left);\n      pos += 'px;right:auto;';\n\n    // Pie\n    } else if (s.pie && s.pie.show) {\n      var center = {\n          x: (this.plotWidth)/2,\n          y: (this.plotHeight)/2\n        },\n        radius = (Math.min(this.canvasWidth, this.canvasHeight) * s.pie.sizeRatio) / 2,\n        bisection = n.sAngle<n.eAngle ? (n.sAngle + n.eAngle) / 2: (n.sAngle + n.eAngle + 2* Math.PI) / 2;\n      \n      pos += 'bottom:' + (m - top - center.y - Math.sin(bisection) * radius/2 + this.canvasHeight) + 'px;top:auto;';\n      pos += 'left:' + (m + left + center.x + Math.cos(bisection) * radius/2) + 'px;right:auto;';\n\n    // Default\n    } else {\n      pos += 'top:';\n      if (/n/.test(p)) pos += (oTop - m + top + n.yaxis.d2p(n.y) - size.height);\n      else             pos += (oTop + m + top + n.yaxis.d2p(n.y));\n      pos += 'px;bottom:auto;left:';\n      if (/w/.test(p)) pos += (oLeft - m + left + n.xaxis.d2p(n.x) - size.width);\n      else             pos += (oLeft + m + left + n.xaxis.d2p(n.x));\n      pos += 'px;right:auto;';\n    }\n\n    // Set position\n    mouseTrack.style.cssText = elStyle + pos;\n\n    if (n.mouse.relative) {\n      if (!/[ew]/.test(p)) {\n        // Center Horizontally\n        mouseTrack.style.left =\n          (oLeft + left + n.xaxis.d2p(n.x) - D.size(mouseTrack).width / 2) + 'px';\n      } else\n      if (!/[ns]/.test(p)) {\n        // Center Vertically\n        mouseTrack.style.top =\n          (oTop + top + n.yaxis.d2p(n.y) - D.size(mouseTrack).height / 2) + 'px';\n      }\n    }\n  }\n\n});\n})();\n\n/** \n * Selection Handles Plugin\n *\n *\n * Options\n *  show - True enables the handles plugin.\n *  drag - Left and Right drag handles\n *  scroll - Scrolling handle\n */\n(function () {\n\nfunction isLeftClick (e, type) {\n  return (e.which ? (e.which === 1) : (e.button === 0 || e.button === 1));\n}\n\nfunction boundX(x, graph) {\n  return Math.min(Math.max(0, x), graph.plotWidth - 1);\n}\n\nfunction boundY(y, graph) {\n  return Math.min(Math.max(0, y), graph.plotHeight);\n}\n\nvar\n  D = Flotr.DOM,\n  E = Flotr.EventAdapter,\n  _ = Flotr._;\n\n\nFlotr.addPlugin('selection', {\n\n  options: {\n    pinchOnly: null,       // Only select on pinch\n    mode: null,            // => one of null, 'x', 'y' or 'xy'\n    color: '#B6D9FF',      // => selection box color\n    fps: 20                // => frames-per-second\n  },\n\n  callbacks: {\n    'flotr:mouseup' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (selection.interval) clearInterval(selection.interval);\n\n      if (this.multitouches) {\n        selection.updateSelection();\n      } else\n      if (!options.pinchOnly) {\n        selection.setSelectionPos(selection.selection.second, pointer);\n      }\n      selection.clearSelection();\n\n      if(selection.selecting && selection.selectionIsSane()){\n        selection.drawSelection();\n        selection.fireSelectEvent();\n        this.ignoreClick = true;\n      }\n    },\n    'flotr:mousedown' : function (event) {\n\n      var\n        options = this.options.selection,\n        selection = this.selection,\n        pointer = this.getEventPosition(event);\n\n      if (!options || !options.mode) return;\n      if (!options.mode || (!isLeftClick(event) && _.isUndefined(event.touches))) return;\n      if (!options.pinchOnly) selection.setSelectionPos(selection.selection.first, pointer);\n      if (selection.interval) clearInterval(selection.interval);\n\n      this.lastMousePos.pageX = null;\n      selection.selecting = false;\n      selection.interval = setInterval(\n        _.bind(selection.updateSelection, this),\n        1000 / options.fps\n      );\n    },\n    'flotr:destroy' : function (event) {\n      clearInterval(this.selection.interval);\n    }\n  },\n\n  // TODO This isn't used.  Maybe it belongs in the draw area and fire select event methods?\n  getArea: function() {\n\n    var\n      s = this.selection.selection,\n      a = this.axes,\n      first = s.first,\n      second = s.second,\n      x1, x2, y1, y2;\n\n    x1 = a.x.p2d(s.first.x);\n    x2 = a.x.p2d(s.second.x);\n    y1 = a.y.p2d(s.first.y);\n    y2 = a.y.p2d(s.second.y);\n\n    return {\n      x1 : Math.min(x1, x2),\n      y1 : Math.min(y1, y2),\n      x2 : Math.max(x1, x2),\n      y2 : Math.max(y1, y2),\n      xfirst : x1,\n      xsecond : x2,\n      yfirst : y1,\n      ysecond : y2\n    };\n  },\n\n  selection: {first: {x: -1, y: -1}, second: {x: -1, y: -1}},\n  prevSelection: null,\n  interval: null,\n\n  /**\n   * Fires the 'flotr:select' event when the user made a selection.\n   */\n  fireSelectEvent: function(name){\n    var\n      area = this.selection.getArea();\n    name = name || 'select';\n    area.selection = this.selection.selection;\n    E.fire(this.el, 'flotr:'+name, [area, this]);\n  },\n\n  /**\n   * Allows the user the manually select an area.\n   * @param {Object} area - Object with coordinates to select.\n   */\n  setSelection: function(area, preventEvent){\n    var options = this.options,\n      xa = this.axes.x,\n      ya = this.axes.y,\n      vertScale = ya.scale,\n      hozScale = xa.scale,\n      selX = options.selection.mode.indexOf('x') != -1,\n      selY = options.selection.mode.indexOf('y') != -1,\n      s = this.selection.selection;\n    \n    this.selection.clearSelection();\n\n    s.first.y  = boundY((selX && !selY) ? 0 : (ya.max - area.y1) * vertScale, this);\n    s.second.y = boundY((selX && !selY) ? this.plotHeight - 1: (ya.max - area.y2) * vertScale, this);\n    s.first.x  = boundX((selY && !selX) ? 0 : (area.x1 - xa.min) * hozScale, this);\n    s.second.x = boundX((selY && !selX) ? this.plotWidth : (area.x2 - xa.min) * hozScale, this);\n    \n    this.selection.drawSelection();\n    if (!preventEvent)\n      this.selection.fireSelectEvent();\n  },\n\n  /**\n   * Calculates the position of the selection.\n   * @param {Object} pos - Position object.\n   * @param {Event} event - Event object.\n   */\n  setSelectionPos: function(pos, pointer) {\n    var mode = this.options.selection.mode,\n        selection = this.selection.selection;\n\n    if(mode.indexOf('x') == -1) {\n      pos.x = (pos == selection.first) ? 0 : this.plotWidth;         \n    }else{\n      pos.x = boundX(pointer.relX, this);\n    }\n\n    if (mode.indexOf('y') == -1) {\n      pos.y = (pos == selection.first) ? 0 : this.plotHeight - 1;\n    }else{\n      pos.y = boundY(pointer.relY, this);\n    }\n  },\n  /**\n   * Draws the selection box.\n   */\n  drawSelection: function() {\n\n    this.selection.fireSelectEvent('selecting');\n\n    var s = this.selection.selection,\n      octx = this.octx,\n      options = this.options,\n      plotOffset = this.plotOffset,\n      prevSelection = this.selection.prevSelection;\n    \n    if (prevSelection &&\n      s.first.x == prevSelection.first.x &&\n      s.first.y == prevSelection.first.y && \n      s.second.x == prevSelection.second.x &&\n      s.second.y == prevSelection.second.y) {\n      return;\n    }\n\n    octx.save();\n    octx.strokeStyle = this.processColor(options.selection.color, {opacity: 0.8});\n    octx.lineWidth = 1;\n    octx.lineJoin = 'miter';\n    octx.fillStyle = this.processColor(options.selection.color, {opacity: 0.4});\n\n    this.selection.prevSelection = {\n      first: { x: s.first.x, y: s.first.y },\n      second: { x: s.second.x, y: s.second.y }\n    };\n\n    var x = Math.min(s.first.x, s.second.x),\n        y = Math.min(s.first.y, s.second.y),\n        w = Math.abs(s.second.x - s.first.x),\n        h = Math.abs(s.second.y - s.first.y);\n\n    octx.fillRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.strokeRect(x + plotOffset.left+0.5, y + plotOffset.top+0.5, w, h);\n    octx.restore();\n  },\n\n  /**\n   * Updates (draws) the selection box.\n   */\n  updateSelection: function(){\n    if (!this.lastMousePos.pageX) return;\n\n    this.selection.selecting = true;\n\n    if (this.multitouches) {\n      this.selection.setSelectionPos(this.selection.selection.first,  this.getEventPosition(this.multitouches[0]));\n      this.selection.setSelectionPos(this.selection.selection.second,  this.getEventPosition(this.multitouches[1]));\n    } else\n    if (this.options.selection.pinchOnly) {\n      return;\n    } else {\n      this.selection.setSelectionPos(this.selection.selection.second, this.lastMousePos);\n    }\n\n    this.selection.clearSelection();\n    \n    if(this.selection.selectionIsSane()) {\n      this.selection.drawSelection();\n    }\n  },\n\n  /**\n   * Removes the selection box from the overlay canvas.\n   */\n  clearSelection: function() {\n    if (!this.selection.prevSelection) return;\n      \n    var prevSelection = this.selection.prevSelection,\n      lw = 1,\n      plotOffset = this.plotOffset,\n      x = Math.min(prevSelection.first.x, prevSelection.second.x),\n      y = Math.min(prevSelection.first.y, prevSelection.second.y),\n      w = Math.abs(prevSelection.second.x - prevSelection.first.x),\n      h = Math.abs(prevSelection.second.y - prevSelection.first.y);\n    \n    this.octx.clearRect(x + plotOffset.left - lw + 0.5,\n                        y + plotOffset.top - lw,\n                        w + 2 * lw + 0.5,\n                        h + 2 * lw + 0.5);\n    \n    this.selection.prevSelection = null;\n  },\n  /**\n   * Determines whether or not the selection is sane and should be drawn.\n   * @return {Boolean} - True when sane, false otherwise.\n   */\n  selectionIsSane: function(){\n    var s = this.selection.selection;\n    return Math.abs(s.second.x - s.first.x) >= 5 || \n           Math.abs(s.second.y - s.first.y) >= 5;\n  }\n\n});\n\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('labels', {\n\n  callbacks : {\n    'flotr:afterdraw' : function () {\n      this.labels.draw();\n    }\n  },\n\n  draw: function(){\n    // Construct fixed width label boxes, which can be styled easily.\n    var\n      axis, tick, left, top, xBoxWidth,\n      radius, sides, coeff, angle,\n      div, i, html = '',\n      noLabels = 0,\n      options  = this.options,\n      ctx      = this.ctx,\n      a        = this.axes,\n      style    = { size: options.fontSize };\n\n    for (i = 0; i < a.x.ticks.length; ++i){\n      if (a.x.ticks[i].label) { ++noLabels; }\n    }\n    xBoxWidth = this.plotWidth / noLabels;\n\n    if (options.grid.circular) {\n      ctx.save();\n      ctx.translate(this.plotOffset.left + this.plotWidth / 2,\n          this.plotOffset.top + this.plotHeight / 2);\n\n      radius = this.plotHeight * options.radar.radiusRatio / 2 + options.fontSize;\n      sides  = this.axes.x.ticks.length;\n      coeff  = 2 * (Math.PI / sides);\n      angle  = -Math.PI / 2;\n\n      drawLabelCircular(this, a.x, false);\n      drawLabelCircular(this, a.x, true);\n      drawLabelCircular(this, a.y, false);\n      drawLabelCircular(this, a.y, true);\n      ctx.restore();\n    }\n\n    if (!options.HtmlText && this.textEnabled) {\n      drawLabelNoHtmlText(this, a.x, 'center', 'top');\n      drawLabelNoHtmlText(this, a.x2, 'center', 'bottom');\n      drawLabelNoHtmlText(this, a.y, 'right', 'middle');\n      drawLabelNoHtmlText(this, a.y2, 'left', 'middle');\n    \n    } else if ((\n        a.x.options.showLabels ||\n        a.x2.options.showLabels ||\n        a.y.options.showLabels ||\n        a.y2.options.showLabels) &&\n        !options.grid.circular\n      ) {\n\n      html = '';\n\n      drawLabelHtml(this, a.x);\n      drawLabelHtml(this, a.x2);\n      drawLabelHtml(this, a.y);\n      drawLabelHtml(this, a.y2);\n\n      ctx.stroke();\n      ctx.restore();\n      div = D.create('div');\n      D.setStyles(div, {\n        fontSize: 'smaller',\n        color: options.grid.color\n      });\n      div.className = 'flotr-labels';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n\n    function drawLabelCircular (graph, axis, minorTicks) {\n      var\n        ticks   = minorTicks ? axis.minorTicks : axis.ticks,\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        angle        : Flotr.toRad(axis.options.labelsAngle),\n        textBaseline : 'middle'\n      };\n\n      for (i = 0; i < ticks.length &&\n          (minorTicks ? axis.options.showMinorLabels : axis.options.showLabels); ++i){\n        tick = ticks[i];\n        tick.label += '';\n        if (!tick.label || !tick.label.length) { continue; }\n\n        x = Math.cos(i * coeff + angle) * radius;\n        y = Math.sin(i * coeff + angle) * radius;\n\n        style.textAlign = isX ? (Math.abs(x) < 0.1 ? 'center' : (x < 0 ? 'right' : 'left')) : 'left';\n\n        Flotr.drawText(\n          ctx, tick.label,\n          isX ? x : 3,\n          isX ? y : -(axis.ticks[i].v / axis.max) * (radius - options.fontSize),\n          style\n        );\n      }\n    }\n\n    function drawLabelNoHtmlText (graph, axis, textAlign, textBaseline)  {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        style, offset;\n\n      style = {\n        color        : axis.options.color || options.grid.color,\n        textAlign    : textAlign,\n        textBaseline : textBaseline,\n        angle : Flotr.toRad(axis.options.labelsAngle)\n      };\n      style = Flotr.getBestTextAlign(style.angle, style);\n\n      for (i = 0; i < axis.ticks.length && continueShowingLabels(axis); ++i) {\n\n        tick = axis.ticks[i];\n        if (!tick.label || !tick.label.length) { continue; }\n\n        offset = axis.d2p(tick.v);\n        if (offset < 0 ||\n            offset > (isX ? graph.plotWidth : graph.plotHeight)) { continue; }\n\n        Flotr.drawText(\n          ctx, tick.label,\n          leftOffset(graph, isX, isFirst, offset),\n          topOffset(graph, isX, isFirst, offset),\n          style\n        );\n\n        // Only draw on axis y2\n        if (!isX && !isFirst) {\n          ctx.save();\n          ctx.strokeStyle = style.color;\n          ctx.beginPath();\n          ctx.moveTo(graph.plotOffset.left + graph.plotWidth - 8, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.lineTo(graph.plotOffset.left + graph.plotWidth, graph.plotOffset.top + axis.d2p(tick.v));\n          ctx.stroke();\n          ctx.restore();\n        }\n      }\n\n      function continueShowingLabels (axis) {\n        return axis.options.showLabels && axis.used;\n      }\n      function leftOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.left +\n          (isX ? offset :\n            (isFirst ?\n              -options.grid.labelMargin :\n              options.grid.labelMargin + graph.plotWidth));\n      }\n      function topOffset (graph, isX, isFirst, offset) {\n        return graph.plotOffset.top +\n          (isX ? options.grid.labelMargin : offset) +\n          ((isX && isFirst) ? graph.plotHeight : 0);\n      }\n    }\n\n    function drawLabelHtml (graph, axis) {\n      var\n        isX     = axis.orientation === 1,\n        isFirst = axis.n === 1,\n        name = '',\n        left, style, top,\n        offset = graph.plotOffset;\n\n      if (!isX && !isFirst) {\n        ctx.save();\n        ctx.strokeStyle = axis.options.color || options.grid.color;\n        ctx.beginPath();\n      }\n\n      if (axis.options.showLabels && (isFirst ? true : axis.used)) {\n        for (i = 0; i < axis.ticks.length; ++i) {\n          tick = axis.ticks[i];\n          if (!tick.label || !tick.label.length ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) < 0) ||\n              ((isX ? offset.left : offset.top) + axis.d2p(tick.v) > (isX ? graph.canvasWidth : graph.canvasHeight))) {\n            continue;\n          }\n          top = offset.top +\n            (isX ?\n              ((isFirst ? 1 : -1 ) * (graph.plotHeight + options.grid.labelMargin)) :\n              axis.d2p(tick.v) - axis.maxLabel.height / 2);\n          left = isX ? (offset.left + axis.d2p(tick.v) - xBoxWidth / 2) : 0;\n\n          name = '';\n          if (i === 0) {\n            name = ' first';\n          } else if (i === axis.ticks.length - 1) {\n            name = ' last';\n          }\n          name += isX ? ' flotr-grid-label-x' : ' flotr-grid-label-y';\n\n          html += [\n            '<div style=\"position:absolute; text-align:' + (isX ? 'center' : 'right') + '; ',\n            'top:' + top + 'px; ',\n            ((!isX && !isFirst) ? 'right:' : 'left:') + left + 'px; ',\n            'width:' + (isX ? xBoxWidth : ((isFirst ? offset.left : offset.right) - options.grid.labelMargin)) + 'px; ',\n            axis.options.color ? ('color:' + axis.options.color + '; ') : ' ',\n            '\" class=\"flotr-grid-label' + name + '\">' + tick.label + '</div>'\n          ].join(' ');\n          \n          if (!isX && !isFirst) {\n            ctx.moveTo(offset.left + graph.plotWidth - 8, offset.top + axis.d2p(tick.v));\n            ctx.lineTo(offset.left + graph.plotWidth, offset.top + axis.d2p(tick.v));\n          }\n        }\n      }\n    }\n  }\n\n});\n})();\n\n(function () {\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('legend', {\n  options: {\n    show: true,            // => setting to true will show the legend, hide otherwise\n    noColumns: 1,          // => number of colums in legend table // @todo: doesn't work for HtmlText = false\n    labelFormatter: function(v){return v;}, // => fn: string -> string\n    labelBoxBorderColor: '#CCCCCC', // => border color for the little label boxes\n    labelBoxWidth: 14,\n    labelBoxHeight: 10,\n    labelBoxMargin: 5,\n    container: null,       // => container (as jQuery object) to put legend in, null means default on top of graph\n    position: 'nw',        // => position of default legend container within plot\n    margin: 5,             // => distance from grid edge to default legend container within plot\n    backgroundColor: '#F0F0F0', // => Legend background color.\n    backgroundOpacity: 0.85// => set to 0 to avoid background, set to 1 for a solid background\n  },\n  callbacks: {\n    'flotr:afterinit': function() {\n      this.legend.insertLegend();\n    },\n    'flotr:destroy': function() {\n      var markup = this.legend.markup;\n      if (markup) {\n        this.legend.markup = null;\n        D.remove(markup);\n      }\n    }\n  },\n  /**\n   * Adds a legend div to the canvas container or draws it on the canvas.\n   */\n  insertLegend: function(){\n\n    if(!this.options.legend.show)\n      return;\n\n    var series      = this.series,\n      plotOffset    = this.plotOffset,\n      options       = this.options,\n      legend        = options.legend,\n      fragments     = [],\n      rowStarted    = false, \n      ctx           = this.ctx,\n      itemCount     = _.filter(series, function(s) {return (s.label && !s.hide);}).length,\n      p             = legend.position, \n      m             = legend.margin,\n      opacity       = legend.backgroundOpacity,\n      i, label, color;\n\n    if (itemCount) {\n\n      var lbw = legend.labelBoxWidth,\n          lbh = legend.labelBoxHeight,\n          lbm = legend.labelBoxMargin,\n          offsetX = plotOffset.left + m,\n          offsetY = plotOffset.top + m,\n          labelMaxWidth = 0,\n          style = {\n            size: options.fontSize*1.1,\n            color: options.grid.color\n          };\n\n      // We calculate the labels' max width\n      for(i = series.length - 1; i > -1; --i){\n        if(!series[i].label || series[i].hide) continue;\n        label = legend.labelFormatter(series[i].label);\n        labelMaxWidth = Math.max(labelMaxWidth, this._text.measureText(label, style).width);\n      }\n\n      var legendWidth  = Math.round(lbw + lbm*3 + labelMaxWidth),\n          legendHeight = Math.round(itemCount*(lbm+lbh) + lbm);\n\n      // Default Opacity\n      if (!opacity && opacity !== 0) {\n        opacity = 0.1;\n      }\n\n      if (!options.HtmlText && this.textEnabled && !legend.container) {\n        \n        if(p.charAt(0) == 's') offsetY = plotOffset.top + this.plotHeight - (m + legendHeight);\n        if(p.charAt(0) == 'c') offsetY = plotOffset.top + (this.plotHeight/2) - (m + (legendHeight/2));\n        if(p.charAt(1) == 'e') offsetX = plotOffset.left + this.plotWidth - (m + legendWidth);\n        \n        // Legend box\n        color = this.processColor(legend.backgroundColor, { opacity : opacity });\n\n        ctx.fillStyle = color;\n        ctx.fillRect(offsetX, offsetY, legendWidth, legendHeight);\n        ctx.strokeStyle = legend.labelBoxBorderColor;\n        ctx.strokeRect(Flotr.toPixel(offsetX), Flotr.toPixel(offsetY), legendWidth, legendHeight);\n        \n        // Legend labels\n        var x = offsetX + lbm;\n        var y = offsetY + lbm;\n        for(i = 0; i < series.length; i++){\n          if(!series[i].label || series[i].hide) continue;\n          label = legend.labelFormatter(series[i].label);\n          \n          ctx.fillStyle = series[i].color;\n          ctx.fillRect(x, y, lbw-1, lbh-1);\n          \n          ctx.strokeStyle = legend.labelBoxBorderColor;\n          ctx.lineWidth = 1;\n          ctx.strokeRect(Math.ceil(x)-1.5, Math.ceil(y)-1.5, lbw+2, lbh+2);\n          \n          // Legend text\n          Flotr.drawText(ctx, label, x + lbw + lbm, y + lbh, style);\n          \n          y += lbh + lbm;\n        }\n      }\n      else {\n        for(i = 0; i < series.length; ++i){\n          if(!series[i].label || series[i].hide) continue;\n          \n          if(i % legend.noColumns === 0){\n            fragments.push(rowStarted ? '</tr><tr>' : '<tr>');\n            rowStarted = true;\n          }\n\n          var s = series[i],\n            boxWidth = legend.labelBoxWidth,\n            boxHeight = legend.labelBoxHeight;\n\n          label = legend.labelFormatter(s.label);\n          color = 'background-color:' + ((s.bars && s.bars.show && s.bars.fillColor && s.bars.fill) ? s.bars.fillColor : s.color) + ';';\n          \n          fragments.push(\n            '<td class=\"flotr-legend-color-box\">',\n              '<div style=\"border:1px solid ', legend.labelBoxBorderColor, ';padding:1px\">',\n                '<div style=\"width:', (boxWidth-1), 'px;height:', (boxHeight-1), 'px;border:1px solid ', series[i].color, '\">', // Border\n                  '<div style=\"width:', boxWidth, 'px;height:', boxHeight, 'px;', color, '\"></div>', // Background\n                '</div>',\n              '</div>',\n            '</td>',\n            '<td class=\"flotr-legend-label\">', label, '</td>'\n          );\n        }\n        if(rowStarted) fragments.push('</tr>');\n          \n        if(fragments.length > 0){\n          var table = '<table style=\"font-size:smaller;color:' + options.grid.color + '\">' + fragments.join('') + '</table>';\n          if(legend.container){\n            table = D.node(table);\n            this.legend.markup = table;\n            D.insert(legend.container, table);\n          }\n          else {\n            var styles = {position: 'absolute', 'zIndex': '2', 'border' : '1px solid ' + legend.labelBoxBorderColor};\n\n                 if(p.charAt(0) == 'n') { styles.top = (m + plotOffset.top) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 'c') { styles.top = (m + (this.plotHeight - legendHeight) / 2) + 'px'; styles.bottom = 'auto'; }\n            else if(p.charAt(0) == 's') { styles.bottom = (m + plotOffset.bottom) + 'px'; styles.top = 'auto'; }\n                 if(p.charAt(1) == 'e') { styles.right = (m + plotOffset.right) + 'px'; styles.left = 'auto'; }\n            else if(p.charAt(1) == 'w') { styles.left = (m + plotOffset.left) + 'px'; styles.right = 'auto'; }\n\n            var div = D.create('div'), size;\n            div.className = 'flotr-legend';\n            D.setStyles(div, styles);\n            D.insert(div, table);\n            D.insert(this.el, div);\n            \n            if (!opacity) return;\n\n            var c = legend.backgroundColor || options.grid.backgroundColor || '#ffffff';\n\n            _.extend(styles, D.size(div), {\n              'backgroundColor': c,\n              'zIndex' : '',\n              'border' : ''\n            });\n            styles.width += 'px';\n            styles.height += 'px';\n\n             // Put in the transparent background separately to avoid blended labels and\n            div = D.create('div');\n            div.className = 'flotr-legend-bg';\n            D.setStyles(div, styles);\n            D.opacity(div, opacity);\n            D.insert(div, ' ');\n            D.insert(this.el, div);\n          }\n        }\n      }\n    }\n  }\n});\n})();\n\n/** Spreadsheet **/\n(function() {\n\nfunction getRowLabel(value){\n  if (this.options.spreadsheet.tickFormatter){\n    //TODO maybe pass the xaxis formatter to the custom tick formatter as an opt-out?\n    return this.options.spreadsheet.tickFormatter(value);\n  }\n  else {\n    var t = _.find(this.axes.x.ticks, function(t){return t.v == value;});\n    if (t) {\n      return t.label;\n    }\n    return value;\n  }\n}\n\nvar\n  D = Flotr.DOM,\n  _ = Flotr._;\n\nFlotr.addPlugin('spreadsheet', {\n  options: {\n    show: false,           // => show the data grid using two tabs\n    tabGraphLabel: 'Graph',\n    tabDataLabel: 'Data',\n    toolbarDownload: 'Download CSV', // @todo: add better language support\n    toolbarSelectAll: 'Select all',\n    csvFileSeparator: ',',\n    decimalSeparator: '.',\n    tickFormatter: null,\n    initialTab: 'graph'\n  },\n  /**\n   * Builds the tabs in the DOM\n   */\n  callbacks: {\n    'flotr:afterconstruct': function(){\n      // @TODO necessary?\n      //this.el.select('.flotr-tabs-group,.flotr-datagrid-container').invoke('remove');\n      \n      if (!this.options.spreadsheet.show) return;\n      \n      var ss = this.spreadsheet,\n        container = D.node('<div class=\"flotr-tabs-group\" style=\"position:absolute;left:0px;width:'+this.canvasWidth+'px\"></div>'),\n        graph = D.node('<div style=\"float:left\" class=\"flotr-tab selected\">'+this.options.spreadsheet.tabGraphLabel+'</div>'),\n        data = D.node('<div style=\"float:left\" class=\"flotr-tab\">'+this.options.spreadsheet.tabDataLabel+'</div>'),\n        offset;\n\n      ss.tabsContainer = container;\n      ss.tabs = { graph : graph, data : data };\n\n      D.insert(container, graph);\n      D.insert(container, data);\n      D.insert(this.el, container);\n\n      offset = D.size(data).height + 2;\n      this.plotOffset.bottom += offset;\n\n      D.setStyles(container, {top: this.canvasHeight-offset+'px'});\n\n      this.\n        observe(graph, 'click',  function(){ss.showTab('graph');}).\n        observe(data, 'click', function(){ss.showTab('data');});\n      if (this.options.spreadsheet.initialTab !== 'graph'){\n        ss.showTab(this.options.spreadsheet.initialTab);\n      }\n    }\n  },\n  /**\n   * Builds a matrix of the data to make the correspondance between the x values and the y values :\n   * X value => Y values from the axes\n   * @return {Array} The data grid\n   */\n  loadDataGrid: function(){\n    if (this.seriesData) return this.seriesData;\n\n    var s = this.series,\n        rows = {};\n\n    /* The data grid is a 2 dimensions array. There is a row for each X value.\n     * Each row contains the x value and the corresponding y value for each serie ('undefined' if there isn't one)\n    **/\n    _.each(s, function(serie, i){\n      _.each(serie.data, function (v) {\n        var x = v[0],\n            y = v[1],\n            r = rows[x];\n        if (r) {\n          r[i+1] = y;\n        } else {\n          var newRow = [];\n          newRow[0] = x;\n          newRow[i+1] = y;\n          rows[x] = newRow;\n        }\n      });\n    });\n\n    // The data grid is sorted by x value\n    this.seriesData = _.sortBy(rows, function(row, x){\n      return parseInt(x, 10);\n    });\n    return this.seriesData;\n  },\n  /**\n   * Constructs the data table for the spreadsheet\n   * @todo make a spreadsheet manager (Flotr.Spreadsheet)\n   * @return {Element} The resulting table element\n   */\n  constructDataGrid: function(){\n    // If the data grid has already been built, nothing to do here\n    if (this.spreadsheet.datagrid) return this.spreadsheet.datagrid;\n    \n    var s = this.series,\n        datagrid = this.spreadsheet.loadDataGrid(),\n        colgroup = ['<colgroup><col />'],\n        buttonDownload, buttonSelect, t;\n    \n    // First row : series' labels\n    var html = ['<table class=\"flotr-datagrid\"><tr class=\"first-row\">'];\n    html.push('<th>&nbsp;</th>');\n    _.each(s, function(serie,i){\n      html.push('<th scope=\"col\">'+(serie.label || String.fromCharCode(65+i))+'</th>');\n      colgroup.push('<col />');\n    });\n    html.push('</tr>');\n    // Data rows\n    _.each(datagrid, function(row){\n      html.push('<tr>');\n      _.times(s.length+1, function(i){\n        var tag = 'td',\n            value = row[i],\n            // TODO: do we really want to handle problems with floating point\n            // precision here?\n            content = (!_.isUndefined(value) ? Math.round(value*100000)/100000 : '');\n        if (i === 0) {\n          tag = 'th';\n          var label = getRowLabel.call(this, content);\n          if (label) content = label;\n        }\n\n        html.push('<'+tag+(tag=='th'?' scope=\"row\"':'')+'>'+content+'</'+tag+'>');\n      }, this);\n      html.push('</tr>');\n    }, this);\n    colgroup.push('</colgroup>');\n    t = D.node(html.join(''));\n\n    /**\n     * @TODO disabled this\n    if (!Flotr.isIE || Flotr.isIE == 9) {\n      function handleMouseout(){\n        t.select('colgroup col.hover, th.hover').invoke('removeClassName', 'hover');\n      }\n      function handleMouseover(e){\n        var td = e.element(),\n          siblings = td.previousSiblings();\n        t.select('th[scope=col]')[siblings.length-1].addClassName('hover');\n        t.select('colgroup col')[siblings.length].addClassName('hover');\n      }\n      _.each(t.select('td'), function(td) {\n        Flotr.EventAdapter.\n          observe(td, 'mouseover', handleMouseover).\n          observe(td, 'mouseout', handleMouseout);\n      });\n    }\n    */\n\n    buttonDownload = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarDownload +\n      '</button>');\n\n    buttonSelect = D.node(\n      '<button type=\"button\" class=\"flotr-datagrid-toolbar-button\">' +\n      this.options.spreadsheet.toolbarSelectAll+\n      '</button>');\n\n    this.\n      observe(buttonDownload, 'click', _.bind(this.spreadsheet.downloadCSV, this)).\n      observe(buttonSelect, 'click', _.bind(this.spreadsheet.selectAllData, this));\n\n    var toolbar = D.node('<div class=\"flotr-datagrid-toolbar\"></div>');\n    D.insert(toolbar, buttonDownload);\n    D.insert(toolbar, buttonSelect);\n\n    var containerHeight =this.canvasHeight - D.size(this.spreadsheet.tabsContainer).height-2,\n        container = D.node('<div class=\"flotr-datagrid-container\" style=\"position:absolute;left:0px;top:0px;width:'+\n          this.canvasWidth+'px;height:'+containerHeight+'px;overflow:auto;z-index:10\"></div>');\n\n    D.insert(container, toolbar);\n    D.insert(container, t);\n    D.insert(this.el, container);\n    this.spreadsheet.datagrid = t;\n    this.spreadsheet.container = container;\n\n    return t;\n  },  \n  /**\n   * Shows the specified tab, by its name\n   * @todo make a tab manager (Flotr.Tabs)\n   * @param {String} tabName - The tab name\n   */\n  showTab: function(tabName){\n    if (this.spreadsheet.activeTab === tabName){\n      return;\n    }\n    switch(tabName) {\n      case 'graph':\n        D.hide(this.spreadsheet.container);\n        D.removeClass(this.spreadsheet.tabs.data, 'selected');\n        D.addClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      case 'data':\n        if (!this.spreadsheet.datagrid)\n          this.spreadsheet.constructDataGrid();\n        D.show(this.spreadsheet.container);\n        D.addClass(this.spreadsheet.tabs.data, 'selected');\n        D.removeClass(this.spreadsheet.tabs.graph, 'selected');\n      break;\n      default:\n        throw 'Illegal tab name: ' + tabName;\n    }\n    this.spreadsheet.activeTab = tabName;\n  },\n  /**\n   * Selects the data table in the DOM for copy/paste\n   */\n  selectAllData: function(){\n    if (this.spreadsheet.tabs) {\n      var selection, range, doc, win, node = this.spreadsheet.constructDataGrid();\n\n      this.spreadsheet.showTab('data');\n      \n      // deferred to be able to select the table\n      setTimeout(function () {\n        if ((doc = node.ownerDocument) && (win = doc.defaultView) && \n            win.getSelection && doc.createRange && \n            (selection = window.getSelection()) && \n            selection.removeAllRanges) {\n            range = doc.createRange();\n            range.selectNode(node);\n            selection.removeAllRanges();\n            selection.addRange(range);\n        }\n        else if (document.body && document.body.createTextRange && \n                (range = document.body.createTextRange())) {\n            range.moveToElementText(node);\n            range.select();\n        }\n      }, 0);\n      return true;\n    }\n    else return false;\n  },\n  /**\n   * Converts the data into CSV in order to download a file\n   */\n  downloadCSV: function(){\n    var csv = '',\n        series = this.series,\n        options = this.options,\n        dg = this.spreadsheet.loadDataGrid(),\n        separator = encodeURIComponent(options.spreadsheet.csvFileSeparator);\n    \n    if (options.spreadsheet.decimalSeparator === options.spreadsheet.csvFileSeparator) {\n      throw \"The decimal separator is the same as the column separator (\"+options.spreadsheet.decimalSeparator+\")\";\n    }\n    \n    // The first row\n    _.each(series, function(serie, i){\n      csv += separator+'\"'+(serie.label || String.fromCharCode(65+i)).replace(/\\\"/g, '\\\\\"')+'\"';\n    });\n\n    csv += \"%0D%0A\"; // \\r\\n\n    \n    // For each row\n    csv += _.reduce(dg, function(memo, row){\n      var rowLabel = getRowLabel.call(this, row[0]) || '';\n      rowLabel = '\"'+(rowLabel+'').replace(/\\\"/g, '\\\\\"')+'\"';\n      var numbers = row.slice(1).join(separator);\n      if (options.spreadsheet.decimalSeparator !== '.') {\n        numbers = numbers.replace(/\\./g, options.spreadsheet.decimalSeparator);\n      }\n      return memo + rowLabel+separator+numbers+\"%0D%0A\"; // \\t and \\r\\n\n    }, '', this);\n\n    if (Flotr.isIE && Flotr.isIE < 9) {\n      csv = csv.replace(new RegExp(separator, 'g'), decodeURIComponent(separator)).replace(/%0A/g, '\\n').replace(/%0D/g, '\\r');\n      window.open().document.write(csv);\n    }\n    else window.open('data:text/csv,'+csv);\n  }\n});\n})();\n\n(function () {\n\nvar D = Flotr.DOM;\n\nFlotr.addPlugin('titles', {\n  callbacks: {\n    'flotr:afterdraw': function() {\n      this.titles.drawTitles();\n    }\n  },\n  /**\n   * Draws the title and the subtitle\n   */\n  drawTitles : function () {\n    var html,\n        options = this.options,\n        margin = options.grid.labelMargin,\n        ctx = this.ctx,\n        a = this.axes;\n    \n    if (!options.HtmlText && this.textEnabled) {\n      var style = {\n        size: options.fontSize,\n        color: options.grid.color,\n        textAlign: 'center'\n      };\n      \n      // Add subtitle\n      if (options.subtitle){\n        Flotr.drawText(\n          ctx, options.subtitle,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight + this.subtitleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.5;\n      style.size *= 1.5;\n      \n      // Add title\n      if (options.title){\n        Flotr.drawText(\n          ctx, options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.titleHeight - 2,\n          style\n        );\n      }\n      \n      style.weight = 1.8;\n      style.size *= 0.8;\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used){\n        style.textAlign = a.x.options.titleAlign || 'center';\n        style.textBaseline = 'top';\n        style.angle = Flotr.toRad(a.x.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top + a.x.maxLabel.height + this.plotHeight + 2 * margin,\n          style\n        );\n      }\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used){\n        style.textAlign = a.x2.options.titleAlign || 'center';\n        style.textBaseline = 'bottom';\n        style.angle = Flotr.toRad(a.x2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.x2.options.title,\n          this.plotOffset.left + this.plotWidth/2, \n          this.plotOffset.top - a.x2.maxLabel.height - 2 * margin,\n          style\n        );\n      }\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used){\n        style.textAlign = a.y.options.titleAlign || 'right';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y.options.title,\n          this.plotOffset.left - a.y.maxLabel.width - 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used){\n        style.textAlign = a.y2.options.titleAlign || 'left';\n        style.textBaseline = 'middle';\n        style.angle = Flotr.toRad(a.y2.options.titleAngle);\n        style = Flotr.getBestTextAlign(style.angle, style);\n        Flotr.drawText(\n          ctx, a.y2.options.title,\n          this.plotOffset.left + this.plotWidth + a.y2.maxLabel.width + 2 * margin, \n          this.plotOffset.top + this.plotHeight / 2,\n          style\n        );\n      }\n    } \n    else {\n      html = [];\n      \n      // Add title\n      if (options.title)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', \n          this.plotOffset.left, 'px;font-size:1em;font-weight:bold;text-align:center;width:',\n          this.plotWidth,'px;\" class=\"flotr-title\">', options.title, '</div>'\n        );\n      \n      // Add subtitle\n      if (options.subtitle)\n        html.push(\n          '<div style=\"position:absolute;top:', this.titleHeight, 'px;left:', \n          this.plotOffset.left, 'px;font-size:smaller;text-align:center;width:',\n          this.plotWidth, 'px;\" class=\"flotr-subtitle\">', options.subtitle, '</div>'\n        );\n\n      html.push('</div>');\n      \n      html.push('<div class=\"flotr-axis-title\" style=\"font-weight:bold;\">');\n      \n      // Add x axis title\n      if (a.x.options.title && a.x.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight + options.grid.labelMargin + a.x.titleSize.height), \n          'px;left:', this.plotOffset.left, 'px;width:', this.plotWidth, \n          'px;text-align:', a.x.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x1\">', a.x.options.title, '</div>'\n        );\n      \n      // Add x2 axis title\n      if (a.x2.options.title && a.x2.used)\n        html.push(\n          '<div style=\"position:absolute;top:0;left:', this.plotOffset.left, 'px;width:', \n          this.plotWidth, 'px;text-align:', a.x2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-x2\">', a.x2.options.title, '</div>'\n        );\n      \n      // Add y axis title\n      if (a.y.options.title && a.y.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;left:0;text-align:', a.y.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y1\">', a.y.options.title, '</div>'\n        );\n      \n      // Add y2 axis title\n      if (a.y2.options.title && a.y2.used)\n        html.push(\n          '<div style=\"position:absolute;top:', \n          (this.plotOffset.top + this.plotHeight/2 - a.y.titleSize.height/2), \n          'px;right:0;text-align:', a.y2.options.titleAlign, ';\" class=\"flotr-axis-title flotr-axis-title-y2\">', a.y2.options.title, '</div>'\n        );\n      \n      html = html.join('');\n\n      var div = D.create('div');\n      D.setStyles({\n        color: options.grid.color \n      });\n      div.className = 'flotr-titles';\n      D.insert(this.el, div);\n      D.insert(div, html);\n    }\n  }\n});\n})();\n"
  },
  {
    "path": "html/lib/flotr2/package.json",
    "content": "{\n  \"name\": \"flotr2\", \n  \"version\": \"0.1.0\",\n  \"description\": \"A library for drawing HTML5 charts and graphs.\",\n  \"homepage\": \"http://www.humblesoftware.com/flotr2\",\n\n  \"bugs\": {\n    \"url\": \"https://github.com/HumbleSoftware/Flotr2/issues\"\n  },\n\n  \"license\": \"MIT\",\n\n  \"author\": {\n    \"name\": \"Carl Sutherland\",\n    \"email\": \"carl@humblesoftware.com\",\n    \"url\": \"https://github.com/cesutherland\"\n  },\n\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/HumbleSoftware/Flotr2.git\"\n  },\n\n  \"devDependencies\": {\n    \"smoosh\": \"0.4.1\"\n  },\n\n  \"private\": true\n}\n"
  },
  {
    "path": "html/lib/font-awesome/css/font-awesome.css",
    "content": "/*!\n *  Font Awesome 4.6.1 by @davegandy - http://fontawesome.io - @fontawesome\n *  License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)\n */\n/* FONT PATH\n * -------------------------- */\n@font-face {\n  font-family: 'FontAwesome';\n  src: url('../fonts/fontawesome-webfont.eot?v=4.6.1');\n  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.1') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff2?v=4.6.1') format('woff2'), url('../fonts/fontawesome-webfont.woff?v=4.6.1') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.6.1') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.6.1#fontawesomeregular') format('svg');\n  font-weight: normal;\n  font-style: normal;\n}\n.fa {\n  display: inline-block;\n  font: normal normal normal 14px/1 FontAwesome;\n  font-size: inherit;\n  text-rendering: auto;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n/* makes the font 33% larger relative to the icon container */\n.fa-lg {\n  font-size: 1.33333333em;\n  line-height: 0.75em;\n  vertical-align: -15%;\n}\n.fa-2x {\n  font-size: 2em;\n}\n.fa-3x {\n  font-size: 3em;\n}\n.fa-4x {\n  font-size: 4em;\n}\n.fa-5x {\n  font-size: 5em;\n}\n.fa-fw {\n  width: 1.28571429em;\n  text-align: center;\n}\n.fa-ul {\n  padding-left: 0;\n  margin-left: 2.14285714em;\n  list-style-type: none;\n}\n.fa-ul > li {\n  position: relative;\n}\n.fa-li {\n  position: absolute;\n  left: -2.14285714em;\n  width: 2.14285714em;\n  top: 0.14285714em;\n  text-align: center;\n}\n.fa-li.fa-lg {\n  left: -1.85714286em;\n}\n.fa-border {\n  padding: .2em .25em .15em;\n  border: solid 0.08em #eeeeee;\n  border-radius: .1em;\n}\n.fa-pull-left {\n  float: left;\n}\n.fa-pull-right {\n  float: right;\n}\n.fa.fa-pull-left {\n  margin-right: .3em;\n}\n.fa.fa-pull-right {\n  margin-left: .3em;\n}\n/* Deprecated as of 4.4.0 */\n.pull-right {\n  float: right;\n}\n.pull-left {\n  float: left;\n}\n.fa.pull-left {\n  margin-right: .3em;\n}\n.fa.pull-right {\n  margin-left: .3em;\n}\n.fa-spin {\n  -webkit-animation: fa-spin 2s infinite linear;\n  animation: fa-spin 2s infinite linear;\n}\n.fa-pulse {\n  -webkit-animation: fa-spin 1s infinite steps(8);\n  animation: fa-spin 1s infinite steps(8);\n}\n@-webkit-keyframes fa-spin {\n  0% {\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n@keyframes fa-spin {\n  0% {\n    -webkit-transform: rotate(0deg);\n    transform: rotate(0deg);\n  }\n  100% {\n    -webkit-transform: rotate(359deg);\n    transform: rotate(359deg);\n  }\n}\n.fa-rotate-90 {\n  -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)\";\n  -webkit-transform: rotate(90deg);\n  -ms-transform: rotate(90deg);\n  transform: rotate(90deg);\n}\n.fa-rotate-180 {\n  -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)\";\n  -webkit-transform: rotate(180deg);\n  -ms-transform: rotate(180deg);\n  transform: rotate(180deg);\n}\n.fa-rotate-270 {\n  -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)\";\n  -webkit-transform: rotate(270deg);\n  -ms-transform: rotate(270deg);\n  transform: rotate(270deg);\n}\n.fa-flip-horizontal {\n  -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)\";\n  -webkit-transform: scale(-1, 1);\n  -ms-transform: scale(-1, 1);\n  transform: scale(-1, 1);\n}\n.fa-flip-vertical {\n  -ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)\";\n  -webkit-transform: scale(1, -1);\n  -ms-transform: scale(1, -1);\n  transform: scale(1, -1);\n}\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical {\n  filter: none;\n}\n.fa-stack {\n  position: relative;\n  display: inline-block;\n  width: 2em;\n  height: 2em;\n  line-height: 2em;\n  vertical-align: middle;\n}\n.fa-stack-1x,\n.fa-stack-2x {\n  position: absolute;\n  left: 0;\n  width: 100%;\n  text-align: center;\n}\n.fa-stack-1x {\n  line-height: inherit;\n}\n.fa-stack-2x {\n  font-size: 2em;\n}\n.fa-inverse {\n  color: #ffffff;\n}\n/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen\n   readers do not read off random characters that represent icons */\n.fa-glass:before {\n  content: \"\\f000\";\n}\n.fa-music:before {\n  content: \"\\f001\";\n}\n.fa-search:before {\n  content: \"\\f002\";\n}\n.fa-envelope-o:before {\n  content: \"\\f003\";\n}\n.fa-heart:before {\n  content: \"\\f004\";\n}\n.fa-star:before {\n  content: \"\\f005\";\n}\n.fa-star-o:before {\n  content: \"\\f006\";\n}\n.fa-user:before {\n  content: \"\\f007\";\n}\n.fa-film:before {\n  content: \"\\f008\";\n}\n.fa-th-large:before {\n  content: \"\\f009\";\n}\n.fa-th:before {\n  content: \"\\f00a\";\n}\n.fa-th-list:before {\n  content: \"\\f00b\";\n}\n.fa-check:before {\n  content: \"\\f00c\";\n}\n.fa-remove:before,\n.fa-close:before,\n.fa-times:before {\n  content: \"\\f00d\";\n}\n.fa-search-plus:before {\n  content: \"\\f00e\";\n}\n.fa-search-minus:before {\n  content: \"\\f010\";\n}\n.fa-power-off:before {\n  content: \"\\f011\";\n}\n.fa-signal:before {\n  content: \"\\f012\";\n}\n.fa-gear:before,\n.fa-cog:before {\n  content: \"\\f013\";\n}\n.fa-trash-o:before {\n  content: \"\\f014\";\n}\n.fa-home:before {\n  content: \"\\f015\";\n}\n.fa-file-o:before {\n  content: \"\\f016\";\n}\n.fa-clock-o:before {\n  content: \"\\f017\";\n}\n.fa-road:before {\n  content: \"\\f018\";\n}\n.fa-download:before {\n  content: \"\\f019\";\n}\n.fa-arrow-circle-o-down:before {\n  content: \"\\f01a\";\n}\n.fa-arrow-circle-o-up:before {\n  content: \"\\f01b\";\n}\n.fa-inbox:before {\n  content: \"\\f01c\";\n}\n.fa-play-circle-o:before {\n  content: \"\\f01d\";\n}\n.fa-rotate-right:before,\n.fa-repeat:before {\n  content: \"\\f01e\";\n}\n.fa-refresh:before {\n  content: \"\\f021\";\n}\n.fa-list-alt:before {\n  content: \"\\f022\";\n}\n.fa-lock:before {\n  content: \"\\f023\";\n}\n.fa-flag:before {\n  content: \"\\f024\";\n}\n.fa-headphones:before {\n  content: \"\\f025\";\n}\n.fa-volume-off:before {\n  content: \"\\f026\";\n}\n.fa-volume-down:before {\n  content: \"\\f027\";\n}\n.fa-volume-up:before {\n  content: \"\\f028\";\n}\n.fa-qrcode:before {\n  content: \"\\f029\";\n}\n.fa-barcode:before {\n  content: \"\\f02a\";\n}\n.fa-tag:before {\n  content: \"\\f02b\";\n}\n.fa-tags:before {\n  content: \"\\f02c\";\n}\n.fa-book:before {\n  content: \"\\f02d\";\n}\n.fa-bookmark:before {\n  content: \"\\f02e\";\n}\n.fa-print:before {\n  content: \"\\f02f\";\n}\n.fa-camera:before {\n  content: \"\\f030\";\n}\n.fa-font:before {\n  content: \"\\f031\";\n}\n.fa-bold:before {\n  content: \"\\f032\";\n}\n.fa-italic:before {\n  content: \"\\f033\";\n}\n.fa-text-height:before {\n  content: \"\\f034\";\n}\n.fa-text-width:before {\n  content: \"\\f035\";\n}\n.fa-align-left:before {\n  content: \"\\f036\";\n}\n.fa-align-center:before {\n  content: \"\\f037\";\n}\n.fa-align-right:before {\n  content: \"\\f038\";\n}\n.fa-align-justify:before {\n  content: \"\\f039\";\n}\n.fa-list:before {\n  content: \"\\f03a\";\n}\n.fa-dedent:before,\n.fa-outdent:before {\n  content: \"\\f03b\";\n}\n.fa-indent:before {\n  content: \"\\f03c\";\n}\n.fa-video-camera:before {\n  content: \"\\f03d\";\n}\n.fa-photo:before,\n.fa-image:before,\n.fa-picture-o:before {\n  content: \"\\f03e\";\n}\n.fa-pencil:before {\n  content: \"\\f040\";\n}\n.fa-map-marker:before {\n  content: \"\\f041\";\n}\n.fa-adjust:before {\n  content: \"\\f042\";\n}\n.fa-tint:before {\n  content: \"\\f043\";\n}\n.fa-edit:before,\n.fa-pencil-square-o:before {\n  content: \"\\f044\";\n}\n.fa-share-square-o:before {\n  content: \"\\f045\";\n}\n.fa-check-square-o:before {\n  content: \"\\f046\";\n}\n.fa-arrows:before {\n  content: \"\\f047\";\n}\n.fa-step-backward:before {\n  content: \"\\f048\";\n}\n.fa-fast-backward:before {\n  content: \"\\f049\";\n}\n.fa-backward:before {\n  content: \"\\f04a\";\n}\n.fa-play:before {\n  content: \"\\f04b\";\n}\n.fa-pause:before {\n  content: \"\\f04c\";\n}\n.fa-stop:before {\n  content: \"\\f04d\";\n}\n.fa-forward:before {\n  content: \"\\f04e\";\n}\n.fa-fast-forward:before {\n  content: \"\\f050\";\n}\n.fa-step-forward:before {\n  content: \"\\f051\";\n}\n.fa-eject:before {\n  content: \"\\f052\";\n}\n.fa-chevron-left:before {\n  content: \"\\f053\";\n}\n.fa-chevron-right:before {\n  content: \"\\f054\";\n}\n.fa-plus-circle:before {\n  content: \"\\f055\";\n}\n.fa-minus-circle:before {\n  content: \"\\f056\";\n}\n.fa-times-circle:before {\n  content: \"\\f057\";\n}\n.fa-check-circle:before {\n  content: \"\\f058\";\n}\n.fa-question-circle:before {\n  content: \"\\f059\";\n}\n.fa-info-circle:before {\n  content: \"\\f05a\";\n}\n.fa-crosshairs:before {\n  content: \"\\f05b\";\n}\n.fa-times-circle-o:before {\n  content: \"\\f05c\";\n}\n.fa-check-circle-o:before {\n  content: \"\\f05d\";\n}\n.fa-ban:before {\n  content: \"\\f05e\";\n}\n.fa-arrow-left:before {\n  content: \"\\f060\";\n}\n.fa-arrow-right:before {\n  content: \"\\f061\";\n}\n.fa-arrow-up:before {\n  content: \"\\f062\";\n}\n.fa-arrow-down:before {\n  content: \"\\f063\";\n}\n.fa-mail-forward:before,\n.fa-share:before {\n  content: \"\\f064\";\n}\n.fa-expand:before {\n  content: \"\\f065\";\n}\n.fa-compress:before {\n  content: \"\\f066\";\n}\n.fa-plus:before {\n  content: \"\\f067\";\n}\n.fa-minus:before {\n  content: \"\\f068\";\n}\n.fa-asterisk:before {\n  content: \"\\f069\";\n}\n.fa-exclamation-circle:before {\n  content: \"\\f06a\";\n}\n.fa-gift:before {\n  content: \"\\f06b\";\n}\n.fa-leaf:before {\n  content: \"\\f06c\";\n}\n.fa-fire:before {\n  content: \"\\f06d\";\n}\n.fa-eye:before {\n  content: \"\\f06e\";\n}\n.fa-eye-slash:before {\n  content: \"\\f070\";\n}\n.fa-warning:before,\n.fa-exclamation-triangle:before {\n  content: \"\\f071\";\n}\n.fa-plane:before {\n  content: \"\\f072\";\n}\n.fa-calendar:before {\n  content: \"\\f073\";\n}\n.fa-random:before {\n  content: \"\\f074\";\n}\n.fa-comment:before {\n  content: \"\\f075\";\n}\n.fa-magnet:before {\n  content: \"\\f076\";\n}\n.fa-chevron-up:before {\n  content: \"\\f077\";\n}\n.fa-chevron-down:before {\n  content: \"\\f078\";\n}\n.fa-retweet:before {\n  content: \"\\f079\";\n}\n.fa-shopping-cart:before {\n  content: \"\\f07a\";\n}\n.fa-folder:before {\n  content: \"\\f07b\";\n}\n.fa-folder-open:before {\n  content: \"\\f07c\";\n}\n.fa-arrows-v:before {\n  content: \"\\f07d\";\n}\n.fa-arrows-h:before {\n  content: \"\\f07e\";\n}\n.fa-bar-chart-o:before,\n.fa-bar-chart:before {\n  content: \"\\f080\";\n}\n.fa-twitter-square:before {\n  content: \"\\f081\";\n}\n.fa-facebook-square:before {\n  content: \"\\f082\";\n}\n.fa-camera-retro:before {\n  content: \"\\f083\";\n}\n.fa-key:before {\n  content: \"\\f084\";\n}\n.fa-gears:before,\n.fa-cogs:before {\n  content: \"\\f085\";\n}\n.fa-comments:before {\n  content: \"\\f086\";\n}\n.fa-thumbs-o-up:before {\n  content: \"\\f087\";\n}\n.fa-thumbs-o-down:before {\n  content: \"\\f088\";\n}\n.fa-star-half:before {\n  content: \"\\f089\";\n}\n.fa-heart-o:before {\n  content: \"\\f08a\";\n}\n.fa-sign-out:before {\n  content: \"\\f08b\";\n}\n.fa-linkedin-square:before {\n  content: \"\\f08c\";\n}\n.fa-thumb-tack:before {\n  content: \"\\f08d\";\n}\n.fa-external-link:before {\n  content: \"\\f08e\";\n}\n.fa-sign-in:before {\n  content: \"\\f090\";\n}\n.fa-trophy:before {\n  content: \"\\f091\";\n}\n.fa-github-square:before {\n  content: \"\\f092\";\n}\n.fa-upload:before {\n  content: \"\\f093\";\n}\n.fa-lemon-o:before {\n  content: \"\\f094\";\n}\n.fa-phone:before {\n  content: \"\\f095\";\n}\n.fa-square-o:before {\n  content: \"\\f096\";\n}\n.fa-bookmark-o:before {\n  content: \"\\f097\";\n}\n.fa-phone-square:before {\n  content: \"\\f098\";\n}\n.fa-twitter:before {\n  content: \"\\f099\";\n}\n.fa-facebook-f:before,\n.fa-facebook:before {\n  content: \"\\f09a\";\n}\n.fa-github:before {\n  content: \"\\f09b\";\n}\n.fa-unlock:before {\n  content: \"\\f09c\";\n}\n.fa-credit-card:before {\n  content: \"\\f09d\";\n}\n.fa-feed:before,\n.fa-rss:before {\n  content: \"\\f09e\";\n}\n.fa-hdd-o:before {\n  content: \"\\f0a0\";\n}\n.fa-bullhorn:before {\n  content: \"\\f0a1\";\n}\n.fa-bell:before {\n  content: \"\\f0f3\";\n}\n.fa-certificate:before {\n  content: \"\\f0a3\";\n}\n.fa-hand-o-right:before {\n  content: \"\\f0a4\";\n}\n.fa-hand-o-left:before {\n  content: \"\\f0a5\";\n}\n.fa-hand-o-up:before {\n  content: \"\\f0a6\";\n}\n.fa-hand-o-down:before {\n  content: \"\\f0a7\";\n}\n.fa-arrow-circle-left:before {\n  content: \"\\f0a8\";\n}\n.fa-arrow-circle-right:before {\n  content: \"\\f0a9\";\n}\n.fa-arrow-circle-up:before {\n  content: \"\\f0aa\";\n}\n.fa-arrow-circle-down:before {\n  content: \"\\f0ab\";\n}\n.fa-globe:before {\n  content: \"\\f0ac\";\n}\n.fa-wrench:before {\n  content: \"\\f0ad\";\n}\n.fa-tasks:before {\n  content: \"\\f0ae\";\n}\n.fa-filter:before {\n  content: \"\\f0b0\";\n}\n.fa-briefcase:before {\n  content: \"\\f0b1\";\n}\n.fa-arrows-alt:before {\n  content: \"\\f0b2\";\n}\n.fa-group:before,\n.fa-users:before {\n  content: \"\\f0c0\";\n}\n.fa-chain:before,\n.fa-link:before {\n  content: \"\\f0c1\";\n}\n.fa-cloud:before {\n  content: \"\\f0c2\";\n}\n.fa-flask:before {\n  content: \"\\f0c3\";\n}\n.fa-cut:before,\n.fa-scissors:before {\n  content: \"\\f0c4\";\n}\n.fa-copy:before,\n.fa-files-o:before {\n  content: \"\\f0c5\";\n}\n.fa-paperclip:before {\n  content: \"\\f0c6\";\n}\n.fa-save:before,\n.fa-floppy-o:before {\n  content: \"\\f0c7\";\n}\n.fa-square:before {\n  content: \"\\f0c8\";\n}\n.fa-navicon:before,\n.fa-reorder:before,\n.fa-bars:before {\n  content: \"\\f0c9\";\n}\n.fa-list-ul:before {\n  content: \"\\f0ca\";\n}\n.fa-list-ol:before {\n  content: \"\\f0cb\";\n}\n.fa-strikethrough:before {\n  content: \"\\f0cc\";\n}\n.fa-underline:before {\n  content: \"\\f0cd\";\n}\n.fa-table:before {\n  content: \"\\f0ce\";\n}\n.fa-magic:before {\n  content: \"\\f0d0\";\n}\n.fa-truck:before {\n  content: \"\\f0d1\";\n}\n.fa-pinterest:before {\n  content: \"\\f0d2\";\n}\n.fa-pinterest-square:before {\n  content: \"\\f0d3\";\n}\n.fa-google-plus-square:before {\n  content: \"\\f0d4\";\n}\n.fa-google-plus:before {\n  content: \"\\f0d5\";\n}\n.fa-money:before {\n  content: \"\\f0d6\";\n}\n.fa-caret-down:before {\n  content: \"\\f0d7\";\n}\n.fa-caret-up:before {\n  content: \"\\f0d8\";\n}\n.fa-caret-left:before {\n  content: \"\\f0d9\";\n}\n.fa-caret-right:before {\n  content: \"\\f0da\";\n}\n.fa-columns:before {\n  content: \"\\f0db\";\n}\n.fa-unsorted:before,\n.fa-sort:before {\n  content: \"\\f0dc\";\n}\n.fa-sort-down:before,\n.fa-sort-desc:before {\n  content: \"\\f0dd\";\n}\n.fa-sort-up:before,\n.fa-sort-asc:before {\n  content: \"\\f0de\";\n}\n.fa-envelope:before {\n  content: \"\\f0e0\";\n}\n.fa-linkedin:before {\n  content: \"\\f0e1\";\n}\n.fa-rotate-left:before,\n.fa-undo:before {\n  content: \"\\f0e2\";\n}\n.fa-legal:before,\n.fa-gavel:before {\n  content: \"\\f0e3\";\n}\n.fa-dashboard:before,\n.fa-tachometer:before {\n  content: \"\\f0e4\";\n}\n.fa-comment-o:before {\n  content: \"\\f0e5\";\n}\n.fa-comments-o:before {\n  content: \"\\f0e6\";\n}\n.fa-flash:before,\n.fa-bolt:before {\n  content: \"\\f0e7\";\n}\n.fa-sitemap:before {\n  content: \"\\f0e8\";\n}\n.fa-umbrella:before {\n  content: \"\\f0e9\";\n}\n.fa-paste:before,\n.fa-clipboard:before {\n  content: \"\\f0ea\";\n}\n.fa-lightbulb-o:before {\n  content: \"\\f0eb\";\n}\n.fa-exchange:before {\n  content: \"\\f0ec\";\n}\n.fa-cloud-download:before {\n  content: \"\\f0ed\";\n}\n.fa-cloud-upload:before {\n  content: \"\\f0ee\";\n}\n.fa-user-md:before {\n  content: \"\\f0f0\";\n}\n.fa-stethoscope:before {\n  content: \"\\f0f1\";\n}\n.fa-suitcase:before {\n  content: \"\\f0f2\";\n}\n.fa-bell-o:before {\n  content: \"\\f0a2\";\n}\n.fa-coffee:before {\n  content: \"\\f0f4\";\n}\n.fa-cutlery:before {\n  content: \"\\f0f5\";\n}\n.fa-file-text-o:before {\n  content: \"\\f0f6\";\n}\n.fa-building-o:before {\n  content: \"\\f0f7\";\n}\n.fa-hospital-o:before {\n  content: \"\\f0f8\";\n}\n.fa-ambulance:before {\n  content: \"\\f0f9\";\n}\n.fa-medkit:before {\n  content: \"\\f0fa\";\n}\n.fa-fighter-jet:before {\n  content: \"\\f0fb\";\n}\n.fa-beer:before {\n  content: \"\\f0fc\";\n}\n.fa-h-square:before {\n  content: \"\\f0fd\";\n}\n.fa-plus-square:before {\n  content: \"\\f0fe\";\n}\n.fa-angle-double-left:before {\n  content: \"\\f100\";\n}\n.fa-angle-double-right:before {\n  content: \"\\f101\";\n}\n.fa-angle-double-up:before {\n  content: \"\\f102\";\n}\n.fa-angle-double-down:before {\n  content: \"\\f103\";\n}\n.fa-angle-left:before {\n  content: \"\\f104\";\n}\n.fa-angle-right:before {\n  content: \"\\f105\";\n}\n.fa-angle-up:before {\n  content: \"\\f106\";\n}\n.fa-angle-down:before {\n  content: \"\\f107\";\n}\n.fa-desktop:before {\n  content: \"\\f108\";\n}\n.fa-laptop:before {\n  content: \"\\f109\";\n}\n.fa-tablet:before {\n  content: \"\\f10a\";\n}\n.fa-mobile-phone:before,\n.fa-mobile:before {\n  content: \"\\f10b\";\n}\n.fa-circle-o:before {\n  content: \"\\f10c\";\n}\n.fa-quote-left:before {\n  content: \"\\f10d\";\n}\n.fa-quote-right:before {\n  content: \"\\f10e\";\n}\n.fa-spinner:before {\n  content: \"\\f110\";\n}\n.fa-circle:before {\n  content: \"\\f111\";\n}\n.fa-mail-reply:before,\n.fa-reply:before {\n  content: \"\\f112\";\n}\n.fa-github-alt:before {\n  content: \"\\f113\";\n}\n.fa-folder-o:before {\n  content: \"\\f114\";\n}\n.fa-folder-open-o:before {\n  content: \"\\f115\";\n}\n.fa-smile-o:before {\n  content: \"\\f118\";\n}\n.fa-frown-o:before {\n  content: \"\\f119\";\n}\n.fa-meh-o:before {\n  content: \"\\f11a\";\n}\n.fa-gamepad:before {\n  content: \"\\f11b\";\n}\n.fa-keyboard-o:before {\n  content: \"\\f11c\";\n}\n.fa-flag-o:before {\n  content: \"\\f11d\";\n}\n.fa-flag-checkered:before {\n  content: \"\\f11e\";\n}\n.fa-terminal:before {\n  content: \"\\f120\";\n}\n.fa-code:before {\n  content: \"\\f121\";\n}\n.fa-mail-reply-all:before,\n.fa-reply-all:before {\n  content: \"\\f122\";\n}\n.fa-star-half-empty:before,\n.fa-star-half-full:before,\n.fa-star-half-o:before {\n  content: \"\\f123\";\n}\n.fa-location-arrow:before {\n  content: \"\\f124\";\n}\n.fa-crop:before {\n  content: \"\\f125\";\n}\n.fa-code-fork:before {\n  content: \"\\f126\";\n}\n.fa-unlink:before,\n.fa-chain-broken:before {\n  content: \"\\f127\";\n}\n.fa-question:before {\n  content: \"\\f128\";\n}\n.fa-info:before {\n  content: \"\\f129\";\n}\n.fa-exclamation:before {\n  content: \"\\f12a\";\n}\n.fa-superscript:before {\n  content: \"\\f12b\";\n}\n.fa-subscript:before {\n  content: \"\\f12c\";\n}\n.fa-eraser:before {\n  content: \"\\f12d\";\n}\n.fa-puzzle-piece:before {\n  content: \"\\f12e\";\n}\n.fa-microphone:before {\n  content: \"\\f130\";\n}\n.fa-microphone-slash:before {\n  content: \"\\f131\";\n}\n.fa-shield:before {\n  content: \"\\f132\";\n}\n.fa-calendar-o:before {\n  content: \"\\f133\";\n}\n.fa-fire-extinguisher:before {\n  content: \"\\f134\";\n}\n.fa-rocket:before {\n  content: \"\\f135\";\n}\n.fa-maxcdn:before {\n  content: \"\\f136\";\n}\n.fa-chevron-circle-left:before {\n  content: \"\\f137\";\n}\n.fa-chevron-circle-right:before {\n  content: \"\\f138\";\n}\n.fa-chevron-circle-up:before {\n  content: \"\\f139\";\n}\n.fa-chevron-circle-down:before {\n  content: \"\\f13a\";\n}\n.fa-html5:before {\n  content: \"\\f13b\";\n}\n.fa-css3:before {\n  content: \"\\f13c\";\n}\n.fa-anchor:before {\n  content: \"\\f13d\";\n}\n.fa-unlock-alt:before {\n  content: \"\\f13e\";\n}\n.fa-bullseye:before {\n  content: \"\\f140\";\n}\n.fa-ellipsis-h:before {\n  content: \"\\f141\";\n}\n.fa-ellipsis-v:before {\n  content: \"\\f142\";\n}\n.fa-rss-square:before {\n  content: \"\\f143\";\n}\n.fa-play-circle:before {\n  content: \"\\f144\";\n}\n.fa-ticket:before {\n  content: \"\\f145\";\n}\n.fa-minus-square:before {\n  content: \"\\f146\";\n}\n.fa-minus-square-o:before {\n  content: \"\\f147\";\n}\n.fa-level-up:before {\n  content: \"\\f148\";\n}\n.fa-level-down:before {\n  content: \"\\f149\";\n}\n.fa-check-square:before {\n  content: \"\\f14a\";\n}\n.fa-pencil-square:before {\n  content: \"\\f14b\";\n}\n.fa-external-link-square:before {\n  content: \"\\f14c\";\n}\n.fa-share-square:before {\n  content: \"\\f14d\";\n}\n.fa-compass:before {\n  content: \"\\f14e\";\n}\n.fa-toggle-down:before,\n.fa-caret-square-o-down:before {\n  content: \"\\f150\";\n}\n.fa-toggle-up:before,\n.fa-caret-square-o-up:before {\n  content: \"\\f151\";\n}\n.fa-toggle-right:before,\n.fa-caret-square-o-right:before {\n  content: \"\\f152\";\n}\n.fa-euro:before,\n.fa-eur:before {\n  content: \"\\f153\";\n}\n.fa-gbp:before {\n  content: \"\\f154\";\n}\n.fa-dollar:before,\n.fa-usd:before {\n  content: \"\\f155\";\n}\n.fa-rupee:before,\n.fa-inr:before {\n  content: \"\\f156\";\n}\n.fa-cny:before,\n.fa-rmb:before,\n.fa-yen:before,\n.fa-jpy:before {\n  content: \"\\f157\";\n}\n.fa-ruble:before,\n.fa-rouble:before,\n.fa-rub:before {\n  content: \"\\f158\";\n}\n.fa-won:before,\n.fa-krw:before {\n  content: \"\\f159\";\n}\n.fa-bitcoin:before,\n.fa-btc:before {\n  content: \"\\f15a\";\n}\n.fa-file:before {\n  content: \"\\f15b\";\n}\n.fa-file-text:before {\n  content: \"\\f15c\";\n}\n.fa-sort-alpha-asc:before {\n  content: \"\\f15d\";\n}\n.fa-sort-alpha-desc:before {\n  content: \"\\f15e\";\n}\n.fa-sort-amount-asc:before {\n  content: \"\\f160\";\n}\n.fa-sort-amount-desc:before {\n  content: \"\\f161\";\n}\n.fa-sort-numeric-asc:before {\n  content: \"\\f162\";\n}\n.fa-sort-numeric-desc:before {\n  content: \"\\f163\";\n}\n.fa-thumbs-up:before {\n  content: \"\\f164\";\n}\n.fa-thumbs-down:before {\n  content: \"\\f165\";\n}\n.fa-youtube-square:before {\n  content: \"\\f166\";\n}\n.fa-youtube:before {\n  content: \"\\f167\";\n}\n.fa-xing:before {\n  content: \"\\f168\";\n}\n.fa-xing-square:before {\n  content: \"\\f169\";\n}\n.fa-youtube-play:before {\n  content: \"\\f16a\";\n}\n.fa-dropbox:before {\n  content: \"\\f16b\";\n}\n.fa-stack-overflow:before {\n  content: \"\\f16c\";\n}\n.fa-instagram:before {\n  content: \"\\f16d\";\n}\n.fa-flickr:before {\n  content: \"\\f16e\";\n}\n.fa-adn:before {\n  content: \"\\f170\";\n}\n.fa-bitbucket:before {\n  content: \"\\f171\";\n}\n.fa-bitbucket-square:before {\n  content: \"\\f172\";\n}\n.fa-tumblr:before {\n  content: \"\\f173\";\n}\n.fa-tumblr-square:before {\n  content: \"\\f174\";\n}\n.fa-long-arrow-down:before {\n  content: \"\\f175\";\n}\n.fa-long-arrow-up:before {\n  content: \"\\f176\";\n}\n.fa-long-arrow-left:before {\n  content: \"\\f177\";\n}\n.fa-long-arrow-right:before {\n  content: \"\\f178\";\n}\n.fa-apple:before {\n  content: \"\\f179\";\n}\n.fa-windows:before {\n  content: \"\\f17a\";\n}\n.fa-android:before {\n  content: \"\\f17b\";\n}\n.fa-linux:before {\n  content: \"\\f17c\";\n}\n.fa-dribbble:before {\n  content: \"\\f17d\";\n}\n.fa-skype:before {\n  content: \"\\f17e\";\n}\n.fa-foursquare:before {\n  content: \"\\f180\";\n}\n.fa-trello:before {\n  content: \"\\f181\";\n}\n.fa-female:before {\n  content: \"\\f182\";\n}\n.fa-male:before {\n  content: \"\\f183\";\n}\n.fa-gittip:before,\n.fa-gratipay:before {\n  content: \"\\f184\";\n}\n.fa-sun-o:before {\n  content: \"\\f185\";\n}\n.fa-moon-o:before {\n  content: \"\\f186\";\n}\n.fa-archive:before {\n  content: \"\\f187\";\n}\n.fa-bug:before {\n  content: \"\\f188\";\n}\n.fa-vk:before {\n  content: \"\\f189\";\n}\n.fa-weibo:before {\n  content: \"\\f18a\";\n}\n.fa-renren:before {\n  content: \"\\f18b\";\n}\n.fa-pagelines:before {\n  content: \"\\f18c\";\n}\n.fa-stack-exchange:before {\n  content: \"\\f18d\";\n}\n.fa-arrow-circle-o-right:before {\n  content: \"\\f18e\";\n}\n.fa-arrow-circle-o-left:before {\n  content: \"\\f190\";\n}\n.fa-toggle-left:before,\n.fa-caret-square-o-left:before {\n  content: \"\\f191\";\n}\n.fa-dot-circle-o:before {\n  content: \"\\f192\";\n}\n.fa-wheelchair:before {\n  content: \"\\f193\";\n}\n.fa-vimeo-square:before {\n  content: \"\\f194\";\n}\n.fa-turkish-lira:before,\n.fa-try:before {\n  content: \"\\f195\";\n}\n.fa-plus-square-o:before {\n  content: \"\\f196\";\n}\n.fa-space-shuttle:before {\n  content: \"\\f197\";\n}\n.fa-slack:before {\n  content: \"\\f198\";\n}\n.fa-envelope-square:before {\n  content: \"\\f199\";\n}\n.fa-wordpress:before {\n  content: \"\\f19a\";\n}\n.fa-openid:before {\n  content: \"\\f19b\";\n}\n.fa-institution:before,\n.fa-bank:before,\n.fa-university:before {\n  content: \"\\f19c\";\n}\n.fa-mortar-board:before,\n.fa-graduation-cap:before {\n  content: \"\\f19d\";\n}\n.fa-yahoo:before {\n  content: \"\\f19e\";\n}\n.fa-google:before {\n  content: \"\\f1a0\";\n}\n.fa-reddit:before {\n  content: \"\\f1a1\";\n}\n.fa-reddit-square:before {\n  content: \"\\f1a2\";\n}\n.fa-stumbleupon-circle:before {\n  content: \"\\f1a3\";\n}\n.fa-stumbleupon:before {\n  content: \"\\f1a4\";\n}\n.fa-delicious:before {\n  content: \"\\f1a5\";\n}\n.fa-digg:before {\n  content: \"\\f1a6\";\n}\n.fa-pied-piper:before {\n  content: \"\\f1a7\";\n}\n.fa-pied-piper-alt:before {\n  content: \"\\f1a8\";\n}\n.fa-drupal:before {\n  content: \"\\f1a9\";\n}\n.fa-joomla:before {\n  content: \"\\f1aa\";\n}\n.fa-language:before {\n  content: \"\\f1ab\";\n}\n.fa-fax:before {\n  content: \"\\f1ac\";\n}\n.fa-building:before {\n  content: \"\\f1ad\";\n}\n.fa-child:before {\n  content: \"\\f1ae\";\n}\n.fa-paw:before {\n  content: \"\\f1b0\";\n}\n.fa-spoon:before {\n  content: \"\\f1b1\";\n}\n.fa-cube:before {\n  content: \"\\f1b2\";\n}\n.fa-cubes:before {\n  content: \"\\f1b3\";\n}\n.fa-behance:before {\n  content: \"\\f1b4\";\n}\n.fa-behance-square:before {\n  content: \"\\f1b5\";\n}\n.fa-steam:before {\n  content: \"\\f1b6\";\n}\n.fa-steam-square:before {\n  content: \"\\f1b7\";\n}\n.fa-recycle:before {\n  content: \"\\f1b8\";\n}\n.fa-automobile:before,\n.fa-car:before {\n  content: \"\\f1b9\";\n}\n.fa-cab:before,\n.fa-taxi:before {\n  content: \"\\f1ba\";\n}\n.fa-tree:before {\n  content: \"\\f1bb\";\n}\n.fa-spotify:before {\n  content: \"\\f1bc\";\n}\n.fa-deviantart:before {\n  content: \"\\f1bd\";\n}\n.fa-soundcloud:before {\n  content: \"\\f1be\";\n}\n.fa-database:before {\n  content: \"\\f1c0\";\n}\n.fa-file-pdf-o:before {\n  content: \"\\f1c1\";\n}\n.fa-file-word-o:before {\n  content: \"\\f1c2\";\n}\n.fa-file-excel-o:before {\n  content: \"\\f1c3\";\n}\n.fa-file-powerpoint-o:before {\n  content: \"\\f1c4\";\n}\n.fa-file-photo-o:before,\n.fa-file-picture-o:before,\n.fa-file-image-o:before {\n  content: \"\\f1c5\";\n}\n.fa-file-zip-o:before,\n.fa-file-archive-o:before {\n  content: \"\\f1c6\";\n}\n.fa-file-sound-o:before,\n.fa-file-audio-o:before {\n  content: \"\\f1c7\";\n}\n.fa-file-movie-o:before,\n.fa-file-video-o:before {\n  content: \"\\f1c8\";\n}\n.fa-file-code-o:before {\n  content: \"\\f1c9\";\n}\n.fa-vine:before {\n  content: \"\\f1ca\";\n}\n.fa-codepen:before {\n  content: \"\\f1cb\";\n}\n.fa-jsfiddle:before {\n  content: \"\\f1cc\";\n}\n.fa-life-bouy:before,\n.fa-life-buoy:before,\n.fa-life-saver:before,\n.fa-support:before,\n.fa-life-ring:before {\n  content: \"\\f1cd\";\n}\n.fa-circle-o-notch:before {\n  content: \"\\f1ce\";\n}\n.fa-ra:before,\n.fa-rebel:before {\n  content: \"\\f1d0\";\n}\n.fa-ge:before,\n.fa-empire:before {\n  content: \"\\f1d1\";\n}\n.fa-git-square:before {\n  content: \"\\f1d2\";\n}\n.fa-git:before {\n  content: \"\\f1d3\";\n}\n.fa-y-combinator-square:before,\n.fa-yc-square:before,\n.fa-hacker-news:before {\n  content: \"\\f1d4\";\n}\n.fa-tencent-weibo:before {\n  content: \"\\f1d5\";\n}\n.fa-qq:before {\n  content: \"\\f1d6\";\n}\n.fa-wechat:before,\n.fa-weixin:before {\n  content: \"\\f1d7\";\n}\n.fa-send:before,\n.fa-paper-plane:before {\n  content: \"\\f1d8\";\n}\n.fa-send-o:before,\n.fa-paper-plane-o:before {\n  content: \"\\f1d9\";\n}\n.fa-history:before {\n  content: \"\\f1da\";\n}\n.fa-circle-thin:before {\n  content: \"\\f1db\";\n}\n.fa-header:before {\n  content: \"\\f1dc\";\n}\n.fa-paragraph:before {\n  content: \"\\f1dd\";\n}\n.fa-sliders:before {\n  content: \"\\f1de\";\n}\n.fa-share-alt:before {\n  content: \"\\f1e0\";\n}\n.fa-share-alt-square:before {\n  content: \"\\f1e1\";\n}\n.fa-bomb:before {\n  content: \"\\f1e2\";\n}\n.fa-soccer-ball-o:before,\n.fa-futbol-o:before {\n  content: \"\\f1e3\";\n}\n.fa-tty:before {\n  content: \"\\f1e4\";\n}\n.fa-binoculars:before {\n  content: \"\\f1e5\";\n}\n.fa-plug:before {\n  content: \"\\f1e6\";\n}\n.fa-slideshare:before {\n  content: \"\\f1e7\";\n}\n.fa-twitch:before {\n  content: \"\\f1e8\";\n}\n.fa-yelp:before {\n  content: \"\\f1e9\";\n}\n.fa-newspaper-o:before {\n  content: \"\\f1ea\";\n}\n.fa-wifi:before {\n  content: \"\\f1eb\";\n}\n.fa-calculator:before {\n  content: \"\\f1ec\";\n}\n.fa-paypal:before {\n  content: \"\\f1ed\";\n}\n.fa-google-wallet:before {\n  content: \"\\f1ee\";\n}\n.fa-cc-visa:before {\n  content: \"\\f1f0\";\n}\n.fa-cc-mastercard:before {\n  content: \"\\f1f1\";\n}\n.fa-cc-discover:before {\n  content: \"\\f1f2\";\n}\n.fa-cc-amex:before {\n  content: \"\\f1f3\";\n}\n.fa-cc-paypal:before {\n  content: \"\\f1f4\";\n}\n.fa-cc-stripe:before {\n  content: \"\\f1f5\";\n}\n.fa-bell-slash:before {\n  content: \"\\f1f6\";\n}\n.fa-bell-slash-o:before {\n  content: \"\\f1f7\";\n}\n.fa-trash:before {\n  content: \"\\f1f8\";\n}\n.fa-copyright:before {\n  content: \"\\f1f9\";\n}\n.fa-at:before {\n  content: \"\\f1fa\";\n}\n.fa-eyedropper:before {\n  content: \"\\f1fb\";\n}\n.fa-paint-brush:before {\n  content: \"\\f1fc\";\n}\n.fa-birthday-cake:before {\n  content: \"\\f1fd\";\n}\n.fa-area-chart:before {\n  content: \"\\f1fe\";\n}\n.fa-pie-chart:before {\n  content: \"\\f200\";\n}\n.fa-line-chart:before {\n  content: \"\\f201\";\n}\n.fa-lastfm:before {\n  content: \"\\f202\";\n}\n.fa-lastfm-square:before {\n  content: \"\\f203\";\n}\n.fa-toggle-off:before {\n  content: \"\\f204\";\n}\n.fa-toggle-on:before {\n  content: \"\\f205\";\n}\n.fa-bicycle:before {\n  content: \"\\f206\";\n}\n.fa-bus:before {\n  content: \"\\f207\";\n}\n.fa-ioxhost:before {\n  content: \"\\f208\";\n}\n.fa-angellist:before {\n  content: \"\\f209\";\n}\n.fa-cc:before {\n  content: \"\\f20a\";\n}\n.fa-shekel:before,\n.fa-sheqel:before,\n.fa-ils:before {\n  content: \"\\f20b\";\n}\n.fa-meanpath:before {\n  content: \"\\f20c\";\n}\n.fa-buysellads:before {\n  content: \"\\f20d\";\n}\n.fa-connectdevelop:before {\n  content: \"\\f20e\";\n}\n.fa-dashcube:before {\n  content: \"\\f210\";\n}\n.fa-forumbee:before {\n  content: \"\\f211\";\n}\n.fa-leanpub:before {\n  content: \"\\f212\";\n}\n.fa-sellsy:before {\n  content: \"\\f213\";\n}\n.fa-shirtsinbulk:before {\n  content: \"\\f214\";\n}\n.fa-simplybuilt:before {\n  content: \"\\f215\";\n}\n.fa-skyatlas:before {\n  content: \"\\f216\";\n}\n.fa-cart-plus:before {\n  content: \"\\f217\";\n}\n.fa-cart-arrow-down:before {\n  content: \"\\f218\";\n}\n.fa-diamond:before {\n  content: \"\\f219\";\n}\n.fa-ship:before {\n  content: \"\\f21a\";\n}\n.fa-user-secret:before {\n  content: \"\\f21b\";\n}\n.fa-motorcycle:before {\n  content: \"\\f21c\";\n}\n.fa-street-view:before {\n  content: \"\\f21d\";\n}\n.fa-heartbeat:before {\n  content: \"\\f21e\";\n}\n.fa-venus:before {\n  content: \"\\f221\";\n}\n.fa-mars:before {\n  content: \"\\f222\";\n}\n.fa-mercury:before {\n  content: \"\\f223\";\n}\n.fa-intersex:before,\n.fa-transgender:before {\n  content: \"\\f224\";\n}\n.fa-transgender-alt:before {\n  content: \"\\f225\";\n}\n.fa-venus-double:before {\n  content: \"\\f226\";\n}\n.fa-mars-double:before {\n  content: \"\\f227\";\n}\n.fa-venus-mars:before {\n  content: \"\\f228\";\n}\n.fa-mars-stroke:before {\n  content: \"\\f229\";\n}\n.fa-mars-stroke-v:before {\n  content: \"\\f22a\";\n}\n.fa-mars-stroke-h:before {\n  content: \"\\f22b\";\n}\n.fa-neuter:before {\n  content: \"\\f22c\";\n}\n.fa-genderless:before {\n  content: \"\\f22d\";\n}\n.fa-facebook-official:before {\n  content: \"\\f230\";\n}\n.fa-pinterest-p:before {\n  content: \"\\f231\";\n}\n.fa-whatsapp:before {\n  content: \"\\f232\";\n}\n.fa-server:before {\n  content: \"\\f233\";\n}\n.fa-user-plus:before {\n  content: \"\\f234\";\n}\n.fa-user-times:before {\n  content: \"\\f235\";\n}\n.fa-hotel:before,\n.fa-bed:before {\n  content: \"\\f236\";\n}\n.fa-viacoin:before {\n  content: \"\\f237\";\n}\n.fa-train:before {\n  content: \"\\f238\";\n}\n.fa-subway:before {\n  content: \"\\f239\";\n}\n.fa-medium:before {\n  content: \"\\f23a\";\n}\n.fa-yc:before,\n.fa-y-combinator:before {\n  content: \"\\f23b\";\n}\n.fa-optin-monster:before {\n  content: \"\\f23c\";\n}\n.fa-opencart:before {\n  content: \"\\f23d\";\n}\n.fa-expeditedssl:before {\n  content: \"\\f23e\";\n}\n.fa-battery-4:before,\n.fa-battery-full:before {\n  content: \"\\f240\";\n}\n.fa-battery-3:before,\n.fa-battery-three-quarters:before {\n  content: \"\\f241\";\n}\n.fa-battery-2:before,\n.fa-battery-half:before {\n  content: \"\\f242\";\n}\n.fa-battery-1:before,\n.fa-battery-quarter:before {\n  content: \"\\f243\";\n}\n.fa-battery-0:before,\n.fa-battery-empty:before {\n  content: \"\\f244\";\n}\n.fa-mouse-pointer:before {\n  content: \"\\f245\";\n}\n.fa-i-cursor:before {\n  content: \"\\f246\";\n}\n.fa-object-group:before {\n  content: \"\\f247\";\n}\n.fa-object-ungroup:before {\n  content: \"\\f248\";\n}\n.fa-sticky-note:before {\n  content: \"\\f249\";\n}\n.fa-sticky-note-o:before {\n  content: \"\\f24a\";\n}\n.fa-cc-jcb:before {\n  content: \"\\f24b\";\n}\n.fa-cc-diners-club:before {\n  content: \"\\f24c\";\n}\n.fa-clone:before {\n  content: \"\\f24d\";\n}\n.fa-balance-scale:before {\n  content: \"\\f24e\";\n}\n.fa-hourglass-o:before {\n  content: \"\\f250\";\n}\n.fa-hourglass-1:before,\n.fa-hourglass-start:before {\n  content: \"\\f251\";\n}\n.fa-hourglass-2:before,\n.fa-hourglass-half:before {\n  content: \"\\f252\";\n}\n.fa-hourglass-3:before,\n.fa-hourglass-end:before {\n  content: \"\\f253\";\n}\n.fa-hourglass:before {\n  content: \"\\f254\";\n}\n.fa-hand-grab-o:before,\n.fa-hand-rock-o:before {\n  content: \"\\f255\";\n}\n.fa-hand-stop-o:before,\n.fa-hand-paper-o:before {\n  content: \"\\f256\";\n}\n.fa-hand-scissors-o:before {\n  content: \"\\f257\";\n}\n.fa-hand-lizard-o:before {\n  content: \"\\f258\";\n}\n.fa-hand-spock-o:before {\n  content: \"\\f259\";\n}\n.fa-hand-pointer-o:before {\n  content: \"\\f25a\";\n}\n.fa-hand-peace-o:before {\n  content: \"\\f25b\";\n}\n.fa-trademark:before {\n  content: \"\\f25c\";\n}\n.fa-registered:before {\n  content: \"\\f25d\";\n}\n.fa-creative-commons:before {\n  content: \"\\f25e\";\n}\n.fa-gg:before {\n  content: \"\\f260\";\n}\n.fa-gg-circle:before {\n  content: \"\\f261\";\n}\n.fa-tripadvisor:before {\n  content: \"\\f262\";\n}\n.fa-odnoklassniki:before {\n  content: \"\\f263\";\n}\n.fa-odnoklassniki-square:before {\n  content: \"\\f264\";\n}\n.fa-get-pocket:before {\n  content: \"\\f265\";\n}\n.fa-wikipedia-w:before {\n  content: \"\\f266\";\n}\n.fa-safari:before {\n  content: \"\\f267\";\n}\n.fa-chrome:before {\n  content: \"\\f268\";\n}\n.fa-firefox:before {\n  content: \"\\f269\";\n}\n.fa-opera:before {\n  content: \"\\f26a\";\n}\n.fa-internet-explorer:before {\n  content: \"\\f26b\";\n}\n.fa-tv:before,\n.fa-television:before {\n  content: \"\\f26c\";\n}\n.fa-contao:before {\n  content: \"\\f26d\";\n}\n.fa-500px:before {\n  content: \"\\f26e\";\n}\n.fa-amazon:before {\n  content: \"\\f270\";\n}\n.fa-calendar-plus-o:before {\n  content: \"\\f271\";\n}\n.fa-calendar-minus-o:before {\n  content: \"\\f272\";\n}\n.fa-calendar-times-o:before {\n  content: \"\\f273\";\n}\n.fa-calendar-check-o:before {\n  content: \"\\f274\";\n}\n.fa-industry:before {\n  content: \"\\f275\";\n}\n.fa-map-pin:before {\n  content: \"\\f276\";\n}\n.fa-map-signs:before {\n  content: \"\\f277\";\n}\n.fa-map-o:before {\n  content: \"\\f278\";\n}\n.fa-map:before {\n  content: \"\\f279\";\n}\n.fa-commenting:before {\n  content: \"\\f27a\";\n}\n.fa-commenting-o:before {\n  content: \"\\f27b\";\n}\n.fa-houzz:before {\n  content: \"\\f27c\";\n}\n.fa-vimeo:before {\n  content: \"\\f27d\";\n}\n.fa-black-tie:before {\n  content: \"\\f27e\";\n}\n.fa-fonticons:before {\n  content: \"\\f280\";\n}\n.fa-reddit-alien:before {\n  content: \"\\f281\";\n}\n.fa-edge:before {\n  content: \"\\f282\";\n}\n.fa-credit-card-alt:before {\n  content: \"\\f283\";\n}\n.fa-codiepie:before {\n  content: \"\\f284\";\n}\n.fa-modx:before {\n  content: \"\\f285\";\n}\n.fa-fort-awesome:before {\n  content: \"\\f286\";\n}\n.fa-usb:before {\n  content: \"\\f287\";\n}\n.fa-product-hunt:before {\n  content: \"\\f288\";\n}\n.fa-mixcloud:before {\n  content: \"\\f289\";\n}\n.fa-scribd:before {\n  content: \"\\f28a\";\n}\n.fa-pause-circle:before {\n  content: \"\\f28b\";\n}\n.fa-pause-circle-o:before {\n  content: \"\\f28c\";\n}\n.fa-stop-circle:before {\n  content: \"\\f28d\";\n}\n.fa-stop-circle-o:before {\n  content: \"\\f28e\";\n}\n.fa-shopping-bag:before {\n  content: \"\\f290\";\n}\n.fa-shopping-basket:before {\n  content: \"\\f291\";\n}\n.fa-hashtag:before {\n  content: \"\\f292\";\n}\n.fa-bluetooth:before {\n  content: \"\\f293\";\n}\n.fa-bluetooth-b:before {\n  content: \"\\f294\";\n}\n.fa-percent:before {\n  content: \"\\f295\";\n}\n.fa-gitlab:before {\n  content: \"\\f296\";\n}\n.fa-wpbeginner:before {\n  content: \"\\f297\";\n}\n.fa-wpforms:before {\n  content: \"\\f298\";\n}\n.fa-envira:before {\n  content: \"\\f299\";\n}\n.fa-universal-access:before {\n  content: \"\\f29a\";\n}\n.fa-wheelchair-alt:before {\n  content: \"\\f29b\";\n}\n.fa-question-circle-o:before {\n  content: \"\\f29c\";\n}\n.fa-blind:before {\n  content: \"\\f29d\";\n}\n.fa-audio-description:before {\n  content: \"\\f29e\";\n}\n.fa-volume-control-phone:before {\n  content: \"\\f2a0\";\n}\n.fa-braille:before {\n  content: \"\\f2a1\";\n}\n.fa-assistive-listening-systems:before {\n  content: \"\\f2a2\";\n}\n.fa-asl-interpreting:before,\n.fa-american-sign-language-interpreting:before {\n  content: \"\\f2a3\";\n}\n.fa-deafness:before,\n.fa-hard-of-hearing:before,\n.fa-deaf:before {\n  content: \"\\f2a4\";\n}\n.fa-glide:before {\n  content: \"\\f2a5\";\n}\n.fa-glide-g:before {\n  content: \"\\f2a6\";\n}\n.fa-signing:before,\n.fa-sign-language:before {\n  content: \"\\f2a7\";\n}\n.fa-low-vision:before {\n  content: \"\\f2a8\";\n}\n.fa-viadeo:before {\n  content: \"\\f2a9\";\n}\n.fa-viadeo-square:before {\n  content: \"\\f2aa\";\n}\n.fa-snapchat:before {\n  content: \"\\f2ab\";\n}\n.fa-snapchat-ghost:before {\n  content: \"\\f2ac\";\n}\n.fa-snapchat-square:before {\n  content: \"\\f2ad\";\n}\n.sr-only {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  padding: 0;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  border: 0;\n}\n.sr-only-focusable:active,\n.sr-only-focusable:focus {\n  position: static;\n  width: auto;\n  height: auto;\n  margin: 0;\n  overflow: visible;\n  clip: auto;\n}\n"
  },
  {
    "path": "html/lib/font-awesome/fonts/index.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css\" />\n  </head>\n\n  <body>\n    <h1>4.4.0</h1>\n    <table>\n      <tr>\n        <td><i class=\"fa fa-1x fa-file-pdf-o\"></i></td>\n        <td><i class=\"fa fa-1x fa-cog\"></i></td>\n        <td><i class=\"fa fa-1x fa-shield\"></i></td>\n        <td><i class=\"fa fa-1x fa-ship\"></i></td>\n        <td><i class=\"fa fa-1x fa-angle-double-up\"></i></td>\n        <td><i class=\"fa fa-1x fa-angle-double-down\"></i></td>\n        <td><i class=\"fa fa-1x fa-file-o\"></i></td>\n      </tr>\n      <tr>\n        <td><i class=\"fa fa-2x fa-file-pdf-o\"></i></td>\n        <td><i class=\"fa fa-2x fa-cog\"></i></td>\n        <td><i class=\"fa fa-2x fa-shield\"></i></td>\n        <td><i class=\"fa fa-2x fa-ship\"></i></td>\n        <td><i class=\"fa fa-2x fa-angle-double-up\"></i></td>\n        <td><i class=\"fa fa-2x fa-angle-double-down\"></i></td>\n        <td><i class=\"fa fa-2x fa-file-o\"></i></td>\n      </tr>\n      <tr>\n        <td><i class=\"fa fa-3x fa-file-pdf-o\"></i></td>\n        <td><i class=\"fa fa-3x fa-cog\"></i></td>\n        <td><i class=\"fa fa-3x fa-shield\"></i></td>\n        <td><i class=\"fa fa-3x fa-ship\"></i></td>\n        <td><i class=\"fa fa-3x fa-angle-double-up\"></i></td>\n        <td><i class=\"fa fa-3x fa-angle-double-down\"></i></td>\n        <td><i class=\"fa fa-3x fa-file-o\"></i></td>\n      </tr>\n      <tr>\n        <td><i class=\"fa fa-4x fa-file-pdf-o\"></i></td>\n        <td><i class=\"fa fa-4x fa-cog\"></i></td>\n        <td><i class=\"fa fa-4x fa-shield\"></i></td>\n        <td><i class=\"fa fa-4x fa-ship\"></i></td>\n        <td><i class=\"fa fa-4x fa-angle-double-up\"></i></td>\n        <td><i class=\"fa fa-4x fa-angle-double-down\"></i></td>\n        <td><i class=\"fa fa-4x fa-file-o\"></i></td>\n      </tr>\n      <tr>\n        <td><i class=\"fa fa-5x fa-file-pdf-o\"></i></td>\n        <td><i class=\"fa fa-5x fa-cog\"></i></td>\n        <td><i class=\"fa fa-5x fa-shield\"></i></td>\n        <td><i class=\"fa fa-5x fa-ship\"></i></td>\n        <td><i class=\"fa fa-5x fa-angle-double-up\"></i></td>\n        <td><i class=\"fa fa-5x fa-angle-double-down\"></i></td>\n        <td><i class=\"fa fa-5x fa-file-o\"></i></td>\n      </tr>\n    </table>\n  </body>\n\n</html>\n"
  },
  {
    "path": "html/lib/jquery/jquery.js",
    "content": "/*!\n * jQuery JavaScript Library v2.2.3\n * http://jquery.com/\n *\n * Includes Sizzle.js\n * http://sizzlejs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * http://jquery.org/license\n *\n * Date: 2016-04-05T19:26Z\n */\n\n(function( global, factory ) {\n\n\tif ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\n\t\t// For CommonJS and CommonJS-like environments where a proper `window`\n\t\t// is present, execute the factory and get jQuery.\n\t\t// For environments that do not have a `window` with a `document`\n\t\t// (such as Node.js), expose a factory as module.exports.\n\t\t// This accentuates the need for the creation of a real `window`.\n\t\t// e.g. var jQuery = require(\"jquery\")(window);\n\t\t// See ticket #14549 for more info.\n\t\tmodule.exports = global.document ?\n\t\t\tfactory( global, true ) :\n\t\t\tfunction( w ) {\n\t\t\t\tif ( !w.document ) {\n\t\t\t\t\tthrow new Error( \"jQuery requires a window with a document\" );\n\t\t\t\t}\n\t\t\t\treturn factory( w );\n\t\t\t};\n\t} else {\n\t\tfactory( global );\n\t}\n\n// Pass this if window is not defined yet\n}(typeof window !== \"undefined\" ? window : this, function( window, noGlobal ) {\n\n// Support: Firefox 18+\n// Can't be in strict mode, several libs including ASP.NET trace\n// the stack via arguments.caller.callee and Firefox dies if\n// you try to trace through \"use strict\" call chains. (#13335)\n//\"use strict\";\nvar arr = [];\n\nvar document = window.document;\n\nvar slice = arr.slice;\n\nvar concat = arr.concat;\n\nvar push = arr.push;\n\nvar indexOf = arr.indexOf;\n\nvar class2type = {};\n\nvar toString = class2type.toString;\n\nvar hasOwn = class2type.hasOwnProperty;\n\nvar support = {};\n\n\n\nvar\n\tversion = \"2.2.3\",\n\n\t// Define a local copy of jQuery\n\tjQuery = function( selector, context ) {\n\n\t\t// The jQuery object is actually just the init constructor 'enhanced'\n\t\t// Need init if jQuery is called (just allow error to be thrown if not included)\n\t\treturn new jQuery.fn.init( selector, context );\n\t},\n\n\t// Support: Android<4.1\n\t// Make sure we trim BOM and NBSP\n\trtrim = /^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g,\n\n\t// Matches dashed string for camelizing\n\trmsPrefix = /^-ms-/,\n\trdashAlpha = /-([\\da-z])/gi,\n\n\t// Used by jQuery.camelCase as callback to replace()\n\tfcamelCase = function( all, letter ) {\n\t\treturn letter.toUpperCase();\n\t};\n\njQuery.fn = jQuery.prototype = {\n\n\t// The current version of jQuery being used\n\tjquery: version,\n\n\tconstructor: jQuery,\n\n\t// Start with an empty selector\n\tselector: \"\",\n\n\t// The default length of a jQuery object is 0\n\tlength: 0,\n\n\ttoArray: function() {\n\t\treturn slice.call( this );\n\t},\n\n\t// Get the Nth element in the matched element set OR\n\t// Get the whole matched element set as a clean array\n\tget: function( num ) {\n\t\treturn num != null ?\n\n\t\t\t// Return just the one element from the set\n\t\t\t( num < 0 ? this[ num + this.length ] : this[ num ] ) :\n\n\t\t\t// Return all the elements in a clean array\n\t\t\tslice.call( this );\n\t},\n\n\t// Take an array of elements and push it onto the stack\n\t// (returning the new matched element set)\n\tpushStack: function( elems ) {\n\n\t\t// Build a new jQuery matched element set\n\t\tvar ret = jQuery.merge( this.constructor(), elems );\n\n\t\t// Add the old object onto the stack (as a reference)\n\t\tret.prevObject = this;\n\t\tret.context = this.context;\n\n\t\t// Return the newly-formed element set\n\t\treturn ret;\n\t},\n\n\t// Execute a callback for every element in the matched set.\n\teach: function( callback ) {\n\t\treturn jQuery.each( this, callback );\n\t},\n\n\tmap: function( callback ) {\n\t\treturn this.pushStack( jQuery.map( this, function( elem, i ) {\n\t\t\treturn callback.call( elem, i, elem );\n\t\t} ) );\n\t},\n\n\tslice: function() {\n\t\treturn this.pushStack( slice.apply( this, arguments ) );\n\t},\n\n\tfirst: function() {\n\t\treturn this.eq( 0 );\n\t},\n\n\tlast: function() {\n\t\treturn this.eq( -1 );\n\t},\n\n\teq: function( i ) {\n\t\tvar len = this.length,\n\t\t\tj = +i + ( i < 0 ? len : 0 );\n\t\treturn this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );\n\t},\n\n\tend: function() {\n\t\treturn this.prevObject || this.constructor();\n\t},\n\n\t// For internal use only.\n\t// Behaves like an Array's method, not like a jQuery method.\n\tpush: push,\n\tsort: arr.sort,\n\tsplice: arr.splice\n};\n\njQuery.extend = jQuery.fn.extend = function() {\n\tvar options, name, src, copy, copyIsArray, clone,\n\t\ttarget = arguments[ 0 ] || {},\n\t\ti = 1,\n\t\tlength = arguments.length,\n\t\tdeep = false;\n\n\t// Handle a deep copy situation\n\tif ( typeof target === \"boolean\" ) {\n\t\tdeep = target;\n\n\t\t// Skip the boolean and the target\n\t\ttarget = arguments[ i ] || {};\n\t\ti++;\n\t}\n\n\t// Handle case when target is a string or something (possible in deep copy)\n\tif ( typeof target !== \"object\" && !jQuery.isFunction( target ) ) {\n\t\ttarget = {};\n\t}\n\n\t// Extend jQuery itself if only one argument is passed\n\tif ( i === length ) {\n\t\ttarget = this;\n\t\ti--;\n\t}\n\n\tfor ( ; i < length; i++ ) {\n\n\t\t// Only deal with non-null/undefined values\n\t\tif ( ( options = arguments[ i ] ) != null ) {\n\n\t\t\t// Extend the base object\n\t\t\tfor ( name in options ) {\n\t\t\t\tsrc = target[ name ];\n\t\t\t\tcopy = options[ name ];\n\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif ( target === copy ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\tif ( deep && copy && ( jQuery.isPlainObject( copy ) ||\n\t\t\t\t\t( copyIsArray = jQuery.isArray( copy ) ) ) ) {\n\n\t\t\t\t\tif ( copyIsArray ) {\n\t\t\t\t\t\tcopyIsArray = false;\n\t\t\t\t\t\tclone = src && jQuery.isArray( src ) ? src : [];\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclone = src && jQuery.isPlainObject( src ) ? src : {};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\ttarget[ name ] = jQuery.extend( deep, clone, copy );\n\n\t\t\t\t// Don't bring in undefined values\n\t\t\t\t} else if ( copy !== undefined ) {\n\t\t\t\t\ttarget[ name ] = copy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n\njQuery.extend( {\n\n\t// Unique for each copy of jQuery on the page\n\texpando: \"jQuery\" + ( version + Math.random() ).replace( /\\D/g, \"\" ),\n\n\t// Assume jQuery is ready without the ready module\n\tisReady: true,\n\n\terror: function( msg ) {\n\t\tthrow new Error( msg );\n\t},\n\n\tnoop: function() {},\n\n\tisFunction: function( obj ) {\n\t\treturn jQuery.type( obj ) === \"function\";\n\t},\n\n\tisArray: Array.isArray,\n\n\tisWindow: function( obj ) {\n\t\treturn obj != null && obj === obj.window;\n\t},\n\n\tisNumeric: function( obj ) {\n\n\t\t// parseFloat NaNs numeric-cast false positives (null|true|false|\"\")\n\t\t// ...but misinterprets leading-number strings, particularly hex literals (\"0x...\")\n\t\t// subtraction forces infinities to NaN\n\t\t// adding 1 corrects loss of precision from parseFloat (#15100)\n\t\tvar realStringObj = obj && obj.toString();\n\t\treturn !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;\n\t},\n\n\tisPlainObject: function( obj ) {\n\t\tvar key;\n\n\t\t// Not plain objects:\n\t\t// - Any object or value whose internal [[Class]] property is not \"[object Object]\"\n\t\t// - DOM nodes\n\t\t// - window\n\t\tif ( jQuery.type( obj ) !== \"object\" || obj.nodeType || jQuery.isWindow( obj ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Not own constructor property must be Object\n\t\tif ( obj.constructor &&\n\t\t\t\t!hasOwn.call( obj, \"constructor\" ) &&\n\t\t\t\t!hasOwn.call( obj.constructor.prototype || {}, \"isPrototypeOf\" ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Own properties are enumerated firstly, so to speed up,\n\t\t// if last one is own, then all properties are own\n\t\tfor ( key in obj ) {}\n\n\t\treturn key === undefined || hasOwn.call( obj, key );\n\t},\n\n\tisEmptyObject: function( obj ) {\n\t\tvar name;\n\t\tfor ( name in obj ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t},\n\n\ttype: function( obj ) {\n\t\tif ( obj == null ) {\n\t\t\treturn obj + \"\";\n\t\t}\n\n\t\t// Support: Android<4.0, iOS<6 (functionish RegExp)\n\t\treturn typeof obj === \"object\" || typeof obj === \"function\" ?\n\t\t\tclass2type[ toString.call( obj ) ] || \"object\" :\n\t\t\ttypeof obj;\n\t},\n\n\t// Evaluates a script in a global context\n\tglobalEval: function( code ) {\n\t\tvar script,\n\t\t\tindirect = eval;\n\n\t\tcode = jQuery.trim( code );\n\n\t\tif ( code ) {\n\n\t\t\t// If the code includes a valid, prologue position\n\t\t\t// strict mode pragma, execute code by injecting a\n\t\t\t// script tag into the document.\n\t\t\tif ( code.indexOf( \"use strict\" ) === 1 ) {\n\t\t\t\tscript = document.createElement( \"script\" );\n\t\t\t\tscript.text = code;\n\t\t\t\tdocument.head.appendChild( script ).parentNode.removeChild( script );\n\t\t\t} else {\n\n\t\t\t\t// Otherwise, avoid the DOM node creation, insertion\n\t\t\t\t// and removal by using an indirect global eval\n\n\t\t\t\tindirect( code );\n\t\t\t}\n\t\t}\n\t},\n\n\t// Convert dashed to camelCase; used by the css and data modules\n\t// Support: IE9-11+\n\t// Microsoft forgot to hump their vendor prefix (#9572)\n\tcamelCase: function( string ) {\n\t\treturn string.replace( rmsPrefix, \"ms-\" ).replace( rdashAlpha, fcamelCase );\n\t},\n\n\tnodeName: function( elem, name ) {\n\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();\n\t},\n\n\teach: function( obj, callback ) {\n\t\tvar length, i = 0;\n\n\t\tif ( isArrayLike( obj ) ) {\n\t\t\tlength = obj.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i in obj ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn obj;\n\t},\n\n\t// Support: Android<4.1\n\ttrim: function( text ) {\n\t\treturn text == null ?\n\t\t\t\"\" :\n\t\t\t( text + \"\" ).replace( rtrim, \"\" );\n\t},\n\n\t// results is for internal usage only\n\tmakeArray: function( arr, results ) {\n\t\tvar ret = results || [];\n\n\t\tif ( arr != null ) {\n\t\t\tif ( isArrayLike( Object( arr ) ) ) {\n\t\t\t\tjQuery.merge( ret,\n\t\t\t\t\ttypeof arr === \"string\" ?\n\t\t\t\t\t[ arr ] : arr\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tpush.call( ret, arr );\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\tinArray: function( elem, arr, i ) {\n\t\treturn arr == null ? -1 : indexOf.call( arr, elem, i );\n\t},\n\n\tmerge: function( first, second ) {\n\t\tvar len = +second.length,\n\t\t\tj = 0,\n\t\t\ti = first.length;\n\n\t\tfor ( ; j < len; j++ ) {\n\t\t\tfirst[ i++ ] = second[ j ];\n\t\t}\n\n\t\tfirst.length = i;\n\n\t\treturn first;\n\t},\n\n\tgrep: function( elems, callback, invert ) {\n\t\tvar callbackInverse,\n\t\t\tmatches = [],\n\t\t\ti = 0,\n\t\t\tlength = elems.length,\n\t\t\tcallbackExpect = !invert;\n\n\t\t// Go through the array, only saving the items\n\t\t// that pass the validator function\n\t\tfor ( ; i < length; i++ ) {\n\t\t\tcallbackInverse = !callback( elems[ i ], i );\n\t\t\tif ( callbackInverse !== callbackExpect ) {\n\t\t\t\tmatches.push( elems[ i ] );\n\t\t\t}\n\t\t}\n\n\t\treturn matches;\n\t},\n\n\t// arg is for internal usage only\n\tmap: function( elems, callback, arg ) {\n\t\tvar length, value,\n\t\t\ti = 0,\n\t\t\tret = [];\n\n\t\t// Go through the array, translating each of the items to their new values\n\t\tif ( isArrayLike( elems ) ) {\n\t\t\tlength = elems.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Go through every key on the object,\n\t\t} else {\n\t\t\tfor ( i in elems ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Flatten any nested arrays\n\t\treturn concat.apply( [], ret );\n\t},\n\n\t// A global GUID counter for objects\n\tguid: 1,\n\n\t// Bind a function to a context, optionally partially applying any\n\t// arguments.\n\tproxy: function( fn, context ) {\n\t\tvar tmp, args, proxy;\n\n\t\tif ( typeof context === \"string\" ) {\n\t\t\ttmp = fn[ context ];\n\t\t\tcontext = fn;\n\t\t\tfn = tmp;\n\t\t}\n\n\t\t// Quick check to determine if target is callable, in the spec\n\t\t// this throws a TypeError, but we will just return undefined.\n\t\tif ( !jQuery.isFunction( fn ) ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Simulated bind\n\t\targs = slice.call( arguments, 2 );\n\t\tproxy = function() {\n\t\t\treturn fn.apply( context || this, args.concat( slice.call( arguments ) ) );\n\t\t};\n\n\t\t// Set the guid of unique handler to the same of original handler, so it can be removed\n\t\tproxy.guid = fn.guid = fn.guid || jQuery.guid++;\n\n\t\treturn proxy;\n\t},\n\n\tnow: Date.now,\n\n\t// jQuery.support is not used in Core but other projects attach their\n\t// properties to it so it needs to exist.\n\tsupport: support\n} );\n\n// JSHint would error on this code due to the Symbol not being defined in ES5.\n// Defining this global in .jshintrc would create a danger of using the global\n// unguarded in another place, it seems safer to just disable JSHint for these\n// three lines.\n/* jshint ignore: start */\nif ( typeof Symbol === \"function\" ) {\n\tjQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];\n}\n/* jshint ignore: end */\n\n// Populate the class2type map\njQuery.each( \"Boolean Number String Function Array Date RegExp Object Error Symbol\".split( \" \" ),\nfunction( i, name ) {\n\tclass2type[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n} );\n\nfunction isArrayLike( obj ) {\n\n\t// Support: iOS 8.2 (not reproducible in simulator)\n\t// `in` check used to prevent JIT error (gh-2145)\n\t// hasOwn isn't used here due to false negatives\n\t// regarding Nodelist length in IE\n\tvar length = !!obj && \"length\" in obj && obj.length,\n\t\ttype = jQuery.type( obj );\n\n\tif ( type === \"function\" || jQuery.isWindow( obj ) ) {\n\t\treturn false;\n\t}\n\n\treturn type === \"array\" || length === 0 ||\n\t\ttypeof length === \"number\" && length > 0 && ( length - 1 ) in obj;\n}\nvar Sizzle =\n/*!\n * Sizzle CSS Selector Engine v2.2.1\n * http://sizzlejs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * http://jquery.org/license\n *\n * Date: 2015-10-17\n */\n(function( window ) {\n\nvar i,\n\tsupport,\n\tExpr,\n\tgetText,\n\tisXML,\n\ttokenize,\n\tcompile,\n\tselect,\n\toutermostContext,\n\tsortInput,\n\thasDuplicate,\n\n\t// Local document vars\n\tsetDocument,\n\tdocument,\n\tdocElem,\n\tdocumentIsHTML,\n\trbuggyQSA,\n\trbuggyMatches,\n\tmatches,\n\tcontains,\n\n\t// Instance-specific data\n\texpando = \"sizzle\" + 1 * new Date(),\n\tpreferredDoc = window.document,\n\tdirruns = 0,\n\tdone = 0,\n\tclassCache = createCache(),\n\ttokenCache = createCache(),\n\tcompilerCache = createCache(),\n\tsortOrder = function( a, b ) {\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t}\n\t\treturn 0;\n\t},\n\n\t// General-purpose constants\n\tMAX_NEGATIVE = 1 << 31,\n\n\t// Instance methods\n\thasOwn = ({}).hasOwnProperty,\n\tarr = [],\n\tpop = arr.pop,\n\tpush_native = arr.push,\n\tpush = arr.push,\n\tslice = arr.slice,\n\t// Use a stripped-down indexOf as it's faster than native\n\t// http://jsperf.com/thor-indexof-vs-for/5\n\tindexOf = function( list, elem ) {\n\t\tvar i = 0,\n\t\t\tlen = list.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( list[i] === elem ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t},\n\n\tbooleans = \"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped\",\n\n\t// Regular expressions\n\n\t// http://www.w3.org/TR/css3-selectors/#whitespace\n\twhitespace = \"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\",\n\n\t// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier\n\tidentifier = \"(?:\\\\\\\\.|[\\\\w-]|[^\\\\x00-\\\\xa0])+\",\n\n\t// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors\n\tattributes = \"\\\\[\" + whitespace + \"*(\" + identifier + \")(?:\" + whitespace +\n\t\t// Operator (capture 2)\n\t\t\"*([*^$|!~]?=)\" + whitespace +\n\t\t// \"Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]\"\n\t\t\"*(?:'((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\"|(\" + identifier + \"))|)\" + whitespace +\n\t\t\"*\\\\]\",\n\n\tpseudos = \":(\" + identifier + \")(?:\\\\((\" +\n\t\t// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:\n\t\t// 1. quoted (capture 3; capture 4 or capture 5)\n\t\t\"('((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\")|\" +\n\t\t// 2. simple (capture 6)\n\t\t\"((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|\" + attributes + \")*)|\" +\n\t\t// 3. anything else (capture 2)\n\t\t\".*\" +\n\t\t\")\\\\)|)\",\n\n\t// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter\n\trwhitespace = new RegExp( whitespace + \"+\", \"g\" ),\n\trtrim = new RegExp( \"^\" + whitespace + \"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\" + whitespace + \"+$\", \"g\" ),\n\n\trcomma = new RegExp( \"^\" + whitespace + \"*,\" + whitespace + \"*\" ),\n\trcombinators = new RegExp( \"^\" + whitespace + \"*([>+~]|\" + whitespace + \")\" + whitespace + \"*\" ),\n\n\trattributeQuotes = new RegExp( \"=\" + whitespace + \"*([^\\\\]'\\\"]*?)\" + whitespace + \"*\\\\]\", \"g\" ),\n\n\trpseudo = new RegExp( pseudos ),\n\tridentifier = new RegExp( \"^\" + identifier + \"$\" ),\n\n\tmatchExpr = {\n\t\t\"ID\": new RegExp( \"^#(\" + identifier + \")\" ),\n\t\t\"CLASS\": new RegExp( \"^\\\\.(\" + identifier + \")\" ),\n\t\t\"TAG\": new RegExp( \"^(\" + identifier + \"|[*])\" ),\n\t\t\"ATTR\": new RegExp( \"^\" + attributes ),\n\t\t\"PSEUDO\": new RegExp( \"^\" + pseudos ),\n\t\t\"CHILD\": new RegExp( \"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\" + whitespace +\n\t\t\t\"*(even|odd|(([+-]|)(\\\\d*)n|)\" + whitespace + \"*(?:([+-]|)\" + whitespace +\n\t\t\t\"*(\\\\d+)|))\" + whitespace + \"*\\\\)|)\", \"i\" ),\n\t\t\"bool\": new RegExp( \"^(?:\" + booleans + \")$\", \"i\" ),\n\t\t// For use in libraries implementing .is()\n\t\t// We use this for POS matching in `select`\n\t\t\"needsContext\": new RegExp( \"^\" + whitespace + \"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\" +\n\t\t\twhitespace + \"*((?:-\\\\d)?\\\\d*)\" + whitespace + \"*\\\\)|)(?=[^-]|$)\", \"i\" )\n\t},\n\n\trinputs = /^(?:input|select|textarea|button)$/i,\n\trheader = /^h\\d$/i,\n\n\trnative = /^[^{]+\\{\\s*\\[native \\w/,\n\n\t// Easily-parseable/retrievable ID or TAG or CLASS selectors\n\trquickExpr = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,\n\n\trsibling = /[+~]/,\n\trescape = /'|\\\\/g,\n\n\t// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters\n\trunescape = new RegExp( \"\\\\\\\\([\\\\da-f]{1,6}\" + whitespace + \"?|(\" + whitespace + \")|.)\", \"ig\" ),\n\tfunescape = function( _, escaped, escapedWhitespace ) {\n\t\tvar high = \"0x\" + escaped - 0x10000;\n\t\t// NaN means non-codepoint\n\t\t// Support: Firefox<24\n\t\t// Workaround erroneous numeric interpretation of +\"0x\"\n\t\treturn high !== high || escapedWhitespace ?\n\t\t\tescaped :\n\t\t\thigh < 0 ?\n\t\t\t\t// BMP codepoint\n\t\t\t\tString.fromCharCode( high + 0x10000 ) :\n\t\t\t\t// Supplemental Plane codepoint (surrogate pair)\n\t\t\t\tString.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );\n\t},\n\n\t// Used for iframes\n\t// See setDocument()\n\t// Removing the function wrapper causes a \"Permission Denied\"\n\t// error in IE\n\tunloadHandler = function() {\n\t\tsetDocument();\n\t};\n\n// Optimize for push.apply( _, NodeList )\ntry {\n\tpush.apply(\n\t\t(arr = slice.call( preferredDoc.childNodes )),\n\t\tpreferredDoc.childNodes\n\t);\n\t// Support: Android<4.0\n\t// Detect silently failing push.apply\n\tarr[ preferredDoc.childNodes.length ].nodeType;\n} catch ( e ) {\n\tpush = { apply: arr.length ?\n\n\t\t// Leverage slice if possible\n\t\tfunction( target, els ) {\n\t\t\tpush_native.apply( target, slice.call(els) );\n\t\t} :\n\n\t\t// Support: IE<9\n\t\t// Otherwise append directly\n\t\tfunction( target, els ) {\n\t\t\tvar j = target.length,\n\t\t\t\ti = 0;\n\t\t\t// Can't trust NodeList.length\n\t\t\twhile ( (target[j++] = els[i++]) ) {}\n\t\t\ttarget.length = j - 1;\n\t\t}\n\t};\n}\n\nfunction Sizzle( selector, context, results, seed ) {\n\tvar m, i, elem, nid, nidselect, match, groups, newSelector,\n\t\tnewContext = context && context.ownerDocument,\n\n\t\t// nodeType defaults to 9, since context defaults to document\n\t\tnodeType = context ? context.nodeType : 9;\n\n\tresults = results || [];\n\n\t// Return early from calls with invalid selector or context\n\tif ( typeof selector !== \"string\" || !selector ||\n\t\tnodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {\n\n\t\treturn results;\n\t}\n\n\t// Try to shortcut find operations (as opposed to filters) in HTML documents\n\tif ( !seed ) {\n\n\t\tif ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {\n\t\t\tsetDocument( context );\n\t\t}\n\t\tcontext = context || document;\n\n\t\tif ( documentIsHTML ) {\n\n\t\t\t// If the selector is sufficiently simple, try using a \"get*By*\" DOM method\n\t\t\t// (excepting DocumentFragment context, where the methods don't exist)\n\t\t\tif ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {\n\n\t\t\t\t// ID selector\n\t\t\t\tif ( (m = match[1]) ) {\n\n\t\t\t\t\t// Document context\n\t\t\t\t\tif ( nodeType === 9 ) {\n\t\t\t\t\t\tif ( (elem = context.getElementById( m )) ) {\n\n\t\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\t\tif ( elem.id === m ) {\n\t\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t// Element context\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\tif ( newContext && (elem = newContext.getElementById( m )) &&\n\t\t\t\t\t\t\tcontains( context, elem ) &&\n\t\t\t\t\t\t\telem.id === m ) {\n\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t// Type selector\n\t\t\t\t} else if ( match[2] ) {\n\t\t\t\t\tpush.apply( results, context.getElementsByTagName( selector ) );\n\t\t\t\t\treturn results;\n\n\t\t\t\t// Class selector\n\t\t\t\t} else if ( (m = match[3]) && support.getElementsByClassName &&\n\t\t\t\t\tcontext.getElementsByClassName ) {\n\n\t\t\t\t\tpush.apply( results, context.getElementsByClassName( m ) );\n\t\t\t\t\treturn results;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Take advantage of querySelectorAll\n\t\t\tif ( support.qsa &&\n\t\t\t\t!compilerCache[ selector + \" \" ] &&\n\t\t\t\t(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {\n\n\t\t\t\tif ( nodeType !== 1 ) {\n\t\t\t\t\tnewContext = context;\n\t\t\t\t\tnewSelector = selector;\n\n\t\t\t\t// qSA looks outside Element context, which is not what we want\n\t\t\t\t// Thanks to Andrew Dupont for this workaround technique\n\t\t\t\t// Support: IE <=8\n\t\t\t\t// Exclude object elements\n\t\t\t\t} else if ( context.nodeName.toLowerCase() !== \"object\" ) {\n\n\t\t\t\t\t// Capture the context ID, setting it first if necessary\n\t\t\t\t\tif ( (nid = context.getAttribute( \"id\" )) ) {\n\t\t\t\t\t\tnid = nid.replace( rescape, \"\\\\$&\" );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.setAttribute( \"id\", (nid = expando) );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prefix every selector in the list\n\t\t\t\t\tgroups = tokenize( selector );\n\t\t\t\t\ti = groups.length;\n\t\t\t\t\tnidselect = ridentifier.test( nid ) ? \"#\" + nid : \"[id='\" + nid + \"']\";\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tgroups[i] = nidselect + \" \" + toSelector( groups[i] );\n\t\t\t\t\t}\n\t\t\t\t\tnewSelector = groups.join( \",\" );\n\n\t\t\t\t\t// Expand context for sibling selectors\n\t\t\t\t\tnewContext = rsibling.test( selector ) && testContext( context.parentNode ) ||\n\t\t\t\t\t\tcontext;\n\t\t\t\t}\n\n\t\t\t\tif ( newSelector ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpush.apply( results,\n\t\t\t\t\t\t\tnewContext.querySelectorAll( newSelector )\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t} catch ( qsaError ) {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif ( nid === expando ) {\n\t\t\t\t\t\t\tcontext.removeAttribute( \"id\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// All others\n\treturn select( selector.replace( rtrim, \"$1\" ), context, results, seed );\n}\n\n/**\n * Create key-value caches of limited size\n * @returns {function(string, object)} Returns the Object data after storing it on itself with\n *\tproperty name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)\n *\tdeleting the oldest entry\n */\nfunction createCache() {\n\tvar keys = [];\n\n\tfunction cache( key, value ) {\n\t\t// Use (key + \" \") to avoid collision with native prototype properties (see Issue #157)\n\t\tif ( keys.push( key + \" \" ) > Expr.cacheLength ) {\n\t\t\t// Only keep the most recent entries\n\t\t\tdelete cache[ keys.shift() ];\n\t\t}\n\t\treturn (cache[ key + \" \" ] = value);\n\t}\n\treturn cache;\n}\n\n/**\n * Mark a function for special use by Sizzle\n * @param {Function} fn The function to mark\n */\nfunction markFunction( fn ) {\n\tfn[ expando ] = true;\n\treturn fn;\n}\n\n/**\n * Support testing using an element\n * @param {Function} fn Passed the created div and expects a boolean result\n */\nfunction assert( fn ) {\n\tvar div = document.createElement(\"div\");\n\n\ttry {\n\t\treturn !!fn( div );\n\t} catch (e) {\n\t\treturn false;\n\t} finally {\n\t\t// Remove from its parent by default\n\t\tif ( div.parentNode ) {\n\t\t\tdiv.parentNode.removeChild( div );\n\t\t}\n\t\t// release memory in IE\n\t\tdiv = null;\n\t}\n}\n\n/**\n * Adds the same handler for all of the specified attrs\n * @param {String} attrs Pipe-separated list of attributes\n * @param {Function} handler The method that will be applied\n */\nfunction addHandle( attrs, handler ) {\n\tvar arr = attrs.split(\"|\"),\n\t\ti = arr.length;\n\n\twhile ( i-- ) {\n\t\tExpr.attrHandle[ arr[i] ] = handler;\n\t}\n}\n\n/**\n * Checks document order of two siblings\n * @param {Element} a\n * @param {Element} b\n * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b\n */\nfunction siblingCheck( a, b ) {\n\tvar cur = b && a,\n\t\tdiff = cur && a.nodeType === 1 && b.nodeType === 1 &&\n\t\t\t( ~b.sourceIndex || MAX_NEGATIVE ) -\n\t\t\t( ~a.sourceIndex || MAX_NEGATIVE );\n\n\t// Use IE sourceIndex if available on both nodes\n\tif ( diff ) {\n\t\treturn diff;\n\t}\n\n\t// Check if b follows a\n\tif ( cur ) {\n\t\twhile ( (cur = cur.nextSibling) ) {\n\t\t\tif ( cur === b ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a ? 1 : -1;\n}\n\n/**\n * Returns a function to use in pseudos for input types\n * @param {String} type\n */\nfunction createInputPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn name === \"input\" && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for buttons\n * @param {String} type\n */\nfunction createButtonPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn (name === \"input\" || name === \"button\") && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for positionals\n * @param {Function} fn\n */\nfunction createPositionalPseudo( fn ) {\n\treturn markFunction(function( argument ) {\n\t\targument = +argument;\n\t\treturn markFunction(function( seed, matches ) {\n\t\t\tvar j,\n\t\t\t\tmatchIndexes = fn( [], seed.length, argument ),\n\t\t\t\ti = matchIndexes.length;\n\n\t\t\t// Match elements found at the specified indexes\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( seed[ (j = matchIndexes[i]) ] ) {\n\t\t\t\t\tseed[j] = !(matches[j] = seed[j]);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Checks a node for validity as a Sizzle context\n * @param {Element|Object=} context\n * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value\n */\nfunction testContext( context ) {\n\treturn context && typeof context.getElementsByTagName !== \"undefined\" && context;\n}\n\n// Expose support vars for convenience\nsupport = Sizzle.support = {};\n\n/**\n * Detects XML nodes\n * @param {Element|Object} elem An element or a document\n * @returns {Boolean} True iff elem is a non-HTML XML node\n */\nisXML = Sizzle.isXML = function( elem ) {\n\t// documentElement is verified for cases where it doesn't yet exist\n\t// (such as loading iframes in IE - #4833)\n\tvar documentElement = elem && (elem.ownerDocument || elem).documentElement;\n\treturn documentElement ? documentElement.nodeName !== \"HTML\" : false;\n};\n\n/**\n * Sets document-related variables once based on the current document\n * @param {Element|Object} [doc] An element or document object to use to set the document\n * @returns {Object} Returns the current document\n */\nsetDocument = Sizzle.setDocument = function( node ) {\n\tvar hasCompare, parent,\n\t\tdoc = node ? node.ownerDocument || node : preferredDoc;\n\n\t// Return early if doc is invalid or already selected\n\tif ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {\n\t\treturn document;\n\t}\n\n\t// Update global variables\n\tdocument = doc;\n\tdocElem = document.documentElement;\n\tdocumentIsHTML = !isXML( document );\n\n\t// Support: IE 9-11, Edge\n\t// Accessing iframe documents after unload throws \"permission denied\" errors (jQuery #13936)\n\tif ( (parent = document.defaultView) && parent.top !== parent ) {\n\t\t// Support: IE 11\n\t\tif ( parent.addEventListener ) {\n\t\t\tparent.addEventListener( \"unload\", unloadHandler, false );\n\n\t\t// Support: IE 9 - 10 only\n\t\t} else if ( parent.attachEvent ) {\n\t\t\tparent.attachEvent( \"onunload\", unloadHandler );\n\t\t}\n\t}\n\n\t/* Attributes\n\t---------------------------------------------------------------------- */\n\n\t// Support: IE<8\n\t// Verify that getAttribute really returns attributes and not properties\n\t// (excepting IE8 booleans)\n\tsupport.attributes = assert(function( div ) {\n\t\tdiv.className = \"i\";\n\t\treturn !div.getAttribute(\"className\");\n\t});\n\n\t/* getElement(s)By*\n\t---------------------------------------------------------------------- */\n\n\t// Check if getElementsByTagName(\"*\") returns only elements\n\tsupport.getElementsByTagName = assert(function( div ) {\n\t\tdiv.appendChild( document.createComment(\"\") );\n\t\treturn !div.getElementsByTagName(\"*\").length;\n\t});\n\n\t// Support: IE<9\n\tsupport.getElementsByClassName = rnative.test( document.getElementsByClassName );\n\n\t// Support: IE<10\n\t// Check if getElementById returns elements by name\n\t// The broken getElementById methods don't pick up programatically-set names,\n\t// so use a roundabout getElementsByName test\n\tsupport.getById = assert(function( div ) {\n\t\tdocElem.appendChild( div ).id = expando;\n\t\treturn !document.getElementsByName || !document.getElementsByName( expando ).length;\n\t});\n\n\t// ID find and filter\n\tif ( support.getById ) {\n\t\tExpr.find[\"ID\"] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== \"undefined\" && documentIsHTML ) {\n\t\t\t\tvar m = context.getElementById( id );\n\t\t\t\treturn m ? [ m ] : [];\n\t\t\t}\n\t\t};\n\t\tExpr.filter[\"ID\"] = function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn elem.getAttribute(\"id\") === attrId;\n\t\t\t};\n\t\t};\n\t} else {\n\t\t// Support: IE6/7\n\t\t// getElementById is not reliable as a find shortcut\n\t\tdelete Expr.find[\"ID\"];\n\n\t\tExpr.filter[\"ID\"] =  function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\tvar node = typeof elem.getAttributeNode !== \"undefined\" &&\n\t\t\t\t\telem.getAttributeNode(\"id\");\n\t\t\t\treturn node && node.value === attrId;\n\t\t\t};\n\t\t};\n\t}\n\n\t// Tag\n\tExpr.find[\"TAG\"] = support.getElementsByTagName ?\n\t\tfunction( tag, context ) {\n\t\t\tif ( typeof context.getElementsByTagName !== \"undefined\" ) {\n\t\t\t\treturn context.getElementsByTagName( tag );\n\n\t\t\t// DocumentFragment nodes don't have gEBTN\n\t\t\t} else if ( support.qsa ) {\n\t\t\t\treturn context.querySelectorAll( tag );\n\t\t\t}\n\t\t} :\n\n\t\tfunction( tag, context ) {\n\t\t\tvar elem,\n\t\t\t\ttmp = [],\n\t\t\t\ti = 0,\n\t\t\t\t// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too\n\t\t\t\tresults = context.getElementsByTagName( tag );\n\n\t\t\t// Filter out possible comments\n\t\t\tif ( tag === \"*\" ) {\n\t\t\t\twhile ( (elem = results[i++]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\ttmp.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t// Class\n\tExpr.find[\"CLASS\"] = support.getElementsByClassName && function( className, context ) {\n\t\tif ( typeof context.getElementsByClassName !== \"undefined\" && documentIsHTML ) {\n\t\t\treturn context.getElementsByClassName( className );\n\t\t}\n\t};\n\n\t/* QSA/matchesSelector\n\t---------------------------------------------------------------------- */\n\n\t// QSA and matchesSelector support\n\n\t// matchesSelector(:active) reports false when true (IE9/Opera 11.5)\n\trbuggyMatches = [];\n\n\t// qSa(:focus) reports false when true (Chrome 21)\n\t// We allow this because of a bug in IE8/9 that throws an error\n\t// whenever `document.activeElement` is accessed on an iframe\n\t// So, we allow :focus to pass through QSA all the time to avoid the IE error\n\t// See http://bugs.jquery.com/ticket/13378\n\trbuggyQSA = [];\n\n\tif ( (support.qsa = rnative.test( document.querySelectorAll )) ) {\n\t\t// Build QSA regex\n\t\t// Regex strategy adopted from Diego Perini\n\t\tassert(function( div ) {\n\t\t\t// Select is set to empty string on purpose\n\t\t\t// This is to test IE's treatment of not explicitly\n\t\t\t// setting a boolean content attribute,\n\t\t\t// since its presence should be enough\n\t\t\t// http://bugs.jquery.com/ticket/12359\n\t\t\tdocElem.appendChild( div ).innerHTML = \"<a id='\" + expando + \"'></a>\" +\n\t\t\t\t\"<select id='\" + expando + \"-\\r\\\\' msallowcapture=''>\" +\n\t\t\t\t\"<option selected=''></option></select>\";\n\n\t\t\t// Support: IE8, Opera 11-12.16\n\t\t\t// Nothing should be selected when empty strings follow ^= or $= or *=\n\t\t\t// The test attribute must be unknown in Opera but \"safe\" for WinRT\n\t\t\t// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section\n\t\t\tif ( div.querySelectorAll(\"[msallowcapture^='']\").length ) {\n\t\t\t\trbuggyQSA.push( \"[*^$]=\" + whitespace + \"*(?:''|\\\"\\\")\" );\n\t\t\t}\n\n\t\t\t// Support: IE8\n\t\t\t// Boolean attributes and \"value\" are not treated correctly\n\t\t\tif ( !div.querySelectorAll(\"[selected]\").length ) {\n\t\t\t\trbuggyQSA.push( \"\\\\[\" + whitespace + \"*(?:value|\" + booleans + \")\" );\n\t\t\t}\n\n\t\t\t// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+\n\t\t\tif ( !div.querySelectorAll( \"[id~=\" + expando + \"-]\" ).length ) {\n\t\t\t\trbuggyQSA.push(\"~=\");\n\t\t\t}\n\n\t\t\t// Webkit/Opera - :checked should return selected option elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !div.querySelectorAll(\":checked\").length ) {\n\t\t\t\trbuggyQSA.push(\":checked\");\n\t\t\t}\n\n\t\t\t// Support: Safari 8+, iOS 8+\n\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=136851\n\t\t\t// In-page `selector#id sibing-combinator selector` fails\n\t\t\tif ( !div.querySelectorAll( \"a#\" + expando + \"+*\" ).length ) {\n\t\t\t\trbuggyQSA.push(\".#.+[+~]\");\n\t\t\t}\n\t\t});\n\n\t\tassert(function( div ) {\n\t\t\t// Support: Windows 8 Native Apps\n\t\t\t// The type and name attributes are restricted during .innerHTML assignment\n\t\t\tvar input = document.createElement(\"input\");\n\t\t\tinput.setAttribute( \"type\", \"hidden\" );\n\t\t\tdiv.appendChild( input ).setAttribute( \"name\", \"D\" );\n\n\t\t\t// Support: IE8\n\t\t\t// Enforce case-sensitivity of name attribute\n\t\t\tif ( div.querySelectorAll(\"[name=d]\").length ) {\n\t\t\t\trbuggyQSA.push( \"name\" + whitespace + \"*[*^$|!~]?=\" );\n\t\t\t}\n\n\t\t\t// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !div.querySelectorAll(\":enabled\").length ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Opera 10-11 does not throw on post-comma invalid pseudos\n\t\t\tdiv.querySelectorAll(\"*,:x\");\n\t\t\trbuggyQSA.push(\",.*:\");\n\t\t});\n\t}\n\n\tif ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||\n\t\tdocElem.webkitMatchesSelector ||\n\t\tdocElem.mozMatchesSelector ||\n\t\tdocElem.oMatchesSelector ||\n\t\tdocElem.msMatchesSelector) )) ) {\n\n\t\tassert(function( div ) {\n\t\t\t// Check to see if it's possible to do matchesSelector\n\t\t\t// on a disconnected node (IE 9)\n\t\t\tsupport.disconnectedMatch = matches.call( div, \"div\" );\n\n\t\t\t// This should fail with an exception\n\t\t\t// Gecko does not error, returns false instead\n\t\t\tmatches.call( div, \"[s!='']:x\" );\n\t\t\trbuggyMatches.push( \"!=\", pseudos );\n\t\t});\n\t}\n\n\trbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join(\"|\") );\n\trbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join(\"|\") );\n\n\t/* Contains\n\t---------------------------------------------------------------------- */\n\thasCompare = rnative.test( docElem.compareDocumentPosition );\n\n\t// Element contains another\n\t// Purposefully self-exclusive\n\t// As in, an element does not contain itself\n\tcontains = hasCompare || rnative.test( docElem.contains ) ?\n\t\tfunction( a, b ) {\n\t\t\tvar adown = a.nodeType === 9 ? a.documentElement : a,\n\t\t\t\tbup = b && b.parentNode;\n\t\t\treturn a === bup || !!( bup && bup.nodeType === 1 && (\n\t\t\t\tadown.contains ?\n\t\t\t\t\tadown.contains( bup ) :\n\t\t\t\t\ta.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16\n\t\t\t));\n\t\t} :\n\t\tfunction( a, b ) {\n\t\t\tif ( b ) {\n\t\t\t\twhile ( (b = b.parentNode) ) {\n\t\t\t\t\tif ( b === a ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t/* Sorting\n\t---------------------------------------------------------------------- */\n\n\t// Document order sorting\n\tsortOrder = hasCompare ?\n\tfunction( a, b ) {\n\n\t\t// Flag for duplicate removal\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Sort on method existence if only one input has compareDocumentPosition\n\t\tvar compare = !a.compareDocumentPosition - !b.compareDocumentPosition;\n\t\tif ( compare ) {\n\t\t\treturn compare;\n\t\t}\n\n\t\t// Calculate position if both inputs belong to the same document\n\t\tcompare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?\n\t\t\ta.compareDocumentPosition( b ) :\n\n\t\t\t// Otherwise we know they are disconnected\n\t\t\t1;\n\n\t\t// Disconnected nodes\n\t\tif ( compare & 1 ||\n\t\t\t(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {\n\n\t\t\t// Choose the first element that is related to our preferred document\n\t\t\tif ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// Maintain original order\n\t\t\treturn sortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\t\t}\n\n\t\treturn compare & 4 ? -1 : 1;\n\t} :\n\tfunction( a, b ) {\n\t\t// Exit early if the nodes are identical\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\taup = a.parentNode,\n\t\t\tbup = b.parentNode,\n\t\t\tap = [ a ],\n\t\t\tbp = [ b ];\n\n\t\t// Parentless nodes are either documents or disconnected\n\t\tif ( !aup || !bup ) {\n\t\t\treturn a === document ? -1 :\n\t\t\t\tb === document ? 1 :\n\t\t\t\taup ? -1 :\n\t\t\t\tbup ? 1 :\n\t\t\t\tsortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\n\t\t// If the nodes are siblings, we can do a quick check\n\t\t} else if ( aup === bup ) {\n\t\t\treturn siblingCheck( a, b );\n\t\t}\n\n\t\t// Otherwise we need full lists of their ancestors for comparison\n\t\tcur = a;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tap.unshift( cur );\n\t\t}\n\t\tcur = b;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tbp.unshift( cur );\n\t\t}\n\n\t\t// Walk down the tree looking for a discrepancy\n\t\twhile ( ap[i] === bp[i] ) {\n\t\t\ti++;\n\t\t}\n\n\t\treturn i ?\n\t\t\t// Do a sibling check if the nodes have a common ancestor\n\t\t\tsiblingCheck( ap[i], bp[i] ) :\n\n\t\t\t// Otherwise nodes in our document sort first\n\t\t\tap[i] === preferredDoc ? -1 :\n\t\t\tbp[i] === preferredDoc ? 1 :\n\t\t\t0;\n\t};\n\n\treturn document;\n};\n\nSizzle.matches = function( expr, elements ) {\n\treturn Sizzle( expr, null, null, elements );\n};\n\nSizzle.matchesSelector = function( elem, expr ) {\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\t// Make sure that attribute selectors are quoted\n\texpr = expr.replace( rattributeQuotes, \"='$1']\" );\n\n\tif ( support.matchesSelector && documentIsHTML &&\n\t\t!compilerCache[ expr + \" \" ] &&\n\t\t( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&\n\t\t( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {\n\n\t\ttry {\n\t\t\tvar ret = matches.call( elem, expr );\n\n\t\t\t// IE 9's matchesSelector returns false on disconnected nodes\n\t\t\tif ( ret || support.disconnectedMatch ||\n\t\t\t\t\t// As well, disconnected nodes are said to be in a document\n\t\t\t\t\t// fragment in IE 9\n\t\t\t\t\telem.document && elem.document.nodeType !== 11 ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} catch (e) {}\n\t}\n\n\treturn Sizzle( expr, document, null, [ elem ] ).length > 0;\n};\n\nSizzle.contains = function( context, elem ) {\n\t// Set document vars if needed\n\tif ( ( context.ownerDocument || context ) !== document ) {\n\t\tsetDocument( context );\n\t}\n\treturn contains( context, elem );\n};\n\nSizzle.attr = function( elem, name ) {\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\tvar fn = Expr.attrHandle[ name.toLowerCase() ],\n\t\t// Don't get fooled by Object.prototype properties (jQuery #13807)\n\t\tval = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?\n\t\t\tfn( elem, name, !documentIsHTML ) :\n\t\t\tundefined;\n\n\treturn val !== undefined ?\n\t\tval :\n\t\tsupport.attributes || !documentIsHTML ?\n\t\t\telem.getAttribute( name ) :\n\t\t\t(val = elem.getAttributeNode(name)) && val.specified ?\n\t\t\t\tval.value :\n\t\t\t\tnull;\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n/**\n * Document sorting and removing duplicates\n * @param {ArrayLike} results\n */\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {\n\t\twhile ( (elem = results[i++]) ) {\n\t\t\tif ( elem === results[ i ] ) {\n\t\t\t\tj = duplicates.push( i );\n\t\t\t}\n\t\t}\n\t\twhile ( j-- ) {\n\t\t\tresults.splice( duplicates[ j ], 1 );\n\t\t}\n\t}\n\n\t// Clear input after sorting to release objects\n\t// See https://github.com/jquery/sizzle/pull/225\n\tsortInput = null;\n\n\treturn results;\n};\n\n/**\n * Utility function for retrieving the text value of an array of DOM nodes\n * @param {Array|Element} elem\n */\ngetText = Sizzle.getText = function( elem ) {\n\tvar node,\n\t\tret = \"\",\n\t\ti = 0,\n\t\tnodeType = elem.nodeType;\n\n\tif ( !nodeType ) {\n\t\t// If no nodeType, this is expected to be an array\n\t\twhile ( (node = elem[i++]) ) {\n\t\t\t// Do not traverse comment nodes\n\t\t\tret += getText( node );\n\t\t}\n\t} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {\n\t\t// Use textContent for elements\n\t\t// innerText usage removed for consistency of new lines (jQuery #11153)\n\t\tif ( typeof elem.textContent === \"string\" ) {\n\t\t\treturn elem.textContent;\n\t\t} else {\n\t\t\t// Traverse its children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tret += getText( elem );\n\t\t\t}\n\t\t}\n\t} else if ( nodeType === 3 || nodeType === 4 ) {\n\t\treturn elem.nodeValue;\n\t}\n\t// Do not include comment or processing instruction nodes\n\n\treturn ret;\n};\n\nExpr = Sizzle.selectors = {\n\n\t// Can be adjusted by the user\n\tcacheLength: 50,\n\n\tcreatePseudo: markFunction,\n\n\tmatch: matchExpr,\n\n\tattrHandle: {},\n\n\tfind: {},\n\n\trelative: {\n\t\t\">\": { dir: \"parentNode\", first: true },\n\t\t\" \": { dir: \"parentNode\" },\n\t\t\"+\": { dir: \"previousSibling\", first: true },\n\t\t\"~\": { dir: \"previousSibling\" }\n\t},\n\n\tpreFilter: {\n\t\t\"ATTR\": function( match ) {\n\t\t\tmatch[1] = match[1].replace( runescape, funescape );\n\n\t\t\t// Move the given value to match[3] whether quoted or unquoted\n\t\t\tmatch[3] = ( match[3] || match[4] || match[5] || \"\" ).replace( runescape, funescape );\n\n\t\t\tif ( match[2] === \"~=\" ) {\n\t\t\t\tmatch[3] = \" \" + match[3] + \" \";\n\t\t\t}\n\n\t\t\treturn match.slice( 0, 4 );\n\t\t},\n\n\t\t\"CHILD\": function( match ) {\n\t\t\t/* matches from matchExpr[\"CHILD\"]\n\t\t\t\t1 type (only|nth|...)\n\t\t\t\t2 what (child|of-type)\n\t\t\t\t3 argument (even|odd|\\d*|\\d*n([+-]\\d+)?|...)\n\t\t\t\t4 xn-component of xn+y argument ([+-]?\\d*n|)\n\t\t\t\t5 sign of xn-component\n\t\t\t\t6 x of xn-component\n\t\t\t\t7 sign of y-component\n\t\t\t\t8 y of y-component\n\t\t\t*/\n\t\t\tmatch[1] = match[1].toLowerCase();\n\n\t\t\tif ( match[1].slice( 0, 3 ) === \"nth\" ) {\n\t\t\t\t// nth-* requires argument\n\t\t\t\tif ( !match[3] ) {\n\t\t\t\t\tSizzle.error( match[0] );\n\t\t\t\t}\n\n\t\t\t\t// numeric x and y parameters for Expr.filter.CHILD\n\t\t\t\t// remember that false/true cast respectively to 0/1\n\t\t\t\tmatch[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === \"even\" || match[3] === \"odd\" ) );\n\t\t\t\tmatch[5] = +( ( match[7] + match[8] ) || match[3] === \"odd\" );\n\n\t\t\t// other types prohibit arguments\n\t\t\t} else if ( match[3] ) {\n\t\t\t\tSizzle.error( match[0] );\n\t\t\t}\n\n\t\t\treturn match;\n\t\t},\n\n\t\t\"PSEUDO\": function( match ) {\n\t\t\tvar excess,\n\t\t\t\tunquoted = !match[6] && match[2];\n\n\t\t\tif ( matchExpr[\"CHILD\"].test( match[0] ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Accept quoted arguments as-is\n\t\t\tif ( match[3] ) {\n\t\t\t\tmatch[2] = match[4] || match[5] || \"\";\n\n\t\t\t// Strip excess characters from unquoted arguments\n\t\t\t} else if ( unquoted && rpseudo.test( unquoted ) &&\n\t\t\t\t// Get excess from tokenize (recursively)\n\t\t\t\t(excess = tokenize( unquoted, true )) &&\n\t\t\t\t// advance to the next closing parenthesis\n\t\t\t\t(excess = unquoted.indexOf( \")\", unquoted.length - excess ) - unquoted.length) ) {\n\n\t\t\t\t// excess is a negative index\n\t\t\t\tmatch[0] = match[0].slice( 0, excess );\n\t\t\t\tmatch[2] = unquoted.slice( 0, excess );\n\t\t\t}\n\n\t\t\t// Return only captures needed by the pseudo filter method (type and argument)\n\t\t\treturn match.slice( 0, 3 );\n\t\t}\n\t},\n\n\tfilter: {\n\n\t\t\"TAG\": function( nodeNameSelector ) {\n\t\t\tvar nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn nodeNameSelector === \"*\" ?\n\t\t\t\tfunction() { return true; } :\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\n\t\t\t\t};\n\t\t},\n\n\t\t\"CLASS\": function( className ) {\n\t\t\tvar pattern = classCache[ className + \" \" ];\n\n\t\t\treturn pattern ||\n\t\t\t\t(pattern = new RegExp( \"(^|\" + whitespace + \")\" + className + \"(\" + whitespace + \"|$)\" )) &&\n\t\t\t\tclassCache( className, function( elem ) {\n\t\t\t\t\treturn pattern.test( typeof elem.className === \"string\" && elem.className || typeof elem.getAttribute !== \"undefined\" && elem.getAttribute(\"class\") || \"\" );\n\t\t\t\t});\n\t\t},\n\n\t\t\"ATTR\": function( name, operator, check ) {\n\t\t\treturn function( elem ) {\n\t\t\t\tvar result = Sizzle.attr( elem, name );\n\n\t\t\t\tif ( result == null ) {\n\t\t\t\t\treturn operator === \"!=\";\n\t\t\t\t}\n\t\t\t\tif ( !operator ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tresult += \"\";\n\n\t\t\t\treturn operator === \"=\" ? result === check :\n\t\t\t\t\toperator === \"!=\" ? result !== check :\n\t\t\t\t\toperator === \"^=\" ? check && result.indexOf( check ) === 0 :\n\t\t\t\t\toperator === \"*=\" ? check && result.indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"$=\" ? check && result.slice( -check.length ) === check :\n\t\t\t\t\toperator === \"~=\" ? ( \" \" + result.replace( rwhitespace, \" \" ) + \" \" ).indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"|=\" ? result === check || result.slice( 0, check.length + 1 ) === check + \"-\" :\n\t\t\t\t\tfalse;\n\t\t\t};\n\t\t},\n\n\t\t\"CHILD\": function( type, what, argument, first, last ) {\n\t\t\tvar simple = type.slice( 0, 3 ) !== \"nth\",\n\t\t\t\tforward = type.slice( -4 ) !== \"last\",\n\t\t\t\tofType = what === \"of-type\";\n\n\t\t\treturn first === 1 && last === 0 ?\n\n\t\t\t\t// Shortcut for :nth-*(n)\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn !!elem.parentNode;\n\t\t\t\t} :\n\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tvar cache, uniqueCache, outerCache, node, nodeIndex, start,\n\t\t\t\t\t\tdir = simple !== forward ? \"nextSibling\" : \"previousSibling\",\n\t\t\t\t\t\tparent = elem.parentNode,\n\t\t\t\t\t\tname = ofType && elem.nodeName.toLowerCase(),\n\t\t\t\t\t\tuseCache = !xml && !ofType,\n\t\t\t\t\t\tdiff = false;\n\n\t\t\t\t\tif ( parent ) {\n\n\t\t\t\t\t\t// :(first|last|only)-(child|of-type)\n\t\t\t\t\t\tif ( simple ) {\n\t\t\t\t\t\t\twhile ( dir ) {\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\twhile ( (node = node[ dir ]) ) {\n\t\t\t\t\t\t\t\t\tif ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) {\n\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Reverse direction for :only-* (if we haven't yet done so)\n\t\t\t\t\t\t\t\tstart = dir = type === \"only\" && !start && \"nextSibling\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstart = [ forward ? parent.firstChild : parent.lastChild ];\n\n\t\t\t\t\t\t// non-xml :nth-child(...) stores cache data on `parent`\n\t\t\t\t\t\tif ( forward && useCache ) {\n\n\t\t\t\t\t\t\t// Seek `elem` from a previously-cached index\n\n\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\tnode = parent;\n\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\tdiff = nodeIndex && cache[ 2 ];\n\t\t\t\t\t\t\tnode = nodeIndex && parent.childNodes[ nodeIndex ];\n\n\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\n\t\t\t\t\t\t\t\t// Fallback to seeking `elem` from the start\n\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\t// When found, cache indexes on `parent` and break\n\t\t\t\t\t\t\t\tif ( node.nodeType === 1 && ++diff && node === elem ) {\n\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, nodeIndex, diff ];\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Use previously-cached element index if available\n\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\t\tdiff = nodeIndex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// xml :nth-child(...)\n\t\t\t\t\t\t\t// or :nth-last-child(...) or :nth(-last)?-of-type(...)\n\t\t\t\t\t\t\tif ( diff === false ) {\n\t\t\t\t\t\t\t\t// Use the same loop as above to seek `elem` from the start\n\t\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\t\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\t\tif ( ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) &&\n\t\t\t\t\t\t\t\t\t\t++diff ) {\n\n\t\t\t\t\t\t\t\t\t\t// Cache the index of each encountered element\n\t\t\t\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, diff ];\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif ( node === elem ) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Incorporate the offset, then check against cycle size\n\t\t\t\t\t\tdiff -= last;\n\t\t\t\t\t\treturn diff === first || ( diff % first === 0 && diff / first >= 0 );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t},\n\n\t\t\"PSEUDO\": function( pseudo, argument ) {\n\t\t\t// pseudo-class names are case-insensitive\n\t\t\t// http://www.w3.org/TR/selectors/#pseudo-classes\n\t\t\t// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters\n\t\t\t// Remember that setFilters inherits from pseudos\n\t\t\tvar args,\n\t\t\t\tfn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||\n\t\t\t\t\tSizzle.error( \"unsupported pseudo: \" + pseudo );\n\n\t\t\t// The user may use createPseudo to indicate that\n\t\t\t// arguments are needed to create the filter function\n\t\t\t// just as Sizzle does\n\t\t\tif ( fn[ expando ] ) {\n\t\t\t\treturn fn( argument );\n\t\t\t}\n\n\t\t\t// But maintain support for old signatures\n\t\t\tif ( fn.length > 1 ) {\n\t\t\t\targs = [ pseudo, pseudo, \"\", argument ];\n\t\t\t\treturn Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?\n\t\t\t\t\tmarkFunction(function( seed, matches ) {\n\t\t\t\t\t\tvar idx,\n\t\t\t\t\t\t\tmatched = fn( seed, argument ),\n\t\t\t\t\t\t\ti = matched.length;\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tidx = indexOf( seed, matched[i] );\n\t\t\t\t\t\t\tseed[ idx ] = !( matches[ idx ] = matched[i] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}) :\n\t\t\t\t\tfunction( elem ) {\n\t\t\t\t\t\treturn fn( elem, 0, args );\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn fn;\n\t\t}\n\t},\n\n\tpseudos: {\n\t\t// Potentially complex pseudos\n\t\t\"not\": markFunction(function( selector ) {\n\t\t\t// Trim the selector passed to compile\n\t\t\t// to avoid treating leading and trailing\n\t\t\t// spaces as combinators\n\t\t\tvar input = [],\n\t\t\t\tresults = [],\n\t\t\t\tmatcher = compile( selector.replace( rtrim, \"$1\" ) );\n\n\t\t\treturn matcher[ expando ] ?\n\t\t\t\tmarkFunction(function( seed, matches, context, xml ) {\n\t\t\t\t\tvar elem,\n\t\t\t\t\t\tunmatched = matcher( seed, null, xml, [] ),\n\t\t\t\t\t\ti = seed.length;\n\n\t\t\t\t\t// Match elements unmatched by `matcher`\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = unmatched[i]) ) {\n\t\t\t\t\t\t\tseed[i] = !(matches[i] = elem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}) :\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tinput[0] = elem;\n\t\t\t\t\tmatcher( input, null, xml, results );\n\t\t\t\t\t// Don't keep the element (issue #299)\n\t\t\t\t\tinput[0] = null;\n\t\t\t\t\treturn !results.pop();\n\t\t\t\t};\n\t\t}),\n\n\t\t\"has\": markFunction(function( selector ) {\n\t\t\treturn function( elem ) {\n\t\t\t\treturn Sizzle( selector, elem ).length > 0;\n\t\t\t};\n\t\t}),\n\n\t\t\"contains\": markFunction(function( text ) {\n\t\t\ttext = text.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;\n\t\t\t};\n\t\t}),\n\n\t\t// \"Whether an element is represented by a :lang() selector\n\t\t// is based solely on the element's language value\n\t\t// being equal to the identifier C,\n\t\t// or beginning with the identifier C immediately followed by \"-\".\n\t\t// The matching of C against the element's language value is performed case-insensitively.\n\t\t// The identifier C does not have to be a valid language name.\"\n\t\t// http://www.w3.org/TR/selectors/#lang-pseudo\n\t\t\"lang\": markFunction( function( lang ) {\n\t\t\t// lang value must be a valid identifier\n\t\t\tif ( !ridentifier.test(lang || \"\") ) {\n\t\t\t\tSizzle.error( \"unsupported lang: \" + lang );\n\t\t\t}\n\t\t\tlang = lang.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn function( elem ) {\n\t\t\t\tvar elemLang;\n\t\t\t\tdo {\n\t\t\t\t\tif ( (elemLang = documentIsHTML ?\n\t\t\t\t\t\telem.lang :\n\t\t\t\t\t\telem.getAttribute(\"xml:lang\") || elem.getAttribute(\"lang\")) ) {\n\n\t\t\t\t\t\telemLang = elemLang.toLowerCase();\n\t\t\t\t\t\treturn elemLang === lang || elemLang.indexOf( lang + \"-\" ) === 0;\n\t\t\t\t\t}\n\t\t\t\t} while ( (elem = elem.parentNode) && elem.nodeType === 1 );\n\t\t\t\treturn false;\n\t\t\t};\n\t\t}),\n\n\t\t// Miscellaneous\n\t\t\"target\": function( elem ) {\n\t\t\tvar hash = window.location && window.location.hash;\n\t\t\treturn hash && hash.slice( 1 ) === elem.id;\n\t\t},\n\n\t\t\"root\": function( elem ) {\n\t\t\treturn elem === docElem;\n\t\t},\n\n\t\t\"focus\": function( elem ) {\n\t\t\treturn elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);\n\t\t},\n\n\t\t// Boolean properties\n\t\t\"enabled\": function( elem ) {\n\t\t\treturn elem.disabled === false;\n\t\t},\n\n\t\t\"disabled\": function( elem ) {\n\t\t\treturn elem.disabled === true;\n\t\t},\n\n\t\t\"checked\": function( elem ) {\n\t\t\t// In CSS3, :checked should return both checked and selected elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\tvar nodeName = elem.nodeName.toLowerCase();\n\t\t\treturn (nodeName === \"input\" && !!elem.checked) || (nodeName === \"option\" && !!elem.selected);\n\t\t},\n\n\t\t\"selected\": function( elem ) {\n\t\t\t// Accessing this property makes selected-by-default\n\t\t\t// options in Safari work properly\n\t\t\tif ( elem.parentNode ) {\n\t\t\t\telem.parentNode.selectedIndex;\n\t\t\t}\n\n\t\t\treturn elem.selected === true;\n\t\t},\n\n\t\t// Contents\n\t\t\"empty\": function( elem ) {\n\t\t\t// http://www.w3.org/TR/selectors/#empty-pseudo\n\t\t\t// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),\n\t\t\t//   but not by others (comment: 8; processing instruction: 7; etc.)\n\t\t\t// nodeType < 6 works because attributes (2) do not appear as children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tif ( elem.nodeType < 6 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\n\t\t\"parent\": function( elem ) {\n\t\t\treturn !Expr.pseudos[\"empty\"]( elem );\n\t\t},\n\n\t\t// Element/input types\n\t\t\"header\": function( elem ) {\n\t\t\treturn rheader.test( elem.nodeName );\n\t\t},\n\n\t\t\"input\": function( elem ) {\n\t\t\treturn rinputs.test( elem.nodeName );\n\t\t},\n\n\t\t\"button\": function( elem ) {\n\t\t\tvar name = elem.nodeName.toLowerCase();\n\t\t\treturn name === \"input\" && elem.type === \"button\" || name === \"button\";\n\t\t},\n\n\t\t\"text\": function( elem ) {\n\t\t\tvar attr;\n\t\t\treturn elem.nodeName.toLowerCase() === \"input\" &&\n\t\t\t\telem.type === \"text\" &&\n\n\t\t\t\t// Support: IE<8\n\t\t\t\t// New HTML5 attribute values (e.g., \"search\") appear with elem.type === \"text\"\n\t\t\t\t( (attr = elem.getAttribute(\"type\")) == null || attr.toLowerCase() === \"text\" );\n\t\t},\n\n\t\t// Position-in-collection\n\t\t\"first\": createPositionalPseudo(function() {\n\t\t\treturn [ 0 ];\n\t\t}),\n\n\t\t\"last\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\treturn [ length - 1 ];\n\t\t}),\n\n\t\t\"eq\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\treturn [ argument < 0 ? argument + length : argument ];\n\t\t}),\n\n\t\t\"even\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"odd\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 1;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"lt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; --i >= 0; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"gt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; ++i < length; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t})\n\t}\n};\n\nExpr.pseudos[\"nth\"] = Expr.pseudos[\"eq\"];\n\n// Add button/input type pseudos\nfor ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {\n\tExpr.pseudos[ i ] = createInputPseudo( i );\n}\nfor ( i in { submit: true, reset: true } ) {\n\tExpr.pseudos[ i ] = createButtonPseudo( i );\n}\n\n// Easy API for creating new setFilters\nfunction setFilters() {}\nsetFilters.prototype = Expr.filters = Expr.pseudos;\nExpr.setFilters = new setFilters();\n\ntokenize = Sizzle.tokenize = function( selector, parseOnly ) {\n\tvar matched, match, tokens, type,\n\t\tsoFar, groups, preFilters,\n\t\tcached = tokenCache[ selector + \" \" ];\n\n\tif ( cached ) {\n\t\treturn parseOnly ? 0 : cached.slice( 0 );\n\t}\n\n\tsoFar = selector;\n\tgroups = [];\n\tpreFilters = Expr.preFilter;\n\n\twhile ( soFar ) {\n\n\t\t// Comma and first run\n\t\tif ( !matched || (match = rcomma.exec( soFar )) ) {\n\t\t\tif ( match ) {\n\t\t\t\t// Don't consume trailing commas as valid\n\t\t\t\tsoFar = soFar.slice( match[0].length ) || soFar;\n\t\t\t}\n\t\t\tgroups.push( (tokens = []) );\n\t\t}\n\n\t\tmatched = false;\n\n\t\t// Combinators\n\t\tif ( (match = rcombinators.exec( soFar )) ) {\n\t\t\tmatched = match.shift();\n\t\t\ttokens.push({\n\t\t\t\tvalue: matched,\n\t\t\t\t// Cast descendant combinators to space\n\t\t\t\ttype: match[0].replace( rtrim, \" \" )\n\t\t\t});\n\t\t\tsoFar = soFar.slice( matched.length );\n\t\t}\n\n\t\t// Filters\n\t\tfor ( type in Expr.filter ) {\n\t\t\tif ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||\n\t\t\t\t(match = preFilters[ type ]( match ))) ) {\n\t\t\t\tmatched = match.shift();\n\t\t\t\ttokens.push({\n\t\t\t\t\tvalue: matched,\n\t\t\t\t\ttype: type,\n\t\t\t\t\tmatches: match\n\t\t\t\t});\n\t\t\t\tsoFar = soFar.slice( matched.length );\n\t\t\t}\n\t\t}\n\n\t\tif ( !matched ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Return the length of the invalid excess\n\t// if we're just parsing\n\t// Otherwise, throw an error or return tokens\n\treturn parseOnly ?\n\t\tsoFar.length :\n\t\tsoFar ?\n\t\t\tSizzle.error( selector ) :\n\t\t\t// Cache the tokens\n\t\t\ttokenCache( selector, groups ).slice( 0 );\n};\n\nfunction toSelector( tokens ) {\n\tvar i = 0,\n\t\tlen = tokens.length,\n\t\tselector = \"\";\n\tfor ( ; i < len; i++ ) {\n\t\tselector += tokens[i].value;\n\t}\n\treturn selector;\n}\n\nfunction addCombinator( matcher, combinator, base ) {\n\tvar dir = combinator.dir,\n\t\tcheckNonElements = base && dir === \"parentNode\",\n\t\tdoneName = done++;\n\n\treturn combinator.first ?\n\t\t// Check against closest ancestor/preceding element\n\t\tfunction( elem, context, xml ) {\n\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\treturn matcher( elem, context, xml );\n\t\t\t\t}\n\t\t\t}\n\t\t} :\n\n\t\t// Check against all ancestor/preceding elements\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar oldCache, uniqueCache, outerCache,\n\t\t\t\tnewCache = [ dirruns, doneName ];\n\n\t\t\t// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching\n\t\t\tif ( xml ) {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\tif ( matcher( elem, context, xml ) ) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\touterCache = elem[ expando ] || (elem[ expando ] = {});\n\n\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\tuniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});\n\n\t\t\t\t\t\tif ( (oldCache = uniqueCache[ dir ]) &&\n\t\t\t\t\t\t\toldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {\n\n\t\t\t\t\t\t\t// Assign to newCache so results back-propagate to previous elements\n\t\t\t\t\t\t\treturn (newCache[ 2 ] = oldCache[ 2 ]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Reuse newcache so results back-propagate to previous elements\n\t\t\t\t\t\t\tuniqueCache[ dir ] = newCache;\n\n\t\t\t\t\t\t\t// A match means we're done; a fail means we have to keep checking\n\t\t\t\t\t\t\tif ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n}\n\nfunction elementMatcher( matchers ) {\n\treturn matchers.length > 1 ?\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar i = matchers.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( !matchers[i]( elem, context, xml ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t} :\n\t\tmatchers[0];\n}\n\nfunction multipleContexts( selector, contexts, results ) {\n\tvar i = 0,\n\t\tlen = contexts.length;\n\tfor ( ; i < len; i++ ) {\n\t\tSizzle( selector, contexts[i], results );\n\t}\n\treturn results;\n}\n\nfunction condense( unmatched, map, filter, context, xml ) {\n\tvar elem,\n\t\tnewUnmatched = [],\n\t\ti = 0,\n\t\tlen = unmatched.length,\n\t\tmapped = map != null;\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (elem = unmatched[i]) ) {\n\t\t\tif ( !filter || filter( elem, context, xml ) ) {\n\t\t\t\tnewUnmatched.push( elem );\n\t\t\t\tif ( mapped ) {\n\t\t\t\t\tmap.push( i );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn newUnmatched;\n}\n\nfunction setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {\n\tif ( postFilter && !postFilter[ expando ] ) {\n\t\tpostFilter = setMatcher( postFilter );\n\t}\n\tif ( postFinder && !postFinder[ expando ] ) {\n\t\tpostFinder = setMatcher( postFinder, postSelector );\n\t}\n\treturn markFunction(function( seed, results, context, xml ) {\n\t\tvar temp, i, elem,\n\t\t\tpreMap = [],\n\t\t\tpostMap = [],\n\t\t\tpreexisting = results.length,\n\n\t\t\t// Get initial elements from seed or context\n\t\t\telems = seed || multipleContexts( selector || \"*\", context.nodeType ? [ context ] : context, [] ),\n\n\t\t\t// Prefilter to get matcher input, preserving a map for seed-results synchronization\n\t\t\tmatcherIn = preFilter && ( seed || !selector ) ?\n\t\t\t\tcondense( elems, preMap, preFilter, context, xml ) :\n\t\t\t\telems,\n\n\t\t\tmatcherOut = matcher ?\n\t\t\t\t// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,\n\t\t\t\tpostFinder || ( seed ? preFilter : preexisting || postFilter ) ?\n\n\t\t\t\t\t// ...intermediate processing is necessary\n\t\t\t\t\t[] :\n\n\t\t\t\t\t// ...otherwise use results directly\n\t\t\t\t\tresults :\n\t\t\t\tmatcherIn;\n\n\t\t// Find primary matches\n\t\tif ( matcher ) {\n\t\t\tmatcher( matcherIn, matcherOut, context, xml );\n\t\t}\n\n\t\t// Apply postFilter\n\t\tif ( postFilter ) {\n\t\t\ttemp = condense( matcherOut, postMap );\n\t\t\tpostFilter( temp, [], context, xml );\n\n\t\t\t// Un-match failing elements by moving them back to matcherIn\n\t\t\ti = temp.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( (elem = temp[i]) ) {\n\t\t\t\t\tmatcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( seed ) {\n\t\t\tif ( postFinder || preFilter ) {\n\t\t\t\tif ( postFinder ) {\n\t\t\t\t\t// Get the final matcherOut by condensing this intermediate into postFinder contexts\n\t\t\t\t\ttemp = [];\n\t\t\t\t\ti = matcherOut.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = matcherOut[i]) ) {\n\t\t\t\t\t\t\t// Restore matcherIn since elem is not yet a final match\n\t\t\t\t\t\t\ttemp.push( (matcherIn[i] = elem) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpostFinder( null, (matcherOut = []), temp, xml );\n\t\t\t\t}\n\n\t\t\t\t// Move matched elements from seed to results to keep them synchronized\n\t\t\t\ti = matcherOut.length;\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tif ( (elem = matcherOut[i]) &&\n\t\t\t\t\t\t(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {\n\n\t\t\t\t\t\tseed[temp] = !(results[temp] = elem);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Add elements to results, through postFinder if defined\n\t\t} else {\n\t\t\tmatcherOut = condense(\n\t\t\t\tmatcherOut === results ?\n\t\t\t\t\tmatcherOut.splice( preexisting, matcherOut.length ) :\n\t\t\t\t\tmatcherOut\n\t\t\t);\n\t\t\tif ( postFinder ) {\n\t\t\t\tpostFinder( null, results, matcherOut, xml );\n\t\t\t} else {\n\t\t\t\tpush.apply( results, matcherOut );\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction matcherFromTokens( tokens ) {\n\tvar checkContext, matcher, j,\n\t\tlen = tokens.length,\n\t\tleadingRelative = Expr.relative[ tokens[0].type ],\n\t\timplicitRelative = leadingRelative || Expr.relative[\" \"],\n\t\ti = leadingRelative ? 1 : 0,\n\n\t\t// The foundational matcher ensures that elements are reachable from top-level context(s)\n\t\tmatchContext = addCombinator( function( elem ) {\n\t\t\treturn elem === checkContext;\n\t\t}, implicitRelative, true ),\n\t\tmatchAnyContext = addCombinator( function( elem ) {\n\t\t\treturn indexOf( checkContext, elem ) > -1;\n\t\t}, implicitRelative, true ),\n\t\tmatchers = [ function( elem, context, xml ) {\n\t\t\tvar ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (\n\t\t\t\t(checkContext = context).nodeType ?\n\t\t\t\t\tmatchContext( elem, context, xml ) :\n\t\t\t\t\tmatchAnyContext( elem, context, xml ) );\n\t\t\t// Avoid hanging onto element (issue #299)\n\t\t\tcheckContext = null;\n\t\t\treturn ret;\n\t\t} ];\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (matcher = Expr.relative[ tokens[i].type ]) ) {\n\t\t\tmatchers = [ addCombinator(elementMatcher( matchers ), matcher) ];\n\t\t} else {\n\t\t\tmatcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );\n\n\t\t\t// Return special upon seeing a positional matcher\n\t\t\tif ( matcher[ expando ] ) {\n\t\t\t\t// Find the next relative operator (if any) for proper handling\n\t\t\t\tj = ++i;\n\t\t\t\tfor ( ; j < len; j++ ) {\n\t\t\t\t\tif ( Expr.relative[ tokens[j].type ] ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn setMatcher(\n\t\t\t\t\ti > 1 && elementMatcher( matchers ),\n\t\t\t\t\ti > 1 && toSelector(\n\t\t\t\t\t\t// If the preceding token was a descendant combinator, insert an implicit any-element `*`\n\t\t\t\t\t\ttokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === \" \" ? \"*\" : \"\" })\n\t\t\t\t\t).replace( rtrim, \"$1\" ),\n\t\t\t\t\tmatcher,\n\t\t\t\t\ti < j && matcherFromTokens( tokens.slice( i, j ) ),\n\t\t\t\t\tj < len && matcherFromTokens( (tokens = tokens.slice( j )) ),\n\t\t\t\t\tj < len && toSelector( tokens )\n\t\t\t\t);\n\t\t\t}\n\t\t\tmatchers.push( matcher );\n\t\t}\n\t}\n\n\treturn elementMatcher( matchers );\n}\n\nfunction matcherFromGroupMatchers( elementMatchers, setMatchers ) {\n\tvar bySet = setMatchers.length > 0,\n\t\tbyElement = elementMatchers.length > 0,\n\t\tsuperMatcher = function( seed, context, xml, results, outermost ) {\n\t\t\tvar elem, j, matcher,\n\t\t\t\tmatchedCount = 0,\n\t\t\t\ti = \"0\",\n\t\t\t\tunmatched = seed && [],\n\t\t\t\tsetMatched = [],\n\t\t\t\tcontextBackup = outermostContext,\n\t\t\t\t// We must always have either seed elements or outermost context\n\t\t\t\telems = seed || byElement && Expr.find[\"TAG\"]( \"*\", outermost ),\n\t\t\t\t// Use integer dirruns iff this is the outermost matcher\n\t\t\t\tdirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),\n\t\t\t\tlen = elems.length;\n\n\t\t\tif ( outermost ) {\n\t\t\t\toutermostContext = context === document || context || outermost;\n\t\t\t}\n\n\t\t\t// Add elements passing elementMatchers directly to results\n\t\t\t// Support: IE<9, Safari\n\t\t\t// Tolerate NodeList properties (IE: \"length\"; Safari: <number>) matching elements by id\n\t\t\tfor ( ; i !== len && (elem = elems[i]) != null; i++ ) {\n\t\t\t\tif ( byElement && elem ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\tif ( !context && elem.ownerDocument !== document ) {\n\t\t\t\t\t\tsetDocument( elem );\n\t\t\t\t\t\txml = !documentIsHTML;\n\t\t\t\t\t}\n\t\t\t\t\twhile ( (matcher = elementMatchers[j++]) ) {\n\t\t\t\t\t\tif ( matcher( elem, context || document, xml) ) {\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( outermost ) {\n\t\t\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Track unmatched elements for set filters\n\t\t\t\tif ( bySet ) {\n\t\t\t\t\t// They will have gone through all possible matchers\n\t\t\t\t\tif ( (elem = !matcher && elem) ) {\n\t\t\t\t\t\tmatchedCount--;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Lengthen the array for every element, matched or not\n\t\t\t\t\tif ( seed ) {\n\t\t\t\t\t\tunmatched.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// `i` is now the count of elements visited above, and adding it to `matchedCount`\n\t\t\t// makes the latter nonnegative.\n\t\t\tmatchedCount += i;\n\n\t\t\t// Apply set filters to unmatched elements\n\t\t\t// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`\n\t\t\t// equals `i`), unless we didn't visit _any_ elements in the above loop because we have\n\t\t\t// no element matchers and no seed.\n\t\t\t// Incrementing an initially-string \"0\" `i` allows `i` to remain a string only in that\n\t\t\t// case, which will result in a \"00\" `matchedCount` that differs from `i` but is also\n\t\t\t// numerically zero.\n\t\t\tif ( bySet && i !== matchedCount ) {\n\t\t\t\tj = 0;\n\t\t\t\twhile ( (matcher = setMatchers[j++]) ) {\n\t\t\t\t\tmatcher( unmatched, setMatched, context, xml );\n\t\t\t\t}\n\n\t\t\t\tif ( seed ) {\n\t\t\t\t\t// Reintegrate element matches to eliminate the need for sorting\n\t\t\t\t\tif ( matchedCount > 0 ) {\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tif ( !(unmatched[i] || setMatched[i]) ) {\n\t\t\t\t\t\t\t\tsetMatched[i] = pop.call( results );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Discard index placeholder values to get only actual matches\n\t\t\t\t\tsetMatched = condense( setMatched );\n\t\t\t\t}\n\n\t\t\t\t// Add matches to results\n\t\t\t\tpush.apply( results, setMatched );\n\n\t\t\t\t// Seedless set matches succeeding multiple successful matchers stipulate sorting\n\t\t\t\tif ( outermost && !seed && setMatched.length > 0 &&\n\t\t\t\t\t( matchedCount + setMatchers.length ) > 1 ) {\n\n\t\t\t\t\tSizzle.uniqueSort( results );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Override manipulation of globals by nested matchers\n\t\t\tif ( outermost ) {\n\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\toutermostContext = contextBackup;\n\t\t\t}\n\n\t\t\treturn unmatched;\n\t\t};\n\n\treturn bySet ?\n\t\tmarkFunction( superMatcher ) :\n\t\tsuperMatcher;\n}\n\ncompile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {\n\tvar i,\n\t\tsetMatchers = [],\n\t\telementMatchers = [],\n\t\tcached = compilerCache[ selector + \" \" ];\n\n\tif ( !cached ) {\n\t\t// Generate a function of recursive functions that can be used to check each element\n\t\tif ( !match ) {\n\t\t\tmatch = tokenize( selector );\n\t\t}\n\t\ti = match.length;\n\t\twhile ( i-- ) {\n\t\t\tcached = matcherFromTokens( match[i] );\n\t\t\tif ( cached[ expando ] ) {\n\t\t\t\tsetMatchers.push( cached );\n\t\t\t} else {\n\t\t\t\telementMatchers.push( cached );\n\t\t\t}\n\t\t}\n\n\t\t// Cache the compiled function\n\t\tcached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );\n\n\t\t// Save selector and tokenization\n\t\tcached.selector = selector;\n\t}\n\treturn cached;\n};\n\n/**\n * A low-level selection function that works with Sizzle's compiled\n *  selector functions\n * @param {String|Function} selector A selector or a pre-compiled\n *  selector function built with Sizzle.compile\n * @param {Element} context\n * @param {Array} [results]\n * @param {Array} [seed] A set of elements to match against\n */\nselect = Sizzle.select = function( selector, context, results, seed ) {\n\tvar i, tokens, token, type, find,\n\t\tcompiled = typeof selector === \"function\" && selector,\n\t\tmatch = !seed && tokenize( (selector = compiled.selector || selector) );\n\n\tresults = results || [];\n\n\t// Try to minimize operations if there is only one selector in the list and no seed\n\t// (the latter of which guarantees us context)\n\tif ( match.length === 1 ) {\n\n\t\t// Reduce context if the leading compound selector is an ID\n\t\ttokens = match[0] = match[0].slice( 0 );\n\t\tif ( tokens.length > 2 && (token = tokens[0]).type === \"ID\" &&\n\t\t\t\tsupport.getById && context.nodeType === 9 && documentIsHTML &&\n\t\t\t\tExpr.relative[ tokens[1].type ] ) {\n\n\t\t\tcontext = ( Expr.find[\"ID\"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];\n\t\t\tif ( !context ) {\n\t\t\t\treturn results;\n\n\t\t\t// Precompiled matchers will still verify ancestry, so step up a level\n\t\t\t} else if ( compiled ) {\n\t\t\t\tcontext = context.parentNode;\n\t\t\t}\n\n\t\t\tselector = selector.slice( tokens.shift().value.length );\n\t\t}\n\n\t\t// Fetch a seed set for right-to-left matching\n\t\ti = matchExpr[\"needsContext\"].test( selector ) ? 0 : tokens.length;\n\t\twhile ( i-- ) {\n\t\t\ttoken = tokens[i];\n\n\t\t\t// Abort if we hit a combinator\n\t\t\tif ( Expr.relative[ (type = token.type) ] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( (find = Expr.find[ type ]) ) {\n\t\t\t\t// Search, expanding context for leading sibling combinators\n\t\t\t\tif ( (seed = find(\n\t\t\t\t\ttoken.matches[0].replace( runescape, funescape ),\n\t\t\t\t\trsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context\n\t\t\t\t)) ) {\n\n\t\t\t\t\t// If seed is empty or no tokens remain, we can return early\n\t\t\t\t\ttokens.splice( i, 1 );\n\t\t\t\t\tselector = seed.length && toSelector( tokens );\n\t\t\t\t\tif ( !selector ) {\n\t\t\t\t\t\tpush.apply( results, seed );\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compile and execute a filtering function if one is not provided\n\t// Provide `match` to avoid retokenization if we modified the selector above\n\t( compiled || compile( selector, match ) )(\n\t\tseed,\n\t\tcontext,\n\t\t!documentIsHTML,\n\t\tresults,\n\t\t!context || rsibling.test( selector ) && testContext( context.parentNode ) || context\n\t);\n\treturn results;\n};\n\n// One-time assignments\n\n// Sort stability\nsupport.sortStable = expando.split(\"\").sort( sortOrder ).join(\"\") === expando;\n\n// Support: Chrome 14-35+\n// Always assume duplicates if they aren't passed to the comparison function\nsupport.detectDuplicates = !!hasDuplicate;\n\n// Initialize against the default document\nsetDocument();\n\n// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)\n// Detached nodes confoundingly follow *each other*\nsupport.sortDetached = assert(function( div1 ) {\n\t// Should return 1, but returns 4 (following)\n\treturn div1.compareDocumentPosition( document.createElement(\"div\") ) & 1;\n});\n\n// Support: IE<8\n// Prevent attribute/property \"interpolation\"\n// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx\nif ( !assert(function( div ) {\n\tdiv.innerHTML = \"<a href='#'></a>\";\n\treturn div.firstChild.getAttribute(\"href\") === \"#\" ;\n}) ) {\n\taddHandle( \"type|href|height|width\", function( elem, name, isXML ) {\n\t\tif ( !isXML ) {\n\t\t\treturn elem.getAttribute( name, name.toLowerCase() === \"type\" ? 1 : 2 );\n\t\t}\n\t});\n}\n\n// Support: IE<9\n// Use defaultValue in place of getAttribute(\"value\")\nif ( !support.attributes || !assert(function( div ) {\n\tdiv.innerHTML = \"<input/>\";\n\tdiv.firstChild.setAttribute( \"value\", \"\" );\n\treturn div.firstChild.getAttribute( \"value\" ) === \"\";\n}) ) {\n\taddHandle( \"value\", function( elem, name, isXML ) {\n\t\tif ( !isXML && elem.nodeName.toLowerCase() === \"input\" ) {\n\t\t\treturn elem.defaultValue;\n\t\t}\n\t});\n}\n\n// Support: IE<9\n// Use getAttributeNode to fetch booleans when getAttribute lies\nif ( !assert(function( div ) {\n\treturn div.getAttribute(\"disabled\") == null;\n}) ) {\n\taddHandle( booleans, function( elem, name, isXML ) {\n\t\tvar val;\n\t\tif ( !isXML ) {\n\t\t\treturn elem[ name ] === true ? name.toLowerCase() :\n\t\t\t\t\t(val = elem.getAttributeNode( name )) && val.specified ?\n\t\t\t\t\tval.value :\n\t\t\t\tnull;\n\t\t}\n\t});\n}\n\nreturn Sizzle;\n\n})( window );\n\n\n\njQuery.find = Sizzle;\njQuery.expr = Sizzle.selectors;\njQuery.expr[ \":\" ] = jQuery.expr.pseudos;\njQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;\njQuery.text = Sizzle.getText;\njQuery.isXMLDoc = Sizzle.isXML;\njQuery.contains = Sizzle.contains;\n\n\n\nvar dir = function( elem, dir, until ) {\n\tvar matched = [],\n\t\ttruncate = until !== undefined;\n\n\twhile ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {\n\t\tif ( elem.nodeType === 1 ) {\n\t\t\tif ( truncate && jQuery( elem ).is( until ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmatched.push( elem );\n\t\t}\n\t}\n\treturn matched;\n};\n\n\nvar siblings = function( n, elem ) {\n\tvar matched = [];\n\n\tfor ( ; n; n = n.nextSibling ) {\n\t\tif ( n.nodeType === 1 && n !== elem ) {\n\t\t\tmatched.push( n );\n\t\t}\n\t}\n\n\treturn matched;\n};\n\n\nvar rneedsContext = jQuery.expr.match.needsContext;\n\nvar rsingleTag = ( /^<([\\w-]+)\\s*\\/?>(?:<\\/\\1>|)$/ );\n\n\n\nvar risSimple = /^.[^:#\\[\\.,]*$/;\n\n// Implement the identical functionality for filter and not\nfunction winnow( elements, qualifier, not ) {\n\tif ( jQuery.isFunction( qualifier ) ) {\n\t\treturn jQuery.grep( elements, function( elem, i ) {\n\t\t\t/* jshint -W018 */\n\t\t\treturn !!qualifier.call( elem, i, elem ) !== not;\n\t\t} );\n\n\t}\n\n\tif ( qualifier.nodeType ) {\n\t\treturn jQuery.grep( elements, function( elem ) {\n\t\t\treturn ( elem === qualifier ) !== not;\n\t\t} );\n\n\t}\n\n\tif ( typeof qualifier === \"string\" ) {\n\t\tif ( risSimple.test( qualifier ) ) {\n\t\t\treturn jQuery.filter( qualifier, elements, not );\n\t\t}\n\n\t\tqualifier = jQuery.filter( qualifier, elements );\n\t}\n\n\treturn jQuery.grep( elements, function( elem ) {\n\t\treturn ( indexOf.call( qualifier, elem ) > -1 ) !== not;\n\t} );\n}\n\njQuery.filter = function( expr, elems, not ) {\n\tvar elem = elems[ 0 ];\n\n\tif ( not ) {\n\t\texpr = \":not(\" + expr + \")\";\n\t}\n\n\treturn elems.length === 1 && elem.nodeType === 1 ?\n\t\tjQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :\n\t\tjQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {\n\t\t\treturn elem.nodeType === 1;\n\t\t} ) );\n};\n\njQuery.fn.extend( {\n\tfind: function( selector ) {\n\t\tvar i,\n\t\t\tlen = this.length,\n\t\t\tret = [],\n\t\t\tself = this;\n\n\t\tif ( typeof selector !== \"string\" ) {\n\t\t\treturn this.pushStack( jQuery( selector ).filter( function() {\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tif ( jQuery.contains( self[ i ], this ) ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ) );\n\t\t}\n\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tjQuery.find( selector, self[ i ], ret );\n\t\t}\n\n\t\t// Needed because $( selector, context ) becomes $( context ).find( selector )\n\t\tret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );\n\t\tret.selector = this.selector ? this.selector + \" \" + selector : selector;\n\t\treturn ret;\n\t},\n\tfilter: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], false ) );\n\t},\n\tnot: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], true ) );\n\t},\n\tis: function( selector ) {\n\t\treturn !!winnow(\n\t\t\tthis,\n\n\t\t\t// If this is a positional/relative selector, check membership in the returned set\n\t\t\t// so $(\"p:first\").is(\"p:last\") won't return true for a doc with two \"p\".\n\t\t\ttypeof selector === \"string\" && rneedsContext.test( selector ) ?\n\t\t\t\tjQuery( selector ) :\n\t\t\t\tselector || [],\n\t\t\tfalse\n\t\t).length;\n\t}\n} );\n\n\n// Initialize a jQuery object\n\n\n// A central reference to the root jQuery(document)\nvar rootjQuery,\n\n\t// A simple way to check for HTML strings\n\t// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)\n\t// Strict HTML recognition (#11290: must start with <)\n\trquickExpr = /^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]*))$/,\n\n\tinit = jQuery.fn.init = function( selector, context, root ) {\n\t\tvar match, elem;\n\n\t\t// HANDLE: $(\"\"), $(null), $(undefined), $(false)\n\t\tif ( !selector ) {\n\t\t\treturn this;\n\t\t}\n\n\t\t// Method init() accepts an alternate rootjQuery\n\t\t// so migrate can support jQuery.sub (gh-2101)\n\t\troot = root || rootjQuery;\n\n\t\t// Handle HTML strings\n\t\tif ( typeof selector === \"string\" ) {\n\t\t\tif ( selector[ 0 ] === \"<\" &&\n\t\t\t\tselector[ selector.length - 1 ] === \">\" &&\n\t\t\t\tselector.length >= 3 ) {\n\n\t\t\t\t// Assume that strings that start and end with <> are HTML and skip the regex check\n\t\t\t\tmatch = [ null, selector, null ];\n\n\t\t\t} else {\n\t\t\t\tmatch = rquickExpr.exec( selector );\n\t\t\t}\n\n\t\t\t// Match html or make sure no context is specified for #id\n\t\t\tif ( match && ( match[ 1 ] || !context ) ) {\n\n\t\t\t\t// HANDLE: $(html) -> $(array)\n\t\t\t\tif ( match[ 1 ] ) {\n\t\t\t\t\tcontext = context instanceof jQuery ? context[ 0 ] : context;\n\n\t\t\t\t\t// Option to run scripts is true for back-compat\n\t\t\t\t\t// Intentionally let the error be thrown if parseHTML is not present\n\t\t\t\t\tjQuery.merge( this, jQuery.parseHTML(\n\t\t\t\t\t\tmatch[ 1 ],\n\t\t\t\t\t\tcontext && context.nodeType ? context.ownerDocument || context : document,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t) );\n\n\t\t\t\t\t// HANDLE: $(html, props)\n\t\t\t\t\tif ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {\n\t\t\t\t\t\tfor ( match in context ) {\n\n\t\t\t\t\t\t\t// Properties of context are called as methods if possible\n\t\t\t\t\t\t\tif ( jQuery.isFunction( this[ match ] ) ) {\n\t\t\t\t\t\t\t\tthis[ match ]( context[ match ] );\n\n\t\t\t\t\t\t\t// ...and otherwise set as attributes\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.attr( match, context[ match ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this;\n\n\t\t\t\t// HANDLE: $(#id)\n\t\t\t\t} else {\n\t\t\t\t\telem = document.getElementById( match[ 2 ] );\n\n\t\t\t\t\t// Support: Blackberry 4.6\n\t\t\t\t\t// gEBID returns nodes no longer in the document (#6963)\n\t\t\t\t\tif ( elem && elem.parentNode ) {\n\n\t\t\t\t\t\t// Inject the element directly into the jQuery object\n\t\t\t\t\t\tthis.length = 1;\n\t\t\t\t\t\tthis[ 0 ] = elem;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context = document;\n\t\t\t\t\tthis.selector = selector;\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\n\t\t\t// HANDLE: $(expr, $(...))\n\t\t\t} else if ( !context || context.jquery ) {\n\t\t\t\treturn ( context || root ).find( selector );\n\n\t\t\t// HANDLE: $(expr, context)\n\t\t\t// (which is just equivalent to: $(context).find(expr)\n\t\t\t} else {\n\t\t\t\treturn this.constructor( context ).find( selector );\n\t\t\t}\n\n\t\t// HANDLE: $(DOMElement)\n\t\t} else if ( selector.nodeType ) {\n\t\t\tthis.context = this[ 0 ] = selector;\n\t\t\tthis.length = 1;\n\t\t\treturn this;\n\n\t\t// HANDLE: $(function)\n\t\t// Shortcut for document ready\n\t\t} else if ( jQuery.isFunction( selector ) ) {\n\t\t\treturn root.ready !== undefined ?\n\t\t\t\troot.ready( selector ) :\n\n\t\t\t\t// Execute immediately if ready is not present\n\t\t\t\tselector( jQuery );\n\t\t}\n\n\t\tif ( selector.selector !== undefined ) {\n\t\t\tthis.selector = selector.selector;\n\t\t\tthis.context = selector.context;\n\t\t}\n\n\t\treturn jQuery.makeArray( selector, this );\n\t};\n\n// Give the init function the jQuery prototype for later instantiation\ninit.prototype = jQuery.fn;\n\n// Initialize central reference\nrootjQuery = jQuery( document );\n\n\nvar rparentsprev = /^(?:parents|prev(?:Until|All))/,\n\n\t// Methods guaranteed to produce a unique set when starting from a unique set\n\tguaranteedUnique = {\n\t\tchildren: true,\n\t\tcontents: true,\n\t\tnext: true,\n\t\tprev: true\n\t};\n\njQuery.fn.extend( {\n\thas: function( target ) {\n\t\tvar targets = jQuery( target, this ),\n\t\t\tl = targets.length;\n\n\t\treturn this.filter( function() {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tif ( jQuery.contains( this, targets[ i ] ) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\tclosest: function( selectors, context ) {\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\tl = this.length,\n\t\t\tmatched = [],\n\t\t\tpos = rneedsContext.test( selectors ) || typeof selectors !== \"string\" ?\n\t\t\t\tjQuery( selectors, context || this.context ) :\n\t\t\t\t0;\n\n\t\tfor ( ; i < l; i++ ) {\n\t\t\tfor ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {\n\n\t\t\t\t// Always skip document fragments\n\t\t\t\tif ( cur.nodeType < 11 && ( pos ?\n\t\t\t\t\tpos.index( cur ) > -1 :\n\n\t\t\t\t\t// Don't pass non-elements to Sizzle\n\t\t\t\t\tcur.nodeType === 1 &&\n\t\t\t\t\t\tjQuery.find.matchesSelector( cur, selectors ) ) ) {\n\n\t\t\t\t\tmatched.push( cur );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );\n\t},\n\n\t// Determine the position of an element within the set\n\tindex: function( elem ) {\n\n\t\t// No argument, return index in parent\n\t\tif ( !elem ) {\n\t\t\treturn ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;\n\t\t}\n\n\t\t// Index in selector\n\t\tif ( typeof elem === \"string\" ) {\n\t\t\treturn indexOf.call( jQuery( elem ), this[ 0 ] );\n\t\t}\n\n\t\t// Locate the position of the desired element\n\t\treturn indexOf.call( this,\n\n\t\t\t// If it receives a jQuery object, the first element is used\n\t\t\telem.jquery ? elem[ 0 ] : elem\n\t\t);\n\t},\n\n\tadd: function( selector, context ) {\n\t\treturn this.pushStack(\n\t\t\tjQuery.uniqueSort(\n\t\t\t\tjQuery.merge( this.get(), jQuery( selector, context ) )\n\t\t\t)\n\t\t);\n\t},\n\n\taddBack: function( selector ) {\n\t\treturn this.add( selector == null ?\n\t\t\tthis.prevObject : this.prevObject.filter( selector )\n\t\t);\n\t}\n} );\n\nfunction sibling( cur, dir ) {\n\twhile ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}\n\treturn cur;\n}\n\njQuery.each( {\n\tparent: function( elem ) {\n\t\tvar parent = elem.parentNode;\n\t\treturn parent && parent.nodeType !== 11 ? parent : null;\n\t},\n\tparents: function( elem ) {\n\t\treturn dir( elem, \"parentNode\" );\n\t},\n\tparentsUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"parentNode\", until );\n\t},\n\tnext: function( elem ) {\n\t\treturn sibling( elem, \"nextSibling\" );\n\t},\n\tprev: function( elem ) {\n\t\treturn sibling( elem, \"previousSibling\" );\n\t},\n\tnextAll: function( elem ) {\n\t\treturn dir( elem, \"nextSibling\" );\n\t},\n\tprevAll: function( elem ) {\n\t\treturn dir( elem, \"previousSibling\" );\n\t},\n\tnextUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"nextSibling\", until );\n\t},\n\tprevUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"previousSibling\", until );\n\t},\n\tsiblings: function( elem ) {\n\t\treturn siblings( ( elem.parentNode || {} ).firstChild, elem );\n\t},\n\tchildren: function( elem ) {\n\t\treturn siblings( elem.firstChild );\n\t},\n\tcontents: function( elem ) {\n\t\treturn elem.contentDocument || jQuery.merge( [], elem.childNodes );\n\t}\n}, function( name, fn ) {\n\tjQuery.fn[ name ] = function( until, selector ) {\n\t\tvar matched = jQuery.map( this, fn, until );\n\n\t\tif ( name.slice( -5 ) !== \"Until\" ) {\n\t\t\tselector = until;\n\t\t}\n\n\t\tif ( selector && typeof selector === \"string\" ) {\n\t\t\tmatched = jQuery.filter( selector, matched );\n\t\t}\n\n\t\tif ( this.length > 1 ) {\n\n\t\t\t// Remove duplicates\n\t\t\tif ( !guaranteedUnique[ name ] ) {\n\t\t\t\tjQuery.uniqueSort( matched );\n\t\t\t}\n\n\t\t\t// Reverse order for parents* and prev-derivatives\n\t\t\tif ( rparentsprev.test( name ) ) {\n\t\t\t\tmatched.reverse();\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched );\n\t};\n} );\nvar rnotwhite = ( /\\S+/g );\n\n\n\n// Convert String-formatted options into Object-formatted ones\nfunction createOptions( options ) {\n\tvar object = {};\n\tjQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {\n\t\tobject[ flag ] = true;\n\t} );\n\treturn object;\n}\n\n/*\n * Create a callback list using the following parameters:\n *\n *\toptions: an optional list of space-separated options that will change how\n *\t\t\tthe callback list behaves or a more traditional option object\n *\n * By default a callback list will act like an event callback list and can be\n * \"fired\" multiple times.\n *\n * Possible options:\n *\n *\tonce:\t\t\twill ensure the callback list can only be fired once (like a Deferred)\n *\n *\tmemory:\t\t\twill keep track of previous values and will call any callback added\n *\t\t\t\t\tafter the list has been fired right away with the latest \"memorized\"\n *\t\t\t\t\tvalues (like a Deferred)\n *\n *\tunique:\t\t\twill ensure a callback can only be added once (no duplicate in the list)\n *\n *\tstopOnFalse:\tinterrupt callings when a callback returns false\n *\n */\njQuery.Callbacks = function( options ) {\n\n\t// Convert options from String-formatted to Object-formatted if needed\n\t// (we check in cache first)\n\toptions = typeof options === \"string\" ?\n\t\tcreateOptions( options ) :\n\t\tjQuery.extend( {}, options );\n\n\tvar // Flag to know if list is currently firing\n\t\tfiring,\n\n\t\t// Last fire value for non-forgettable lists\n\t\tmemory,\n\n\t\t// Flag to know if list was already fired\n\t\tfired,\n\n\t\t// Flag to prevent firing\n\t\tlocked,\n\n\t\t// Actual callback list\n\t\tlist = [],\n\n\t\t// Queue of execution data for repeatable lists\n\t\tqueue = [],\n\n\t\t// Index of currently firing callback (modified by add/remove as needed)\n\t\tfiringIndex = -1,\n\n\t\t// Fire callbacks\n\t\tfire = function() {\n\n\t\t\t// Enforce single-firing\n\t\t\tlocked = options.once;\n\n\t\t\t// Execute callbacks for all pending executions,\n\t\t\t// respecting firingIndex overrides and runtime changes\n\t\t\tfired = firing = true;\n\t\t\tfor ( ; queue.length; firingIndex = -1 ) {\n\t\t\t\tmemory = queue.shift();\n\t\t\t\twhile ( ++firingIndex < list.length ) {\n\n\t\t\t\t\t// Run callback and check for early termination\n\t\t\t\t\tif ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&\n\t\t\t\t\t\toptions.stopOnFalse ) {\n\n\t\t\t\t\t\t// Jump to end and forget the data so .add doesn't re-fire\n\t\t\t\t\t\tfiringIndex = list.length;\n\t\t\t\t\t\tmemory = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Forget the data if we're done with it\n\t\t\tif ( !options.memory ) {\n\t\t\t\tmemory = false;\n\t\t\t}\n\n\t\t\tfiring = false;\n\n\t\t\t// Clean up if we're done firing for good\n\t\t\tif ( locked ) {\n\n\t\t\t\t// Keep an empty list if we have data for future add calls\n\t\t\t\tif ( memory ) {\n\t\t\t\t\tlist = [];\n\n\t\t\t\t// Otherwise, this object is spent\n\t\t\t\t} else {\n\t\t\t\t\tlist = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Actual Callbacks object\n\t\tself = {\n\n\t\t\t// Add a callback or a collection of callbacks to the list\n\t\t\tadd: function() {\n\t\t\t\tif ( list ) {\n\n\t\t\t\t\t// If we have memory from a past run, we should fire after adding\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfiringIndex = list.length - 1;\n\t\t\t\t\t\tqueue.push( memory );\n\t\t\t\t\t}\n\n\t\t\t\t\t( function add( args ) {\n\t\t\t\t\t\tjQuery.each( args, function( _, arg ) {\n\t\t\t\t\t\t\tif ( jQuery.isFunction( arg ) ) {\n\t\t\t\t\t\t\t\tif ( !options.unique || !self.has( arg ) ) {\n\t\t\t\t\t\t\t\t\tlist.push( arg );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( arg && arg.length && jQuery.type( arg ) !== \"string\" ) {\n\n\t\t\t\t\t\t\t\t// Inspect recursively\n\t\t\t\t\t\t\t\tadd( arg );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )( arguments );\n\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Remove a callback from the list\n\t\t\tremove: function() {\n\t\t\t\tjQuery.each( arguments, function( _, arg ) {\n\t\t\t\t\tvar index;\n\t\t\t\t\twhile ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {\n\t\t\t\t\t\tlist.splice( index, 1 );\n\n\t\t\t\t\t\t// Handle firing indexes\n\t\t\t\t\t\tif ( index <= firingIndex ) {\n\t\t\t\t\t\t\tfiringIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Check if a given callback is in the list.\n\t\t\t// If no argument is given, return whether or not list has callbacks attached.\n\t\t\thas: function( fn ) {\n\t\t\t\treturn fn ?\n\t\t\t\t\tjQuery.inArray( fn, list ) > -1 :\n\t\t\t\t\tlist.length > 0;\n\t\t\t},\n\n\t\t\t// Remove all callbacks from the list\n\t\t\tempty: function() {\n\t\t\t\tif ( list ) {\n\t\t\t\t\tlist = [];\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Disable .fire and .add\n\t\t\t// Abort any current/pending executions\n\t\t\t// Clear all callbacks and values\n\t\t\tdisable: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tlist = memory = \"\";\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tdisabled: function() {\n\t\t\t\treturn !list;\n\t\t\t},\n\n\t\t\t// Disable .fire\n\t\t\t// Also disable .add unless we have memory (since it would have no effect)\n\t\t\t// Abort any pending executions\n\t\t\tlock: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tif ( !memory ) {\n\t\t\t\t\tlist = memory = \"\";\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tlocked: function() {\n\t\t\t\treturn !!locked;\n\t\t\t},\n\n\t\t\t// Call all callbacks with the given context and arguments\n\t\t\tfireWith: function( context, args ) {\n\t\t\t\tif ( !locked ) {\n\t\t\t\t\targs = args || [];\n\t\t\t\t\targs = [ context, args.slice ? args.slice() : args ];\n\t\t\t\t\tqueue.push( args );\n\t\t\t\t\tif ( !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Call all the callbacks with the given arguments\n\t\t\tfire: function() {\n\t\t\t\tself.fireWith( this, arguments );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// To know if the callbacks have already been called at least once\n\t\t\tfired: function() {\n\t\t\t\treturn !!fired;\n\t\t\t}\n\t\t};\n\n\treturn self;\n};\n\n\njQuery.extend( {\n\n\tDeferred: function( func ) {\n\t\tvar tuples = [\n\n\t\t\t\t// action, add listener, listener list, final state\n\t\t\t\t[ \"resolve\", \"done\", jQuery.Callbacks( \"once memory\" ), \"resolved\" ],\n\t\t\t\t[ \"reject\", \"fail\", jQuery.Callbacks( \"once memory\" ), \"rejected\" ],\n\t\t\t\t[ \"notify\", \"progress\", jQuery.Callbacks( \"memory\" ) ]\n\t\t\t],\n\t\t\tstate = \"pending\",\n\t\t\tpromise = {\n\t\t\t\tstate: function() {\n\t\t\t\t\treturn state;\n\t\t\t\t},\n\t\t\t\talways: function() {\n\t\t\t\t\tdeferred.done( arguments ).fail( arguments );\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\t\t\t\tthen: function( /* fnDone, fnFail, fnProgress */ ) {\n\t\t\t\t\tvar fns = arguments;\n\t\t\t\t\treturn jQuery.Deferred( function( newDefer ) {\n\t\t\t\t\t\tjQuery.each( tuples, function( i, tuple ) {\n\t\t\t\t\t\t\tvar fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];\n\n\t\t\t\t\t\t\t// deferred[ done | fail | progress ] for forwarding actions to newDefer\n\t\t\t\t\t\t\tdeferred[ tuple[ 1 ] ]( function() {\n\t\t\t\t\t\t\t\tvar returned = fn && fn.apply( this, arguments );\n\t\t\t\t\t\t\t\tif ( returned && jQuery.isFunction( returned.promise ) ) {\n\t\t\t\t\t\t\t\t\treturned.promise()\n\t\t\t\t\t\t\t\t\t\t.progress( newDefer.notify )\n\t\t\t\t\t\t\t\t\t\t.done( newDefer.resolve )\n\t\t\t\t\t\t\t\t\t\t.fail( newDefer.reject );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tnewDefer[ tuple[ 0 ] + \"With\" ](\n\t\t\t\t\t\t\t\t\t\tthis === promise ? newDefer.promise() : this,\n\t\t\t\t\t\t\t\t\t\tfn ? [ returned ] : arguments\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tfns = null;\n\t\t\t\t\t} ).promise();\n\t\t\t\t},\n\n\t\t\t\t// Get a promise for this deferred\n\t\t\t\t// If obj is provided, the promise aspect is added to the object\n\t\t\t\tpromise: function( obj ) {\n\t\t\t\t\treturn obj != null ? jQuery.extend( obj, promise ) : promise;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdeferred = {};\n\n\t\t// Keep pipe for back-compat\n\t\tpromise.pipe = promise.then;\n\n\t\t// Add list-specific methods\n\t\tjQuery.each( tuples, function( i, tuple ) {\n\t\t\tvar list = tuple[ 2 ],\n\t\t\t\tstateString = tuple[ 3 ];\n\n\t\t\t// promise[ done | fail | progress ] = list.add\n\t\t\tpromise[ tuple[ 1 ] ] = list.add;\n\n\t\t\t// Handle state\n\t\t\tif ( stateString ) {\n\t\t\t\tlist.add( function() {\n\n\t\t\t\t\t// state = [ resolved | rejected ]\n\t\t\t\t\tstate = stateString;\n\n\t\t\t\t// [ reject_list | resolve_list ].disable; progress_list.lock\n\t\t\t\t}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );\n\t\t\t}\n\n\t\t\t// deferred[ resolve | reject | notify ]\n\t\t\tdeferred[ tuple[ 0 ] ] = function() {\n\t\t\t\tdeferred[ tuple[ 0 ] + \"With\" ]( this === deferred ? promise : this, arguments );\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tdeferred[ tuple[ 0 ] + \"With\" ] = list.fireWith;\n\t\t} );\n\n\t\t// Make the deferred a promise\n\t\tpromise.promise( deferred );\n\n\t\t// Call given func if any\n\t\tif ( func ) {\n\t\t\tfunc.call( deferred, deferred );\n\t\t}\n\n\t\t// All done!\n\t\treturn deferred;\n\t},\n\n\t// Deferred helper\n\twhen: function( subordinate /* , ..., subordinateN */ ) {\n\t\tvar i = 0,\n\t\t\tresolveValues = slice.call( arguments ),\n\t\t\tlength = resolveValues.length,\n\n\t\t\t// the count of uncompleted subordinates\n\t\t\tremaining = length !== 1 ||\n\t\t\t\t( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,\n\n\t\t\t// the master Deferred.\n\t\t\t// If resolveValues consist of only a single Deferred, just use that.\n\t\t\tdeferred = remaining === 1 ? subordinate : jQuery.Deferred(),\n\n\t\t\t// Update function for both resolve and progress values\n\t\t\tupdateFunc = function( i, contexts, values ) {\n\t\t\t\treturn function( value ) {\n\t\t\t\t\tcontexts[ i ] = this;\n\t\t\t\t\tvalues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;\n\t\t\t\t\tif ( values === progressValues ) {\n\t\t\t\t\t\tdeferred.notifyWith( contexts, values );\n\t\t\t\t\t} else if ( !( --remaining ) ) {\n\t\t\t\t\t\tdeferred.resolveWith( contexts, values );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\n\t\t\tprogressValues, progressContexts, resolveContexts;\n\n\t\t// Add listeners to Deferred subordinates; treat others as resolved\n\t\tif ( length > 1 ) {\n\t\t\tprogressValues = new Array( length );\n\t\t\tprogressContexts = new Array( length );\n\t\t\tresolveContexts = new Array( length );\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tif ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {\n\t\t\t\t\tresolveValues[ i ].promise()\n\t\t\t\t\t\t.progress( updateFunc( i, progressContexts, progressValues ) )\n\t\t\t\t\t\t.done( updateFunc( i, resolveContexts, resolveValues ) )\n\t\t\t\t\t\t.fail( deferred.reject );\n\t\t\t\t} else {\n\t\t\t\t\t--remaining;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we're not waiting on anything, resolve the master\n\t\tif ( !remaining ) {\n\t\t\tdeferred.resolveWith( resolveContexts, resolveValues );\n\t\t}\n\n\t\treturn deferred.promise();\n\t}\n} );\n\n\n// The deferred used on DOM ready\nvar readyList;\n\njQuery.fn.ready = function( fn ) {\n\n\t// Add the callback\n\tjQuery.ready.promise().done( fn );\n\n\treturn this;\n};\n\njQuery.extend( {\n\n\t// Is the DOM ready to be used? Set to true once it occurs.\n\tisReady: false,\n\n\t// A counter to track how many items to wait for before\n\t// the ready event fires. See #6781\n\treadyWait: 1,\n\n\t// Hold (or release) the ready event\n\tholdReady: function( hold ) {\n\t\tif ( hold ) {\n\t\t\tjQuery.readyWait++;\n\t\t} else {\n\t\t\tjQuery.ready( true );\n\t\t}\n\t},\n\n\t// Handle when the DOM is ready\n\tready: function( wait ) {\n\n\t\t// Abort if there are pending holds or we're already ready\n\t\tif ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Remember that the DOM is ready\n\t\tjQuery.isReady = true;\n\n\t\t// If a normal DOM Ready event fired, decrement, and wait if need be\n\t\tif ( wait !== true && --jQuery.readyWait > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there are functions bound, to execute\n\t\treadyList.resolveWith( document, [ jQuery ] );\n\n\t\t// Trigger any bound ready events\n\t\tif ( jQuery.fn.triggerHandler ) {\n\t\t\tjQuery( document ).triggerHandler( \"ready\" );\n\t\t\tjQuery( document ).off( \"ready\" );\n\t\t}\n\t}\n} );\n\n/**\n * The ready event handler and self cleanup method\n */\nfunction completed() {\n\tdocument.removeEventListener( \"DOMContentLoaded\", completed );\n\twindow.removeEventListener( \"load\", completed );\n\tjQuery.ready();\n}\n\njQuery.ready.promise = function( obj ) {\n\tif ( !readyList ) {\n\n\t\treadyList = jQuery.Deferred();\n\n\t\t// Catch cases where $(document).ready() is called\n\t\t// after the browser event has already occurred.\n\t\t// Support: IE9-10 only\n\t\t// Older IE sometimes signals \"interactive\" too soon\n\t\tif ( document.readyState === \"complete\" ||\n\t\t\t( document.readyState !== \"loading\" && !document.documentElement.doScroll ) ) {\n\n\t\t\t// Handle it asynchronously to allow scripts the opportunity to delay ready\n\t\t\twindow.setTimeout( jQuery.ready );\n\n\t\t} else {\n\n\t\t\t// Use the handy event callback\n\t\t\tdocument.addEventListener( \"DOMContentLoaded\", completed );\n\n\t\t\t// A fallback to window.onload, that will always work\n\t\t\twindow.addEventListener( \"load\", completed );\n\t\t}\n\t}\n\treturn readyList.promise( obj );\n};\n\n// Kick off the DOM ready check even if the user does not\njQuery.ready.promise();\n\n\n\n\n// Multifunctional method to get and set values of a collection\n// The value/s can optionally be executed if it's a function\nvar access = function( elems, fn, key, value, chainable, emptyGet, raw ) {\n\tvar i = 0,\n\t\tlen = elems.length,\n\t\tbulk = key == null;\n\n\t// Sets many values\n\tif ( jQuery.type( key ) === \"object\" ) {\n\t\tchainable = true;\n\t\tfor ( i in key ) {\n\t\t\taccess( elems, fn, i, key[ i ], true, emptyGet, raw );\n\t\t}\n\n\t// Sets one value\n\t} else if ( value !== undefined ) {\n\t\tchainable = true;\n\n\t\tif ( !jQuery.isFunction( value ) ) {\n\t\t\traw = true;\n\t\t}\n\n\t\tif ( bulk ) {\n\n\t\t\t// Bulk operations run against the entire set\n\t\t\tif ( raw ) {\n\t\t\t\tfn.call( elems, value );\n\t\t\t\tfn = null;\n\n\t\t\t// ...except when executing function values\n\t\t\t} else {\n\t\t\t\tbulk = fn;\n\t\t\t\tfn = function( elem, key, value ) {\n\t\t\t\t\treturn bulk.call( jQuery( elem ), value );\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( fn ) {\n\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\tfn(\n\t\t\t\t\telems[ i ], key, raw ?\n\t\t\t\t\tvalue :\n\t\t\t\t\tvalue.call( elems[ i ], i, fn( elems[ i ], key ) )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn chainable ?\n\t\telems :\n\n\t\t// Gets\n\t\tbulk ?\n\t\t\tfn.call( elems ) :\n\t\t\tlen ? fn( elems[ 0 ], key ) : emptyGet;\n};\nvar acceptData = function( owner ) {\n\n\t// Accepts only:\n\t//  - Node\n\t//    - Node.ELEMENT_NODE\n\t//    - Node.DOCUMENT_NODE\n\t//  - Object\n\t//    - Any\n\t/* jshint -W018 */\n\treturn owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );\n};\n\n\n\n\nfunction Data() {\n\tthis.expando = jQuery.expando + Data.uid++;\n}\n\nData.uid = 1;\n\nData.prototype = {\n\n\tregister: function( owner, initial ) {\n\t\tvar value = initial || {};\n\n\t\t// If it is a node unlikely to be stringify-ed or looped over\n\t\t// use plain assignment\n\t\tif ( owner.nodeType ) {\n\t\t\towner[ this.expando ] = value;\n\n\t\t// Otherwise secure it in a non-enumerable, non-writable property\n\t\t// configurability must be true to allow the property to be\n\t\t// deleted with the delete operator\n\t\t} else {\n\t\t\tObject.defineProperty( owner, this.expando, {\n\t\t\t\tvalue: value,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: true\n\t\t\t} );\n\t\t}\n\t\treturn owner[ this.expando ];\n\t},\n\tcache: function( owner ) {\n\n\t\t// We can accept data for non-element nodes in modern browsers,\n\t\t// but we should not, see #8335.\n\t\t// Always return an empty object.\n\t\tif ( !acceptData( owner ) ) {\n\t\t\treturn {};\n\t\t}\n\n\t\t// Check if the owner object already has a cache\n\t\tvar value = owner[ this.expando ];\n\n\t\t// If not, create one\n\t\tif ( !value ) {\n\t\t\tvalue = {};\n\n\t\t\t// We can accept data for non-element nodes in modern browsers,\n\t\t\t// but we should not, see #8335.\n\t\t\t// Always return an empty object.\n\t\t\tif ( acceptData( owner ) ) {\n\n\t\t\t\t// If it is a node unlikely to be stringify-ed or looped over\n\t\t\t\t// use plain assignment\n\t\t\t\tif ( owner.nodeType ) {\n\t\t\t\t\towner[ this.expando ] = value;\n\n\t\t\t\t// Otherwise secure it in a non-enumerable property\n\t\t\t\t// configurable must be true to allow the property to be\n\t\t\t\t// deleted when data is removed\n\t\t\t\t} else {\n\t\t\t\t\tObject.defineProperty( owner, this.expando, {\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\tconfigurable: true\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t},\n\tset: function( owner, data, value ) {\n\t\tvar prop,\n\t\t\tcache = this.cache( owner );\n\n\t\t// Handle: [ owner, key, value ] args\n\t\tif ( typeof data === \"string\" ) {\n\t\t\tcache[ data ] = value;\n\n\t\t// Handle: [ owner, { properties } ] args\n\t\t} else {\n\n\t\t\t// Copy the properties one-by-one to the cache object\n\t\t\tfor ( prop in data ) {\n\t\t\t\tcache[ prop ] = data[ prop ];\n\t\t\t}\n\t\t}\n\t\treturn cache;\n\t},\n\tget: function( owner, key ) {\n\t\treturn key === undefined ?\n\t\t\tthis.cache( owner ) :\n\t\t\towner[ this.expando ] && owner[ this.expando ][ key ];\n\t},\n\taccess: function( owner, key, value ) {\n\t\tvar stored;\n\n\t\t// In cases where either:\n\t\t//\n\t\t//   1. No key was specified\n\t\t//   2. A string key was specified, but no value provided\n\t\t//\n\t\t// Take the \"read\" path and allow the get method to determine\n\t\t// which value to return, respectively either:\n\t\t//\n\t\t//   1. The entire cache object\n\t\t//   2. The data stored at the key\n\t\t//\n\t\tif ( key === undefined ||\n\t\t\t\t( ( key && typeof key === \"string\" ) && value === undefined ) ) {\n\n\t\t\tstored = this.get( owner, key );\n\n\t\t\treturn stored !== undefined ?\n\t\t\t\tstored : this.get( owner, jQuery.camelCase( key ) );\n\t\t}\n\n\t\t// When the key is not a string, or both a key and value\n\t\t// are specified, set or extend (existing objects) with either:\n\t\t//\n\t\t//   1. An object of properties\n\t\t//   2. A key and value\n\t\t//\n\t\tthis.set( owner, key, value );\n\n\t\t// Since the \"set\" path can have two possible entry points\n\t\t// return the expected data based on which path was taken[*]\n\t\treturn value !== undefined ? value : key;\n\t},\n\tremove: function( owner, key ) {\n\t\tvar i, name, camel,\n\t\t\tcache = owner[ this.expando ];\n\n\t\tif ( cache === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( key === undefined ) {\n\t\t\tthis.register( owner );\n\n\t\t} else {\n\n\t\t\t// Support array or space separated string of keys\n\t\t\tif ( jQuery.isArray( key ) ) {\n\n\t\t\t\t// If \"name\" is an array of keys...\n\t\t\t\t// When data is initially created, via (\"key\", \"val\") signature,\n\t\t\t\t// keys will be converted to camelCase.\n\t\t\t\t// Since there is no way to tell _how_ a key was added, remove\n\t\t\t\t// both plain key and camelCase key. #12786\n\t\t\t\t// This will only penalize the array argument path.\n\t\t\t\tname = key.concat( key.map( jQuery.camelCase ) );\n\t\t\t} else {\n\t\t\t\tcamel = jQuery.camelCase( key );\n\n\t\t\t\t// Try the string as a key before any manipulation\n\t\t\t\tif ( key in cache ) {\n\t\t\t\t\tname = [ key, camel ];\n\t\t\t\t} else {\n\n\t\t\t\t\t// If a key with the spaces exists, use it.\n\t\t\t\t\t// Otherwise, create an array by matching non-whitespace\n\t\t\t\t\tname = camel;\n\t\t\t\t\tname = name in cache ?\n\t\t\t\t\t\t[ name ] : ( name.match( rnotwhite ) || [] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ti = name.length;\n\n\t\t\twhile ( i-- ) {\n\t\t\t\tdelete cache[ name[ i ] ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove the expando if there's no more data\n\t\tif ( key === undefined || jQuery.isEmptyObject( cache ) ) {\n\n\t\t\t// Support: Chrome <= 35-45+\n\t\t\t// Webkit & Blink performance suffers when deleting properties\n\t\t\t// from DOM nodes, so set to undefined instead\n\t\t\t// https://code.google.com/p/chromium/issues/detail?id=378607\n\t\t\tif ( owner.nodeType ) {\n\t\t\t\towner[ this.expando ] = undefined;\n\t\t\t} else {\n\t\t\t\tdelete owner[ this.expando ];\n\t\t\t}\n\t\t}\n\t},\n\thasData: function( owner ) {\n\t\tvar cache = owner[ this.expando ];\n\t\treturn cache !== undefined && !jQuery.isEmptyObject( cache );\n\t}\n};\nvar dataPriv = new Data();\n\nvar dataUser = new Data();\n\n\n\n//\tImplementation Summary\n//\n//\t1. Enforce API surface and semantic compatibility with 1.9.x branch\n//\t2. Improve the module's maintainability by reducing the storage\n//\t\tpaths to a single mechanism.\n//\t3. Use the same single mechanism to support \"private\" and \"user\" data.\n//\t4. _Never_ expose \"private\" data to user code (TODO: Drop _data, _removeData)\n//\t5. Avoid exposing implementation details on user objects (eg. expando properties)\n//\t6. Provide a clear path for implementation upgrade to WeakMap in 2014\n\nvar rbrace = /^(?:\\{[\\w\\W]*\\}|\\[[\\w\\W]*\\])$/,\n\trmultiDash = /[A-Z]/g;\n\nfunction dataAttr( elem, key, data ) {\n\tvar name;\n\n\t// If nothing was found internally, try to fetch any\n\t// data from the HTML5 data-* attribute\n\tif ( data === undefined && elem.nodeType === 1 ) {\n\t\tname = \"data-\" + key.replace( rmultiDash, \"-$&\" ).toLowerCase();\n\t\tdata = elem.getAttribute( name );\n\n\t\tif ( typeof data === \"string\" ) {\n\t\t\ttry {\n\t\t\t\tdata = data === \"true\" ? true :\n\t\t\t\t\tdata === \"false\" ? false :\n\t\t\t\t\tdata === \"null\" ? null :\n\n\t\t\t\t\t// Only convert to a number if it doesn't change the string\n\t\t\t\t\t+data + \"\" === data ? +data :\n\t\t\t\t\trbrace.test( data ) ? jQuery.parseJSON( data ) :\n\t\t\t\t\tdata;\n\t\t\t} catch ( e ) {}\n\n\t\t\t// Make sure we set the data so it isn't changed later\n\t\t\tdataUser.set( elem, key, data );\n\t\t} else {\n\t\t\tdata = undefined;\n\t\t}\n\t}\n\treturn data;\n}\n\njQuery.extend( {\n\thasData: function( elem ) {\n\t\treturn dataUser.hasData( elem ) || dataPriv.hasData( elem );\n\t},\n\n\tdata: function( elem, name, data ) {\n\t\treturn dataUser.access( elem, name, data );\n\t},\n\n\tremoveData: function( elem, name ) {\n\t\tdataUser.remove( elem, name );\n\t},\n\n\t// TODO: Now that all calls to _data and _removeData have been replaced\n\t// with direct calls to dataPriv methods, these can be deprecated.\n\t_data: function( elem, name, data ) {\n\t\treturn dataPriv.access( elem, name, data );\n\t},\n\n\t_removeData: function( elem, name ) {\n\t\tdataPriv.remove( elem, name );\n\t}\n} );\n\njQuery.fn.extend( {\n\tdata: function( key, value ) {\n\t\tvar i, name, data,\n\t\t\telem = this[ 0 ],\n\t\t\tattrs = elem && elem.attributes;\n\n\t\t// Gets all values\n\t\tif ( key === undefined ) {\n\t\t\tif ( this.length ) {\n\t\t\t\tdata = dataUser.get( elem );\n\n\t\t\t\tif ( elem.nodeType === 1 && !dataPriv.get( elem, \"hasDataAttrs\" ) ) {\n\t\t\t\t\ti = attrs.length;\n\t\t\t\t\twhile ( i-- ) {\n\n\t\t\t\t\t\t// Support: IE11+\n\t\t\t\t\t\t// The attrs elements can be null (#14894)\n\t\t\t\t\t\tif ( attrs[ i ] ) {\n\t\t\t\t\t\t\tname = attrs[ i ].name;\n\t\t\t\t\t\t\tif ( name.indexOf( \"data-\" ) === 0 ) {\n\t\t\t\t\t\t\t\tname = jQuery.camelCase( name.slice( 5 ) );\n\t\t\t\t\t\t\t\tdataAttr( elem, name, data[ name ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdataPriv.set( elem, \"hasDataAttrs\", true );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\n\t\t// Sets multiple values\n\t\tif ( typeof key === \"object\" ) {\n\t\t\treturn this.each( function() {\n\t\t\t\tdataUser.set( this, key );\n\t\t\t} );\n\t\t}\n\n\t\treturn access( this, function( value ) {\n\t\t\tvar data, camelKey;\n\n\t\t\t// The calling jQuery object (element matches) is not empty\n\t\t\t// (and therefore has an element appears at this[ 0 ]) and the\n\t\t\t// `value` parameter was not undefined. An empty jQuery object\n\t\t\t// will result in `undefined` for elem = this[ 0 ] which will\n\t\t\t// throw an exception if an attempt to read a data cache is made.\n\t\t\tif ( elem && value === undefined ) {\n\n\t\t\t\t// Attempt to get data from the cache\n\t\t\t\t// with the key as-is\n\t\t\t\tdata = dataUser.get( elem, key ) ||\n\n\t\t\t\t\t// Try to find dashed key if it exists (gh-2779)\n\t\t\t\t\t// This is for 2.2.x only\n\t\t\t\t\tdataUser.get( elem, key.replace( rmultiDash, \"-$&\" ).toLowerCase() );\n\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\tcamelKey = jQuery.camelCase( key );\n\n\t\t\t\t// Attempt to get data from the cache\n\t\t\t\t// with the key camelized\n\t\t\t\tdata = dataUser.get( elem, camelKey );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// Attempt to \"discover\" the data in\n\t\t\t\t// HTML5 custom data-* attrs\n\t\t\t\tdata = dataAttr( elem, camelKey, undefined );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// We tried really hard, but the data doesn't exist.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the data...\n\t\t\tcamelKey = jQuery.camelCase( key );\n\t\t\tthis.each( function() {\n\n\t\t\t\t// First, attempt to store a copy or reference of any\n\t\t\t\t// data that might've been store with a camelCased key.\n\t\t\t\tvar data = dataUser.get( this, camelKey );\n\n\t\t\t\t// For HTML5 data-* attribute interop, we have to\n\t\t\t\t// store property names with dashes in a camelCase form.\n\t\t\t\t// This might not apply to all properties...*\n\t\t\t\tdataUser.set( this, camelKey, value );\n\n\t\t\t\t// *... In the case of properties that might _actually_\n\t\t\t\t// have dashes, we need to also store a copy of that\n\t\t\t\t// unchanged property.\n\t\t\t\tif ( key.indexOf( \"-\" ) > -1 && data !== undefined ) {\n\t\t\t\t\tdataUser.set( this, key, value );\n\t\t\t\t}\n\t\t\t} );\n\t\t}, null, value, arguments.length > 1, null, true );\n\t},\n\n\tremoveData: function( key ) {\n\t\treturn this.each( function() {\n\t\t\tdataUser.remove( this, key );\n\t\t} );\n\t}\n} );\n\n\njQuery.extend( {\n\tqueue: function( elem, type, data ) {\n\t\tvar queue;\n\n\t\tif ( elem ) {\n\t\t\ttype = ( type || \"fx\" ) + \"queue\";\n\t\t\tqueue = dataPriv.get( elem, type );\n\n\t\t\t// Speed up dequeue by getting out quickly if this is just a lookup\n\t\t\tif ( data ) {\n\t\t\t\tif ( !queue || jQuery.isArray( data ) ) {\n\t\t\t\t\tqueue = dataPriv.access( elem, type, jQuery.makeArray( data ) );\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push( data );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn queue || [];\n\t\t}\n\t},\n\n\tdequeue: function( elem, type ) {\n\t\ttype = type || \"fx\";\n\n\t\tvar queue = jQuery.queue( elem, type ),\n\t\t\tstartLength = queue.length,\n\t\t\tfn = queue.shift(),\n\t\t\thooks = jQuery._queueHooks( elem, type ),\n\t\t\tnext = function() {\n\t\t\t\tjQuery.dequeue( elem, type );\n\t\t\t};\n\n\t\t// If the fx queue is dequeued, always remove the progress sentinel\n\t\tif ( fn === \"inprogress\" ) {\n\t\t\tfn = queue.shift();\n\t\t\tstartLength--;\n\t\t}\n\n\t\tif ( fn ) {\n\n\t\t\t// Add a progress sentinel to prevent the fx queue from being\n\t\t\t// automatically dequeued\n\t\t\tif ( type === \"fx\" ) {\n\t\t\t\tqueue.unshift( \"inprogress\" );\n\t\t\t}\n\n\t\t\t// Clear up the last queue stop function\n\t\t\tdelete hooks.stop;\n\t\t\tfn.call( elem, next, hooks );\n\t\t}\n\n\t\tif ( !startLength && hooks ) {\n\t\t\thooks.empty.fire();\n\t\t}\n\t},\n\n\t// Not public - generate a queueHooks object, or return the current one\n\t_queueHooks: function( elem, type ) {\n\t\tvar key = type + \"queueHooks\";\n\t\treturn dataPriv.get( elem, key ) || dataPriv.access( elem, key, {\n\t\t\tempty: jQuery.Callbacks( \"once memory\" ).add( function() {\n\t\t\t\tdataPriv.remove( elem, [ type + \"queue\", key ] );\n\t\t\t} )\n\t\t} );\n\t}\n} );\n\njQuery.fn.extend( {\n\tqueue: function( type, data ) {\n\t\tvar setter = 2;\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tdata = type;\n\t\t\ttype = \"fx\";\n\t\t\tsetter--;\n\t\t}\n\n\t\tif ( arguments.length < setter ) {\n\t\t\treturn jQuery.queue( this[ 0 ], type );\n\t\t}\n\n\t\treturn data === undefined ?\n\t\t\tthis :\n\t\t\tthis.each( function() {\n\t\t\t\tvar queue = jQuery.queue( this, type, data );\n\n\t\t\t\t// Ensure a hooks for this queue\n\t\t\t\tjQuery._queueHooks( this, type );\n\n\t\t\t\tif ( type === \"fx\" && queue[ 0 ] !== \"inprogress\" ) {\n\t\t\t\t\tjQuery.dequeue( this, type );\n\t\t\t\t}\n\t\t\t} );\n\t},\n\tdequeue: function( type ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.dequeue( this, type );\n\t\t} );\n\t},\n\tclearQueue: function( type ) {\n\t\treturn this.queue( type || \"fx\", [] );\n\t},\n\n\t// Get a promise resolved when queues of a certain type\n\t// are emptied (fx is the type by default)\n\tpromise: function( type, obj ) {\n\t\tvar tmp,\n\t\t\tcount = 1,\n\t\t\tdefer = jQuery.Deferred(),\n\t\t\telements = this,\n\t\t\ti = this.length,\n\t\t\tresolve = function() {\n\t\t\t\tif ( !( --count ) ) {\n\t\t\t\t\tdefer.resolveWith( elements, [ elements ] );\n\t\t\t\t}\n\t\t\t};\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tobj = type;\n\t\t\ttype = undefined;\n\t\t}\n\t\ttype = type || \"fx\";\n\n\t\twhile ( i-- ) {\n\t\t\ttmp = dataPriv.get( elements[ i ], type + \"queueHooks\" );\n\t\t\tif ( tmp && tmp.empty ) {\n\t\t\t\tcount++;\n\t\t\t\ttmp.empty.add( resolve );\n\t\t\t}\n\t\t}\n\t\tresolve();\n\t\treturn defer.promise( obj );\n\t}\n} );\nvar pnum = ( /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/ ).source;\n\nvar rcssNum = new RegExp( \"^(?:([+-])=|)(\" + pnum + \")([a-z%]*)$\", \"i\" );\n\n\nvar cssExpand = [ \"Top\", \"Right\", \"Bottom\", \"Left\" ];\n\nvar isHidden = function( elem, el ) {\n\n\t\t// isHidden might be called from jQuery#filter function;\n\t\t// in that case, element will be second argument\n\t\telem = el || elem;\n\t\treturn jQuery.css( elem, \"display\" ) === \"none\" ||\n\t\t\t!jQuery.contains( elem.ownerDocument, elem );\n\t};\n\n\n\nfunction adjustCSS( elem, prop, valueParts, tween ) {\n\tvar adjusted,\n\t\tscale = 1,\n\t\tmaxIterations = 20,\n\t\tcurrentValue = tween ?\n\t\t\tfunction() { return tween.cur(); } :\n\t\t\tfunction() { return jQuery.css( elem, prop, \"\" ); },\n\t\tinitial = currentValue(),\n\t\tunit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? \"\" : \"px\" ),\n\n\t\t// Starting value computation is required for potential unit mismatches\n\t\tinitialInUnit = ( jQuery.cssNumber[ prop ] || unit !== \"px\" && +initial ) &&\n\t\t\trcssNum.exec( jQuery.css( elem, prop ) );\n\n\tif ( initialInUnit && initialInUnit[ 3 ] !== unit ) {\n\n\t\t// Trust units reported by jQuery.css\n\t\tunit = unit || initialInUnit[ 3 ];\n\n\t\t// Make sure we update the tween properties later on\n\t\tvalueParts = valueParts || [];\n\n\t\t// Iteratively approximate from a nonzero starting point\n\t\tinitialInUnit = +initial || 1;\n\n\t\tdo {\n\n\t\t\t// If previous iteration zeroed out, double until we get *something*.\n\t\t\t// Use string for doubling so we don't accidentally see scale as unchanged below\n\t\t\tscale = scale || \".5\";\n\n\t\t\t// Adjust and apply\n\t\t\tinitialInUnit = initialInUnit / scale;\n\t\t\tjQuery.style( elem, prop, initialInUnit + unit );\n\n\t\t// Update scale, tolerating zero or NaN from tween.cur()\n\t\t// Break the loop if scale is unchanged or perfect, or if we've just had enough.\n\t\t} while (\n\t\t\tscale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations\n\t\t);\n\t}\n\n\tif ( valueParts ) {\n\t\tinitialInUnit = +initialInUnit || +initial || 0;\n\n\t\t// Apply relative offset (+=/-=) if specified\n\t\tadjusted = valueParts[ 1 ] ?\n\t\t\tinitialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :\n\t\t\t+valueParts[ 2 ];\n\t\tif ( tween ) {\n\t\t\ttween.unit = unit;\n\t\t\ttween.start = initialInUnit;\n\t\t\ttween.end = adjusted;\n\t\t}\n\t}\n\treturn adjusted;\n}\nvar rcheckableType = ( /^(?:checkbox|radio)$/i );\n\nvar rtagName = ( /<([\\w:-]+)/ );\n\nvar rscriptType = ( /^$|\\/(?:java|ecma)script/i );\n\n\n\n// We have to close these tags to support XHTML (#13200)\nvar wrapMap = {\n\n\t// Support: IE9\n\toption: [ 1, \"<select multiple='multiple'>\", \"</select>\" ],\n\n\t// XHTML parsers do not magically insert elements in the\n\t// same way that tag soup parsers do. So we cannot shorten\n\t// this by omitting <tbody> or other required elements.\n\tthead: [ 1, \"<table>\", \"</table>\" ],\n\tcol: [ 2, \"<table><colgroup>\", \"</colgroup></table>\" ],\n\ttr: [ 2, \"<table><tbody>\", \"</tbody></table>\" ],\n\ttd: [ 3, \"<table><tbody><tr>\", \"</tr></tbody></table>\" ],\n\n\t_default: [ 0, \"\", \"\" ]\n};\n\n// Support: IE9\nwrapMap.optgroup = wrapMap.option;\n\nwrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;\nwrapMap.th = wrapMap.td;\n\n\nfunction getAll( context, tag ) {\n\n\t// Support: IE9-11+\n\t// Use typeof to avoid zero-argument method invocation on host objects (#15151)\n\tvar ret = typeof context.getElementsByTagName !== \"undefined\" ?\n\t\t\tcontext.getElementsByTagName( tag || \"*\" ) :\n\t\t\ttypeof context.querySelectorAll !== \"undefined\" ?\n\t\t\t\tcontext.querySelectorAll( tag || \"*\" ) :\n\t\t\t[];\n\n\treturn tag === undefined || tag && jQuery.nodeName( context, tag ) ?\n\t\tjQuery.merge( [ context ], ret ) :\n\t\tret;\n}\n\n\n// Mark scripts as having already been evaluated\nfunction setGlobalEval( elems, refElements ) {\n\tvar i = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\tdataPriv.set(\n\t\t\telems[ i ],\n\t\t\t\"globalEval\",\n\t\t\t!refElements || dataPriv.get( refElements[ i ], \"globalEval\" )\n\t\t);\n\t}\n}\n\n\nvar rhtml = /<|&#?\\w+;/;\n\nfunction buildFragment( elems, context, scripts, selection, ignored ) {\n\tvar elem, tmp, tag, wrap, contains, j,\n\t\tfragment = context.createDocumentFragment(),\n\t\tnodes = [],\n\t\ti = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\telem = elems[ i ];\n\n\t\tif ( elem || elem === 0 ) {\n\n\t\t\t// Add nodes directly\n\t\t\tif ( jQuery.type( elem ) === \"object\" ) {\n\n\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );\n\n\t\t\t// Convert non-html into a text node\n\t\t\t} else if ( !rhtml.test( elem ) ) {\n\t\t\t\tnodes.push( context.createTextNode( elem ) );\n\n\t\t\t// Convert html into DOM nodes\n\t\t\t} else {\n\t\t\t\ttmp = tmp || fragment.appendChild( context.createElement( \"div\" ) );\n\n\t\t\t\t// Deserialize a standard representation\n\t\t\t\ttag = ( rtagName.exec( elem ) || [ \"\", \"\" ] )[ 1 ].toLowerCase();\n\t\t\t\twrap = wrapMap[ tag ] || wrapMap._default;\n\t\t\t\ttmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];\n\n\t\t\t\t// Descend through wrappers to the right content\n\t\t\t\tj = wrap[ 0 ];\n\t\t\t\twhile ( j-- ) {\n\t\t\t\t\ttmp = tmp.lastChild;\n\t\t\t\t}\n\n\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, tmp.childNodes );\n\n\t\t\t\t// Remember the top-level container\n\t\t\t\ttmp = fragment.firstChild;\n\n\t\t\t\t// Ensure the created nodes are orphaned (#12392)\n\t\t\t\ttmp.textContent = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove wrapper from fragment\n\tfragment.textContent = \"\";\n\n\ti = 0;\n\twhile ( ( elem = nodes[ i++ ] ) ) {\n\n\t\t// Skip elements already in the context collection (trac-4087)\n\t\tif ( selection && jQuery.inArray( elem, selection ) > -1 ) {\n\t\t\tif ( ignored ) {\n\t\t\t\tignored.push( elem );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tcontains = jQuery.contains( elem.ownerDocument, elem );\n\n\t\t// Append to fragment\n\t\ttmp = getAll( fragment.appendChild( elem ), \"script\" );\n\n\t\t// Preserve script evaluation history\n\t\tif ( contains ) {\n\t\t\tsetGlobalEval( tmp );\n\t\t}\n\n\t\t// Capture executables\n\t\tif ( scripts ) {\n\t\t\tj = 0;\n\t\t\twhile ( ( elem = tmp[ j++ ] ) ) {\n\t\t\t\tif ( rscriptType.test( elem.type || \"\" ) ) {\n\t\t\t\t\tscripts.push( elem );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn fragment;\n}\n\n\n( function() {\n\tvar fragment = document.createDocumentFragment(),\n\t\tdiv = fragment.appendChild( document.createElement( \"div\" ) ),\n\t\tinput = document.createElement( \"input\" );\n\n\t// Support: Android 4.0-4.3, Safari<=5.1\n\t// Check state lost if the name is set (#11217)\n\t// Support: Windows Web Apps (WWA)\n\t// `name` and `type` must use .setAttribute for WWA (#14901)\n\tinput.setAttribute( \"type\", \"radio\" );\n\tinput.setAttribute( \"checked\", \"checked\" );\n\tinput.setAttribute( \"name\", \"t\" );\n\n\tdiv.appendChild( input );\n\n\t// Support: Safari<=5.1, Android<4.2\n\t// Older WebKit doesn't clone checked state correctly in fragments\n\tsupport.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;\n\n\t// Support: IE<=11+\n\t// Make sure textarea (and checkbox) defaultValue is properly cloned\n\tdiv.innerHTML = \"<textarea>x</textarea>\";\n\tsupport.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;\n} )();\n\n\nvar\n\trkeyEvent = /^key/,\n\trmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,\n\trtypenamespace = /^([^.]*)(?:\\.(.+)|)/;\n\nfunction returnTrue() {\n\treturn true;\n}\n\nfunction returnFalse() {\n\treturn false;\n}\n\n// Support: IE9\n// See #13393 for more info\nfunction safeActiveElement() {\n\ttry {\n\t\treturn document.activeElement;\n\t} catch ( err ) { }\n}\n\nfunction on( elem, types, selector, data, fn, one ) {\n\tvar origFn, type;\n\n\t// Types can be a map of types/handlers\n\tif ( typeof types === \"object\" ) {\n\n\t\t// ( types-Object, selector, data )\n\t\tif ( typeof selector !== \"string\" ) {\n\n\t\t\t// ( types-Object, data )\n\t\t\tdata = data || selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tfor ( type in types ) {\n\t\t\ton( elem, type, selector, data, types[ type ], one );\n\t\t}\n\t\treturn elem;\n\t}\n\n\tif ( data == null && fn == null ) {\n\n\t\t// ( types, fn )\n\t\tfn = selector;\n\t\tdata = selector = undefined;\n\t} else if ( fn == null ) {\n\t\tif ( typeof selector === \"string\" ) {\n\n\t\t\t// ( types, selector, fn )\n\t\t\tfn = data;\n\t\t\tdata = undefined;\n\t\t} else {\n\n\t\t\t// ( types, data, fn )\n\t\t\tfn = data;\n\t\t\tdata = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t}\n\tif ( fn === false ) {\n\t\tfn = returnFalse;\n\t} else if ( !fn ) {\n\t\treturn elem;\n\t}\n\n\tif ( one === 1 ) {\n\t\torigFn = fn;\n\t\tfn = function( event ) {\n\n\t\t\t// Can use an empty set, since event contains the info\n\t\t\tjQuery().off( event );\n\t\t\treturn origFn.apply( this, arguments );\n\t\t};\n\n\t\t// Use same guid so caller can remove using origFn\n\t\tfn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );\n\t}\n\treturn elem.each( function() {\n\t\tjQuery.event.add( this, types, fn, data, selector );\n\t} );\n}\n\n/*\n * Helper functions for managing events -- not part of the public interface.\n * Props to Dean Edwards' addEvent library for many of the ideas.\n */\njQuery.event = {\n\n\tglobal: {},\n\n\tadd: function( elem, types, handler, data, selector ) {\n\n\t\tvar handleObjIn, eventHandle, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.get( elem );\n\n\t\t// Don't attach events to noData or text/comment nodes (but allow plain objects)\n\t\tif ( !elemData ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Caller can pass in an object of custom data in lieu of the handler\n\t\tif ( handler.handler ) {\n\t\t\thandleObjIn = handler;\n\t\t\thandler = handleObjIn.handler;\n\t\t\tselector = handleObjIn.selector;\n\t\t}\n\n\t\t// Make sure that the handler has a unique ID, used to find/remove it later\n\t\tif ( !handler.guid ) {\n\t\t\thandler.guid = jQuery.guid++;\n\t\t}\n\n\t\t// Init the element's event structure and main handler, if this is the first\n\t\tif ( !( events = elemData.events ) ) {\n\t\t\tevents = elemData.events = {};\n\t\t}\n\t\tif ( !( eventHandle = elemData.handle ) ) {\n\t\t\teventHandle = elemData.handle = function( e ) {\n\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== \"undefined\" && jQuery.event.triggered !== e.type ?\n\t\t\t\t\tjQuery.event.dispatch.apply( elem, arguments ) : undefined;\n\t\t\t};\n\t\t}\n\n\t\t// Handle multiple events separated by a space\n\t\ttypes = ( types || \"\" ).match( rnotwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// There *must* be a type, no attaching namespace-only handlers\n\t\t\tif ( !type ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If event changes its type, use the special event handlers for the changed type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// If selector defined, determine special event api type, otherwise given type\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\n\t\t\t// Update special based on newly reset type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// handleObj is passed to all event handlers\n\t\t\thandleObj = jQuery.extend( {\n\t\t\t\ttype: type,\n\t\t\t\torigType: origType,\n\t\t\t\tdata: data,\n\t\t\t\thandler: handler,\n\t\t\t\tguid: handler.guid,\n\t\t\t\tselector: selector,\n\t\t\t\tneedsContext: selector && jQuery.expr.match.needsContext.test( selector ),\n\t\t\t\tnamespace: namespaces.join( \".\" )\n\t\t\t}, handleObjIn );\n\n\t\t\t// Init the event handler queue if we're the first\n\t\t\tif ( !( handlers = events[ type ] ) ) {\n\t\t\t\thandlers = events[ type ] = [];\n\t\t\t\thandlers.delegateCount = 0;\n\n\t\t\t\t// Only use addEventListener if the special events handler returns false\n\t\t\t\tif ( !special.setup ||\n\t\t\t\t\tspecial.setup.call( elem, data, namespaces, eventHandle ) === false ) {\n\n\t\t\t\t\tif ( elem.addEventListener ) {\n\t\t\t\t\t\telem.addEventListener( type, eventHandle );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( special.add ) {\n\t\t\t\tspecial.add.call( elem, handleObj );\n\n\t\t\t\tif ( !handleObj.handler.guid ) {\n\t\t\t\t\thandleObj.handler.guid = handler.guid;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add to the element's handler list, delegates in front\n\t\t\tif ( selector ) {\n\t\t\t\thandlers.splice( handlers.delegateCount++, 0, handleObj );\n\t\t\t} else {\n\t\t\t\thandlers.push( handleObj );\n\t\t\t}\n\n\t\t\t// Keep track of which events have ever been used, for event optimization\n\t\t\tjQuery.event.global[ type ] = true;\n\t\t}\n\n\t},\n\n\t// Detach an event or set of events from an element\n\tremove: function( elem, types, handler, selector, mappedTypes ) {\n\n\t\tvar j, origCount, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.hasData( elem ) && dataPriv.get( elem );\n\n\t\tif ( !elemData || !( events = elemData.events ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Once for each type.namespace in types; type may be omitted\n\t\ttypes = ( types || \"\" ).match( rnotwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// Unbind all events (on this namespace, if provided) for the element\n\t\t\tif ( !type ) {\n\t\t\t\tfor ( type in events ) {\n\t\t\t\t\tjQuery.event.remove( elem, type + types[ t ], handler, selector, true );\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\t\t\thandlers = events[ type ] || [];\n\t\t\ttmp = tmp[ 2 ] &&\n\t\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" );\n\n\t\t\t// Remove matching events\n\t\t\torigCount = j = handlers.length;\n\t\t\twhile ( j-- ) {\n\t\t\t\thandleObj = handlers[ j ];\n\n\t\t\t\tif ( ( mappedTypes || origType === handleObj.origType ) &&\n\t\t\t\t\t( !handler || handler.guid === handleObj.guid ) &&\n\t\t\t\t\t( !tmp || tmp.test( handleObj.namespace ) ) &&\n\t\t\t\t\t( !selector || selector === handleObj.selector ||\n\t\t\t\t\t\tselector === \"**\" && handleObj.selector ) ) {\n\t\t\t\t\thandlers.splice( j, 1 );\n\n\t\t\t\t\tif ( handleObj.selector ) {\n\t\t\t\t\t\thandlers.delegateCount--;\n\t\t\t\t\t}\n\t\t\t\t\tif ( special.remove ) {\n\t\t\t\t\t\tspecial.remove.call( elem, handleObj );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove generic event handler if we removed something and no more handlers exist\n\t\t\t// (avoids potential for endless recursion during removal of special event handlers)\n\t\t\tif ( origCount && !handlers.length ) {\n\t\t\t\tif ( !special.teardown ||\n\t\t\t\t\tspecial.teardown.call( elem, namespaces, elemData.handle ) === false ) {\n\n\t\t\t\t\tjQuery.removeEvent( elem, type, elemData.handle );\n\t\t\t\t}\n\n\t\t\t\tdelete events[ type ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove data and the expando if it's no longer used\n\t\tif ( jQuery.isEmptyObject( events ) ) {\n\t\t\tdataPriv.remove( elem, \"handle events\" );\n\t\t}\n\t},\n\n\tdispatch: function( event ) {\n\n\t\t// Make a writable jQuery.Event from the native event object\n\t\tevent = jQuery.event.fix( event );\n\n\t\tvar i, j, ret, matched, handleObj,\n\t\t\thandlerQueue = [],\n\t\t\targs = slice.call( arguments ),\n\t\t\thandlers = ( dataPriv.get( this, \"events\" ) || {} )[ event.type ] || [],\n\t\t\tspecial = jQuery.event.special[ event.type ] || {};\n\n\t\t// Use the fix-ed jQuery.Event rather than the (read-only) native event\n\t\targs[ 0 ] = event;\n\t\tevent.delegateTarget = this;\n\n\t\t// Call the preDispatch hook for the mapped type, and let it bail if desired\n\t\tif ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine handlers\n\t\thandlerQueue = jQuery.event.handlers.call( this, event, handlers );\n\n\t\t// Run delegates first; they may want to stop propagation beneath us\n\t\ti = 0;\n\t\twhile ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {\n\t\t\tevent.currentTarget = matched.elem;\n\n\t\t\tj = 0;\n\t\t\twhile ( ( handleObj = matched.handlers[ j++ ] ) &&\n\t\t\t\t!event.isImmediatePropagationStopped() ) {\n\n\t\t\t\t// Triggered event must either 1) have no namespace, or 2) have namespace(s)\n\t\t\t\t// a subset or equal to those in the bound event (both can have no namespace).\n\t\t\t\tif ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {\n\n\t\t\t\t\tevent.handleObj = handleObj;\n\t\t\t\t\tevent.data = handleObj.data;\n\n\t\t\t\t\tret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||\n\t\t\t\t\t\thandleObj.handler ).apply( matched.elem, args );\n\n\t\t\t\t\tif ( ret !== undefined ) {\n\t\t\t\t\t\tif ( ( event.result = ret ) === false ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Call the postDispatch hook for the mapped type\n\t\tif ( special.postDispatch ) {\n\t\t\tspecial.postDispatch.call( this, event );\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\thandlers: function( event, handlers ) {\n\t\tvar i, matches, sel, handleObj,\n\t\t\thandlerQueue = [],\n\t\t\tdelegateCount = handlers.delegateCount,\n\t\t\tcur = event.target;\n\n\t\t// Support (at least): Chrome, IE9\n\t\t// Find delegate handlers\n\t\t// Black-hole SVG <use> instance trees (#13180)\n\t\t//\n\t\t// Support: Firefox<=42+\n\t\t// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)\n\t\tif ( delegateCount && cur.nodeType &&\n\t\t\t( event.type !== \"click\" || isNaN( event.button ) || event.button < 1 ) ) {\n\n\t\t\tfor ( ; cur !== this; cur = cur.parentNode || this ) {\n\n\t\t\t\t// Don't check non-elements (#13208)\n\t\t\t\t// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)\n\t\t\t\tif ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== \"click\" ) ) {\n\t\t\t\t\tmatches = [];\n\t\t\t\t\tfor ( i = 0; i < delegateCount; i++ ) {\n\t\t\t\t\t\thandleObj = handlers[ i ];\n\n\t\t\t\t\t\t// Don't conflict with Object.prototype properties (#13203)\n\t\t\t\t\t\tsel = handleObj.selector + \" \";\n\n\t\t\t\t\t\tif ( matches[ sel ] === undefined ) {\n\t\t\t\t\t\t\tmatches[ sel ] = handleObj.needsContext ?\n\t\t\t\t\t\t\t\tjQuery( sel, this ).index( cur ) > -1 :\n\t\t\t\t\t\t\t\tjQuery.find( sel, this, null, [ cur ] ).length;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( matches[ sel ] ) {\n\t\t\t\t\t\t\tmatches.push( handleObj );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( matches.length ) {\n\t\t\t\t\t\thandlerQueue.push( { elem: cur, handlers: matches } );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add the remaining (directly-bound) handlers\n\t\tif ( delegateCount < handlers.length ) {\n\t\t\thandlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );\n\t\t}\n\n\t\treturn handlerQueue;\n\t},\n\n\t// Includes some event props shared by KeyEvent and MouseEvent\n\tprops: ( \"altKey bubbles cancelable ctrlKey currentTarget detail eventPhase \" +\n\t\t\"metaKey relatedTarget shiftKey target timeStamp view which\" ).split( \" \" ),\n\n\tfixHooks: {},\n\n\tkeyHooks: {\n\t\tprops: \"char charCode key keyCode\".split( \" \" ),\n\t\tfilter: function( event, original ) {\n\n\t\t\t// Add which for key events\n\t\t\tif ( event.which == null ) {\n\t\t\t\tevent.which = original.charCode != null ? original.charCode : original.keyCode;\n\t\t\t}\n\n\t\t\treturn event;\n\t\t}\n\t},\n\n\tmouseHooks: {\n\t\tprops: ( \"button buttons clientX clientY offsetX offsetY pageX pageY \" +\n\t\t\t\"screenX screenY toElement\" ).split( \" \" ),\n\t\tfilter: function( event, original ) {\n\t\t\tvar eventDoc, doc, body,\n\t\t\t\tbutton = original.button;\n\n\t\t\t// Calculate pageX/Y if missing and clientX/Y available\n\t\t\tif ( event.pageX == null && original.clientX != null ) {\n\t\t\t\teventDoc = event.target.ownerDocument || document;\n\t\t\t\tdoc = eventDoc.documentElement;\n\t\t\t\tbody = eventDoc.body;\n\n\t\t\t\tevent.pageX = original.clientX +\n\t\t\t\t\t( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -\n\t\t\t\t\t( doc && doc.clientLeft || body && body.clientLeft || 0 );\n\t\t\t\tevent.pageY = original.clientY +\n\t\t\t\t\t( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) -\n\t\t\t\t\t( doc && doc.clientTop  || body && body.clientTop  || 0 );\n\t\t\t}\n\n\t\t\t// Add which for click: 1 === left; 2 === middle; 3 === right\n\t\t\t// Note: button is not normalized, so don't use it\n\t\t\tif ( !event.which && button !== undefined ) {\n\t\t\t\tevent.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );\n\t\t\t}\n\n\t\t\treturn event;\n\t\t}\n\t},\n\n\tfix: function( event ) {\n\t\tif ( event[ jQuery.expando ] ) {\n\t\t\treturn event;\n\t\t}\n\n\t\t// Create a writable copy of the event object and normalize some properties\n\t\tvar i, prop, copy,\n\t\t\ttype = event.type,\n\t\t\toriginalEvent = event,\n\t\t\tfixHook = this.fixHooks[ type ];\n\n\t\tif ( !fixHook ) {\n\t\t\tthis.fixHooks[ type ] = fixHook =\n\t\t\t\trmouseEvent.test( type ) ? this.mouseHooks :\n\t\t\t\trkeyEvent.test( type ) ? this.keyHooks :\n\t\t\t\t{};\n\t\t}\n\t\tcopy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;\n\n\t\tevent = new jQuery.Event( originalEvent );\n\n\t\ti = copy.length;\n\t\twhile ( i-- ) {\n\t\t\tprop = copy[ i ];\n\t\t\tevent[ prop ] = originalEvent[ prop ];\n\t\t}\n\n\t\t// Support: Cordova 2.5 (WebKit) (#13255)\n\t\t// All events should have a target; Cordova deviceready doesn't\n\t\tif ( !event.target ) {\n\t\t\tevent.target = document;\n\t\t}\n\n\t\t// Support: Safari 6.0+, Chrome<28\n\t\t// Target should not be a text node (#504, #13143)\n\t\tif ( event.target.nodeType === 3 ) {\n\t\t\tevent.target = event.target.parentNode;\n\t\t}\n\n\t\treturn fixHook.filter ? fixHook.filter( event, originalEvent ) : event;\n\t},\n\n\tspecial: {\n\t\tload: {\n\n\t\t\t// Prevent triggered image.load events from bubbling to window.load\n\t\t\tnoBubble: true\n\t\t},\n\t\tfocus: {\n\n\t\t\t// Fire native event if possible so blur/focus sequence is correct\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this !== safeActiveElement() && this.focus ) {\n\t\t\t\t\tthis.focus();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelegateType: \"focusin\"\n\t\t},\n\t\tblur: {\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this === safeActiveElement() && this.blur ) {\n\t\t\t\t\tthis.blur();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelegateType: \"focusout\"\n\t\t},\n\t\tclick: {\n\n\t\t\t// For checkbox, fire native event so checked state will be right\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this.type === \"checkbox\" && this.click && jQuery.nodeName( this, \"input\" ) ) {\n\t\t\t\t\tthis.click();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// For cross-browser consistency, don't fire native .click() on links\n\t\t\t_default: function( event ) {\n\t\t\t\treturn jQuery.nodeName( event.target, \"a\" );\n\t\t\t}\n\t\t},\n\n\t\tbeforeunload: {\n\t\t\tpostDispatch: function( event ) {\n\n\t\t\t\t// Support: Firefox 20+\n\t\t\t\t// Firefox doesn't alert if the returnValue field is not set.\n\t\t\t\tif ( event.result !== undefined && event.originalEvent ) {\n\t\t\t\t\tevent.originalEvent.returnValue = event.result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\njQuery.removeEvent = function( elem, type, handle ) {\n\n\t// This \"if\" is needed for plain objects\n\tif ( elem.removeEventListener ) {\n\t\telem.removeEventListener( type, handle );\n\t}\n};\n\njQuery.Event = function( src, props ) {\n\n\t// Allow instantiation without the 'new' keyword\n\tif ( !( this instanceof jQuery.Event ) ) {\n\t\treturn new jQuery.Event( src, props );\n\t}\n\n\t// Event object\n\tif ( src && src.type ) {\n\t\tthis.originalEvent = src;\n\t\tthis.type = src.type;\n\n\t\t// Events bubbling up the document may have been marked as prevented\n\t\t// by a handler lower down the tree; reflect the correct value.\n\t\tthis.isDefaultPrevented = src.defaultPrevented ||\n\t\t\t\tsrc.defaultPrevented === undefined &&\n\n\t\t\t\t// Support: Android<4.0\n\t\t\t\tsrc.returnValue === false ?\n\t\t\treturnTrue :\n\t\t\treturnFalse;\n\n\t// Event type\n\t} else {\n\t\tthis.type = src;\n\t}\n\n\t// Put explicitly provided properties onto the event object\n\tif ( props ) {\n\t\tjQuery.extend( this, props );\n\t}\n\n\t// Create a timestamp if incoming event doesn't have one\n\tthis.timeStamp = src && src.timeStamp || jQuery.now();\n\n\t// Mark it as fixed\n\tthis[ jQuery.expando ] = true;\n};\n\n// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding\n// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html\njQuery.Event.prototype = {\n\tconstructor: jQuery.Event,\n\tisDefaultPrevented: returnFalse,\n\tisPropagationStopped: returnFalse,\n\tisImmediatePropagationStopped: returnFalse,\n\n\tpreventDefault: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isDefaultPrevented = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.preventDefault();\n\t\t}\n\t},\n\tstopPropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isPropagationStopped = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.stopPropagation();\n\t\t}\n\t},\n\tstopImmediatePropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isImmediatePropagationStopped = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.stopImmediatePropagation();\n\t\t}\n\n\t\tthis.stopPropagation();\n\t}\n};\n\n// Create mouseenter/leave events using mouseover/out and event-time checks\n// so that event delegation works in jQuery.\n// Do the same for pointerenter/pointerleave and pointerover/pointerout\n//\n// Support: Safari 7 only\n// Safari sends mouseenter too often; see:\n// https://code.google.com/p/chromium/issues/detail?id=470258\n// for the description of the bug (it existed in older Chrome versions as well).\njQuery.each( {\n\tmouseenter: \"mouseover\",\n\tmouseleave: \"mouseout\",\n\tpointerenter: \"pointerover\",\n\tpointerleave: \"pointerout\"\n}, function( orig, fix ) {\n\tjQuery.event.special[ orig ] = {\n\t\tdelegateType: fix,\n\t\tbindType: fix,\n\n\t\thandle: function( event ) {\n\t\t\tvar ret,\n\t\t\t\ttarget = this,\n\t\t\t\trelated = event.relatedTarget,\n\t\t\t\thandleObj = event.handleObj;\n\n\t\t\t// For mouseenter/leave call the handler if related is outside the target.\n\t\t\t// NB: No relatedTarget if the mouse left/entered the browser window\n\t\t\tif ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {\n\t\t\t\tevent.type = handleObj.origType;\n\t\t\t\tret = handleObj.handler.apply( this, arguments );\n\t\t\t\tevent.type = fix;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t};\n} );\n\njQuery.fn.extend( {\n\ton: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn );\n\t},\n\tone: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn, 1 );\n\t},\n\toff: function( types, selector, fn ) {\n\t\tvar handleObj, type;\n\t\tif ( types && types.preventDefault && types.handleObj ) {\n\n\t\t\t// ( event )  dispatched jQuery.Event\n\t\t\thandleObj = types.handleObj;\n\t\t\tjQuery( types.delegateTarget ).off(\n\t\t\t\thandleObj.namespace ?\n\t\t\t\t\thandleObj.origType + \".\" + handleObj.namespace :\n\t\t\t\t\thandleObj.origType,\n\t\t\t\thandleObj.selector,\n\t\t\t\thandleObj.handler\n\t\t\t);\n\t\t\treturn this;\n\t\t}\n\t\tif ( typeof types === \"object\" ) {\n\n\t\t\t// ( types-object [, selector] )\n\t\t\tfor ( type in types ) {\n\t\t\t\tthis.off( type, selector, types[ type ] );\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\tif ( selector === false || typeof selector === \"function\" ) {\n\n\t\t\t// ( types [, fn] )\n\t\t\tfn = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tif ( fn === false ) {\n\t\t\tfn = returnFalse;\n\t\t}\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.remove( this, types, fn, selector );\n\t\t} );\n\t}\n} );\n\n\nvar\n\trxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\\w:-]+)[^>]*)\\/>/gi,\n\n\t// Support: IE 10-11, Edge 10240+\n\t// In IE/Edge using regex groups here causes severe slowdowns.\n\t// See https://connect.microsoft.com/IE/feedback/details/1736512/\n\trnoInnerhtml = /<script|<style|<link/i,\n\n\t// checked=\"checked\" or checked\n\trchecked = /checked\\s*(?:[^=]|=\\s*.checked.)/i,\n\trscriptTypeMasked = /^true\\/(.*)/,\n\trcleanScript = /^\\s*<!(?:\\[CDATA\\[|--)|(?:\\]\\]|--)>\\s*$/g;\n\n// Manipulating tables requires a tbody\nfunction manipulationTarget( elem, content ) {\n\treturn jQuery.nodeName( elem, \"table\" ) &&\n\t\tjQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, \"tr\" ) ?\n\n\t\telem.getElementsByTagName( \"tbody\" )[ 0 ] ||\n\t\t\telem.appendChild( elem.ownerDocument.createElement( \"tbody\" ) ) :\n\t\telem;\n}\n\n// Replace/restore the type attribute of script elements for safe DOM manipulation\nfunction disableScript( elem ) {\n\telem.type = ( elem.getAttribute( \"type\" ) !== null ) + \"/\" + elem.type;\n\treturn elem;\n}\nfunction restoreScript( elem ) {\n\tvar match = rscriptTypeMasked.exec( elem.type );\n\n\tif ( match ) {\n\t\telem.type = match[ 1 ];\n\t} else {\n\t\telem.removeAttribute( \"type\" );\n\t}\n\n\treturn elem;\n}\n\nfunction cloneCopyEvent( src, dest ) {\n\tvar i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;\n\n\tif ( dest.nodeType !== 1 ) {\n\t\treturn;\n\t}\n\n\t// 1. Copy private data: events, handlers, etc.\n\tif ( dataPriv.hasData( src ) ) {\n\t\tpdataOld = dataPriv.access( src );\n\t\tpdataCur = dataPriv.set( dest, pdataOld );\n\t\tevents = pdataOld.events;\n\n\t\tif ( events ) {\n\t\t\tdelete pdataCur.handle;\n\t\t\tpdataCur.events = {};\n\n\t\t\tfor ( type in events ) {\n\t\t\t\tfor ( i = 0, l = events[ type ].length; i < l; i++ ) {\n\t\t\t\t\tjQuery.event.add( dest, type, events[ type ][ i ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Copy user data\n\tif ( dataUser.hasData( src ) ) {\n\t\tudataOld = dataUser.access( src );\n\t\tudataCur = jQuery.extend( {}, udataOld );\n\n\t\tdataUser.set( dest, udataCur );\n\t}\n}\n\n// Fix IE bugs, see support tests\nfunction fixInput( src, dest ) {\n\tvar nodeName = dest.nodeName.toLowerCase();\n\n\t// Fails to persist the checked state of a cloned checkbox or radio button.\n\tif ( nodeName === \"input\" && rcheckableType.test( src.type ) ) {\n\t\tdest.checked = src.checked;\n\n\t// Fails to return the selected option to the default selected state when cloning options\n\t} else if ( nodeName === \"input\" || nodeName === \"textarea\" ) {\n\t\tdest.defaultValue = src.defaultValue;\n\t}\n}\n\nfunction domManip( collection, args, callback, ignored ) {\n\n\t// Flatten any nested arrays\n\targs = concat.apply( [], args );\n\n\tvar fragment, first, scripts, hasScripts, node, doc,\n\t\ti = 0,\n\t\tl = collection.length,\n\t\tiNoClone = l - 1,\n\t\tvalue = args[ 0 ],\n\t\tisFunction = jQuery.isFunction( value );\n\n\t// We can't cloneNode fragments that contain checked, in WebKit\n\tif ( isFunction ||\n\t\t\t( l > 1 && typeof value === \"string\" &&\n\t\t\t\t!support.checkClone && rchecked.test( value ) ) ) {\n\t\treturn collection.each( function( index ) {\n\t\t\tvar self = collection.eq( index );\n\t\t\tif ( isFunction ) {\n\t\t\t\targs[ 0 ] = value.call( this, index, self.html() );\n\t\t\t}\n\t\t\tdomManip( self, args, callback, ignored );\n\t\t} );\n\t}\n\n\tif ( l ) {\n\t\tfragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );\n\t\tfirst = fragment.firstChild;\n\n\t\tif ( fragment.childNodes.length === 1 ) {\n\t\t\tfragment = first;\n\t\t}\n\n\t\t// Require either new content or an interest in ignored elements to invoke the callback\n\t\tif ( first || ignored ) {\n\t\t\tscripts = jQuery.map( getAll( fragment, \"script\" ), disableScript );\n\t\t\thasScripts = scripts.length;\n\n\t\t\t// Use the original fragment for the last item\n\t\t\t// instead of the first because it can end up\n\t\t\t// being emptied incorrectly in certain situations (#8070).\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tnode = fragment;\n\n\t\t\t\tif ( i !== iNoClone ) {\n\t\t\t\t\tnode = jQuery.clone( node, true, true );\n\n\t\t\t\t\t// Keep references to cloned scripts for later restoration\n\t\t\t\t\tif ( hasScripts ) {\n\n\t\t\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\t\t\tjQuery.merge( scripts, getAll( node, \"script\" ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcallback.call( collection[ i ], node, i );\n\t\t\t}\n\n\t\t\tif ( hasScripts ) {\n\t\t\t\tdoc = scripts[ scripts.length - 1 ].ownerDocument;\n\n\t\t\t\t// Reenable scripts\n\t\t\t\tjQuery.map( scripts, restoreScript );\n\n\t\t\t\t// Evaluate executable scripts on first document insertion\n\t\t\t\tfor ( i = 0; i < hasScripts; i++ ) {\n\t\t\t\t\tnode = scripts[ i ];\n\t\t\t\t\tif ( rscriptType.test( node.type || \"\" ) &&\n\t\t\t\t\t\t!dataPriv.access( node, \"globalEval\" ) &&\n\t\t\t\t\t\tjQuery.contains( doc, node ) ) {\n\n\t\t\t\t\t\tif ( node.src ) {\n\n\t\t\t\t\t\t\t// Optional AJAX dependency, but won't run scripts if not present\n\t\t\t\t\t\t\tif ( jQuery._evalUrl ) {\n\t\t\t\t\t\t\t\tjQuery._evalUrl( node.src );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tjQuery.globalEval( node.textContent.replace( rcleanScript, \"\" ) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn collection;\n}\n\nfunction remove( elem, selector, keepData ) {\n\tvar node,\n\t\tnodes = selector ? jQuery.filter( selector, elem ) : elem,\n\t\ti = 0;\n\n\tfor ( ; ( node = nodes[ i ] ) != null; i++ ) {\n\t\tif ( !keepData && node.nodeType === 1 ) {\n\t\t\tjQuery.cleanData( getAll( node ) );\n\t\t}\n\n\t\tif ( node.parentNode ) {\n\t\t\tif ( keepData && jQuery.contains( node.ownerDocument, node ) ) {\n\t\t\t\tsetGlobalEval( getAll( node, \"script\" ) );\n\t\t\t}\n\t\t\tnode.parentNode.removeChild( node );\n\t\t}\n\t}\n\n\treturn elem;\n}\n\njQuery.extend( {\n\thtmlPrefilter: function( html ) {\n\t\treturn html.replace( rxhtmlTag, \"<$1></$2>\" );\n\t},\n\n\tclone: function( elem, dataAndEvents, deepDataAndEvents ) {\n\t\tvar i, l, srcElements, destElements,\n\t\t\tclone = elem.cloneNode( true ),\n\t\t\tinPage = jQuery.contains( elem.ownerDocument, elem );\n\n\t\t// Fix IE cloning issues\n\t\tif ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&\n\t\t\t\t!jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2\n\t\t\tdestElements = getAll( clone );\n\t\t\tsrcElements = getAll( elem );\n\n\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\tfixInput( srcElements[ i ], destElements[ i ] );\n\t\t\t}\n\t\t}\n\n\t\t// Copy the events from the original to the clone\n\t\tif ( dataAndEvents ) {\n\t\t\tif ( deepDataAndEvents ) {\n\t\t\t\tsrcElements = srcElements || getAll( elem );\n\t\t\t\tdestElements = destElements || getAll( clone );\n\n\t\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\t\tcloneCopyEvent( srcElements[ i ], destElements[ i ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcloneCopyEvent( elem, clone );\n\t\t\t}\n\t\t}\n\n\t\t// Preserve script evaluation history\n\t\tdestElements = getAll( clone, \"script\" );\n\t\tif ( destElements.length > 0 ) {\n\t\t\tsetGlobalEval( destElements, !inPage && getAll( elem, \"script\" ) );\n\t\t}\n\n\t\t// Return the cloned set\n\t\treturn clone;\n\t},\n\n\tcleanData: function( elems ) {\n\t\tvar data, elem, type,\n\t\t\tspecial = jQuery.event.special,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {\n\t\t\tif ( acceptData( elem ) ) {\n\t\t\t\tif ( ( data = elem[ dataPriv.expando ] ) ) {\n\t\t\t\t\tif ( data.events ) {\n\t\t\t\t\t\tfor ( type in data.events ) {\n\t\t\t\t\t\t\tif ( special[ type ] ) {\n\t\t\t\t\t\t\t\tjQuery.event.remove( elem, type );\n\n\t\t\t\t\t\t\t// This is a shortcut to avoid jQuery.event.remove's overhead\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tjQuery.removeEvent( elem, type, data.handle );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Support: Chrome <= 35-45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataPriv.expando ] = undefined;\n\t\t\t\t}\n\t\t\t\tif ( elem[ dataUser.expando ] ) {\n\n\t\t\t\t\t// Support: Chrome <= 35-45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataUser.expando ] = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n} );\n\njQuery.fn.extend( {\n\n\t// Keep domManip exposed until 3.0 (gh-2225)\n\tdomManip: domManip,\n\n\tdetach: function( selector ) {\n\t\treturn remove( this, selector, true );\n\t},\n\n\tremove: function( selector ) {\n\t\treturn remove( this, selector );\n\t},\n\n\ttext: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\treturn value === undefined ?\n\t\t\t\tjQuery.text( this ) :\n\t\t\t\tthis.empty().each( function() {\n\t\t\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\t\t\tthis.textContent = value;\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t}, null, value, arguments.length );\n\t},\n\n\tappend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.appendChild( elem );\n\t\t\t}\n\t\t} );\n\t},\n\n\tprepend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.insertBefore( elem, target.firstChild );\n\t\t\t}\n\t\t} );\n\t},\n\n\tbefore: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this );\n\t\t\t}\n\t\t} );\n\t},\n\n\tafter: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this.nextSibling );\n\t\t\t}\n\t\t} );\n\t},\n\n\tempty: function() {\n\t\tvar elem,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = this[ i ] ) != null; i++ ) {\n\t\t\tif ( elem.nodeType === 1 ) {\n\n\t\t\t\t// Prevent memory leaks\n\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\n\t\t\t\t// Remove any remaining nodes\n\t\t\t\telem.textContent = \"\";\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tclone: function( dataAndEvents, deepDataAndEvents ) {\n\t\tdataAndEvents = dataAndEvents == null ? false : dataAndEvents;\n\t\tdeepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;\n\n\t\treturn this.map( function() {\n\t\t\treturn jQuery.clone( this, dataAndEvents, deepDataAndEvents );\n\t\t} );\n\t},\n\n\thtml: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\tvar elem = this[ 0 ] || {},\n\t\t\t\ti = 0,\n\t\t\t\tl = this.length;\n\n\t\t\tif ( value === undefined && elem.nodeType === 1 ) {\n\t\t\t\treturn elem.innerHTML;\n\t\t\t}\n\n\t\t\t// See if we can take a shortcut and just use innerHTML\n\t\t\tif ( typeof value === \"string\" && !rnoInnerhtml.test( value ) &&\n\t\t\t\t!wrapMap[ ( rtagName.exec( value ) || [ \"\", \"\" ] )[ 1 ].toLowerCase() ] ) {\n\n\t\t\t\tvalue = jQuery.htmlPrefilter( value );\n\n\t\t\t\ttry {\n\t\t\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\t\t\telem = this[ i ] || {};\n\n\t\t\t\t\t\t// Remove element nodes and prevent memory leaks\n\t\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\t\t\t\t\t\t\telem.innerHTML = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\telem = 0;\n\n\t\t\t\t// If using innerHTML throws an exception, use the fallback method\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\tif ( elem ) {\n\t\t\t\tthis.empty().append( value );\n\t\t\t}\n\t\t}, null, value, arguments.length );\n\t},\n\n\treplaceWith: function() {\n\t\tvar ignored = [];\n\n\t\t// Make the changes, replacing each non-ignored context element with the new content\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tvar parent = this.parentNode;\n\n\t\t\tif ( jQuery.inArray( this, ignored ) < 0 ) {\n\t\t\t\tjQuery.cleanData( getAll( this ) );\n\t\t\t\tif ( parent ) {\n\t\t\t\t\tparent.replaceChild( elem, this );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Force callback invocation\n\t\t}, ignored );\n\t}\n} );\n\njQuery.each( {\n\tappendTo: \"append\",\n\tprependTo: \"prepend\",\n\tinsertBefore: \"before\",\n\tinsertAfter: \"after\",\n\treplaceAll: \"replaceWith\"\n}, function( name, original ) {\n\tjQuery.fn[ name ] = function( selector ) {\n\t\tvar elems,\n\t\t\tret = [],\n\t\t\tinsert = jQuery( selector ),\n\t\t\tlast = insert.length - 1,\n\t\t\ti = 0;\n\n\t\tfor ( ; i <= last; i++ ) {\n\t\t\telems = i === last ? this : this.clone( true );\n\t\t\tjQuery( insert[ i ] )[ original ]( elems );\n\n\t\t\t// Support: QtWebKit\n\t\t\t// .get() because push.apply(_, arraylike) throws\n\t\t\tpush.apply( ret, elems.get() );\n\t\t}\n\n\t\treturn this.pushStack( ret );\n\t};\n} );\n\n\nvar iframe,\n\telemdisplay = {\n\n\t\t// Support: Firefox\n\t\t// We have to pre-define these values for FF (#10227)\n\t\tHTML: \"block\",\n\t\tBODY: \"block\"\n\t};\n\n/**\n * Retrieve the actual display of a element\n * @param {String} name nodeName of the element\n * @param {Object} doc Document object\n */\n\n// Called only from within defaultDisplay\nfunction actualDisplay( name, doc ) {\n\tvar elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),\n\n\t\tdisplay = jQuery.css( elem[ 0 ], \"display\" );\n\n\t// We don't have any data stored on the element,\n\t// so use \"detach\" method as fast way to get rid of the element\n\telem.detach();\n\n\treturn display;\n}\n\n/**\n * Try to determine the default display value of an element\n * @param {String} nodeName\n */\nfunction defaultDisplay( nodeName ) {\n\tvar doc = document,\n\t\tdisplay = elemdisplay[ nodeName ];\n\n\tif ( !display ) {\n\t\tdisplay = actualDisplay( nodeName, doc );\n\n\t\t// If the simple way fails, read from inside an iframe\n\t\tif ( display === \"none\" || !display ) {\n\n\t\t\t// Use the already-created iframe if possible\n\t\t\tiframe = ( iframe || jQuery( \"<iframe frameborder='0' width='0' height='0'/>\" ) )\n\t\t\t\t.appendTo( doc.documentElement );\n\n\t\t\t// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse\n\t\t\tdoc = iframe[ 0 ].contentDocument;\n\n\t\t\t// Support: IE\n\t\t\tdoc.write();\n\t\t\tdoc.close();\n\n\t\t\tdisplay = actualDisplay( nodeName, doc );\n\t\t\tiframe.detach();\n\t\t}\n\n\t\t// Store the correct default display\n\t\telemdisplay[ nodeName ] = display;\n\t}\n\n\treturn display;\n}\nvar rmargin = ( /^margin/ );\n\nvar rnumnonpx = new RegExp( \"^(\" + pnum + \")(?!px)[a-z%]+$\", \"i\" );\n\nvar getStyles = function( elem ) {\n\n\t\t// Support: IE<=11+, Firefox<=30+ (#15098, #14150)\n\t\t// IE throws on elements created in popups\n\t\t// FF meanwhile throws on frame elements through \"defaultView.getComputedStyle\"\n\t\tvar view = elem.ownerDocument.defaultView;\n\n\t\tif ( !view || !view.opener ) {\n\t\t\tview = window;\n\t\t}\n\n\t\treturn view.getComputedStyle( elem );\n\t};\n\nvar swap = function( elem, options, callback, args ) {\n\tvar ret, name,\n\t\told = {};\n\n\t// Remember the old values, and insert the new ones\n\tfor ( name in options ) {\n\t\told[ name ] = elem.style[ name ];\n\t\telem.style[ name ] = options[ name ];\n\t}\n\n\tret = callback.apply( elem, args || [] );\n\n\t// Revert the old values\n\tfor ( name in options ) {\n\t\telem.style[ name ] = old[ name ];\n\t}\n\n\treturn ret;\n};\n\n\nvar documentElement = document.documentElement;\n\n\n\n( function() {\n\tvar pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,\n\t\tcontainer = document.createElement( \"div\" ),\n\t\tdiv = document.createElement( \"div\" );\n\n\t// Finish early in limited (non-browser) environments\n\tif ( !div.style ) {\n\t\treturn;\n\t}\n\n\t// Support: IE9-11+\n\t// Style of cloned element affects source element cloned (#8908)\n\tdiv.style.backgroundClip = \"content-box\";\n\tdiv.cloneNode( true ).style.backgroundClip = \"\";\n\tsupport.clearCloneStyle = div.style.backgroundClip === \"content-box\";\n\n\tcontainer.style.cssText = \"border:0;width:8px;height:0;top:0;left:-9999px;\" +\n\t\t\"padding:0;margin-top:1px;position:absolute\";\n\tcontainer.appendChild( div );\n\n\t// Executing both pixelPosition & boxSizingReliable tests require only one layout\n\t// so they're executed at the same time to save the second computation.\n\tfunction computeStyleTests() {\n\t\tdiv.style.cssText =\n\n\t\t\t// Support: Firefox<29, Android 2.3\n\t\t\t// Vendor-prefix box-sizing\n\t\t\t\"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;\" +\n\t\t\t\"position:relative;display:block;\" +\n\t\t\t\"margin:auto;border:1px;padding:1px;\" +\n\t\t\t\"top:1%;width:50%\";\n\t\tdiv.innerHTML = \"\";\n\t\tdocumentElement.appendChild( container );\n\n\t\tvar divStyle = window.getComputedStyle( div );\n\t\tpixelPositionVal = divStyle.top !== \"1%\";\n\t\treliableMarginLeftVal = divStyle.marginLeft === \"2px\";\n\t\tboxSizingReliableVal = divStyle.width === \"4px\";\n\n\t\t// Support: Android 4.0 - 4.3 only\n\t\t// Some styles come back with percentage values, even though they shouldn't\n\t\tdiv.style.marginRight = \"50%\";\n\t\tpixelMarginRightVal = divStyle.marginRight === \"4px\";\n\n\t\tdocumentElement.removeChild( container );\n\t}\n\n\tjQuery.extend( support, {\n\t\tpixelPosition: function() {\n\n\t\t\t// This test is executed only once but we still do memoizing\n\t\t\t// since we can use the boxSizingReliable pre-computing.\n\t\t\t// No need to check if the test was already performed, though.\n\t\t\tcomputeStyleTests();\n\t\t\treturn pixelPositionVal;\n\t\t},\n\t\tboxSizingReliable: function() {\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn boxSizingReliableVal;\n\t\t},\n\t\tpixelMarginRight: function() {\n\n\t\t\t// Support: Android 4.0-4.3\n\t\t\t// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal\n\t\t\t// since that compresses better and they're computed together anyway.\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn pixelMarginRightVal;\n\t\t},\n\t\treliableMarginLeft: function() {\n\n\t\t\t// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn reliableMarginLeftVal;\n\t\t},\n\t\treliableMarginRight: function() {\n\n\t\t\t// Support: Android 2.3\n\t\t\t// Check if div with explicit width and no margin-right incorrectly\n\t\t\t// gets computed margin-right based on width of container. (#3333)\n\t\t\t// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right\n\t\t\t// This support function is only executed once so no memoizing is needed.\n\t\t\tvar ret,\n\t\t\t\tmarginDiv = div.appendChild( document.createElement( \"div\" ) );\n\n\t\t\t// Reset CSS: box-sizing; display; margin; border; padding\n\t\t\tmarginDiv.style.cssText = div.style.cssText =\n\n\t\t\t\t// Support: Android 2.3\n\t\t\t\t// Vendor-prefix box-sizing\n\t\t\t\t\"-webkit-box-sizing:content-box;box-sizing:content-box;\" +\n\t\t\t\t\"display:block;margin:0;border:0;padding:0\";\n\t\t\tmarginDiv.style.marginRight = marginDiv.style.width = \"0\";\n\t\t\tdiv.style.width = \"1px\";\n\t\t\tdocumentElement.appendChild( container );\n\n\t\t\tret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );\n\n\t\t\tdocumentElement.removeChild( container );\n\t\t\tdiv.removeChild( marginDiv );\n\n\t\t\treturn ret;\n\t\t}\n\t} );\n} )();\n\n\nfunction curCSS( elem, name, computed ) {\n\tvar width, minWidth, maxWidth, ret,\n\t\tstyle = elem.style;\n\n\tcomputed = computed || getStyles( elem );\n\tret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;\n\n\t// Support: Opera 12.1x only\n\t// Fall back to style even without computed\n\t// computed is undefined for elems on document fragments\n\tif ( ( ret === \"\" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {\n\t\tret = jQuery.style( elem, name );\n\t}\n\n\t// Support: IE9\n\t// getPropertyValue is only needed for .css('filter') (#12537)\n\tif ( computed ) {\n\n\t\t// A tribute to the \"awesome hack by Dean Edwards\"\n\t\t// Android Browser returns percentage for some values,\n\t\t// but width seems to be reliably pixels.\n\t\t// This is against the CSSOM draft spec:\n\t\t// http://dev.w3.org/csswg/cssom/#resolved-values\n\t\tif ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {\n\n\t\t\t// Remember the original values\n\t\t\twidth = style.width;\n\t\t\tminWidth = style.minWidth;\n\t\t\tmaxWidth = style.maxWidth;\n\n\t\t\t// Put in the new values to get a computed value out\n\t\t\tstyle.minWidth = style.maxWidth = style.width = ret;\n\t\t\tret = computed.width;\n\n\t\t\t// Revert the changed values\n\t\t\tstyle.width = width;\n\t\t\tstyle.minWidth = minWidth;\n\t\t\tstyle.maxWidth = maxWidth;\n\t\t}\n\t}\n\n\treturn ret !== undefined ?\n\n\t\t// Support: IE9-11+\n\t\t// IE returns zIndex value as an integer.\n\t\tret + \"\" :\n\t\tret;\n}\n\n\nfunction addGetHookIf( conditionFn, hookFn ) {\n\n\t// Define the hook, we'll check on the first run if it's really needed.\n\treturn {\n\t\tget: function() {\n\t\t\tif ( conditionFn() ) {\n\n\t\t\t\t// Hook not needed (or it's not possible to use it due\n\t\t\t\t// to missing dependency), remove it.\n\t\t\t\tdelete this.get;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Hook needed; redefine it so that the support test is not executed again.\n\t\t\treturn ( this.get = hookFn ).apply( this, arguments );\n\t\t}\n\t};\n}\n\n\nvar\n\n\t// Swappable if display is none or starts with table\n\t// except \"table\", \"table-cell\", or \"table-caption\"\n\t// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display\n\trdisplayswap = /^(none|table(?!-c[ea]).+)/,\n\n\tcssShow = { position: \"absolute\", visibility: \"hidden\", display: \"block\" },\n\tcssNormalTransform = {\n\t\tletterSpacing: \"0\",\n\t\tfontWeight: \"400\"\n\t},\n\n\tcssPrefixes = [ \"Webkit\", \"O\", \"Moz\", \"ms\" ],\n\temptyStyle = document.createElement( \"div\" ).style;\n\n// Return a css property mapped to a potentially vendor prefixed property\nfunction vendorPropName( name ) {\n\n\t// Shortcut for names that are not vendor prefixed\n\tif ( name in emptyStyle ) {\n\t\treturn name;\n\t}\n\n\t// Check for vendor prefixed names\n\tvar capName = name[ 0 ].toUpperCase() + name.slice( 1 ),\n\t\ti = cssPrefixes.length;\n\n\twhile ( i-- ) {\n\t\tname = cssPrefixes[ i ] + capName;\n\t\tif ( name in emptyStyle ) {\n\t\t\treturn name;\n\t\t}\n\t}\n}\n\nfunction setPositiveNumber( elem, value, subtract ) {\n\n\t// Any relative (+/-) values have already been\n\t// normalized at this point\n\tvar matches = rcssNum.exec( value );\n\treturn matches ?\n\n\t\t// Guard against undefined \"subtract\", e.g., when used as in cssHooks\n\t\tMath.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || \"px\" ) :\n\t\tvalue;\n}\n\nfunction augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {\n\tvar i = extra === ( isBorderBox ? \"border\" : \"content\" ) ?\n\n\t\t// If we already have the right measurement, avoid augmentation\n\t\t4 :\n\n\t\t// Otherwise initialize for horizontal or vertical properties\n\t\tname === \"width\" ? 1 : 0,\n\n\t\tval = 0;\n\n\tfor ( ; i < 4; i += 2 ) {\n\n\t\t// Both box models exclude margin, so add it if we want it\n\t\tif ( extra === \"margin\" ) {\n\t\t\tval += jQuery.css( elem, extra + cssExpand[ i ], true, styles );\n\t\t}\n\n\t\tif ( isBorderBox ) {\n\n\t\t\t// border-box includes padding, so remove it if we want content\n\t\t\tif ( extra === \"content\" ) {\n\t\t\t\tval -= jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\t\t\t}\n\n\t\t\t// At this point, extra isn't border nor margin, so remove border\n\t\t\tif ( extra !== \"margin\" ) {\n\t\t\t\tval -= jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\t\t} else {\n\n\t\t\t// At this point, extra isn't content, so add padding\n\t\t\tval += jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\n\t\t\t// At this point, extra isn't content nor padding, so add border\n\t\t\tif ( extra !== \"padding\" ) {\n\t\t\t\tval += jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn val;\n}\n\nfunction getWidthOrHeight( elem, name, extra ) {\n\n\t// Start with offset property, which is equivalent to the border-box value\n\tvar valueIsBorderBox = true,\n\t\tval = name === \"width\" ? elem.offsetWidth : elem.offsetHeight,\n\t\tstyles = getStyles( elem ),\n\t\tisBorderBox = jQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\";\n\n\t// Support: IE11 only\n\t// In IE 11 fullscreen elements inside of an iframe have\n\t// 100x too small dimensions (gh-1764).\n\tif ( document.msFullscreenElement && window.top !== window ) {\n\n\t\t// Support: IE11 only\n\t\t// Running getBoundingClientRect on a disconnected node\n\t\t// in IE throws an error.\n\t\tif ( elem.getClientRects().length ) {\n\t\t\tval = Math.round( elem.getBoundingClientRect()[ name ] * 100 );\n\t\t}\n\t}\n\n\t// Some non-html elements return undefined for offsetWidth, so check for null/undefined\n\t// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285\n\t// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668\n\tif ( val <= 0 || val == null ) {\n\n\t\t// Fall back to computed then uncomputed css if necessary\n\t\tval = curCSS( elem, name, styles );\n\t\tif ( val < 0 || val == null ) {\n\t\t\tval = elem.style[ name ];\n\t\t}\n\n\t\t// Computed unit is not pixels. Stop here and return.\n\t\tif ( rnumnonpx.test( val ) ) {\n\t\t\treturn val;\n\t\t}\n\n\t\t// Check for style in case a browser which returns unreliable values\n\t\t// for getComputedStyle silently falls back to the reliable elem.style\n\t\tvalueIsBorderBox = isBorderBox &&\n\t\t\t( support.boxSizingReliable() || val === elem.style[ name ] );\n\n\t\t// Normalize \"\", auto, and prepare for extra\n\t\tval = parseFloat( val ) || 0;\n\t}\n\n\t// Use the active box-sizing model to add/subtract irrelevant styles\n\treturn ( val +\n\t\taugmentWidthOrHeight(\n\t\t\telem,\n\t\t\tname,\n\t\t\textra || ( isBorderBox ? \"border\" : \"content\" ),\n\t\t\tvalueIsBorderBox,\n\t\t\tstyles\n\t\t)\n\t) + \"px\";\n}\n\nfunction showHide( elements, show ) {\n\tvar display, elem, hidden,\n\t\tvalues = [],\n\t\tindex = 0,\n\t\tlength = elements.length;\n\n\tfor ( ; index < length; index++ ) {\n\t\telem = elements[ index ];\n\t\tif ( !elem.style ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tvalues[ index ] = dataPriv.get( elem, \"olddisplay\" );\n\t\tdisplay = elem.style.display;\n\t\tif ( show ) {\n\n\t\t\t// Reset the inline display of this element to learn if it is\n\t\t\t// being hidden by cascaded rules or not\n\t\t\tif ( !values[ index ] && display === \"none\" ) {\n\t\t\t\telem.style.display = \"\";\n\t\t\t}\n\n\t\t\t// Set elements which have been overridden with display: none\n\t\t\t// in a stylesheet to whatever the default browser style is\n\t\t\t// for such an element\n\t\t\tif ( elem.style.display === \"\" && isHidden( elem ) ) {\n\t\t\t\tvalues[ index ] = dataPriv.access(\n\t\t\t\t\telem,\n\t\t\t\t\t\"olddisplay\",\n\t\t\t\t\tdefaultDisplay( elem.nodeName )\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\thidden = isHidden( elem );\n\n\t\t\tif ( display !== \"none\" || !hidden ) {\n\t\t\t\tdataPriv.set(\n\t\t\t\t\telem,\n\t\t\t\t\t\"olddisplay\",\n\t\t\t\t\thidden ? display : jQuery.css( elem, \"display\" )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Set the display of most of the elements in a second loop\n\t// to avoid the constant reflow\n\tfor ( index = 0; index < length; index++ ) {\n\t\telem = elements[ index ];\n\t\tif ( !elem.style ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( !show || elem.style.display === \"none\" || elem.style.display === \"\" ) {\n\t\t\telem.style.display = show ? values[ index ] || \"\" : \"none\";\n\t\t}\n\t}\n\n\treturn elements;\n}\n\njQuery.extend( {\n\n\t// Add in style property hooks for overriding the default\n\t// behavior of getting and setting a style property\n\tcssHooks: {\n\t\topacity: {\n\t\t\tget: function( elem, computed ) {\n\t\t\t\tif ( computed ) {\n\n\t\t\t\t\t// We should always get a number back from opacity\n\t\t\t\t\tvar ret = curCSS( elem, \"opacity\" );\n\t\t\t\t\treturn ret === \"\" ? \"1\" : ret;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t// Don't automatically add \"px\" to these possibly-unitless properties\n\tcssNumber: {\n\t\t\"animationIterationCount\": true,\n\t\t\"columnCount\": true,\n\t\t\"fillOpacity\": true,\n\t\t\"flexGrow\": true,\n\t\t\"flexShrink\": true,\n\t\t\"fontWeight\": true,\n\t\t\"lineHeight\": true,\n\t\t\"opacity\": true,\n\t\t\"order\": true,\n\t\t\"orphans\": true,\n\t\t\"widows\": true,\n\t\t\"zIndex\": true,\n\t\t\"zoom\": true\n\t},\n\n\t// Add in properties whose names you wish to fix before\n\t// setting or getting the value\n\tcssProps: {\n\t\t\"float\": \"cssFloat\"\n\t},\n\n\t// Get and set the style property on a DOM Node\n\tstyle: function( elem, name, value, extra ) {\n\n\t\t// Don't set styles on text and comment nodes\n\t\tif ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure that we're working with the right name\n\t\tvar ret, type, hooks,\n\t\t\torigName = jQuery.camelCase( name ),\n\t\t\tstyle = elem.style;\n\n\t\tname = jQuery.cssProps[ origName ] ||\n\t\t\t( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );\n\n\t\t// Gets hook for the prefixed version, then unprefixed version\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// Check if we're setting a value\n\t\tif ( value !== undefined ) {\n\t\t\ttype = typeof value;\n\n\t\t\t// Convert \"+=\" or \"-=\" to relative numbers (#7345)\n\t\t\tif ( type === \"string\" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {\n\t\t\t\tvalue = adjustCSS( elem, name, ret );\n\n\t\t\t\t// Fixes bug #9237\n\t\t\t\ttype = \"number\";\n\t\t\t}\n\n\t\t\t// Make sure that null and NaN values aren't set (#7116)\n\t\t\tif ( value == null || value !== value ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If a number was passed in, add the unit (except for certain CSS properties)\n\t\t\tif ( type === \"number\" ) {\n\t\t\t\tvalue += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? \"\" : \"px\" );\n\t\t\t}\n\n\t\t\t// Support: IE9-11+\n\t\t\t// background-* props affect original clone's values\n\t\t\tif ( !support.clearCloneStyle && value === \"\" && name.indexOf( \"background\" ) === 0 ) {\n\t\t\t\tstyle[ name ] = \"inherit\";\n\t\t\t}\n\n\t\t\t// If a hook was provided, use that value, otherwise just set the specified value\n\t\t\tif ( !hooks || !( \"set\" in hooks ) ||\n\t\t\t\t( value = hooks.set( elem, value, extra ) ) !== undefined ) {\n\n\t\t\t\tstyle[ name ] = value;\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// If a hook was provided get the non-computed value from there\n\t\t\tif ( hooks && \"get\" in hooks &&\n\t\t\t\t( ret = hooks.get( elem, false, extra ) ) !== undefined ) {\n\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t// Otherwise just get the value from the style object\n\t\t\treturn style[ name ];\n\t\t}\n\t},\n\n\tcss: function( elem, name, extra, styles ) {\n\t\tvar val, num, hooks,\n\t\t\torigName = jQuery.camelCase( name );\n\n\t\t// Make sure that we're working with the right name\n\t\tname = jQuery.cssProps[ origName ] ||\n\t\t\t( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );\n\n\t\t// Try prefixed name followed by the unprefixed name\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// If a hook was provided get the computed value from there\n\t\tif ( hooks && \"get\" in hooks ) {\n\t\t\tval = hooks.get( elem, true, extra );\n\t\t}\n\n\t\t// Otherwise, if a way to get the computed value exists, use that\n\t\tif ( val === undefined ) {\n\t\t\tval = curCSS( elem, name, styles );\n\t\t}\n\n\t\t// Convert \"normal\" to computed value\n\t\tif ( val === \"normal\" && name in cssNormalTransform ) {\n\t\t\tval = cssNormalTransform[ name ];\n\t\t}\n\n\t\t// Make numeric if forced or a qualifier was provided and val looks numeric\n\t\tif ( extra === \"\" || extra ) {\n\t\t\tnum = parseFloat( val );\n\t\t\treturn extra === true || isFinite( num ) ? num || 0 : val;\n\t\t}\n\t\treturn val;\n\t}\n} );\n\njQuery.each( [ \"height\", \"width\" ], function( i, name ) {\n\tjQuery.cssHooks[ name ] = {\n\t\tget: function( elem, computed, extra ) {\n\t\t\tif ( computed ) {\n\n\t\t\t\t// Certain elements can have dimension info if we invisibly show them\n\t\t\t\t// but it must have a current display style that would benefit\n\t\t\t\treturn rdisplayswap.test( jQuery.css( elem, \"display\" ) ) &&\n\t\t\t\t\telem.offsetWidth === 0 ?\n\t\t\t\t\t\tswap( elem, cssShow, function() {\n\t\t\t\t\t\t\treturn getWidthOrHeight( elem, name, extra );\n\t\t\t\t\t\t} ) :\n\t\t\t\t\t\tgetWidthOrHeight( elem, name, extra );\n\t\t\t}\n\t\t},\n\n\t\tset: function( elem, value, extra ) {\n\t\t\tvar matches,\n\t\t\t\tstyles = extra && getStyles( elem ),\n\t\t\t\tsubtract = extra && augmentWidthOrHeight(\n\t\t\t\t\telem,\n\t\t\t\t\tname,\n\t\t\t\t\textra,\n\t\t\t\t\tjQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\",\n\t\t\t\t\tstyles\n\t\t\t\t);\n\n\t\t\t// Convert to pixels if value adjustment is needed\n\t\t\tif ( subtract && ( matches = rcssNum.exec( value ) ) &&\n\t\t\t\t( matches[ 3 ] || \"px\" ) !== \"px\" ) {\n\n\t\t\t\telem.style[ name ] = value;\n\t\t\t\tvalue = jQuery.css( elem, name );\n\t\t\t}\n\n\t\t\treturn setPositiveNumber( elem, value, subtract );\n\t\t}\n\t};\n} );\n\njQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,\n\tfunction( elem, computed ) {\n\t\tif ( computed ) {\n\t\t\treturn ( parseFloat( curCSS( elem, \"marginLeft\" ) ) ||\n\t\t\t\telem.getBoundingClientRect().left -\n\t\t\t\t\tswap( elem, { marginLeft: 0 }, function() {\n\t\t\t\t\t\treturn elem.getBoundingClientRect().left;\n\t\t\t\t\t} )\n\t\t\t\t) + \"px\";\n\t\t}\n\t}\n);\n\n// Support: Android 2.3\njQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,\n\tfunction( elem, computed ) {\n\t\tif ( computed ) {\n\t\t\treturn swap( elem, { \"display\": \"inline-block\" },\n\t\t\t\tcurCSS, [ elem, \"marginRight\" ] );\n\t\t}\n\t}\n);\n\n// These hooks are used by animate to expand properties\njQuery.each( {\n\tmargin: \"\",\n\tpadding: \"\",\n\tborder: \"Width\"\n}, function( prefix, suffix ) {\n\tjQuery.cssHooks[ prefix + suffix ] = {\n\t\texpand: function( value ) {\n\t\t\tvar i = 0,\n\t\t\t\texpanded = {},\n\n\t\t\t\t// Assumes a single number if not a string\n\t\t\t\tparts = typeof value === \"string\" ? value.split( \" \" ) : [ value ];\n\n\t\t\tfor ( ; i < 4; i++ ) {\n\t\t\t\texpanded[ prefix + cssExpand[ i ] + suffix ] =\n\t\t\t\t\tparts[ i ] || parts[ i - 2 ] || parts[ 0 ];\n\t\t\t}\n\n\t\t\treturn expanded;\n\t\t}\n\t};\n\n\tif ( !rmargin.test( prefix ) ) {\n\t\tjQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;\n\t}\n} );\n\njQuery.fn.extend( {\n\tcss: function( name, value ) {\n\t\treturn access( this, function( elem, name, value ) {\n\t\t\tvar styles, len,\n\t\t\t\tmap = {},\n\t\t\t\ti = 0;\n\n\t\t\tif ( jQuery.isArray( name ) ) {\n\t\t\t\tstyles = getStyles( elem );\n\t\t\t\tlen = name.length;\n\n\t\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\t\tmap[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}\n\n\t\t\treturn value !== undefined ?\n\t\t\t\tjQuery.style( elem, name, value ) :\n\t\t\t\tjQuery.css( elem, name );\n\t\t}, name, value, arguments.length > 1 );\n\t},\n\tshow: function() {\n\t\treturn showHide( this, true );\n\t},\n\thide: function() {\n\t\treturn showHide( this );\n\t},\n\ttoggle: function( state ) {\n\t\tif ( typeof state === \"boolean\" ) {\n\t\t\treturn state ? this.show() : this.hide();\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tif ( isHidden( this ) ) {\n\t\t\t\tjQuery( this ).show();\n\t\t\t} else {\n\t\t\t\tjQuery( this ).hide();\n\t\t\t}\n\t\t} );\n\t}\n} );\n\n\nfunction Tween( elem, options, prop, end, easing ) {\n\treturn new Tween.prototype.init( elem, options, prop, end, easing );\n}\njQuery.Tween = Tween;\n\nTween.prototype = {\n\tconstructor: Tween,\n\tinit: function( elem, options, prop, end, easing, unit ) {\n\t\tthis.elem = elem;\n\t\tthis.prop = prop;\n\t\tthis.easing = easing || jQuery.easing._default;\n\t\tthis.options = options;\n\t\tthis.start = this.now = this.cur();\n\t\tthis.end = end;\n\t\tthis.unit = unit || ( jQuery.cssNumber[ prop ] ? \"\" : \"px\" );\n\t},\n\tcur: function() {\n\t\tvar hooks = Tween.propHooks[ this.prop ];\n\n\t\treturn hooks && hooks.get ?\n\t\t\thooks.get( this ) :\n\t\t\tTween.propHooks._default.get( this );\n\t},\n\trun: function( percent ) {\n\t\tvar eased,\n\t\t\thooks = Tween.propHooks[ this.prop ];\n\n\t\tif ( this.options.duration ) {\n\t\t\tthis.pos = eased = jQuery.easing[ this.easing ](\n\t\t\t\tpercent, this.options.duration * percent, 0, 1, this.options.duration\n\t\t\t);\n\t\t} else {\n\t\t\tthis.pos = eased = percent;\n\t\t}\n\t\tthis.now = ( this.end - this.start ) * eased + this.start;\n\n\t\tif ( this.options.step ) {\n\t\t\tthis.options.step.call( this.elem, this.now, this );\n\t\t}\n\n\t\tif ( hooks && hooks.set ) {\n\t\t\thooks.set( this );\n\t\t} else {\n\t\t\tTween.propHooks._default.set( this );\n\t\t}\n\t\treturn this;\n\t}\n};\n\nTween.prototype.init.prototype = Tween.prototype;\n\nTween.propHooks = {\n\t_default: {\n\t\tget: function( tween ) {\n\t\t\tvar result;\n\n\t\t\t// Use a property on the element directly when it is not a DOM element,\n\t\t\t// or when there is no matching style property that exists.\n\t\t\tif ( tween.elem.nodeType !== 1 ||\n\t\t\t\ttween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {\n\t\t\t\treturn tween.elem[ tween.prop ];\n\t\t\t}\n\n\t\t\t// Passing an empty string as a 3rd parameter to .css will automatically\n\t\t\t// attempt a parseFloat and fallback to a string if the parse fails.\n\t\t\t// Simple values such as \"10px\" are parsed to Float;\n\t\t\t// complex values such as \"rotate(1rad)\" are returned as-is.\n\t\t\tresult = jQuery.css( tween.elem, tween.prop, \"\" );\n\n\t\t\t// Empty strings, null, undefined and \"auto\" are converted to 0.\n\t\t\treturn !result || result === \"auto\" ? 0 : result;\n\t\t},\n\t\tset: function( tween ) {\n\n\t\t\t// Use step hook for back compat.\n\t\t\t// Use cssHook if its there.\n\t\t\t// Use .style if available and use plain properties where available.\n\t\t\tif ( jQuery.fx.step[ tween.prop ] ) {\n\t\t\t\tjQuery.fx.step[ tween.prop ]( tween );\n\t\t\t} else if ( tween.elem.nodeType === 1 &&\n\t\t\t\t( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||\n\t\t\t\t\tjQuery.cssHooks[ tween.prop ] ) ) {\n\t\t\t\tjQuery.style( tween.elem, tween.prop, tween.now + tween.unit );\n\t\t\t} else {\n\t\t\t\ttween.elem[ tween.prop ] = tween.now;\n\t\t\t}\n\t\t}\n\t}\n};\n\n// Support: IE9\n// Panic based approach to setting things on disconnected nodes\nTween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {\n\tset: function( tween ) {\n\t\tif ( tween.elem.nodeType && tween.elem.parentNode ) {\n\t\t\ttween.elem[ tween.prop ] = tween.now;\n\t\t}\n\t}\n};\n\njQuery.easing = {\n\tlinear: function( p ) {\n\t\treturn p;\n\t},\n\tswing: function( p ) {\n\t\treturn 0.5 - Math.cos( p * Math.PI ) / 2;\n\t},\n\t_default: \"swing\"\n};\n\njQuery.fx = Tween.prototype.init;\n\n// Back Compat <1.8 extension point\njQuery.fx.step = {};\n\n\n\n\nvar\n\tfxNow, timerId,\n\trfxtypes = /^(?:toggle|show|hide)$/,\n\trrun = /queueHooks$/;\n\n// Animations created synchronously will run synchronously\nfunction createFxNow() {\n\twindow.setTimeout( function() {\n\t\tfxNow = undefined;\n\t} );\n\treturn ( fxNow = jQuery.now() );\n}\n\n// Generate parameters to create a standard animation\nfunction genFx( type, includeWidth ) {\n\tvar which,\n\t\ti = 0,\n\t\tattrs = { height: type };\n\n\t// If we include width, step value is 1 to do all cssExpand values,\n\t// otherwise step value is 2 to skip over Left and Right\n\tincludeWidth = includeWidth ? 1 : 0;\n\tfor ( ; i < 4 ; i += 2 - includeWidth ) {\n\t\twhich = cssExpand[ i ];\n\t\tattrs[ \"margin\" + which ] = attrs[ \"padding\" + which ] = type;\n\t}\n\n\tif ( includeWidth ) {\n\t\tattrs.opacity = attrs.width = type;\n\t}\n\n\treturn attrs;\n}\n\nfunction createTween( value, prop, animation ) {\n\tvar tween,\n\t\tcollection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ \"*\" ] ),\n\t\tindex = 0,\n\t\tlength = collection.length;\n\tfor ( ; index < length; index++ ) {\n\t\tif ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {\n\n\t\t\t// We're done with this property\n\t\t\treturn tween;\n\t\t}\n\t}\n}\n\nfunction defaultPrefilter( elem, props, opts ) {\n\t/* jshint validthis: true */\n\tvar prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,\n\t\tanim = this,\n\t\torig = {},\n\t\tstyle = elem.style,\n\t\thidden = elem.nodeType && isHidden( elem ),\n\t\tdataShow = dataPriv.get( elem, \"fxshow\" );\n\n\t// Handle queue: false promises\n\tif ( !opts.queue ) {\n\t\thooks = jQuery._queueHooks( elem, \"fx\" );\n\t\tif ( hooks.unqueued == null ) {\n\t\t\thooks.unqueued = 0;\n\t\t\toldfire = hooks.empty.fire;\n\t\t\thooks.empty.fire = function() {\n\t\t\t\tif ( !hooks.unqueued ) {\n\t\t\t\t\toldfire();\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\thooks.unqueued++;\n\n\t\tanim.always( function() {\n\n\t\t\t// Ensure the complete handler is called before this completes\n\t\t\tanim.always( function() {\n\t\t\t\thooks.unqueued--;\n\t\t\t\tif ( !jQuery.queue( elem, \"fx\" ).length ) {\n\t\t\t\t\thooks.empty.fire();\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t}\n\n\t// Height/width overflow pass\n\tif ( elem.nodeType === 1 && ( \"height\" in props || \"width\" in props ) ) {\n\n\t\t// Make sure that nothing sneaks out\n\t\t// Record all 3 overflow attributes because IE9-10 do not\n\t\t// change the overflow attribute when overflowX and\n\t\t// overflowY are set to the same value\n\t\topts.overflow = [ style.overflow, style.overflowX, style.overflowY ];\n\n\t\t// Set display property to inline-block for height/width\n\t\t// animations on inline elements that are having width/height animated\n\t\tdisplay = jQuery.css( elem, \"display\" );\n\n\t\t// Test default display if display is currently \"none\"\n\t\tcheckDisplay = display === \"none\" ?\n\t\t\tdataPriv.get( elem, \"olddisplay\" ) || defaultDisplay( elem.nodeName ) : display;\n\n\t\tif ( checkDisplay === \"inline\" && jQuery.css( elem, \"float\" ) === \"none\" ) {\n\t\t\tstyle.display = \"inline-block\";\n\t\t}\n\t}\n\n\tif ( opts.overflow ) {\n\t\tstyle.overflow = \"hidden\";\n\t\tanim.always( function() {\n\t\t\tstyle.overflow = opts.overflow[ 0 ];\n\t\t\tstyle.overflowX = opts.overflow[ 1 ];\n\t\t\tstyle.overflowY = opts.overflow[ 2 ];\n\t\t} );\n\t}\n\n\t// show/hide pass\n\tfor ( prop in props ) {\n\t\tvalue = props[ prop ];\n\t\tif ( rfxtypes.exec( value ) ) {\n\t\t\tdelete props[ prop ];\n\t\t\ttoggle = toggle || value === \"toggle\";\n\t\t\tif ( value === ( hidden ? \"hide\" : \"show\" ) ) {\n\n\t\t\t\t// If there is dataShow left over from a stopped hide or show\n\t\t\t\t// and we are going to proceed with show, we should pretend to be hidden\n\t\t\t\tif ( value === \"show\" && dataShow && dataShow[ prop ] !== undefined ) {\n\t\t\t\t\thidden = true;\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\torig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );\n\n\t\t// Any non-fx value stops us from restoring the original display value\n\t\t} else {\n\t\t\tdisplay = undefined;\n\t\t}\n\t}\n\n\tif ( !jQuery.isEmptyObject( orig ) ) {\n\t\tif ( dataShow ) {\n\t\t\tif ( \"hidden\" in dataShow ) {\n\t\t\t\thidden = dataShow.hidden;\n\t\t\t}\n\t\t} else {\n\t\t\tdataShow = dataPriv.access( elem, \"fxshow\", {} );\n\t\t}\n\n\t\t// Store state if its toggle - enables .stop().toggle() to \"reverse\"\n\t\tif ( toggle ) {\n\t\t\tdataShow.hidden = !hidden;\n\t\t}\n\t\tif ( hidden ) {\n\t\t\tjQuery( elem ).show();\n\t\t} else {\n\t\t\tanim.done( function() {\n\t\t\t\tjQuery( elem ).hide();\n\t\t\t} );\n\t\t}\n\t\tanim.done( function() {\n\t\t\tvar prop;\n\n\t\t\tdataPriv.remove( elem, \"fxshow\" );\n\t\t\tfor ( prop in orig ) {\n\t\t\t\tjQuery.style( elem, prop, orig[ prop ] );\n\t\t\t}\n\t\t} );\n\t\tfor ( prop in orig ) {\n\t\t\ttween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );\n\n\t\t\tif ( !( prop in dataShow ) ) {\n\t\t\t\tdataShow[ prop ] = tween.start;\n\t\t\t\tif ( hidden ) {\n\t\t\t\t\ttween.end = tween.start;\n\t\t\t\t\ttween.start = prop === \"width\" || prop === \"height\" ? 1 : 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t// If this is a noop like .hide().hide(), restore an overwritten display value\n\t} else if ( ( display === \"none\" ? defaultDisplay( elem.nodeName ) : display ) === \"inline\" ) {\n\t\tstyle.display = display;\n\t}\n}\n\nfunction propFilter( props, specialEasing ) {\n\tvar index, name, easing, value, hooks;\n\n\t// camelCase, specialEasing and expand cssHook pass\n\tfor ( index in props ) {\n\t\tname = jQuery.camelCase( index );\n\t\teasing = specialEasing[ name ];\n\t\tvalue = props[ index ];\n\t\tif ( jQuery.isArray( value ) ) {\n\t\t\teasing = value[ 1 ];\n\t\t\tvalue = props[ index ] = value[ 0 ];\n\t\t}\n\n\t\tif ( index !== name ) {\n\t\t\tprops[ name ] = value;\n\t\t\tdelete props[ index ];\n\t\t}\n\n\t\thooks = jQuery.cssHooks[ name ];\n\t\tif ( hooks && \"expand\" in hooks ) {\n\t\t\tvalue = hooks.expand( value );\n\t\t\tdelete props[ name ];\n\n\t\t\t// Not quite $.extend, this won't overwrite existing keys.\n\t\t\t// Reusing 'index' because we have the correct \"name\"\n\t\t\tfor ( index in value ) {\n\t\t\t\tif ( !( index in props ) ) {\n\t\t\t\t\tprops[ index ] = value[ index ];\n\t\t\t\t\tspecialEasing[ index ] = easing;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tspecialEasing[ name ] = easing;\n\t\t}\n\t}\n}\n\nfunction Animation( elem, properties, options ) {\n\tvar result,\n\t\tstopped,\n\t\tindex = 0,\n\t\tlength = Animation.prefilters.length,\n\t\tdeferred = jQuery.Deferred().always( function() {\n\n\t\t\t// Don't match elem in the :animated selector\n\t\t\tdelete tick.elem;\n\t\t} ),\n\t\ttick = function() {\n\t\t\tif ( stopped ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tvar currentTime = fxNow || createFxNow(),\n\t\t\t\tremaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),\n\n\t\t\t\t// Support: Android 2.3\n\t\t\t\t// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)\n\t\t\t\ttemp = remaining / animation.duration || 0,\n\t\t\t\tpercent = 1 - temp,\n\t\t\t\tindex = 0,\n\t\t\t\tlength = animation.tweens.length;\n\n\t\t\tfor ( ; index < length ; index++ ) {\n\t\t\t\tanimation.tweens[ index ].run( percent );\n\t\t\t}\n\n\t\t\tdeferred.notifyWith( elem, [ animation, percent, remaining ] );\n\n\t\t\tif ( percent < 1 && length ) {\n\t\t\t\treturn remaining;\n\t\t\t} else {\n\t\t\t\tdeferred.resolveWith( elem, [ animation ] );\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\tanimation = deferred.promise( {\n\t\t\telem: elem,\n\t\t\tprops: jQuery.extend( {}, properties ),\n\t\t\topts: jQuery.extend( true, {\n\t\t\t\tspecialEasing: {},\n\t\t\t\teasing: jQuery.easing._default\n\t\t\t}, options ),\n\t\t\toriginalProperties: properties,\n\t\t\toriginalOptions: options,\n\t\t\tstartTime: fxNow || createFxNow(),\n\t\t\tduration: options.duration,\n\t\t\ttweens: [],\n\t\t\tcreateTween: function( prop, end ) {\n\t\t\t\tvar tween = jQuery.Tween( elem, animation.opts, prop, end,\n\t\t\t\t\t\tanimation.opts.specialEasing[ prop ] || animation.opts.easing );\n\t\t\t\tanimation.tweens.push( tween );\n\t\t\t\treturn tween;\n\t\t\t},\n\t\t\tstop: function( gotoEnd ) {\n\t\t\t\tvar index = 0,\n\n\t\t\t\t\t// If we are going to the end, we want to run all the tweens\n\t\t\t\t\t// otherwise we skip this part\n\t\t\t\t\tlength = gotoEnd ? animation.tweens.length : 0;\n\t\t\t\tif ( stopped ) {\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t\tstopped = true;\n\t\t\t\tfor ( ; index < length ; index++ ) {\n\t\t\t\t\tanimation.tweens[ index ].run( 1 );\n\t\t\t\t}\n\n\t\t\t\t// Resolve when we played the last frame; otherwise, reject\n\t\t\t\tif ( gotoEnd ) {\n\t\t\t\t\tdeferred.notifyWith( elem, [ animation, 1, 0 ] );\n\t\t\t\t\tdeferred.resolveWith( elem, [ animation, gotoEnd ] );\n\t\t\t\t} else {\n\t\t\t\t\tdeferred.rejectWith( elem, [ animation, gotoEnd ] );\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t}\n\t\t} ),\n\t\tprops = animation.props;\n\n\tpropFilter( props, animation.opts.specialEasing );\n\n\tfor ( ; index < length ; index++ ) {\n\t\tresult = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );\n\t\tif ( result ) {\n\t\t\tif ( jQuery.isFunction( result.stop ) ) {\n\t\t\t\tjQuery._queueHooks( animation.elem, animation.opts.queue ).stop =\n\t\t\t\t\tjQuery.proxy( result.stop, result );\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tjQuery.map( props, createTween, animation );\n\n\tif ( jQuery.isFunction( animation.opts.start ) ) {\n\t\tanimation.opts.start.call( elem, animation );\n\t}\n\n\tjQuery.fx.timer(\n\t\tjQuery.extend( tick, {\n\t\t\telem: elem,\n\t\t\tanim: animation,\n\t\t\tqueue: animation.opts.queue\n\t\t} )\n\t);\n\n\t// attach callbacks from options\n\treturn animation.progress( animation.opts.progress )\n\t\t.done( animation.opts.done, animation.opts.complete )\n\t\t.fail( animation.opts.fail )\n\t\t.always( animation.opts.always );\n}\n\njQuery.Animation = jQuery.extend( Animation, {\n\ttweeners: {\n\t\t\"*\": [ function( prop, value ) {\n\t\t\tvar tween = this.createTween( prop, value );\n\t\t\tadjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );\n\t\t\treturn tween;\n\t\t} ]\n\t},\n\n\ttweener: function( props, callback ) {\n\t\tif ( jQuery.isFunction( props ) ) {\n\t\t\tcallback = props;\n\t\t\tprops = [ \"*\" ];\n\t\t} else {\n\t\t\tprops = props.match( rnotwhite );\n\t\t}\n\n\t\tvar prop,\n\t\t\tindex = 0,\n\t\t\tlength = props.length;\n\n\t\tfor ( ; index < length ; index++ ) {\n\t\t\tprop = props[ index ];\n\t\t\tAnimation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];\n\t\t\tAnimation.tweeners[ prop ].unshift( callback );\n\t\t}\n\t},\n\n\tprefilters: [ defaultPrefilter ],\n\n\tprefilter: function( callback, prepend ) {\n\t\tif ( prepend ) {\n\t\t\tAnimation.prefilters.unshift( callback );\n\t\t} else {\n\t\t\tAnimation.prefilters.push( callback );\n\t\t}\n\t}\n} );\n\njQuery.speed = function( speed, easing, fn ) {\n\tvar opt = speed && typeof speed === \"object\" ? jQuery.extend( {}, speed ) : {\n\t\tcomplete: fn || !fn && easing ||\n\t\t\tjQuery.isFunction( speed ) && speed,\n\t\tduration: speed,\n\t\teasing: fn && easing || easing && !jQuery.isFunction( easing ) && easing\n\t};\n\n\topt.duration = jQuery.fx.off ? 0 : typeof opt.duration === \"number\" ?\n\t\topt.duration : opt.duration in jQuery.fx.speeds ?\n\t\t\tjQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;\n\n\t// Normalize opt.queue - true/undefined/null -> \"fx\"\n\tif ( opt.queue == null || opt.queue === true ) {\n\t\topt.queue = \"fx\";\n\t}\n\n\t// Queueing\n\topt.old = opt.complete;\n\n\topt.complete = function() {\n\t\tif ( jQuery.isFunction( opt.old ) ) {\n\t\t\topt.old.call( this );\n\t\t}\n\n\t\tif ( opt.queue ) {\n\t\t\tjQuery.dequeue( this, opt.queue );\n\t\t}\n\t};\n\n\treturn opt;\n};\n\njQuery.fn.extend( {\n\tfadeTo: function( speed, to, easing, callback ) {\n\n\t\t// Show any hidden elements after setting opacity to 0\n\t\treturn this.filter( isHidden ).css( \"opacity\", 0 ).show()\n\n\t\t\t// Animate to the value specified\n\t\t\t.end().animate( { opacity: to }, speed, easing, callback );\n\t},\n\tanimate: function( prop, speed, easing, callback ) {\n\t\tvar empty = jQuery.isEmptyObject( prop ),\n\t\t\toptall = jQuery.speed( speed, easing, callback ),\n\t\t\tdoAnimation = function() {\n\n\t\t\t\t// Operate on a copy of prop so per-property easing won't be lost\n\t\t\t\tvar anim = Animation( this, jQuery.extend( {}, prop ), optall );\n\n\t\t\t\t// Empty animations, or finishing resolves immediately\n\t\t\t\tif ( empty || dataPriv.get( this, \"finish\" ) ) {\n\t\t\t\t\tanim.stop( true );\n\t\t\t\t}\n\t\t\t};\n\t\t\tdoAnimation.finish = doAnimation;\n\n\t\treturn empty || optall.queue === false ?\n\t\t\tthis.each( doAnimation ) :\n\t\t\tthis.queue( optall.queue, doAnimation );\n\t},\n\tstop: function( type, clearQueue, gotoEnd ) {\n\t\tvar stopQueue = function( hooks ) {\n\t\t\tvar stop = hooks.stop;\n\t\t\tdelete hooks.stop;\n\t\t\tstop( gotoEnd );\n\t\t};\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tgotoEnd = clearQueue;\n\t\t\tclearQueue = type;\n\t\t\ttype = undefined;\n\t\t}\n\t\tif ( clearQueue && type !== false ) {\n\t\t\tthis.queue( type || \"fx\", [] );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar dequeue = true,\n\t\t\t\tindex = type != null && type + \"queueHooks\",\n\t\t\t\ttimers = jQuery.timers,\n\t\t\t\tdata = dataPriv.get( this );\n\n\t\t\tif ( index ) {\n\t\t\t\tif ( data[ index ] && data[ index ].stop ) {\n\t\t\t\t\tstopQueue( data[ index ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor ( index in data ) {\n\t\t\t\t\tif ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {\n\t\t\t\t\t\tstopQueue( data[ index ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor ( index = timers.length; index--; ) {\n\t\t\t\tif ( timers[ index ].elem === this &&\n\t\t\t\t\t( type == null || timers[ index ].queue === type ) ) {\n\n\t\t\t\t\ttimers[ index ].anim.stop( gotoEnd );\n\t\t\t\t\tdequeue = false;\n\t\t\t\t\ttimers.splice( index, 1 );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Start the next in the queue if the last step wasn't forced.\n\t\t\t// Timers currently will call their complete callbacks, which\n\t\t\t// will dequeue but only if they were gotoEnd.\n\t\t\tif ( dequeue || !gotoEnd ) {\n\t\t\t\tjQuery.dequeue( this, type );\n\t\t\t}\n\t\t} );\n\t},\n\tfinish: function( type ) {\n\t\tif ( type !== false ) {\n\t\t\ttype = type || \"fx\";\n\t\t}\n\t\treturn this.each( function() {\n\t\t\tvar index,\n\t\t\t\tdata = dataPriv.get( this ),\n\t\t\t\tqueue = data[ type + \"queue\" ],\n\t\t\t\thooks = data[ type + \"queueHooks\" ],\n\t\t\t\ttimers = jQuery.timers,\n\t\t\t\tlength = queue ? queue.length : 0;\n\n\t\t\t// Enable finishing flag on private data\n\t\t\tdata.finish = true;\n\n\t\t\t// Empty the queue first\n\t\t\tjQuery.queue( this, type, [] );\n\n\t\t\tif ( hooks && hooks.stop ) {\n\t\t\t\thooks.stop.call( this, true );\n\t\t\t}\n\n\t\t\t// Look for any active animations, and finish them\n\t\t\tfor ( index = timers.length; index--; ) {\n\t\t\t\tif ( timers[ index ].elem === this && timers[ index ].queue === type ) {\n\t\t\t\t\ttimers[ index ].anim.stop( true );\n\t\t\t\t\ttimers.splice( index, 1 );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Look for any animations in the old queue and finish them\n\t\t\tfor ( index = 0; index < length; index++ ) {\n\t\t\t\tif ( queue[ index ] && queue[ index ].finish ) {\n\t\t\t\t\tqueue[ index ].finish.call( this );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Turn off finishing flag\n\t\t\tdelete data.finish;\n\t\t} );\n\t}\n} );\n\njQuery.each( [ \"toggle\", \"show\", \"hide\" ], function( i, name ) {\n\tvar cssFn = jQuery.fn[ name ];\n\tjQuery.fn[ name ] = function( speed, easing, callback ) {\n\t\treturn speed == null || typeof speed === \"boolean\" ?\n\t\t\tcssFn.apply( this, arguments ) :\n\t\t\tthis.animate( genFx( name, true ), speed, easing, callback );\n\t};\n} );\n\n// Generate shortcuts for custom animations\njQuery.each( {\n\tslideDown: genFx( \"show\" ),\n\tslideUp: genFx( \"hide\" ),\n\tslideToggle: genFx( \"toggle\" ),\n\tfadeIn: { opacity: \"show\" },\n\tfadeOut: { opacity: \"hide\" },\n\tfadeToggle: { opacity: \"toggle\" }\n}, function( name, props ) {\n\tjQuery.fn[ name ] = function( speed, easing, callback ) {\n\t\treturn this.animate( props, speed, easing, callback );\n\t};\n} );\n\njQuery.timers = [];\njQuery.fx.tick = function() {\n\tvar timer,\n\t\ti = 0,\n\t\ttimers = jQuery.timers;\n\n\tfxNow = jQuery.now();\n\n\tfor ( ; i < timers.length; i++ ) {\n\t\ttimer = timers[ i ];\n\n\t\t// Checks the timer has not already been removed\n\t\tif ( !timer() && timers[ i ] === timer ) {\n\t\t\ttimers.splice( i--, 1 );\n\t\t}\n\t}\n\n\tif ( !timers.length ) {\n\t\tjQuery.fx.stop();\n\t}\n\tfxNow = undefined;\n};\n\njQuery.fx.timer = function( timer ) {\n\tjQuery.timers.push( timer );\n\tif ( timer() ) {\n\t\tjQuery.fx.start();\n\t} else {\n\t\tjQuery.timers.pop();\n\t}\n};\n\njQuery.fx.interval = 13;\njQuery.fx.start = function() {\n\tif ( !timerId ) {\n\t\ttimerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );\n\t}\n};\n\njQuery.fx.stop = function() {\n\twindow.clearInterval( timerId );\n\n\ttimerId = null;\n};\n\njQuery.fx.speeds = {\n\tslow: 600,\n\tfast: 200,\n\n\t// Default speed\n\t_default: 400\n};\n\n\n// Based off of the plugin by Clint Helfers, with permission.\n// http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/\njQuery.fn.delay = function( time, type ) {\n\ttime = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;\n\ttype = type || \"fx\";\n\n\treturn this.queue( type, function( next, hooks ) {\n\t\tvar timeout = window.setTimeout( next, time );\n\t\thooks.stop = function() {\n\t\t\twindow.clearTimeout( timeout );\n\t\t};\n\t} );\n};\n\n\n( function() {\n\tvar input = document.createElement( \"input\" ),\n\t\tselect = document.createElement( \"select\" ),\n\t\topt = select.appendChild( document.createElement( \"option\" ) );\n\n\tinput.type = \"checkbox\";\n\n\t// Support: iOS<=5.1, Android<=4.2+\n\t// Default value for a checkbox should be \"on\"\n\tsupport.checkOn = input.value !== \"\";\n\n\t// Support: IE<=11+\n\t// Must access selectedIndex to make default options select\n\tsupport.optSelected = opt.selected;\n\n\t// Support: Android<=2.3\n\t// Options inside disabled selects are incorrectly marked as disabled\n\tselect.disabled = true;\n\tsupport.optDisabled = !opt.disabled;\n\n\t// Support: IE<=11+\n\t// An input loses its value after becoming a radio\n\tinput = document.createElement( \"input\" );\n\tinput.value = \"t\";\n\tinput.type = \"radio\";\n\tsupport.radioValue = input.value === \"t\";\n} )();\n\n\nvar boolHook,\n\tattrHandle = jQuery.expr.attrHandle;\n\njQuery.fn.extend( {\n\tattr: function( name, value ) {\n\t\treturn access( this, jQuery.attr, name, value, arguments.length > 1 );\n\t},\n\n\tremoveAttr: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.removeAttr( this, name );\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tattr: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set attributes on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Fallback to prop when attributes are not supported\n\t\tif ( typeof elem.getAttribute === \"undefined\" ) {\n\t\t\treturn jQuery.prop( elem, name, value );\n\t\t}\n\n\t\t// All attributes are lowercase\n\t\t// Grab necessary hook if one is defined\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\t\t\tname = name.toLowerCase();\n\t\t\thooks = jQuery.attrHooks[ name ] ||\n\t\t\t\t( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( value === null ) {\n\t\t\t\tjQuery.removeAttr( elem, name );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\telem.setAttribute( name, value + \"\" );\n\t\t\treturn value;\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tret = jQuery.find.attr( elem, name );\n\n\t\t// Non-existent attributes return null, we normalize to undefined\n\t\treturn ret == null ? undefined : ret;\n\t},\n\n\tattrHooks: {\n\t\ttype: {\n\t\t\tset: function( elem, value ) {\n\t\t\t\tif ( !support.radioValue && value === \"radio\" &&\n\t\t\t\t\tjQuery.nodeName( elem, \"input\" ) ) {\n\t\t\t\t\tvar val = elem.value;\n\t\t\t\t\telem.setAttribute( \"type\", value );\n\t\t\t\t\tif ( val ) {\n\t\t\t\t\t\telem.value = val;\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremoveAttr: function( elem, value ) {\n\t\tvar name, propName,\n\t\t\ti = 0,\n\t\t\tattrNames = value && value.match( rnotwhite );\n\n\t\tif ( attrNames && elem.nodeType === 1 ) {\n\t\t\twhile ( ( name = attrNames[ i++ ] ) ) {\n\t\t\t\tpropName = jQuery.propFix[ name ] || name;\n\n\t\t\t\t// Boolean attributes get special treatment (#10870)\n\t\t\t\tif ( jQuery.expr.match.bool.test( name ) ) {\n\n\t\t\t\t\t// Set corresponding property to false\n\t\t\t\t\telem[ propName ] = false;\n\t\t\t\t}\n\n\t\t\t\telem.removeAttribute( name );\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Hooks for boolean attributes\nboolHook = {\n\tset: function( elem, value, name ) {\n\t\tif ( value === false ) {\n\n\t\t\t// Remove boolean attributes when set to false\n\t\t\tjQuery.removeAttr( elem, name );\n\t\t} else {\n\t\t\telem.setAttribute( name, name );\n\t\t}\n\t\treturn name;\n\t}\n};\njQuery.each( jQuery.expr.match.bool.source.match( /\\w+/g ), function( i, name ) {\n\tvar getter = attrHandle[ name ] || jQuery.find.attr;\n\n\tattrHandle[ name ] = function( elem, name, isXML ) {\n\t\tvar ret, handle;\n\t\tif ( !isXML ) {\n\n\t\t\t// Avoid an infinite loop by temporarily removing this function from the getter\n\t\t\thandle = attrHandle[ name ];\n\t\t\tattrHandle[ name ] = ret;\n\t\t\tret = getter( elem, name, isXML ) != null ?\n\t\t\t\tname.toLowerCase() :\n\t\t\t\tnull;\n\t\t\tattrHandle[ name ] = handle;\n\t\t}\n\t\treturn ret;\n\t};\n} );\n\n\n\n\nvar rfocusable = /^(?:input|select|textarea|button)$/i,\n\trclickable = /^(?:a|area)$/i;\n\njQuery.fn.extend( {\n\tprop: function( name, value ) {\n\t\treturn access( this, jQuery.prop, name, value, arguments.length > 1 );\n\t},\n\n\tremoveProp: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tdelete this[ jQuery.propFix[ name ] || name ];\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tprop: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set properties on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// Fix name and attach hooks\n\t\t\tname = jQuery.propFix[ name ] || name;\n\t\t\thooks = jQuery.propHooks[ name ];\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\treturn ( elem[ name ] = value );\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\treturn elem[ name ];\n\t},\n\n\tpropHooks: {\n\t\ttabIndex: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\t// elem.tabIndex doesn't always return the\n\t\t\t\t// correct value when it hasn't been explicitly set\n\t\t\t\t// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/\n\t\t\t\t// Use proper attribute retrieval(#12072)\n\t\t\t\tvar tabindex = jQuery.find.attr( elem, \"tabindex\" );\n\n\t\t\t\treturn tabindex ?\n\t\t\t\t\tparseInt( tabindex, 10 ) :\n\t\t\t\t\trfocusable.test( elem.nodeName ) ||\n\t\t\t\t\t\trclickable.test( elem.nodeName ) && elem.href ?\n\t\t\t\t\t\t\t0 :\n\t\t\t\t\t\t\t-1;\n\t\t\t}\n\t\t}\n\t},\n\n\tpropFix: {\n\t\t\"for\": \"htmlFor\",\n\t\t\"class\": \"className\"\n\t}\n} );\n\n// Support: IE <=11 only\n// Accessing the selectedIndex property\n// forces the browser to respect setting selected\n// on the option\n// The getter ensures a default option is selected\n// when in an optgroup\nif ( !support.optSelected ) {\n\tjQuery.propHooks.selected = {\n\t\tget: function( elem ) {\n\t\t\tvar parent = elem.parentNode;\n\t\t\tif ( parent && parent.parentNode ) {\n\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\tset: function( elem ) {\n\t\t\tvar parent = elem.parentNode;\n\t\t\tif ( parent ) {\n\t\t\t\tparent.selectedIndex;\n\n\t\t\t\tif ( parent.parentNode ) {\n\t\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\njQuery.each( [\n\t\"tabIndex\",\n\t\"readOnly\",\n\t\"maxLength\",\n\t\"cellSpacing\",\n\t\"cellPadding\",\n\t\"rowSpan\",\n\t\"colSpan\",\n\t\"useMap\",\n\t\"frameBorder\",\n\t\"contentEditable\"\n], function() {\n\tjQuery.propFix[ this.toLowerCase() ] = this;\n} );\n\n\n\n\nvar rclass = /[\\t\\r\\n\\f]/g;\n\nfunction getClass( elem ) {\n\treturn elem.getAttribute && elem.getAttribute( \"class\" ) || \"\";\n}\n\njQuery.fn.extend( {\n\taddClass: function( value ) {\n\t\tvar classes, elem, cur, curValue, clazz, j, finalValue,\n\t\t\ti = 0;\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).addClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( typeof value === \"string\" && value ) {\n\t\t\tclasses = value.match( rnotwhite ) || [];\n\n\t\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\t\tcurValue = getClass( elem );\n\t\t\t\tcur = elem.nodeType === 1 &&\n\t\t\t\t\t( \" \" + curValue + \" \" ).replace( rclass, \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\twhile ( ( clazz = classes[ j++ ] ) ) {\n\t\t\t\t\t\tif ( cur.indexOf( \" \" + clazz + \" \" ) < 0 ) {\n\t\t\t\t\t\t\tcur += clazz + \" \";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = jQuery.trim( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\telem.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tremoveClass: function( value ) {\n\t\tvar classes, elem, cur, curValue, clazz, j, finalValue,\n\t\t\ti = 0;\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( !arguments.length ) {\n\t\t\treturn this.attr( \"class\", \"\" );\n\t\t}\n\n\t\tif ( typeof value === \"string\" && value ) {\n\t\t\tclasses = value.match( rnotwhite ) || [];\n\n\t\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\t\tcurValue = getClass( elem );\n\n\t\t\t\t// This expression is here for better compressibility (see addClass)\n\t\t\t\tcur = elem.nodeType === 1 &&\n\t\t\t\t\t( \" \" + curValue + \" \" ).replace( rclass, \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\twhile ( ( clazz = classes[ j++ ] ) ) {\n\n\t\t\t\t\t\t// Remove *all* instances\n\t\t\t\t\t\twhile ( cur.indexOf( \" \" + clazz + \" \" ) > -1 ) {\n\t\t\t\t\t\t\tcur = cur.replace( \" \" + clazz + \" \", \" \" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = jQuery.trim( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\telem.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttoggleClass: function( value, stateVal ) {\n\t\tvar type = typeof value;\n\n\t\tif ( typeof stateVal === \"boolean\" && type === \"string\" ) {\n\t\t\treturn stateVal ? this.addClass( value ) : this.removeClass( value );\n\t\t}\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).toggleClass(\n\t\t\t\t\tvalue.call( this, i, getClass( this ), stateVal ),\n\t\t\t\t\tstateVal\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar className, i, self, classNames;\n\n\t\t\tif ( type === \"string\" ) {\n\n\t\t\t\t// Toggle individual class names\n\t\t\t\ti = 0;\n\t\t\t\tself = jQuery( this );\n\t\t\t\tclassNames = value.match( rnotwhite ) || [];\n\n\t\t\t\twhile ( ( className = classNames[ i++ ] ) ) {\n\n\t\t\t\t\t// Check each className given, space separated list\n\t\t\t\t\tif ( self.hasClass( className ) ) {\n\t\t\t\t\t\tself.removeClass( className );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tself.addClass( className );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t// Toggle whole class name\n\t\t\t} else if ( value === undefined || type === \"boolean\" ) {\n\t\t\t\tclassName = getClass( this );\n\t\t\t\tif ( className ) {\n\n\t\t\t\t\t// Store className if set\n\t\t\t\t\tdataPriv.set( this, \"__className__\", className );\n\t\t\t\t}\n\n\t\t\t\t// If the element has a class name or if we're passed `false`,\n\t\t\t\t// then remove the whole classname (if there was one, the above saved it).\n\t\t\t\t// Otherwise bring back whatever was previously saved (if anything),\n\t\t\t\t// falling back to the empty string if nothing was stored.\n\t\t\t\tif ( this.setAttribute ) {\n\t\t\t\t\tthis.setAttribute( \"class\",\n\t\t\t\t\t\tclassName || value === false ?\n\t\t\t\t\t\t\"\" :\n\t\t\t\t\t\tdataPriv.get( this, \"__className__\" ) || \"\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\thasClass: function( selector ) {\n\t\tvar className, elem,\n\t\t\ti = 0;\n\n\t\tclassName = \" \" + selector + \" \";\n\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\tif ( elem.nodeType === 1 &&\n\t\t\t\t( \" \" + getClass( elem ) + \" \" ).replace( rclass, \" \" )\n\t\t\t\t\t.indexOf( className ) > -1\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n} );\n\n\n\n\nvar rreturn = /\\r/g,\n\trspaces = /[\\x20\\t\\r\\n\\f]+/g;\n\njQuery.fn.extend( {\n\tval: function( value ) {\n\t\tvar hooks, ret, isFunction,\n\t\t\telem = this[ 0 ];\n\n\t\tif ( !arguments.length ) {\n\t\t\tif ( elem ) {\n\t\t\t\thooks = jQuery.valHooks[ elem.type ] ||\n\t\t\t\t\tjQuery.valHooks[ elem.nodeName.toLowerCase() ];\n\n\t\t\t\tif ( hooks &&\n\t\t\t\t\t\"get\" in hooks &&\n\t\t\t\t\t( ret = hooks.get( elem, \"value\" ) ) !== undefined\n\t\t\t\t) {\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\t\tret = elem.value;\n\n\t\t\t\treturn typeof ret === \"string\" ?\n\n\t\t\t\t\t// Handle most common string cases\n\t\t\t\t\tret.replace( rreturn, \"\" ) :\n\n\t\t\t\t\t// Handle cases where value is null/undef or number\n\t\t\t\t\tret == null ? \"\" : ret;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tisFunction = jQuery.isFunction( value );\n\n\t\treturn this.each( function( i ) {\n\t\t\tvar val;\n\n\t\t\tif ( this.nodeType !== 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isFunction ) {\n\t\t\t\tval = value.call( this, i, jQuery( this ).val() );\n\t\t\t} else {\n\t\t\t\tval = value;\n\t\t\t}\n\n\t\t\t// Treat null/undefined as \"\"; convert numbers to string\n\t\t\tif ( val == null ) {\n\t\t\t\tval = \"\";\n\n\t\t\t} else if ( typeof val === \"number\" ) {\n\t\t\t\tval += \"\";\n\n\t\t\t} else if ( jQuery.isArray( val ) ) {\n\t\t\t\tval = jQuery.map( val, function( value ) {\n\t\t\t\t\treturn value == null ? \"\" : value + \"\";\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];\n\n\t\t\t// If set returns undefined, fall back to normal setting\n\t\t\tif ( !hooks || !( \"set\" in hooks ) || hooks.set( this, val, \"value\" ) === undefined ) {\n\t\t\t\tthis.value = val;\n\t\t\t}\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tvalHooks: {\n\t\toption: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\tvar val = jQuery.find.attr( elem, \"value\" );\n\t\t\t\treturn val != null ?\n\t\t\t\t\tval :\n\n\t\t\t\t\t// Support: IE10-11+\n\t\t\t\t\t// option.text throws exceptions (#14686, #14858)\n\t\t\t\t\t// Strip and collapse whitespace\n\t\t\t\t\t// https://html.spec.whatwg.org/#strip-and-collapse-whitespace\n\t\t\t\t\tjQuery.trim( jQuery.text( elem ) ).replace( rspaces, \" \" );\n\t\t\t}\n\t\t},\n\t\tselect: {\n\t\t\tget: function( elem ) {\n\t\t\t\tvar value, option,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tindex = elem.selectedIndex,\n\t\t\t\t\tone = elem.type === \"select-one\" || index < 0,\n\t\t\t\t\tvalues = one ? null : [],\n\t\t\t\t\tmax = one ? index + 1 : options.length,\n\t\t\t\t\ti = index < 0 ?\n\t\t\t\t\t\tmax :\n\t\t\t\t\t\tone ? index : 0;\n\n\t\t\t\t// Loop through all the selected options\n\t\t\t\tfor ( ; i < max; i++ ) {\n\t\t\t\t\toption = options[ i ];\n\n\t\t\t\t\t// IE8-9 doesn't update selected after form reset (#2551)\n\t\t\t\t\tif ( ( option.selected || i === index ) &&\n\n\t\t\t\t\t\t\t// Don't return options that are disabled or in a disabled optgroup\n\t\t\t\t\t\t\t( support.optDisabled ?\n\t\t\t\t\t\t\t\t!option.disabled : option.getAttribute( \"disabled\" ) === null ) &&\n\t\t\t\t\t\t\t( !option.parentNode.disabled ||\n\t\t\t\t\t\t\t\t!jQuery.nodeName( option.parentNode, \"optgroup\" ) ) ) {\n\n\t\t\t\t\t\t// Get the specific value for the option\n\t\t\t\t\t\tvalue = jQuery( option ).val();\n\n\t\t\t\t\t\t// We don't need an array for one selects\n\t\t\t\t\t\tif ( one ) {\n\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Multi-Selects return an array\n\t\t\t\t\t\tvalues.push( value );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\t\t\t},\n\n\t\t\tset: function( elem, value ) {\n\t\t\t\tvar optionSet, option,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tvalues = jQuery.makeArray( value ),\n\t\t\t\t\ti = options.length;\n\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\toption = options[ i ];\n\t\t\t\t\tif ( option.selected =\n\t\t\t\t\t\tjQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1\n\t\t\t\t\t) {\n\t\t\t\t\t\toptionSet = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Force browsers to behave consistently when non-matching value is set\n\t\t\t\tif ( !optionSet ) {\n\t\t\t\t\telem.selectedIndex = -1;\n\t\t\t\t}\n\t\t\t\treturn values;\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Radios and checkboxes getter/setter\njQuery.each( [ \"radio\", \"checkbox\" ], function() {\n\tjQuery.valHooks[ this ] = {\n\t\tset: function( elem, value ) {\n\t\t\tif ( jQuery.isArray( value ) ) {\n\t\t\t\treturn ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );\n\t\t\t}\n\t\t}\n\t};\n\tif ( !support.checkOn ) {\n\t\tjQuery.valHooks[ this ].get = function( elem ) {\n\t\t\treturn elem.getAttribute( \"value\" ) === null ? \"on\" : elem.value;\n\t\t};\n\t}\n} );\n\n\n\n\n// Return jQuery for attributes-only inclusion\n\n\nvar rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;\n\njQuery.extend( jQuery.event, {\n\n\ttrigger: function( event, data, elem, onlyHandlers ) {\n\n\t\tvar i, cur, tmp, bubbleType, ontype, handle, special,\n\t\t\teventPath = [ elem || document ],\n\t\t\ttype = hasOwn.call( event, \"type\" ) ? event.type : event,\n\t\t\tnamespaces = hasOwn.call( event, \"namespace\" ) ? event.namespace.split( \".\" ) : [];\n\n\t\tcur = tmp = elem = elem || document;\n\n\t\t// Don't do events on text and comment nodes\n\t\tif ( elem.nodeType === 3 || elem.nodeType === 8 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// focus/blur morphs to focusin/out; ensure we're not firing them right now\n\t\tif ( rfocusMorph.test( type + jQuery.event.triggered ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( type.indexOf( \".\" ) > -1 ) {\n\n\t\t\t// Namespaced trigger; create a regexp to match event type in handle()\n\t\t\tnamespaces = type.split( \".\" );\n\t\t\ttype = namespaces.shift();\n\t\t\tnamespaces.sort();\n\t\t}\n\t\tontype = type.indexOf( \":\" ) < 0 && \"on\" + type;\n\n\t\t// Caller can pass in a jQuery.Event object, Object, or just an event type string\n\t\tevent = event[ jQuery.expando ] ?\n\t\t\tevent :\n\t\t\tnew jQuery.Event( type, typeof event === \"object\" && event );\n\n\t\t// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)\n\t\tevent.isTrigger = onlyHandlers ? 2 : 3;\n\t\tevent.namespace = namespaces.join( \".\" );\n\t\tevent.rnamespace = event.namespace ?\n\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" ) :\n\t\t\tnull;\n\n\t\t// Clean up the event in case it is being reused\n\t\tevent.result = undefined;\n\t\tif ( !event.target ) {\n\t\t\tevent.target = elem;\n\t\t}\n\n\t\t// Clone any incoming data and prepend the event, creating the handler arg list\n\t\tdata = data == null ?\n\t\t\t[ event ] :\n\t\t\tjQuery.makeArray( data, [ event ] );\n\n\t\t// Allow special events to draw outside the lines\n\t\tspecial = jQuery.event.special[ type ] || {};\n\t\tif ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine event propagation path in advance, per W3C events spec (#9951)\n\t\t// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)\n\t\tif ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {\n\n\t\t\tbubbleType = special.delegateType || type;\n\t\t\tif ( !rfocusMorph.test( bubbleType + type ) ) {\n\t\t\t\tcur = cur.parentNode;\n\t\t\t}\n\t\t\tfor ( ; cur; cur = cur.parentNode ) {\n\t\t\t\teventPath.push( cur );\n\t\t\t\ttmp = cur;\n\t\t\t}\n\n\t\t\t// Only add window if we got to document (e.g., not plain obj or detached DOM)\n\t\t\tif ( tmp === ( elem.ownerDocument || document ) ) {\n\t\t\t\teventPath.push( tmp.defaultView || tmp.parentWindow || window );\n\t\t\t}\n\t\t}\n\n\t\t// Fire handlers on the event path\n\t\ti = 0;\n\t\twhile ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {\n\n\t\t\tevent.type = i > 1 ?\n\t\t\t\tbubbleType :\n\t\t\t\tspecial.bindType || type;\n\n\t\t\t// jQuery handler\n\t\t\thandle = ( dataPriv.get( cur, \"events\" ) || {} )[ event.type ] &&\n\t\t\t\tdataPriv.get( cur, \"handle\" );\n\t\t\tif ( handle ) {\n\t\t\t\thandle.apply( cur, data );\n\t\t\t}\n\n\t\t\t// Native handler\n\t\t\thandle = ontype && cur[ ontype ];\n\t\t\tif ( handle && handle.apply && acceptData( cur ) ) {\n\t\t\t\tevent.result = handle.apply( cur, data );\n\t\t\t\tif ( event.result === false ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tevent.type = type;\n\n\t\t// If nobody prevented the default action, do it now\n\t\tif ( !onlyHandlers && !event.isDefaultPrevented() ) {\n\n\t\t\tif ( ( !special._default ||\n\t\t\t\tspecial._default.apply( eventPath.pop(), data ) === false ) &&\n\t\t\t\tacceptData( elem ) ) {\n\n\t\t\t\t// Call a native DOM method on the target with the same name name as the event.\n\t\t\t\t// Don't do default actions on window, that's where global variables be (#6170)\n\t\t\t\tif ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {\n\n\t\t\t\t\t// Don't re-trigger an onFOO event when we call its FOO() method\n\t\t\t\t\ttmp = elem[ ontype ];\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prevent re-triggering of the same event, since we already bubbled it above\n\t\t\t\t\tjQuery.event.triggered = type;\n\t\t\t\t\telem[ type ]();\n\t\t\t\t\tjQuery.event.triggered = undefined;\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = tmp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\t// Piggyback on a donor event to simulate a different one\n\tsimulate: function( type, elem, event ) {\n\t\tvar e = jQuery.extend(\n\t\t\tnew jQuery.Event(),\n\t\t\tevent,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t\tisSimulated: true\n\n\t\t\t\t// Previously, `originalEvent: {}` was set here, so stopPropagation call\n\t\t\t\t// would not be triggered on donor event, since in our own\n\t\t\t\t// jQuery.event.stopPropagation function we had a check for existence of\n\t\t\t\t// originalEvent.stopPropagation method, so, consequently it would be a noop.\n\t\t\t\t//\n\t\t\t\t// But now, this \"simulate\" function is used only for events\n\t\t\t\t// for which stopPropagation() is noop, so there is no need for that anymore.\n\t\t\t\t//\n\t\t\t\t// For the 1.x branch though, guard for \"click\" and \"submit\"\n\t\t\t\t// events is still used, but was moved to jQuery.event.stopPropagation function\n\t\t\t\t// because `originalEvent` should point to the original event for the constancy\n\t\t\t\t// with other events and for more focused logic\n\t\t\t}\n\t\t);\n\n\t\tjQuery.event.trigger( e, null, elem );\n\n\t\tif ( e.isDefaultPrevented() ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n} );\n\njQuery.fn.extend( {\n\n\ttrigger: function( type, data ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.trigger( type, data, this );\n\t\t} );\n\t},\n\ttriggerHandler: function( type, data ) {\n\t\tvar elem = this[ 0 ];\n\t\tif ( elem ) {\n\t\t\treturn jQuery.event.trigger( type, data, elem, true );\n\t\t}\n\t}\n} );\n\n\njQuery.each( ( \"blur focus focusin focusout load resize scroll unload click dblclick \" +\n\t\"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave \" +\n\t\"change select submit keydown keypress keyup error contextmenu\" ).split( \" \" ),\n\tfunction( i, name ) {\n\n\t// Handle event binding\n\tjQuery.fn[ name ] = function( data, fn ) {\n\t\treturn arguments.length > 0 ?\n\t\t\tthis.on( name, null, data, fn ) :\n\t\t\tthis.trigger( name );\n\t};\n} );\n\njQuery.fn.extend( {\n\thover: function( fnOver, fnOut ) {\n\t\treturn this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );\n\t}\n} );\n\n\n\n\nsupport.focusin = \"onfocusin\" in window;\n\n\n// Support: Firefox\n// Firefox doesn't have focus(in | out) events\n// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787\n//\n// Support: Chrome, Safari\n// focus(in | out) events fire after focus & blur events,\n// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order\n// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857\nif ( !support.focusin ) {\n\tjQuery.each( { focus: \"focusin\", blur: \"focusout\" }, function( orig, fix ) {\n\n\t\t// Attach a single capturing handler on the document while someone wants focusin/focusout\n\t\tvar handler = function( event ) {\n\t\t\tjQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );\n\t\t};\n\n\t\tjQuery.event.special[ fix ] = {\n\t\t\tsetup: function() {\n\t\t\t\tvar doc = this.ownerDocument || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix );\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.addEventListener( orig, handler, true );\n\t\t\t\t}\n\t\t\t\tdataPriv.access( doc, fix, ( attaches || 0 ) + 1 );\n\t\t\t},\n\t\t\tteardown: function() {\n\t\t\t\tvar doc = this.ownerDocument || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix ) - 1;\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.removeEventListener( orig, handler, true );\n\t\t\t\t\tdataPriv.remove( doc, fix );\n\n\t\t\t\t} else {\n\t\t\t\t\tdataPriv.access( doc, fix, attaches );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t} );\n}\nvar location = window.location;\n\nvar nonce = jQuery.now();\n\nvar rquery = ( /\\?/ );\n\n\n\n// Support: Android 2.3\n// Workaround failure to string-cast null input\njQuery.parseJSON = function( data ) {\n\treturn JSON.parse( data + \"\" );\n};\n\n\n// Cross-browser xml parsing\njQuery.parseXML = function( data ) {\n\tvar xml;\n\tif ( !data || typeof data !== \"string\" ) {\n\t\treturn null;\n\t}\n\n\t// Support: IE9\n\ttry {\n\t\txml = ( new window.DOMParser() ).parseFromString( data, \"text/xml\" );\n\t} catch ( e ) {\n\t\txml = undefined;\n\t}\n\n\tif ( !xml || xml.getElementsByTagName( \"parsererror\" ).length ) {\n\t\tjQuery.error( \"Invalid XML: \" + data );\n\t}\n\treturn xml;\n};\n\n\nvar\n\trhash = /#.*$/,\n\trts = /([?&])_=[^&]*/,\n\trheaders = /^(.*?):[ \\t]*([^\\r\\n]*)$/mg,\n\n\t// #7653, #8125, #8152: local protocol detection\n\trlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,\n\trnoContent = /^(?:GET|HEAD)$/,\n\trprotocol = /^\\/\\//,\n\n\t/* Prefilters\n\t * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)\n\t * 2) These are called:\n\t *    - BEFORE asking for a transport\n\t *    - AFTER param serialization (s.data is a string if s.processData is true)\n\t * 3) key is the dataType\n\t * 4) the catchall symbol \"*\" can be used\n\t * 5) execution will start with transport dataType and THEN continue down to \"*\" if needed\n\t */\n\tprefilters = {},\n\n\t/* Transports bindings\n\t * 1) key is the dataType\n\t * 2) the catchall symbol \"*\" can be used\n\t * 3) selection will start with transport dataType and THEN go to \"*\" if needed\n\t */\n\ttransports = {},\n\n\t// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression\n\tallTypes = \"*/\".concat( \"*\" ),\n\n\t// Anchor tag for parsing the document origin\n\toriginAnchor = document.createElement( \"a\" );\n\toriginAnchor.href = location.href;\n\n// Base \"constructor\" for jQuery.ajaxPrefilter and jQuery.ajaxTransport\nfunction addToPrefiltersOrTransports( structure ) {\n\n\t// dataTypeExpression is optional and defaults to \"*\"\n\treturn function( dataTypeExpression, func ) {\n\n\t\tif ( typeof dataTypeExpression !== \"string\" ) {\n\t\t\tfunc = dataTypeExpression;\n\t\t\tdataTypeExpression = \"*\";\n\t\t}\n\n\t\tvar dataType,\n\t\t\ti = 0,\n\t\t\tdataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];\n\n\t\tif ( jQuery.isFunction( func ) ) {\n\n\t\t\t// For each dataType in the dataTypeExpression\n\t\t\twhile ( ( dataType = dataTypes[ i++ ] ) ) {\n\n\t\t\t\t// Prepend if requested\n\t\t\t\tif ( dataType[ 0 ] === \"+\" ) {\n\t\t\t\t\tdataType = dataType.slice( 1 ) || \"*\";\n\t\t\t\t\t( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );\n\n\t\t\t\t// Otherwise append\n\t\t\t\t} else {\n\t\t\t\t\t( structure[ dataType ] = structure[ dataType ] || [] ).push( func );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\n// Base inspection function for prefilters and transports\nfunction inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {\n\n\tvar inspected = {},\n\t\tseekingTransport = ( structure === transports );\n\n\tfunction inspect( dataType ) {\n\t\tvar selected;\n\t\tinspected[ dataType ] = true;\n\t\tjQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {\n\t\t\tvar dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );\n\t\t\tif ( typeof dataTypeOrTransport === \"string\" &&\n\t\t\t\t!seekingTransport && !inspected[ dataTypeOrTransport ] ) {\n\n\t\t\t\toptions.dataTypes.unshift( dataTypeOrTransport );\n\t\t\t\tinspect( dataTypeOrTransport );\n\t\t\t\treturn false;\n\t\t\t} else if ( seekingTransport ) {\n\t\t\t\treturn !( selected = dataTypeOrTransport );\n\t\t\t}\n\t\t} );\n\t\treturn selected;\n\t}\n\n\treturn inspect( options.dataTypes[ 0 ] ) || !inspected[ \"*\" ] && inspect( \"*\" );\n}\n\n// A special extend for ajax options\n// that takes \"flat\" options (not to be deep extended)\n// Fixes #9887\nfunction ajaxExtend( target, src ) {\n\tvar key, deep,\n\t\tflatOptions = jQuery.ajaxSettings.flatOptions || {};\n\n\tfor ( key in src ) {\n\t\tif ( src[ key ] !== undefined ) {\n\t\t\t( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];\n\t\t}\n\t}\n\tif ( deep ) {\n\t\tjQuery.extend( true, target, deep );\n\t}\n\n\treturn target;\n}\n\n/* Handles responses to an ajax request:\n * - finds the right dataType (mediates between content-type and expected dataType)\n * - returns the corresponding response\n */\nfunction ajaxHandleResponses( s, jqXHR, responses ) {\n\n\tvar ct, type, finalDataType, firstDataType,\n\t\tcontents = s.contents,\n\t\tdataTypes = s.dataTypes;\n\n\t// Remove auto dataType and get content-type in the process\n\twhile ( dataTypes[ 0 ] === \"*\" ) {\n\t\tdataTypes.shift();\n\t\tif ( ct === undefined ) {\n\t\t\tct = s.mimeType || jqXHR.getResponseHeader( \"Content-Type\" );\n\t\t}\n\t}\n\n\t// Check if we're dealing with a known content-type\n\tif ( ct ) {\n\t\tfor ( type in contents ) {\n\t\t\tif ( contents[ type ] && contents[ type ].test( ct ) ) {\n\t\t\t\tdataTypes.unshift( type );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Check to see if we have a response for the expected dataType\n\tif ( dataTypes[ 0 ] in responses ) {\n\t\tfinalDataType = dataTypes[ 0 ];\n\t} else {\n\n\t\t// Try convertible dataTypes\n\t\tfor ( type in responses ) {\n\t\t\tif ( !dataTypes[ 0 ] || s.converters[ type + \" \" + dataTypes[ 0 ] ] ) {\n\t\t\t\tfinalDataType = type;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( !firstDataType ) {\n\t\t\t\tfirstDataType = type;\n\t\t\t}\n\t\t}\n\n\t\t// Or just use first one\n\t\tfinalDataType = finalDataType || firstDataType;\n\t}\n\n\t// If we found a dataType\n\t// We add the dataType to the list if needed\n\t// and return the corresponding response\n\tif ( finalDataType ) {\n\t\tif ( finalDataType !== dataTypes[ 0 ] ) {\n\t\t\tdataTypes.unshift( finalDataType );\n\t\t}\n\t\treturn responses[ finalDataType ];\n\t}\n}\n\n/* Chain conversions given the request and the original response\n * Also sets the responseXXX fields on the jqXHR instance\n */\nfunction ajaxConvert( s, response, jqXHR, isSuccess ) {\n\tvar conv2, current, conv, tmp, prev,\n\t\tconverters = {},\n\n\t\t// Work with a copy of dataTypes in case we need to modify it for conversion\n\t\tdataTypes = s.dataTypes.slice();\n\n\t// Create converters map with lowercased keys\n\tif ( dataTypes[ 1 ] ) {\n\t\tfor ( conv in s.converters ) {\n\t\t\tconverters[ conv.toLowerCase() ] = s.converters[ conv ];\n\t\t}\n\t}\n\n\tcurrent = dataTypes.shift();\n\n\t// Convert to each sequential dataType\n\twhile ( current ) {\n\n\t\tif ( s.responseFields[ current ] ) {\n\t\t\tjqXHR[ s.responseFields[ current ] ] = response;\n\t\t}\n\n\t\t// Apply the dataFilter if provided\n\t\tif ( !prev && isSuccess && s.dataFilter ) {\n\t\t\tresponse = s.dataFilter( response, s.dataType );\n\t\t}\n\n\t\tprev = current;\n\t\tcurrent = dataTypes.shift();\n\n\t\tif ( current ) {\n\n\t\t// There's only work to do if current dataType is non-auto\n\t\t\tif ( current === \"*\" ) {\n\n\t\t\t\tcurrent = prev;\n\n\t\t\t// Convert response if prev dataType is non-auto and differs from current\n\t\t\t} else if ( prev !== \"*\" && prev !== current ) {\n\n\t\t\t\t// Seek a direct converter\n\t\t\t\tconv = converters[ prev + \" \" + current ] || converters[ \"* \" + current ];\n\n\t\t\t\t// If none found, seek a pair\n\t\t\t\tif ( !conv ) {\n\t\t\t\t\tfor ( conv2 in converters ) {\n\n\t\t\t\t\t\t// If conv2 outputs current\n\t\t\t\t\t\ttmp = conv2.split( \" \" );\n\t\t\t\t\t\tif ( tmp[ 1 ] === current ) {\n\n\t\t\t\t\t\t\t// If prev can be converted to accepted input\n\t\t\t\t\t\t\tconv = converters[ prev + \" \" + tmp[ 0 ] ] ||\n\t\t\t\t\t\t\t\tconverters[ \"* \" + tmp[ 0 ] ];\n\t\t\t\t\t\t\tif ( conv ) {\n\n\t\t\t\t\t\t\t\t// Condense equivalence converters\n\t\t\t\t\t\t\t\tif ( conv === true ) {\n\t\t\t\t\t\t\t\t\tconv = converters[ conv2 ];\n\n\t\t\t\t\t\t\t\t// Otherwise, insert the intermediate dataType\n\t\t\t\t\t\t\t\t} else if ( converters[ conv2 ] !== true ) {\n\t\t\t\t\t\t\t\t\tcurrent = tmp[ 0 ];\n\t\t\t\t\t\t\t\t\tdataTypes.unshift( tmp[ 1 ] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Apply converter (if not an equivalence)\n\t\t\t\tif ( conv !== true ) {\n\n\t\t\t\t\t// Unless errors are allowed to bubble, catch and return them\n\t\t\t\t\tif ( conv && s.throws ) {\n\t\t\t\t\t\tresponse = conv( response );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresponse = conv( response );\n\t\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tstate: \"parsererror\",\n\t\t\t\t\t\t\t\terror: conv ? e : \"No conversion from \" + prev + \" to \" + current\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { state: \"success\", data: response };\n}\n\njQuery.extend( {\n\n\t// Counter for holding the number of active queries\n\tactive: 0,\n\n\t// Last-Modified header cache for next request\n\tlastModified: {},\n\tetag: {},\n\n\tajaxSettings: {\n\t\turl: location.href,\n\t\ttype: \"GET\",\n\t\tisLocal: rlocalProtocol.test( location.protocol ),\n\t\tglobal: true,\n\t\tprocessData: true,\n\t\tasync: true,\n\t\tcontentType: \"application/x-www-form-urlencoded; charset=UTF-8\",\n\t\t/*\n\t\ttimeout: 0,\n\t\tdata: null,\n\t\tdataType: null,\n\t\tusername: null,\n\t\tpassword: null,\n\t\tcache: null,\n\t\tthrows: false,\n\t\ttraditional: false,\n\t\theaders: {},\n\t\t*/\n\n\t\taccepts: {\n\t\t\t\"*\": allTypes,\n\t\t\ttext: \"text/plain\",\n\t\t\thtml: \"text/html\",\n\t\t\txml: \"application/xml, text/xml\",\n\t\t\tjson: \"application/json, text/javascript\"\n\t\t},\n\n\t\tcontents: {\n\t\t\txml: /\\bxml\\b/,\n\t\t\thtml: /\\bhtml/,\n\t\t\tjson: /\\bjson\\b/\n\t\t},\n\n\t\tresponseFields: {\n\t\t\txml: \"responseXML\",\n\t\t\ttext: \"responseText\",\n\t\t\tjson: \"responseJSON\"\n\t\t},\n\n\t\t// Data converters\n\t\t// Keys separate source (or catchall \"*\") and destination types with a single space\n\t\tconverters: {\n\n\t\t\t// Convert anything to text\n\t\t\t\"* text\": String,\n\n\t\t\t// Text to html (true = no transformation)\n\t\t\t\"text html\": true,\n\n\t\t\t// Evaluate text as a json expression\n\t\t\t\"text json\": jQuery.parseJSON,\n\n\t\t\t// Parse text as xml\n\t\t\t\"text xml\": jQuery.parseXML\n\t\t},\n\n\t\t// For options that shouldn't be deep extended:\n\t\t// you can add your own custom options here if\n\t\t// and when you create one that shouldn't be\n\t\t// deep extended (see ajaxExtend)\n\t\tflatOptions: {\n\t\t\turl: true,\n\t\t\tcontext: true\n\t\t}\n\t},\n\n\t// Creates a full fledged settings object into target\n\t// with both ajaxSettings and settings fields.\n\t// If target is omitted, writes into ajaxSettings.\n\tajaxSetup: function( target, settings ) {\n\t\treturn settings ?\n\n\t\t\t// Building a settings object\n\t\t\tajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :\n\n\t\t\t// Extending ajaxSettings\n\t\t\tajaxExtend( jQuery.ajaxSettings, target );\n\t},\n\n\tajaxPrefilter: addToPrefiltersOrTransports( prefilters ),\n\tajaxTransport: addToPrefiltersOrTransports( transports ),\n\n\t// Main method\n\tajax: function( url, options ) {\n\n\t\t// If url is an object, simulate pre-1.5 signature\n\t\tif ( typeof url === \"object\" ) {\n\t\t\toptions = url;\n\t\t\turl = undefined;\n\t\t}\n\n\t\t// Force options to be an object\n\t\toptions = options || {};\n\n\t\tvar transport,\n\n\t\t\t// URL without anti-cache param\n\t\t\tcacheURL,\n\n\t\t\t// Response headers\n\t\t\tresponseHeadersString,\n\t\t\tresponseHeaders,\n\n\t\t\t// timeout handle\n\t\t\ttimeoutTimer,\n\n\t\t\t// Url cleanup var\n\t\t\turlAnchor,\n\n\t\t\t// To know if global events are to be dispatched\n\t\t\tfireGlobals,\n\n\t\t\t// Loop variable\n\t\t\ti,\n\n\t\t\t// Create the final options object\n\t\t\ts = jQuery.ajaxSetup( {}, options ),\n\n\t\t\t// Callbacks context\n\t\t\tcallbackContext = s.context || s,\n\n\t\t\t// Context for global events is callbackContext if it is a DOM node or jQuery collection\n\t\t\tglobalEventContext = s.context &&\n\t\t\t\t( callbackContext.nodeType || callbackContext.jquery ) ?\n\t\t\t\t\tjQuery( callbackContext ) :\n\t\t\t\t\tjQuery.event,\n\n\t\t\t// Deferreds\n\t\t\tdeferred = jQuery.Deferred(),\n\t\t\tcompleteDeferred = jQuery.Callbacks( \"once memory\" ),\n\n\t\t\t// Status-dependent callbacks\n\t\t\tstatusCode = s.statusCode || {},\n\n\t\t\t// Headers (they are sent all at once)\n\t\t\trequestHeaders = {},\n\t\t\trequestHeadersNames = {},\n\n\t\t\t// The jqXHR state\n\t\t\tstate = 0,\n\n\t\t\t// Default abort message\n\t\t\tstrAbort = \"canceled\",\n\n\t\t\t// Fake xhr\n\t\t\tjqXHR = {\n\t\t\t\treadyState: 0,\n\n\t\t\t\t// Builds headers hashtable if needed\n\t\t\t\tgetResponseHeader: function( key ) {\n\t\t\t\t\tvar match;\n\t\t\t\t\tif ( state === 2 ) {\n\t\t\t\t\t\tif ( !responseHeaders ) {\n\t\t\t\t\t\t\tresponseHeaders = {};\n\t\t\t\t\t\t\twhile ( ( match = rheaders.exec( responseHeadersString ) ) ) {\n\t\t\t\t\t\t\t\tresponseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmatch = responseHeaders[ key.toLowerCase() ];\n\t\t\t\t\t}\n\t\t\t\t\treturn match == null ? null : match;\n\t\t\t\t},\n\n\t\t\t\t// Raw string\n\t\t\t\tgetAllResponseHeaders: function() {\n\t\t\t\t\treturn state === 2 ? responseHeadersString : null;\n\t\t\t\t},\n\n\t\t\t\t// Caches the header\n\t\t\t\tsetRequestHeader: function( name, value ) {\n\t\t\t\t\tvar lname = name.toLowerCase();\n\t\t\t\t\tif ( !state ) {\n\t\t\t\t\t\tname = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;\n\t\t\t\t\t\trequestHeaders[ name ] = value;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Overrides response content-type header\n\t\t\t\toverrideMimeType: function( type ) {\n\t\t\t\t\tif ( !state ) {\n\t\t\t\t\t\ts.mimeType = type;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Status-dependent callbacks\n\t\t\t\tstatusCode: function( map ) {\n\t\t\t\t\tvar code;\n\t\t\t\t\tif ( map ) {\n\t\t\t\t\t\tif ( state < 2 ) {\n\t\t\t\t\t\t\tfor ( code in map ) {\n\n\t\t\t\t\t\t\t\t// Lazy-add the new callback in a way that preserves old ones\n\t\t\t\t\t\t\t\tstatusCode[ code ] = [ statusCode[ code ], map[ code ] ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// Execute the appropriate callbacks\n\t\t\t\t\t\t\tjqXHR.always( map[ jqXHR.status ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\n\t\t\t\t// Cancel the request\n\t\t\t\tabort: function( statusText ) {\n\t\t\t\t\tvar finalText = statusText || strAbort;\n\t\t\t\t\tif ( transport ) {\n\t\t\t\t\t\ttransport.abort( finalText );\n\t\t\t\t\t}\n\t\t\t\t\tdone( 0, finalText );\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t};\n\n\t\t// Attach deferreds\n\t\tdeferred.promise( jqXHR ).complete = completeDeferred.add;\n\t\tjqXHR.success = jqXHR.done;\n\t\tjqXHR.error = jqXHR.fail;\n\n\t\t// Remove hash character (#7531: and string promotion)\n\t\t// Add protocol if not provided (prefilters might expect it)\n\t\t// Handle falsy url in the settings object (#10093: consistency with old signature)\n\t\t// We also use the url parameter if available\n\t\ts.url = ( ( url || s.url || location.href ) + \"\" ).replace( rhash, \"\" )\n\t\t\t.replace( rprotocol, location.protocol + \"//\" );\n\n\t\t// Alias method option to type as per ticket #12004\n\t\ts.type = options.method || options.type || s.method || s.type;\n\n\t\t// Extract dataTypes list\n\t\ts.dataTypes = jQuery.trim( s.dataType || \"*\" ).toLowerCase().match( rnotwhite ) || [ \"\" ];\n\n\t\t// A cross-domain request is in order when the origin doesn't match the current origin.\n\t\tif ( s.crossDomain == null ) {\n\t\t\turlAnchor = document.createElement( \"a\" );\n\n\t\t\t// Support: IE8-11+\n\t\t\t// IE throws exception if url is malformed, e.g. http://example.com:80x/\n\t\t\ttry {\n\t\t\t\turlAnchor.href = s.url;\n\n\t\t\t\t// Support: IE8-11+\n\t\t\t\t// Anchor's host property isn't correctly set when s.url is relative\n\t\t\t\turlAnchor.href = urlAnchor.href;\n\t\t\t\ts.crossDomain = originAnchor.protocol + \"//\" + originAnchor.host !==\n\t\t\t\t\turlAnchor.protocol + \"//\" + urlAnchor.host;\n\t\t\t} catch ( e ) {\n\n\t\t\t\t// If there is an error parsing the URL, assume it is crossDomain,\n\t\t\t\t// it can be rejected by the transport if it is invalid\n\t\t\t\ts.crossDomain = true;\n\t\t\t}\n\t\t}\n\n\t\t// Convert data if not already a string\n\t\tif ( s.data && s.processData && typeof s.data !== \"string\" ) {\n\t\t\ts.data = jQuery.param( s.data, s.traditional );\n\t\t}\n\n\t\t// Apply prefilters\n\t\tinspectPrefiltersOrTransports( prefilters, s, options, jqXHR );\n\n\t\t// If request was aborted inside a prefilter, stop there\n\t\tif ( state === 2 ) {\n\t\t\treturn jqXHR;\n\t\t}\n\n\t\t// We can fire global events as of now if asked to\n\t\t// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)\n\t\tfireGlobals = jQuery.event && s.global;\n\n\t\t// Watch for a new set of requests\n\t\tif ( fireGlobals && jQuery.active++ === 0 ) {\n\t\t\tjQuery.event.trigger( \"ajaxStart\" );\n\t\t}\n\n\t\t// Uppercase the type\n\t\ts.type = s.type.toUpperCase();\n\n\t\t// Determine if request has content\n\t\ts.hasContent = !rnoContent.test( s.type );\n\n\t\t// Save the URL in case we're toying with the If-Modified-Since\n\t\t// and/or If-None-Match header later on\n\t\tcacheURL = s.url;\n\n\t\t// More options handling for requests with no content\n\t\tif ( !s.hasContent ) {\n\n\t\t\t// If data is available, append data to url\n\t\t\tif ( s.data ) {\n\t\t\t\tcacheURL = ( s.url += ( rquery.test( cacheURL ) ? \"&\" : \"?\" ) + s.data );\n\n\t\t\t\t// #9682: remove data so that it's not used in an eventual retry\n\t\t\t\tdelete s.data;\n\t\t\t}\n\n\t\t\t// Add anti-cache in url if needed\n\t\t\tif ( s.cache === false ) {\n\t\t\t\ts.url = rts.test( cacheURL ) ?\n\n\t\t\t\t\t// If there is already a '_' parameter, set its value\n\t\t\t\t\tcacheURL.replace( rts, \"$1_=\" + nonce++ ) :\n\n\t\t\t\t\t// Otherwise add one to the end\n\t\t\t\t\tcacheURL + ( rquery.test( cacheURL ) ? \"&\" : \"?\" ) + \"_=\" + nonce++;\n\t\t\t}\n\t\t}\n\n\t\t// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.\n\t\tif ( s.ifModified ) {\n\t\t\tif ( jQuery.lastModified[ cacheURL ] ) {\n\t\t\t\tjqXHR.setRequestHeader( \"If-Modified-Since\", jQuery.lastModified[ cacheURL ] );\n\t\t\t}\n\t\t\tif ( jQuery.etag[ cacheURL ] ) {\n\t\t\t\tjqXHR.setRequestHeader( \"If-None-Match\", jQuery.etag[ cacheURL ] );\n\t\t\t}\n\t\t}\n\n\t\t// Set the correct header, if data is being sent\n\t\tif ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {\n\t\t\tjqXHR.setRequestHeader( \"Content-Type\", s.contentType );\n\t\t}\n\n\t\t// Set the Accepts header for the server, depending on the dataType\n\t\tjqXHR.setRequestHeader(\n\t\t\t\"Accept\",\n\t\t\ts.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?\n\t\t\t\ts.accepts[ s.dataTypes[ 0 ] ] +\n\t\t\t\t\t( s.dataTypes[ 0 ] !== \"*\" ? \", \" + allTypes + \"; q=0.01\" : \"\" ) :\n\t\t\t\ts.accepts[ \"*\" ]\n\t\t);\n\n\t\t// Check for headers option\n\t\tfor ( i in s.headers ) {\n\t\t\tjqXHR.setRequestHeader( i, s.headers[ i ] );\n\t\t}\n\n\t\t// Allow custom headers/mimetypes and early abort\n\t\tif ( s.beforeSend &&\n\t\t\t( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {\n\n\t\t\t// Abort if not done already and return\n\t\t\treturn jqXHR.abort();\n\t\t}\n\n\t\t// Aborting is no longer a cancellation\n\t\tstrAbort = \"abort\";\n\n\t\t// Install callbacks on deferreds\n\t\tfor ( i in { success: 1, error: 1, complete: 1 } ) {\n\t\t\tjqXHR[ i ]( s[ i ] );\n\t\t}\n\n\t\t// Get transport\n\t\ttransport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );\n\n\t\t// If no transport, we auto-abort\n\t\tif ( !transport ) {\n\t\t\tdone( -1, \"No Transport\" );\n\t\t} else {\n\t\t\tjqXHR.readyState = 1;\n\n\t\t\t// Send global event\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( \"ajaxSend\", [ jqXHR, s ] );\n\t\t\t}\n\n\t\t\t// If request was aborted inside ajaxSend, stop there\n\t\t\tif ( state === 2 ) {\n\t\t\t\treturn jqXHR;\n\t\t\t}\n\n\t\t\t// Timeout\n\t\t\tif ( s.async && s.timeout > 0 ) {\n\t\t\t\ttimeoutTimer = window.setTimeout( function() {\n\t\t\t\t\tjqXHR.abort( \"timeout\" );\n\t\t\t\t}, s.timeout );\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tstate = 1;\n\t\t\t\ttransport.send( requestHeaders, done );\n\t\t\t} catch ( e ) {\n\n\t\t\t\t// Propagate exception as error if not done\n\t\t\t\tif ( state < 2 ) {\n\t\t\t\t\tdone( -1, e );\n\n\t\t\t\t// Simply rethrow otherwise\n\t\t\t\t} else {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Callback for when everything is done\n\t\tfunction done( status, nativeStatusText, responses, headers ) {\n\t\t\tvar isSuccess, success, error, response, modified,\n\t\t\t\tstatusText = nativeStatusText;\n\n\t\t\t// Called once\n\t\t\tif ( state === 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// State is \"done\" now\n\t\t\tstate = 2;\n\n\t\t\t// Clear timeout if it exists\n\t\t\tif ( timeoutTimer ) {\n\t\t\t\twindow.clearTimeout( timeoutTimer );\n\t\t\t}\n\n\t\t\t// Dereference transport for early garbage collection\n\t\t\t// (no matter how long the jqXHR object will be used)\n\t\t\ttransport = undefined;\n\n\t\t\t// Cache response headers\n\t\t\tresponseHeadersString = headers || \"\";\n\n\t\t\t// Set readyState\n\t\t\tjqXHR.readyState = status > 0 ? 4 : 0;\n\n\t\t\t// Determine if successful\n\t\t\tisSuccess = status >= 200 && status < 300 || status === 304;\n\n\t\t\t// Get response data\n\t\t\tif ( responses ) {\n\t\t\t\tresponse = ajaxHandleResponses( s, jqXHR, responses );\n\t\t\t}\n\n\t\t\t// Convert no matter what (that way responseXXX fields are always set)\n\t\t\tresponse = ajaxConvert( s, response, jqXHR, isSuccess );\n\n\t\t\t// If successful, handle type chaining\n\t\t\tif ( isSuccess ) {\n\n\t\t\t\t// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.\n\t\t\t\tif ( s.ifModified ) {\n\t\t\t\t\tmodified = jqXHR.getResponseHeader( \"Last-Modified\" );\n\t\t\t\t\tif ( modified ) {\n\t\t\t\t\t\tjQuery.lastModified[ cacheURL ] = modified;\n\t\t\t\t\t}\n\t\t\t\t\tmodified = jqXHR.getResponseHeader( \"etag\" );\n\t\t\t\t\tif ( modified ) {\n\t\t\t\t\t\tjQuery.etag[ cacheURL ] = modified;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// if no content\n\t\t\t\tif ( status === 204 || s.type === \"HEAD\" ) {\n\t\t\t\t\tstatusText = \"nocontent\";\n\n\t\t\t\t// if not modified\n\t\t\t\t} else if ( status === 304 ) {\n\t\t\t\t\tstatusText = \"notmodified\";\n\n\t\t\t\t// If we have data, let's convert it\n\t\t\t\t} else {\n\t\t\t\t\tstatusText = response.state;\n\t\t\t\t\tsuccess = response.data;\n\t\t\t\t\terror = response.error;\n\t\t\t\t\tisSuccess = !error;\n\t\t\t\t}\n\t\t\t} else {\n\n\t\t\t\t// Extract error from statusText and normalize for non-aborts\n\t\t\t\terror = statusText;\n\t\t\t\tif ( status || !statusText ) {\n\t\t\t\t\tstatusText = \"error\";\n\t\t\t\t\tif ( status < 0 ) {\n\t\t\t\t\t\tstatus = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Set data for the fake xhr object\n\t\t\tjqXHR.status = status;\n\t\t\tjqXHR.statusText = ( nativeStatusText || statusText ) + \"\";\n\n\t\t\t// Success/Error\n\t\t\tif ( isSuccess ) {\n\t\t\t\tdeferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );\n\t\t\t} else {\n\t\t\t\tdeferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );\n\t\t\t}\n\n\t\t\t// Status-dependent callbacks\n\t\t\tjqXHR.statusCode( statusCode );\n\t\t\tstatusCode = undefined;\n\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( isSuccess ? \"ajaxSuccess\" : \"ajaxError\",\n\t\t\t\t\t[ jqXHR, s, isSuccess ? success : error ] );\n\t\t\t}\n\n\t\t\t// Complete\n\t\t\tcompleteDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );\n\n\t\t\tif ( fireGlobals ) {\n\t\t\t\tglobalEventContext.trigger( \"ajaxComplete\", [ jqXHR, s ] );\n\n\t\t\t\t// Handle the global AJAX counter\n\t\t\t\tif ( !( --jQuery.active ) ) {\n\t\t\t\t\tjQuery.event.trigger( \"ajaxStop\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jqXHR;\n\t},\n\n\tgetJSON: function( url, data, callback ) {\n\t\treturn jQuery.get( url, data, callback, \"json\" );\n\t},\n\n\tgetScript: function( url, callback ) {\n\t\treturn jQuery.get( url, undefined, callback, \"script\" );\n\t}\n} );\n\njQuery.each( [ \"get\", \"post\" ], function( i, method ) {\n\tjQuery[ method ] = function( url, data, callback, type ) {\n\n\t\t// Shift arguments if data argument was omitted\n\t\tif ( jQuery.isFunction( data ) ) {\n\t\t\ttype = type || callback;\n\t\t\tcallback = data;\n\t\t\tdata = undefined;\n\t\t}\n\n\t\t// The url can be an options object (which then must have .url)\n\t\treturn jQuery.ajax( jQuery.extend( {\n\t\t\turl: url,\n\t\t\ttype: method,\n\t\t\tdataType: type,\n\t\t\tdata: data,\n\t\t\tsuccess: callback\n\t\t}, jQuery.isPlainObject( url ) && url ) );\n\t};\n} );\n\n\njQuery._evalUrl = function( url ) {\n\treturn jQuery.ajax( {\n\t\turl: url,\n\n\t\t// Make this explicit, since user can override this through ajaxSetup (#11264)\n\t\ttype: \"GET\",\n\t\tdataType: \"script\",\n\t\tasync: false,\n\t\tglobal: false,\n\t\t\"throws\": true\n\t} );\n};\n\n\njQuery.fn.extend( {\n\twrapAll: function( html ) {\n\t\tvar wrap;\n\n\t\tif ( jQuery.isFunction( html ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).wrapAll( html.call( this, i ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( this[ 0 ] ) {\n\n\t\t\t// The elements to wrap the target around\n\t\t\twrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );\n\n\t\t\tif ( this[ 0 ].parentNode ) {\n\t\t\t\twrap.insertBefore( this[ 0 ] );\n\t\t\t}\n\n\t\t\twrap.map( function() {\n\t\t\t\tvar elem = this;\n\n\t\t\t\twhile ( elem.firstElementChild ) {\n\t\t\t\t\telem = elem.firstElementChild;\n\t\t\t\t}\n\n\t\t\t\treturn elem;\n\t\t\t} ).append( this );\n\t\t}\n\n\t\treturn this;\n\t},\n\n\twrapInner: function( html ) {\n\t\tif ( jQuery.isFunction( html ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).wrapInner( html.call( this, i ) );\n\t\t\t} );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar self = jQuery( this ),\n\t\t\t\tcontents = self.contents();\n\n\t\t\tif ( contents.length ) {\n\t\t\t\tcontents.wrapAll( html );\n\n\t\t\t} else {\n\t\t\t\tself.append( html );\n\t\t\t}\n\t\t} );\n\t},\n\n\twrap: function( html ) {\n\t\tvar isFunction = jQuery.isFunction( html );\n\n\t\treturn this.each( function( i ) {\n\t\t\tjQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );\n\t\t} );\n\t},\n\n\tunwrap: function() {\n\t\treturn this.parent().each( function() {\n\t\t\tif ( !jQuery.nodeName( this, \"body\" ) ) {\n\t\t\t\tjQuery( this ).replaceWith( this.childNodes );\n\t\t\t}\n\t\t} ).end();\n\t}\n} );\n\n\njQuery.expr.filters.hidden = function( elem ) {\n\treturn !jQuery.expr.filters.visible( elem );\n};\njQuery.expr.filters.visible = function( elem ) {\n\n\t// Support: Opera <= 12.12\n\t// Opera reports offsetWidths and offsetHeights less than zero on some elements\n\t// Use OR instead of AND as the element is not visible if either is true\n\t// See tickets #10406 and #13132\n\treturn elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0;\n};\n\n\n\n\nvar r20 = /%20/g,\n\trbracket = /\\[\\]$/,\n\trCRLF = /\\r?\\n/g,\n\trsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,\n\trsubmittable = /^(?:input|select|textarea|keygen)/i;\n\nfunction buildParams( prefix, obj, traditional, add ) {\n\tvar name;\n\n\tif ( jQuery.isArray( obj ) ) {\n\n\t\t// Serialize array item.\n\t\tjQuery.each( obj, function( i, v ) {\n\t\t\tif ( traditional || rbracket.test( prefix ) ) {\n\n\t\t\t\t// Treat each array item as a scalar.\n\t\t\t\tadd( prefix, v );\n\n\t\t\t} else {\n\n\t\t\t\t// Item is non-scalar (array or object), encode its numeric index.\n\t\t\t\tbuildParams(\n\t\t\t\t\tprefix + \"[\" + ( typeof v === \"object\" && v != null ? i : \"\" ) + \"]\",\n\t\t\t\t\tv,\n\t\t\t\t\ttraditional,\n\t\t\t\t\tadd\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t} else if ( !traditional && jQuery.type( obj ) === \"object\" ) {\n\n\t\t// Serialize object item.\n\t\tfor ( name in obj ) {\n\t\t\tbuildParams( prefix + \"[\" + name + \"]\", obj[ name ], traditional, add );\n\t\t}\n\n\t} else {\n\n\t\t// Serialize scalar item.\n\t\tadd( prefix, obj );\n\t}\n}\n\n// Serialize an array of form elements or a set of\n// key/values into a query string\njQuery.param = function( a, traditional ) {\n\tvar prefix,\n\t\ts = [],\n\t\tadd = function( key, value ) {\n\n\t\t\t// If value is a function, invoke it and return its value\n\t\t\tvalue = jQuery.isFunction( value ) ? value() : ( value == null ? \"\" : value );\n\t\t\ts[ s.length ] = encodeURIComponent( key ) + \"=\" + encodeURIComponent( value );\n\t\t};\n\n\t// Set traditional to true for jQuery <= 1.3.2 behavior.\n\tif ( traditional === undefined ) {\n\t\ttraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;\n\t}\n\n\t// If an array was passed in, assume that it is an array of form elements.\n\tif ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {\n\n\t\t// Serialize the form elements\n\t\tjQuery.each( a, function() {\n\t\t\tadd( this.name, this.value );\n\t\t} );\n\n\t} else {\n\n\t\t// If traditional, encode the \"old\" way (the way 1.3.2 or older\n\t\t// did it), otherwise encode params recursively.\n\t\tfor ( prefix in a ) {\n\t\t\tbuildParams( prefix, a[ prefix ], traditional, add );\n\t\t}\n\t}\n\n\t// Return the resulting serialization\n\treturn s.join( \"&\" ).replace( r20, \"+\" );\n};\n\njQuery.fn.extend( {\n\tserialize: function() {\n\t\treturn jQuery.param( this.serializeArray() );\n\t},\n\tserializeArray: function() {\n\t\treturn this.map( function() {\n\n\t\t\t// Can add propHook for \"elements\" to filter or add form elements\n\t\t\tvar elements = jQuery.prop( this, \"elements\" );\n\t\t\treturn elements ? jQuery.makeArray( elements ) : this;\n\t\t} )\n\t\t.filter( function() {\n\t\t\tvar type = this.type;\n\n\t\t\t// Use .is( \":disabled\" ) so that fieldset[disabled] works\n\t\t\treturn this.name && !jQuery( this ).is( \":disabled\" ) &&\n\t\t\t\trsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&\n\t\t\t\t( this.checked || !rcheckableType.test( type ) );\n\t\t} )\n\t\t.map( function( i, elem ) {\n\t\t\tvar val = jQuery( this ).val();\n\n\t\t\treturn val == null ?\n\t\t\t\tnull :\n\t\t\t\tjQuery.isArray( val ) ?\n\t\t\t\t\tjQuery.map( val, function( val ) {\n\t\t\t\t\t\treturn { name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t\t\t\t} ) :\n\t\t\t\t\t{ name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t} ).get();\n\t}\n} );\n\n\njQuery.ajaxSettings.xhr = function() {\n\ttry {\n\t\treturn new window.XMLHttpRequest();\n\t} catch ( e ) {}\n};\n\nvar xhrSuccessStatus = {\n\n\t\t// File protocol always yields status code 0, assume 200\n\t\t0: 200,\n\n\t\t// Support: IE9\n\t\t// #1450: sometimes IE returns 1223 when it should be 204\n\t\t1223: 204\n\t},\n\txhrSupported = jQuery.ajaxSettings.xhr();\n\nsupport.cors = !!xhrSupported && ( \"withCredentials\" in xhrSupported );\nsupport.ajax = xhrSupported = !!xhrSupported;\n\njQuery.ajaxTransport( function( options ) {\n\tvar callback, errorCallback;\n\n\t// Cross domain only allowed if supported through XMLHttpRequest\n\tif ( support.cors || xhrSupported && !options.crossDomain ) {\n\t\treturn {\n\t\t\tsend: function( headers, complete ) {\n\t\t\t\tvar i,\n\t\t\t\t\txhr = options.xhr();\n\n\t\t\t\txhr.open(\n\t\t\t\t\toptions.type,\n\t\t\t\t\toptions.url,\n\t\t\t\t\toptions.async,\n\t\t\t\t\toptions.username,\n\t\t\t\t\toptions.password\n\t\t\t\t);\n\n\t\t\t\t// Apply custom fields if provided\n\t\t\t\tif ( options.xhrFields ) {\n\t\t\t\t\tfor ( i in options.xhrFields ) {\n\t\t\t\t\t\txhr[ i ] = options.xhrFields[ i ];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Override mime type if needed\n\t\t\t\tif ( options.mimeType && xhr.overrideMimeType ) {\n\t\t\t\t\txhr.overrideMimeType( options.mimeType );\n\t\t\t\t}\n\n\t\t\t\t// X-Requested-With header\n\t\t\t\t// For cross-domain requests, seeing as conditions for a preflight are\n\t\t\t\t// akin to a jigsaw puzzle, we simply never set it to be sure.\n\t\t\t\t// (it can always be set on a per-request basis or even using ajaxSetup)\n\t\t\t\t// For same-domain requests, won't change header if already provided.\n\t\t\t\tif ( !options.crossDomain && !headers[ \"X-Requested-With\" ] ) {\n\t\t\t\t\theaders[ \"X-Requested-With\" ] = \"XMLHttpRequest\";\n\t\t\t\t}\n\n\t\t\t\t// Set headers\n\t\t\t\tfor ( i in headers ) {\n\t\t\t\t\txhr.setRequestHeader( i, headers[ i ] );\n\t\t\t\t}\n\n\t\t\t\t// Callback\n\t\t\t\tcallback = function( type ) {\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\t\tcallback = errorCallback = xhr.onload =\n\t\t\t\t\t\t\t\txhr.onerror = xhr.onabort = xhr.onreadystatechange = null;\n\n\t\t\t\t\t\t\tif ( type === \"abort\" ) {\n\t\t\t\t\t\t\t\txhr.abort();\n\t\t\t\t\t\t\t} else if ( type === \"error\" ) {\n\n\t\t\t\t\t\t\t\t// Support: IE9\n\t\t\t\t\t\t\t\t// On a manual native abort, IE9 throws\n\t\t\t\t\t\t\t\t// errors on any property access that is not readyState\n\t\t\t\t\t\t\t\tif ( typeof xhr.status !== \"number\" ) {\n\t\t\t\t\t\t\t\t\tcomplete( 0, \"error\" );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcomplete(\n\n\t\t\t\t\t\t\t\t\t\t// File: protocol always yields status 0; see #8605, #14207\n\t\t\t\t\t\t\t\t\t\txhr.status,\n\t\t\t\t\t\t\t\t\t\txhr.statusText\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcomplete(\n\t\t\t\t\t\t\t\t\txhrSuccessStatus[ xhr.status ] || xhr.status,\n\t\t\t\t\t\t\t\t\txhr.statusText,\n\n\t\t\t\t\t\t\t\t\t// Support: IE9 only\n\t\t\t\t\t\t\t\t\t// IE9 has no XHR2 but throws on binary (trac-11426)\n\t\t\t\t\t\t\t\t\t// For XHR2 non-text, let the caller handle it (gh-2498)\n\t\t\t\t\t\t\t\t\t( xhr.responseType || \"text\" ) !== \"text\"  ||\n\t\t\t\t\t\t\t\t\ttypeof xhr.responseText !== \"string\" ?\n\t\t\t\t\t\t\t\t\t\t{ binary: xhr.response } :\n\t\t\t\t\t\t\t\t\t\t{ text: xhr.responseText },\n\t\t\t\t\t\t\t\t\txhr.getAllResponseHeaders()\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t};\n\n\t\t\t\t// Listen to events\n\t\t\t\txhr.onload = callback();\n\t\t\t\terrorCallback = xhr.onerror = callback( \"error\" );\n\n\t\t\t\t// Support: IE9\n\t\t\t\t// Use onreadystatechange to replace onabort\n\t\t\t\t// to handle uncaught aborts\n\t\t\t\tif ( xhr.onabort !== undefined ) {\n\t\t\t\t\txhr.onabort = errorCallback;\n\t\t\t\t} else {\n\t\t\t\t\txhr.onreadystatechange = function() {\n\n\t\t\t\t\t\t// Check readyState before timeout as it changes\n\t\t\t\t\t\tif ( xhr.readyState === 4 ) {\n\n\t\t\t\t\t\t\t// Allow onerror to be called first,\n\t\t\t\t\t\t\t// but that will not handle a native abort\n\t\t\t\t\t\t\t// Also, save errorCallback to a variable\n\t\t\t\t\t\t\t// as xhr.onerror cannot be accessed\n\t\t\t\t\t\t\twindow.setTimeout( function() {\n\t\t\t\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\t\t\t\terrorCallback();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Create the abort callback\n\t\t\t\tcallback = callback( \"abort\" );\n\n\t\t\t\ttry {\n\n\t\t\t\t\t// Do send the request (this may raise an exception)\n\t\t\t\t\txhr.send( options.hasContent && options.data || null );\n\t\t\t\t} catch ( e ) {\n\n\t\t\t\t\t// #14683: Only rethrow if this hasn't been notified as an error yet\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tabort: function() {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n} );\n\n\n\n\n// Install script dataType\njQuery.ajaxSetup( {\n\taccepts: {\n\t\tscript: \"text/javascript, application/javascript, \" +\n\t\t\t\"application/ecmascript, application/x-ecmascript\"\n\t},\n\tcontents: {\n\t\tscript: /\\b(?:java|ecma)script\\b/\n\t},\n\tconverters: {\n\t\t\"text script\": function( text ) {\n\t\t\tjQuery.globalEval( text );\n\t\t\treturn text;\n\t\t}\n\t}\n} );\n\n// Handle cache's special case and crossDomain\njQuery.ajaxPrefilter( \"script\", function( s ) {\n\tif ( s.cache === undefined ) {\n\t\ts.cache = false;\n\t}\n\tif ( s.crossDomain ) {\n\t\ts.type = \"GET\";\n\t}\n} );\n\n// Bind script tag hack transport\njQuery.ajaxTransport( \"script\", function( s ) {\n\n\t// This transport only deals with cross domain requests\n\tif ( s.crossDomain ) {\n\t\tvar script, callback;\n\t\treturn {\n\t\t\tsend: function( _, complete ) {\n\t\t\t\tscript = jQuery( \"<script>\" ).prop( {\n\t\t\t\t\tcharset: s.scriptCharset,\n\t\t\t\t\tsrc: s.url\n\t\t\t\t} ).on(\n\t\t\t\t\t\"load error\",\n\t\t\t\t\tcallback = function( evt ) {\n\t\t\t\t\t\tscript.remove();\n\t\t\t\t\t\tcallback = null;\n\t\t\t\t\t\tif ( evt ) {\n\t\t\t\t\t\t\tcomplete( evt.type === \"error\" ? 404 : 200, evt.type );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Use native DOM manipulation to avoid our domManip AJAX trickery\n\t\t\t\tdocument.head.appendChild( script[ 0 ] );\n\t\t\t},\n\t\t\tabort: function() {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n} );\n\n\n\n\nvar oldCallbacks = [],\n\trjsonp = /(=)\\?(?=&|$)|\\?\\?/;\n\n// Default jsonp settings\njQuery.ajaxSetup( {\n\tjsonp: \"callback\",\n\tjsonpCallback: function() {\n\t\tvar callback = oldCallbacks.pop() || ( jQuery.expando + \"_\" + ( nonce++ ) );\n\t\tthis[ callback ] = true;\n\t\treturn callback;\n\t}\n} );\n\n// Detect, normalize options and install callbacks for jsonp requests\njQuery.ajaxPrefilter( \"json jsonp\", function( s, originalSettings, jqXHR ) {\n\n\tvar callbackName, overwritten, responseContainer,\n\t\tjsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?\n\t\t\t\"url\" :\n\t\t\ttypeof s.data === \"string\" &&\n\t\t\t\t( s.contentType || \"\" )\n\t\t\t\t\t.indexOf( \"application/x-www-form-urlencoded\" ) === 0 &&\n\t\t\t\trjsonp.test( s.data ) && \"data\"\n\t\t);\n\n\t// Handle iff the expected data type is \"jsonp\" or we have a parameter to set\n\tif ( jsonProp || s.dataTypes[ 0 ] === \"jsonp\" ) {\n\n\t\t// Get callback name, remembering preexisting value associated with it\n\t\tcallbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?\n\t\t\ts.jsonpCallback() :\n\t\t\ts.jsonpCallback;\n\n\t\t// Insert callback into url or form data\n\t\tif ( jsonProp ) {\n\t\t\ts[ jsonProp ] = s[ jsonProp ].replace( rjsonp, \"$1\" + callbackName );\n\t\t} else if ( s.jsonp !== false ) {\n\t\t\ts.url += ( rquery.test( s.url ) ? \"&\" : \"?\" ) + s.jsonp + \"=\" + callbackName;\n\t\t}\n\n\t\t// Use data converter to retrieve json after script execution\n\t\ts.converters[ \"script json\" ] = function() {\n\t\t\tif ( !responseContainer ) {\n\t\t\t\tjQuery.error( callbackName + \" was not called\" );\n\t\t\t}\n\t\t\treturn responseContainer[ 0 ];\n\t\t};\n\n\t\t// Force json dataType\n\t\ts.dataTypes[ 0 ] = \"json\";\n\n\t\t// Install callback\n\t\toverwritten = window[ callbackName ];\n\t\twindow[ callbackName ] = function() {\n\t\t\tresponseContainer = arguments;\n\t\t};\n\n\t\t// Clean-up function (fires after converters)\n\t\tjqXHR.always( function() {\n\n\t\t\t// If previous value didn't exist - remove it\n\t\t\tif ( overwritten === undefined ) {\n\t\t\t\tjQuery( window ).removeProp( callbackName );\n\n\t\t\t// Otherwise restore preexisting value\n\t\t\t} else {\n\t\t\t\twindow[ callbackName ] = overwritten;\n\t\t\t}\n\n\t\t\t// Save back as free\n\t\t\tif ( s[ callbackName ] ) {\n\n\t\t\t\t// Make sure that re-using the options doesn't screw things around\n\t\t\t\ts.jsonpCallback = originalSettings.jsonpCallback;\n\n\t\t\t\t// Save the callback name for future use\n\t\t\t\toldCallbacks.push( callbackName );\n\t\t\t}\n\n\t\t\t// Call if it was a function and we have a response\n\t\t\tif ( responseContainer && jQuery.isFunction( overwritten ) ) {\n\t\t\t\toverwritten( responseContainer[ 0 ] );\n\t\t\t}\n\n\t\t\tresponseContainer = overwritten = undefined;\n\t\t} );\n\n\t\t// Delegate to script\n\t\treturn \"script\";\n\t}\n} );\n\n\n\n\n// Argument \"data\" should be string of html\n// context (optional): If specified, the fragment will be created in this context,\n// defaults to document\n// keepScripts (optional): If true, will include scripts passed in the html string\njQuery.parseHTML = function( data, context, keepScripts ) {\n\tif ( !data || typeof data !== \"string\" ) {\n\t\treturn null;\n\t}\n\tif ( typeof context === \"boolean\" ) {\n\t\tkeepScripts = context;\n\t\tcontext = false;\n\t}\n\tcontext = context || document;\n\n\tvar parsed = rsingleTag.exec( data ),\n\t\tscripts = !keepScripts && [];\n\n\t// Single tag\n\tif ( parsed ) {\n\t\treturn [ context.createElement( parsed[ 1 ] ) ];\n\t}\n\n\tparsed = buildFragment( [ data ], context, scripts );\n\n\tif ( scripts && scripts.length ) {\n\t\tjQuery( scripts ).remove();\n\t}\n\n\treturn jQuery.merge( [], parsed.childNodes );\n};\n\n\n// Keep a copy of the old load method\nvar _load = jQuery.fn.load;\n\n/**\n * Load a url into a page\n */\njQuery.fn.load = function( url, params, callback ) {\n\tif ( typeof url !== \"string\" && _load ) {\n\t\treturn _load.apply( this, arguments );\n\t}\n\n\tvar selector, type, response,\n\t\tself = this,\n\t\toff = url.indexOf( \" \" );\n\n\tif ( off > -1 ) {\n\t\tselector = jQuery.trim( url.slice( off ) );\n\t\turl = url.slice( 0, off );\n\t}\n\n\t// If it's a function\n\tif ( jQuery.isFunction( params ) ) {\n\n\t\t// We assume that it's the callback\n\t\tcallback = params;\n\t\tparams = undefined;\n\n\t// Otherwise, build a param string\n\t} else if ( params && typeof params === \"object\" ) {\n\t\ttype = \"POST\";\n\t}\n\n\t// If we have elements to modify, make the request\n\tif ( self.length > 0 ) {\n\t\tjQuery.ajax( {\n\t\t\turl: url,\n\n\t\t\t// If \"type\" variable is undefined, then \"GET\" method will be used.\n\t\t\t// Make value of this field explicit since\n\t\t\t// user can override it through ajaxSetup method\n\t\t\ttype: type || \"GET\",\n\t\t\tdataType: \"html\",\n\t\t\tdata: params\n\t\t} ).done( function( responseText ) {\n\n\t\t\t// Save response for use in complete callback\n\t\t\tresponse = arguments;\n\n\t\t\tself.html( selector ?\n\n\t\t\t\t// If a selector was specified, locate the right elements in a dummy div\n\t\t\t\t// Exclude scripts to avoid IE 'Permission Denied' errors\n\t\t\t\tjQuery( \"<div>\" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :\n\n\t\t\t\t// Otherwise use the full result\n\t\t\t\tresponseText );\n\n\t\t// If the request succeeds, this function gets \"data\", \"status\", \"jqXHR\"\n\t\t// but they are ignored because response was set above.\n\t\t// If it fails, this function gets \"jqXHR\", \"status\", \"error\"\n\t\t} ).always( callback && function( jqXHR, status ) {\n\t\t\tself.each( function() {\n\t\t\t\tcallback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );\n\t\t\t} );\n\t\t} );\n\t}\n\n\treturn this;\n};\n\n\n\n\n// Attach a bunch of functions for handling common AJAX events\njQuery.each( [\n\t\"ajaxStart\",\n\t\"ajaxStop\",\n\t\"ajaxComplete\",\n\t\"ajaxError\",\n\t\"ajaxSuccess\",\n\t\"ajaxSend\"\n], function( i, type ) {\n\tjQuery.fn[ type ] = function( fn ) {\n\t\treturn this.on( type, fn );\n\t};\n} );\n\n\n\n\njQuery.expr.filters.animated = function( elem ) {\n\treturn jQuery.grep( jQuery.timers, function( fn ) {\n\t\treturn elem === fn.elem;\n\t} ).length;\n};\n\n\n\n\n/**\n * Gets a window from an element\n */\nfunction getWindow( elem ) {\n\treturn jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;\n}\n\njQuery.offset = {\n\tsetOffset: function( elem, options, i ) {\n\t\tvar curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,\n\t\t\tposition = jQuery.css( elem, \"position\" ),\n\t\t\tcurElem = jQuery( elem ),\n\t\t\tprops = {};\n\n\t\t// Set position first, in-case top/left are set even on static elem\n\t\tif ( position === \"static\" ) {\n\t\t\telem.style.position = \"relative\";\n\t\t}\n\n\t\tcurOffset = curElem.offset();\n\t\tcurCSSTop = jQuery.css( elem, \"top\" );\n\t\tcurCSSLeft = jQuery.css( elem, \"left\" );\n\t\tcalculatePosition = ( position === \"absolute\" || position === \"fixed\" ) &&\n\t\t\t( curCSSTop + curCSSLeft ).indexOf( \"auto\" ) > -1;\n\n\t\t// Need to be able to calculate position if either\n\t\t// top or left is auto and position is either absolute or fixed\n\t\tif ( calculatePosition ) {\n\t\t\tcurPosition = curElem.position();\n\t\t\tcurTop = curPosition.top;\n\t\t\tcurLeft = curPosition.left;\n\n\t\t} else {\n\t\t\tcurTop = parseFloat( curCSSTop ) || 0;\n\t\t\tcurLeft = parseFloat( curCSSLeft ) || 0;\n\t\t}\n\n\t\tif ( jQuery.isFunction( options ) ) {\n\n\t\t\t// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)\n\t\t\toptions = options.call( elem, i, jQuery.extend( {}, curOffset ) );\n\t\t}\n\n\t\tif ( options.top != null ) {\n\t\t\tprops.top = ( options.top - curOffset.top ) + curTop;\n\t\t}\n\t\tif ( options.left != null ) {\n\t\t\tprops.left = ( options.left - curOffset.left ) + curLeft;\n\t\t}\n\n\t\tif ( \"using\" in options ) {\n\t\t\toptions.using.call( elem, props );\n\n\t\t} else {\n\t\t\tcurElem.css( props );\n\t\t}\n\t}\n};\n\njQuery.fn.extend( {\n\toffset: function( options ) {\n\t\tif ( arguments.length ) {\n\t\t\treturn options === undefined ?\n\t\t\t\tthis :\n\t\t\t\tthis.each( function( i ) {\n\t\t\t\t\tjQuery.offset.setOffset( this, options, i );\n\t\t\t\t} );\n\t\t}\n\n\t\tvar docElem, win,\n\t\t\telem = this[ 0 ],\n\t\t\tbox = { top: 0, left: 0 },\n\t\t\tdoc = elem && elem.ownerDocument;\n\n\t\tif ( !doc ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocElem = doc.documentElement;\n\n\t\t// Make sure it's not a disconnected DOM node\n\t\tif ( !jQuery.contains( docElem, elem ) ) {\n\t\t\treturn box;\n\t\t}\n\n\t\tbox = elem.getBoundingClientRect();\n\t\twin = getWindow( doc );\n\t\treturn {\n\t\t\ttop: box.top + win.pageYOffset - docElem.clientTop,\n\t\t\tleft: box.left + win.pageXOffset - docElem.clientLeft\n\t\t};\n\t},\n\n\tposition: function() {\n\t\tif ( !this[ 0 ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar offsetParent, offset,\n\t\t\telem = this[ 0 ],\n\t\t\tparentOffset = { top: 0, left: 0 };\n\n\t\t// Fixed elements are offset from window (parentOffset = {top:0, left: 0},\n\t\t// because it is its only offset parent\n\t\tif ( jQuery.css( elem, \"position\" ) === \"fixed\" ) {\n\n\t\t\t// Assume getBoundingClientRect is there when computed position is fixed\n\t\t\toffset = elem.getBoundingClientRect();\n\n\t\t} else {\n\n\t\t\t// Get *real* offsetParent\n\t\t\toffsetParent = this.offsetParent();\n\n\t\t\t// Get correct offsets\n\t\t\toffset = this.offset();\n\t\t\tif ( !jQuery.nodeName( offsetParent[ 0 ], \"html\" ) ) {\n\t\t\t\tparentOffset = offsetParent.offset();\n\t\t\t}\n\n\t\t\t// Add offsetParent borders\n\t\t\tparentOffset.top += jQuery.css( offsetParent[ 0 ], \"borderTopWidth\", true );\n\t\t\tparentOffset.left += jQuery.css( offsetParent[ 0 ], \"borderLeftWidth\", true );\n\t\t}\n\n\t\t// Subtract parent offsets and element margins\n\t\treturn {\n\t\t\ttop: offset.top - parentOffset.top - jQuery.css( elem, \"marginTop\", true ),\n\t\t\tleft: offset.left - parentOffset.left - jQuery.css( elem, \"marginLeft\", true )\n\t\t};\n\t},\n\n\t// This method will return documentElement in the following cases:\n\t// 1) For the element inside the iframe without offsetParent, this method will return\n\t//    documentElement of the parent window\n\t// 2) For the hidden or detached element\n\t// 3) For body or html element, i.e. in case of the html node - it will return itself\n\t//\n\t// but those exceptions were never presented as a real life use-cases\n\t// and might be considered as more preferable results.\n\t//\n\t// This logic, however, is not guaranteed and can change at any point in the future\n\toffsetParent: function() {\n\t\treturn this.map( function() {\n\t\t\tvar offsetParent = this.offsetParent;\n\n\t\t\twhile ( offsetParent && jQuery.css( offsetParent, \"position\" ) === \"static\" ) {\n\t\t\t\toffsetParent = offsetParent.offsetParent;\n\t\t\t}\n\n\t\t\treturn offsetParent || documentElement;\n\t\t} );\n\t}\n} );\n\n// Create scrollLeft and scrollTop methods\njQuery.each( { scrollLeft: \"pageXOffset\", scrollTop: \"pageYOffset\" }, function( method, prop ) {\n\tvar top = \"pageYOffset\" === prop;\n\n\tjQuery.fn[ method ] = function( val ) {\n\t\treturn access( this, function( elem, method, val ) {\n\t\t\tvar win = getWindow( elem );\n\n\t\t\tif ( val === undefined ) {\n\t\t\t\treturn win ? win[ prop ] : elem[ method ];\n\t\t\t}\n\n\t\t\tif ( win ) {\n\t\t\t\twin.scrollTo(\n\t\t\t\t\t!top ? val : win.pageXOffset,\n\t\t\t\t\ttop ? val : win.pageYOffset\n\t\t\t\t);\n\n\t\t\t} else {\n\t\t\t\telem[ method ] = val;\n\t\t\t}\n\t\t}, method, val, arguments.length );\n\t};\n} );\n\n// Support: Safari<7-8+, Chrome<37-44+\n// Add the top/left cssHooks using jQuery.fn.position\n// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084\n// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280\n// getComputedStyle returns percent when specified for top/left/bottom/right;\n// rather than make the css module depend on the offset module, just check for it here\njQuery.each( [ \"top\", \"left\" ], function( i, prop ) {\n\tjQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,\n\t\tfunction( elem, computed ) {\n\t\t\tif ( computed ) {\n\t\t\t\tcomputed = curCSS( elem, prop );\n\n\t\t\t\t// If curCSS returns percentage, fallback to offset\n\t\t\t\treturn rnumnonpx.test( computed ) ?\n\t\t\t\t\tjQuery( elem ).position()[ prop ] + \"px\" :\n\t\t\t\t\tcomputed;\n\t\t\t}\n\t\t}\n\t);\n} );\n\n\n// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods\njQuery.each( { Height: \"height\", Width: \"width\" }, function( name, type ) {\n\tjQuery.each( { padding: \"inner\" + name, content: type, \"\": \"outer\" + name },\n\t\tfunction( defaultExtra, funcName ) {\n\n\t\t// Margin is only for outerHeight, outerWidth\n\t\tjQuery.fn[ funcName ] = function( margin, value ) {\n\t\t\tvar chainable = arguments.length && ( defaultExtra || typeof margin !== \"boolean\" ),\n\t\t\t\textra = defaultExtra || ( margin === true || value === true ? \"margin\" : \"border\" );\n\n\t\t\treturn access( this, function( elem, type, value ) {\n\t\t\t\tvar doc;\n\n\t\t\t\tif ( jQuery.isWindow( elem ) ) {\n\n\t\t\t\t\t// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there\n\t\t\t\t\t// isn't a whole lot we can do. See pull request at this URL for discussion:\n\t\t\t\t\t// https://github.com/jquery/jquery/pull/764\n\t\t\t\t\treturn elem.document.documentElement[ \"client\" + name ];\n\t\t\t\t}\n\n\t\t\t\t// Get document width or height\n\t\t\t\tif ( elem.nodeType === 9 ) {\n\t\t\t\t\tdoc = elem.documentElement;\n\n\t\t\t\t\t// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],\n\t\t\t\t\t// whichever is greatest\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\telem.body[ \"scroll\" + name ], doc[ \"scroll\" + name ],\n\t\t\t\t\t\telem.body[ \"offset\" + name ], doc[ \"offset\" + name ],\n\t\t\t\t\t\tdoc[ \"client\" + name ]\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn value === undefined ?\n\n\t\t\t\t\t// Get width or height on the element, requesting but not forcing parseFloat\n\t\t\t\t\tjQuery.css( elem, type, extra ) :\n\n\t\t\t\t\t// Set width or height on the element\n\t\t\t\t\tjQuery.style( elem, type, value, extra );\n\t\t\t}, type, chainable ? margin : undefined, chainable, null );\n\t\t};\n\t} );\n} );\n\n\njQuery.fn.extend( {\n\n\tbind: function( types, data, fn ) {\n\t\treturn this.on( types, null, data, fn );\n\t},\n\tunbind: function( types, fn ) {\n\t\treturn this.off( types, null, fn );\n\t},\n\n\tdelegate: function( selector, types, data, fn ) {\n\t\treturn this.on( types, selector, data, fn );\n\t},\n\tundelegate: function( selector, types, fn ) {\n\n\t\t// ( namespace ) or ( selector, types [, fn] )\n\t\treturn arguments.length === 1 ?\n\t\t\tthis.off( selector, \"**\" ) :\n\t\t\tthis.off( types, selector || \"**\", fn );\n\t},\n\tsize: function() {\n\t\treturn this.length;\n\t}\n} );\n\njQuery.fn.andSelf = jQuery.fn.addBack;\n\n\n\n\n// Register as a named AMD module, since jQuery can be concatenated with other\n// files that may use define, but not via a proper concatenation script that\n// understands anonymous AMD modules. A named AMD is safest and most robust\n// way to register. Lowercase jquery is used because AMD module names are\n// derived from file names, and jQuery is normally delivered in a lowercase\n// file name. Do this after creating the global so that if an AMD module wants\n// to call noConflict to hide this version of jQuery, it will work.\n\n// Note that for maximum portability, libraries that are not jQuery should\n// declare themselves as anonymous modules, and avoid setting a global if an\n// AMD loader is present. jQuery is a special case. For more information, see\n// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon\n\nif ( typeof define === \"function\" && define.amd ) {\n\tdefine( \"jquery\", [], function() {\n\t\treturn jQuery;\n\t} );\n}\n\n\n\nvar\n\n\t// Map over jQuery in case of overwrite\n\t_jQuery = window.jQuery,\n\n\t// Map over the $ in case of overwrite\n\t_$ = window.$;\n\njQuery.noConflict = function( deep ) {\n\tif ( window.$ === jQuery ) {\n\t\twindow.$ = _$;\n\t}\n\n\tif ( deep && window.jQuery === jQuery ) {\n\t\twindow.jQuery = _jQuery;\n\t}\n\n\treturn jQuery;\n};\n\n// Expose jQuery and $ identifiers, even in AMD\n// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)\n// and CommonJS for browser emulators (#13566)\nif ( !noGlobal ) {\n\twindow.jQuery = window.$ = jQuery;\n}\n\nreturn jQuery;\n}));\n"
  },
  {
    "path": "html/lib/jquery/jquery.slim.js",
    "content": "/*!\n * jQuery JavaScript Library v3.0.0-beta1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseJSON,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated\n * https://jquery.com/\n *\n * Includes Sizzle.js\n * https://sizzlejs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2016-01-14T23:07Z\n */\n\n(function( global, factory ) {\n\n\tif ( typeof module === \"object\" && typeof module.exports === \"object\" ) {\n\t\t// For CommonJS and CommonJS-like environments where a proper `window`\n\t\t// is present, execute the factory and get jQuery.\n\t\t// For environments that do not have a `window` with a `document`\n\t\t// (such as Node.js), expose a factory as module.exports.\n\t\t// This accentuates the need for the creation of a real `window`.\n\t\t// e.g. var jQuery = require(\"jquery\")(window);\n\t\t// See ticket #14549 for more info.\n\t\tmodule.exports = global.document ?\n\t\t\tfactory( global, true ) :\n\t\t\tfunction( w ) {\n\t\t\t\tif ( !w.document ) {\n\t\t\t\t\tthrow new Error( \"jQuery requires a window with a document\" );\n\t\t\t\t}\n\t\t\t\treturn factory( w );\n\t\t\t};\n\t} else {\n\t\tfactory( global );\n\t}\n\n// Pass this if window is not defined yet\n}(typeof window !== \"undefined\" ? window : this, function( window, noGlobal ) {\n\n// Support: Firefox 18+\n// Can't be in strict mode, several libs including ASP.NET trace\n// the stack via arguments.caller.callee and Firefox dies if\n// you try to trace through \"use strict\" call chains. (#13335)\n//\"use strict\";\nvar arr = [];\n\nvar document = window.document;\n\nvar slice = arr.slice;\n\nvar concat = arr.concat;\n\nvar push = arr.push;\n\nvar indexOf = arr.indexOf;\n\nvar class2type = {};\n\nvar toString = class2type.toString;\n\nvar hasOwn = class2type.hasOwnProperty;\n\nvar support = {};\n\n\n\tfunction DOMEval( code, doc ) {\n\t\tdoc = doc || document;\n\n\t\tvar script = doc.createElement( \"script\" );\n\n\t\tscript.text = code;\n\t\tdoc.head.appendChild( script ).parentNode.removeChild( script );\n\t}\n\n\nvar\n\tversion = \"3.0.0-beta1 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseJSON,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated\",\n\n\t// Define a local copy of jQuery\n\tjQuery = function( selector, context ) {\n\n\t\t// The jQuery object is actually just the init constructor 'enhanced'\n\t\t// Need init if jQuery is called (just allow error to be thrown if not included)\n\t\treturn new jQuery.fn.init( selector, context );\n\t},\n\n\t// Support: Android<4.1\n\t// Make sure we trim BOM and NBSP\n\trtrim = /^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g,\n\n\t// Matches dashed string for camelizing\n\trmsPrefix = /^-ms-/,\n\trdashAlpha = /-([a-z])/g,\n\n\t// Used by jQuery.camelCase as callback to replace()\n\tfcamelCase = function( all, letter ) {\n\t\treturn letter.toUpperCase();\n\t};\n\njQuery.fn = jQuery.prototype = {\n\n\t// The current version of jQuery being used\n\tjquery: version,\n\n\tconstructor: jQuery,\n\n\t// The default length of a jQuery object is 0\n\tlength: 0,\n\n\ttoArray: function() {\n\t\treturn slice.call( this );\n\t},\n\n\t// Get the Nth element in the matched element set OR\n\t// Get the whole matched element set as a clean array\n\tget: function( num ) {\n\t\treturn num != null ?\n\n\t\t\t// Return just the one element from the set\n\t\t\t( num < 0 ? this[ num + this.length ] : this[ num ] ) :\n\n\t\t\t// Return all the elements in a clean array\n\t\t\tslice.call( this );\n\t},\n\n\t// Take an array of elements and push it onto the stack\n\t// (returning the new matched element set)\n\tpushStack: function( elems ) {\n\n\t\t// Build a new jQuery matched element set\n\t\tvar ret = jQuery.merge( this.constructor(), elems );\n\n\t\t// Add the old object onto the stack (as a reference)\n\t\tret.prevObject = this;\n\n\t\t// Return the newly-formed element set\n\t\treturn ret;\n\t},\n\n\t// Execute a callback for every element in the matched set.\n\teach: function( callback ) {\n\t\treturn jQuery.each( this, callback );\n\t},\n\n\tmap: function( callback ) {\n\t\treturn this.pushStack( jQuery.map( this, function( elem, i ) {\n\t\t\treturn callback.call( elem, i, elem );\n\t\t} ) );\n\t},\n\n\tslice: function() {\n\t\treturn this.pushStack( slice.apply( this, arguments ) );\n\t},\n\n\tfirst: function() {\n\t\treturn this.eq( 0 );\n\t},\n\n\tlast: function() {\n\t\treturn this.eq( -1 );\n\t},\n\n\teq: function( i ) {\n\t\tvar len = this.length,\n\t\t\tj = +i + ( i < 0 ? len : 0 );\n\t\treturn this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );\n\t},\n\n\tend: function() {\n\t\treturn this.prevObject || this.constructor();\n\t},\n\n\t// For internal use only.\n\t// Behaves like an Array's method, not like a jQuery method.\n\tpush: push,\n\tsort: arr.sort,\n\tsplice: arr.splice\n};\n\njQuery.extend = jQuery.fn.extend = function() {\n\tvar options, name, src, copy, copyIsArray, clone,\n\t\ttarget = arguments[ 0 ] || {},\n\t\ti = 1,\n\t\tlength = arguments.length,\n\t\tdeep = false;\n\n\t// Handle a deep copy situation\n\tif ( typeof target === \"boolean\" ) {\n\t\tdeep = target;\n\n\t\t// Skip the boolean and the target\n\t\ttarget = arguments[ i ] || {};\n\t\ti++;\n\t}\n\n\t// Handle case when target is a string or something (possible in deep copy)\n\tif ( typeof target !== \"object\" && !jQuery.isFunction( target ) ) {\n\t\ttarget = {};\n\t}\n\n\t// Extend jQuery itself if only one argument is passed\n\tif ( i === length ) {\n\t\ttarget = this;\n\t\ti--;\n\t}\n\n\tfor ( ; i < length; i++ ) {\n\n\t\t// Only deal with non-null/undefined values\n\t\tif ( ( options = arguments[ i ] ) != null ) {\n\n\t\t\t// Extend the base object\n\t\t\tfor ( name in options ) {\n\t\t\t\tsrc = target[ name ];\n\t\t\t\tcopy = options[ name ];\n\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif ( target === copy ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\tif ( deep && copy && ( jQuery.isPlainObject( copy ) ||\n\t\t\t\t\t( copyIsArray = jQuery.isArray( copy ) ) ) ) {\n\n\t\t\t\t\tif ( copyIsArray ) {\n\t\t\t\t\t\tcopyIsArray = false;\n\t\t\t\t\t\tclone = src && jQuery.isArray( src ) ? src : [];\n\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclone = src && jQuery.isPlainObject( src ) ? src : {};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\ttarget[ name ] = jQuery.extend( deep, clone, copy );\n\n\t\t\t\t// Don't bring in undefined values\n\t\t\t\t} else if ( copy !== undefined ) {\n\t\t\t\t\ttarget[ name ] = copy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n\njQuery.extend( {\n\n\t// Unique for each copy of jQuery on the page\n\texpando: \"jQuery\" + ( version + Math.random() ).replace( /\\D/g, \"\" ),\n\n\t// Assume jQuery is ready without the ready module\n\tisReady: true,\n\n\terror: function( msg ) {\n\t\tthrow new Error( msg );\n\t},\n\n\tnoop: function() {},\n\n\tisFunction: function( obj ) {\n\t\treturn jQuery.type( obj ) === \"function\";\n\t},\n\n\tisArray: Array.isArray,\n\n\tisWindow: function( obj ) {\n\t\treturn obj != null && obj === obj.window;\n\t},\n\n\tisNumeric: function( obj ) {\n\n\t\t// As of jQuery 3.0, isNumeric is limited to\n\t\t// strings and numbers (primitives or objects)\n\t\t// that can be coerced to finite numbers (gh-2662)\n\t\tvar type = jQuery.type( obj );\n\t\treturn ( type === \"number\" || type === \"string\" ) &&\n\t\t\t( obj - parseFloat( obj ) + 1 ) >= 0;\n\t},\n\n\tisPlainObject: function( obj ) {\n\n\t\t// Not plain objects:\n\t\t// - Any object or value whose internal [[Class]] property is not \"[object Object]\"\n\t\t// - DOM nodes\n\t\t// - window\n\t\tif ( jQuery.type( obj ) !== \"object\" || obj.nodeType || jQuery.isWindow( obj ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( obj.constructor &&\n\t\t\t\t!hasOwn.call( obj.constructor.prototype, \"isPrototypeOf\" ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If the function hasn't returned already, we're confident that\n\t\t// |obj| is a plain object, created by {} or constructed with new Object\n\t\treturn true;\n\t},\n\n\tisEmptyObject: function( obj ) {\n\t\tvar name;\n\t\tfor ( name in obj ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t},\n\n\ttype: function( obj ) {\n\t\tif ( obj == null ) {\n\t\t\treturn obj + \"\";\n\t\t}\n\n\t\t// Support: Android<4.0 (functionish RegExp)\n\t\treturn typeof obj === \"object\" || typeof obj === \"function\" ?\n\t\t\tclass2type[ toString.call( obj ) ] || \"object\" :\n\t\t\ttypeof obj;\n\t},\n\n\t// Evaluates a script in a global context\n\tglobalEval: function( code ) {\n\t\tDOMEval( code );\n\t},\n\n\t// Convert dashed to camelCase; used by the css and data modules\n\t// Support: IE9-11+\n\t// Microsoft forgot to hump their vendor prefix (#9572)\n\tcamelCase: function( string ) {\n\t\treturn string.replace( rmsPrefix, \"ms-\" ).replace( rdashAlpha, fcamelCase );\n\t},\n\n\tnodeName: function( elem, name ) {\n\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();\n\t},\n\n\teach: function( obj, callback ) {\n\t\tvar length, i = 0;\n\n\t\tif ( isArrayLike( obj ) ) {\n\t\t\tlength = obj.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i in obj ) {\n\t\t\t\tif ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn obj;\n\t},\n\n\t// Support: Android<4.1\n\ttrim: function( text ) {\n\t\treturn text == null ?\n\t\t\t\"\" :\n\t\t\t( text + \"\" ).replace( rtrim, \"\" );\n\t},\n\n\t// results is for internal usage only\n\tmakeArray: function( arr, results ) {\n\t\tvar ret = results || [];\n\n\t\tif ( arr != null ) {\n\t\t\tif ( isArrayLike( Object( arr ) ) ) {\n\t\t\t\tjQuery.merge( ret,\n\t\t\t\t\ttypeof arr === \"string\" ?\n\t\t\t\t\t[ arr ] : arr\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tpush.call( ret, arr );\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t},\n\n\tinArray: function( elem, arr, i ) {\n\t\treturn arr == null ? -1 : indexOf.call( arr, elem, i );\n\t},\n\n\t// Support: Android<4.1, PhantomJS<2\n\t// push.apply(_, arraylike) throws on ancient WebKit\n\tmerge: function( first, second ) {\n\t\tvar len = +second.length,\n\t\t\tj = 0,\n\t\t\ti = first.length;\n\n\t\tfor ( ; j < len; j++ ) {\n\t\t\tfirst[ i++ ] = second[ j ];\n\t\t}\n\n\t\tfirst.length = i;\n\n\t\treturn first;\n\t},\n\n\tgrep: function( elems, callback, invert ) {\n\t\tvar callbackInverse,\n\t\t\tmatches = [],\n\t\t\ti = 0,\n\t\t\tlength = elems.length,\n\t\t\tcallbackExpect = !invert;\n\n\t\t// Go through the array, only saving the items\n\t\t// that pass the validator function\n\t\tfor ( ; i < length; i++ ) {\n\t\t\tcallbackInverse = !callback( elems[ i ], i );\n\t\t\tif ( callbackInverse !== callbackExpect ) {\n\t\t\t\tmatches.push( elems[ i ] );\n\t\t\t}\n\t\t}\n\n\t\treturn matches;\n\t},\n\n\t// arg is for internal usage only\n\tmap: function( elems, callback, arg ) {\n\t\tvar length, value,\n\t\t\ti = 0,\n\t\t\tret = [];\n\n\t\t// Go through the array, translating each of the items to their new values\n\t\tif ( isArrayLike( elems ) ) {\n\t\t\tlength = elems.length;\n\t\t\tfor ( ; i < length; i++ ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Go through every key on the object,\n\t\t} else {\n\t\t\tfor ( i in elems ) {\n\t\t\t\tvalue = callback( elems[ i ], i, arg );\n\n\t\t\t\tif ( value != null ) {\n\t\t\t\t\tret.push( value );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Flatten any nested arrays\n\t\treturn concat.apply( [], ret );\n\t},\n\n\t// A global GUID counter for objects\n\tguid: 1,\n\n\t// Bind a function to a context, optionally partially applying any\n\t// arguments.\n\tproxy: function( fn, context ) {\n\t\tvar tmp, args, proxy;\n\n\t\tif ( typeof context === \"string\" ) {\n\t\t\ttmp = fn[ context ];\n\t\t\tcontext = fn;\n\t\t\tfn = tmp;\n\t\t}\n\n\t\t// Quick check to determine if target is callable, in the spec\n\t\t// this throws a TypeError, but we will just return undefined.\n\t\tif ( !jQuery.isFunction( fn ) ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Simulated bind\n\t\targs = slice.call( arguments, 2 );\n\t\tproxy = function() {\n\t\t\treturn fn.apply( context || this, args.concat( slice.call( arguments ) ) );\n\t\t};\n\n\t\t// Set the guid of unique handler to the same of original handler, so it can be removed\n\t\tproxy.guid = fn.guid = fn.guid || jQuery.guid++;\n\n\t\treturn proxy;\n\t},\n\n\tnow: Date.now,\n\n\t// jQuery.support is not used in Core but other projects attach their\n\t// properties to it so it needs to exist.\n\tsupport: support\n} );\n\n// JSHint would error on this code due to the Symbol not being defined in ES5.\n// Defining this global in .jshintrc would create a danger of using the global\n// unguarded in another place, it seems safer to just disable JSHint for these\n// three lines.\n/* jshint ignore: start */\nif ( typeof Symbol === \"function\" ) {\n\tjQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];\n}\n/* jshint ignore: end */\n\n// Populate the class2type map\njQuery.each( \"Boolean Number String Function Array Date RegExp Object Error Symbol\".split( \" \" ),\nfunction( i, name ) {\n\tclass2type[ \"[object \" + name + \"]\" ] = name.toLowerCase();\n} );\n\nfunction isArrayLike( obj ) {\n\n\t// Support: iOS 8.2 (not reproducible in simulator)\n\t// `in` check used to prevent JIT error (gh-2145)\n\t// hasOwn isn't used here due to false negatives\n\t// regarding Nodelist length in IE\n\tvar length = !!obj && \"length\" in obj && obj.length,\n\t\ttype = jQuery.type( obj );\n\n\tif ( type === \"function\" || jQuery.isWindow( obj ) ) {\n\t\treturn false;\n\t}\n\n\treturn type === \"array\" || length === 0 ||\n\t\ttypeof length === \"number\" && length > 0 && ( length - 1 ) in obj;\n}\nvar Sizzle =\n/*!\n * Sizzle CSS Selector Engine v2.3.0\n * https://sizzlejs.com/\n *\n * Copyright jQuery Foundation and other contributors\n * Released under the MIT license\n * http://jquery.org/license\n *\n * Date: 2016-01-04\n */\n(function( window ) {\n\nvar i,\n\tsupport,\n\tExpr,\n\tgetText,\n\tisXML,\n\ttokenize,\n\tcompile,\n\tselect,\n\toutermostContext,\n\tsortInput,\n\thasDuplicate,\n\n\t// Local document vars\n\tsetDocument,\n\tdocument,\n\tdocElem,\n\tdocumentIsHTML,\n\trbuggyQSA,\n\trbuggyMatches,\n\tmatches,\n\tcontains,\n\n\t// Instance-specific data\n\texpando = \"sizzle\" + 1 * new Date(),\n\tpreferredDoc = window.document,\n\tdirruns = 0,\n\tdone = 0,\n\tclassCache = createCache(),\n\ttokenCache = createCache(),\n\tcompilerCache = createCache(),\n\tsortOrder = function( a, b ) {\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t}\n\t\treturn 0;\n\t},\n\n\t// Instance methods\n\thasOwn = ({}).hasOwnProperty,\n\tarr = [],\n\tpop = arr.pop,\n\tpush_native = arr.push,\n\tpush = arr.push,\n\tslice = arr.slice,\n\t// Use a stripped-down indexOf as it's faster than native\n\t// https://jsperf.com/thor-indexof-vs-for/5\n\tindexOf = function( list, elem ) {\n\t\tvar i = 0,\n\t\t\tlen = list.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( list[i] === elem ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t},\n\n\tbooleans = \"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped\",\n\n\t// Regular expressions\n\n\t// http://www.w3.org/TR/css3-selectors/#whitespace\n\twhitespace = \"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\",\n\n\t// http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier\n\tidentifier = \"(?:\\\\\\\\.|[\\\\w-]|[^\\0-\\\\xa0])+\",\n\n\t// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors\n\tattributes = \"\\\\[\" + whitespace + \"*(\" + identifier + \")(?:\" + whitespace +\n\t\t// Operator (capture 2)\n\t\t\"*([*^$|!~]?=)\" + whitespace +\n\t\t// \"Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]\"\n\t\t\"*(?:'((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\"|(\" + identifier + \"))|)\" + whitespace +\n\t\t\"*\\\\]\",\n\n\tpseudos = \":(\" + identifier + \")(?:\\\\((\" +\n\t\t// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:\n\t\t// 1. quoted (capture 3; capture 4 or capture 5)\n\t\t\"('((?:\\\\\\\\.|[^\\\\\\\\'])*)'|\\\"((?:\\\\\\\\.|[^\\\\\\\\\\\"])*)\\\")|\" +\n\t\t// 2. simple (capture 6)\n\t\t\"((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|\" + attributes + \")*)|\" +\n\t\t// 3. anything else (capture 2)\n\t\t\".*\" +\n\t\t\")\\\\)|)\",\n\n\t// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter\n\trwhitespace = new RegExp( whitespace + \"+\", \"g\" ),\n\trtrim = new RegExp( \"^\" + whitespace + \"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\" + whitespace + \"+$\", \"g\" ),\n\n\trcomma = new RegExp( \"^\" + whitespace + \"*,\" + whitespace + \"*\" ),\n\trcombinators = new RegExp( \"^\" + whitespace + \"*([>+~]|\" + whitespace + \")\" + whitespace + \"*\" ),\n\n\trattributeQuotes = new RegExp( \"=\" + whitespace + \"*([^\\\\]'\\\"]*?)\" + whitespace + \"*\\\\]\", \"g\" ),\n\n\trpseudo = new RegExp( pseudos ),\n\tridentifier = new RegExp( \"^\" + identifier + \"$\" ),\n\n\tmatchExpr = {\n\t\t\"ID\": new RegExp( \"^#(\" + identifier + \")\" ),\n\t\t\"CLASS\": new RegExp( \"^\\\\.(\" + identifier + \")\" ),\n\t\t\"TAG\": new RegExp( \"^(\" + identifier + \"|[*])\" ),\n\t\t\"ATTR\": new RegExp( \"^\" + attributes ),\n\t\t\"PSEUDO\": new RegExp( \"^\" + pseudos ),\n\t\t\"CHILD\": new RegExp( \"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\" + whitespace +\n\t\t\t\"*(even|odd|(([+-]|)(\\\\d*)n|)\" + whitespace + \"*(?:([+-]|)\" + whitespace +\n\t\t\t\"*(\\\\d+)|))\" + whitespace + \"*\\\\)|)\", \"i\" ),\n\t\t\"bool\": new RegExp( \"^(?:\" + booleans + \")$\", \"i\" ),\n\t\t// For use in libraries implementing .is()\n\t\t// We use this for POS matching in `select`\n\t\t\"needsContext\": new RegExp( \"^\" + whitespace + \"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\" +\n\t\t\twhitespace + \"*((?:-\\\\d)?\\\\d*)\" + whitespace + \"*\\\\)|)(?=[^-]|$)\", \"i\" )\n\t},\n\n\trinputs = /^(?:input|select|textarea|button)$/i,\n\trheader = /^h\\d$/i,\n\n\trnative = /^[^{]+\\{\\s*\\[native \\w/,\n\n\t// Easily-parseable/retrievable ID or TAG or CLASS selectors\n\trquickExpr = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,\n\n\trsibling = /[+~]/,\n\n\t// CSS escapes\n\t// http://www.w3.org/TR/CSS21/syndata.html#escaped-characters\n\trunescape = new RegExp( \"\\\\\\\\([\\\\da-f]{1,6}\" + whitespace + \"?|(\" + whitespace + \")|.)\", \"ig\" ),\n\tfunescape = function( _, escaped, escapedWhitespace ) {\n\t\tvar high = \"0x\" + escaped - 0x10000;\n\t\t// NaN means non-codepoint\n\t\t// Support: Firefox<24\n\t\t// Workaround erroneous numeric interpretation of +\"0x\"\n\t\treturn high !== high || escapedWhitespace ?\n\t\t\tescaped :\n\t\t\thigh < 0 ?\n\t\t\t\t// BMP codepoint\n\t\t\t\tString.fromCharCode( high + 0x10000 ) :\n\t\t\t\t// Supplemental Plane codepoint (surrogate pair)\n\t\t\t\tString.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );\n\t},\n\n\t// CSS string/identifier serialization\n\t// https://drafts.csswg.org/cssom/#common-serializing-idioms\n\trcssescape = /([\\0-\\x1f\\x7f]|^-?\\d)|^-$|[^\\x80-\\uFFFF\\w-]/g,\n\tfcssescape = function( ch, asCodePoint ) {\n\t\tif ( asCodePoint ) {\n\n\t\t\t// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER\n\t\t\tif ( ch === \"\\0\" ) {\n\t\t\t\treturn \"\\uFFFD\";\n\t\t\t}\n\n\t\t\t// Control characters and (dependent upon position) numbers get escaped as code points\n\t\t\treturn ch.slice( 0, -1 ) + \"\\\\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + \" \";\n\t\t}\n\n\t\t// Other potentially-special ASCII characters get backslash-escaped\n\t\treturn \"\\\\\" + ch;\n\t},\n\n\t// Used for iframes\n\t// See setDocument()\n\t// Removing the function wrapper causes a \"Permission Denied\"\n\t// error in IE\n\tunloadHandler = function() {\n\t\tsetDocument();\n\t},\n\n\tdisabledAncestor = addCombinator(\n\t\tfunction( elem ) {\n\t\t\treturn elem.disabled === true;\n\t\t},\n\t\t{ dir: \"parentNode\", next: \"legend\" }\n\t);\n\n// Optimize for push.apply( _, NodeList )\ntry {\n\tpush.apply(\n\t\t(arr = slice.call( preferredDoc.childNodes )),\n\t\tpreferredDoc.childNodes\n\t);\n\t// Support: Android<4.0\n\t// Detect silently failing push.apply\n\tarr[ preferredDoc.childNodes.length ].nodeType;\n} catch ( e ) {\n\tpush = { apply: arr.length ?\n\n\t\t// Leverage slice if possible\n\t\tfunction( target, els ) {\n\t\t\tpush_native.apply( target, slice.call(els) );\n\t\t} :\n\n\t\t// Support: IE<9\n\t\t// Otherwise append directly\n\t\tfunction( target, els ) {\n\t\t\tvar j = target.length,\n\t\t\t\ti = 0;\n\t\t\t// Can't trust NodeList.length\n\t\t\twhile ( (target[j++] = els[i++]) ) {}\n\t\t\ttarget.length = j - 1;\n\t\t}\n\t};\n}\n\nfunction Sizzle( selector, context, results, seed ) {\n\tvar m, i, elem, nid, match, groups, newSelector,\n\t\tnewContext = context && context.ownerDocument,\n\n\t\t// nodeType defaults to 9, since context defaults to document\n\t\tnodeType = context ? context.nodeType : 9;\n\n\tresults = results || [];\n\n\t// Return early from calls with invalid selector or context\n\tif ( typeof selector !== \"string\" || !selector ||\n\t\tnodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {\n\n\t\treturn results;\n\t}\n\n\t// Try to shortcut find operations (as opposed to filters) in HTML documents\n\tif ( !seed ) {\n\n\t\tif ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {\n\t\t\tsetDocument( context );\n\t\t}\n\t\tcontext = context || document;\n\n\t\tif ( documentIsHTML ) {\n\n\t\t\t// If the selector is sufficiently simple, try using a \"get*By*\" DOM method\n\t\t\t// (excepting DocumentFragment context, where the methods don't exist)\n\t\t\tif ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {\n\n\t\t\t\t// ID selector\n\t\t\t\tif ( (m = match[1]) ) {\n\n\t\t\t\t\t// Document context\n\t\t\t\t\tif ( nodeType === 9 ) {\n\t\t\t\t\t\tif ( (elem = context.getElementById( m )) ) {\n\n\t\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\t\tif ( elem.id === m ) {\n\t\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t// Element context\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// Support: IE, Opera, Webkit\n\t\t\t\t\t\t// TODO: identify versions\n\t\t\t\t\t\t// getElementById can match elements by name instead of ID\n\t\t\t\t\t\tif ( newContext && (elem = newContext.getElementById( m )) &&\n\t\t\t\t\t\t\tcontains( context, elem ) &&\n\t\t\t\t\t\t\telem.id === m ) {\n\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t// Type selector\n\t\t\t\t} else if ( match[2] ) {\n\t\t\t\t\tpush.apply( results, context.getElementsByTagName( selector ) );\n\t\t\t\t\treturn results;\n\n\t\t\t\t// Class selector\n\t\t\t\t} else if ( (m = match[3]) && support.getElementsByClassName &&\n\t\t\t\t\tcontext.getElementsByClassName ) {\n\n\t\t\t\t\tpush.apply( results, context.getElementsByClassName( m ) );\n\t\t\t\t\treturn results;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Take advantage of querySelectorAll\n\t\t\tif ( support.qsa &&\n\t\t\t\t!compilerCache[ selector + \" \" ] &&\n\t\t\t\t(!rbuggyQSA || !rbuggyQSA.test( selector )) ) {\n\n\t\t\t\tif ( nodeType !== 1 ) {\n\t\t\t\t\tnewContext = context;\n\t\t\t\t\tnewSelector = selector;\n\n\t\t\t\t// qSA looks outside Element context, which is not what we want\n\t\t\t\t// Thanks to Andrew Dupont for this workaround technique\n\t\t\t\t// Support: IE <=8\n\t\t\t\t// Exclude object elements\n\t\t\t\t} else if ( context.nodeName.toLowerCase() !== \"object\" ) {\n\n\t\t\t\t\t// Capture the context ID, setting it first if necessary\n\t\t\t\t\tif ( (nid = context.getAttribute( \"id\" )) ) {\n\t\t\t\t\t\tnid = nid.replace( rcssescape, fcssescape );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontext.setAttribute( \"id\", (nid = expando) );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prefix every selector in the list\n\t\t\t\t\tgroups = tokenize( selector );\n\t\t\t\t\ti = groups.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tgroups[i] = \"#\" + nid + \" \" + toSelector( groups[i] );\n\t\t\t\t\t}\n\t\t\t\t\tnewSelector = groups.join( \",\" );\n\n\t\t\t\t\t// Expand context for sibling selectors\n\t\t\t\t\tnewContext = rsibling.test( selector ) && testContext( context.parentNode ) ||\n\t\t\t\t\t\tcontext;\n\t\t\t\t}\n\n\t\t\t\tif ( newSelector ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpush.apply( results,\n\t\t\t\t\t\t\tnewContext.querySelectorAll( newSelector )\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t} catch ( qsaError ) {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif ( nid === expando ) {\n\t\t\t\t\t\t\tcontext.removeAttribute( \"id\" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// All others\n\treturn select( selector.replace( rtrim, \"$1\" ), context, results, seed );\n}\n\n/**\n * Create key-value caches of limited size\n * @returns {function(string, object)} Returns the Object data after storing it on itself with\n *\tproperty name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)\n *\tdeleting the oldest entry\n */\nfunction createCache() {\n\tvar keys = [];\n\n\tfunction cache( key, value ) {\n\t\t// Use (key + \" \") to avoid collision with native prototype properties (see Issue #157)\n\t\tif ( keys.push( key + \" \" ) > Expr.cacheLength ) {\n\t\t\t// Only keep the most recent entries\n\t\t\tdelete cache[ keys.shift() ];\n\t\t}\n\t\treturn (cache[ key + \" \" ] = value);\n\t}\n\treturn cache;\n}\n\n/**\n * Mark a function for special use by Sizzle\n * @param {Function} fn The function to mark\n */\nfunction markFunction( fn ) {\n\tfn[ expando ] = true;\n\treturn fn;\n}\n\n/**\n * Support testing using an element\n * @param {Function} fn Passed the created element and returns a boolean result\n */\nfunction assert( fn ) {\n\tvar el = document.createElement(\"fieldset\");\n\n\ttry {\n\t\treturn !!fn( el );\n\t} catch (e) {\n\t\treturn false;\n\t} finally {\n\t\t// Remove from its parent by default\n\t\tif ( el.parentNode ) {\n\t\t\tel.parentNode.removeChild( el );\n\t\t}\n\t\t// release memory in IE\n\t\tel = null;\n\t}\n}\n\n/**\n * Adds the same handler for all of the specified attrs\n * @param {String} attrs Pipe-separated list of attributes\n * @param {Function} handler The method that will be applied\n */\nfunction addHandle( attrs, handler ) {\n\tvar arr = attrs.split(\"|\"),\n\t\ti = arr.length;\n\n\twhile ( i-- ) {\n\t\tExpr.attrHandle[ arr[i] ] = handler;\n\t}\n}\n\n/**\n * Checks document order of two siblings\n * @param {Element} a\n * @param {Element} b\n * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b\n */\nfunction siblingCheck( a, b ) {\n\tvar cur = b && a,\n\t\tdiff = cur && a.nodeType === 1 && b.nodeType === 1 &&\n\t\t\ta.sourceIndex - b.sourceIndex;\n\n\t// Use IE sourceIndex if available on both nodes\n\tif ( diff ) {\n\t\treturn diff;\n\t}\n\n\t// Check if b follows a\n\tif ( cur ) {\n\t\twhile ( (cur = cur.nextSibling) ) {\n\t\t\tif ( cur === b ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a ? 1 : -1;\n}\n\n/**\n * Returns a function to use in pseudos for input types\n * @param {String} type\n */\nfunction createInputPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn name === \"input\" && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for buttons\n * @param {String} type\n */\nfunction createButtonPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn (name === \"input\" || name === \"button\") && elem.type === type;\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for :enabled/:disabled\n * @param {Boolean} disabled true for :disabled; false for :enabled\n */\nfunction createDisabledPseudo( disabled ) {\n\t// Known :disabled false positives:\n\t// IE: *[disabled]:not(button, input, select, textarea, optgroup, option, menuitem, fieldset)\n\t// not IE: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable\n\treturn function( elem ) {\n\n\t\t// Check form elements and option elements for explicit disabling\n\t\treturn \"label\" in elem && elem.disabled === disabled ||\n\t\t\t\"form\" in elem && elem.disabled === disabled ||\n\n\t\t\t// Check non-disabled form elements for fieldset[disabled] ancestors\n\t\t\t\"form\" in elem && elem.disabled === false && (\n\t\t\t\t// Support: IE6-11+\n\t\t\t\t// Ancestry is covered for us\n\t\t\t\telem.isDisabled === disabled ||\n\n\t\t\t\t// Otherwise, assume any non-<option> under fieldset[disabled] is disabled\n\t\t\t\t/* jshint -W018 */\n\t\t\t\telem.isDisabled !== !disabled &&\n\t\t\t\t\t(\"label\" in elem || !disabledAncestor( elem )) !== disabled\n\t\t\t);\n\t};\n}\n\n/**\n * Returns a function to use in pseudos for positionals\n * @param {Function} fn\n */\nfunction createPositionalPseudo( fn ) {\n\treturn markFunction(function( argument ) {\n\t\targument = +argument;\n\t\treturn markFunction(function( seed, matches ) {\n\t\t\tvar j,\n\t\t\t\tmatchIndexes = fn( [], seed.length, argument ),\n\t\t\t\ti = matchIndexes.length;\n\n\t\t\t// Match elements found at the specified indexes\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( seed[ (j = matchIndexes[i]) ] ) {\n\t\t\t\t\tseed[j] = !(matches[j] = seed[j]);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Checks a node for validity as a Sizzle context\n * @param {Element|Object=} context\n * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value\n */\nfunction testContext( context ) {\n\treturn context && typeof context.getElementsByTagName !== \"undefined\" && context;\n}\n\n// Expose support vars for convenience\nsupport = Sizzle.support = {};\n\n/**\n * Detects XML nodes\n * @param {Element|Object} elem An element or a document\n * @returns {Boolean} True iff elem is a non-HTML XML node\n */\nisXML = Sizzle.isXML = function( elem ) {\n\t// documentElement is verified for cases where it doesn't yet exist\n\t// (such as loading iframes in IE - #4833)\n\tvar documentElement = elem && (elem.ownerDocument || elem).documentElement;\n\treturn documentElement ? documentElement.nodeName !== \"HTML\" : false;\n};\n\n/**\n * Sets document-related variables once based on the current document\n * @param {Element|Object} [doc] An element or document object to use to set the document\n * @returns {Object} Returns the current document\n */\nsetDocument = Sizzle.setDocument = function( node ) {\n\tvar hasCompare, subWindow,\n\t\tdoc = node ? node.ownerDocument || node : preferredDoc;\n\n\t// Return early if doc is invalid or already selected\n\tif ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {\n\t\treturn document;\n\t}\n\n\t// Update global variables\n\tdocument = doc;\n\tdocElem = document.documentElement;\n\tdocumentIsHTML = !isXML( document );\n\n\t// Support: IE 9-11, Edge\n\t// Accessing iframe documents after unload throws \"permission denied\" errors (jQuery #13936)\n\tif ( preferredDoc !== document &&\n\t\t(subWindow = document.defaultView) && subWindow.top !== subWindow ) {\n\n\t\t// Support: IE 11, Edge\n\t\tif ( subWindow.addEventListener ) {\n\t\t\tsubWindow.addEventListener( \"unload\", unloadHandler, false );\n\n\t\t// Support: IE 9 - 10 only\n\t\t} else if ( subWindow.attachEvent ) {\n\t\t\tsubWindow.attachEvent( \"onunload\", unloadHandler );\n\t\t}\n\t}\n\n\t/* Attributes\n\t---------------------------------------------------------------------- */\n\n\t// Support: IE<8\n\t// Verify that getAttribute really returns attributes and not properties\n\t// (excepting IE8 booleans)\n\tsupport.attributes = assert(function( el ) {\n\t\tel.className = \"i\";\n\t\treturn !el.getAttribute(\"className\");\n\t});\n\n\t/* getElement(s)By*\n\t---------------------------------------------------------------------- */\n\n\t// Check if getElementsByTagName(\"*\") returns only elements\n\tsupport.getElementsByTagName = assert(function( el ) {\n\t\tel.appendChild( document.createComment(\"\") );\n\t\treturn !el.getElementsByTagName(\"*\").length;\n\t});\n\n\t// Support: IE<9\n\tsupport.getElementsByClassName = rnative.test( document.getElementsByClassName );\n\n\t// Support: IE<10\n\t// Check if getElementById returns elements by name\n\t// The broken getElementById methods don't pick up programmatically-set names,\n\t// so use a roundabout getElementsByName test\n\tsupport.getById = assert(function( el ) {\n\t\tdocElem.appendChild( el ).id = expando;\n\t\treturn !document.getElementsByName || !document.getElementsByName( expando ).length;\n\t});\n\n\t// ID find and filter\n\tif ( support.getById ) {\n\t\tExpr.find[\"ID\"] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== \"undefined\" && documentIsHTML ) {\n\t\t\t\tvar m = context.getElementById( id );\n\t\t\t\treturn m ? [ m ] : [];\n\t\t\t}\n\t\t};\n\t\tExpr.filter[\"ID\"] = function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn elem.getAttribute(\"id\") === attrId;\n\t\t\t};\n\t\t};\n\t} else {\n\t\t// Support: IE6/7\n\t\t// getElementById is not reliable as a find shortcut\n\t\tdelete Expr.find[\"ID\"];\n\n\t\tExpr.filter[\"ID\"] =  function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\tvar node = typeof elem.getAttributeNode !== \"undefined\" &&\n\t\t\t\t\telem.getAttributeNode(\"id\");\n\t\t\t\treturn node && node.value === attrId;\n\t\t\t};\n\t\t};\n\t}\n\n\t// Tag\n\tExpr.find[\"TAG\"] = support.getElementsByTagName ?\n\t\tfunction( tag, context ) {\n\t\t\tif ( typeof context.getElementsByTagName !== \"undefined\" ) {\n\t\t\t\treturn context.getElementsByTagName( tag );\n\n\t\t\t// DocumentFragment nodes don't have gEBTN\n\t\t\t} else if ( support.qsa ) {\n\t\t\t\treturn context.querySelectorAll( tag );\n\t\t\t}\n\t\t} :\n\n\t\tfunction( tag, context ) {\n\t\t\tvar elem,\n\t\t\t\ttmp = [],\n\t\t\t\ti = 0,\n\t\t\t\t// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too\n\t\t\t\tresults = context.getElementsByTagName( tag );\n\n\t\t\t// Filter out possible comments\n\t\t\tif ( tag === \"*\" ) {\n\t\t\t\twhile ( (elem = results[i++]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\ttmp.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t// Class\n\tExpr.find[\"CLASS\"] = support.getElementsByClassName && function( className, context ) {\n\t\tif ( typeof context.getElementsByClassName !== \"undefined\" && documentIsHTML ) {\n\t\t\treturn context.getElementsByClassName( className );\n\t\t}\n\t};\n\n\t/* QSA/matchesSelector\n\t---------------------------------------------------------------------- */\n\n\t// QSA and matchesSelector support\n\n\t// matchesSelector(:active) reports false when true (IE9/Opera 11.5)\n\trbuggyMatches = [];\n\n\t// qSa(:focus) reports false when true (Chrome 21)\n\t// We allow this because of a bug in IE8/9 that throws an error\n\t// whenever `document.activeElement` is accessed on an iframe\n\t// So, we allow :focus to pass through QSA all the time to avoid the IE error\n\t// See https://bugs.jquery.com/ticket/13378\n\trbuggyQSA = [];\n\n\tif ( (support.qsa = rnative.test( document.querySelectorAll )) ) {\n\t\t// Build QSA regex\n\t\t// Regex strategy adopted from Diego Perini\n\t\tassert(function( el ) {\n\t\t\t// Select is set to empty string on purpose\n\t\t\t// This is to test IE's treatment of not explicitly\n\t\t\t// setting a boolean content attribute,\n\t\t\t// since its presence should be enough\n\t\t\t// https://bugs.jquery.com/ticket/12359\n\t\t\tdocElem.appendChild( el ).innerHTML = \"<a id='\" + expando + \"'></a>\" +\n\t\t\t\t\"<select id='\" + expando + \"-\\r\\\\' msallowcapture=''>\" +\n\t\t\t\t\"<option selected=''></option></select>\";\n\n\t\t\t// Support: IE8, Opera 11-12.16\n\t\t\t// Nothing should be selected when empty strings follow ^= or $= or *=\n\t\t\t// The test attribute must be unknown in Opera but \"safe\" for WinRT\n\t\t\t// https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section\n\t\t\tif ( el.querySelectorAll(\"[msallowcapture^='']\").length ) {\n\t\t\t\trbuggyQSA.push( \"[*^$]=\" + whitespace + \"*(?:''|\\\"\\\")\" );\n\t\t\t}\n\n\t\t\t// Support: IE8\n\t\t\t// Boolean attributes and \"value\" are not treated correctly\n\t\t\tif ( !el.querySelectorAll(\"[selected]\").length ) {\n\t\t\t\trbuggyQSA.push( \"\\\\[\" + whitespace + \"*(?:value|\" + booleans + \")\" );\n\t\t\t}\n\n\t\t\t// Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+\n\t\t\tif ( !el.querySelectorAll( \"[id~=\" + expando + \"-]\" ).length ) {\n\t\t\t\trbuggyQSA.push(\"~=\");\n\t\t\t}\n\n\t\t\t// Webkit/Opera - :checked should return selected option elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !el.querySelectorAll(\":checked\").length ) {\n\t\t\t\trbuggyQSA.push(\":checked\");\n\t\t\t}\n\n\t\t\t// Support: Safari 8+, iOS 8+\n\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=136851\n\t\t\t// In-page `selector#id sibling-combinator selector` fails\n\t\t\tif ( !el.querySelectorAll( \"a#\" + expando + \"+*\" ).length ) {\n\t\t\t\trbuggyQSA.push(\".#.+[+~]\");\n\t\t\t}\n\t\t});\n\n\t\tassert(function( el ) {\n\t\t\tel.innerHTML = \"<a href='' disabled='disabled'></a>\" +\n\t\t\t\t\"<select disabled='disabled'><option/></select>\";\n\n\t\t\t// Support: Windows 8 Native Apps\n\t\t\t// The type and name attributes are restricted during .innerHTML assignment\n\t\t\tvar input = document.createElement(\"input\");\n\t\t\tinput.setAttribute( \"type\", \"hidden\" );\n\t\t\tel.appendChild( input ).setAttribute( \"name\", \"D\" );\n\n\t\t\t// Support: IE8\n\t\t\t// Enforce case-sensitivity of name attribute\n\t\t\tif ( el.querySelectorAll(\"[name=d]\").length ) {\n\t\t\t\trbuggyQSA.push( \"name\" + whitespace + \"*[*^$|!~]?=\" );\n\t\t\t}\n\n\t\t\t// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( el.querySelectorAll(\":enabled\").length !== 2 ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Support: IE9-11+\n\t\t\t// IE's :disabled selector does not pick up the children of disabled fieldsets\n\t\t\tdocElem.appendChild( el ).disabled = true;\n\t\t\tif ( el.querySelectorAll(\":disabled\").length !== 2 ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Opera 10-11 does not throw on post-comma invalid pseudos\n\t\t\tel.querySelectorAll(\"*,:x\");\n\t\t\trbuggyQSA.push(\",.*:\");\n\t\t});\n\t}\n\n\tif ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||\n\t\tdocElem.webkitMatchesSelector ||\n\t\tdocElem.mozMatchesSelector ||\n\t\tdocElem.oMatchesSelector ||\n\t\tdocElem.msMatchesSelector) )) ) {\n\n\t\tassert(function( el ) {\n\t\t\t// Check to see if it's possible to do matchesSelector\n\t\t\t// on a disconnected node (IE 9)\n\t\t\tsupport.disconnectedMatch = matches.call( el, \"*\" );\n\n\t\t\t// This should fail with an exception\n\t\t\t// Gecko does not error, returns false instead\n\t\t\tmatches.call( el, \"[s!='']:x\" );\n\t\t\trbuggyMatches.push( \"!=\", pseudos );\n\t\t});\n\t}\n\n\trbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join(\"|\") );\n\trbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join(\"|\") );\n\n\t/* Contains\n\t---------------------------------------------------------------------- */\n\thasCompare = rnative.test( docElem.compareDocumentPosition );\n\n\t// Element contains another\n\t// Purposefully self-exclusive\n\t// As in, an element does not contain itself\n\tcontains = hasCompare || rnative.test( docElem.contains ) ?\n\t\tfunction( a, b ) {\n\t\t\tvar adown = a.nodeType === 9 ? a.documentElement : a,\n\t\t\t\tbup = b && b.parentNode;\n\t\t\treturn a === bup || !!( bup && bup.nodeType === 1 && (\n\t\t\t\tadown.contains ?\n\t\t\t\t\tadown.contains( bup ) :\n\t\t\t\t\ta.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16\n\t\t\t));\n\t\t} :\n\t\tfunction( a, b ) {\n\t\t\tif ( b ) {\n\t\t\t\twhile ( (b = b.parentNode) ) {\n\t\t\t\t\tif ( b === a ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t/* Sorting\n\t---------------------------------------------------------------------- */\n\n\t// Document order sorting\n\tsortOrder = hasCompare ?\n\tfunction( a, b ) {\n\n\t\t// Flag for duplicate removal\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Sort on method existence if only one input has compareDocumentPosition\n\t\tvar compare = !a.compareDocumentPosition - !b.compareDocumentPosition;\n\t\tif ( compare ) {\n\t\t\treturn compare;\n\t\t}\n\n\t\t// Calculate position if both inputs belong to the same document\n\t\tcompare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?\n\t\t\ta.compareDocumentPosition( b ) :\n\n\t\t\t// Otherwise we know they are disconnected\n\t\t\t1;\n\n\t\t// Disconnected nodes\n\t\tif ( compare & 1 ||\n\t\t\t(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {\n\n\t\t\t// Choose the first element that is related to our preferred document\n\t\t\tif ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// Maintain original order\n\t\t\treturn sortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\t\t}\n\n\t\treturn compare & 4 ? -1 : 1;\n\t} :\n\tfunction( a, b ) {\n\t\t// Exit early if the nodes are identical\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\taup = a.parentNode,\n\t\t\tbup = b.parentNode,\n\t\t\tap = [ a ],\n\t\t\tbp = [ b ];\n\n\t\t// Parentless nodes are either documents or disconnected\n\t\tif ( !aup || !bup ) {\n\t\t\treturn a === document ? -1 :\n\t\t\t\tb === document ? 1 :\n\t\t\t\taup ? -1 :\n\t\t\t\tbup ? 1 :\n\t\t\t\tsortInput ?\n\t\t\t\t( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :\n\t\t\t\t0;\n\n\t\t// If the nodes are siblings, we can do a quick check\n\t\t} else if ( aup === bup ) {\n\t\t\treturn siblingCheck( a, b );\n\t\t}\n\n\t\t// Otherwise we need full lists of their ancestors for comparison\n\t\tcur = a;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tap.unshift( cur );\n\t\t}\n\t\tcur = b;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tbp.unshift( cur );\n\t\t}\n\n\t\t// Walk down the tree looking for a discrepancy\n\t\twhile ( ap[i] === bp[i] ) {\n\t\t\ti++;\n\t\t}\n\n\t\treturn i ?\n\t\t\t// Do a sibling check if the nodes have a common ancestor\n\t\t\tsiblingCheck( ap[i], bp[i] ) :\n\n\t\t\t// Otherwise nodes in our document sort first\n\t\t\tap[i] === preferredDoc ? -1 :\n\t\t\tbp[i] === preferredDoc ? 1 :\n\t\t\t0;\n\t};\n\n\treturn document;\n};\n\nSizzle.matches = function( expr, elements ) {\n\treturn Sizzle( expr, null, null, elements );\n};\n\nSizzle.matchesSelector = function( elem, expr ) {\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\t// Make sure that attribute selectors are quoted\n\texpr = expr.replace( rattributeQuotes, \"='$1']\" );\n\n\tif ( support.matchesSelector && documentIsHTML &&\n\t\t!compilerCache[ expr + \" \" ] &&\n\t\t( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&\n\t\t( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {\n\n\t\ttry {\n\t\t\tvar ret = matches.call( elem, expr );\n\n\t\t\t// IE 9's matchesSelector returns false on disconnected nodes\n\t\t\tif ( ret || support.disconnectedMatch ||\n\t\t\t\t\t// As well, disconnected nodes are said to be in a document\n\t\t\t\t\t// fragment in IE 9\n\t\t\t\t\telem.document && elem.document.nodeType !== 11 ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} catch (e) {}\n\t}\n\n\treturn Sizzle( expr, document, null, [ elem ] ).length > 0;\n};\n\nSizzle.contains = function( context, elem ) {\n\t// Set document vars if needed\n\tif ( ( context.ownerDocument || context ) !== document ) {\n\t\tsetDocument( context );\n\t}\n\treturn contains( context, elem );\n};\n\nSizzle.attr = function( elem, name ) {\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\tvar fn = Expr.attrHandle[ name.toLowerCase() ],\n\t\t// Don't get fooled by Object.prototype properties (jQuery #13807)\n\t\tval = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?\n\t\t\tfn( elem, name, !documentIsHTML ) :\n\t\t\tundefined;\n\n\treturn val !== undefined ?\n\t\tval :\n\t\tsupport.attributes || !documentIsHTML ?\n\t\t\telem.getAttribute( name ) :\n\t\t\t(val = elem.getAttributeNode(name)) && val.specified ?\n\t\t\t\tval.value :\n\t\t\t\tnull;\n};\n\nSizzle.escape = function( sel ) {\n\treturn (sel + \"\").replace( rcssescape, fcssescape );\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n/**\n * Document sorting and removing duplicates\n * @param {ArrayLike} results\n */\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {\n\t\twhile ( (elem = results[i++]) ) {\n\t\t\tif ( elem === results[ i ] ) {\n\t\t\t\tj = duplicates.push( i );\n\t\t\t}\n\t\t}\n\t\twhile ( j-- ) {\n\t\t\tresults.splice( duplicates[ j ], 1 );\n\t\t}\n\t}\n\n\t// Clear input after sorting to release objects\n\t// See https://github.com/jquery/sizzle/pull/225\n\tsortInput = null;\n\n\treturn results;\n};\n\n/**\n * Utility function for retrieving the text value of an array of DOM nodes\n * @param {Array|Element} elem\n */\ngetText = Sizzle.getText = function( elem ) {\n\tvar node,\n\t\tret = \"\",\n\t\ti = 0,\n\t\tnodeType = elem.nodeType;\n\n\tif ( !nodeType ) {\n\t\t// If no nodeType, this is expected to be an array\n\t\twhile ( (node = elem[i++]) ) {\n\t\t\t// Do not traverse comment nodes\n\t\t\tret += getText( node );\n\t\t}\n\t} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {\n\t\t// Use textContent for elements\n\t\t// innerText usage removed for consistency of new lines (jQuery #11153)\n\t\tif ( typeof elem.textContent === \"string\" ) {\n\t\t\treturn elem.textContent;\n\t\t} else {\n\t\t\t// Traverse its children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tret += getText( elem );\n\t\t\t}\n\t\t}\n\t} else if ( nodeType === 3 || nodeType === 4 ) {\n\t\treturn elem.nodeValue;\n\t}\n\t// Do not include comment or processing instruction nodes\n\n\treturn ret;\n};\n\nExpr = Sizzle.selectors = {\n\n\t// Can be adjusted by the user\n\tcacheLength: 50,\n\n\tcreatePseudo: markFunction,\n\n\tmatch: matchExpr,\n\n\tattrHandle: {},\n\n\tfind: {},\n\n\trelative: {\n\t\t\">\": { dir: \"parentNode\", first: true },\n\t\t\" \": { dir: \"parentNode\" },\n\t\t\"+\": { dir: \"previousSibling\", first: true },\n\t\t\"~\": { dir: \"previousSibling\" }\n\t},\n\n\tpreFilter: {\n\t\t\"ATTR\": function( match ) {\n\t\t\tmatch[1] = match[1].replace( runescape, funescape );\n\n\t\t\t// Move the given value to match[3] whether quoted or unquoted\n\t\t\tmatch[3] = ( match[3] || match[4] || match[5] || \"\" ).replace( runescape, funescape );\n\n\t\t\tif ( match[2] === \"~=\" ) {\n\t\t\t\tmatch[3] = \" \" + match[3] + \" \";\n\t\t\t}\n\n\t\t\treturn match.slice( 0, 4 );\n\t\t},\n\n\t\t\"CHILD\": function( match ) {\n\t\t\t/* matches from matchExpr[\"CHILD\"]\n\t\t\t\t1 type (only|nth|...)\n\t\t\t\t2 what (child|of-type)\n\t\t\t\t3 argument (even|odd|\\d*|\\d*n([+-]\\d+)?|...)\n\t\t\t\t4 xn-component of xn+y argument ([+-]?\\d*n|)\n\t\t\t\t5 sign of xn-component\n\t\t\t\t6 x of xn-component\n\t\t\t\t7 sign of y-component\n\t\t\t\t8 y of y-component\n\t\t\t*/\n\t\t\tmatch[1] = match[1].toLowerCase();\n\n\t\t\tif ( match[1].slice( 0, 3 ) === \"nth\" ) {\n\t\t\t\t// nth-* requires argument\n\t\t\t\tif ( !match[3] ) {\n\t\t\t\t\tSizzle.error( match[0] );\n\t\t\t\t}\n\n\t\t\t\t// numeric x and y parameters for Expr.filter.CHILD\n\t\t\t\t// remember that false/true cast respectively to 0/1\n\t\t\t\tmatch[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === \"even\" || match[3] === \"odd\" ) );\n\t\t\t\tmatch[5] = +( ( match[7] + match[8] ) || match[3] === \"odd\" );\n\n\t\t\t// other types prohibit arguments\n\t\t\t} else if ( match[3] ) {\n\t\t\t\tSizzle.error( match[0] );\n\t\t\t}\n\n\t\t\treturn match;\n\t\t},\n\n\t\t\"PSEUDO\": function( match ) {\n\t\t\tvar excess,\n\t\t\t\tunquoted = !match[6] && match[2];\n\n\t\t\tif ( matchExpr[\"CHILD\"].test( match[0] ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Accept quoted arguments as-is\n\t\t\tif ( match[3] ) {\n\t\t\t\tmatch[2] = match[4] || match[5] || \"\";\n\n\t\t\t// Strip excess characters from unquoted arguments\n\t\t\t} else if ( unquoted && rpseudo.test( unquoted ) &&\n\t\t\t\t// Get excess from tokenize (recursively)\n\t\t\t\t(excess = tokenize( unquoted, true )) &&\n\t\t\t\t// advance to the next closing parenthesis\n\t\t\t\t(excess = unquoted.indexOf( \")\", unquoted.length - excess ) - unquoted.length) ) {\n\n\t\t\t\t// excess is a negative index\n\t\t\t\tmatch[0] = match[0].slice( 0, excess );\n\t\t\t\tmatch[2] = unquoted.slice( 0, excess );\n\t\t\t}\n\n\t\t\t// Return only captures needed by the pseudo filter method (type and argument)\n\t\t\treturn match.slice( 0, 3 );\n\t\t}\n\t},\n\n\tfilter: {\n\n\t\t\"TAG\": function( nodeNameSelector ) {\n\t\t\tvar nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn nodeNameSelector === \"*\" ?\n\t\t\t\tfunction() { return true; } :\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\n\t\t\t\t};\n\t\t},\n\n\t\t\"CLASS\": function( className ) {\n\t\t\tvar pattern = classCache[ className + \" \" ];\n\n\t\t\treturn pattern ||\n\t\t\t\t(pattern = new RegExp( \"(^|\" + whitespace + \")\" + className + \"(\" + whitespace + \"|$)\" )) &&\n\t\t\t\tclassCache( className, function( elem ) {\n\t\t\t\t\treturn pattern.test( typeof elem.className === \"string\" && elem.className || typeof elem.getAttribute !== \"undefined\" && elem.getAttribute(\"class\") || \"\" );\n\t\t\t\t});\n\t\t},\n\n\t\t\"ATTR\": function( name, operator, check ) {\n\t\t\treturn function( elem ) {\n\t\t\t\tvar result = Sizzle.attr( elem, name );\n\n\t\t\t\tif ( result == null ) {\n\t\t\t\t\treturn operator === \"!=\";\n\t\t\t\t}\n\t\t\t\tif ( !operator ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tresult += \"\";\n\n\t\t\t\treturn operator === \"=\" ? result === check :\n\t\t\t\t\toperator === \"!=\" ? result !== check :\n\t\t\t\t\toperator === \"^=\" ? check && result.indexOf( check ) === 0 :\n\t\t\t\t\toperator === \"*=\" ? check && result.indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"$=\" ? check && result.slice( -check.length ) === check :\n\t\t\t\t\toperator === \"~=\" ? ( \" \" + result.replace( rwhitespace, \" \" ) + \" \" ).indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"|=\" ? result === check || result.slice( 0, check.length + 1 ) === check + \"-\" :\n\t\t\t\t\tfalse;\n\t\t\t};\n\t\t},\n\n\t\t\"CHILD\": function( type, what, argument, first, last ) {\n\t\t\tvar simple = type.slice( 0, 3 ) !== \"nth\",\n\t\t\t\tforward = type.slice( -4 ) !== \"last\",\n\t\t\t\tofType = what === \"of-type\";\n\n\t\t\treturn first === 1 && last === 0 ?\n\n\t\t\t\t// Shortcut for :nth-*(n)\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn !!elem.parentNode;\n\t\t\t\t} :\n\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tvar cache, uniqueCache, outerCache, node, nodeIndex, start,\n\t\t\t\t\t\tdir = simple !== forward ? \"nextSibling\" : \"previousSibling\",\n\t\t\t\t\t\tparent = elem.parentNode,\n\t\t\t\t\t\tname = ofType && elem.nodeName.toLowerCase(),\n\t\t\t\t\t\tuseCache = !xml && !ofType,\n\t\t\t\t\t\tdiff = false;\n\n\t\t\t\t\tif ( parent ) {\n\n\t\t\t\t\t\t// :(first|last|only)-(child|of-type)\n\t\t\t\t\t\tif ( simple ) {\n\t\t\t\t\t\t\twhile ( dir ) {\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\twhile ( (node = node[ dir ]) ) {\n\t\t\t\t\t\t\t\t\tif ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) {\n\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Reverse direction for :only-* (if we haven't yet done so)\n\t\t\t\t\t\t\t\tstart = dir = type === \"only\" && !start && \"nextSibling\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstart = [ forward ? parent.firstChild : parent.lastChild ];\n\n\t\t\t\t\t\t// non-xml :nth-child(...) stores cache data on `parent`\n\t\t\t\t\t\tif ( forward && useCache ) {\n\n\t\t\t\t\t\t\t// Seek `elem` from a previously-cached index\n\n\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\tnode = parent;\n\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\tdiff = nodeIndex && cache[ 2 ];\n\t\t\t\t\t\t\tnode = nodeIndex && parent.childNodes[ nodeIndex ];\n\n\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\n\t\t\t\t\t\t\t\t// Fallback to seeking `elem` from the start\n\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\t// When found, cache indexes on `parent` and break\n\t\t\t\t\t\t\t\tif ( node.nodeType === 1 && ++diff && node === elem ) {\n\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, nodeIndex, diff ];\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Use previously-cached element index if available\n\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t// ...in a gzip-friendly way\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\t\tcache = uniqueCache[ type ] || [];\n\t\t\t\t\t\t\t\tnodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];\n\t\t\t\t\t\t\t\tdiff = nodeIndex;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// xml :nth-child(...)\n\t\t\t\t\t\t\t// or :nth-last-child(...) or :nth(-last)?-of-type(...)\n\t\t\t\t\t\t\tif ( diff === false ) {\n\t\t\t\t\t\t\t\t// Use the same loop as above to seek `elem` from the start\n\t\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\t\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\t\tif ( ( ofType ?\n\t\t\t\t\t\t\t\t\t\tnode.nodeName.toLowerCase() === name :\n\t\t\t\t\t\t\t\t\t\tnode.nodeType === 1 ) &&\n\t\t\t\t\t\t\t\t\t\t++diff ) {\n\n\t\t\t\t\t\t\t\t\t\t// Cache the index of each encountered element\n\t\t\t\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t\t\t\touterCache = node[ expando ] || (node[ expando ] = {});\n\n\t\t\t\t\t\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache = outerCache[ node.uniqueID ] ||\n\t\t\t\t\t\t\t\t\t\t\t\t(outerCache[ node.uniqueID ] = {});\n\n\t\t\t\t\t\t\t\t\t\t\tuniqueCache[ type ] = [ dirruns, diff ];\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif ( node === elem ) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Incorporate the offset, then check against cycle size\n\t\t\t\t\t\tdiff -= last;\n\t\t\t\t\t\treturn diff === first || ( diff % first === 0 && diff / first >= 0 );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t},\n\n\t\t\"PSEUDO\": function( pseudo, argument ) {\n\t\t\t// pseudo-class names are case-insensitive\n\t\t\t// http://www.w3.org/TR/selectors/#pseudo-classes\n\t\t\t// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters\n\t\t\t// Remember that setFilters inherits from pseudos\n\t\t\tvar args,\n\t\t\t\tfn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||\n\t\t\t\t\tSizzle.error( \"unsupported pseudo: \" + pseudo );\n\n\t\t\t// The user may use createPseudo to indicate that\n\t\t\t// arguments are needed to create the filter function\n\t\t\t// just as Sizzle does\n\t\t\tif ( fn[ expando ] ) {\n\t\t\t\treturn fn( argument );\n\t\t\t}\n\n\t\t\t// But maintain support for old signatures\n\t\t\tif ( fn.length > 1 ) {\n\t\t\t\targs = [ pseudo, pseudo, \"\", argument ];\n\t\t\t\treturn Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?\n\t\t\t\t\tmarkFunction(function( seed, matches ) {\n\t\t\t\t\t\tvar idx,\n\t\t\t\t\t\t\tmatched = fn( seed, argument ),\n\t\t\t\t\t\t\ti = matched.length;\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tidx = indexOf( seed, matched[i] );\n\t\t\t\t\t\t\tseed[ idx ] = !( matches[ idx ] = matched[i] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}) :\n\t\t\t\t\tfunction( elem ) {\n\t\t\t\t\t\treturn fn( elem, 0, args );\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn fn;\n\t\t}\n\t},\n\n\tpseudos: {\n\t\t// Potentially complex pseudos\n\t\t\"not\": markFunction(function( selector ) {\n\t\t\t// Trim the selector passed to compile\n\t\t\t// to avoid treating leading and trailing\n\t\t\t// spaces as combinators\n\t\t\tvar input = [],\n\t\t\t\tresults = [],\n\t\t\t\tmatcher = compile( selector.replace( rtrim, \"$1\" ) );\n\n\t\t\treturn matcher[ expando ] ?\n\t\t\t\tmarkFunction(function( seed, matches, context, xml ) {\n\t\t\t\t\tvar elem,\n\t\t\t\t\t\tunmatched = matcher( seed, null, xml, [] ),\n\t\t\t\t\t\ti = seed.length;\n\n\t\t\t\t\t// Match elements unmatched by `matcher`\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = unmatched[i]) ) {\n\t\t\t\t\t\t\tseed[i] = !(matches[i] = elem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}) :\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tinput[0] = elem;\n\t\t\t\t\tmatcher( input, null, xml, results );\n\t\t\t\t\t// Don't keep the element (issue #299)\n\t\t\t\t\tinput[0] = null;\n\t\t\t\t\treturn !results.pop();\n\t\t\t\t};\n\t\t}),\n\n\t\t\"has\": markFunction(function( selector ) {\n\t\t\treturn function( elem ) {\n\t\t\t\treturn Sizzle( selector, elem ).length > 0;\n\t\t\t};\n\t\t}),\n\n\t\t\"contains\": markFunction(function( text ) {\n\t\t\ttext = text.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;\n\t\t\t};\n\t\t}),\n\n\t\t// \"Whether an element is represented by a :lang() selector\n\t\t// is based solely on the element's language value\n\t\t// being equal to the identifier C,\n\t\t// or beginning with the identifier C immediately followed by \"-\".\n\t\t// The matching of C against the element's language value is performed case-insensitively.\n\t\t// The identifier C does not have to be a valid language name.\"\n\t\t// http://www.w3.org/TR/selectors/#lang-pseudo\n\t\t\"lang\": markFunction( function( lang ) {\n\t\t\t// lang value must be a valid identifier\n\t\t\tif ( !ridentifier.test(lang || \"\") ) {\n\t\t\t\tSizzle.error( \"unsupported lang: \" + lang );\n\t\t\t}\n\t\t\tlang = lang.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn function( elem ) {\n\t\t\t\tvar elemLang;\n\t\t\t\tdo {\n\t\t\t\t\tif ( (elemLang = documentIsHTML ?\n\t\t\t\t\t\telem.lang :\n\t\t\t\t\t\telem.getAttribute(\"xml:lang\") || elem.getAttribute(\"lang\")) ) {\n\n\t\t\t\t\t\telemLang = elemLang.toLowerCase();\n\t\t\t\t\t\treturn elemLang === lang || elemLang.indexOf( lang + \"-\" ) === 0;\n\t\t\t\t\t}\n\t\t\t\t} while ( (elem = elem.parentNode) && elem.nodeType === 1 );\n\t\t\t\treturn false;\n\t\t\t};\n\t\t}),\n\n\t\t// Miscellaneous\n\t\t\"target\": function( elem ) {\n\t\t\tvar hash = window.location && window.location.hash;\n\t\t\treturn hash && hash.slice( 1 ) === elem.id;\n\t\t},\n\n\t\t\"root\": function( elem ) {\n\t\t\treturn elem === docElem;\n\t\t},\n\n\t\t\"focus\": function( elem ) {\n\t\t\treturn elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);\n\t\t},\n\n\t\t// Boolean properties\n\t\t\"enabled\": createDisabledPseudo( false ),\n\t\t\"disabled\": createDisabledPseudo( true ),\n\n\t\t\"checked\": function( elem ) {\n\t\t\t// In CSS3, :checked should return both checked and selected elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\tvar nodeName = elem.nodeName.toLowerCase();\n\t\t\treturn (nodeName === \"input\" && !!elem.checked) || (nodeName === \"option\" && !!elem.selected);\n\t\t},\n\n\t\t\"selected\": function( elem ) {\n\t\t\t// Accessing this property makes selected-by-default\n\t\t\t// options in Safari work properly\n\t\t\tif ( elem.parentNode ) {\n\t\t\t\telem.parentNode.selectedIndex;\n\t\t\t}\n\n\t\t\treturn elem.selected === true;\n\t\t},\n\n\t\t// Contents\n\t\t\"empty\": function( elem ) {\n\t\t\t// http://www.w3.org/TR/selectors/#empty-pseudo\n\t\t\t// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),\n\t\t\t//   but not by others (comment: 8; processing instruction: 7; etc.)\n\t\t\t// nodeType < 6 works because attributes (2) do not appear as children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tif ( elem.nodeType < 6 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\n\t\t\"parent\": function( elem ) {\n\t\t\treturn !Expr.pseudos[\"empty\"]( elem );\n\t\t},\n\n\t\t// Element/input types\n\t\t\"header\": function( elem ) {\n\t\t\treturn rheader.test( elem.nodeName );\n\t\t},\n\n\t\t\"input\": function( elem ) {\n\t\t\treturn rinputs.test( elem.nodeName );\n\t\t},\n\n\t\t\"button\": function( elem ) {\n\t\t\tvar name = elem.nodeName.toLowerCase();\n\t\t\treturn name === \"input\" && elem.type === \"button\" || name === \"button\";\n\t\t},\n\n\t\t\"text\": function( elem ) {\n\t\t\tvar attr;\n\t\t\treturn elem.nodeName.toLowerCase() === \"input\" &&\n\t\t\t\telem.type === \"text\" &&\n\n\t\t\t\t// Support: IE<8\n\t\t\t\t// New HTML5 attribute values (e.g., \"search\") appear with elem.type === \"text\"\n\t\t\t\t( (attr = elem.getAttribute(\"type\")) == null || attr.toLowerCase() === \"text\" );\n\t\t},\n\n\t\t// Position-in-collection\n\t\t\"first\": createPositionalPseudo(function() {\n\t\t\treturn [ 0 ];\n\t\t}),\n\n\t\t\"last\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\treturn [ length - 1 ];\n\t\t}),\n\n\t\t\"eq\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\treturn [ argument < 0 ? argument + length : argument ];\n\t\t}),\n\n\t\t\"even\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"odd\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 1;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"lt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; --i >= 0; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"gt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; ++i < length; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t})\n\t}\n};\n\nExpr.pseudos[\"nth\"] = Expr.pseudos[\"eq\"];\n\n// Add button/input type pseudos\nfor ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {\n\tExpr.pseudos[ i ] = createInputPseudo( i );\n}\nfor ( i in { submit: true, reset: true } ) {\n\tExpr.pseudos[ i ] = createButtonPseudo( i );\n}\n\n// Easy API for creating new setFilters\nfunction setFilters() {}\nsetFilters.prototype = Expr.filters = Expr.pseudos;\nExpr.setFilters = new setFilters();\n\ntokenize = Sizzle.tokenize = function( selector, parseOnly ) {\n\tvar matched, match, tokens, type,\n\t\tsoFar, groups, preFilters,\n\t\tcached = tokenCache[ selector + \" \" ];\n\n\tif ( cached ) {\n\t\treturn parseOnly ? 0 : cached.slice( 0 );\n\t}\n\n\tsoFar = selector;\n\tgroups = [];\n\tpreFilters = Expr.preFilter;\n\n\twhile ( soFar ) {\n\n\t\t// Comma and first run\n\t\tif ( !matched || (match = rcomma.exec( soFar )) ) {\n\t\t\tif ( match ) {\n\t\t\t\t// Don't consume trailing commas as valid\n\t\t\t\tsoFar = soFar.slice( match[0].length ) || soFar;\n\t\t\t}\n\t\t\tgroups.push( (tokens = []) );\n\t\t}\n\n\t\tmatched = false;\n\n\t\t// Combinators\n\t\tif ( (match = rcombinators.exec( soFar )) ) {\n\t\t\tmatched = match.shift();\n\t\t\ttokens.push({\n\t\t\t\tvalue: matched,\n\t\t\t\t// Cast descendant combinators to space\n\t\t\t\ttype: match[0].replace( rtrim, \" \" )\n\t\t\t});\n\t\t\tsoFar = soFar.slice( matched.length );\n\t\t}\n\n\t\t// Filters\n\t\tfor ( type in Expr.filter ) {\n\t\t\tif ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||\n\t\t\t\t(match = preFilters[ type ]( match ))) ) {\n\t\t\t\tmatched = match.shift();\n\t\t\t\ttokens.push({\n\t\t\t\t\tvalue: matched,\n\t\t\t\t\ttype: type,\n\t\t\t\t\tmatches: match\n\t\t\t\t});\n\t\t\t\tsoFar = soFar.slice( matched.length );\n\t\t\t}\n\t\t}\n\n\t\tif ( !matched ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Return the length of the invalid excess\n\t// if we're just parsing\n\t// Otherwise, throw an error or return tokens\n\treturn parseOnly ?\n\t\tsoFar.length :\n\t\tsoFar ?\n\t\t\tSizzle.error( selector ) :\n\t\t\t// Cache the tokens\n\t\t\ttokenCache( selector, groups ).slice( 0 );\n};\n\nfunction toSelector( tokens ) {\n\tvar i = 0,\n\t\tlen = tokens.length,\n\t\tselector = \"\";\n\tfor ( ; i < len; i++ ) {\n\t\tselector += tokens[i].value;\n\t}\n\treturn selector;\n}\n\nfunction addCombinator( matcher, combinator, base ) {\n\tvar dir = combinator.dir,\n\t\tskip = combinator.next,\n\t\tkey = skip || dir,\n\t\tcheckNonElements = base && key === \"parentNode\",\n\t\tdoneName = done++;\n\n\treturn combinator.first ?\n\t\t// Check against closest ancestor/preceding element\n\t\tfunction( elem, context, xml ) {\n\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\treturn matcher( elem, context, xml );\n\t\t\t\t}\n\t\t\t}\n\t\t} :\n\n\t\t// Check against all ancestor/preceding elements\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar oldCache, uniqueCache, outerCache,\n\t\t\t\tnewCache = [ dirruns, doneName ];\n\n\t\t\t// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching\n\t\t\tif ( xml ) {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\tif ( matcher( elem, context, xml ) ) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\touterCache = elem[ expando ] || (elem[ expando ] = {});\n\n\t\t\t\t\t\t// Support: IE <9 only\n\t\t\t\t\t\t// Defend against cloned attroperties (jQuery gh-1709)\n\t\t\t\t\t\tuniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});\n\n\t\t\t\t\t\tif ( skip && skip === elem.nodeName.toLowerCase() ) {\n\t\t\t\t\t\t\telem = elem[ dir ] || elem;\n\t\t\t\t\t\t} else if ( (oldCache = uniqueCache[ key ]) &&\n\t\t\t\t\t\t\toldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {\n\n\t\t\t\t\t\t\t// Assign to newCache so results back-propagate to previous elements\n\t\t\t\t\t\t\treturn (newCache[ 2 ] = oldCache[ 2 ]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Reuse newcache so results back-propagate to previous elements\n\t\t\t\t\t\t\tuniqueCache[ key ] = newCache;\n\n\t\t\t\t\t\t\t// A match means we're done; a fail means we have to keep checking\n\t\t\t\t\t\t\tif ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n}\n\nfunction elementMatcher( matchers ) {\n\treturn matchers.length > 1 ?\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar i = matchers.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( !matchers[i]( elem, context, xml ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t} :\n\t\tmatchers[0];\n}\n\nfunction multipleContexts( selector, contexts, results ) {\n\tvar i = 0,\n\t\tlen = contexts.length;\n\tfor ( ; i < len; i++ ) {\n\t\tSizzle( selector, contexts[i], results );\n\t}\n\treturn results;\n}\n\nfunction condense( unmatched, map, filter, context, xml ) {\n\tvar elem,\n\t\tnewUnmatched = [],\n\t\ti = 0,\n\t\tlen = unmatched.length,\n\t\tmapped = map != null;\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (elem = unmatched[i]) ) {\n\t\t\tif ( !filter || filter( elem, context, xml ) ) {\n\t\t\t\tnewUnmatched.push( elem );\n\t\t\t\tif ( mapped ) {\n\t\t\t\t\tmap.push( i );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn newUnmatched;\n}\n\nfunction setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {\n\tif ( postFilter && !postFilter[ expando ] ) {\n\t\tpostFilter = setMatcher( postFilter );\n\t}\n\tif ( postFinder && !postFinder[ expando ] ) {\n\t\tpostFinder = setMatcher( postFinder, postSelector );\n\t}\n\treturn markFunction(function( seed, results, context, xml ) {\n\t\tvar temp, i, elem,\n\t\t\tpreMap = [],\n\t\t\tpostMap = [],\n\t\t\tpreexisting = results.length,\n\n\t\t\t// Get initial elements from seed or context\n\t\t\telems = seed || multipleContexts( selector || \"*\", context.nodeType ? [ context ] : context, [] ),\n\n\t\t\t// Prefilter to get matcher input, preserving a map for seed-results synchronization\n\t\t\tmatcherIn = preFilter && ( seed || !selector ) ?\n\t\t\t\tcondense( elems, preMap, preFilter, context, xml ) :\n\t\t\t\telems,\n\n\t\t\tmatcherOut = matcher ?\n\t\t\t\t// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,\n\t\t\t\tpostFinder || ( seed ? preFilter : preexisting || postFilter ) ?\n\n\t\t\t\t\t// ...intermediate processing is necessary\n\t\t\t\t\t[] :\n\n\t\t\t\t\t// ...otherwise use results directly\n\t\t\t\t\tresults :\n\t\t\t\tmatcherIn;\n\n\t\t// Find primary matches\n\t\tif ( matcher ) {\n\t\t\tmatcher( matcherIn, matcherOut, context, xml );\n\t\t}\n\n\t\t// Apply postFilter\n\t\tif ( postFilter ) {\n\t\t\ttemp = condense( matcherOut, postMap );\n\t\t\tpostFilter( temp, [], context, xml );\n\n\t\t\t// Un-match failing elements by moving them back to matcherIn\n\t\t\ti = temp.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( (elem = temp[i]) ) {\n\t\t\t\t\tmatcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( seed ) {\n\t\t\tif ( postFinder || preFilter ) {\n\t\t\t\tif ( postFinder ) {\n\t\t\t\t\t// Get the final matcherOut by condensing this intermediate into postFinder contexts\n\t\t\t\t\ttemp = [];\n\t\t\t\t\ti = matcherOut.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = matcherOut[i]) ) {\n\t\t\t\t\t\t\t// Restore matcherIn since elem is not yet a final match\n\t\t\t\t\t\t\ttemp.push( (matcherIn[i] = elem) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpostFinder( null, (matcherOut = []), temp, xml );\n\t\t\t\t}\n\n\t\t\t\t// Move matched elements from seed to results to keep them synchronized\n\t\t\t\ti = matcherOut.length;\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tif ( (elem = matcherOut[i]) &&\n\t\t\t\t\t\t(temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {\n\n\t\t\t\t\t\tseed[temp] = !(results[temp] = elem);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Add elements to results, through postFinder if defined\n\t\t} else {\n\t\t\tmatcherOut = condense(\n\t\t\t\tmatcherOut === results ?\n\t\t\t\t\tmatcherOut.splice( preexisting, matcherOut.length ) :\n\t\t\t\t\tmatcherOut\n\t\t\t);\n\t\t\tif ( postFinder ) {\n\t\t\t\tpostFinder( null, results, matcherOut, xml );\n\t\t\t} else {\n\t\t\t\tpush.apply( results, matcherOut );\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction matcherFromTokens( tokens ) {\n\tvar checkContext, matcher, j,\n\t\tlen = tokens.length,\n\t\tleadingRelative = Expr.relative[ tokens[0].type ],\n\t\timplicitRelative = leadingRelative || Expr.relative[\" \"],\n\t\ti = leadingRelative ? 1 : 0,\n\n\t\t// The foundational matcher ensures that elements are reachable from top-level context(s)\n\t\tmatchContext = addCombinator( function( elem ) {\n\t\t\treturn elem === checkContext;\n\t\t}, implicitRelative, true ),\n\t\tmatchAnyContext = addCombinator( function( elem ) {\n\t\t\treturn indexOf( checkContext, elem ) > -1;\n\t\t}, implicitRelative, true ),\n\t\tmatchers = [ function( elem, context, xml ) {\n\t\t\tvar ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (\n\t\t\t\t(checkContext = context).nodeType ?\n\t\t\t\t\tmatchContext( elem, context, xml ) :\n\t\t\t\t\tmatchAnyContext( elem, context, xml ) );\n\t\t\t// Avoid hanging onto element (issue #299)\n\t\t\tcheckContext = null;\n\t\t\treturn ret;\n\t\t} ];\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (matcher = Expr.relative[ tokens[i].type ]) ) {\n\t\t\tmatchers = [ addCombinator(elementMatcher( matchers ), matcher) ];\n\t\t} else {\n\t\t\tmatcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );\n\n\t\t\t// Return special upon seeing a positional matcher\n\t\t\tif ( matcher[ expando ] ) {\n\t\t\t\t// Find the next relative operator (if any) for proper handling\n\t\t\t\tj = ++i;\n\t\t\t\tfor ( ; j < len; j++ ) {\n\t\t\t\t\tif ( Expr.relative[ tokens[j].type ] ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn setMatcher(\n\t\t\t\t\ti > 1 && elementMatcher( matchers ),\n\t\t\t\t\ti > 1 && toSelector(\n\t\t\t\t\t\t// If the preceding token was a descendant combinator, insert an implicit any-element `*`\n\t\t\t\t\t\ttokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === \" \" ? \"*\" : \"\" })\n\t\t\t\t\t).replace( rtrim, \"$1\" ),\n\t\t\t\t\tmatcher,\n\t\t\t\t\ti < j && matcherFromTokens( tokens.slice( i, j ) ),\n\t\t\t\t\tj < len && matcherFromTokens( (tokens = tokens.slice( j )) ),\n\t\t\t\t\tj < len && toSelector( tokens )\n\t\t\t\t);\n\t\t\t}\n\t\t\tmatchers.push( matcher );\n\t\t}\n\t}\n\n\treturn elementMatcher( matchers );\n}\n\nfunction matcherFromGroupMatchers( elementMatchers, setMatchers ) {\n\tvar bySet = setMatchers.length > 0,\n\t\tbyElement = elementMatchers.length > 0,\n\t\tsuperMatcher = function( seed, context, xml, results, outermost ) {\n\t\t\tvar elem, j, matcher,\n\t\t\t\tmatchedCount = 0,\n\t\t\t\ti = \"0\",\n\t\t\t\tunmatched = seed && [],\n\t\t\t\tsetMatched = [],\n\t\t\t\tcontextBackup = outermostContext,\n\t\t\t\t// We must always have either seed elements or outermost context\n\t\t\t\telems = seed || byElement && Expr.find[\"TAG\"]( \"*\", outermost ),\n\t\t\t\t// Use integer dirruns iff this is the outermost matcher\n\t\t\t\tdirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),\n\t\t\t\tlen = elems.length;\n\n\t\t\tif ( outermost ) {\n\t\t\t\toutermostContext = context === document || context || outermost;\n\t\t\t}\n\n\t\t\t// Add elements passing elementMatchers directly to results\n\t\t\t// Support: IE<9, Safari\n\t\t\t// Tolerate NodeList properties (IE: \"length\"; Safari: <number>) matching elements by id\n\t\t\tfor ( ; i !== len && (elem = elems[i]) != null; i++ ) {\n\t\t\t\tif ( byElement && elem ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\tif ( !context && elem.ownerDocument !== document ) {\n\t\t\t\t\t\tsetDocument( elem );\n\t\t\t\t\t\txml = !documentIsHTML;\n\t\t\t\t\t}\n\t\t\t\t\twhile ( (matcher = elementMatchers[j++]) ) {\n\t\t\t\t\t\tif ( matcher( elem, context || document, xml) ) {\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( outermost ) {\n\t\t\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Track unmatched elements for set filters\n\t\t\t\tif ( bySet ) {\n\t\t\t\t\t// They will have gone through all possible matchers\n\t\t\t\t\tif ( (elem = !matcher && elem) ) {\n\t\t\t\t\t\tmatchedCount--;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Lengthen the array for every element, matched or not\n\t\t\t\t\tif ( seed ) {\n\t\t\t\t\t\tunmatched.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// `i` is now the count of elements visited above, and adding it to `matchedCount`\n\t\t\t// makes the latter nonnegative.\n\t\t\tmatchedCount += i;\n\n\t\t\t// Apply set filters to unmatched elements\n\t\t\t// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`\n\t\t\t// equals `i`), unless we didn't visit _any_ elements in the above loop because we have\n\t\t\t// no element matchers and no seed.\n\t\t\t// Incrementing an initially-string \"0\" `i` allows `i` to remain a string only in that\n\t\t\t// case, which will result in a \"00\" `matchedCount` that differs from `i` but is also\n\t\t\t// numerically zero.\n\t\t\tif ( bySet && i !== matchedCount ) {\n\t\t\t\tj = 0;\n\t\t\t\twhile ( (matcher = setMatchers[j++]) ) {\n\t\t\t\t\tmatcher( unmatched, setMatched, context, xml );\n\t\t\t\t}\n\n\t\t\t\tif ( seed ) {\n\t\t\t\t\t// Reintegrate element matches to eliminate the need for sorting\n\t\t\t\t\tif ( matchedCount > 0 ) {\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tif ( !(unmatched[i] || setMatched[i]) ) {\n\t\t\t\t\t\t\t\tsetMatched[i] = pop.call( results );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Discard index placeholder values to get only actual matches\n\t\t\t\t\tsetMatched = condense( setMatched );\n\t\t\t\t}\n\n\t\t\t\t// Add matches to results\n\t\t\t\tpush.apply( results, setMatched );\n\n\t\t\t\t// Seedless set matches succeeding multiple successful matchers stipulate sorting\n\t\t\t\tif ( outermost && !seed && setMatched.length > 0 &&\n\t\t\t\t\t( matchedCount + setMatchers.length ) > 1 ) {\n\n\t\t\t\t\tSizzle.uniqueSort( results );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Override manipulation of globals by nested matchers\n\t\t\tif ( outermost ) {\n\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\toutermostContext = contextBackup;\n\t\t\t}\n\n\t\t\treturn unmatched;\n\t\t};\n\n\treturn bySet ?\n\t\tmarkFunction( superMatcher ) :\n\t\tsuperMatcher;\n}\n\ncompile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {\n\tvar i,\n\t\tsetMatchers = [],\n\t\telementMatchers = [],\n\t\tcached = compilerCache[ selector + \" \" ];\n\n\tif ( !cached ) {\n\t\t// Generate a function of recursive functions that can be used to check each element\n\t\tif ( !match ) {\n\t\t\tmatch = tokenize( selector );\n\t\t}\n\t\ti = match.length;\n\t\twhile ( i-- ) {\n\t\t\tcached = matcherFromTokens( match[i] );\n\t\t\tif ( cached[ expando ] ) {\n\t\t\t\tsetMatchers.push( cached );\n\t\t\t} else {\n\t\t\t\telementMatchers.push( cached );\n\t\t\t}\n\t\t}\n\n\t\t// Cache the compiled function\n\t\tcached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );\n\n\t\t// Save selector and tokenization\n\t\tcached.selector = selector;\n\t}\n\treturn cached;\n};\n\n/**\n * A low-level selection function that works with Sizzle's compiled\n *  selector functions\n * @param {String|Function} selector A selector or a pre-compiled\n *  selector function built with Sizzle.compile\n * @param {Element} context\n * @param {Array} [results]\n * @param {Array} [seed] A set of elements to match against\n */\nselect = Sizzle.select = function( selector, context, results, seed ) {\n\tvar i, tokens, token, type, find,\n\t\tcompiled = typeof selector === \"function\" && selector,\n\t\tmatch = !seed && tokenize( (selector = compiled.selector || selector) );\n\n\tresults = results || [];\n\n\t// Try to minimize operations if there is only one selector in the list and no seed\n\t// (the latter of which guarantees us context)\n\tif ( match.length === 1 ) {\n\n\t\t// Reduce context if the leading compound selector is an ID\n\t\ttokens = match[0] = match[0].slice( 0 );\n\t\tif ( tokens.length > 2 && (token = tokens[0]).type === \"ID\" &&\n\t\t\t\tsupport.getById && context.nodeType === 9 && documentIsHTML &&\n\t\t\t\tExpr.relative[ tokens[1].type ] ) {\n\n\t\t\tcontext = ( Expr.find[\"ID\"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];\n\t\t\tif ( !context ) {\n\t\t\t\treturn results;\n\n\t\t\t// Precompiled matchers will still verify ancestry, so step up a level\n\t\t\t} else if ( compiled ) {\n\t\t\t\tcontext = context.parentNode;\n\t\t\t}\n\n\t\t\tselector = selector.slice( tokens.shift().value.length );\n\t\t}\n\n\t\t// Fetch a seed set for right-to-left matching\n\t\ti = matchExpr[\"needsContext\"].test( selector ) ? 0 : tokens.length;\n\t\twhile ( i-- ) {\n\t\t\ttoken = tokens[i];\n\n\t\t\t// Abort if we hit a combinator\n\t\t\tif ( Expr.relative[ (type = token.type) ] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( (find = Expr.find[ type ]) ) {\n\t\t\t\t// Search, expanding context for leading sibling combinators\n\t\t\t\tif ( (seed = find(\n\t\t\t\t\ttoken.matches[0].replace( runescape, funescape ),\n\t\t\t\t\trsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context\n\t\t\t\t)) ) {\n\n\t\t\t\t\t// If seed is empty or no tokens remain, we can return early\n\t\t\t\t\ttokens.splice( i, 1 );\n\t\t\t\t\tselector = seed.length && toSelector( tokens );\n\t\t\t\t\tif ( !selector ) {\n\t\t\t\t\t\tpush.apply( results, seed );\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compile and execute a filtering function if one is not provided\n\t// Provide `match` to avoid retokenization if we modified the selector above\n\t( compiled || compile( selector, match ) )(\n\t\tseed,\n\t\tcontext,\n\t\t!documentIsHTML,\n\t\tresults,\n\t\t!context || rsibling.test( selector ) && testContext( context.parentNode ) || context\n\t);\n\treturn results;\n};\n\n// One-time assignments\n\n// Sort stability\nsupport.sortStable = expando.split(\"\").sort( sortOrder ).join(\"\") === expando;\n\n// Support: Chrome 14-35+\n// Always assume duplicates if they aren't passed to the comparison function\nsupport.detectDuplicates = !!hasDuplicate;\n\n// Initialize against the default document\nsetDocument();\n\n// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)\n// Detached nodes confoundingly follow *each other*\nsupport.sortDetached = assert(function( el ) {\n\t// Should return 1, but returns 4 (following)\n\treturn el.compareDocumentPosition( document.createElement(\"fieldset\") ) & 1;\n});\n\n// Support: IE<8\n// Prevent attribute/property \"interpolation\"\n// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx\nif ( !assert(function( el ) {\n\tel.innerHTML = \"<a href='#'></a>\";\n\treturn el.firstChild.getAttribute(\"href\") === \"#\" ;\n}) ) {\n\taddHandle( \"type|href|height|width\", function( elem, name, isXML ) {\n\t\tif ( !isXML ) {\n\t\t\treturn elem.getAttribute( name, name.toLowerCase() === \"type\" ? 1 : 2 );\n\t\t}\n\t});\n}\n\n// Support: IE<9\n// Use defaultValue in place of getAttribute(\"value\")\nif ( !support.attributes || !assert(function( el ) {\n\tel.innerHTML = \"<input/>\";\n\tel.firstChild.setAttribute( \"value\", \"\" );\n\treturn el.firstChild.getAttribute( \"value\" ) === \"\";\n}) ) {\n\taddHandle( \"value\", function( elem, name, isXML ) {\n\t\tif ( !isXML && elem.nodeName.toLowerCase() === \"input\" ) {\n\t\t\treturn elem.defaultValue;\n\t\t}\n\t});\n}\n\n// Support: IE<9\n// Use getAttributeNode to fetch booleans when getAttribute lies\nif ( !assert(function( el ) {\n\treturn el.getAttribute(\"disabled\") == null;\n}) ) {\n\taddHandle( booleans, function( elem, name, isXML ) {\n\t\tvar val;\n\t\tif ( !isXML ) {\n\t\t\treturn elem[ name ] === true ? name.toLowerCase() :\n\t\t\t\t\t(val = elem.getAttributeNode( name )) && val.specified ?\n\t\t\t\t\tval.value :\n\t\t\t\tnull;\n\t\t}\n\t});\n}\n\nreturn Sizzle;\n\n})( window );\n\n\n\njQuery.find = Sizzle;\njQuery.expr = Sizzle.selectors;\njQuery.expr[ \":\" ] = jQuery.expr.pseudos;\njQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;\njQuery.text = Sizzle.getText;\njQuery.isXMLDoc = Sizzle.isXML;\njQuery.contains = Sizzle.contains;\n\n\n\nvar dir = function( elem, dir, until ) {\n\tvar matched = [],\n\t\ttruncate = until !== undefined;\n\n\twhile ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {\n\t\tif ( elem.nodeType === 1 ) {\n\t\t\tif ( truncate && jQuery( elem ).is( until ) ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmatched.push( elem );\n\t\t}\n\t}\n\treturn matched;\n};\n\n\nvar siblings = function( n, elem ) {\n\tvar matched = [];\n\n\tfor ( ; n; n = n.nextSibling ) {\n\t\tif ( n.nodeType === 1 && n !== elem ) {\n\t\t\tmatched.push( n );\n\t\t}\n\t}\n\n\treturn matched;\n};\n\n\nvar rneedsContext = jQuery.expr.match.needsContext;\n\nvar rsingleTag = ( /^<([a-z][^\\/\\0>:\\x20\\t\\r\\n\\f]*)[\\x20\\t\\r\\n\\f]*\\/?>(?:<\\/\\1>|)$/i );\n\n\n\nvar risSimple = /^.[^:#\\[\\.,]*$/;\n\n// Implement the identical functionality for filter and not\nfunction winnow( elements, qualifier, not ) {\n\tif ( jQuery.isFunction( qualifier ) ) {\n\t\treturn jQuery.grep( elements, function( elem, i ) {\n\t\t\t/* jshint -W018 */\n\t\t\treturn !!qualifier.call( elem, i, elem ) !== not;\n\t\t} );\n\n\t}\n\n\tif ( qualifier.nodeType ) {\n\t\treturn jQuery.grep( elements, function( elem ) {\n\t\t\treturn ( elem === qualifier ) !== not;\n\t\t} );\n\n\t}\n\n\tif ( typeof qualifier === \"string\" ) {\n\t\tif ( risSimple.test( qualifier ) ) {\n\t\t\treturn jQuery.filter( qualifier, elements, not );\n\t\t}\n\n\t\tqualifier = jQuery.filter( qualifier, elements );\n\t}\n\n\treturn jQuery.grep( elements, function( elem ) {\n\t\treturn ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;\n\t} );\n}\n\njQuery.filter = function( expr, elems, not ) {\n\tvar elem = elems[ 0 ];\n\n\tif ( not ) {\n\t\texpr = \":not(\" + expr + \")\";\n\t}\n\n\treturn elems.length === 1 && elem.nodeType === 1 ?\n\t\tjQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :\n\t\tjQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {\n\t\t\treturn elem.nodeType === 1;\n\t\t} ) );\n};\n\njQuery.fn.extend( {\n\tfind: function( selector ) {\n\t\tvar i,\n\t\t\tlen = this.length,\n\t\t\tret = [],\n\t\t\tself = this;\n\n\t\tif ( typeof selector !== \"string\" ) {\n\t\t\treturn this.pushStack( jQuery( selector ).filter( function() {\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tif ( jQuery.contains( self[ i ], this ) ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ) );\n\t\t}\n\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tjQuery.find( selector, self[ i ], ret );\n\t\t}\n\n\t\treturn this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );\n\t},\n\tfilter: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], false ) );\n\t},\n\tnot: function( selector ) {\n\t\treturn this.pushStack( winnow( this, selector || [], true ) );\n\t},\n\tis: function( selector ) {\n\t\treturn !!winnow(\n\t\t\tthis,\n\n\t\t\t// If this is a positional/relative selector, check membership in the returned set\n\t\t\t// so $(\"p:first\").is(\"p:last\") won't return true for a doc with two \"p\".\n\t\t\ttypeof selector === \"string\" && rneedsContext.test( selector ) ?\n\t\t\t\tjQuery( selector ) :\n\t\t\t\tselector || [],\n\t\t\tfalse\n\t\t).length;\n\t}\n} );\n\n\n// Initialize a jQuery object\n\n\n// A central reference to the root jQuery(document)\nvar rootjQuery,\n\n\t// A simple way to check for HTML strings\n\t// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)\n\t// Strict HTML recognition (#11290: must start with <)\n\t// Shortcut simple #id case for speed\n\trquickExpr = /^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/,\n\n\tinit = jQuery.fn.init = function( selector, context, root ) {\n\t\tvar match, elem;\n\n\t\t// HANDLE: $(\"\"), $(null), $(undefined), $(false)\n\t\tif ( !selector ) {\n\t\t\treturn this;\n\t\t}\n\n\t\t// Method init() accepts an alternate rootjQuery\n\t\t// so migrate can support jQuery.sub (gh-2101)\n\t\troot = root || rootjQuery;\n\n\t\t// Handle HTML strings\n\t\tif ( typeof selector === \"string\" ) {\n\t\t\tif ( selector[ 0 ] === \"<\" &&\n\t\t\t\tselector[ selector.length - 1 ] === \">\" &&\n\t\t\t\tselector.length >= 3 ) {\n\n\t\t\t\t// Assume that strings that start and end with <> are HTML and skip the regex check\n\t\t\t\tmatch = [ null, selector, null ];\n\n\t\t\t} else {\n\t\t\t\tmatch = rquickExpr.exec( selector );\n\t\t\t}\n\n\t\t\t// Match html or make sure no context is specified for #id\n\t\t\tif ( match && ( match[ 1 ] || !context ) ) {\n\n\t\t\t\t// HANDLE: $(html) -> $(array)\n\t\t\t\tif ( match[ 1 ] ) {\n\t\t\t\t\tcontext = context instanceof jQuery ? context[ 0 ] : context;\n\n\t\t\t\t\t// Option to run scripts is true for back-compat\n\t\t\t\t\t// Intentionally let the error be thrown if parseHTML is not present\n\t\t\t\t\tjQuery.merge( this, jQuery.parseHTML(\n\t\t\t\t\t\tmatch[ 1 ],\n\t\t\t\t\t\tcontext && context.nodeType ? context.ownerDocument || context : document,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t) );\n\n\t\t\t\t\t// HANDLE: $(html, props)\n\t\t\t\t\tif ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {\n\t\t\t\t\t\tfor ( match in context ) {\n\n\t\t\t\t\t\t\t// Properties of context are called as methods if possible\n\t\t\t\t\t\t\tif ( jQuery.isFunction( this[ match ] ) ) {\n\t\t\t\t\t\t\t\tthis[ match ]( context[ match ] );\n\n\t\t\t\t\t\t\t// ...and otherwise set as attributes\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.attr( match, context[ match ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this;\n\n\t\t\t\t// HANDLE: $(#id)\n\t\t\t\t} else {\n\t\t\t\t\telem = document.getElementById( match[ 2 ] );\n\n\t\t\t\t\tif ( elem ) {\n\n\t\t\t\t\t\t// Inject the element directly into the jQuery object\n\t\t\t\t\t\tthis[ 0 ] = elem;\n\t\t\t\t\t\tthis.length = 1;\n\t\t\t\t\t}\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\n\t\t\t// HANDLE: $(expr, $(...))\n\t\t\t} else if ( !context || context.jquery ) {\n\t\t\t\treturn ( context || root ).find( selector );\n\n\t\t\t// HANDLE: $(expr, context)\n\t\t\t// (which is just equivalent to: $(context).find(expr)\n\t\t\t} else {\n\t\t\t\treturn this.constructor( context ).find( selector );\n\t\t\t}\n\n\t\t// HANDLE: $(DOMElement)\n\t\t} else if ( selector.nodeType ) {\n\t\t\tthis[ 0 ] = selector;\n\t\t\tthis.length = 1;\n\t\t\treturn this;\n\n\t\t// HANDLE: $(function)\n\t\t// Shortcut for document ready\n\t\t} else if ( jQuery.isFunction( selector ) ) {\n\t\t\treturn root.ready !== undefined ?\n\t\t\t\troot.ready( selector ) :\n\n\t\t\t\t// Execute immediately if ready is not present\n\t\t\t\tselector( jQuery );\n\t\t}\n\n\t\treturn jQuery.makeArray( selector, this );\n\t};\n\n// Give the init function the jQuery prototype for later instantiation\ninit.prototype = jQuery.fn;\n\n// Initialize central reference\nrootjQuery = jQuery( document );\n\n\nvar rparentsprev = /^(?:parents|prev(?:Until|All))/,\n\n\t// Methods guaranteed to produce a unique set when starting from a unique set\n\tguaranteedUnique = {\n\t\tchildren: true,\n\t\tcontents: true,\n\t\tnext: true,\n\t\tprev: true\n\t};\n\njQuery.fn.extend( {\n\thas: function( target ) {\n\t\tvar targets = jQuery( target, this ),\n\t\t\tl = targets.length;\n\n\t\treturn this.filter( function() {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tif ( jQuery.contains( this, targets[ i ] ) ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\tclosest: function( selectors, context ) {\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\tl = this.length,\n\t\t\tmatched = [],\n\t\t\ttargets = typeof selectors !== \"string\" && jQuery( selectors );\n\n\t\t// Positional selectors never match, since there's no _selection_ context\n\t\tif ( !rneedsContext.test( selectors ) ) {\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tfor ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {\n\n\t\t\t\t\t// Always skip document fragments\n\t\t\t\t\tif ( cur.nodeType < 11 && ( targets ?\n\t\t\t\t\t\ttargets.index( cur ) > -1 :\n\n\t\t\t\t\t\t// Don't pass non-elements to Sizzle\n\t\t\t\t\t\tcur.nodeType === 1 &&\n\t\t\t\t\t\t\tjQuery.find.matchesSelector( cur, selectors ) ) ) {\n\n\t\t\t\t\t\tmatched.push( cur );\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );\n\t},\n\n\t// Determine the position of an element within the set\n\tindex: function( elem ) {\n\n\t\t// No argument, return index in parent\n\t\tif ( !elem ) {\n\t\t\treturn ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;\n\t\t}\n\n\t\t// Index in selector\n\t\tif ( typeof elem === \"string\" ) {\n\t\t\treturn indexOf.call( jQuery( elem ), this[ 0 ] );\n\t\t}\n\n\t\t// Locate the position of the desired element\n\t\treturn indexOf.call( this,\n\n\t\t\t// If it receives a jQuery object, the first element is used\n\t\t\telem.jquery ? elem[ 0 ] : elem\n\t\t);\n\t},\n\n\tadd: function( selector, context ) {\n\t\treturn this.pushStack(\n\t\t\tjQuery.uniqueSort(\n\t\t\t\tjQuery.merge( this.get(), jQuery( selector, context ) )\n\t\t\t)\n\t\t);\n\t},\n\n\taddBack: function( selector ) {\n\t\treturn this.add( selector == null ?\n\t\t\tthis.prevObject : this.prevObject.filter( selector )\n\t\t);\n\t}\n} );\n\nfunction sibling( cur, dir ) {\n\twhile ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}\n\treturn cur;\n}\n\njQuery.each( {\n\tparent: function( elem ) {\n\t\tvar parent = elem.parentNode;\n\t\treturn parent && parent.nodeType !== 11 ? parent : null;\n\t},\n\tparents: function( elem ) {\n\t\treturn dir( elem, \"parentNode\" );\n\t},\n\tparentsUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"parentNode\", until );\n\t},\n\tnext: function( elem ) {\n\t\treturn sibling( elem, \"nextSibling\" );\n\t},\n\tprev: function( elem ) {\n\t\treturn sibling( elem, \"previousSibling\" );\n\t},\n\tnextAll: function( elem ) {\n\t\treturn dir( elem, \"nextSibling\" );\n\t},\n\tprevAll: function( elem ) {\n\t\treturn dir( elem, \"previousSibling\" );\n\t},\n\tnextUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"nextSibling\", until );\n\t},\n\tprevUntil: function( elem, i, until ) {\n\t\treturn dir( elem, \"previousSibling\", until );\n\t},\n\tsiblings: function( elem ) {\n\t\treturn siblings( ( elem.parentNode || {} ).firstChild, elem );\n\t},\n\tchildren: function( elem ) {\n\t\treturn siblings( elem.firstChild );\n\t},\n\tcontents: function( elem ) {\n\t\treturn elem.contentDocument || jQuery.merge( [], elem.childNodes );\n\t}\n}, function( name, fn ) {\n\tjQuery.fn[ name ] = function( until, selector ) {\n\t\tvar matched = jQuery.map( this, fn, until );\n\n\t\tif ( name.slice( -5 ) !== \"Until\" ) {\n\t\t\tselector = until;\n\t\t}\n\n\t\tif ( selector && typeof selector === \"string\" ) {\n\t\t\tmatched = jQuery.filter( selector, matched );\n\t\t}\n\n\t\tif ( this.length > 1 ) {\n\n\t\t\t// Remove duplicates\n\t\t\tif ( !guaranteedUnique[ name ] ) {\n\t\t\t\tjQuery.uniqueSort( matched );\n\t\t\t}\n\n\t\t\t// Reverse order for parents* and prev-derivatives\n\t\t\tif ( rparentsprev.test( name ) ) {\n\t\t\t\tmatched.reverse();\n\t\t\t}\n\t\t}\n\n\t\treturn this.pushStack( matched );\n\t};\n} );\nvar rnotwhite = ( /\\S+/g );\n\n\n\n// Convert String-formatted options into Object-formatted ones\nfunction createOptions( options ) {\n\tvar object = {};\n\tjQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {\n\t\tobject[ flag ] = true;\n\t} );\n\treturn object;\n}\n\n/*\n * Create a callback list using the following parameters:\n *\n *\toptions: an optional list of space-separated options that will change how\n *\t\t\tthe callback list behaves or a more traditional option object\n *\n * By default a callback list will act like an event callback list and can be\n * \"fired\" multiple times.\n *\n * Possible options:\n *\n *\tonce:\t\t\twill ensure the callback list can only be fired once (like a Deferred)\n *\n *\tmemory:\t\t\twill keep track of previous values and will call any callback added\n *\t\t\t\t\tafter the list has been fired right away with the latest \"memorized\"\n *\t\t\t\t\tvalues (like a Deferred)\n *\n *\tunique:\t\t\twill ensure a callback can only be added once (no duplicate in the list)\n *\n *\tstopOnFalse:\tinterrupt callings when a callback returns false\n *\n */\njQuery.Callbacks = function( options ) {\n\n\t// Convert options from String-formatted to Object-formatted if needed\n\t// (we check in cache first)\n\toptions = typeof options === \"string\" ?\n\t\tcreateOptions( options ) :\n\t\tjQuery.extend( {}, options );\n\n\tvar // Flag to know if list is currently firing\n\t\tfiring,\n\n\t\t// Last fire value for non-forgettable lists\n\t\tmemory,\n\n\t\t// Flag to know if list was already fired\n\t\tfired,\n\n\t\t// Flag to prevent firing\n\t\tlocked,\n\n\t\t// Actual callback list\n\t\tlist = [],\n\n\t\t// Queue of execution data for repeatable lists\n\t\tqueue = [],\n\n\t\t// Index of currently firing callback (modified by add/remove as needed)\n\t\tfiringIndex = -1,\n\n\t\t// Fire callbacks\n\t\tfire = function() {\n\n\t\t\t// Enforce single-firing\n\t\t\tlocked = options.once;\n\n\t\t\t// Execute callbacks for all pending executions,\n\t\t\t// respecting firingIndex overrides and runtime changes\n\t\t\tfired = firing = true;\n\t\t\tfor ( ; queue.length; firingIndex = -1 ) {\n\t\t\t\tmemory = queue.shift();\n\t\t\t\twhile ( ++firingIndex < list.length ) {\n\n\t\t\t\t\t// Run callback and check for early termination\n\t\t\t\t\tif ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&\n\t\t\t\t\t\toptions.stopOnFalse ) {\n\n\t\t\t\t\t\t// Jump to end and forget the data so .add doesn't re-fire\n\t\t\t\t\t\tfiringIndex = list.length;\n\t\t\t\t\t\tmemory = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Forget the data if we're done with it\n\t\t\tif ( !options.memory ) {\n\t\t\t\tmemory = false;\n\t\t\t}\n\n\t\t\tfiring = false;\n\n\t\t\t// Clean up if we're done firing for good\n\t\t\tif ( locked ) {\n\n\t\t\t\t// Keep an empty list if we have data for future add calls\n\t\t\t\tif ( memory ) {\n\t\t\t\t\tlist = [];\n\n\t\t\t\t// Otherwise, this object is spent\n\t\t\t\t} else {\n\t\t\t\t\tlist = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t// Actual Callbacks object\n\t\tself = {\n\n\t\t\t// Add a callback or a collection of callbacks to the list\n\t\t\tadd: function() {\n\t\t\t\tif ( list ) {\n\n\t\t\t\t\t// If we have memory from a past run, we should fire after adding\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfiringIndex = list.length - 1;\n\t\t\t\t\t\tqueue.push( memory );\n\t\t\t\t\t}\n\n\t\t\t\t\t( function add( args ) {\n\t\t\t\t\t\tjQuery.each( args, function( _, arg ) {\n\t\t\t\t\t\t\tif ( jQuery.isFunction( arg ) ) {\n\t\t\t\t\t\t\t\tif ( !options.unique || !self.has( arg ) ) {\n\t\t\t\t\t\t\t\t\tlist.push( arg );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if ( arg && arg.length && jQuery.type( arg ) !== \"string\" ) {\n\n\t\t\t\t\t\t\t\t// Inspect recursively\n\t\t\t\t\t\t\t\tadd( arg );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )( arguments );\n\n\t\t\t\t\tif ( memory && !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Remove a callback from the list\n\t\t\tremove: function() {\n\t\t\t\tjQuery.each( arguments, function( _, arg ) {\n\t\t\t\t\tvar index;\n\t\t\t\t\twhile ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {\n\t\t\t\t\t\tlist.splice( index, 1 );\n\n\t\t\t\t\t\t// Handle firing indexes\n\t\t\t\t\t\tif ( index <= firingIndex ) {\n\t\t\t\t\t\t\tfiringIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Check if a given callback is in the list.\n\t\t\t// If no argument is given, return whether or not list has callbacks attached.\n\t\t\thas: function( fn ) {\n\t\t\t\treturn fn ?\n\t\t\t\t\tjQuery.inArray( fn, list ) > -1 :\n\t\t\t\t\tlist.length > 0;\n\t\t\t},\n\n\t\t\t// Remove all callbacks from the list\n\t\t\tempty: function() {\n\t\t\t\tif ( list ) {\n\t\t\t\t\tlist = [];\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Disable .fire and .add\n\t\t\t// Abort any current/pending executions\n\t\t\t// Clear all callbacks and values\n\t\t\tdisable: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tlist = memory = \"\";\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tdisabled: function() {\n\t\t\t\treturn !list;\n\t\t\t},\n\n\t\t\t// Disable .fire\n\t\t\t// Also disable .add unless we have memory (since it would have no effect)\n\t\t\t// Abort any pending executions\n\t\t\tlock: function() {\n\t\t\t\tlocked = queue = [];\n\t\t\t\tif ( !memory && !firing ) {\n\t\t\t\t\tlist = memory = \"\";\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tlocked: function() {\n\t\t\t\treturn !!locked;\n\t\t\t},\n\n\t\t\t// Call all callbacks with the given context and arguments\n\t\t\tfireWith: function( context, args ) {\n\t\t\t\tif ( !locked ) {\n\t\t\t\t\targs = args || [];\n\t\t\t\t\targs = [ context, args.slice ? args.slice() : args ];\n\t\t\t\t\tqueue.push( args );\n\t\t\t\t\tif ( !firing ) {\n\t\t\t\t\t\tfire();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// Call all the callbacks with the given arguments\n\t\t\tfire: function() {\n\t\t\t\tself.fireWith( this, arguments );\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// To know if the callbacks have already been called at least once\n\t\t\tfired: function() {\n\t\t\t\treturn !!fired;\n\t\t\t}\n\t\t};\n\n\treturn self;\n};\n\n\nfunction Identity( v ) {\n\treturn v;\n}\nfunction Thrower( ex ) {\n\tthrow ex;\n}\n\njQuery.extend( {\n\n\tDeferred: function( func ) {\n\t\tvar tuples = [\n\n\t\t\t\t// action, add listener, callbacks,\n\t\t\t\t// ... .then handlers, argument index, [final state]\n\t\t\t\t[ \"notify\", \"progress\", jQuery.Callbacks( \"memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"memory\" ), 2 ],\n\t\t\t\t[ \"resolve\", \"done\", jQuery.Callbacks( \"once memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"once memory\" ), 0, \"resolved\" ],\n\t\t\t\t[ \"reject\", \"fail\", jQuery.Callbacks( \"once memory\" ),\n\t\t\t\t\tjQuery.Callbacks( \"once memory\" ), 1, \"rejected\" ]\n\t\t\t],\n\t\t\tstate = \"pending\",\n\t\t\tpromise = {\n\t\t\t\tstate: function() {\n\t\t\t\t\treturn state;\n\t\t\t\t},\n\t\t\t\talways: function() {\n\t\t\t\t\tdeferred.done( arguments ).fail( arguments );\n\t\t\t\t\treturn this;\n\t\t\t\t},\n\t\t\t\t\"catch\": function( fn ) {\n\t\t\t\t\treturn promise.then( null, fn );\n\t\t\t\t},\n\n\t\t\t\t// Keep pipe for back-compat\n\t\t\t\tpipe: function( /* fnDone, fnFail, fnProgress */ ) {\n\t\t\t\t\tvar fns = arguments;\n\n\t\t\t\t\treturn jQuery.Deferred( function( newDefer ) {\n\t\t\t\t\t\tjQuery.each( tuples, function( i, tuple ) {\n\n\t\t\t\t\t\t\t// Map tuples (progress, done, fail) to arguments (done, fail, progress)\n\t\t\t\t\t\t\tvar fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];\n\n\t\t\t\t\t\t\t// deferred.progress(function() { bind to newDefer or newDefer.notify })\n\t\t\t\t\t\t\t// deferred.done(function() { bind to newDefer or newDefer.resolve })\n\t\t\t\t\t\t\t// deferred.fail(function() { bind to newDefer or newDefer.reject })\n\t\t\t\t\t\t\tdeferred[ tuple[ 1 ] ]( function() {\n\t\t\t\t\t\t\t\tvar returned = fn && fn.apply( this, arguments );\n\t\t\t\t\t\t\t\tif ( returned && jQuery.isFunction( returned.promise ) ) {\n\t\t\t\t\t\t\t\t\treturned.promise()\n\t\t\t\t\t\t\t\t\t\t.progress( newDefer.notify )\n\t\t\t\t\t\t\t\t\t\t.done( newDefer.resolve )\n\t\t\t\t\t\t\t\t\t\t.fail( newDefer.reject );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tnewDefer[ tuple[ 0 ] + \"With\" ](\n\t\t\t\t\t\t\t\t\t\tthis === promise ? newDefer.promise() : this,\n\t\t\t\t\t\t\t\t\t\tfn ? [ returned ] : arguments\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tfns = null;\n\t\t\t\t\t} ).promise();\n\t\t\t\t},\n\t\t\t\tthen: function( onFulfilled, onRejected, onProgress ) {\n\t\t\t\t\tvar maxDepth = 0;\n\t\t\t\t\tfunction resolve( depth, deferred, handler, special ) {\n\t\t\t\t\t\treturn function() {\n\t\t\t\t\t\t\tvar that = this === promise ? undefined : this,\n\t\t\t\t\t\t\t\targs = arguments,\n\t\t\t\t\t\t\t\tmightThrow = function() {\n\t\t\t\t\t\t\t\t\tvar returned, then;\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.3\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-59\n\t\t\t\t\t\t\t\t\t// Ignore double-resolution attempts\n\t\t\t\t\t\t\t\t\tif ( depth < maxDepth ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturned = handler.apply( that, args );\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.1\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-48\n\t\t\t\t\t\t\t\t\tif ( returned === deferred.promise() ) {\n\t\t\t\t\t\t\t\t\t\tthrow new TypeError( \"Thenable self-resolution\" );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Support: Promises/A+ sections 2.3.3.1, 3.5\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-54\n\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-75\n\t\t\t\t\t\t\t\t\t// Retrieve `then` only once\n\t\t\t\t\t\t\t\t\tthen = returned &&\n\n\t\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.4\n\t\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-64\n\t\t\t\t\t\t\t\t\t\t// Only check objects and functions for thenability\n\t\t\t\t\t\t\t\t\t\t( typeof returned === \"object\" ||\n\t\t\t\t\t\t\t\t\t\t\ttypeof returned === \"function\" ) &&\n\t\t\t\t\t\t\t\t\t\treturned.then;\n\n\t\t\t\t\t\t\t\t\t// Handle a returned thenable\n\t\t\t\t\t\t\t\t\tif ( jQuery.isFunction( then ) ) {\n\n\t\t\t\t\t\t\t\t\t\t// Special processors (notify) just wait for resolution\n\t\t\t\t\t\t\t\t\t\tif ( special ) {\n\t\t\t\t\t\t\t\t\t\t\tthen.call(\n\t\t\t\t\t\t\t\t\t\t\t\treturned,\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Thrower, special )\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t// Normal processors (resolve) also hook into progress\n\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t// ...and disregard older resolution values\n\t\t\t\t\t\t\t\t\t\t\tmaxDepth++;\n\n\t\t\t\t\t\t\t\t\t\t\tthen.call(\n\t\t\t\t\t\t\t\t\t\t\t\treturned,\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Thrower, special ),\n\t\t\t\t\t\t\t\t\t\t\t\tresolve( maxDepth, deferred, Identity,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdeferred.notify )\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Handle all other returned values\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t// Only substitute handlers pass on context\n\t\t\t\t\t\t\t\t\t\t// and multiple values (non-spec behavior)\n\t\t\t\t\t\t\t\t\t\tif ( handler !== Identity ) {\n\t\t\t\t\t\t\t\t\t\t\tthat = undefined;\n\t\t\t\t\t\t\t\t\t\t\targs = [ returned ];\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Process the value(s)\n\t\t\t\t\t\t\t\t\t\t// Default process is resolve\n\t\t\t\t\t\t\t\t\t\t( special || deferred.resolveWith )(\n\t\t\t\t\t\t\t\t\t\t\tthat || deferred.promise(), args );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t// Only normal processors (resolve) catch and reject exceptions\n\t\t\t\t\t\t\t\tprocess = special ?\n\t\t\t\t\t\t\t\t\tmightThrow :\n\t\t\t\t\t\t\t\t\tfunction() {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tmightThrow();\n\t\t\t\t\t\t\t\t\t\t} catch ( e ) {\n\n\t\t\t\t\t\t\t\t\t\t\tif ( jQuery.Deferred.exceptionHook ) {\n\t\t\t\t\t\t\t\t\t\t\t\tjQuery.Deferred.exceptionHook( e,\n\t\t\t\t\t\t\t\t\t\t\t\t\tprocess.stackTrace );\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.4.1\n\t\t\t\t\t\t\t\t\t\t\t// https://promisesaplus.com/#point-61\n\t\t\t\t\t\t\t\t\t\t\t// Ignore post-resolution exceptions\n\t\t\t\t\t\t\t\t\t\t\tif ( depth + 1 >= maxDepth ) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t// Only substitute handlers pass on context\n\t\t\t\t\t\t\t\t\t\t\t\t// and multiple values (non-spec behavior)\n\t\t\t\t\t\t\t\t\t\t\t\tif ( handler !== Thrower ) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthat = undefined;\n\t\t\t\t\t\t\t\t\t\t\t\t\targs = [ e ];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tdeferred.rejectWith( that || deferred.promise(),\n\t\t\t\t\t\t\t\t\t\t\t\t\targs );\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// Support: Promises/A+ section 2.3.3.3.1\n\t\t\t\t\t\t\t// https://promisesaplus.com/#point-57\n\t\t\t\t\t\t\t// Re-resolve promises immediately to dodge false rejection from\n\t\t\t\t\t\t\t// subsequent errors\n\t\t\t\t\t\t\tif ( depth ) {\n\t\t\t\t\t\t\t\tprocess();\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t// Call an optional hook to record the stack, in case of exception\n\t\t\t\t\t\t\t\t// since it's otherwise lost when execution goes async\n\t\t\t\t\t\t\t\tif ( jQuery.Deferred.getStackHook ) {\n\t\t\t\t\t\t\t\t\tprocess.stackTrace = jQuery.Deferred.getStackHook();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\twindow.setTimeout( process );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn jQuery.Deferred( function( newDefer ) {\n\n\t\t\t\t\t\t// progress_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 0 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tjQuery.isFunction( onProgress ) ?\n\t\t\t\t\t\t\t\t\tonProgress :\n\t\t\t\t\t\t\t\t\tIdentity,\n\t\t\t\t\t\t\t\tnewDefer.notifyWith\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// fulfilled_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 1 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tjQuery.isFunction( onFulfilled ) ?\n\t\t\t\t\t\t\t\t\tonFulfilled :\n\t\t\t\t\t\t\t\t\tIdentity\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// rejected_handlers.add( ... )\n\t\t\t\t\t\ttuples[ 2 ][ 3 ].add(\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tnewDefer,\n\t\t\t\t\t\t\t\tjQuery.isFunction( onRejected ) ?\n\t\t\t\t\t\t\t\t\tonRejected :\n\t\t\t\t\t\t\t\t\tThrower\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} ).promise();\n\t\t\t\t},\n\n\t\t\t\t// Get a promise for this deferred\n\t\t\t\t// If obj is provided, the promise aspect is added to the object\n\t\t\t\tpromise: function( obj ) {\n\t\t\t\t\treturn obj != null ? jQuery.extend( obj, promise ) : promise;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdeferred = {};\n\n\t\t// Add list-specific methods\n\t\tjQuery.each( tuples, function( i, tuple ) {\n\t\t\tvar list = tuple[ 2 ],\n\t\t\t\tstateString = tuple[ 5 ];\n\n\t\t\t// promise.progress = list.add\n\t\t\t// promise.done = list.add\n\t\t\t// promise.fail = list.add\n\t\t\tpromise[ tuple[ 1 ] ] = list.add;\n\n\t\t\t// Handle state\n\t\t\tif ( stateString ) {\n\t\t\t\tlist.add(\n\t\t\t\t\tfunction() {\n\n\t\t\t\t\t\t// state = \"resolved\" (i.e., fulfilled)\n\t\t\t\t\t\t// state = \"rejected\"\n\t\t\t\t\t\tstate = stateString;\n\t\t\t\t\t},\n\n\t\t\t\t\t// rejected_callbacks.disable\n\t\t\t\t\t// fulfilled_callbacks.disable\n\t\t\t\t\ttuples[ 3 - i ][ 2 ].disable,\n\n\t\t\t\t\t// progress_callbacks.lock\n\t\t\t\t\ttuples[ 0 ][ 2 ].lock\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// progress_handlers.fire\n\t\t\t// fulfilled_handlers.fire\n\t\t\t// rejected_handlers.fire\n\t\t\tlist.add( tuple[ 3 ].fire );\n\n\t\t\t// deferred.notify = function() { deferred.notifyWith(...) }\n\t\t\t// deferred.resolve = function() { deferred.resolveWith(...) }\n\t\t\t// deferred.reject = function() { deferred.rejectWith(...) }\n\t\t\tdeferred[ tuple[ 0 ] ] = function() {\n\t\t\t\tdeferred[ tuple[ 0 ] + \"With\" ]( this === deferred ? promise : this, arguments );\n\t\t\t\treturn this;\n\t\t\t};\n\n\t\t\t// deferred.notifyWith = list.fireWith\n\t\t\t// deferred.resolveWith = list.fireWith\n\t\t\t// deferred.rejectWith = list.fireWith\n\t\t\tdeferred[ tuple[ 0 ] + \"With\" ] = list.fireWith;\n\t\t} );\n\n\t\t// Make the deferred a promise\n\t\tpromise.promise( deferred );\n\n\t\t// Call given func if any\n\t\tif ( func ) {\n\t\t\tfunc.call( deferred, deferred );\n\t\t}\n\n\t\t// All done!\n\t\treturn deferred;\n\t},\n\n\t// Deferred helper\n\twhen: function() {\n\t\tvar method, resolveContexts,\n\t\t\ti = 0,\n\t\t\tresolveValues = slice.call( arguments ),\n\t\t\tlength = resolveValues.length,\n\n\t\t\t// the count of uncompleted subordinates\n\t\t\tremaining = length,\n\n\t\t\t// the master Deferred.\n\t\t\tmaster = jQuery.Deferred(),\n\n\t\t\t// Update function for both resolving subordinates\n\t\t\tupdateFunc = function( i ) {\n\t\t\t\treturn function( value ) {\n\t\t\t\t\tresolveContexts[ i ] = this;\n\t\t\t\t\tresolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;\n\t\t\t\t\tif ( !( --remaining ) ) {\n\t\t\t\t\t\tmaster.resolveWith(\n\t\t\t\t\t\t\tresolveContexts.length === 1 ? resolveContexts[ 0 ] : resolveContexts,\n\t\t\t\t\t\t\tresolveValues\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t};\n\n\t\t// Add listeners to promise-like subordinates; treat others as resolved\n\t\tif ( length > 0 ) {\n\t\t\tresolveContexts = new Array( length );\n\t\t\tfor ( ; i < length; i++ ) {\n\n\t\t\t\t// jQuery.Deferred - treated specially to get resolve-sync behavior\n\t\t\t\tif ( resolveValues[ i ] &&\n\t\t\t\t\tjQuery.isFunction( ( method = resolveValues[ i ].promise ) ) ) {\n\n\t\t\t\t\tmethod.call( resolveValues[ i ] )\n\t\t\t\t\t\t.done( updateFunc( i ) )\n\t\t\t\t\t\t.fail( master.reject );\n\n\t\t\t\t// Other thenables\n\t\t\t\t} else if ( resolveValues[ i ] &&\n\t\t\t\t\tjQuery.isFunction( ( method = resolveValues[ i ].then ) ) ) {\n\n\t\t\t\t\tmethod.call(\n\t\t\t\t\t\tresolveValues[ i ],\n\t\t\t\t\t\tupdateFunc( i ),\n\t\t\t\t\t\tmaster.reject\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tupdateFunc( i )( resolveValues[ i ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// If we're not waiting on anything, resolve the master\n\t\t} else {\n\t\t\tmaster.resolveWith();\n\t\t}\n\n\t\treturn master.promise();\n\t}\n} );\n\n\n// These usually indicate a programmer mistake during development,\n// warn about them ASAP rather than swallowing them by default.\nvar rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;\n\njQuery.Deferred.exceptionHook = function( error, stack ) {\n\n\t// Support: IE9\n\t// Console exists when dev tools are open, which can happen at any time\n\tif ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {\n\t\twindow.console.warn( \"jQuery.Deferred exception: \" + error.message, stack );\n\t}\n};\n\n\n\n\n// The deferred used on DOM ready\nvar readyList;\n\njQuery.fn.ready = function( fn ) {\n\n\t// Add the callback\n\tjQuery.ready.promise().done( fn );\n\n\treturn this;\n};\n\njQuery.extend( {\n\n\t// Is the DOM ready to be used? Set to true once it occurs.\n\tisReady: false,\n\n\t// A counter to track how many items to wait for before\n\t// the ready event fires. See #6781\n\treadyWait: 1,\n\n\t// Hold (or release) the ready event\n\tholdReady: function( hold ) {\n\t\tif ( hold ) {\n\t\t\tjQuery.readyWait++;\n\t\t} else {\n\t\t\tjQuery.ready( true );\n\t\t}\n\t},\n\n\t// Handle when the DOM is ready\n\tready: function( wait ) {\n\n\t\t// Abort if there are pending holds or we're already ready\n\t\tif ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Remember that the DOM is ready\n\t\tjQuery.isReady = true;\n\n\t\t// If a normal DOM Ready event fired, decrement, and wait if need be\n\t\tif ( wait !== true && --jQuery.readyWait > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there are functions bound, to execute\n\t\treadyList.resolveWith( document, [ jQuery ] );\n\t}\n} );\n\n/**\n * The ready event handler and self cleanup method\n */\nfunction completed() {\n\tdocument.removeEventListener( \"DOMContentLoaded\", completed );\n\twindow.removeEventListener( \"load\", completed );\n\tjQuery.ready();\n}\n\njQuery.ready.promise = function( obj ) {\n\tif ( !readyList ) {\n\n\t\treadyList = jQuery.Deferred();\n\n\t\t// Catch cases where $(document).ready() is called\n\t\t// after the browser event has already occurred.\n\t\t// Support: IE9-10 only\n\t\t// Older IE sometimes signals \"interactive\" too soon\n\t\tif ( document.readyState === \"complete\" ||\n\t\t\t( document.readyState !== \"loading\" && !document.documentElement.doScroll ) ) {\n\n\t\t\t// Handle it asynchronously to allow scripts the opportunity to delay ready\n\t\t\twindow.setTimeout( jQuery.ready );\n\n\t\t} else {\n\n\t\t\t// Use the handy event callback\n\t\t\tdocument.addEventListener( \"DOMContentLoaded\", completed );\n\n\t\t\t// A fallback to window.onload, that will always work\n\t\t\twindow.addEventListener( \"load\", completed );\n\t\t}\n\t}\n\treturn readyList.promise( obj );\n};\n\n// Kick off the DOM ready check even if the user does not\njQuery.ready.promise();\n\n\n\n\n// Multifunctional method to get and set values of a collection\n// The value/s can optionally be executed if it's a function\nvar access = function( elems, fn, key, value, chainable, emptyGet, raw ) {\n\tvar i = 0,\n\t\tlen = elems.length,\n\t\tbulk = key == null;\n\n\t// Sets many values\n\tif ( jQuery.type( key ) === \"object\" ) {\n\t\tchainable = true;\n\t\tfor ( i in key ) {\n\t\t\taccess( elems, fn, i, key[ i ], true, emptyGet, raw );\n\t\t}\n\n\t// Sets one value\n\t} else if ( value !== undefined ) {\n\t\tchainable = true;\n\n\t\tif ( !jQuery.isFunction( value ) ) {\n\t\t\traw = true;\n\t\t}\n\n\t\tif ( bulk ) {\n\n\t\t\t// Bulk operations run against the entire set\n\t\t\tif ( raw ) {\n\t\t\t\tfn.call( elems, value );\n\t\t\t\tfn = null;\n\n\t\t\t// ...except when executing function values\n\t\t\t} else {\n\t\t\t\tbulk = fn;\n\t\t\t\tfn = function( elem, key, value ) {\n\t\t\t\t\treturn bulk.call( jQuery( elem ), value );\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( fn ) {\n\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\tfn(\n\t\t\t\t\telems[ i ], key, raw ?\n\t\t\t\t\tvalue :\n\t\t\t\t\tvalue.call( elems[ i ], i, fn( elems[ i ], key ) )\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn chainable ?\n\t\telems :\n\n\t\t// Gets\n\t\tbulk ?\n\t\t\tfn.call( elems ) :\n\t\t\tlen ? fn( elems[ 0 ], key ) : emptyGet;\n};\nvar acceptData = function( owner ) {\n\n\t// Accepts only:\n\t//  - Node\n\t//    - Node.ELEMENT_NODE\n\t//    - Node.DOCUMENT_NODE\n\t//  - Object\n\t//    - Any\n\t/* jshint -W018 */\n\treturn owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );\n};\n\n\n\n\nfunction Data() {\n\tthis.expando = jQuery.expando + Data.uid++;\n}\n\nData.uid = 1;\n\nData.prototype = {\n\n\tcache: function( owner ) {\n\n\t\t// Check if the owner object already has a cache\n\t\tvar value = owner[ this.expando ];\n\n\t\t// If not, create one\n\t\tif ( !value ) {\n\t\t\tvalue = {};\n\n\t\t\t// We can accept data for non-element nodes in modern browsers,\n\t\t\t// but we should not, see #8335.\n\t\t\t// Always return an empty object.\n\t\t\tif ( acceptData( owner ) ) {\n\n\t\t\t\t// If it is a node unlikely to be stringify-ed or looped over\n\t\t\t\t// use plain assignment\n\t\t\t\tif ( owner.nodeType ) {\n\t\t\t\t\towner[ this.expando ] = value;\n\n\t\t\t\t// Otherwise secure it in a non-enumerable property\n\t\t\t\t// configurable must be true to allow the property to be\n\t\t\t\t// deleted when data is removed\n\t\t\t\t} else {\n\t\t\t\t\tObject.defineProperty( owner, this.expando, {\n\t\t\t\t\t\tvalue: value,\n\t\t\t\t\t\tconfigurable: true\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t},\n\tset: function( owner, data, value ) {\n\t\tvar prop,\n\t\t\tcache = this.cache( owner );\n\n\t\t// Handle: [ owner, key, value ] args\n\t\t// Always use camelCase key (gh-2257)\n\t\tif ( typeof data === \"string\" ) {\n\t\t\tcache[ jQuery.camelCase( data ) ] = value;\n\n\t\t// Handle: [ owner, { properties } ] args\n\t\t} else {\n\n\t\t\t// Copy the properties one-by-one to the cache object\n\t\t\tfor ( prop in data ) {\n\t\t\t\tcache[ jQuery.camelCase( prop ) ] = data[ prop ];\n\t\t\t}\n\t\t}\n\t\treturn cache;\n\t},\n\tget: function( owner, key ) {\n\t\treturn key === undefined ?\n\t\t\tthis.cache( owner ) :\n\n\t\t\t// Always use camelCase key (gh-2257)\n\t\t\towner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];\n\t},\n\taccess: function( owner, key, value ) {\n\n\t\t// In cases where either:\n\t\t//\n\t\t//   1. No key was specified\n\t\t//   2. A string key was specified, but no value provided\n\t\t//\n\t\t// Take the \"read\" path and allow the get method to determine\n\t\t// which value to return, respectively either:\n\t\t//\n\t\t//   1. The entire cache object\n\t\t//   2. The data stored at the key\n\t\t//\n\t\tif ( key === undefined ||\n\t\t\t\t( ( key && typeof key === \"string\" ) && value === undefined ) ) {\n\n\t\t\treturn this.get( owner, key );\n\t\t}\n\n\t\t// When the key is not a string, or both a key and value\n\t\t// are specified, set or extend (existing objects) with either:\n\t\t//\n\t\t//   1. An object of properties\n\t\t//   2. A key and value\n\t\t//\n\t\tthis.set( owner, key, value );\n\n\t\t// Since the \"set\" path can have two possible entry points\n\t\t// return the expected data based on which path was taken[*]\n\t\treturn value !== undefined ? value : key;\n\t},\n\tremove: function( owner, key ) {\n\t\tvar i,\n\t\t\tcache = owner[ this.expando ];\n\n\t\tif ( cache === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( key !== undefined ) {\n\n\t\t\t// Support array or space separated string of keys\n\t\t\tif ( jQuery.isArray( key ) ) {\n\n\t\t\t\t// If key is an array of keys...\n\t\t\t\t// We always set camelCase keys, so remove that.\n\t\t\t\tkey = key.map( jQuery.camelCase );\n\t\t\t} else {\n\t\t\t\tkey = jQuery.camelCase( key );\n\n\t\t\t\t// If a key with the spaces exists, use it.\n\t\t\t\t// Otherwise, create an array by matching non-whitespace\n\t\t\t\tkey = key in cache ?\n\t\t\t\t\t[ key ] :\n\t\t\t\t\t( key.match( rnotwhite ) || [] );\n\t\t\t}\n\n\t\t\ti = key.length;\n\n\t\t\twhile ( i-- ) {\n\t\t\t\tdelete cache[ key[ i ] ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove the expando if there's no more data\n\t\tif ( key === undefined || jQuery.isEmptyObject( cache ) ) {\n\n\t\t\t// Support: Chrome <= 35-45+\n\t\t\t// Webkit & Blink performance suffers when deleting properties\n\t\t\t// from DOM nodes, so set to undefined instead\n\t\t\t// https://code.google.com/p/chromium/issues/detail?id=378607\n\t\t\tif ( owner.nodeType ) {\n\t\t\t\towner[ this.expando ] = undefined;\n\t\t\t} else {\n\t\t\t\tdelete owner[ this.expando ];\n\t\t\t}\n\t\t}\n\t},\n\thasData: function( owner ) {\n\t\tvar cache = owner[ this.expando ];\n\t\treturn cache !== undefined && !jQuery.isEmptyObject( cache );\n\t}\n};\nvar dataPriv = new Data();\n\nvar dataUser = new Data();\n\n\n\n//\tImplementation Summary\n//\n//\t1. Enforce API surface and semantic compatibility with 1.9.x branch\n//\t2. Improve the module's maintainability by reducing the storage\n//\t\tpaths to a single mechanism.\n//\t3. Use the same single mechanism to support \"private\" and \"user\" data.\n//\t4. _Never_ expose \"private\" data to user code (TODO: Drop _data, _removeData)\n//\t5. Avoid exposing implementation details on user objects (eg. expando properties)\n//\t6. Provide a clear path for implementation upgrade to WeakMap in 2014\n\nvar rbrace = /^(?:\\{[\\w\\W]*\\}|\\[[\\w\\W]*\\])$/,\n\trmultiDash = /[A-Z]/g;\n\nfunction dataAttr( elem, key, data ) {\n\tvar name;\n\n\t// If nothing was found internally, try to fetch any\n\t// data from the HTML5 data-* attribute\n\tif ( data === undefined && elem.nodeType === 1 ) {\n\t\tname = \"data-\" + key.replace( rmultiDash, \"-$&\" ).toLowerCase();\n\t\tdata = elem.getAttribute( name );\n\n\t\tif ( typeof data === \"string\" ) {\n\t\t\ttry {\n\t\t\t\tdata = data === \"true\" ? true :\n\t\t\t\t\tdata === \"false\" ? false :\n\t\t\t\t\tdata === \"null\" ? null :\n\n\t\t\t\t\t// Only convert to a number if it doesn't change the string\n\t\t\t\t\t+data + \"\" === data ? +data :\n\t\t\t\t\trbrace.test( data ) ? jQuery.parseJSON( data ) :\n\t\t\t\t\tdata;\n\t\t\t} catch ( e ) {}\n\n\t\t\t// Make sure we set the data so it isn't changed later\n\t\t\tdataUser.set( elem, key, data );\n\t\t} else {\n\t\t\tdata = undefined;\n\t\t}\n\t}\n\treturn data;\n}\n\njQuery.extend( {\n\thasData: function( elem ) {\n\t\treturn dataUser.hasData( elem ) || dataPriv.hasData( elem );\n\t},\n\n\tdata: function( elem, name, data ) {\n\t\treturn dataUser.access( elem, name, data );\n\t},\n\n\tremoveData: function( elem, name ) {\n\t\tdataUser.remove( elem, name );\n\t},\n\n\t// TODO: Now that all calls to _data and _removeData have been replaced\n\t// with direct calls to dataPriv methods, these can be deprecated.\n\t_data: function( elem, name, data ) {\n\t\treturn dataPriv.access( elem, name, data );\n\t},\n\n\t_removeData: function( elem, name ) {\n\t\tdataPriv.remove( elem, name );\n\t}\n} );\n\njQuery.fn.extend( {\n\tdata: function( key, value ) {\n\t\tvar i, name, data,\n\t\t\telem = this[ 0 ],\n\t\t\tattrs = elem && elem.attributes;\n\n\t\t// Gets all values\n\t\tif ( key === undefined ) {\n\t\t\tif ( this.length ) {\n\t\t\t\tdata = dataUser.get( elem );\n\n\t\t\t\tif ( elem.nodeType === 1 && !dataPriv.get( elem, \"hasDataAttrs\" ) ) {\n\t\t\t\t\ti = attrs.length;\n\t\t\t\t\twhile ( i-- ) {\n\n\t\t\t\t\t\t// Support: IE11+\n\t\t\t\t\t\t// The attrs elements can be null (#14894)\n\t\t\t\t\t\tif ( attrs[ i ] ) {\n\t\t\t\t\t\t\tname = attrs[ i ].name;\n\t\t\t\t\t\t\tif ( name.indexOf( \"data-\" ) === 0 ) {\n\t\t\t\t\t\t\t\tname = jQuery.camelCase( name.slice( 5 ) );\n\t\t\t\t\t\t\t\tdataAttr( elem, name, data[ name ] );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdataPriv.set( elem, \"hasDataAttrs\", true );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\n\t\t// Sets multiple values\n\t\tif ( typeof key === \"object\" ) {\n\t\t\treturn this.each( function() {\n\t\t\t\tdataUser.set( this, key );\n\t\t\t} );\n\t\t}\n\n\t\treturn access( this, function( value ) {\n\t\t\tvar data;\n\n\t\t\t// The calling jQuery object (element matches) is not empty\n\t\t\t// (and therefore has an element appears at this[ 0 ]) and the\n\t\t\t// `value` parameter was not undefined. An empty jQuery object\n\t\t\t// will result in `undefined` for elem = this[ 0 ] which will\n\t\t\t// throw an exception if an attempt to read a data cache is made.\n\t\t\tif ( elem && value === undefined ) {\n\n\t\t\t\t// Attempt to get data from the cache\n\t\t\t\t// The key will always be camelCased in Data\n\t\t\t\tdata = dataUser.get( elem, key );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// Attempt to \"discover\" the data in\n\t\t\t\t// HTML5 custom data-* attrs\n\t\t\t\tdata = dataAttr( elem, key );\n\t\t\t\tif ( data !== undefined ) {\n\t\t\t\t\treturn data;\n\t\t\t\t}\n\n\t\t\t\t// We tried really hard, but the data doesn't exist.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set the data...\n\t\t\tthis.each( function() {\n\n\t\t\t\t// We always store the camelCased key\n\t\t\t\tdataUser.set( this, key, value );\n\t\t\t} );\n\t\t}, null, value, arguments.length > 1, null, true );\n\t},\n\n\tremoveData: function( key ) {\n\t\treturn this.each( function() {\n\t\t\tdataUser.remove( this, key );\n\t\t} );\n\t}\n} );\n\n\njQuery.extend( {\n\tqueue: function( elem, type, data ) {\n\t\tvar queue;\n\n\t\tif ( elem ) {\n\t\t\ttype = ( type || \"fx\" ) + \"queue\";\n\t\t\tqueue = dataPriv.get( elem, type );\n\n\t\t\t// Speed up dequeue by getting out quickly if this is just a lookup\n\t\t\tif ( data ) {\n\t\t\t\tif ( !queue || jQuery.isArray( data ) ) {\n\t\t\t\t\tqueue = dataPriv.access( elem, type, jQuery.makeArray( data ) );\n\t\t\t\t} else {\n\t\t\t\t\tqueue.push( data );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn queue || [];\n\t\t}\n\t},\n\n\tdequeue: function( elem, type ) {\n\t\ttype = type || \"fx\";\n\n\t\tvar queue = jQuery.queue( elem, type ),\n\t\t\tstartLength = queue.length,\n\t\t\tfn = queue.shift(),\n\t\t\thooks = jQuery._queueHooks( elem, type ),\n\t\t\tnext = function() {\n\t\t\t\tjQuery.dequeue( elem, type );\n\t\t\t};\n\n\t\t// If the fx queue is dequeued, always remove the progress sentinel\n\t\tif ( fn === \"inprogress\" ) {\n\t\t\tfn = queue.shift();\n\t\t\tstartLength--;\n\t\t}\n\n\t\tif ( fn ) {\n\n\t\t\t// Add a progress sentinel to prevent the fx queue from being\n\t\t\t// automatically dequeued\n\t\t\tif ( type === \"fx\" ) {\n\t\t\t\tqueue.unshift( \"inprogress\" );\n\t\t\t}\n\n\t\t\t// Clear up the last queue stop function\n\t\t\tdelete hooks.stop;\n\t\t\tfn.call( elem, next, hooks );\n\t\t}\n\n\t\tif ( !startLength && hooks ) {\n\t\t\thooks.empty.fire();\n\t\t}\n\t},\n\n\t// Not public - generate a queueHooks object, or return the current one\n\t_queueHooks: function( elem, type ) {\n\t\tvar key = type + \"queueHooks\";\n\t\treturn dataPriv.get( elem, key ) || dataPriv.access( elem, key, {\n\t\t\tempty: jQuery.Callbacks( \"once memory\" ).add( function() {\n\t\t\t\tdataPriv.remove( elem, [ type + \"queue\", key ] );\n\t\t\t} )\n\t\t} );\n\t}\n} );\n\njQuery.fn.extend( {\n\tqueue: function( type, data ) {\n\t\tvar setter = 2;\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tdata = type;\n\t\t\ttype = \"fx\";\n\t\t\tsetter--;\n\t\t}\n\n\t\tif ( arguments.length < setter ) {\n\t\t\treturn jQuery.queue( this[ 0 ], type );\n\t\t}\n\n\t\treturn data === undefined ?\n\t\t\tthis :\n\t\t\tthis.each( function() {\n\t\t\t\tvar queue = jQuery.queue( this, type, data );\n\n\t\t\t\t// Ensure a hooks for this queue\n\t\t\t\tjQuery._queueHooks( this, type );\n\n\t\t\t\tif ( type === \"fx\" && queue[ 0 ] !== \"inprogress\" ) {\n\t\t\t\t\tjQuery.dequeue( this, type );\n\t\t\t\t}\n\t\t\t} );\n\t},\n\tdequeue: function( type ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.dequeue( this, type );\n\t\t} );\n\t},\n\tclearQueue: function( type ) {\n\t\treturn this.queue( type || \"fx\", [] );\n\t},\n\n\t// Get a promise resolved when queues of a certain type\n\t// are emptied (fx is the type by default)\n\tpromise: function( type, obj ) {\n\t\tvar tmp,\n\t\t\tcount = 1,\n\t\t\tdefer = jQuery.Deferred(),\n\t\t\telements = this,\n\t\t\ti = this.length,\n\t\t\tresolve = function() {\n\t\t\t\tif ( !( --count ) ) {\n\t\t\t\t\tdefer.resolveWith( elements, [ elements ] );\n\t\t\t\t}\n\t\t\t};\n\n\t\tif ( typeof type !== \"string\" ) {\n\t\t\tobj = type;\n\t\t\ttype = undefined;\n\t\t}\n\t\ttype = type || \"fx\";\n\n\t\twhile ( i-- ) {\n\t\t\ttmp = dataPriv.get( elements[ i ], type + \"queueHooks\" );\n\t\t\tif ( tmp && tmp.empty ) {\n\t\t\t\tcount++;\n\t\t\t\ttmp.empty.add( resolve );\n\t\t\t}\n\t\t}\n\t\tresolve();\n\t\treturn defer.promise( obj );\n\t}\n} );\nvar pnum = ( /[+-]?(?:\\d*\\.|)\\d+(?:[eE][+-]?\\d+|)/ ).source;\n\nvar rcssNum = new RegExp( \"^(?:([+-])=|)(\" + pnum + \")([a-z%]*)$\", \"i\" );\n\n\nvar cssExpand = [ \"Top\", \"Right\", \"Bottom\", \"Left\" ];\n\nvar isHidden = function( elem, el ) {\n\n\t\t// isHidden might be called from jQuery#filter function;\n\t\t// in that case, element will be second argument\n\t\telem = el || elem;\n\t\treturn jQuery.css( elem, \"display\" ) === \"none\" ||\n\t\t\t!jQuery.contains( elem.ownerDocument, elem );\n\t};\n\nvar swap = function( elem, options, callback, args ) {\n\tvar ret, name,\n\t\told = {};\n\n\t// Remember the old values, and insert the new ones\n\tfor ( name in options ) {\n\t\told[ name ] = elem.style[ name ];\n\t\telem.style[ name ] = options[ name ];\n\t}\n\n\tret = callback.apply( elem, args || [] );\n\n\t// Revert the old values\n\tfor ( name in options ) {\n\t\telem.style[ name ] = old[ name ];\n\t}\n\n\treturn ret;\n};\n\n\n\n\nfunction adjustCSS( elem, prop, valueParts, tween ) {\n\tvar adjusted,\n\t\tscale = 1,\n\t\tmaxIterations = 20,\n\t\tcurrentValue = tween ?\n\t\t\tfunction() { return tween.cur(); } :\n\t\t\tfunction() { return jQuery.css( elem, prop, \"\" ); },\n\t\tinitial = currentValue(),\n\t\tunit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? \"\" : \"px\" ),\n\n\t\t// Starting value computation is required for potential unit mismatches\n\t\tinitialInUnit = ( jQuery.cssNumber[ prop ] || unit !== \"px\" && +initial ) &&\n\t\t\trcssNum.exec( jQuery.css( elem, prop ) );\n\n\tif ( initialInUnit && initialInUnit[ 3 ] !== unit ) {\n\n\t\t// Trust units reported by jQuery.css\n\t\tunit = unit || initialInUnit[ 3 ];\n\n\t\t// Make sure we update the tween properties later on\n\t\tvalueParts = valueParts || [];\n\n\t\t// Iteratively approximate from a nonzero starting point\n\t\tinitialInUnit = +initial || 1;\n\n\t\tdo {\n\n\t\t\t// If previous iteration zeroed out, double until we get *something*.\n\t\t\t// Use string for doubling so we don't accidentally see scale as unchanged below\n\t\t\tscale = scale || \".5\";\n\n\t\t\t// Adjust and apply\n\t\t\tinitialInUnit = initialInUnit / scale;\n\t\t\tjQuery.style( elem, prop, initialInUnit + unit );\n\n\t\t// Update scale, tolerating zero or NaN from tween.cur()\n\t\t// Break the loop if scale is unchanged or perfect, or if we've just had enough.\n\t\t} while (\n\t\t\tscale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations\n\t\t);\n\t}\n\n\tif ( valueParts ) {\n\t\tinitialInUnit = +initialInUnit || +initial || 0;\n\n\t\t// Apply relative offset (+=/-=) if specified\n\t\tadjusted = valueParts[ 1 ] ?\n\t\t\tinitialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :\n\t\t\t+valueParts[ 2 ];\n\t\tif ( tween ) {\n\t\t\ttween.unit = unit;\n\t\t\ttween.start = initialInUnit;\n\t\t\ttween.end = adjusted;\n\t\t}\n\t}\n\treturn adjusted;\n}\n\n\nvar defaultDisplayMap = {};\n\nfunction getDefaultDisplay( elem ) {\n\tvar temp,\n\t\tdoc = elem.ownerDocument,\n\t\tnodeName = elem.nodeName,\n\t\tdisplay = defaultDisplayMap[ nodeName ];\n\n\tif ( display ) {\n\t\treturn display;\n\t}\n\n\ttemp = doc.body.appendChild( doc.createElement( nodeName ) ),\n\tdisplay = jQuery.css( temp, \"display\" );\n\n\ttemp.parentNode.removeChild( temp );\n\n\tif ( display === \"none\" ) {\n\t\tdisplay = \"block\";\n\t}\n\tdefaultDisplayMap[ nodeName ] = display;\n\n\treturn display;\n}\n\nfunction showHide( elements, show ) {\n\tvar display, elem,\n\t\tvalues = [],\n\t\tindex = 0,\n\t\tlength = elements.length;\n\n\t// Determine new display value for elements that need to change\n\tfor ( ; index < length; index++ ) {\n\t\telem = elements[ index ];\n\t\tif ( !elem.style ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tdisplay = elem.style.display;\n\t\tif ( show ) {\n\n\t\t\t// Since we force visibility upon cascade-hidden elements, an immediate (and slow)\n\t\t\t// check is required in this first loop unless we have a nonempty display value (either\n\t\t\t// inline or about-to-be-restored)\n\t\t\tif ( display === \"none\" ) {\n\t\t\t\tvalues[ index ] = dataPriv.get( elem, \"display\" ) || null;\n\t\t\t\tif ( !values[ index ] ) {\n\t\t\t\t\telem.style.display = \"\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( elem.style.display === \"\" && jQuery.css( elem, \"display\" ) === \"none\" &&\n\n\t\t\t\t\t// Support: Firefox <=42 - 43\n\t\t\t\t\t// Don't set inline display on disconnected elements with computed display: none\n\t\t\t\t\tjQuery.contains( elem.ownerDocument, elem ) ) {\n\n\t\t\t\tvalues[ index ] = getDefaultDisplay( elem );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( display !== \"none\" ) {\n\t\t\t\tvalues[ index ] = \"none\";\n\n\t\t\t\t// Remember what we're overwriting\n\t\t\t\tdataPriv.set( elem, \"display\", display );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Set the display of the elements in a second loop to avoid constant reflow\n\tfor ( index = 0; index < length; index++ ) {\n\t\tif ( values[ index ] != null ) {\n\t\t\telements[ index ].style.display = values[ index ];\n\t\t}\n\t}\n\n\treturn elements;\n}\n\njQuery.fn.extend( {\n\tshow: function() {\n\t\treturn showHide( this, true );\n\t},\n\thide: function() {\n\t\treturn showHide( this );\n\t},\n\ttoggle: function( state ) {\n\t\tif ( typeof state === \"boolean\" ) {\n\t\t\treturn state ? this.show() : this.hide();\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tif ( isHidden( this ) ) {\n\t\t\t\tjQuery( this ).show();\n\t\t\t} else {\n\t\t\t\tjQuery( this ).hide();\n\t\t\t}\n\t\t} );\n\t}\n} );\nvar rcheckableType = ( /^(?:checkbox|radio)$/i );\n\nvar rtagName = ( /<([a-z][^\\/\\0>\\x20\\t\\r\\n\\f]+)/i );\n\nvar rscriptType = ( /^$|\\/(?:java|ecma)script/i );\n\n\n\n// We have to close these tags to support XHTML (#13200)\nvar wrapMap = {\n\n\t// Support: IE9\n\toption: [ 1, \"<select multiple='multiple'>\", \"</select>\" ],\n\n\t// XHTML parsers do not magically insert elements in the\n\t// same way that tag soup parsers do. So we cannot shorten\n\t// this by omitting <tbody> or other required elements.\n\tthead: [ 1, \"<table>\", \"</table>\" ],\n\tcol: [ 2, \"<table><colgroup>\", \"</colgroup></table>\" ],\n\ttr: [ 2, \"<table><tbody>\", \"</tbody></table>\" ],\n\ttd: [ 3, \"<table><tbody><tr>\", \"</tr></tbody></table>\" ],\n\n\t_default: [ 0, \"\", \"\" ]\n};\n\n// Support: IE9\nwrapMap.optgroup = wrapMap.option;\n\nwrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;\nwrapMap.th = wrapMap.td;\n\n\nfunction getAll( context, tag ) {\n\n\t// Support: IE9-11+\n\t// Use typeof to avoid zero-argument method invocation on host objects (#15151)\n\tvar ret = typeof context.getElementsByTagName !== \"undefined\" ?\n\t\t\tcontext.getElementsByTagName( tag || \"*\" ) :\n\t\t\ttypeof context.querySelectorAll !== \"undefined\" ?\n\t\t\t\tcontext.querySelectorAll( tag || \"*\" ) :\n\t\t\t[];\n\n\treturn tag === undefined || tag && jQuery.nodeName( context, tag ) ?\n\t\tjQuery.merge( [ context ], ret ) :\n\t\tret;\n}\n\n\n// Mark scripts as having already been evaluated\nfunction setGlobalEval( elems, refElements ) {\n\tvar i = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\tdataPriv.set(\n\t\t\telems[ i ],\n\t\t\t\"globalEval\",\n\t\t\t!refElements || dataPriv.get( refElements[ i ], \"globalEval\" )\n\t\t);\n\t}\n}\n\n\nvar rhtml = /<|&#?\\w+;/;\n\nfunction buildFragment( elems, context, scripts, selection, ignored ) {\n\tvar elem, tmp, tag, wrap, contains, j,\n\t\tfragment = context.createDocumentFragment(),\n\t\tnodes = [],\n\t\ti = 0,\n\t\tl = elems.length;\n\n\tfor ( ; i < l; i++ ) {\n\t\telem = elems[ i ];\n\n\t\tif ( elem || elem === 0 ) {\n\n\t\t\t// Add nodes directly\n\t\t\tif ( jQuery.type( elem ) === \"object\" ) {\n\n\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );\n\n\t\t\t// Convert non-html into a text node\n\t\t\t} else if ( !rhtml.test( elem ) ) {\n\t\t\t\tnodes.push( context.createTextNode( elem ) );\n\n\t\t\t// Convert html into DOM nodes\n\t\t\t} else {\n\t\t\t\ttmp = tmp || fragment.appendChild( context.createElement( \"div\" ) );\n\n\t\t\t\t// Deserialize a standard representation\n\t\t\t\ttag = ( rtagName.exec( elem ) || [ \"\", \"\" ] )[ 1 ].toLowerCase();\n\t\t\t\twrap = wrapMap[ tag ] || wrapMap._default;\n\t\t\t\ttmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];\n\n\t\t\t\t// Descend through wrappers to the right content\n\t\t\t\tj = wrap[ 0 ];\n\t\t\t\twhile ( j-- ) {\n\t\t\t\t\ttmp = tmp.lastChild;\n\t\t\t\t}\n\n\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\tjQuery.merge( nodes, tmp.childNodes );\n\n\t\t\t\t// Remember the top-level container\n\t\t\t\ttmp = fragment.firstChild;\n\n\t\t\t\t// Ensure the created nodes are orphaned (#12392)\n\t\t\t\ttmp.textContent = \"\";\n\t\t\t}\n\t\t}\n\t}\n\n\t// Remove wrapper from fragment\n\tfragment.textContent = \"\";\n\n\ti = 0;\n\twhile ( ( elem = nodes[ i++ ] ) ) {\n\n\t\t// Skip elements already in the context collection (trac-4087)\n\t\tif ( selection && jQuery.inArray( elem, selection ) > -1 ) {\n\t\t\tif ( ignored ) {\n\t\t\t\tignored.push( elem );\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tcontains = jQuery.contains( elem.ownerDocument, elem );\n\n\t\t// Append to fragment\n\t\ttmp = getAll( fragment.appendChild( elem ), \"script\" );\n\n\t\t// Preserve script evaluation history\n\t\tif ( contains ) {\n\t\t\tsetGlobalEval( tmp );\n\t\t}\n\n\t\t// Capture executables\n\t\tif ( scripts ) {\n\t\t\tj = 0;\n\t\t\twhile ( ( elem = tmp[ j++ ] ) ) {\n\t\t\t\tif ( rscriptType.test( elem.type || \"\" ) ) {\n\t\t\t\t\tscripts.push( elem );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn fragment;\n}\n\n\n( function() {\n\tvar fragment = document.createDocumentFragment(),\n\t\tdiv = fragment.appendChild( document.createElement( \"div\" ) ),\n\t\tinput = document.createElement( \"input\" );\n\n\t// Support: Android 4.0-4.3\n\t// Check state lost if the name is set (#11217)\n\t// Support: Windows Web Apps (WWA)\n\t// `name` and `type` must use .setAttribute for WWA (#14901)\n\tinput.setAttribute( \"type\", \"radio\" );\n\tinput.setAttribute( \"checked\", \"checked\" );\n\tinput.setAttribute( \"name\", \"t\" );\n\n\tdiv.appendChild( input );\n\n\t// Support: Android<4.2\n\t// Older WebKit doesn't clone checked state correctly in fragments\n\tsupport.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;\n\n\t// Support: IE<=11+\n\t// Make sure textarea (and checkbox) defaultValue is properly cloned\n\tdiv.innerHTML = \"<textarea>x</textarea>\";\n\tsupport.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;\n} )();\n\n\nvar\n\trkeyEvent = /^key/,\n\trmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,\n\trtypenamespace = /^([^.]*)(?:\\.(.+)|)/;\n\nfunction returnTrue() {\n\treturn true;\n}\n\nfunction returnFalse() {\n\treturn false;\n}\n\n// Support: IE9\n// See #13393 for more info\nfunction safeActiveElement() {\n\ttry {\n\t\treturn document.activeElement;\n\t} catch ( err ) { }\n}\n\nfunction on( elem, types, selector, data, fn, one ) {\n\tvar origFn, type;\n\n\t// Types can be a map of types/handlers\n\tif ( typeof types === \"object\" ) {\n\n\t\t// ( types-Object, selector, data )\n\t\tif ( typeof selector !== \"string\" ) {\n\n\t\t\t// ( types-Object, data )\n\t\t\tdata = data || selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tfor ( type in types ) {\n\t\t\ton( elem, type, selector, data, types[ type ], one );\n\t\t}\n\t\treturn elem;\n\t}\n\n\tif ( data == null && fn == null ) {\n\n\t\t// ( types, fn )\n\t\tfn = selector;\n\t\tdata = selector = undefined;\n\t} else if ( fn == null ) {\n\t\tif ( typeof selector === \"string\" ) {\n\n\t\t\t// ( types, selector, fn )\n\t\t\tfn = data;\n\t\t\tdata = undefined;\n\t\t} else {\n\n\t\t\t// ( types, data, fn )\n\t\t\tfn = data;\n\t\t\tdata = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t}\n\tif ( fn === false ) {\n\t\tfn = returnFalse;\n\t}\n\n\tif ( one === 1 ) {\n\t\torigFn = fn;\n\t\tfn = function( event ) {\n\n\t\t\t// Can use an empty set, since event contains the info\n\t\t\tjQuery().off( event );\n\t\t\treturn origFn.apply( this, arguments );\n\t\t};\n\n\t\t// Use same guid so caller can remove using origFn\n\t\tfn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );\n\t}\n\treturn elem.each( function() {\n\t\tjQuery.event.add( this, types, fn, data, selector );\n\t} );\n}\n\n/*\n * Helper functions for managing events -- not part of the public interface.\n * Props to Dean Edwards' addEvent library for many of the ideas.\n */\njQuery.event = {\n\n\tglobal: {},\n\n\tadd: function( elem, types, handler, data, selector ) {\n\n\t\tvar handleObjIn, eventHandle, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.get( elem );\n\n\t\t// Don't attach events to noData or text/comment nodes (but allow plain objects)\n\t\tif ( !elemData ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Caller can pass in an object of custom data in lieu of the handler\n\t\tif ( handler.handler ) {\n\t\t\thandleObjIn = handler;\n\t\t\thandler = handleObjIn.handler;\n\t\t\tselector = handleObjIn.selector;\n\t\t}\n\n\t\t// Make sure that the handler has a unique ID, used to find/remove it later\n\t\tif ( !handler.guid ) {\n\t\t\thandler.guid = jQuery.guid++;\n\t\t}\n\n\t\t// Init the element's event structure and main handler, if this is the first\n\t\tif ( !( events = elemData.events ) ) {\n\t\t\tevents = elemData.events = {};\n\t\t}\n\t\tif ( !( eventHandle = elemData.handle ) ) {\n\t\t\teventHandle = elemData.handle = function( e ) {\n\n\t\t\t\t// Discard the second event of a jQuery.event.trigger() and\n\t\t\t\t// when an event is called after a page has unloaded\n\t\t\t\treturn typeof jQuery !== \"undefined\" && jQuery.event.triggered !== e.type ?\n\t\t\t\t\tjQuery.event.dispatch.apply( elem, arguments ) : undefined;\n\t\t\t};\n\t\t}\n\n\t\t// Handle multiple events separated by a space\n\t\ttypes = ( types || \"\" ).match( rnotwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// There *must* be a type, no attaching namespace-only handlers\n\t\t\tif ( !type ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If event changes its type, use the special event handlers for the changed type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// If selector defined, determine special event api type, otherwise given type\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\n\t\t\t// Update special based on newly reset type\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\n\t\t\t// handleObj is passed to all event handlers\n\t\t\thandleObj = jQuery.extend( {\n\t\t\t\ttype: type,\n\t\t\t\torigType: origType,\n\t\t\t\tdata: data,\n\t\t\t\thandler: handler,\n\t\t\t\tguid: handler.guid,\n\t\t\t\tselector: selector,\n\t\t\t\tneedsContext: selector && jQuery.expr.match.needsContext.test( selector ),\n\t\t\t\tnamespace: namespaces.join( \".\" )\n\t\t\t}, handleObjIn );\n\n\t\t\t// Init the event handler queue if we're the first\n\t\t\tif ( !( handlers = events[ type ] ) ) {\n\t\t\t\thandlers = events[ type ] = [];\n\t\t\t\thandlers.delegateCount = 0;\n\n\t\t\t\t// Only use addEventListener if the special events handler returns false\n\t\t\t\tif ( !special.setup ||\n\t\t\t\t\tspecial.setup.call( elem, data, namespaces, eventHandle ) === false ) {\n\n\t\t\t\t\tif ( elem.addEventListener ) {\n\t\t\t\t\t\telem.addEventListener( type, eventHandle );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( special.add ) {\n\t\t\t\tspecial.add.call( elem, handleObj );\n\n\t\t\t\tif ( !handleObj.handler.guid ) {\n\t\t\t\t\thandleObj.handler.guid = handler.guid;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add to the element's handler list, delegates in front\n\t\t\tif ( selector ) {\n\t\t\t\thandlers.splice( handlers.delegateCount++, 0, handleObj );\n\t\t\t} else {\n\t\t\t\thandlers.push( handleObj );\n\t\t\t}\n\n\t\t\t// Keep track of which events have ever been used, for event optimization\n\t\t\tjQuery.event.global[ type ] = true;\n\t\t}\n\n\t},\n\n\t// Detach an event or set of events from an element\n\tremove: function( elem, types, handler, selector, mappedTypes ) {\n\n\t\tvar j, origCount, tmp,\n\t\t\tevents, t, handleObj,\n\t\t\tspecial, handlers, type, namespaces, origType,\n\t\t\telemData = dataPriv.hasData( elem ) && dataPriv.get( elem );\n\n\t\tif ( !elemData || !( events = elemData.events ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Once for each type.namespace in types; type may be omitted\n\t\ttypes = ( types || \"\" ).match( rnotwhite ) || [ \"\" ];\n\t\tt = types.length;\n\t\twhile ( t-- ) {\n\t\t\ttmp = rtypenamespace.exec( types[ t ] ) || [];\n\t\t\ttype = origType = tmp[ 1 ];\n\t\t\tnamespaces = ( tmp[ 2 ] || \"\" ).split( \".\" ).sort();\n\n\t\t\t// Unbind all events (on this namespace, if provided) for the element\n\t\t\tif ( !type ) {\n\t\t\t\tfor ( type in events ) {\n\t\t\t\t\tjQuery.event.remove( elem, type + types[ t ], handler, selector, true );\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tspecial = jQuery.event.special[ type ] || {};\n\t\t\ttype = ( selector ? special.delegateType : special.bindType ) || type;\n\t\t\thandlers = events[ type ] || [];\n\t\t\ttmp = tmp[ 2 ] &&\n\t\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" );\n\n\t\t\t// Remove matching events\n\t\t\torigCount = j = handlers.length;\n\t\t\twhile ( j-- ) {\n\t\t\t\thandleObj = handlers[ j ];\n\n\t\t\t\tif ( ( mappedTypes || origType === handleObj.origType ) &&\n\t\t\t\t\t( !handler || handler.guid === handleObj.guid ) &&\n\t\t\t\t\t( !tmp || tmp.test( handleObj.namespace ) ) &&\n\t\t\t\t\t( !selector || selector === handleObj.selector ||\n\t\t\t\t\t\tselector === \"**\" && handleObj.selector ) ) {\n\t\t\t\t\thandlers.splice( j, 1 );\n\n\t\t\t\t\tif ( handleObj.selector ) {\n\t\t\t\t\t\thandlers.delegateCount--;\n\t\t\t\t\t}\n\t\t\t\t\tif ( special.remove ) {\n\t\t\t\t\t\tspecial.remove.call( elem, handleObj );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Remove generic event handler if we removed something and no more handlers exist\n\t\t\t// (avoids potential for endless recursion during removal of special event handlers)\n\t\t\tif ( origCount && !handlers.length ) {\n\t\t\t\tif ( !special.teardown ||\n\t\t\t\t\tspecial.teardown.call( elem, namespaces, elemData.handle ) === false ) {\n\n\t\t\t\t\tjQuery.removeEvent( elem, type, elemData.handle );\n\t\t\t\t}\n\n\t\t\t\tdelete events[ type ];\n\t\t\t}\n\t\t}\n\n\t\t// Remove data and the expando if it's no longer used\n\t\tif ( jQuery.isEmptyObject( events ) ) {\n\t\t\tdataPriv.remove( elem, \"handle events\" );\n\t\t}\n\t},\n\n\tdispatch: function( event ) {\n\n\t\t// Make a writable jQuery.Event from the native event object\n\t\tevent = jQuery.event.fix( event );\n\n\t\tvar i, j, ret, matched, handleObj,\n\t\t\thandlerQueue = [],\n\t\t\targs = slice.call( arguments ),\n\t\t\thandlers = ( dataPriv.get( this, \"events\" ) || {} )[ event.type ] || [],\n\t\t\tspecial = jQuery.event.special[ event.type ] || {};\n\n\t\t// Use the fix-ed jQuery.Event rather than the (read-only) native event\n\t\targs[ 0 ] = event;\n\t\tevent.delegateTarget = this;\n\n\t\t// Call the preDispatch hook for the mapped type, and let it bail if desired\n\t\tif ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine handlers\n\t\thandlerQueue = jQuery.event.handlers.call( this, event, handlers );\n\n\t\t// Run delegates first; they may want to stop propagation beneath us\n\t\ti = 0;\n\t\twhile ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {\n\t\t\tevent.currentTarget = matched.elem;\n\n\t\t\tj = 0;\n\t\t\twhile ( ( handleObj = matched.handlers[ j++ ] ) &&\n\t\t\t\t!event.isImmediatePropagationStopped() ) {\n\n\t\t\t\t// Triggered event must either 1) have no namespace, or 2) have namespace(s)\n\t\t\t\t// a subset or equal to those in the bound event (both can have no namespace).\n\t\t\t\tif ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {\n\n\t\t\t\t\tevent.handleObj = handleObj;\n\t\t\t\t\tevent.data = handleObj.data;\n\n\t\t\t\t\tret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||\n\t\t\t\t\t\thandleObj.handler ).apply( matched.elem, args );\n\n\t\t\t\t\tif ( ret !== undefined ) {\n\t\t\t\t\t\tif ( ( event.result = ret ) === false ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Call the postDispatch hook for the mapped type\n\t\tif ( special.postDispatch ) {\n\t\t\tspecial.postDispatch.call( this, event );\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\thandlers: function( event, handlers ) {\n\t\tvar i, matches, sel, handleObj,\n\t\t\thandlerQueue = [],\n\t\t\tdelegateCount = handlers.delegateCount,\n\t\t\tcur = event.target;\n\n\t\t// Support (at least): Chrome, IE9\n\t\t// Find delegate handlers\n\t\t// Black-hole SVG <use> instance trees (#13180)\n\t\t//\n\t\t// Support: Firefox<=42+\n\t\t// Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)\n\t\tif ( delegateCount && cur.nodeType &&\n\t\t\t( event.type !== \"click\" || isNaN( event.button ) || event.button < 1 ) ) {\n\n\t\t\tfor ( ; cur !== this; cur = cur.parentNode || this ) {\n\n\t\t\t\t// Don't check non-elements (#13208)\n\t\t\t\t// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)\n\t\t\t\tif ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== \"click\" ) ) {\n\t\t\t\t\tmatches = [];\n\t\t\t\t\tfor ( i = 0; i < delegateCount; i++ ) {\n\t\t\t\t\t\thandleObj = handlers[ i ];\n\n\t\t\t\t\t\t// Don't conflict with Object.prototype properties (#13203)\n\t\t\t\t\t\tsel = handleObj.selector + \" \";\n\n\t\t\t\t\t\tif ( matches[ sel ] === undefined ) {\n\t\t\t\t\t\t\tmatches[ sel ] = handleObj.needsContext ?\n\t\t\t\t\t\t\t\tjQuery( sel, this ).index( cur ) > -1 :\n\t\t\t\t\t\t\t\tjQuery.find( sel, this, null, [ cur ] ).length;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( matches[ sel ] ) {\n\t\t\t\t\t\t\tmatches.push( handleObj );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( matches.length ) {\n\t\t\t\t\t\thandlerQueue.push( { elem: cur, handlers: matches } );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add the remaining (directly-bound) handlers\n\t\tif ( delegateCount < handlers.length ) {\n\t\t\thandlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );\n\t\t}\n\n\t\treturn handlerQueue;\n\t},\n\n\t// Includes some event props shared by KeyEvent and MouseEvent\n\tprops: ( \"altKey bubbles cancelable ctrlKey currentTarget detail eventPhase \" +\n\t\t\"metaKey relatedTarget shiftKey target timeStamp view which\" ).split( \" \" ),\n\n\tfixHooks: {},\n\n\tkeyHooks: {\n\t\tprops: \"char charCode key keyCode\".split( \" \" ),\n\t\tfilter: function( event, original ) {\n\n\t\t\t// Add which for key events\n\t\t\tif ( event.which == null ) {\n\t\t\t\tevent.which = original.charCode != null ? original.charCode : original.keyCode;\n\t\t\t}\n\n\t\t\treturn event;\n\t\t}\n\t},\n\n\tmouseHooks: {\n\t\tprops: ( \"button buttons clientX clientY offsetX offsetY pageX pageY \" +\n\t\t\t\"screenX screenY toElement\" ).split( \" \" ),\n\t\tfilter: function( event, original ) {\n\t\t\tvar eventDoc, doc, body,\n\t\t\t\tbutton = original.button;\n\n\t\t\t// Calculate pageX/Y if missing and clientX/Y available\n\t\t\tif ( event.pageX == null && original.clientX != null ) {\n\t\t\t\teventDoc = event.target.ownerDocument || document;\n\t\t\t\tdoc = eventDoc.documentElement;\n\t\t\t\tbody = eventDoc.body;\n\n\t\t\t\tevent.pageX = original.clientX +\n\t\t\t\t\t( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -\n\t\t\t\t\t( doc && doc.clientLeft || body && body.clientLeft || 0 );\n\t\t\t\tevent.pageY = original.clientY +\n\t\t\t\t\t( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) -\n\t\t\t\t\t( doc && doc.clientTop  || body && body.clientTop  || 0 );\n\t\t\t}\n\n\t\t\t// Add which for click: 1 === left; 2 === middle; 3 === right\n\t\t\t// Note: button is not normalized, so don't use it\n\t\t\tif ( !event.which && button !== undefined ) {\n\t\t\t\tevent.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );\n\t\t\t}\n\n\t\t\treturn event;\n\t\t}\n\t},\n\n\tfix: function( event ) {\n\t\tif ( event[ jQuery.expando ] ) {\n\t\t\treturn event;\n\t\t}\n\n\t\t// Create a writable copy of the event object and normalize some properties\n\t\tvar i, prop, copy,\n\t\t\ttype = event.type,\n\t\t\toriginalEvent = event,\n\t\t\tfixHook = this.fixHooks[ type ];\n\n\t\tif ( !fixHook ) {\n\t\t\tthis.fixHooks[ type ] = fixHook =\n\t\t\t\trmouseEvent.test( type ) ? this.mouseHooks :\n\t\t\t\trkeyEvent.test( type ) ? this.keyHooks :\n\t\t\t\t{};\n\t\t}\n\t\tcopy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;\n\n\t\tevent = new jQuery.Event( originalEvent );\n\n\t\ti = copy.length;\n\t\twhile ( i-- ) {\n\t\t\tprop = copy[ i ];\n\t\t\tevent[ prop ] = originalEvent[ prop ];\n\t\t}\n\n\t\t// Support: Safari 6-8+\n\t\t// Target should not be a text node (#504, #13143)\n\t\tif ( event.target.nodeType === 3 ) {\n\t\t\tevent.target = event.target.parentNode;\n\t\t}\n\n\t\treturn fixHook.filter ? fixHook.filter( event, originalEvent ) : event;\n\t},\n\n\tspecial: {\n\t\tload: {\n\n\t\t\t// Prevent triggered image.load events from bubbling to window.load\n\t\t\tnoBubble: true\n\t\t},\n\t\tfocus: {\n\n\t\t\t// Fire native event if possible so blur/focus sequence is correct\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this !== safeActiveElement() && this.focus ) {\n\t\t\t\t\tthis.focus();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelegateType: \"focusin\"\n\t\t},\n\t\tblur: {\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this === safeActiveElement() && this.blur ) {\n\t\t\t\t\tthis.blur();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tdelegateType: \"focusout\"\n\t\t},\n\t\tclick: {\n\n\t\t\t// For checkbox, fire native event so checked state will be right\n\t\t\ttrigger: function() {\n\t\t\t\tif ( this.type === \"checkbox\" && this.click && jQuery.nodeName( this, \"input\" ) ) {\n\t\t\t\t\tthis.click();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// For cross-browser consistency, don't fire native .click() on links\n\t\t\t_default: function( event ) {\n\t\t\t\treturn jQuery.nodeName( event.target, \"a\" );\n\t\t\t}\n\t\t},\n\n\t\tbeforeunload: {\n\t\t\tpostDispatch: function( event ) {\n\n\t\t\t\t// Support: Firefox 20+\n\t\t\t\t// Firefox doesn't alert if the returnValue field is not set.\n\t\t\t\tif ( event.result !== undefined && event.originalEvent ) {\n\t\t\t\t\tevent.originalEvent.returnValue = event.result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\njQuery.removeEvent = function( elem, type, handle ) {\n\n\t// This \"if\" is needed for plain objects\n\tif ( elem.removeEventListener ) {\n\t\telem.removeEventListener( type, handle );\n\t}\n};\n\njQuery.Event = function( src, props ) {\n\n\t// Allow instantiation without the 'new' keyword\n\tif ( !( this instanceof jQuery.Event ) ) {\n\t\treturn new jQuery.Event( src, props );\n\t}\n\n\t// Event object\n\tif ( src && src.type ) {\n\t\tthis.originalEvent = src;\n\t\tthis.type = src.type;\n\n\t\t// Events bubbling up the document may have been marked as prevented\n\t\t// by a handler lower down the tree; reflect the correct value.\n\t\tthis.isDefaultPrevented = src.defaultPrevented ||\n\t\t\t\tsrc.defaultPrevented === undefined &&\n\n\t\t\t\t// Support: Android<4.0\n\t\t\t\tsrc.returnValue === false ?\n\t\t\treturnTrue :\n\t\t\treturnFalse;\n\n\t// Event type\n\t} else {\n\t\tthis.type = src;\n\t}\n\n\t// Put explicitly provided properties onto the event object\n\tif ( props ) {\n\t\tjQuery.extend( this, props );\n\t}\n\n\t// Create a timestamp if incoming event doesn't have one\n\tthis.timeStamp = src && src.timeStamp || jQuery.now();\n\n\t// Mark it as fixed\n\tthis[ jQuery.expando ] = true;\n};\n\n// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding\n// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html\njQuery.Event.prototype = {\n\tconstructor: jQuery.Event,\n\tisDefaultPrevented: returnFalse,\n\tisPropagationStopped: returnFalse,\n\tisImmediatePropagationStopped: returnFalse,\n\n\tpreventDefault: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isDefaultPrevented = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.preventDefault();\n\t\t}\n\t},\n\tstopPropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isPropagationStopped = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.stopPropagation();\n\t\t}\n\t},\n\tstopImmediatePropagation: function() {\n\t\tvar e = this.originalEvent;\n\n\t\tthis.isImmediatePropagationStopped = returnTrue;\n\n\t\tif ( e ) {\n\t\t\te.stopImmediatePropagation();\n\t\t}\n\n\t\tthis.stopPropagation();\n\t}\n};\n\n// Create mouseenter/leave events using mouseover/out and event-time checks\n// so that event delegation works in jQuery.\n// Do the same for pointerenter/pointerleave and pointerover/pointerout\n//\n// Support: Safari 7 only\n// Safari sends mouseenter too often; see:\n// https://code.google.com/p/chromium/issues/detail?id=470258\n// for the description of the bug (it existed in older Chrome versions as well).\njQuery.each( {\n\tmouseenter: \"mouseover\",\n\tmouseleave: \"mouseout\",\n\tpointerenter: \"pointerover\",\n\tpointerleave: \"pointerout\"\n}, function( orig, fix ) {\n\tjQuery.event.special[ orig ] = {\n\t\tdelegateType: fix,\n\t\tbindType: fix,\n\n\t\thandle: function( event ) {\n\t\t\tvar ret,\n\t\t\t\ttarget = this,\n\t\t\t\trelated = event.relatedTarget,\n\t\t\t\thandleObj = event.handleObj;\n\n\t\t\t// For mouseenter/leave call the handler if related is outside the target.\n\t\t\t// NB: No relatedTarget if the mouse left/entered the browser window\n\t\t\tif ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {\n\t\t\t\tevent.type = handleObj.origType;\n\t\t\t\tret = handleObj.handler.apply( this, arguments );\n\t\t\t\tevent.type = fix;\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t};\n} );\n\njQuery.fn.extend( {\n\n\ton: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn );\n\t},\n\tone: function( types, selector, data, fn ) {\n\t\treturn on( this, types, selector, data, fn, 1 );\n\t},\n\toff: function( types, selector, fn ) {\n\t\tvar handleObj, type;\n\t\tif ( types && types.preventDefault && types.handleObj ) {\n\n\t\t\t// ( event )  dispatched jQuery.Event\n\t\t\thandleObj = types.handleObj;\n\t\t\tjQuery( types.delegateTarget ).off(\n\t\t\t\thandleObj.namespace ?\n\t\t\t\t\thandleObj.origType + \".\" + handleObj.namespace :\n\t\t\t\t\thandleObj.origType,\n\t\t\t\thandleObj.selector,\n\t\t\t\thandleObj.handler\n\t\t\t);\n\t\t\treturn this;\n\t\t}\n\t\tif ( typeof types === \"object\" ) {\n\n\t\t\t// ( types-object [, selector] )\n\t\t\tfor ( type in types ) {\n\t\t\t\tthis.off( type, selector, types[ type ] );\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\tif ( selector === false || typeof selector === \"function\" ) {\n\n\t\t\t// ( types [, fn] )\n\t\t\tfn = selector;\n\t\t\tselector = undefined;\n\t\t}\n\t\tif ( fn === false ) {\n\t\t\tfn = returnFalse;\n\t\t}\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.remove( this, types, fn, selector );\n\t\t} );\n\t}\n} );\n\n\nvar\n\trxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\\/\\0>\\x20\\t\\r\\n\\f]*)[^>]*)\\/>/gi,\n\n\t// Support: IE 10-11, Edge 10240+\n\t// In IE/Edge using regex groups here causes severe slowdowns.\n\t// See https://connect.microsoft.com/IE/feedback/details/1736512/\n\trnoInnerhtml = /<script|<style|<link/i,\n\n\t// checked=\"checked\" or checked\n\trchecked = /checked\\s*(?:[^=]|=\\s*.checked.)/i,\n\trscriptTypeMasked = /^true\\/(.*)/,\n\trcleanScript = /^\\s*<!(?:\\[CDATA\\[|--)|(?:\\]\\]|--)>\\s*$/g;\n\nfunction manipulationTarget( elem, content ) {\n\tif ( jQuery.nodeName( elem, \"table\" ) &&\n\t\tjQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, \"tr\" ) ) {\n\n\t\treturn elem.getElementsByTagName( \"tbody\" )[ 0 ] || elem;\n\t}\n\n\treturn elem;\n}\n\n// Replace/restore the type attribute of script elements for safe DOM manipulation\nfunction disableScript( elem ) {\n\telem.type = ( elem.getAttribute( \"type\" ) !== null ) + \"/\" + elem.type;\n\treturn elem;\n}\nfunction restoreScript( elem ) {\n\tvar match = rscriptTypeMasked.exec( elem.type );\n\n\tif ( match ) {\n\t\telem.type = match[ 1 ];\n\t} else {\n\t\telem.removeAttribute( \"type\" );\n\t}\n\n\treturn elem;\n}\n\nfunction cloneCopyEvent( src, dest ) {\n\tvar i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;\n\n\tif ( dest.nodeType !== 1 ) {\n\t\treturn;\n\t}\n\n\t// 1. Copy private data: events, handlers, etc.\n\tif ( dataPriv.hasData( src ) ) {\n\t\tpdataOld = dataPriv.access( src );\n\t\tpdataCur = dataPriv.set( dest, pdataOld );\n\t\tevents = pdataOld.events;\n\n\t\tif ( events ) {\n\t\t\tdelete pdataCur.handle;\n\t\t\tpdataCur.events = {};\n\n\t\t\tfor ( type in events ) {\n\t\t\t\tfor ( i = 0, l = events[ type ].length; i < l; i++ ) {\n\t\t\t\t\tjQuery.event.add( dest, type, events[ type ][ i ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Copy user data\n\tif ( dataUser.hasData( src ) ) {\n\t\tudataOld = dataUser.access( src );\n\t\tudataCur = jQuery.extend( {}, udataOld );\n\n\t\tdataUser.set( dest, udataCur );\n\t}\n}\n\n// Fix IE bugs, see support tests\nfunction fixInput( src, dest ) {\n\tvar nodeName = dest.nodeName.toLowerCase();\n\n\t// Fails to persist the checked state of a cloned checkbox or radio button.\n\tif ( nodeName === \"input\" && rcheckableType.test( src.type ) ) {\n\t\tdest.checked = src.checked;\n\n\t// Fails to return the selected option to the default selected state when cloning options\n\t} else if ( nodeName === \"input\" || nodeName === \"textarea\" ) {\n\t\tdest.defaultValue = src.defaultValue;\n\t}\n}\n\nfunction domManip( collection, args, callback, ignored ) {\n\n\t// Flatten any nested arrays\n\targs = concat.apply( [], args );\n\n\tvar fragment, first, scripts, hasScripts, node, doc,\n\t\ti = 0,\n\t\tl = collection.length,\n\t\tiNoClone = l - 1,\n\t\tvalue = args[ 0 ],\n\t\tisFunction = jQuery.isFunction( value );\n\n\t// We can't cloneNode fragments that contain checked, in WebKit\n\tif ( isFunction ||\n\t\t\t( l > 1 && typeof value === \"string\" &&\n\t\t\t\t!support.checkClone && rchecked.test( value ) ) ) {\n\t\treturn collection.each( function( index ) {\n\t\t\tvar self = collection.eq( index );\n\t\t\tif ( isFunction ) {\n\t\t\t\targs[ 0 ] = value.call( this, index, self.html() );\n\t\t\t}\n\t\t\tdomManip( self, args, callback, ignored );\n\t\t} );\n\t}\n\n\tif ( l ) {\n\t\tfragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );\n\t\tfirst = fragment.firstChild;\n\n\t\tif ( fragment.childNodes.length === 1 ) {\n\t\t\tfragment = first;\n\t\t}\n\n\t\t// Require either new content or an interest in ignored elements to invoke the callback\n\t\tif ( first || ignored ) {\n\t\t\tscripts = jQuery.map( getAll( fragment, \"script\" ), disableScript );\n\t\t\thasScripts = scripts.length;\n\n\t\t\t// Use the original fragment for the last item\n\t\t\t// instead of the first because it can end up\n\t\t\t// being emptied incorrectly in certain situations (#8070).\n\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\tnode = fragment;\n\n\t\t\t\tif ( i !== iNoClone ) {\n\t\t\t\t\tnode = jQuery.clone( node, true, true );\n\n\t\t\t\t\t// Keep references to cloned scripts for later restoration\n\t\t\t\t\tif ( hasScripts ) {\n\n\t\t\t\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t\t\t\t// push.apply(_, arraylike) throws on ancient WebKit\n\t\t\t\t\t\tjQuery.merge( scripts, getAll( node, \"script\" ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tcallback.call( collection[ i ], node, i );\n\t\t\t}\n\n\t\t\tif ( hasScripts ) {\n\t\t\t\tdoc = scripts[ scripts.length - 1 ].ownerDocument;\n\n\t\t\t\t// Reenable scripts\n\t\t\t\tjQuery.map( scripts, restoreScript );\n\n\t\t\t\t// Evaluate executable scripts on first document insertion\n\t\t\t\tfor ( i = 0; i < hasScripts; i++ ) {\n\t\t\t\t\tnode = scripts[ i ];\n\t\t\t\t\tif ( rscriptType.test( node.type || \"\" ) &&\n\t\t\t\t\t\t!dataPriv.access( node, \"globalEval\" ) &&\n\t\t\t\t\t\tjQuery.contains( doc, node ) ) {\n\n\t\t\t\t\t\tif ( node.src ) {\n\n\t\t\t\t\t\t\t// Optional AJAX dependency, but won't run scripts if not present\n\t\t\t\t\t\t\tif ( jQuery._evalUrl ) {\n\t\t\t\t\t\t\t\tjQuery._evalUrl( node.src );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tDOMEval( node.textContent.replace( rcleanScript, \"\" ), doc );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn collection;\n}\n\nfunction remove( elem, selector, keepData ) {\n\tvar node,\n\t\tnodes = selector ? jQuery.filter( selector, elem ) : elem,\n\t\ti = 0;\n\n\tfor ( ; ( node = nodes[ i ] ) != null; i++ ) {\n\t\tif ( !keepData && node.nodeType === 1 ) {\n\t\t\tjQuery.cleanData( getAll( node ) );\n\t\t}\n\n\t\tif ( node.parentNode ) {\n\t\t\tif ( keepData && jQuery.contains( node.ownerDocument, node ) ) {\n\t\t\t\tsetGlobalEval( getAll( node, \"script\" ) );\n\t\t\t}\n\t\t\tnode.parentNode.removeChild( node );\n\t\t}\n\t}\n\n\treturn elem;\n}\n\njQuery.extend( {\n\thtmlPrefilter: function( html ) {\n\t\treturn html.replace( rxhtmlTag, \"<$1></$2>\" );\n\t},\n\n\tclone: function( elem, dataAndEvents, deepDataAndEvents ) {\n\t\tvar i, l, srcElements, destElements,\n\t\t\tclone = elem.cloneNode( true ),\n\t\t\tinPage = jQuery.contains( elem.ownerDocument, elem );\n\n\t\t// Fix IE cloning issues\n\t\tif ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&\n\t\t\t\t!jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2\n\t\t\tdestElements = getAll( clone );\n\t\t\tsrcElements = getAll( elem );\n\n\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\tfixInput( srcElements[ i ], destElements[ i ] );\n\t\t\t}\n\t\t}\n\n\t\t// Copy the events from the original to the clone\n\t\tif ( dataAndEvents ) {\n\t\t\tif ( deepDataAndEvents ) {\n\t\t\t\tsrcElements = srcElements || getAll( elem );\n\t\t\t\tdestElements = destElements || getAll( clone );\n\n\t\t\t\tfor ( i = 0, l = srcElements.length; i < l; i++ ) {\n\t\t\t\t\tcloneCopyEvent( srcElements[ i ], destElements[ i ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcloneCopyEvent( elem, clone );\n\t\t\t}\n\t\t}\n\n\t\t// Preserve script evaluation history\n\t\tdestElements = getAll( clone, \"script\" );\n\t\tif ( destElements.length > 0 ) {\n\t\t\tsetGlobalEval( destElements, !inPage && getAll( elem, \"script\" ) );\n\t\t}\n\n\t\t// Return the cloned set\n\t\treturn clone;\n\t},\n\n\tcleanData: function( elems ) {\n\t\tvar data, elem, type,\n\t\t\tspecial = jQuery.event.special,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {\n\t\t\tif ( acceptData( elem ) ) {\n\t\t\t\tif ( ( data = elem[ dataPriv.expando ] ) ) {\n\t\t\t\t\tif ( data.events ) {\n\t\t\t\t\t\tfor ( type in data.events ) {\n\t\t\t\t\t\t\tif ( special[ type ] ) {\n\t\t\t\t\t\t\t\tjQuery.event.remove( elem, type );\n\n\t\t\t\t\t\t\t// This is a shortcut to avoid jQuery.event.remove's overhead\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tjQuery.removeEvent( elem, type, data.handle );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Support: Chrome <= 35-45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataPriv.expando ] = undefined;\n\t\t\t\t}\n\t\t\t\tif ( elem[ dataUser.expando ] ) {\n\n\t\t\t\t\t// Support: Chrome <= 35-45+\n\t\t\t\t\t// Assign undefined instead of using delete, see Data#remove\n\t\t\t\t\telem[ dataUser.expando ] = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n} );\n\njQuery.fn.extend( {\n\tdetach: function( selector ) {\n\t\treturn remove( this, selector, true );\n\t},\n\n\tremove: function( selector ) {\n\t\treturn remove( this, selector );\n\t},\n\n\ttext: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\treturn value === undefined ?\n\t\t\t\tjQuery.text( this ) :\n\t\t\t\tthis.empty().each( function() {\n\t\t\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\t\t\tthis.textContent = value;\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t}, null, value, arguments.length );\n\t},\n\n\tappend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.appendChild( elem );\n\t\t\t}\n\t\t} );\n\t},\n\n\tprepend: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {\n\t\t\t\tvar target = manipulationTarget( this, elem );\n\t\t\t\ttarget.insertBefore( elem, target.firstChild );\n\t\t\t}\n\t\t} );\n\t},\n\n\tbefore: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this );\n\t\t\t}\n\t\t} );\n\t},\n\n\tafter: function() {\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tif ( this.parentNode ) {\n\t\t\t\tthis.parentNode.insertBefore( elem, this.nextSibling );\n\t\t\t}\n\t\t} );\n\t},\n\n\tempty: function() {\n\t\tvar elem,\n\t\t\ti = 0;\n\n\t\tfor ( ; ( elem = this[ i ] ) != null; i++ ) {\n\t\t\tif ( elem.nodeType === 1 ) {\n\n\t\t\t\t// Prevent memory leaks\n\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\n\t\t\t\t// Remove any remaining nodes\n\t\t\t\telem.textContent = \"\";\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tclone: function( dataAndEvents, deepDataAndEvents ) {\n\t\tdataAndEvents = dataAndEvents == null ? false : dataAndEvents;\n\t\tdeepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;\n\n\t\treturn this.map( function() {\n\t\t\treturn jQuery.clone( this, dataAndEvents, deepDataAndEvents );\n\t\t} );\n\t},\n\n\thtml: function( value ) {\n\t\treturn access( this, function( value ) {\n\t\t\tvar elem = this[ 0 ] || {},\n\t\t\t\ti = 0,\n\t\t\t\tl = this.length;\n\n\t\t\tif ( value === undefined && elem.nodeType === 1 ) {\n\t\t\t\treturn elem.innerHTML;\n\t\t\t}\n\n\t\t\t// See if we can take a shortcut and just use innerHTML\n\t\t\tif ( typeof value === \"string\" && !rnoInnerhtml.test( value ) &&\n\t\t\t\t!wrapMap[ ( rtagName.exec( value ) || [ \"\", \"\" ] )[ 1 ].toLowerCase() ] ) {\n\n\t\t\t\tvalue = jQuery.htmlPrefilter( value );\n\n\t\t\t\ttry {\n\t\t\t\t\tfor ( ; i < l; i++ ) {\n\t\t\t\t\t\telem = this[ i ] || {};\n\n\t\t\t\t\t\t// Remove element nodes and prevent memory leaks\n\t\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\t\tjQuery.cleanData( getAll( elem, false ) );\n\t\t\t\t\t\t\telem.innerHTML = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\telem = 0;\n\n\t\t\t\t// If using innerHTML throws an exception, use the fallback method\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\tif ( elem ) {\n\t\t\t\tthis.empty().append( value );\n\t\t\t}\n\t\t}, null, value, arguments.length );\n\t},\n\n\treplaceWith: function() {\n\t\tvar ignored = [];\n\n\t\t// Make the changes, replacing each non-ignored context element with the new content\n\t\treturn domManip( this, arguments, function( elem ) {\n\t\t\tvar parent = this.parentNode;\n\n\t\t\tif ( jQuery.inArray( this, ignored ) < 0 ) {\n\t\t\t\tjQuery.cleanData( getAll( this ) );\n\t\t\t\tif ( parent ) {\n\t\t\t\t\tparent.replaceChild( elem, this );\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Force callback invocation\n\t\t}, ignored );\n\t}\n} );\n\njQuery.each( {\n\tappendTo: \"append\",\n\tprependTo: \"prepend\",\n\tinsertBefore: \"before\",\n\tinsertAfter: \"after\",\n\treplaceAll: \"replaceWith\"\n}, function( name, original ) {\n\tjQuery.fn[ name ] = function( selector ) {\n\t\tvar elems,\n\t\t\tret = [],\n\t\t\tinsert = jQuery( selector ),\n\t\t\tlast = insert.length - 1,\n\t\t\ti = 0;\n\n\t\tfor ( ; i <= last; i++ ) {\n\t\t\telems = i === last ? this : this.clone( true );\n\t\t\tjQuery( insert[ i ] )[ original ]( elems );\n\n\t\t\t// Support: Android<4.1, PhantomJS<2\n\t\t\t// .get() because push.apply(_, arraylike) throws on ancient WebKit\n\t\t\tpush.apply( ret, elems.get() );\n\t\t}\n\n\t\treturn this.pushStack( ret );\n\t};\n} );\nvar rmargin = ( /^margin/ );\n\nvar rnumnonpx = new RegExp( \"^(\" + pnum + \")(?!px)[a-z%]+$\", \"i\" );\n\nvar getStyles = function( elem ) {\n\n\t\t// Support: IE<=11+, Firefox<=30+ (#15098, #14150)\n\t\t// IE throws on elements created in popups\n\t\t// FF meanwhile throws on frame elements through \"defaultView.getComputedStyle\"\n\t\tvar view = elem.ownerDocument.defaultView;\n\n\t\tif ( !view.opener ) {\n\t\t\tview = window;\n\t\t}\n\n\t\treturn view.getComputedStyle( elem );\n\t};\n\nvar documentElement = document.documentElement;\n\n\n\n( function() {\n\tvar pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,\n\t\tcontainer = document.createElement( \"div\" ),\n\t\tdiv = document.createElement( \"div\" );\n\n\t// Finish early in limited (non-browser) environments\n\tif ( !div.style ) {\n\t\treturn;\n\t}\n\n\t// Support: IE9-11+\n\t// Style of cloned element affects source element cloned (#8908)\n\tdiv.style.backgroundClip = \"content-box\";\n\tdiv.cloneNode( true ).style.backgroundClip = \"\";\n\tsupport.clearCloneStyle = div.style.backgroundClip === \"content-box\";\n\n\tcontainer.style.cssText = \"border:0;width:8px;height:0;top:0;left:-9999px;\" +\n\t\t\"padding:0;margin-top:1px;position:absolute\";\n\tcontainer.appendChild( div );\n\n\t// Executing both pixelPosition & boxSizingReliable tests require only one layout\n\t// so they're executed at the same time to save the second computation.\n\tfunction computeStyleTests() {\n\t\tdiv.style.cssText =\n\t\t\t\"box-sizing:border-box;\" +\n\t\t\t\"position:relative;display:block;\" +\n\t\t\t\"margin:auto;border:1px;padding:1px;\" +\n\t\t\t\"top:1%;width:50%\";\n\t\tdiv.innerHTML = \"\";\n\t\tdocumentElement.appendChild( container );\n\n\t\tvar divStyle = window.getComputedStyle( div );\n\t\tpixelPositionVal = divStyle.top !== \"1%\";\n\t\treliableMarginLeftVal = divStyle.marginLeft === \"2px\";\n\t\tboxSizingReliableVal = divStyle.width === \"4px\";\n\n\t\t// Support: Android 4.0 - 4.3 only\n\t\t// Some styles come back with percentage values, even though they shouldn't\n\t\tdiv.style.marginRight = \"50%\";\n\t\tpixelMarginRightVal = divStyle.marginRight === \"4px\";\n\n\t\tdocumentElement.removeChild( container );\n\t}\n\n\tjQuery.extend( support, {\n\t\tpixelPosition: function() {\n\n\t\t\t// This test is executed only once but we still do memoizing\n\t\t\t// since we can use the boxSizingReliable pre-computing.\n\t\t\t// No need to check if the test was already performed, though.\n\t\t\tcomputeStyleTests();\n\t\t\treturn pixelPositionVal;\n\t\t},\n\t\tboxSizingReliable: function() {\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn boxSizingReliableVal;\n\t\t},\n\t\tpixelMarginRight: function() {\n\n\t\t\t// Support: Android 4.0-4.3\n\t\t\t// We're checking for boxSizingReliableVal here instead of pixelMarginRightVal\n\t\t\t// since that compresses better and they're computed together anyway.\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn pixelMarginRightVal;\n\t\t},\n\t\treliableMarginLeft: function() {\n\n\t\t\t// Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37\n\t\t\tif ( boxSizingReliableVal == null ) {\n\t\t\t\tcomputeStyleTests();\n\t\t\t}\n\t\t\treturn reliableMarginLeftVal;\n\t\t}\n\t} );\n} )();\n\n\nfunction curCSS( elem, name, computed ) {\n\tvar width, minWidth, maxWidth, ret,\n\t\tstyle = elem.style;\n\n\tcomputed = computed || getStyles( elem );\n\n\t// Support: IE9\n\t// getPropertyValue is only needed for .css('filter') (#12537)\n\tif ( computed ) {\n\t\tret = computed.getPropertyValue( name ) || computed[ name ];\n\n\t\tif ( ret === \"\" && !jQuery.contains( elem.ownerDocument, elem ) ) {\n\t\t\tret = jQuery.style( elem, name );\n\t\t}\n\n\t\t// A tribute to the \"awesome hack by Dean Edwards\"\n\t\t// Android Browser returns percentage for some values,\n\t\t// but width seems to be reliably pixels.\n\t\t// This is against the CSSOM draft spec:\n\t\t// http://dev.w3.org/csswg/cssom/#resolved-values\n\t\tif ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {\n\n\t\t\t// Remember the original values\n\t\t\twidth = style.width;\n\t\t\tminWidth = style.minWidth;\n\t\t\tmaxWidth = style.maxWidth;\n\n\t\t\t// Put in the new values to get a computed value out\n\t\t\tstyle.minWidth = style.maxWidth = style.width = ret;\n\t\t\tret = computed.width;\n\n\t\t\t// Revert the changed values\n\t\t\tstyle.width = width;\n\t\t\tstyle.minWidth = minWidth;\n\t\t\tstyle.maxWidth = maxWidth;\n\t\t}\n\t}\n\n\treturn ret !== undefined ?\n\n\t\t// Support: IE9-11+\n\t\t// IE returns zIndex value as an integer.\n\t\tret + \"\" :\n\t\tret;\n}\n\n\nfunction addGetHookIf( conditionFn, hookFn ) {\n\n\t// Define the hook, we'll check on the first run if it's really needed.\n\treturn {\n\t\tget: function() {\n\t\t\tif ( conditionFn() ) {\n\n\t\t\t\t// Hook not needed (or it's not possible to use it due\n\t\t\t\t// to missing dependency), remove it.\n\t\t\t\tdelete this.get;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Hook needed; redefine it so that the support test is not executed again.\n\t\t\treturn ( this.get = hookFn ).apply( this, arguments );\n\t\t}\n\t};\n}\n\n\nvar\n\n\t// Swappable if display is none or starts with table\n\t// except \"table\", \"table-cell\", or \"table-caption\"\n\t// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display\n\trdisplayswap = /^(none|table(?!-c[ea]).+)/,\n\tcssShow = { position: \"absolute\", visibility: \"hidden\", display: \"block\" },\n\tcssNormalTransform = {\n\t\tletterSpacing: \"0\",\n\t\tfontWeight: \"400\"\n\t},\n\n\tcssPrefixes = [ \"Webkit\", \"Moz\", \"ms\" ],\n\temptyStyle = document.createElement( \"div\" ).style;\n\n// Return a css property mapped to a potentially vendor prefixed property\nfunction vendorPropName( name ) {\n\n\t// Shortcut for names that are not vendor prefixed\n\tif ( name in emptyStyle ) {\n\t\treturn name;\n\t}\n\n\t// Check for vendor prefixed names\n\tvar capName = name[ 0 ].toUpperCase() + name.slice( 1 ),\n\t\ti = cssPrefixes.length;\n\n\twhile ( i-- ) {\n\t\tname = cssPrefixes[ i ] + capName;\n\t\tif ( name in emptyStyle ) {\n\t\t\treturn name;\n\t\t}\n\t}\n}\n\nfunction setPositiveNumber( elem, value, subtract ) {\n\n\t// Any relative (+/-) values have already been\n\t// normalized at this point\n\tvar matches = rcssNum.exec( value );\n\treturn matches ?\n\n\t\t// Guard against undefined \"subtract\", e.g., when used as in cssHooks\n\t\tMath.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || \"px\" ) :\n\t\tvalue;\n}\n\nfunction augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {\n\tvar i = extra === ( isBorderBox ? \"border\" : \"content\" ) ?\n\n\t\t// If we already have the right measurement, avoid augmentation\n\t\t4 :\n\n\t\t// Otherwise initialize for horizontal or vertical properties\n\t\tname === \"width\" ? 1 : 0,\n\n\t\tval = 0;\n\n\tfor ( ; i < 4; i += 2 ) {\n\n\t\t// Both box models exclude margin, so add it if we want it\n\t\tif ( extra === \"margin\" ) {\n\t\t\tval += jQuery.css( elem, extra + cssExpand[ i ], true, styles );\n\t\t}\n\n\t\tif ( isBorderBox ) {\n\n\t\t\t// border-box includes padding, so remove it if we want content\n\t\t\tif ( extra === \"content\" ) {\n\t\t\t\tval -= jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\t\t\t}\n\n\t\t\t// At this point, extra isn't border nor margin, so remove border\n\t\t\tif ( extra !== \"margin\" ) {\n\t\t\t\tval -= jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\t\t} else {\n\n\t\t\t// At this point, extra isn't content, so add padding\n\t\t\tval += jQuery.css( elem, \"padding\" + cssExpand[ i ], true, styles );\n\n\t\t\t// At this point, extra isn't content nor padding, so add border\n\t\t\tif ( extra !== \"padding\" ) {\n\t\t\t\tval += jQuery.css( elem, \"border\" + cssExpand[ i ] + \"Width\", true, styles );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn val;\n}\n\nfunction getWidthOrHeight( elem, name, extra ) {\n\n\t// Start with offset property, which is equivalent to the border-box value\n\tvar val,\n\t\tvalueIsBorderBox = true,\n\t\tstyles = getStyles( elem ),\n\t\tisBorderBox = jQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\";\n\n\t// Support: IE <= 11 only\n\t// Running getBoundingClientRect on a disconnected node\n\t// in IE throws an error.\n\tif ( elem.getClientRects().length ) {\n\t\tval = elem.getBoundingClientRect()[ name ];\n\t}\n\n\t// Support: IE11 only\n\t// In IE 11 fullscreen elements inside of an iframe have\n\t// 100x too small dimensions (gh-1764).\n\tif ( document.msFullscreenElement && window.top !== window ) {\n\t\tval *= 100;\n\t}\n\n\t// Some non-html elements return undefined for offsetWidth, so check for null/undefined\n\t// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285\n\t// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668\n\tif ( val <= 0 || val == null ) {\n\n\t\t// Fall back to computed then uncomputed css if necessary\n\t\tval = curCSS( elem, name, styles );\n\t\tif ( val < 0 || val == null ) {\n\t\t\tval = elem.style[ name ];\n\t\t}\n\n\t\t// Computed unit is not pixels. Stop here and return.\n\t\tif ( rnumnonpx.test( val ) ) {\n\t\t\treturn val;\n\t\t}\n\n\t\t// Check for style in case a browser which returns unreliable values\n\t\t// for getComputedStyle silently falls back to the reliable elem.style\n\t\tvalueIsBorderBox = isBorderBox &&\n\t\t\t( support.boxSizingReliable() || val === elem.style[ name ] );\n\n\t\t// Normalize \"\", auto, and prepare for extra\n\t\tval = parseFloat( val ) || 0;\n\t}\n\n\t// Use the active box-sizing model to add/subtract irrelevant styles\n\treturn ( val +\n\t\taugmentWidthOrHeight(\n\t\t\telem,\n\t\t\tname,\n\t\t\textra || ( isBorderBox ? \"border\" : \"content\" ),\n\t\t\tvalueIsBorderBox,\n\t\t\tstyles\n\t\t)\n\t) + \"px\";\n}\n\njQuery.extend( {\n\n\t// Add in style property hooks for overriding the default\n\t// behavior of getting and setting a style property\n\tcssHooks: {\n\t\topacity: {\n\t\t\tget: function( elem, computed ) {\n\t\t\t\tif ( computed ) {\n\n\t\t\t\t\t// We should always get a number back from opacity\n\t\t\t\t\tvar ret = curCSS( elem, \"opacity\" );\n\t\t\t\t\treturn ret === \"\" ? \"1\" : ret;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\t// Don't automatically add \"px\" to these possibly-unitless properties\n\tcssNumber: {\n\t\t\"animationIterationCount\": true,\n\t\t\"columnCount\": true,\n\t\t\"fillOpacity\": true,\n\t\t\"flexGrow\": true,\n\t\t\"flexShrink\": true,\n\t\t\"fontWeight\": true,\n\t\t\"lineHeight\": true,\n\t\t\"opacity\": true,\n\t\t\"order\": true,\n\t\t\"orphans\": true,\n\t\t\"widows\": true,\n\t\t\"zIndex\": true,\n\t\t\"zoom\": true\n\t},\n\n\t// Add in properties whose names you wish to fix before\n\t// setting or getting the value\n\tcssProps: {\n\t\t\"float\": \"cssFloat\"\n\t},\n\n\t// Get and set the style property on a DOM Node\n\tstyle: function( elem, name, value, extra ) {\n\n\t\t// Don't set styles on text and comment nodes\n\t\tif ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure that we're working with the right name\n\t\tvar ret, type, hooks,\n\t\t\torigName = jQuery.camelCase( name ),\n\t\t\tstyle = elem.style;\n\n\t\tname = jQuery.cssProps[ origName ] ||\n\t\t\t( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );\n\n\t\t// Gets hook for the prefixed version, then unprefixed version\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// Check if we're setting a value\n\t\tif ( value !== undefined ) {\n\t\t\ttype = typeof value;\n\n\t\t\t// Convert \"+=\" or \"-=\" to relative numbers (#7345)\n\t\t\tif ( type === \"string\" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {\n\t\t\t\tvalue = adjustCSS( elem, name, ret );\n\n\t\t\t\t// Fixes bug #9237\n\t\t\t\ttype = \"number\";\n\t\t\t}\n\n\t\t\t// Make sure that null and NaN values aren't set (#7116)\n\t\t\tif ( value == null || value !== value ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If a number was passed in, add the unit (except for certain CSS properties)\n\t\t\tif ( type === \"number\" ) {\n\t\t\t\tvalue += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? \"\" : \"px\" );\n\t\t\t}\n\n\t\t\t// Support: IE9-11+\n\t\t\t// background-* props affect original clone's values\n\t\t\tif ( !support.clearCloneStyle && value === \"\" && name.indexOf( \"background\" ) === 0 ) {\n\t\t\t\tstyle[ name ] = \"inherit\";\n\t\t\t}\n\n\t\t\t// If a hook was provided, use that value, otherwise just set the specified value\n\t\t\tif ( !hooks || !( \"set\" in hooks ) ||\n\t\t\t\t( value = hooks.set( elem, value, extra ) ) !== undefined ) {\n\n\t\t\t\tstyle[ name ] = value;\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// If a hook was provided get the non-computed value from there\n\t\t\tif ( hooks && \"get\" in hooks &&\n\t\t\t\t( ret = hooks.get( elem, false, extra ) ) !== undefined ) {\n\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\t// Otherwise just get the value from the style object\n\t\t\treturn style[ name ];\n\t\t}\n\t},\n\n\tcss: function( elem, name, extra, styles ) {\n\t\tvar val, num, hooks,\n\t\t\torigName = jQuery.camelCase( name );\n\n\t\t// Make sure that we're working with the right name\n\t\tname = jQuery.cssProps[ origName ] ||\n\t\t\t( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );\n\n\t\t// Try prefixed name followed by the unprefixed name\n\t\thooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];\n\n\t\t// If a hook was provided get the computed value from there\n\t\tif ( hooks && \"get\" in hooks ) {\n\t\t\tval = hooks.get( elem, true, extra );\n\t\t}\n\n\t\t// Otherwise, if a way to get the computed value exists, use that\n\t\tif ( val === undefined ) {\n\t\t\tval = curCSS( elem, name, styles );\n\t\t}\n\n\t\t// Convert \"normal\" to computed value\n\t\tif ( val === \"normal\" && name in cssNormalTransform ) {\n\t\t\tval = cssNormalTransform[ name ];\n\t\t}\n\n\t\t// Make numeric if forced or a qualifier was provided and val looks numeric\n\t\tif ( extra === \"\" || extra ) {\n\t\t\tnum = parseFloat( val );\n\t\t\treturn extra === true || isFinite( num ) ? num || 0 : val;\n\t\t}\n\t\treturn val;\n\t}\n} );\n\njQuery.each( [ \"height\", \"width\" ], function( i, name ) {\n\tjQuery.cssHooks[ name ] = {\n\t\tget: function( elem, computed, extra ) {\n\t\t\tif ( computed ) {\n\n\t\t\t\t// Certain elements can have dimension info if we invisibly show them\n\t\t\t\t// but it must have a current display style that would benefit\n\t\t\t\treturn rdisplayswap.test( jQuery.css( elem, \"display\" ) ) &&\n\n\t\t\t\t\t// Support: Safari 8+\n\t\t\t\t\t// Table columns in Safari have non-zero offsetWidth & zero\n\t\t\t\t\t// getBoundingClientRect().width unless display is changed.\n\t\t\t\t\t// Support: IE <= 11 only\n\t\t\t\t\t// Running getBoundingClientRect on a disconnected node\n\t\t\t\t\t// in IE throws an error.\n\t\t\t\t\t( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?\n\t\t\t\t\t\tswap( elem, cssShow, function() {\n\t\t\t\t\t\t\treturn getWidthOrHeight( elem, name, extra );\n\t\t\t\t\t\t} ) :\n\t\t\t\t\t\tgetWidthOrHeight( elem, name, extra );\n\t\t\t}\n\t\t},\n\n\t\tset: function( elem, value, extra ) {\n\t\t\tvar matches,\n\t\t\t\tstyles = extra && getStyles( elem ),\n\t\t\t\tsubtract = extra && augmentWidthOrHeight(\n\t\t\t\t\telem,\n\t\t\t\t\tname,\n\t\t\t\t\textra,\n\t\t\t\t\tjQuery.css( elem, \"boxSizing\", false, styles ) === \"border-box\",\n\t\t\t\t\tstyles\n\t\t\t\t);\n\n\t\t\t// Convert to pixels if value adjustment is needed\n\t\t\tif ( subtract && ( matches = rcssNum.exec( value ) ) &&\n\t\t\t\t( matches[ 3 ] || \"px\" ) !== \"px\" ) {\n\n\t\t\t\telem.style[ name ] = value;\n\t\t\t\tvalue = jQuery.css( elem, name );\n\t\t\t}\n\n\t\t\treturn setPositiveNumber( elem, value, subtract );\n\t\t}\n\t};\n} );\n\njQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,\n\tfunction( elem, computed ) {\n\t\tif ( computed ) {\n\t\t\treturn ( parseFloat( curCSS( elem, \"marginLeft\" ) ) ||\n\t\t\t\telem.getBoundingClientRect().left -\n\t\t\t\t\tswap( elem, { marginLeft: 0 }, function() {\n\t\t\t\t\t\treturn elem.getBoundingClientRect().left;\n\t\t\t\t\t} )\n\t\t\t\t) + \"px\";\n\t\t}\n\t}\n);\n\n// These hooks are used by animate to expand properties\njQuery.each( {\n\tmargin: \"\",\n\tpadding: \"\",\n\tborder: \"Width\"\n}, function( prefix, suffix ) {\n\tjQuery.cssHooks[ prefix + suffix ] = {\n\t\texpand: function( value ) {\n\t\t\tvar i = 0,\n\t\t\t\texpanded = {},\n\n\t\t\t\t// Assumes a single number if not a string\n\t\t\t\tparts = typeof value === \"string\" ? value.split( \" \" ) : [ value ];\n\n\t\t\tfor ( ; i < 4; i++ ) {\n\t\t\t\texpanded[ prefix + cssExpand[ i ] + suffix ] =\n\t\t\t\t\tparts[ i ] || parts[ i - 2 ] || parts[ 0 ];\n\t\t\t}\n\n\t\t\treturn expanded;\n\t\t}\n\t};\n\n\tif ( !rmargin.test( prefix ) ) {\n\t\tjQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;\n\t}\n} );\n\njQuery.fn.extend( {\n\tcss: function( name, value ) {\n\t\treturn access( this, function( elem, name, value ) {\n\t\t\tvar styles, len,\n\t\t\t\tmap = {},\n\t\t\t\ti = 0;\n\n\t\t\tif ( jQuery.isArray( name ) ) {\n\t\t\t\tstyles = getStyles( elem );\n\t\t\t\tlen = name.length;\n\n\t\t\t\tfor ( ; i < len; i++ ) {\n\t\t\t\t\tmap[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}\n\n\t\t\treturn value !== undefined ?\n\t\t\t\tjQuery.style( elem, name, value ) :\n\t\t\t\tjQuery.css( elem, name );\n\t\t}, name, value, arguments.length > 1 );\n\t}\n} );\n\n\n// Based off of the plugin by Clint Helfers, with permission.\n// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/\njQuery.fn.delay = function( time, type ) {\n\ttime = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;\n\ttype = type || \"fx\";\n\n\treturn this.queue( type, function( next, hooks ) {\n\t\tvar timeout = window.setTimeout( next, time );\n\t\thooks.stop = function() {\n\t\t\twindow.clearTimeout( timeout );\n\t\t};\n\t} );\n};\n\n\n( function() {\n\tvar input = document.createElement( \"input\" ),\n\t\tselect = document.createElement( \"select\" ),\n\t\topt = select.appendChild( document.createElement( \"option\" ) );\n\n\tinput.type = \"checkbox\";\n\n\t// Support: Android<4.4\n\t// Default value for a checkbox should be \"on\"\n\tsupport.checkOn = input.value !== \"\";\n\n\t// Support: IE<=11+\n\t// Must access selectedIndex to make default options select\n\tsupport.optSelected = opt.selected;\n\n\t// Support: IE<=11+\n\t// An input loses its value after becoming a radio\n\tinput = document.createElement( \"input\" );\n\tinput.value = \"t\";\n\tinput.type = \"radio\";\n\tsupport.radioValue = input.value === \"t\";\n} )();\n\n\nvar boolHook,\n\tattrHandle = jQuery.expr.attrHandle,\n\n\t// Exclusively lowercase A-Z in attribute names (gh-2730)\n\t// https://dom.spec.whatwg.org/#converted-to-ascii-lowercase\n\traz = /[A-Z]+/g,\n\tlowercase = function( ch ) {\n\t\treturn ch.toLowerCase();\n\t};\n\njQuery.fn.extend( {\n\tattr: function( name, value ) {\n\t\treturn access( this, jQuery.attr, name, value, arguments.length > 1 );\n\t},\n\n\tremoveAttr: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.removeAttr( this, name );\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tattr: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set attributes on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Fallback to prop when attributes are not supported\n\t\tif ( typeof elem.getAttribute === \"undefined\" ) {\n\t\t\treturn jQuery.prop( elem, name, value );\n\t\t}\n\n\t\t// All attributes are lowercase\n\t\t// Grab necessary hook if one is defined\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\t\t\tname = name.replace( raz, lowercase );\n\t\t\thooks = jQuery.attrHooks[ name ] ||\n\t\t\t\t( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( value === null ) {\n\t\t\t\tjQuery.removeAttr( elem, name );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\telem.setAttribute( name, value + \"\" );\n\t\t\treturn value;\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tret = jQuery.find.attr( elem, name );\n\n\t\t// Non-existent attributes return null, we normalize to undefined\n\t\treturn ret == null ? undefined : ret;\n\t},\n\n\tattrHooks: {\n\t\ttype: {\n\t\t\tset: function( elem, value ) {\n\t\t\t\tif ( !support.radioValue && value === \"radio\" &&\n\t\t\t\t\tjQuery.nodeName( elem, \"input\" ) ) {\n\t\t\t\t\tvar val = elem.value;\n\t\t\t\t\telem.setAttribute( \"type\", value );\n\t\t\t\t\tif ( val ) {\n\t\t\t\t\t\telem.value = val;\n\t\t\t\t\t}\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\n\tremoveAttr: function( elem, value ) {\n\t\tvar name,\n\t\t\ti = 0,\n\t\t\tattrNames = value && value.match( rnotwhite );\n\n\t\tif ( attrNames && elem.nodeType === 1 ) {\n\t\t\twhile ( ( name = attrNames[ i++ ] ) ) {\n\t\t\t\telem.removeAttribute( name );\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Hooks for boolean attributes\nboolHook = {\n\tset: function( elem, value, name ) {\n\t\tif ( value === false ) {\n\n\t\t\t// Remove boolean attributes when set to false\n\t\t\tjQuery.removeAttr( elem, name );\n\t\t} else {\n\t\t\telem.setAttribute( name, name );\n\t\t}\n\t\treturn name;\n\t}\n};\n\njQuery.each( jQuery.expr.match.bool.source.match( /\\w+/g ), function( i, name ) {\n\tvar getter = attrHandle[ name ] || jQuery.find.attr;\n\n\tattrHandle[ name ] = function( elem, name, isXML ) {\n\t\tvar ret, handle;\n\t\tif ( !isXML ) {\n\n\t\t\t// Avoid an infinite loop by temporarily removing this function from the getter\n\t\t\thandle = attrHandle[ name ];\n\t\t\tattrHandle[ name ] = ret;\n\t\t\tret = getter( elem, name, isXML ) != null ?\n\t\t\t\tname.toLowerCase() :\n\t\t\t\tnull;\n\t\t\tattrHandle[ name ] = handle;\n\t\t}\n\t\treturn ret;\n\t};\n} );\n\n\n\n\nvar rfocusable = /^(?:input|select|textarea|button)$/i,\n\trclickable = /^(?:a|area)$/i;\n\njQuery.fn.extend( {\n\tprop: function( name, value ) {\n\t\treturn access( this, jQuery.prop, name, value, arguments.length > 1 );\n\t},\n\n\tremoveProp: function( name ) {\n\t\treturn this.each( function() {\n\t\t\tdelete this[ jQuery.propFix[ name ] || name ];\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tprop: function( elem, name, value ) {\n\t\tvar ret, hooks,\n\t\t\tnType = elem.nodeType;\n\n\t\t// Don't get/set properties on text, comment and attribute nodes\n\t\tif ( nType === 3 || nType === 8 || nType === 2 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {\n\n\t\t\t// Fix name and attach hooks\n\t\t\tname = jQuery.propFix[ name ] || name;\n\t\t\thooks = jQuery.propHooks[ name ];\n\t\t}\n\n\t\tif ( value !== undefined ) {\n\t\t\tif ( hooks && \"set\" in hooks &&\n\t\t\t\t( ret = hooks.set( elem, value, name ) ) !== undefined ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\treturn ( elem[ name ] = value );\n\t\t}\n\n\t\tif ( hooks && \"get\" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {\n\t\t\treturn ret;\n\t\t}\n\n\t\treturn elem[ name ];\n\t},\n\n\tpropHooks: {\n\t\ttabIndex: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\t// elem.tabIndex doesn't always return the\n\t\t\t\t// correct value when it hasn't been explicitly set\n\t\t\t\t// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/\n\t\t\t\t// Use proper attribute retrieval(#12072)\n\t\t\t\tvar tabindex = jQuery.find.attr( elem, \"tabindex\" );\n\n\t\t\t\treturn tabindex ?\n\t\t\t\t\tparseInt( tabindex, 10 ) :\n\t\t\t\t\trfocusable.test( elem.nodeName ) ||\n\t\t\t\t\t\trclickable.test( elem.nodeName ) && elem.href ?\n\t\t\t\t\t\t\t0 :\n\t\t\t\t\t\t\t-1;\n\t\t\t}\n\t\t}\n\t},\n\n\tpropFix: {\n\t\t\"for\": \"htmlFor\",\n\t\t\"class\": \"className\"\n\t}\n} );\n\nif ( !support.optSelected ) {\n\tjQuery.propHooks.selected = {\n\t\tget: function( elem ) {\n\t\t\tvar parent = elem.parentNode;\n\t\t\tif ( parent && parent.parentNode ) {\n\t\t\t\tparent.parentNode.selectedIndex;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t};\n}\n\njQuery.each( [\n\t\"tabIndex\",\n\t\"readOnly\",\n\t\"maxLength\",\n\t\"cellSpacing\",\n\t\"cellPadding\",\n\t\"rowSpan\",\n\t\"colSpan\",\n\t\"useMap\",\n\t\"frameBorder\",\n\t\"contentEditable\"\n], function() {\n\tjQuery.propFix[ this.toLowerCase() ] = this;\n} );\n\n\n\n\nvar rclass = /[\\t\\r\\n\\f]/g;\n\nfunction getClass( elem ) {\n\treturn elem.getAttribute && elem.getAttribute( \"class\" ) || \"\";\n}\n\njQuery.fn.extend( {\n\taddClass: function( value ) {\n\t\tvar classes, elem, cur, curValue, clazz, j, finalValue,\n\t\t\ti = 0;\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).addClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( typeof value === \"string\" && value ) {\n\t\t\tclasses = value.match( rnotwhite ) || [];\n\n\t\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\t\tcurValue = getClass( elem );\n\t\t\t\tcur = elem.nodeType === 1 &&\n\t\t\t\t\t( \" \" + curValue + \" \" ).replace( rclass, \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\twhile ( ( clazz = classes[ j++ ] ) ) {\n\t\t\t\t\t\tif ( cur.indexOf( \" \" + clazz + \" \" ) < 0 ) {\n\t\t\t\t\t\t\tcur += clazz + \" \";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = jQuery.trim( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\telem.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tremoveClass: function( value ) {\n\t\tvar classes, elem, cur, curValue, clazz, j, finalValue,\n\t\t\ti = 0;\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( j ) {\n\t\t\t\tjQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );\n\t\t\t} );\n\t\t}\n\n\t\tif ( !arguments.length ) {\n\t\t\treturn this.attr( \"class\", \"\" );\n\t\t}\n\n\t\tif ( typeof value === \"string\" && value ) {\n\t\t\tclasses = value.match( rnotwhite ) || [];\n\n\t\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\t\tcurValue = getClass( elem );\n\n\t\t\t\t// This expression is here for better compressibility (see addClass)\n\t\t\t\tcur = elem.nodeType === 1 &&\n\t\t\t\t\t( \" \" + curValue + \" \" ).replace( rclass, \" \" );\n\n\t\t\t\tif ( cur ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\twhile ( ( clazz = classes[ j++ ] ) ) {\n\n\t\t\t\t\t\t// Remove *all* instances\n\t\t\t\t\t\twhile ( cur.indexOf( \" \" + clazz + \" \" ) > -1 ) {\n\t\t\t\t\t\t\tcur = cur.replace( \" \" + clazz + \" \", \" \" );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Only assign if different to avoid unneeded rendering.\n\t\t\t\t\tfinalValue = jQuery.trim( cur );\n\t\t\t\t\tif ( curValue !== finalValue ) {\n\t\t\t\t\t\telem.setAttribute( \"class\", finalValue );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttoggleClass: function( value, stateVal ) {\n\t\tvar type = typeof value;\n\n\t\tif ( typeof stateVal === \"boolean\" && type === \"string\" ) {\n\t\t\treturn stateVal ? this.addClass( value ) : this.removeClass( value );\n\t\t}\n\n\t\tif ( jQuery.isFunction( value ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).toggleClass(\n\t\t\t\t\tvalue.call( this, i, getClass( this ), stateVal ),\n\t\t\t\t\tstateVal\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar className, i, self, classNames;\n\n\t\t\tif ( type === \"string\" ) {\n\n\t\t\t\t// Toggle individual class names\n\t\t\t\ti = 0;\n\t\t\t\tself = jQuery( this );\n\t\t\t\tclassNames = value.match( rnotwhite ) || [];\n\n\t\t\t\twhile ( ( className = classNames[ i++ ] ) ) {\n\n\t\t\t\t\t// Check each className given, space separated list\n\t\t\t\t\tif ( self.hasClass( className ) ) {\n\t\t\t\t\t\tself.removeClass( className );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tself.addClass( className );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t// Toggle whole class name\n\t\t\t} else if ( value === undefined || type === \"boolean\" ) {\n\t\t\t\tclassName = getClass( this );\n\t\t\t\tif ( className ) {\n\n\t\t\t\t\t// Store className if set\n\t\t\t\t\tdataPriv.set( this, \"__className__\", className );\n\t\t\t\t}\n\n\t\t\t\t// If the element has a class name or if we're passed `false`,\n\t\t\t\t// then remove the whole classname (if there was one, the above saved it).\n\t\t\t\t// Otherwise bring back whatever was previously saved (if anything),\n\t\t\t\t// falling back to the empty string if nothing was stored.\n\t\t\t\tif ( this.setAttribute ) {\n\t\t\t\t\tthis.setAttribute( \"class\",\n\t\t\t\t\t\tclassName || value === false ?\n\t\t\t\t\t\t\"\" :\n\t\t\t\t\t\tdataPriv.get( this, \"__className__\" ) || \"\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t},\n\n\thasClass: function( selector ) {\n\t\tvar className, elem,\n\t\t\ti = 0;\n\n\t\tclassName = \" \" + selector + \" \";\n\t\twhile ( ( elem = this[ i++ ] ) ) {\n\t\t\tif ( elem.nodeType === 1 &&\n\t\t\t\t( \" \" + getClass( elem ) + \" \" ).replace( rclass, \" \" )\n\t\t\t\t\t.indexOf( className ) > -1\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n} );\n\n\n\n\nvar rreturn = /\\r/g;\n\njQuery.fn.extend( {\n\tval: function( value ) {\n\t\tvar hooks, ret, isFunction,\n\t\t\telem = this[ 0 ];\n\n\t\tif ( !arguments.length ) {\n\t\t\tif ( elem ) {\n\t\t\t\thooks = jQuery.valHooks[ elem.type ] ||\n\t\t\t\t\tjQuery.valHooks[ elem.nodeName.toLowerCase() ];\n\n\t\t\t\tif ( hooks &&\n\t\t\t\t\t\"get\" in hooks &&\n\t\t\t\t\t( ret = hooks.get( elem, \"value\" ) ) !== undefined\n\t\t\t\t) {\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\n\t\t\t\tret = elem.value;\n\n\t\t\t\treturn typeof ret === \"string\" ?\n\n\t\t\t\t\t// Handle most common string cases\n\t\t\t\t\tret.replace( rreturn, \"\" ) :\n\n\t\t\t\t\t// Handle cases where value is null/undef or number\n\t\t\t\t\tret == null ? \"\" : ret;\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tisFunction = jQuery.isFunction( value );\n\n\t\treturn this.each( function( i ) {\n\t\t\tvar val;\n\n\t\t\tif ( this.nodeType !== 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isFunction ) {\n\t\t\t\tval = value.call( this, i, jQuery( this ).val() );\n\t\t\t} else {\n\t\t\t\tval = value;\n\t\t\t}\n\n\t\t\t// Treat null/undefined as \"\"; convert numbers to string\n\t\t\tif ( val == null ) {\n\t\t\t\tval = \"\";\n\n\t\t\t} else if ( typeof val === \"number\" ) {\n\t\t\t\tval += \"\";\n\n\t\t\t} else if ( jQuery.isArray( val ) ) {\n\t\t\t\tval = jQuery.map( val, function( value ) {\n\t\t\t\t\treturn value == null ? \"\" : value + \"\";\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];\n\n\t\t\t// If set returns undefined, fall back to normal setting\n\t\t\tif ( !hooks || !( \"set\" in hooks ) || hooks.set( this, val, \"value\" ) === undefined ) {\n\t\t\t\tthis.value = val;\n\t\t\t}\n\t\t} );\n\t}\n} );\n\njQuery.extend( {\n\tvalHooks: {\n\t\toption: {\n\t\t\tget: function( elem ) {\n\n\t\t\t\t// Support: IE<11\n\t\t\t\t// option.value not trimmed (#14858)\n\t\t\t\treturn jQuery.trim( elem.value );\n\t\t\t}\n\t\t},\n\t\tselect: {\n\t\t\tget: function( elem ) {\n\t\t\t\tvar value, option,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tindex = elem.selectedIndex,\n\t\t\t\t\tone = elem.type === \"select-one\",\n\t\t\t\t\tvalues = one ? null : [],\n\t\t\t\t\tmax = one ? index + 1 : options.length,\n\t\t\t\t\ti = index < 0 ?\n\t\t\t\t\t\tmax :\n\t\t\t\t\t\tone ? index : 0;\n\n\t\t\t\t// Loop through all the selected options\n\t\t\t\tfor ( ; i < max; i++ ) {\n\t\t\t\t\toption = options[ i ];\n\n\t\t\t\t\t// IE8-9 doesn't update selected after form reset (#2551)\n\t\t\t\t\tif ( ( option.selected || i === index ) &&\n\n\t\t\t\t\t\t\t// Don't return options that are disabled or in a disabled optgroup\n\t\t\t\t\t\t\t!option.disabled &&\n\t\t\t\t\t\t\t( !option.parentNode.disabled ||\n\t\t\t\t\t\t\t\t!jQuery.nodeName( option.parentNode, \"optgroup\" ) ) ) {\n\n\t\t\t\t\t\t// Get the specific value for the option\n\t\t\t\t\t\tvalue = jQuery( option ).val();\n\n\t\t\t\t\t\t// We don't need an array for one selects\n\t\t\t\t\t\tif ( one ) {\n\t\t\t\t\t\t\treturn value;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Multi-Selects return an array\n\t\t\t\t\t\tvalues.push( value );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\t\t\t},\n\n\t\t\tset: function( elem, value ) {\n\t\t\t\tvar optionSet, option,\n\t\t\t\t\toptions = elem.options,\n\t\t\t\t\tvalues = jQuery.makeArray( value ),\n\t\t\t\t\ti = options.length;\n\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\toption = options[ i ];\n\t\t\t\t\tif ( option.selected =\n\t\t\t\t\t\t\tjQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1\n\t\t\t\t\t) {\n\t\t\t\t\t\toptionSet = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Force browsers to behave consistently when non-matching value is set\n\t\t\t\tif ( !optionSet ) {\n\t\t\t\t\telem.selectedIndex = -1;\n\t\t\t\t}\n\t\t\t\treturn values;\n\t\t\t}\n\t\t}\n\t}\n} );\n\n// Radios and checkboxes getter/setter\njQuery.each( [ \"radio\", \"checkbox\" ], function() {\n\tjQuery.valHooks[ this ] = {\n\t\tset: function( elem, value ) {\n\t\t\tif ( jQuery.isArray( value ) ) {\n\t\t\t\treturn ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );\n\t\t\t}\n\t\t}\n\t};\n\tif ( !support.checkOn ) {\n\t\tjQuery.valHooks[ this ].get = function( elem ) {\n\t\t\treturn elem.getAttribute( \"value\" ) === null ? \"on\" : elem.value;\n\t\t};\n\t}\n} );\n\n\n\n\n// Return jQuery for attributes-only inclusion\n\n\nvar rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;\n\njQuery.extend( jQuery.event, {\n\n\ttrigger: function( event, data, elem, onlyHandlers ) {\n\n\t\tvar i, cur, tmp, bubbleType, ontype, handle, special,\n\t\t\teventPath = [ elem || document ],\n\t\t\ttype = hasOwn.call( event, \"type\" ) ? event.type : event,\n\t\t\tnamespaces = hasOwn.call( event, \"namespace\" ) ? event.namespace.split( \".\" ) : [];\n\n\t\tcur = tmp = elem = elem || document;\n\n\t\t// Don't do events on text and comment nodes\n\t\tif ( elem.nodeType === 3 || elem.nodeType === 8 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// focus/blur morphs to focusin/out; ensure we're not firing them right now\n\t\tif ( rfocusMorph.test( type + jQuery.event.triggered ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( type.indexOf( \".\" ) > -1 ) {\n\n\t\t\t// Namespaced trigger; create a regexp to match event type in handle()\n\t\t\tnamespaces = type.split( \".\" );\n\t\t\ttype = namespaces.shift();\n\t\t\tnamespaces.sort();\n\t\t}\n\t\tontype = type.indexOf( \":\" ) < 0 && \"on\" + type;\n\n\t\t// Caller can pass in a jQuery.Event object, Object, or just an event type string\n\t\tevent = event[ jQuery.expando ] ?\n\t\t\tevent :\n\t\t\tnew jQuery.Event( type, typeof event === \"object\" && event );\n\n\t\t// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)\n\t\tevent.isTrigger = onlyHandlers ? 2 : 3;\n\t\tevent.namespace = namespaces.join( \".\" );\n\t\tevent.rnamespace = event.namespace ?\n\t\t\tnew RegExp( \"(^|\\\\.)\" + namespaces.join( \"\\\\.(?:.*\\\\.|)\" ) + \"(\\\\.|$)\" ) :\n\t\t\tnull;\n\n\t\t// Clean up the event in case it is being reused\n\t\tevent.result = undefined;\n\t\tif ( !event.target ) {\n\t\t\tevent.target = elem;\n\t\t}\n\n\t\t// Clone any incoming data and prepend the event, creating the handler arg list\n\t\tdata = data == null ?\n\t\t\t[ event ] :\n\t\t\tjQuery.makeArray( data, [ event ] );\n\n\t\t// Allow special events to draw outside the lines\n\t\tspecial = jQuery.event.special[ type ] || {};\n\t\tif ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Determine event propagation path in advance, per W3C events spec (#9951)\n\t\t// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)\n\t\tif ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {\n\n\t\t\tbubbleType = special.delegateType || type;\n\t\t\tif ( !rfocusMorph.test( bubbleType + type ) ) {\n\t\t\t\tcur = cur.parentNode;\n\t\t\t}\n\t\t\tfor ( ; cur; cur = cur.parentNode ) {\n\t\t\t\teventPath.push( cur );\n\t\t\t\ttmp = cur;\n\t\t\t}\n\n\t\t\t// Only add window if we got to document (e.g., not plain obj or detached DOM)\n\t\t\tif ( tmp === ( elem.ownerDocument || document ) ) {\n\t\t\t\teventPath.push( tmp.defaultView || tmp.parentWindow || window );\n\t\t\t}\n\t\t}\n\n\t\t// Fire handlers on the event path\n\t\ti = 0;\n\t\twhile ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {\n\n\t\t\tevent.type = i > 1 ?\n\t\t\t\tbubbleType :\n\t\t\t\tspecial.bindType || type;\n\n\t\t\t// jQuery handler\n\t\t\thandle = ( dataPriv.get( cur, \"events\" ) || {} )[ event.type ] &&\n\t\t\t\tdataPriv.get( cur, \"handle\" );\n\t\t\tif ( handle ) {\n\t\t\t\thandle.apply( cur, data );\n\t\t\t}\n\n\t\t\t// Native handler\n\t\t\thandle = ontype && cur[ ontype ];\n\t\t\tif ( handle && handle.apply && acceptData( cur ) ) {\n\t\t\t\tevent.result = handle.apply( cur, data );\n\t\t\t\tif ( event.result === false ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tevent.type = type;\n\n\t\t// If nobody prevented the default action, do it now\n\t\tif ( !onlyHandlers && !event.isDefaultPrevented() ) {\n\n\t\t\tif ( ( !special._default ||\n\t\t\t\tspecial._default.apply( eventPath.pop(), data ) === false ) &&\n\t\t\t\tacceptData( elem ) ) {\n\n\t\t\t\t// Call a native DOM method on the target with the same name as the event.\n\t\t\t\t// Don't do default actions on window, that's where global variables be (#6170)\n\t\t\t\tif ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {\n\n\t\t\t\t\t// Don't re-trigger an onFOO event when we call its FOO() method\n\t\t\t\t\ttmp = elem[ ontype ];\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = null;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Prevent re-triggering of the same event, since we already bubbled it above\n\t\t\t\t\tjQuery.event.triggered = type;\n\t\t\t\t\telem[ type ]();\n\t\t\t\t\tjQuery.event.triggered = undefined;\n\n\t\t\t\t\tif ( tmp ) {\n\t\t\t\t\t\telem[ ontype ] = tmp;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn event.result;\n\t},\n\n\t// Piggyback on a donor event to simulate a different one\n\tsimulate: function( type, elem, event ) {\n\t\tvar e = jQuery.extend(\n\t\t\tnew jQuery.Event(),\n\t\t\tevent,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t\tisSimulated: true\n\n\t\t\t\t// Previously, `originalEvent: {}` was set here, so stopPropagation call\n\t\t\t\t// would not be triggered on donor event, since in our own\n\t\t\t\t// jQuery.event.stopPropagation function we had a check for existence of\n\t\t\t\t// originalEvent.stopPropagation method, so, consequently it would be a noop.\n\t\t\t\t//\n\t\t\t\t// But now, this \"simulate\" function is used only for events\n\t\t\t\t// for which stopPropagation() is noop, so there is no need for that anymore.\n\t\t\t\t//\n\t\t\t\t// For the compat branch though, guard for \"click\" and \"submit\"\n\t\t\t\t// events is still used, but was moved to jQuery.event.stopPropagation function\n\t\t\t\t// because `originalEvent` should point to the original event for the constancy\n\t\t\t\t// with other events and for more focused logic\n\t\t\t}\n\t\t);\n\n\t\tjQuery.event.trigger( e, null, elem );\n\n\t\tif ( e.isDefaultPrevented() ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n} );\n\njQuery.fn.extend( {\n\n\ttrigger: function( type, data ) {\n\t\treturn this.each( function() {\n\t\t\tjQuery.event.trigger( type, data, this );\n\t\t} );\n\t},\n\ttriggerHandler: function( type, data ) {\n\t\tvar elem = this[ 0 ];\n\t\tif ( elem ) {\n\t\t\treturn jQuery.event.trigger( type, data, elem, true );\n\t\t}\n\t}\n} );\n\n\njQuery.each( ( \"blur focus focusin focusout resize scroll click dblclick \" +\n\t\"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave \" +\n\t\"change select submit keydown keypress keyup contextmenu\" ).split( \" \" ),\n\tfunction( i, name ) {\n\n\t// Handle event binding\n\tjQuery.fn[ name ] = function( data, fn ) {\n\t\treturn arguments.length > 0 ?\n\t\t\tthis.on( name, null, data, fn ) :\n\t\t\tthis.trigger( name );\n\t};\n} );\n\njQuery.fn.extend( {\n\thover: function( fnOver, fnOut ) {\n\t\treturn this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );\n\t}\n} );\n\n\n\n\nsupport.focusin = \"onfocusin\" in window;\n\n\n// Support: Firefox\n// Firefox doesn't have focus(in | out) events\n// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787\n//\n// Support: Chrome, Safari\n// focus(in | out) events fire after focus & blur events,\n// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order\n// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857\nif ( !support.focusin ) {\n\tjQuery.each( { focus: \"focusin\", blur: \"focusout\" }, function( orig, fix ) {\n\n\t\t// Attach a single capturing handler on the document while someone wants focusin/focusout\n\t\tvar handler = function( event ) {\n\t\t\tjQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );\n\t\t};\n\n\t\tjQuery.event.special[ fix ] = {\n\t\t\tsetup: function() {\n\t\t\t\tvar doc = this.ownerDocument || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix );\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.addEventListener( orig, handler, true );\n\t\t\t\t}\n\t\t\t\tdataPriv.access( doc, fix, ( attaches || 0 ) + 1 );\n\t\t\t},\n\t\t\tteardown: function() {\n\t\t\t\tvar doc = this.ownerDocument || this,\n\t\t\t\t\tattaches = dataPriv.access( doc, fix ) - 1;\n\n\t\t\t\tif ( !attaches ) {\n\t\t\t\t\tdoc.removeEventListener( orig, handler, true );\n\t\t\t\t\tdataPriv.remove( doc, fix );\n\n\t\t\t\t} else {\n\t\t\t\t\tdataPriv.access( doc, fix, attaches );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t} );\n}\n\n\njQuery.fn.extend( {\n\twrapAll: function( html ) {\n\t\tvar wrap;\n\n\t\tif ( this[ 0 ] ) {\n\t\t\tif ( jQuery.isFunction( html ) ) {\n\t\t\t\thtml = html.call( this[ 0 ] );\n\t\t\t}\n\n\t\t\t// The elements to wrap the target around\n\t\t\twrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );\n\n\t\t\tif ( this[ 0 ].parentNode ) {\n\t\t\t\twrap.insertBefore( this[ 0 ] );\n\t\t\t}\n\n\t\t\twrap.map( function() {\n\t\t\t\tvar elem = this;\n\n\t\t\t\twhile ( elem.firstElementChild ) {\n\t\t\t\t\telem = elem.firstElementChild;\n\t\t\t\t}\n\n\t\t\t\treturn elem;\n\t\t\t} ).append( this );\n\t\t}\n\n\t\treturn this;\n\t},\n\n\twrapInner: function( html ) {\n\t\tif ( jQuery.isFunction( html ) ) {\n\t\t\treturn this.each( function( i ) {\n\t\t\t\tjQuery( this ).wrapInner( html.call( this, i ) );\n\t\t\t} );\n\t\t}\n\n\t\treturn this.each( function() {\n\t\t\tvar self = jQuery( this ),\n\t\t\t\tcontents = self.contents();\n\n\t\t\tif ( contents.length ) {\n\t\t\t\tcontents.wrapAll( html );\n\n\t\t\t} else {\n\t\t\t\tself.append( html );\n\t\t\t}\n\t\t} );\n\t},\n\n\twrap: function( html ) {\n\t\tvar isFunction = jQuery.isFunction( html );\n\n\t\treturn this.each( function( i ) {\n\t\t\tjQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );\n\t\t} );\n\t},\n\n\tunwrap: function( selector ) {\n\t\tthis.parent( selector ).not( \"body\" ).each( function() {\n\t\t\tjQuery( this ).replaceWith( this.childNodes );\n\t\t} );\n\t\treturn this;\n\t}\n} );\n\n\njQuery.expr.filters.hidden = function( elem ) {\n\treturn !jQuery.expr.filters.visible( elem );\n};\njQuery.expr.filters.visible = function( elem ) {\n\treturn !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );\n};\n\n\n\n\nvar\n\trbracket = /\\[\\]$/,\n\trCRLF = /\\r?\\n/g,\n\trsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,\n\trsubmittable = /^(?:input|select|textarea|keygen)/i;\n\nfunction buildParams( prefix, obj, traditional, add ) {\n\tvar name;\n\n\tif ( jQuery.isArray( obj ) ) {\n\n\t\t// Serialize array item.\n\t\tjQuery.each( obj, function( i, v ) {\n\t\t\tif ( traditional || rbracket.test( prefix ) ) {\n\n\t\t\t\t// Treat each array item as a scalar.\n\t\t\t\tadd( prefix, v );\n\n\t\t\t} else {\n\n\t\t\t\t// Item is non-scalar (array or object), encode its numeric index.\n\t\t\t\tbuildParams(\n\t\t\t\t\tprefix + \"[\" + ( typeof v === \"object\" && v != null ? i : \"\" ) + \"]\",\n\t\t\t\t\tv,\n\t\t\t\t\ttraditional,\n\t\t\t\t\tadd\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t} else if ( !traditional && jQuery.type( obj ) === \"object\" ) {\n\n\t\t// Serialize object item.\n\t\tfor ( name in obj ) {\n\t\t\tbuildParams( prefix + \"[\" + name + \"]\", obj[ name ], traditional, add );\n\t\t}\n\n\t} else {\n\n\t\t// Serialize scalar item.\n\t\tadd( prefix, obj );\n\t}\n}\n\n// Serialize an array of form elements or a set of\n// key/values into a query string\njQuery.param = function( a, traditional ) {\n\tvar prefix,\n\t\ts = [],\n\t\tadd = function( key, value ) {\n\n\t\t\t// If value is a function, invoke it and return its value\n\t\t\tvalue = jQuery.isFunction( value ) ? value() : ( value == null ? \"\" : value );\n\t\t\ts[ s.length ] = encodeURIComponent( key ) + \"=\" + encodeURIComponent( value );\n\t\t};\n\n\t// Set traditional to true for jQuery <= 1.3.2 behavior.\n\tif ( traditional === undefined ) {\n\t\ttraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;\n\t}\n\n\t// If an array was passed in, assume that it is an array of form elements.\n\tif ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {\n\n\t\t// Serialize the form elements\n\t\tjQuery.each( a, function() {\n\t\t\tadd( this.name, this.value );\n\t\t} );\n\n\t} else {\n\n\t\t// If traditional, encode the \"old\" way (the way 1.3.2 or older\n\t\t// did it), otherwise encode params recursively.\n\t\tfor ( prefix in a ) {\n\t\t\tbuildParams( prefix, a[ prefix ], traditional, add );\n\t\t}\n\t}\n\n\t// Return the resulting serialization\n\treturn s.join( \"&\" );\n};\n\njQuery.fn.extend( {\n\tserialize: function() {\n\t\treturn jQuery.param( this.serializeArray() );\n\t},\n\tserializeArray: function() {\n\t\treturn this.map( function() {\n\n\t\t\t// Can add propHook for \"elements\" to filter or add form elements\n\t\t\tvar elements = jQuery.prop( this, \"elements\" );\n\t\t\treturn elements ? jQuery.makeArray( elements ) : this;\n\t\t} )\n\t\t.filter( function() {\n\t\t\tvar type = this.type;\n\n\t\t\t// Use .is( \":disabled\" ) so that fieldset[disabled] works\n\t\t\treturn this.name && !jQuery( this ).is( \":disabled\" ) &&\n\t\t\t\trsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&\n\t\t\t\t( this.checked || !rcheckableType.test( type ) );\n\t\t} )\n\t\t.map( function( i, elem ) {\n\t\t\tvar val = jQuery( this ).val();\n\n\t\t\treturn val == null ?\n\t\t\t\tnull :\n\t\t\t\tjQuery.isArray( val ) ?\n\t\t\t\t\tjQuery.map( val, function( val ) {\n\t\t\t\t\t\treturn { name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t\t\t\t} ) :\n\t\t\t\t\t{ name: elem.name, value: val.replace( rCRLF, \"\\r\\n\" ) };\n\t\t} ).get();\n\t}\n} );\n\n\n// Support: Safari 8+\n// In Safari 8 documents created via document.implementation.createHTMLDocument\n// collapse sibling forms: the second one becomes a child of the first one.\n// Because of that, this security measure has to be disabled in Safari 8.\n// https://bugs.webkit.org/show_bug.cgi?id=137337\nsupport.createHTMLDocument = ( function() {\n\tvar body = document.implementation.createHTMLDocument( \"\" ).body;\n\tbody.innerHTML = \"<form></form><form></form>\";\n\treturn body.childNodes.length === 2;\n} )();\n\n\n// Argument \"data\" should be string of html\n// context (optional): If specified, the fragment will be created in this context,\n// defaults to document\n// keepScripts (optional): If true, will include scripts passed in the html string\njQuery.parseHTML = function( data, context, keepScripts ) {\n\tif ( typeof data !== \"string\" ) {\n\t\treturn [];\n\t}\n\tif ( typeof context === \"boolean\" ) {\n\t\tkeepScripts = context;\n\t\tcontext = false;\n\t}\n\n\t// Stop scripts or inline event handlers from being executed immediately\n\t// by using document.implementation\n\tcontext = context || ( support.createHTMLDocument ?\n\t\tdocument.implementation.createHTMLDocument( \"\" ) :\n\t\tdocument );\n\n\tvar parsed = rsingleTag.exec( data ),\n\t\tscripts = !keepScripts && [];\n\n\t// Single tag\n\tif ( parsed ) {\n\t\treturn [ context.createElement( parsed[ 1 ] ) ];\n\t}\n\n\tparsed = buildFragment( [ data ], context, scripts );\n\n\tif ( scripts && scripts.length ) {\n\t\tjQuery( scripts ).remove();\n\t}\n\n\treturn jQuery.merge( [], parsed.childNodes );\n};\n\n\n/**\n * Gets a window from an element\n */\nfunction getWindow( elem ) {\n\treturn jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;\n}\n\njQuery.offset = {\n\tsetOffset: function( elem, options, i ) {\n\t\tvar curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,\n\t\t\tposition = jQuery.css( elem, \"position\" ),\n\t\t\tcurElem = jQuery( elem ),\n\t\t\tprops = {};\n\n\t\t// Set position first, in-case top/left are set even on static elem\n\t\tif ( position === \"static\" ) {\n\t\t\telem.style.position = \"relative\";\n\t\t}\n\n\t\tcurOffset = curElem.offset();\n\t\tcurCSSTop = jQuery.css( elem, \"top\" );\n\t\tcurCSSLeft = jQuery.css( elem, \"left\" );\n\t\tcalculatePosition = ( position === \"absolute\" || position === \"fixed\" ) &&\n\t\t\t( curCSSTop + curCSSLeft ).indexOf( \"auto\" ) > -1;\n\n\t\t// Need to be able to calculate position if either\n\t\t// top or left is auto and position is either absolute or fixed\n\t\tif ( calculatePosition ) {\n\t\t\tcurPosition = curElem.position();\n\t\t\tcurTop = curPosition.top;\n\t\t\tcurLeft = curPosition.left;\n\n\t\t} else {\n\t\t\tcurTop = parseFloat( curCSSTop ) || 0;\n\t\t\tcurLeft = parseFloat( curCSSLeft ) || 0;\n\t\t}\n\n\t\tif ( jQuery.isFunction( options ) ) {\n\n\t\t\t// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)\n\t\t\toptions = options.call( elem, i, jQuery.extend( {}, curOffset ) );\n\t\t}\n\n\t\tif ( options.top != null ) {\n\t\t\tprops.top = ( options.top - curOffset.top ) + curTop;\n\t\t}\n\t\tif ( options.left != null ) {\n\t\t\tprops.left = ( options.left - curOffset.left ) + curLeft;\n\t\t}\n\n\t\tif ( \"using\" in options ) {\n\t\t\toptions.using.call( elem, props );\n\n\t\t} else {\n\t\t\tcurElem.css( props );\n\t\t}\n\t}\n};\n\njQuery.fn.extend( {\n\toffset: function( options ) {\n\n\t\t// Preserve chaining for setter\n\t\tif ( arguments.length ) {\n\t\t\treturn options === undefined ?\n\t\t\t\tthis :\n\t\t\t\tthis.each( function( i ) {\n\t\t\t\t\tjQuery.offset.setOffset( this, options, i );\n\t\t\t\t} );\n\t\t}\n\n\t\tvar docElem, win, rect, doc,\n\t\t\telem = this[ 0 ];\n\n\t\tif ( !elem ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Support: IE<=11+\n\t\t// Running getBoundingClientRect on a\n\t\t// disconnected node in IE throws an error\n\t\tif ( !elem.getClientRects().length ) {\n\t\t\treturn { top: 0, left: 0 };\n\t\t}\n\n\t\trect = elem.getBoundingClientRect();\n\n\t\t// Make sure element is not hidden (display: none)\n\t\tif ( rect.width || rect.height ) {\n\t\t\tdoc = elem.ownerDocument;\n\t\t\twin = getWindow( doc );\n\t\t\tdocElem = doc.documentElement;\n\n\t\t\treturn {\n\t\t\t\ttop: rect.top + win.pageYOffset - docElem.clientTop,\n\t\t\t\tleft: rect.left + win.pageXOffset - docElem.clientLeft\n\t\t\t};\n\t\t}\n\n\t\t// Return zeros for disconnected and hidden elements (gh-2310)\n\t\treturn rect;\n\t},\n\n\tposition: function() {\n\t\tif ( !this[ 0 ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar offsetParent, offset,\n\t\t\telem = this[ 0 ],\n\t\t\tparentOffset = { top: 0, left: 0 };\n\n\t\t// Fixed elements are offset from window (parentOffset = {top:0, left: 0},\n\t\t// because it is its only offset parent\n\t\tif ( jQuery.css( elem, \"position\" ) === \"fixed\" ) {\n\n\t\t\t// Assume getBoundingClientRect is there when computed position is fixed\n\t\t\toffset = elem.getBoundingClientRect();\n\n\t\t} else {\n\n\t\t\t// Get *real* offsetParent\n\t\t\toffsetParent = this.offsetParent();\n\n\t\t\t// Get correct offsets\n\t\t\toffset = this.offset();\n\t\t\tif ( !jQuery.nodeName( offsetParent[ 0 ], \"html\" ) ) {\n\t\t\t\tparentOffset = offsetParent.offset();\n\t\t\t}\n\n\t\t\t// Add offsetParent borders\n\t\t\t// Subtract offsetParent scroll positions\n\t\t\tparentOffset.top += jQuery.css( offsetParent[ 0 ], \"borderTopWidth\", true ) -\n\t\t\t\toffsetParent.scrollTop();\n\t\t\tparentOffset.left += jQuery.css( offsetParent[ 0 ], \"borderLeftWidth\", true ) -\n\t\t\t\toffsetParent.scrollLeft();\n\t\t}\n\n\t\t// Subtract parent offsets and element margins\n\t\treturn {\n\t\t\ttop: offset.top - parentOffset.top - jQuery.css( elem, \"marginTop\", true ),\n\t\t\tleft: offset.left - parentOffset.left - jQuery.css( elem, \"marginLeft\", true )\n\t\t};\n\t},\n\n\t// This method will return documentElement in the following cases:\n\t// 1) For the element inside the iframe without offsetParent, this method will return\n\t//    documentElement of the parent window\n\t// 2) For the hidden or detached element\n\t// 3) For body or html element, i.e. in case of the html node - it will return itself\n\t//\n\t// but those exceptions were never presented as a real life use-cases\n\t// and might be considered as more preferable results.\n\t//\n\t// This logic, however, is not guaranteed and can change at any point in the future\n\toffsetParent: function() {\n\t\treturn this.map( function() {\n\t\t\tvar offsetParent = this.offsetParent;\n\n\t\t\twhile ( offsetParent && jQuery.css( offsetParent, \"position\" ) === \"static\" ) {\n\t\t\t\toffsetParent = offsetParent.offsetParent;\n\t\t\t}\n\n\t\t\treturn offsetParent || documentElement;\n\t\t} );\n\t}\n} );\n\n// Create scrollLeft and scrollTop methods\njQuery.each( { scrollLeft: \"pageXOffset\", scrollTop: \"pageYOffset\" }, function( method, prop ) {\n\tvar top = \"pageYOffset\" === prop;\n\n\tjQuery.fn[ method ] = function( val ) {\n\t\treturn access( this, function( elem, method, val ) {\n\t\t\tvar win = getWindow( elem );\n\n\t\t\tif ( val === undefined ) {\n\t\t\t\treturn win ? win[ prop ] : elem[ method ];\n\t\t\t}\n\n\t\t\tif ( win ) {\n\t\t\t\twin.scrollTo(\n\t\t\t\t\t!top ? val : win.pageXOffset,\n\t\t\t\t\ttop ? val : win.pageYOffset\n\t\t\t\t);\n\n\t\t\t} else {\n\t\t\t\telem[ method ] = val;\n\t\t\t}\n\t\t}, method, val, arguments.length );\n\t};\n} );\n\n// Support: Safari<7-8+, Chrome<37-44+\n// Add the top/left cssHooks using jQuery.fn.position\n// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084\n// Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280\n// getComputedStyle returns percent when specified for top/left/bottom/right;\n// rather than make the css module depend on the offset module, just check for it here\njQuery.each( [ \"top\", \"left\" ], function( i, prop ) {\n\tjQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,\n\t\tfunction( elem, computed ) {\n\t\t\tif ( computed ) {\n\t\t\t\tcomputed = curCSS( elem, prop );\n\n\t\t\t\t// If curCSS returns percentage, fallback to offset\n\t\t\t\treturn rnumnonpx.test( computed ) ?\n\t\t\t\t\tjQuery( elem ).position()[ prop ] + \"px\" :\n\t\t\t\t\tcomputed;\n\t\t\t}\n\t\t}\n\t);\n} );\n\n\n// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods\njQuery.each( { Height: \"height\", Width: \"width\" }, function( name, type ) {\n\tjQuery.each( { padding: \"inner\" + name, content: type, \"\": \"outer\" + name },\n\t\tfunction( defaultExtra, funcName ) {\n\n\t\t// Margin is only for outerHeight, outerWidth\n\t\tjQuery.fn[ funcName ] = function( margin, value ) {\n\t\t\tvar chainable = arguments.length && ( defaultExtra || typeof margin !== \"boolean\" ),\n\t\t\t\textra = defaultExtra || ( margin === true || value === true ? \"margin\" : \"border\" );\n\n\t\t\treturn access( this, function( elem, type, value ) {\n\t\t\t\tvar doc;\n\n\t\t\t\tif ( jQuery.isWindow( elem ) ) {\n\n\t\t\t\t\t// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)\n\t\t\t\t\treturn funcName.indexOf( \"outer\" ) === 0 ?\n\t\t\t\t\t\telem[ \"inner\" + name ] :\n\t\t\t\t\t\telem.document.documentElement[ \"client\" + name ];\n\t\t\t\t}\n\n\t\t\t\t// Get document width or height\n\t\t\t\tif ( elem.nodeType === 9 ) {\n\t\t\t\t\tdoc = elem.documentElement;\n\n\t\t\t\t\t// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],\n\t\t\t\t\t// whichever is greatest\n\t\t\t\t\treturn Math.max(\n\t\t\t\t\t\telem.body[ \"scroll\" + name ], doc[ \"scroll\" + name ],\n\t\t\t\t\t\telem.body[ \"offset\" + name ], doc[ \"offset\" + name ],\n\t\t\t\t\t\tdoc[ \"client\" + name ]\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn value === undefined ?\n\n\t\t\t\t\t// Get width or height on the element, requesting but not forcing parseFloat\n\t\t\t\t\tjQuery.css( elem, type, extra ) :\n\n\t\t\t\t\t// Set width or height on the element\n\t\t\t\t\tjQuery.style( elem, type, value, extra );\n\t\t\t}, type, chainable ? margin : undefined, chainable );\n\t\t};\n\t} );\n} );\n\n\n// Register as a named AMD module, since jQuery can be concatenated with other\n// files that may use define, but not via a proper concatenation script that\n// understands anonymous AMD modules. A named AMD is safest and most robust\n// way to register. Lowercase jquery is used because AMD module names are\n// derived from file names, and jQuery is normally delivered in a lowercase\n// file name. Do this after creating the global so that if an AMD module wants\n// to call noConflict to hide this version of jQuery, it will work.\n\n// Note that for maximum portability, libraries that are not jQuery should\n// declare themselves as anonymous modules, and avoid setting a global if an\n// AMD loader is present. jQuery is a special case. For more information, see\n// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon\n\nif ( typeof define === \"function\" && define.amd ) {\n\tdefine( \"jquery\", [], function() {\n\t\treturn jQuery;\n\t} );\n}\n\n\n\nvar\n\n\t// Map over jQuery in case of overwrite\n\t_jQuery = window.jQuery,\n\n\t// Map over the $ in case of overwrite\n\t_$ = window.$;\n\njQuery.noConflict = function( deep ) {\n\tif ( window.$ === jQuery ) {\n\t\twindow.$ = _$;\n\t}\n\n\tif ( deep && window.jQuery === jQuery ) {\n\t\twindow.jQuery = _jQuery;\n\t}\n\n\treturn jQuery;\n};\n\n// Expose jQuery and $ identifiers, even in AMD\n// (#7102#comment:10, https://github.com/jquery/jquery/pull/557)\n// and CommonJS for browser emulators (#13566)\nif ( !noGlobal ) {\n\twindow.jQuery = window.$ = jQuery;\n}\n\nreturn jQuery;\n}));\n"
  },
  {
    "path": "html/lib/nvd3/nv.d3.css",
    "content": "/* nvd3 version 1.8.2 (https://github.com/novus/nvd3) 2016-01-24 */\n.nvd3 .nv-axis {\r\n    pointer-events:none;\r\n    opacity: 1;\r\n}\r\n\r\n.nvd3 .nv-axis path {\r\n    fill: none;\r\n    stroke: #000;\r\n    stroke-opacity: .75;\r\n    shape-rendering: crispEdges;\r\n}\r\n\r\n.nvd3 .nv-axis path.domain {\r\n    stroke-opacity: .75;\r\n}\r\n\r\n.nvd3 .nv-axis.nv-x path.domain {\r\n    stroke-opacity: 0;\r\n}\r\n\r\n.nvd3 .nv-axis line {\r\n    fill: none;\r\n    stroke: #e5e5e5;\r\n    shape-rendering: crispEdges;\r\n}\r\n\r\n.nvd3 .nv-axis .zero line,\r\n    /*this selector may not be necessary*/ .nvd3 .nv-axis line.zero {\r\n    stroke-opacity: .75;\r\n}\r\n\r\n.nvd3 .nv-axis .nv-axisMaxMin text {\r\n    font-weight: bold;\r\n}\r\n\r\n.nvd3 .x  .nv-axis .nv-axisMaxMin text,\r\n.nvd3 .x2 .nv-axis .nv-axisMaxMin text,\r\n.nvd3 .x3 .nv-axis .nv-axisMaxMin text {\r\n    text-anchor: middle\r\n}\r\n\r\n.nvd3 .nv-axis.nv-disabled {\r\n    opacity: 0;\r\n}\r\n\n.nvd3 .nv-bars rect {\r\n    fill-opacity: .75;\r\n\r\n    transition: fill-opacity 250ms linear;\r\n    -moz-transition: fill-opacity 250ms linear;\r\n    -webkit-transition: fill-opacity 250ms linear;\r\n}\r\n\r\n.nvd3 .nv-bars rect.hover {\r\n    fill-opacity: 1;\r\n}\r\n\r\n.nvd3 .nv-bars .hover rect {\r\n    fill: lightblue;\r\n}\r\n\r\n.nvd3 .nv-bars text {\r\n    fill: rgba(0,0,0,0);\r\n}\r\n\r\n.nvd3 .nv-bars .hover text {\r\n    fill: rgba(0,0,0,1);\r\n}\r\n\r\n.nvd3 .nv-multibar .nv-groups rect,\r\n.nvd3 .nv-multibarHorizontal .nv-groups rect,\r\n.nvd3 .nv-discretebar .nv-groups rect {\r\n    stroke-opacity: 0;\r\n\r\n    transition: fill-opacity 250ms linear;\r\n    -moz-transition: fill-opacity 250ms linear;\r\n    -webkit-transition: fill-opacity 250ms linear;\r\n}\r\n\r\n.nvd3 .nv-multibar .nv-groups rect:hover,\r\n.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,\r\n.nvd3 .nv-candlestickBar .nv-ticks rect:hover,\r\n.nvd3 .nv-discretebar .nv-groups rect:hover {\r\n    fill-opacity: 1;\r\n}\r\n\r\n.nvd3 .nv-discretebar .nv-groups text,\r\n.nvd3 .nv-multibarHorizontal .nv-groups text {\r\n    font-weight: bold;\r\n    fill: rgba(0,0,0,1);\r\n    stroke: rgba(0,0,0,0);\r\n}\r\n\n/* boxplot CSS */\n.nvd3 .nv-boxplot circle {\n  fill-opacity: 0.5;\n}\n\n.nvd3 .nv-boxplot circle:hover {\n  fill-opacity: 1;\n}\n\n.nvd3 .nv-boxplot rect:hover {\n  fill-opacity: 1;\n}\n\n.nvd3 line.nv-boxplot-median {\n  stroke: black;\n}\n\n.nv-boxplot-tick:hover {\n  stroke-width: 2.5px;\n}\n/* bullet */\r\n.nvd3.nv-bullet { font: 10px sans-serif; }\r\n.nvd3.nv-bullet .nv-measure { fill-opacity: .8; }\r\n.nvd3.nv-bullet .nv-measure:hover { fill-opacity: 1; }\r\n.nvd3.nv-bullet .nv-marker { stroke: #000; stroke-width: 2px; }\r\n.nvd3.nv-bullet .nv-markerTriangle { stroke: #000; fill: #fff; stroke-width: 1.5px; }\r\n.nvd3.nv-bullet .nv-tick line { stroke: #666; stroke-width: .5px; }\r\n.nvd3.nv-bullet .nv-range.nv-s0 { fill: #eee; }\r\n.nvd3.nv-bullet .nv-range.nv-s1 { fill: #ddd; }\r\n.nvd3.nv-bullet .nv-range.nv-s2 { fill: #ccc; }\r\n.nvd3.nv-bullet .nv-title { font-size: 14px; font-weight: bold; }\r\n.nvd3.nv-bullet .nv-subtitle { fill: #999; }\r\n\r\n\r\n.nvd3.nv-bullet .nv-range {\r\n    fill: #bababa;\r\n    fill-opacity: .4;\r\n}\r\n.nvd3.nv-bullet .nv-range:hover {\r\n    fill-opacity: .7;\r\n}\r\n\n.nvd3.nv-candlestickBar .nv-ticks .nv-tick {\r\n    stroke-width: 1px;\r\n}\r\n\r\n.nvd3.nv-candlestickBar .nv-ticks .nv-tick.hover {\r\n    stroke-width: 2px;\r\n}\r\n\r\n.nvd3.nv-candlestickBar .nv-ticks .nv-tick.positive rect {\r\n    stroke: #2ca02c;\r\n    fill: #2ca02c;\r\n}\r\n\r\n.nvd3.nv-candlestickBar .nv-ticks .nv-tick.negative rect {\r\n    stroke: #d62728;\r\n    fill: #d62728;\r\n}\r\n\r\n.with-transitions .nv-candlestickBar .nv-ticks .nv-tick {\r\n    transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n\r\n}\r\n\r\n.nvd3.nv-candlestickBar .nv-ticks line {\r\n    stroke: #333;\r\n}\r\n\r\n\n.nvd3 .nv-legend .nv-disabled rect {\n    /*fill-opacity: 0;*/\n}\n\n.nvd3 .nv-check-box .nv-box {\n    fill-opacity:0;\n    stroke-width:2;\n}\n\n.nvd3 .nv-check-box .nv-check {\n    fill-opacity:0;\n    stroke-width:4;\n}\n\n.nvd3 .nv-series.nv-disabled .nv-check-box .nv-check {\n    fill-opacity:0;\n    stroke-opacity:0;\n}\n\n.nvd3 .nv-controlsWrap .nv-legend .nv-check-box .nv-check {\n    opacity: 0;\n}\n\n/* line plus bar */\r\n.nvd3.nv-linePlusBar .nv-bar rect {\r\n    fill-opacity: .75;\r\n}\r\n\r\n.nvd3.nv-linePlusBar .nv-bar rect:hover {\r\n    fill-opacity: 1;\r\n}\n.nvd3 .nv-groups path.nv-line {\r\n    fill: none;\r\n}\r\n\r\n.nvd3 .nv-groups path.nv-area {\r\n    stroke: none;\r\n}\r\n\r\n.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point {\r\n    fill-opacity: 0;\r\n    stroke-opacity: 0;\r\n}\r\n\r\n.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point {\r\n    fill-opacity: .5 !important;\r\n    stroke-opacity: .5 !important;\r\n}\r\n\r\n\r\n.with-transitions .nvd3 .nv-groups .nv-point {\r\n    transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n\r\n}\r\n\r\n.nvd3.nv-scatter .nv-groups .nv-point.hover,\r\n.nvd3 .nv-groups .nv-point.hover {\r\n    stroke-width: 7px;\r\n    fill-opacity: .95 !important;\r\n    stroke-opacity: .95 !important;\r\n}\r\n\r\n\r\n.nvd3 .nv-point-paths path {\r\n    stroke: #aaa;\r\n    stroke-opacity: 0;\r\n    fill: #eee;\r\n    fill-opacity: 0;\r\n}\r\n\r\n\r\n\r\n.nvd3 .nv-indexLine {\r\n    cursor: ew-resize;\r\n}\r\n\n/********************\r\n * SVG CSS\r\n */\r\n\r\n/********************\r\n  Default CSS for an svg element nvd3 used\r\n*/\r\nsvg.nvd3-svg {\r\n    -webkit-touch-callout: none;\r\n    -webkit-user-select: none;\r\n    -khtml-user-select: none;\r\n    -ms-user-select: none;\r\n    -moz-user-select: none;\r\n    user-select: none;\r\n    display: block;\r\n    width:100%;\r\n    height:100%;\r\n}\r\n\r\n/********************\r\n  Box shadow and border radius styling\r\n*/\r\n.nvtooltip.with-3d-shadow, .with-3d-shadow .nvtooltip {\r\n    -moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);\r\n    -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);\r\n    box-shadow: 0 5px 10px rgba(0,0,0,.2);\r\n\r\n    -webkit-border-radius: 5px;\r\n    -moz-border-radius: 5px;\r\n    border-radius: 5px;\r\n}\r\n\r\n\r\n.nvd3 text {\r\n    font: normal 12px Arial;\r\n}\r\n\r\n.nvd3 .title {\r\n    font: bold 14px Arial;\r\n}\r\n\r\n.nvd3 .nv-background {\r\n    fill: white;\r\n    fill-opacity: 0;\r\n}\r\n\r\n.nvd3.nv-noData {\r\n    font-size: 18px;\r\n    font-weight: bold;\r\n}\r\n\r\n\r\n/**********\r\n*  Brush\r\n*/\r\n\r\n.nv-brush .extent {\r\n    fill-opacity: .125;\r\n    shape-rendering: crispEdges;\r\n}\r\n\r\n.nv-brush .resize path {\r\n    fill: #eee;\r\n    stroke: #666;\r\n}\r\n\r\n\r\n/**********\r\n*  Legend\r\n*/\r\n\r\n.nvd3 .nv-legend .nv-series {\r\n    cursor: pointer;\r\n}\r\n\r\n.nvd3 .nv-legend .nv-disabled circle {\r\n    fill-opacity: 0;\r\n}\r\n\r\n/* focus */\r\n.nvd3 .nv-brush .extent {\r\n    fill-opacity: 0 !important;\r\n}\r\n\r\n.nvd3 .nv-brushBackground rect {\r\n    stroke: #000;\r\n    stroke-width: .4;\r\n    fill: #fff;\r\n    fill-opacity: .7;\r\n}\r\n\r\n\n.nvd3.nv-ohlcBar .nv-ticks .nv-tick {\r\n    stroke-width: 1px;\r\n}\r\n\r\n.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover {\r\n    stroke-width: 2px;\r\n}\r\n\r\n.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive {\r\n    stroke: #2ca02c;\r\n}\r\n\r\n.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative {\r\n    stroke: #d62728;\r\n}\r\n\r\n\n.nvd3 .background path {\r\n    fill: none;\r\n    stroke: #EEE;\r\n    stroke-opacity: .4;\r\n    shape-rendering: crispEdges;\r\n}\r\n\r\n.nvd3 .foreground path {\r\n    fill: none;\r\n    stroke-opacity: .7;\r\n}\r\n\r\n.nvd3 .nv-parallelCoordinates-brush .extent \r\n{\r\n    fill: #fff;\r\n    fill-opacity: .6;\r\n    stroke: gray;\r\n    shape-rendering: crispEdges;\r\n}\r\n\r\n.nvd3 .nv-parallelCoordinates .hover  {\r\n    fill-opacity: 1;\r\n\tstroke-width: 3px;\r\n}\r\n\r\n\r\n.nvd3 .missingValuesline line {\r\n  fill: none;\r\n  stroke: black;\r\n  stroke-width: 1;\r\n  stroke-opacity: 1;\r\n  stroke-dasharray: 5, 5; \r\n}\n.nvd3.nv-pie path {\r\n    stroke-opacity: 0;\r\n    transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -moz-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n    -webkit-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;\r\n\r\n}\r\n\r\n.nvd3.nv-pie .nv-pie-title {\r\n    font-size: 24px;\r\n    fill: rgba(19, 196, 249, 0.59);\r\n}\r\n\r\n.nvd3.nv-pie .nv-slice text {\r\n    stroke: #000;\r\n    stroke-width: 0;\r\n}\r\n\r\n.nvd3.nv-pie path {\r\n    stroke: #fff;\r\n    stroke-width: 1px;\r\n    stroke-opacity: 1;\r\n}\r\n\r\n.nvd3.nv-pie path {\r\n    fill-opacity: .7;\r\n}\r\n.nvd3.nv-pie .hover path {\r\n    fill-opacity: 1;\r\n}\r\n.nvd3.nv-pie .nv-label {\r\n    pointer-events: none;\r\n}\r\n.nvd3.nv-pie .nv-label rect {\r\n    fill-opacity: 0;\r\n    stroke-opacity: 0;\r\n}\r\n\n/* scatter */\r\n.nvd3 .nv-groups .nv-point.hover {\r\n    stroke-width: 20px;\r\n    stroke-opacity: .5;\r\n}\r\n\r\n.nvd3 .nv-scatter .nv-point.hover {\r\n    fill-opacity: 1;\r\n}\r\n.nv-noninteractive {\r\n    pointer-events: none;\r\n}\r\n\r\n.nv-distx, .nv-disty {\r\n    pointer-events: none;\r\n}\r\n\n/* sparkline */\r\n.nvd3.nv-sparkline path {\r\n    fill: none;\r\n}\r\n\r\n.nvd3.nv-sparklineplus g.nv-hoverValue {\r\n    pointer-events: none;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-hoverValue line {\r\n    stroke: #333;\r\n    stroke-width: 1.5px;\r\n}\r\n\r\n.nvd3.nv-sparklineplus,\r\n.nvd3.nv-sparklineplus g {\r\n    pointer-events: all;\r\n}\r\n\r\n.nvd3 .nv-hoverArea {\r\n    fill-opacity: 0;\r\n    stroke-opacity: 0;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-xValue,\r\n.nvd3.nv-sparklineplus .nv-yValue {\r\n    stroke-width: 0;\r\n    font-size: .9em;\r\n    font-weight: normal;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-yValue {\r\n    stroke: #f66;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-maxValue {\r\n    stroke: #2ca02c;\r\n    fill: #2ca02c;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-minValue {\r\n    stroke: #d62728;\r\n    fill: #d62728;\r\n}\r\n\r\n.nvd3.nv-sparklineplus .nv-currentValue {\r\n    font-weight: bold;\r\n    font-size: 1.1em;\r\n}\n/* stacked area */\r\n.nvd3.nv-stackedarea path.nv-area {\r\n    fill-opacity: .7;\r\n    stroke-opacity: 0;\r\n    transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;\r\n    -moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;\r\n    -webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;\r\n}\r\n\r\n.nvd3.nv-stackedarea path.nv-area.hover {\r\n    fill-opacity: .9;\r\n}\r\n\r\n\r\n.nvd3.nv-stackedarea .nv-groups .nv-point {\r\n    stroke-opacity: 0;\r\n    fill-opacity: 0;\r\n}\n\r\n\r\n.nvtooltip {\r\n    position: absolute;\r\n    background-color: rgba(255,255,255,1.0);\r\n    color: rgba(0,0,0,1.0);\r\n    padding: 1px;\r\n    border: 1px solid rgba(0,0,0,.2);\r\n    z-index: 10000;\r\n    display: block;\r\n\r\n    font-family: Arial;\r\n    font-size: 13px;\r\n    text-align: left;\r\n    pointer-events: none;\r\n\r\n    white-space: nowrap;\r\n\r\n    -webkit-touch-callout: none;\r\n    -webkit-user-select: none;\r\n    -khtml-user-select: none;\r\n    -moz-user-select: none;\r\n    -ms-user-select: none;\r\n    user-select: none;\r\n}\r\n\r\n.nvtooltip {\r\n    background: rgba(255,255,255, 0.8);\r\n    border: 1px solid rgba(0,0,0,0.5);\r\n    border-radius: 4px;\r\n}\r\n\r\n/*Give tooltips that old fade in transition by\r\n    putting a \"with-transitions\" class on the container div.\r\n*/\r\n.nvtooltip.with-transitions, .with-transitions .nvtooltip {\r\n    transition: opacity 50ms linear;\r\n    -moz-transition: opacity 50ms linear;\r\n    -webkit-transition: opacity 50ms linear;\r\n\r\n    transition-delay: 200ms;\r\n    -moz-transition-delay: 200ms;\r\n    -webkit-transition-delay: 200ms;\r\n}\r\n\r\n.nvtooltip.x-nvtooltip,\r\n.nvtooltip.y-nvtooltip {\r\n    padding: 8px;\r\n}\r\n\r\n.nvtooltip h3 {\r\n    margin: 0;\r\n    padding: 4px 14px;\r\n    line-height: 18px;\r\n    font-weight: normal;\r\n    background-color: rgba(247,247,247,0.75);\r\n    color: rgba(0,0,0,1.0);\r\n    text-align: center;\r\n\r\n    border-bottom: 1px solid #ebebeb;\r\n\r\n    -webkit-border-radius: 5px 5px 0 0;\r\n    -moz-border-radius: 5px 5px 0 0;\r\n    border-radius: 5px 5px 0 0;\r\n}\r\n\r\n.nvtooltip p {\r\n    margin: 0;\r\n    padding: 5px 14px;\r\n    text-align: center;\r\n}\r\n\r\n.nvtooltip span {\r\n    display: inline-block;\r\n    margin: 2px 0;\r\n}\r\n\r\n.nvtooltip table {\r\n    margin: 6px;\r\n    border-spacing:0;\r\n}\r\n\r\n\r\n.nvtooltip table td {\r\n    padding: 2px 9px 2px 0;\r\n    vertical-align: middle;\r\n}\r\n\r\n.nvtooltip table td.key {\r\n    font-weight: normal;\r\n}\r\n.nvtooltip table td.key.total {\r\n    font-weight: bold;\r\n}\r\n.nvtooltip table td.value {\r\n    text-align: right;\r\n    font-weight: bold;\r\n}\r\n\r\n.nvtooltip table tr.highlight td {\r\n    padding: 1px 9px 1px 0;\r\n    border-bottom-style: solid;\r\n    border-bottom-width: 1px;\r\n    border-top-style: solid;\r\n    border-top-width: 1px;\r\n}\r\n\r\n.nvtooltip table td.legend-color-guide div {\r\n    width: 8px;\r\n    height: 8px;\r\n    vertical-align: middle;\r\n}\r\n\r\n.nvtooltip table td.legend-color-guide div {\r\n    width: 12px;\r\n    height: 12px;\r\n    border: 1px solid #999;\r\n}\r\n\r\n.nvtooltip .footer {\r\n    padding: 3px;\r\n    text-align: center;\r\n}\r\n\r\n.nvtooltip-pending-removal {\r\n    pointer-events: none;\r\n    display: none;\r\n}\r\n\r\n\r\n/****\r\nInteractive Layer\r\n*/\r\n.nvd3 .nv-interactiveGuideLine {\r\n    pointer-events:none;\r\n}\r\n.nvd3 line.nv-guideline {\r\n    stroke: #ccc;\r\n}\r\n"
  },
  {
    "path": "html/lib/nvd3/nv.d3.js",
    "content": "/* nvd3 version 1.8.2 (https://github.com/novus/nvd3) 2016-01-24 */\n(function(){\n\n// set up main nv object\nvar nv = {};\n\n// the major global objects under the nv namespace\nnv.dev = false; //set false when in production\nnv.tooltip = nv.tooltip || {}; // For the tooltip system\nnv.utils = nv.utils || {}; // Utility subsystem\nnv.models = nv.models || {}; //stores all the possible models/components\nnv.charts = {}; //stores all the ready to use charts\nnv.logs = {}; //stores some statistics and potential error messages\nnv.dom = {}; //DOM manipulation functions\n\nnv.dispatch = d3.dispatch('render_start', 'render_end');\n\n// Function bind polyfill\n// Needed ONLY for phantomJS as it's missing until version 2.0 which is unreleased as of this comment\n// https://github.com/ariya/phantomjs/issues/10522\n// http://kangax.github.io/compat-table/es5/#Function.prototype.bind\n// phantomJS is used for running the test suite\nif (!Function.prototype.bind) {\n    Function.prototype.bind = function (oThis) {\n        if (typeof this !== \"function\") {\n            // closest thing possible to the ECMAScript 5 internal IsCallable function\n            throw new TypeError(\"Function.prototype.bind - what is trying to be bound is not callable\");\n        }\n\n        var aArgs = Array.prototype.slice.call(arguments, 1),\n            fToBind = this,\n            fNOP = function () {},\n            fBound = function () {\n                return fToBind.apply(this instanceof fNOP && oThis\n                        ? this\n                        : oThis,\n                    aArgs.concat(Array.prototype.slice.call(arguments)));\n            };\n\n        fNOP.prototype = this.prototype;\n        fBound.prototype = new fNOP();\n        return fBound;\n    };\n}\n\n//  Development render timers - disabled if dev = false\nif (nv.dev) {\n    nv.dispatch.on('render_start', function(e) {\n        nv.logs.startTime = +new Date();\n    });\n\n    nv.dispatch.on('render_end', function(e) {\n        nv.logs.endTime = +new Date();\n        nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime;\n        nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times\n    });\n}\n\n// Logs all arguments, and returns the last so you can test things in place\n// Note: in IE8 console.log is an object not a function, and if modernizr is used\n// then calling Function.prototype.bind with with anything other than a function\n// causes a TypeError to be thrown.\nnv.log = function() {\n    if (nv.dev && window.console && console.log && console.log.apply)\n        console.log.apply(console, arguments);\n    else if (nv.dev && window.console && typeof console.log == \"function\" && Function.prototype.bind) {\n        var log = Function.prototype.bind.call(console.log, console);\n        log.apply(console, arguments);\n    }\n    return arguments[arguments.length - 1];\n};\n\n// print console warning, should be used by deprecated functions\nnv.deprecated = function(name, info) {\n    if (console && console.warn) {\n        console.warn('nvd3 warning: `' + name + '` has been deprecated. ', info || '');\n    }\n};\n\n// The nv.render function is used to queue up chart rendering\n// in non-blocking async functions.\n// When all queued charts are done rendering, nv.dispatch.render_end is invoked.\nnv.render = function render(step) {\n    // number of graphs to generate in each timeout loop\n    step = step || 1;\n\n    nv.render.active = true;\n    nv.dispatch.render_start();\n\n    var renderLoop = function() {\n        var chart, graph;\n\n        for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) {\n            chart = graph.generate();\n            if (typeof graph.callback == typeof(Function)) graph.callback(chart);\n        }\n\n        nv.render.queue.splice(0, i);\n\n        if (nv.render.queue.length) {\n            setTimeout(renderLoop);\n        }\n        else {\n            nv.dispatch.render_end();\n            nv.render.active = false;\n        }\n    };\n\n    setTimeout(renderLoop);\n};\n\nnv.render.active = false;\nnv.render.queue = [];\n\n/*\nAdds a chart to the async rendering queue. This method can take arguments in two forms:\nnv.addGraph({\n    generate: <Function>\n    callback: <Function>\n})\n\nor\n\nnv.addGraph(<generate Function>, <callback Function>)\n\nThe generate function should contain code that creates the NVD3 model, sets options\non it, adds data to an SVG element, and invokes the chart model. The generate function\nshould return the chart model.  See examples/lineChart.html for a usage example.\n\nThe callback function is optional, and it is called when the generate function completes.\n*/\nnv.addGraph = function(obj) {\n    if (typeof arguments[0] === typeof(Function)) {\n        obj = {generate: arguments[0], callback: arguments[1]};\n    }\n\n    nv.render.queue.push(obj);\n\n    if (!nv.render.active) {\n        nv.render();\n    }\n};\n\n// Node/CommonJS exports\nif (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') {\n  module.exports = nv;\n}\n\nif (typeof(window) !== 'undefined') {\n  window.nv = nv;\n}\n/* Facade for queueing DOM write operations\r\n * with Fastdom (https://github.com/wilsonpage/fastdom)\r\n * if available.\r\n * This could easily be extended to support alternate\r\n * implementations in the future.\r\n */\r\nnv.dom.write = function(callback) {\r\n\tif (window.fastdom !== undefined) {\r\n\t\treturn fastdom.write(callback);\r\n\t}\r\n\treturn callback();\r\n};\r\n\r\n/* Facade for queueing DOM read operations\r\n * with Fastdom (https://github.com/wilsonpage/fastdom)\r\n * if available.\r\n * This could easily be extended to support alternate\r\n * implementations in the future.\r\n */\r\nnv.dom.read = function(callback) {\r\n\tif (window.fastdom !== undefined) {\r\n\t\treturn fastdom.read(callback);\r\n\t}\r\n\treturn callback();\r\n};/* Utility class to handle creation of an interactive layer.\n This places a rectangle on top of the chart. When you mouse move over it, it sends a dispatch\n containing the X-coordinate. It can also render a vertical line where the mouse is located.\n\n dispatch.elementMousemove is the important event to latch onto.  It is fired whenever the mouse moves over\n the rectangle. The dispatch is given one object which contains the mouseX/Y location.\n It also has 'pointXValue', which is the conversion of mouseX to the x-axis scale.\n */\nnv.interactiveGuideline = function() {\n    \"use strict\";\n\n    var margin = { left: 0, top: 0 } //Pass the chart's top and left magins. Used to calculate the mouseX/Y.\n        ,   width = null\n        ,   height = null\n        ,   xScale = d3.scale.linear()\n        ,   dispatch = d3.dispatch('elementMousemove', 'elementMouseout', 'elementClick', 'elementDblclick', 'elementMouseDown', 'elementMouseUp')\n        ,   showGuideLine = true\n        ,   svgContainer = null // Must pass the chart's svg, we'll use its mousemove event.\n        ,   tooltip = nv.models.tooltip()\n        ,   isMSIE = \"ActiveXObject\" in window // Checkt if IE by looking for activeX.\n    ;\n\n    tooltip\n        .duration(0)\n        .hideDelay(0)\n        .hidden(false);\n\n    function layer(selection) {\n        selection.each(function(data) {\n            var container = d3.select(this);\n            var availableWidth = (width || 960), availableHeight = (height || 400);\n            var wrap = container.selectAll(\"g.nv-wrap.nv-interactiveLineLayer\")\n                .data([data]);\n            var wrapEnter = wrap.enter()\n                .append(\"g\").attr(\"class\", \" nv-wrap nv-interactiveLineLayer\");\n            wrapEnter.append(\"g\").attr(\"class\",\"nv-interactiveGuideLine\");\n\n            if (!svgContainer) {\n                return;\n            }\n\n            function mouseHandler() {\n                var d3mouse = d3.mouse(this);\n                var mouseX = d3mouse[0];\n                var mouseY = d3mouse[1];\n                var subtractMargin = true;\n                var mouseOutAnyReason = false;\n                if (isMSIE) {\n                    /*\n                     D3.js (or maybe SVG.getScreenCTM) has a nasty bug in Internet Explorer 10.\n                     d3.mouse() returns incorrect X,Y mouse coordinates when mouse moving\n                     over a rect in IE 10.\n                     However, d3.event.offsetX/Y also returns the mouse coordinates\n                     relative to the triggering <rect>. So we use offsetX/Y on IE.\n                     */\n                    mouseX = d3.event.offsetX;\n                    mouseY = d3.event.offsetY;\n\n                    /*\n                     On IE, if you attach a mouse event listener to the <svg> container,\n                     it will actually trigger it for all the child elements (like <path>, <circle>, etc).\n                     When this happens on IE, the offsetX/Y is set to where ever the child element\n                     is located.\n                     As a result, we do NOT need to subtract margins to figure out the mouse X/Y\n                     position under this scenario. Removing the line below *will* cause\n                     the interactive layer to not work right on IE.\n                     */\n                    if(d3.event.target.tagName !== \"svg\") {\n                        subtractMargin = false;\n                    }\n\n                    if (d3.event.target.className.baseVal.match(\"nv-legend\")) {\n                        mouseOutAnyReason = true;\n                    }\n\n                }\n\n                if(subtractMargin) {\n                    mouseX -= margin.left;\n                    mouseY -= margin.top;\n                }\n\n                /* If mouseX/Y is outside of the chart's bounds,\n                 trigger a mouseOut event.\n                 */\n                if (mouseX < 0 || mouseY < 0\n                    || mouseX > availableWidth || mouseY > availableHeight\n                    || (d3.event.relatedTarget && d3.event.relatedTarget.ownerSVGElement === undefined)\n                    || mouseOutAnyReason\n                    ) {\n\n                    if (isMSIE) {\n                        if (d3.event.relatedTarget\n                            && d3.event.relatedTarget.ownerSVGElement === undefined\n                            && (d3.event.relatedTarget.className === undefined\n                                || d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass))) {\n\n                            return;\n                        }\n                    }\n                    dispatch.elementMouseout({\n                        mouseX: mouseX,\n                        mouseY: mouseY\n                    });\n                    layer.renderGuideLine(null); //hide the guideline\n                    tooltip.hidden(true);\n                    return;\n                } else {\n                    tooltip.hidden(false);\n                }\n\n\n                var scaleIsOrdinal = typeof xScale.rangeBands === 'function';\n                var pointXValue = undefined;\n\n                // Ordinal scale has no invert method\n                if (scaleIsOrdinal) {\n                    var elementIndex = d3.bisect(xScale.range(), mouseX) - 1;\n                    // Check if mouseX is in the range band\n                    if (xScale.range()[elementIndex] + xScale.rangeBand() >= mouseX) {\n                        pointXValue = xScale.domain()[d3.bisect(xScale.range(), mouseX) - 1];\n                    }\n                    else {\n                        dispatch.elementMouseout({\n                            mouseX: mouseX,\n                            mouseY: mouseY\n                        });\n                        layer.renderGuideLine(null); //hide the guideline\n                        tooltip.hidden(true);\n                        return;\n                    }\n                }\n                else {\n                    pointXValue = xScale.invert(mouseX);\n                }\n\n                dispatch.elementMousemove({\n                    mouseX: mouseX,\n                    mouseY: mouseY,\n                    pointXValue: pointXValue\n                });\n\n                //If user double clicks the layer, fire a elementDblclick\n                if (d3.event.type === \"dblclick\") {\n                    dispatch.elementDblclick({\n                        mouseX: mouseX,\n                        mouseY: mouseY,\n                        pointXValue: pointXValue\n                    });\n                }\n\n                // if user single clicks the layer, fire elementClick\n                if (d3.event.type === 'click') {\n                    dispatch.elementClick({\n                        mouseX: mouseX,\n                        mouseY: mouseY,\n                        pointXValue: pointXValue\n                    });\n                }\n\n                // if user presses mouse down the layer, fire elementMouseDown\n                if (d3.event.type === 'mousedown') {\n                \tdispatch.elementMouseDown({\n                \t\tmouseX: mouseX,\n                \t\tmouseY: mouseY,\n                \t\tpointXValue: pointXValue\n                \t});\n                }\n\n                // if user presses mouse down the layer, fire elementMouseUp\n                if (d3.event.type === 'mouseup') {\n                \tdispatch.elementMouseUp({\n                \t\tmouseX: mouseX,\n                \t\tmouseY: mouseY,\n                \t\tpointXValue: pointXValue\n                \t});\n                }\n            }\n\n            svgContainer\n                .on(\"touchmove\",mouseHandler)\n                .on(\"mousemove\",mouseHandler, true)\n                .on(\"mouseout\" ,mouseHandler,true)\n                .on(\"mousedown\" ,mouseHandler,true)\n                .on(\"mouseup\" ,mouseHandler,true)\n                .on(\"dblclick\" ,mouseHandler)\n                .on(\"click\", mouseHandler)\n            ;\n\n            layer.guideLine = null;\n            //Draws a vertical guideline at the given X postion.\n            layer.renderGuideLine = function(x) {\n                if (!showGuideLine) return;\n                if (layer.guideLine && layer.guideLine.attr(\"x1\") === x) return;\n                nv.dom.write(function() {\n                    var line = wrap.select(\".nv-interactiveGuideLine\")\n                        .selectAll(\"line\")\n                        .data((x != null) ? [nv.utils.NaNtoZero(x)] : [], String);\n                    line.enter()\n                        .append(\"line\")\n                        .attr(\"class\", \"nv-guideline\")\n                        .attr(\"x1\", function(d) { return d;})\n                        .attr(\"x2\", function(d) { return d;})\n                        .attr(\"y1\", availableHeight)\n                        .attr(\"y2\",0);\n                    line.exit().remove();\n                });\n            }\n        });\n    }\n\n    layer.dispatch = dispatch;\n    layer.tooltip = tooltip;\n\n    layer.margin = function(_) {\n        if (!arguments.length) return margin;\n        margin.top    = typeof _.top    != 'undefined' ? _.top    : margin.top;\n        margin.left   = typeof _.left   != 'undefined' ? _.left   : margin.left;\n        return layer;\n    };\n\n    layer.width = function(_) {\n        if (!arguments.length) return width;\n        width = _;\n        return layer;\n    };\n\n    layer.height = function(_) {\n        if (!arguments.length) return height;\n        height = _;\n        return layer;\n    };\n\n    layer.xScale = function(_) {\n        if (!arguments.length) return xScale;\n        xScale = _;\n        return layer;\n    };\n\n    layer.showGuideLine = function(_) {\n        if (!arguments.length) return showGuideLine;\n        showGuideLine = _;\n        return layer;\n    };\n\n    layer.svgContainer = function(_) {\n        if (!arguments.length) return svgContainer;\n        svgContainer = _;\n        return layer;\n    };\n\n    return layer;\n};\n\n/* Utility class that uses d3.bisect to find the index in a given array, where a search value can be inserted.\n This is different from normal bisectLeft; this function finds the nearest index to insert the search value.\n\n For instance, lets say your array is [1,2,3,5,10,30], and you search for 28.\n Normal d3.bisectLeft will return 4, because 28 is inserted after the number 10.  But interactiveBisect will return 5\n because 28 is closer to 30 than 10.\n\n Unit tests can be found in: interactiveBisectTest.html\n\n Has the following known issues:\n * Will not work if the data points move backwards (ie, 10,9,8,7, etc) or if the data points are in random order.\n * Won't work if there are duplicate x coordinate values.\n */\nnv.interactiveBisect = function (values, searchVal, xAccessor) {\n    \"use strict\";\n    if (! (values instanceof Array)) {\n        return null;\n    }\n    var _xAccessor;\n    if (typeof xAccessor !== 'function') {\n        _xAccessor = function(d) {\n            return d.x;\n        }\n    } else {\n        _xAccessor = xAccessor;\n    }\n    var _cmp = function(d, v) {\n        // Accessors are no longer passed the index of the element along with\n        // the element itself when invoked by d3.bisector.\n        //\n        // Starting at D3 v3.4.4, d3.bisector() started inspecting the\n        // function passed to determine if it should consider it an accessor\n        // or a comparator. This meant that accessors that take two arguments\n        // (expecting an index as the second parameter) are treated as\n        // comparators where the second argument is the search value against\n        // which the first argument is compared.\n        return _xAccessor(d) - v;\n    };\n\n    var bisect = d3.bisector(_cmp).left;\n    var index = d3.max([0, bisect(values,searchVal) - 1]);\n    var currentValue = _xAccessor(values[index]);\n\n    if (typeof currentValue === 'undefined') {\n        currentValue = index;\n    }\n\n    if (currentValue === searchVal) {\n        return index; //found exact match\n    }\n\n    var nextIndex = d3.min([index+1, values.length - 1]);\n    var nextValue = _xAccessor(values[nextIndex]);\n\n    if (typeof nextValue === 'undefined') {\n        nextValue = nextIndex;\n    }\n\n    if (Math.abs(nextValue - searchVal) >= Math.abs(currentValue - searchVal)) {\n        return index;\n    } else {\n        return nextIndex\n    }\n};\n\n/*\n Returns the index in the array \"values\" that is closest to searchVal.\n Only returns an index if searchVal is within some \"threshold\".\n Otherwise, returns null.\n */\nnv.nearestValueIndex = function (values, searchVal, threshold) {\n    \"use strict\";\n    var yDistMax = Infinity, indexToHighlight = null;\n    values.forEach(function(d,i) {\n        var delta = Math.abs(searchVal - d);\n        if ( d != null && delta <= yDistMax && delta < threshold) {\n            yDistMax = delta;\n            indexToHighlight = i;\n        }\n    });\n    return indexToHighlight;\n};\n\n/* Model which can be instantiated to handle tooltip rendering.\n Example usage:\n var tip = nv.models.tooltip().gravity('w').distance(23)\n .data(myDataObject);\n\n tip();    //just invoke the returned function to render tooltip.\n */\nnv.models.tooltip = function() {\n    \"use strict\";\n\n    /*\n    Tooltip data. If data is given in the proper format, a consistent tooltip is generated.\n    Example Format of data:\n    {\n        key: \"Date\",\n        value: \"August 2009\",\n        series: [\n            {key: \"Series 1\", value: \"Value 1\", color: \"#000\"},\n            {key: \"Series 2\", value: \"Value 2\", color: \"#00f\"}\n        ]\n    }\n    */\n    var id = \"nvtooltip-\" + Math.floor(Math.random() * 100000) // Generates a unique id when you create a new tooltip() object.\n        ,   data = null\n        ,   gravity = 'w'   // Can be 'n','s','e','w'. Determines how tooltip is positioned.\n        ,   distance = 25 // Distance to offset tooltip from the mouse location.\n        ,   snapDistance = 0   // Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect)\n        ,   classes = null  // Attaches additional CSS classes to the tooltip DIV that is created.\n        ,   chartContainer = null // Parent dom element of the SVG that holds the chart.\n        ,   hidden = true  // Start off hidden, toggle with hide/show functions below.\n        ,   hideDelay = 200  // Delay (in ms) before the tooltip hides after calling hide().\n        ,   tooltip = null // d3 select of the tooltip div.\n        ,   lastPosition = { left: null, top: null } // Last position the tooltip was in.\n        ,   enabled = true  // True -> tooltips are rendered. False -> don't render tooltips.\n        ,   duration = 100 // Tooltip movement duration, in ms.\n        ,   headerEnabled = true // If is to show the tooltip header.\n        ,   nvPointerEventsClass = \"nv-pointer-events-none\" // CSS class to specify whether element should not have mouse events.\n    ;\n\n    /*\n     Function that returns the position (relative to the viewport) the tooltip should be placed in.\n     Should return: {\n        left: <leftPos>,\n        top: <topPos>\n     }\n     */\n    var position = function() {\n        return {\n            left: d3.event !== null ? d3.event.clientX : 0,\n            top: d3.event !== null ? d3.event.clientY : 0\n        };\n    };\n\n    // Format function for the tooltip values column.\n    var valueFormatter = function(d, i) {\n        return d;\n    };\n\n    // Format function for the tooltip header value.\n    var headerFormatter = function(d) {\n        return d;\n    };\n\n    var keyFormatter = function(d, i) {\n        return d;\n    };\n\n    // By default, the tooltip model renders a beautiful table inside a DIV.\n    // You can override this function if a custom tooltip is desired.\n    var contentGenerator = function(d) {\n        if (d === null) {\n            return '';\n        }\n\n        var table = d3.select(document.createElement(\"table\"));\n        if (headerEnabled) {\n            var theadEnter = table.selectAll(\"thead\")\n                .data([d])\n                .enter().append(\"thead\");\n\n            theadEnter.append(\"tr\")\n                .append(\"td\")\n                .attr(\"colspan\", 3)\n                .append(\"strong\")\n                .classed(\"x-value\", true)\n                .html(headerFormatter(d.value));\n        }\n\n        var tbodyEnter = table.selectAll(\"tbody\")\n            .data([d])\n            .enter().append(\"tbody\");\n\n        var trowEnter = tbodyEnter.selectAll(\"tr\")\n                .data(function(p) { return p.series})\n                .enter()\n                .append(\"tr\")\n                .classed(\"highlight\", function(p) { return p.highlight});\n\n        trowEnter.append(\"td\")\n            .classed(\"legend-color-guide\",true)\n            .append(\"div\")\n            .style(\"background-color\", function(p) { return p.color});\n\n        trowEnter.append(\"td\")\n            .classed(\"key\",true)\n            .classed(\"total\",function(p) { return !!p.total})\n            .html(function(p, i) { return keyFormatter(p.key, i)});\n\n        trowEnter.append(\"td\")\n            .classed(\"value\",true)\n            .html(function(p, i) { return valueFormatter(p.value, i) });\n\n        trowEnter.selectAll(\"td\").each(function(p) {\n            if (p.highlight) {\n                var opacityScale = d3.scale.linear().domain([0,1]).range([\"#fff\",p.color]);\n                var opacity = 0.6;\n                d3.select(this)\n                    .style(\"border-bottom-color\", opacityScale(opacity))\n                    .style(\"border-top-color\", opacityScale(opacity))\n                ;\n            }\n        });\n\n        var html = table.node().outerHTML;\n        if (d.footer !== undefined)\n            html += \"<div class='footer'>\" + d.footer + \"</div>\";\n        return html;\n\n    };\n\n    var dataSeriesExists = function(d) {\n        if (d && d.series) {\n            if (d.series instanceof Array) {\n                return !!d.series.length;\n            }\n            // if object, it's okay just convert to array of the object\n            if (d.series instanceof Object) {\n                d.series = [d.series];\n                return true;\n            }\n        }\n        return false;\n    };\n\n    // Calculates the gravity offset of the tooltip. Parameter is position of tooltip\n    // relative to the viewport.\n    var calcGravityOffset = function(pos) {\n        var height = tooltip.node().offsetHeight,\n            width = tooltip.node().offsetWidth,\n            clientWidth = document.documentElement.clientWidth, // Don't want scrollbars.\n            clientHeight = document.documentElement.clientHeight, // Don't want scrollbars.\n            left, top, tmp;\n\n        // calculate position based on gravity\n        switch (gravity) {\n            case 'e':\n                left = - width - distance;\n                top = - (height / 2);\n                if(pos.left + left < 0) left = distance;\n                if((tmp = pos.top + top) < 0) top -= tmp;\n                if((tmp = pos.top + top + height) > clientHeight) top -= tmp - clientHeight;\n                break;\n            case 'w':\n                left = distance;\n                top = - (height / 2);\n                if (pos.left + left + width > clientWidth) left = - width - distance;\n                if ((tmp = pos.top + top) < 0) top -= tmp;\n                if ((tmp = pos.top + top + height) > clientHeight) top -= tmp - clientHeight;\n                break;\n            case 'n':\n                left = - (width / 2) - 5; // - 5 is an approximation of the mouse's height.\n                top = distance;\n                if (pos.top + top + height > clientHeight) top = - height - distance;\n                if ((tmp = pos.left + left) < 0) left -= tmp;\n                if ((tmp = pos.left + left + width) > clientWidth) left -= tmp - clientWidth;\n                break;\n            case 's':\n                left = - (width / 2);\n                top = - height - distance;\n                if (pos.top + top < 0) top = distance;\n                if ((tmp = pos.left + left) < 0) left -= tmp;\n                if ((tmp = pos.left + left + width) > clientWidth) left -= tmp - clientWidth;\n                break;\n            case 'center':\n                left = - (width / 2);\n                top = - (height / 2);\n                break;\n            default:\n                left = 0;\n                top = 0;\n                break;\n        }\n\n        return { 'left': left, 'top': top };\n    };\n\n    /*\n     Positions the tooltip in the correct place, as given by the position() function.\n     */\n    var positionTooltip = function() {\n        nv.dom.read(function() {\n            var pos = position(),\n                gravityOffset = calcGravityOffset(pos),\n                left = pos.left + gravityOffset.left,\n                top = pos.top + gravityOffset.top;\n\n            // delay hiding a bit to avoid flickering\n            if (hidden) {\n                tooltip\n                    .interrupt()\n                    .transition()\n                    .delay(hideDelay)\n                    .duration(0)\n                    .style('opacity', 0);\n            } else {\n                // using tooltip.style('transform') returns values un-usable for tween\n                var old_translate = 'translate(' + lastPosition.left + 'px, ' + lastPosition.top + 'px)';\n                var new_translate = 'translate(' + left + 'px, ' + top + 'px)';\n                var translateInterpolator = d3.interpolateString(old_translate, new_translate);\n                var is_hidden = tooltip.style('opacity') < 0.1;\n\n                tooltip\n                    .interrupt() // cancel running transitions\n                    .transition()\n                    .duration(is_hidden ? 0 : duration)\n                    // using tween since some versions of d3 can't auto-tween a translate on a div\n                    .styleTween('transform', function (d) {\n                        return translateInterpolator;\n                    }, 'important')\n                    // Safari has its own `-webkit-transform` and does not support `transform`\n                    .styleTween('-webkit-transform', function (d) {\n                        return translateInterpolator;\n                    })\n                    .style('-ms-transform', new_translate)\n                    .style('opacity', 1);\n            }\n\n            lastPosition.left = left;\n            lastPosition.top = top;\n        });\n    };\n\n    // Creates new tooltip container, or uses existing one on DOM.\n    function initTooltip() {\n        if (!tooltip) {\n            var container = chartContainer ? chartContainer : document.body;\n\n            // Create new tooltip div if it doesn't exist on DOM.\n            tooltip = d3.select(container).append(\"div\")\n                .attr(\"class\", \"nvtooltip \" + (classes ? classes : \"xy-tooltip\"))\n                .attr(\"id\", id);\n            tooltip.style(\"top\", 0).style(\"left\", 0);\n            tooltip.style('opacity', 0);\n            tooltip.style('position', 'fixed');\n            tooltip.selectAll(\"div, table, td, tr\").classed(nvPointerEventsClass, true);\n            tooltip.classed(nvPointerEventsClass, true);\n        }\n    }\n\n    // Draw the tooltip onto the DOM.\n    function nvtooltip() {\n        if (!enabled) return;\n        if (!dataSeriesExists(data)) return;\n\n        nv.dom.write(function () {\n            initTooltip();\n            // Generate data and set it into tooltip.\n            // Bonus - If you override contentGenerator and return falsey you can use something like\n            //         React or Knockout to bind the data for your tooltip.\n            var newContent = contentGenerator(data);\n            if (newContent) {\n                tooltip.node().innerHTML = newContent;\n            }\n\n            positionTooltip();\n        });\n\n        return nvtooltip;\n    }\n\n    nvtooltip.nvPointerEventsClass = nvPointerEventsClass;\n    nvtooltip.options = nv.utils.optionsFunc.bind(nvtooltip);\n\n    nvtooltip._options = Object.create({}, {\n        // simple read/write options\n        duration: {get: function(){return duration;}, set: function(_){duration=_;}},\n        gravity: {get: function(){return gravity;}, set: function(_){gravity=_;}},\n        distance: {get: function(){return distance;}, set: function(_){distance=_;}},\n        snapDistance: {get: function(){return snapDistance;}, set: function(_){snapDistance=_;}},\n        classes: {get: function(){return classes;}, set: function(_){classes=_;}},\n        chartContainer: {get: function(){return chartContainer;}, set: function(_){chartContainer=_;}},\n        enabled: {get: function(){return enabled;}, set: function(_){enabled=_;}},\n        hideDelay: {get: function(){return hideDelay;}, set: function(_){hideDelay=_;}},\n        contentGenerator: {get: function(){return contentGenerator;}, set: function(_){contentGenerator=_;}},\n        valueFormatter: {get: function(){return valueFormatter;}, set: function(_){valueFormatter=_;}},\n        headerFormatter: {get: function(){return headerFormatter;}, set: function(_){headerFormatter=_;}},\n        keyFormatter: {get: function(){return keyFormatter;}, set: function(_){keyFormatter=_;}},\n        headerEnabled: {get: function(){return headerEnabled;}, set: function(_){headerEnabled=_;}},\n        position: {get: function(){return position;}, set: function(_){position=_;}},\n\n        // Deprecated options\n        fixedTop: {get: function(){return null;}, set: function(_){\n            // deprecated after 1.8.1\n            nv.deprecated('fixedTop', 'feature removed after 1.8.1');\n        }},\n        offset: {get: function(){return {left: 0, top: 0};}, set: function(_){\n            // deprecated after 1.8.1\n            nv.deprecated('offset', 'use chart.tooltip.distance() instead');\n        }},\n\n        // options with extra logic\n        hidden: {get: function(){return hidden;}, set: function(_){\n            if (hidden != _) {\n                hidden = !!_;\n                nvtooltip();\n            }\n        }},\n        data: {get: function(){return data;}, set: function(_){\n            // if showing a single data point, adjust data format with that\n            if (_.point) {\n                _.value = _.point.x;\n                _.series = _.series || {};\n                _.series.value = _.point.y;\n                _.series.color = _.point.color || _.series.color;\n            }\n            data = _;\n        }},\n\n        // read only properties\n        node: {get: function(){return tooltip.node();}, set: function(_){}},\n        id: {get: function(){return id;}, set: function(_){}}\n    });\n\n    nv.utils.initOptions(nvtooltip);\n    return nvtooltip;\n};\n\n\n/*\nGets the browser window size\n\nReturns object with height and width properties\n */\nnv.utils.windowSize = function() {\n    // Sane defaults\n    var size = {width: 640, height: 480};\n\n    // Most recent browsers use\n    if (window.innerWidth && window.innerHeight) {\n        size.width = window.innerWidth;\n        size.height = window.innerHeight;\n        return (size);\n    }\n\n    // IE can use depending on mode it is in\n    if (document.compatMode=='CSS1Compat' &&\n        document.documentElement &&\n        document.documentElement.offsetWidth ) {\n\n        size.width = document.documentElement.offsetWidth;\n        size.height = document.documentElement.offsetHeight;\n        return (size);\n    }\n\n    // Earlier IE uses Doc.body\n    if (document.body && document.body.offsetWidth) {\n        size.width = document.body.offsetWidth;\n        size.height = document.body.offsetHeight;\n        return (size);\n    }\n\n    return (size);\n};\n\n/*\nBinds callback function to run when window is resized\n */\nnv.utils.windowResize = function(handler) {\n    if (window.addEventListener) {\n        window.addEventListener('resize', handler);\n    } else {\n        nv.log(\"ERROR: Failed to bind to window.resize with: \", handler);\n    }\n    // return object with clear function to remove the single added callback.\n    return {\n        callback: handler,\n        clear: function() {\n            window.removeEventListener('resize', handler);\n        }\n    }\n};\n\n\n/*\nBackwards compatible way to implement more d3-like coloring of graphs.\nCan take in nothing, an array, or a function/scale\nTo use a normal scale, get the range and pass that because we must be able\nto take two arguments and use the index to keep backward compatibility\n*/\nnv.utils.getColor = function(color) {\n    //if you pass in nothing, get default colors back\n    if (color === undefined) {\n        return nv.utils.defaultColor();\n\n    //if passed an array, turn it into a color scale\n    // use isArray, instanceof fails if d3 range is created in an iframe\n    } else if(Array.isArray(color)) {\n        var color_scale = d3.scale.ordinal().range(color);\n        return function(d, i) {\n            var key = i === undefined ? d : i;\n            return d.color || color_scale(key);\n        };\n\n    //if passed a function or scale, return it, or whatever it may be\n    //external libs, such as angularjs-nvd3-directives use this\n    } else {\n        //can't really help it if someone passes rubbish as color\n        return color;\n    }\n};\n\n\n/*\nDefault color chooser uses a color scale of 20 colors from D3\n https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors\n */\nnv.utils.defaultColor = function() {\n    // get range of the scale so we'll turn it into our own function.\n    return nv.utils.getColor(d3.scale.category20().range());\n};\n\n\n/*\nReturns a color function that takes the result of 'getKey' for each series and\nlooks for a corresponding color from the dictionary\n*/\nnv.utils.customTheme = function(dictionary, getKey, defaultColors) {\n    // use default series.key if getKey is undefined\n    getKey = getKey || function(series) { return series.key };\n    defaultColors = defaultColors || d3.scale.category20().range();\n\n    // start at end of default color list and walk back to index 0\n    var defIndex = defaultColors.length;\n\n    return function(series, index) {\n        var key = getKey(series);\n        if (typeof dictionary[key] === 'function') {\n            return dictionary[key]();\n        } else if (dictionary[key] !== undefined) {\n            return dictionary[key];\n        } else {\n            // no match in dictionary, use a default color\n            if (!defIndex) {\n                // used all the default colors, start over\n                defIndex = defaultColors.length;\n            }\n            defIndex = defIndex - 1;\n            return defaultColors[defIndex];\n        }\n    };\n};\n\n\n/*\nFrom the PJAX example on d3js.org, while this is not really directly needed\nit's a very cool method for doing pjax, I may expand upon it a little bit,\nopen to suggestions on anything that may be useful\n*/\nnv.utils.pjax = function(links, content) {\n\n    var load = function(href) {\n        d3.html(href, function(fragment) {\n            var target = d3.select(content).node();\n            target.parentNode.replaceChild(\n                d3.select(fragment).select(content).node(),\n                target);\n            nv.utils.pjax(links, content);\n        });\n    };\n\n    d3.selectAll(links).on(\"click\", function() {\n        history.pushState(this.href, this.textContent, this.href);\n        load(this.href);\n        d3.event.preventDefault();\n    });\n\n    d3.select(window).on(\"popstate\", function() {\n        if (d3.event.state) {\n            load(d3.event.state);\n        }\n    });\n};\n\n\n/*\nFor when we want to approximate the width in pixels for an SVG:text element.\nMost common instance is when the element is in a display:none; container.\nForumla is : text.length * font-size * constant_factor\n*/\nnv.utils.calcApproxTextWidth = function (svgTextElem) {\n    if (typeof svgTextElem.style === 'function'\n        && typeof svgTextElem.text === 'function') {\n\n        var fontSize = parseInt(svgTextElem.style(\"font-size\").replace(\"px\",\"\"), 10);\n        var textLength = svgTextElem.text().length;\n        return textLength * fontSize * 0.5;\n    }\n    return 0;\n};\n\n\n/*\nNumbers that are undefined, null or NaN, convert them to zeros.\n*/\nnv.utils.NaNtoZero = function(n) {\n    if (typeof n !== 'number'\n        || isNaN(n)\n        || n === null\n        || n === Infinity\n        || n === -Infinity) {\n\n        return 0;\n    }\n    return n;\n};\n\n/*\nAdd a way to watch for d3 transition ends to d3\n*/\nd3.selection.prototype.watchTransition = function(renderWatch){\n    var args = [this].concat([].slice.call(arguments, 1));\n    return renderWatch.transition.apply(renderWatch, args);\n};\n\n\n/*\nHelper object to watch when d3 has rendered something\n*/\nnv.utils.renderWatch = function(dispatch, duration) {\n    if (!(this instanceof nv.utils.renderWatch)) {\n        return new nv.utils.renderWatch(dispatch, duration);\n    }\n\n    var _duration = duration !== undefined ? duration : 250;\n    var renderStack = [];\n    var self = this;\n\n    this.models = function(models) {\n        models = [].slice.call(arguments, 0);\n        models.forEach(function(model){\n            model.__rendered = false;\n            (function(m){\n                m.dispatch.on('renderEnd', function(arg){\n                    m.__rendered = true;\n                    self.renderEnd('model');\n                });\n            })(model);\n\n            if (renderStack.indexOf(model) < 0) {\n                renderStack.push(model);\n            }\n        });\n    return this;\n    };\n\n    this.reset = function(duration) {\n        if (duration !== undefined) {\n            _duration = duration;\n        }\n        renderStack = [];\n    };\n\n    this.transition = function(selection, args, duration) {\n        args = arguments.length > 1 ? [].slice.call(arguments, 1) : [];\n\n        if (args.length > 1) {\n            duration = args.pop();\n        } else {\n            duration = _duration !== undefined ? _duration : 250;\n        }\n        selection.__rendered = false;\n\n        if (renderStack.indexOf(selection) < 0) {\n            renderStack.push(selection);\n        }\n\n        if (duration === 0) {\n            selection.__rendered = true;\n            selection.delay = function() { return this; };\n            selection.duration = function() { return this; };\n            return selection;\n        } else {\n            if (selection.length === 0) {\n                selection.__rendered = true;\n            } else if (selection.every( function(d){ return !d.length; } )) {\n                selection.__rendered = true;\n            } else {\n                selection.__rendered = false;\n            }\n\n            var n = 0;\n            return selection\n                .transition()\n                .duration(duration)\n                .each(function(){ ++n; })\n                .each('end', function(d, i) {\n                    if (--n === 0) {\n                        selection.__rendered = true;\n                        self.renderEnd.apply(this, args);\n                    }\n                });\n        }\n    };\n\n    this.renderEnd = function() {\n        if (renderStack.every( function(d){ return d.__rendered; } )) {\n            renderStack.forEach( function(d){ d.__rendered = false; });\n            dispatch.renderEnd.apply(this, arguments);\n        }\n    }\n\n};\n\n\n/*\nTakes multiple objects and combines them into the first one (dst)\nexample:  nv.utils.deepExtend({a: 1}, {a: 2, b: 3}, {c: 4});\ngives:  {a: 2, b: 3, c: 4}\n*/\nnv.utils.deepExtend = function(dst){\n    var sources = arguments.length > 1 ? [].slice.call(arguments, 1) : [];\n    sources.forEach(function(source) {\n        for (var key in source) {\n            var isArray = dst[key] instanceof Array;\n            var isObject = typeof dst[key] === 'object';\n            var srcObj = typeof source[key] === 'object';\n\n            if (isObject && !isArray && srcObj) {\n                nv.utils.deepExtend(dst[key], source[key]);\n            } else {\n                dst[key] = source[key];\n            }\n        }\n    });\n};\n\n\n/*\nstate utility object, used to track d3 states in the models\n*/\nnv.utils.state = function(){\n    if (!(this instanceof nv.utils.state)) {\n        return new nv.utils.state();\n    }\n    var state = {};\n    var _self = this;\n    var _setState = function(){};\n    var _getState = function(){ return {}; };\n    var init = null;\n    var changed = null;\n\n    this.dispatch = d3.dispatch('change', 'set');\n\n    this.dispatch.on('set', function(state){\n        _setState(state, true);\n    });\n\n    this.getter = function(fn){\n        _getState = fn;\n        return this;\n    };\n\n    this.setter = function(fn, callback) {\n        if (!callback) {\n            callback = function(){};\n        }\n        _setState = function(state, update){\n            fn(state);\n            if (update) {\n                callback();\n            }\n        };\n        return this;\n    };\n\n    this.init = function(state){\n        init = init || {};\n        nv.utils.deepExtend(init, state);\n    };\n\n    var _set = function(){\n        var settings = _getState();\n\n        if (JSON.stringify(settings) === JSON.stringify(state)) {\n            return false;\n        }\n\n        for (var key in settings) {\n            if (state[key] === undefined) {\n                state[key] = {};\n            }\n            state[key] = settings[key];\n            changed = true;\n        }\n        return true;\n    };\n\n    this.update = function(){\n        if (init) {\n            _setState(init, false);\n            init = null;\n        }\n        if (_set.call(this)) {\n            this.dispatch.change(state);\n        }\n    };\n\n};\n\n\n/*\nSnippet of code you can insert into each nv.models.* to give you the ability to\ndo things like:\nchart.options({\n  showXAxis: true,\n  tooltips: true\n});\n\nTo enable in the chart:\nchart.options = nv.utils.optionsFunc.bind(chart);\n*/\nnv.utils.optionsFunc = function(args) {\n    if (args) {\n        d3.map(args).forEach((function(key,value) {\n            if (typeof this[key] === \"function\") {\n                this[key](value);\n            }\n        }).bind(this));\n    }\n    return this;\n};\n\n\n/*\nnumTicks:  requested number of ticks\ndata:  the chart data\n\nreturns the number of ticks to actually use on X axis, based on chart data\nto avoid duplicate ticks with the same value\n*/\nnv.utils.calcTicksX = function(numTicks, data) {\n    // find max number of values from all data streams\n    var numValues = 1;\n    var i = 0;\n    for (i; i < data.length; i += 1) {\n        var stream_len = data[i] && data[i].values ? data[i].values.length : 0;\n        numValues = stream_len > numValues ? stream_len : numValues;\n    }\n    nv.log(\"Requested number of ticks: \", numTicks);\n    nv.log(\"Calculated max values to be: \", numValues);\n    // make sure we don't have more ticks than values to avoid duplicates\n    numTicks = numTicks > numValues ? numTicks = numValues - 1 : numTicks;\n    // make sure we have at least one tick\n    numTicks = numTicks < 1 ? 1 : numTicks;\n    // make sure it's an integer\n    numTicks = Math.floor(numTicks);\n    nv.log(\"Calculating tick count as: \", numTicks);\n    return numTicks;\n};\n\n\n/*\nreturns number of ticks to actually use on Y axis, based on chart data\n*/\nnv.utils.calcTicksY = function(numTicks, data) {\n    // currently uses the same logic but we can adjust here if needed later\n    return nv.utils.calcTicksX(numTicks, data);\n};\n\n\n/*\nAdd a particular option from an options object onto chart\nOptions exposed on a chart are a getter/setter function that returns chart\non set to mimic typical d3 option chaining, e.g. svg.option1('a').option2('b');\n\noption objects should be generated via Object.create() to provide\nthe option of manipulating data via get/set functions.\n*/\nnv.utils.initOption = function(chart, name) {\n    // if it's a call option, just call it directly, otherwise do get/set\n    if (chart._calls && chart._calls[name]) {\n        chart[name] = chart._calls[name];\n    } else {\n        chart[name] = function (_) {\n            if (!arguments.length) return chart._options[name];\n            chart._overrides[name] = true;\n            chart._options[name] = _;\n            return chart;\n        };\n        // calling the option as _option will ignore if set by option already\n        // so nvd3 can set options internally but the stop if set manually\n        chart['_' + name] = function(_) {\n            if (!arguments.length) return chart._options[name];\n            if (!chart._overrides[name]) {\n                chart._options[name] = _;\n            }\n            return chart;\n        }\n    }\n};\n\n\n/*\nAdd all options in an options object to the chart\n*/\nnv.utils.initOptions = function(chart) {\n    chart._overrides = chart._overrides || {};\n    var ops = Object.getOwnPropertyNames(chart._options || {});\n    var calls = Object.getOwnPropertyNames(chart._calls || {});\n    ops = ops.concat(calls);\n    for (var i in ops) {\n        nv.utils.initOption(chart, ops[i]);\n    }\n};\n\n\n/*\nInherit options from a D3 object\nd3.rebind makes calling the function on target actually call it on source\nAlso use _d3options so we can track what we inherit for documentation and chained inheritance\n*/\nnv.utils.inheritOptionsD3 = function(target, d3_source, oplist) {\n    target._d3options = oplist.concat(target._d3options || []);\n    oplist.unshift(d3_source);\n    oplist.unshift(target);\n    d3.rebind.apply(this, oplist);\n};\n\n\n/*\nRemove duplicates from an array\n*/\nnv.utils.arrayUnique = function(a) {\n    return a.sort().filter(function(item, pos) {\n        return !pos || item != a[pos - 1];\n    });\n};\n\n\n/*\nKeeps a list of custom symbols to draw from in addition to d3.svg.symbol\nNecessary since d3 doesn't let you extend its list -_-\nAdd new symbols by doing nv.utils.symbols.set('name', function(size){...});\n*/\nnv.utils.symbolMap = d3.map();\n\n\n/*\nReplaces d3.svg.symbol so that we can look both there and our own map\n */\nnv.utils.symbol = function() {\n    var type,\n        size = 64;\n    function symbol(d,i) {\n        var t = type.call(this,d,i);\n        var s = size.call(this,d,i);\n        if (d3.svg.symbolTypes.indexOf(t) !== -1) {\n            return d3.svg.symbol().type(t).size(s)();\n        } else {\n            return nv.utils.symbolMap.get(t)(s);\n        }\n    }\n    symbol.type = function(_) {\n        if (!arguments.length) return type;\n        type = d3.functor(_);\n        return symbol;\n    };\n    symbol.size = function(_) {\n        if (!arguments.length) return size;\n        size = d3.functor(_);\n        return symbol;\n    };\n    return symbol;\n};\n\n\n/*\nInherit option getter/setter functions from source to target\nd3.rebind makes calling the function on target actually call it on source\nAlso track via _inherited and _d3options so we can track what we inherit\nfor documentation generation purposes and chained inheritance\n*/\nnv.utils.inheritOptions = function(target, source) {\n    // inherit all the things\n    var ops = Object.getOwnPropertyNames(source._options || {});\n    var calls = Object.getOwnPropertyNames(source._calls || {});\n    var inherited = source._inherited || [];\n    var d3ops = source._d3options || [];\n    var args = ops.concat(calls).concat(inherited).concat(d3ops);\n    args.unshift(source);\n    args.unshift(target);\n    d3.rebind.apply(this, args);\n    // pass along the lists to keep track of them, don't allow duplicates\n    target._inherited = nv.utils.arrayUnique(ops.concat(calls).concat(inherited).concat(ops).concat(target._inherited || []));\n    target._d3options = nv.utils.arrayUnique(d3ops.concat(target._d3options || []));\n};\n\n\n/*\nRuns common initialize code on the svg before the chart builds\n*/\nnv.utils.initSVG = function(svg) {\n    svg.classed({'nvd3-svg':true});\n};\n\n\n/*\nSanitize and provide default for the container height.\n*/\nnv.utils.sanitizeHeight = function(height, container) {\n    return (height || parseInt(container.style('height'), 10) || 400);\n};\n\n\n/*\nSanitize and provide default for the container width.\n*/\nnv.utils.sanitizeWidth = function(width, container) {\n    return (width || parseInt(container.style('width'), 10) || 960);\n};\n\n\n/*\nCalculate the available height for a chart.\n*/\nnv.utils.availableHeight = function(height, container, margin) {\n    return Math.max(0,nv.utils.sanitizeHeight(height, container) - margin.top - margin.bottom);\n};\n\n/*\nCalculate the available width for a chart.\n*/\nnv.utils.availableWidth = function(width, container, margin) {\n    return Math.max(0,nv.utils.sanitizeWidth(width, container) - margin.left - margin.right);\n};\n\n/*\nClear any rendered chart components and display a chart's 'noData' message\n*/\nnv.utils.noData = function(chart, container) {\n    var opt = chart.options(),\n        margin = opt.margin(),\n        noData = opt.noData(),\n        data = (noData == null) ? [\"No Data Available.\"] : [noData],\n        height = nv.utils.availableHeight(null, container, margin),\n        width = nv.utils.availableWidth(null, container, margin),\n        x = margin.left + width/2,\n        y = margin.top + height/2;\n\n    //Remove any previously created chart components\n    container.selectAll('g').remove();\n\n    var noDataText = container.selectAll('.nv-noData').data(data);\n\n    noDataText.enter().append('text')\n        .attr('class', 'nvd3 nv-noData')\n        .attr('dy', '-.7em')\n        .style('text-anchor', 'middle');\n\n    noDataText\n        .attr('x', x)\n        .attr('y', y)\n        .text(function(t){ return t; });\n};\n\n/*\n Wrap long labels.\n */\nnv.utils.wrapTicks = function (text, width) {\n    text.each(function() {\n        var text = d3.select(this),\n            words = text.text().split(/\\s+/).reverse(),\n            word,\n            line = [],\n            lineNumber = 0,\n            lineHeight = 1.1,\n            y = text.attr(\"y\"),\n            dy = parseFloat(text.attr(\"dy\")),\n            tspan = text.text(null).append(\"tspan\").attr(\"x\", 0).attr(\"y\", y).attr(\"dy\", dy + \"em\");\n        while (word = words.pop()) {\n            line.push(word);\n            tspan.text(line.join(\" \"));\n            if (tspan.node().getComputedTextLength() > width) {\n                line.pop();\n                tspan.text(line.join(\" \"));\n                line = [word];\n                tspan = text.append(\"tspan\").attr(\"x\", 0).attr(\"y\", y).attr(\"dy\", ++lineNumber * lineHeight + dy + \"em\").text(word);\n            }\n        }\n    });\n};\n\n/*\nCheck equality of 2 array\n*/\nnv.utils.arrayEquals = function (array1, array2) {\n    if (array1 === array2)\n        return true;\n\n    if (!array1 || !array2)\n        return false;\n\n    // compare lengths - can save a lot of time \n    if (array1.length != array2.length)\n        return false;\n\n    for (var i = 0,\n        l = array1.length; i < l; i++) {\n        // Check if we have nested arrays\n        if (array1[i] instanceof Array && array2[i] instanceof Array) {\n            // recurse into the nested arrays\n            if (!nv.arrayEquals(array1[i], array2[i]))\n                return false;\n        } else if (array1[i] != array2[i]) {\n            // Warning - two different object instances will never be equal: {x:20} != {x:20}\n            return false;\n        }\n    }\n    return true;\n};nv.models.axis = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var axis = d3.svg.axis();\n    var scale = d3.scale.linear();\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 75 //only used for tickLabel currently\n        , height = 60 //only used for tickLabel currently\n        , axisLabelText = null\n        , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes\n        , rotateLabels = 0\n        , rotateYLabel = true\n        , staggerLabels = false\n        , isOrdinal = false\n        , ticks = null\n        , axisLabelDistance = 0\n        , duration = 250\n        , dispatch = d3.dispatch('renderEnd')\n        ;\n    axis\n        .scale(scale)\n        .orient('bottom')\n        .tickFormat(function(d) { return d })\n    ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var scale0;\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            if (ticks !== null)\n                axis.ticks(ticks);\n            else if (axis.orient() == 'top' || axis.orient() == 'bottom')\n                axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100);\n\n            //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component\n            g.watchTransition(renderWatch, 'axis').call(axis);\n\n            scale0 = scale0 || axis.scale();\n\n            var fmt = axis.tickFormat();\n            if (fmt == null) {\n                fmt = scale0.tickFormat();\n            }\n\n            var axisLabel = g.selectAll('text.nv-axislabel')\n                .data([axisLabelText || null]);\n            axisLabel.exit().remove();\n\n            var xLabelMargin;\n            var axisMaxMin;\n            var w;\n            switch (axis.orient()) {\n                case 'top':\n                    axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n                  w = 0;\n                  if (scale.range().length === 1) {\n                    w = isOrdinal ? scale.range()[0] * 2 + scale.rangeBand() : 0;\n                  } else if (scale.range().length === 2) {\n                    w = isOrdinal ? scale.range()[0] + scale.range()[1] + scale.rangeBand() : scale.range()[1];\n                  } else if ( scale.range().length > 2){\n                    w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]);\n                  };\n                    axisLabel\n                        .attr('text-anchor', 'middle')\n                        .attr('y', 0)\n                        .attr('x', w/2);\n                    if (showMaxMin) {\n                        axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n                            .data(scale.domain());\n                        axisMaxMin.enter().append('g').attr('class',function(d,i){\n                                return ['nv-axisMaxMin','nv-axisMaxMin-x',(i == 0 ? 'nv-axisMin-x':'nv-axisMax-x')].join(' ')\n                        }).append('text');\n                        axisMaxMin.exit().remove();\n                        axisMaxMin\n                            .attr('transform', function(d,i) {\n                                return 'translate(' + nv.utils.NaNtoZero(scale(d)) + ',0)'\n                            })\n                            .select('text')\n                            .attr('dy', '-0.5em')\n                            .attr('y', -axis.tickPadding())\n                            .attr('text-anchor', 'middle')\n                            .text(function(d,i) {\n                                var v = fmt(d);\n                                return ('' + v).match('NaN') ? '' : v;\n                            });\n                        axisMaxMin.watchTransition(renderWatch, 'min-max top')\n                            .attr('transform', function(d,i) {\n                                return 'translate(' + nv.utils.NaNtoZero(scale.range()[i]) + ',0)'\n                            });\n                    }\n                    break;\n                case 'bottom':\n                    xLabelMargin = axisLabelDistance + 36;\n                    var maxTextWidth = 30;\n                    var textHeight = 0;\n                    var xTicks = g.selectAll('g').select(\"text\");\n                    var rotateLabelsRule = '';\n                    if (rotateLabels%360) {\n                        //Calculate the longest xTick width\n                        xTicks.each(function(d,i){\n                            var box = this.getBoundingClientRect();\n                            var width = box.width;\n                            textHeight = box.height;\n                            if(width > maxTextWidth) maxTextWidth = width;\n                        });\n                        rotateLabelsRule = 'rotate(' + rotateLabels + ' 0,' + (textHeight/2 + axis.tickPadding()) + ')';\n                        //Convert to radians before calculating sin. Add 30 to margin for healthy padding.\n                        var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180));\n                        xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30;\n                        //Rotate all xTicks\n                        xTicks\n                            .attr('transform', rotateLabelsRule)\n                            .style('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end');\n                    } else {\n                        if (staggerLabels) {\n                            xTicks\n                                .attr('transform', function(d,i) {\n                                    return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')'\n                                });\n                        } else {\n                            xTicks.attr('transform', \"translate(0,0)\");\n                        }\n                    }\n                    axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n                    w = 0;\n                    if (scale.range().length === 1) {\n                        w = isOrdinal ? scale.range()[0] * 2 + scale.rangeBand() : 0;\n                    } else if (scale.range().length === 2) {\n                        w = isOrdinal ? scale.range()[0] + scale.range()[1] + scale.rangeBand() : scale.range()[1];\n                    } else if ( scale.range().length > 2){\n                        w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]);\n                    };\n                    axisLabel\n                        .attr('text-anchor', 'middle')\n                        .attr('y', xLabelMargin)\n                        .attr('x', w/2);\n                    if (showMaxMin) {\n                        //if (showMaxMin && !isOrdinal) {\n                        axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n                            //.data(scale.domain())\n                            .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]);\n                        axisMaxMin.enter().append('g').attr('class',function(d,i){\n                                return ['nv-axisMaxMin','nv-axisMaxMin-x',(i == 0 ? 'nv-axisMin-x':'nv-axisMax-x')].join(' ')\n                        }).append('text');\n                        axisMaxMin.exit().remove();\n                        axisMaxMin\n                            .attr('transform', function(d,i) {\n                                return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)'\n                            })\n                            .select('text')\n                            .attr('dy', '.71em')\n                            .attr('y', axis.tickPadding())\n                            .attr('transform', rotateLabelsRule)\n                            .style('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle')\n                            .text(function(d,i) {\n                                var v = fmt(d);\n                                return ('' + v).match('NaN') ? '' : v;\n                            });\n                        axisMaxMin.watchTransition(renderWatch, 'min-max bottom')\n                            .attr('transform', function(d,i) {\n                                return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)'\n                            });\n                    }\n\n                    break;\n                case 'right':\n                    axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n                    axisLabel\n                        .style('text-anchor', rotateYLabel ? 'middle' : 'begin')\n                        .attr('transform', rotateYLabel ? 'rotate(90)' : '')\n                        .attr('y', rotateYLabel ? (-Math.max(margin.right, width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart\n                        .attr('x', rotateYLabel ? (d3.max(scale.range()) / 2) : axis.tickPadding());\n                    if (showMaxMin) {\n                        axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n                            .data(scale.domain());\n                       \taxisMaxMin.enter().append('g').attr('class',function(d,i){\n                                return ['nv-axisMaxMin','nv-axisMaxMin-y',(i == 0 ? 'nv-axisMin-y':'nv-axisMax-y')].join(' ')\n                        }).append('text')\n                            .style('opacity', 0);\n                        axisMaxMin.exit().remove();\n                        axisMaxMin\n                            .attr('transform', function(d,i) {\n                                return 'translate(0,' + nv.utils.NaNtoZero(scale(d)) + ')'\n                            })\n                            .select('text')\n                            .attr('dy', '.32em')\n                            .attr('y', 0)\n                            .attr('x', axis.tickPadding())\n                            .style('text-anchor', 'start')\n                            .text(function(d, i) {\n                                var v = fmt(d);\n                                return ('' + v).match('NaN') ? '' : v;\n                            });\n                        axisMaxMin.watchTransition(renderWatch, 'min-max right')\n                            .attr('transform', function(d,i) {\n                                return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')'\n                            })\n                            .select('text')\n                            .style('opacity', 1);\n                    }\n                    break;\n                case 'left':\n                    /*\n                     //For dynamically placing the label. Can be used with dynamically-sized chart axis margins\n                     var yTicks = g.selectAll('g').select(\"text\");\n                     yTicks.each(function(d,i){\n                     var labelPadding = this.getBoundingClientRect().width + axis.tickPadding() + 16;\n                     if(labelPadding > width) width = labelPadding;\n                     });\n                     */\n                    axisLabel.enter().append('text').attr('class', 'nv-axislabel');\n                    axisLabel\n                        .style('text-anchor', rotateYLabel ? 'middle' : 'end')\n                        .attr('transform', rotateYLabel ? 'rotate(-90)' : '')\n                        .attr('y', rotateYLabel ? (-Math.max(margin.left, width) + 25 - (axisLabelDistance || 0)) : -10)\n                        .attr('x', rotateYLabel ? (-d3.max(scale.range()) / 2) : -axis.tickPadding());\n                    if (showMaxMin) {\n                        axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')\n                            .data(scale.domain());\n                        axisMaxMin.enter().append('g').attr('class',function(d,i){\n                                return ['nv-axisMaxMin','nv-axisMaxMin-y',(i == 0 ? 'nv-axisMin-y':'nv-axisMax-y')].join(' ')\n                        }).append('text')\n                            .style('opacity', 0);\n                        axisMaxMin.exit().remove();\n                        axisMaxMin\n                            .attr('transform', function(d,i) {\n                                return 'translate(0,' + nv.utils.NaNtoZero(scale0(d)) + ')'\n                            })\n                            .select('text')\n                            .attr('dy', '.32em')\n                            .attr('y', 0)\n                            .attr('x', -axis.tickPadding())\n                            .attr('text-anchor', 'end')\n                            .text(function(d,i) {\n                                var v = fmt(d);\n                                return ('' + v).match('NaN') ? '' : v;\n                            });\n                        axisMaxMin.watchTransition(renderWatch, 'min-max right')\n                            .attr('transform', function(d,i) {\n                                return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')'\n                            })\n                            .select('text')\n                            .style('opacity', 1);\n                    }\n                    break;\n            }\n            axisLabel.text(function(d) { return d });\n\n            if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) {\n                //check if max and min overlap other values, if so, hide the values that overlap\n                g.selectAll('g') // the g's wrapping each tick\n                    .each(function(d,i) {\n                        d3.select(this).select('text').attr('opacity', 1);\n                        if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it!\n                            if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL\n                                d3.select(this).attr('opacity', 0);\n\n                            d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!!\n                        }\n                    });\n\n                //if Max and Min = 0 only show min, Issue #281\n                if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0) {\n                    wrap.selectAll('g.nv-axisMaxMin').style('opacity', function (d, i) {\n                        return !i ? 1 : 0\n                    });\n                }\n            }\n\n            if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) {\n                var maxMinRange = [];\n                wrap.selectAll('g.nv-axisMaxMin')\n                    .each(function(d,i) {\n                        try {\n                            if (i) // i== 1, max position\n                                maxMinRange.push(scale(d) - this.getBoundingClientRect().width - 4);  //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)\n                            else // i==0, min position\n                                maxMinRange.push(scale(d) + this.getBoundingClientRect().width + 4)\n                        }catch (err) {\n                            if (i) // i== 1, max position\n                                maxMinRange.push(scale(d) - 4);  //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)\n                            else // i==0, min position\n                                maxMinRange.push(scale(d) + 4);\n                        }\n                    });\n                // the g's wrapping each tick\n                g.selectAll('g').each(function(d, i) {\n                    if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) {\n                        if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL\n                            d3.select(this).remove();\n                        else\n                            d3.select(this).select('text').remove(); // Don't remove the ZERO line!!\n                    }\n                });\n            }\n\n            //Highlight zero tick line\n            g.selectAll('.tick')\n                .filter(function (d) {\n                    /*\n                    The filter needs to return only ticks at or near zero.\n                    Numbers like 0.00001 need to count as zero as well,\n                    and the arithmetic trick below solves that.\n                    */\n                    return !parseFloat(Math.round(d * 100000) / 1000000) && (d !== undefined)\n                }) \n                .classed('zero', true);\n            \n            //store old scales for use in transitions on update\n            scale0 = scale.copy();\n\n        });\n\n        renderWatch.renderEnd('axis immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.axis = axis;\n    chart.dispatch = dispatch;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        axisLabelDistance: {get: function(){return axisLabelDistance;}, set: function(_){axisLabelDistance=_;}},\n        staggerLabels:     {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n        rotateLabels:      {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n        rotateYLabel:      {get: function(){return rotateYLabel;}, set: function(_){rotateYLabel=_;}},\n        showMaxMin:        {get: function(){return showMaxMin;}, set: function(_){showMaxMin=_;}},\n        axisLabel:         {get: function(){return axisLabelText;}, set: function(_){axisLabelText=_;}},\n        height:            {get: function(){return height;}, set: function(_){height=_;}},\n        ticks:             {get: function(){return ticks;}, set: function(_){ticks=_;}},\n        width:             {get: function(){return width;}, set: function(_){width=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top !== undefined    ? _.top    : margin.top;\n            margin.right  = _.right !== undefined  ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left !== undefined   ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration=_;\n            renderWatch.reset(duration);\n        }},\n        scale: {get: function(){return scale;}, set: function(_){\n            scale = _;\n            axis.scale(scale);\n            isOrdinal = typeof scale.rangeBands === 'function';\n            nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    nv.utils.inheritOptionsD3(chart, axis, ['orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat']);\n    nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']);\n\n    return chart;\n};\nnv.models.boxPlot = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , x = d3.scale.ordinal()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , color = nv.utils.defaultColor()\n        , container = null\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        , duration = 250\n        , maxBoxWidth = null\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0;\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup Scales\n            x   .domain(xDomain || data.map(function(d,i) { return getX(d,i); }))\n                .rangeBands(xRange || [0, availableWidth], .1);\n\n            // if we know yDomain, no need to calculate\n            var yData = []\n            if (!yDomain) {\n                // (y-range is based on quartiles, whiskers and outliers)\n\n                // lower values\n                var yMin = d3.min(data.map(function(d) {\n                    var min_arr = [];\n\n                    min_arr.push(d.values.Q1);\n                    if (d.values.hasOwnProperty('whisker_low') && d.values.whisker_low !== null) { min_arr.push(d.values.whisker_low); }\n                    if (d.values.hasOwnProperty('outliers') && d.values.outliers !== null) { min_arr = min_arr.concat(d.values.outliers); }\n\n                    return d3.min(min_arr);\n                }));\n\n                // upper values\n                var yMax = d3.max(data.map(function(d) {\n                    var max_arr = [];\n\n                    max_arr.push(d.values.Q3);\n                    if (d.values.hasOwnProperty('whisker_high') && d.values.whisker_high !== null) { max_arr.push(d.values.whisker_high); }\n                    if (d.values.hasOwnProperty('outliers') && d.values.outliers !== null) { max_arr = max_arr.concat(d.values.outliers); }\n\n                    return d3.max(max_arr);\n                }));\n\n                yData = [ yMin, yMax ] ;\n            }\n\n            y.domain(yDomain || yData);\n            y.range(yRange || [availableHeight, 0]);\n\n            //store old scales if they exist\n            x0 = x0 || x;\n            y0 = y0 || y.copy().range([y(0),y(0)]);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap');\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var boxplots = wrap.selectAll('.nv-boxplot').data(function(d) { return d });\n            var boxEnter = boxplots.enter().append('g').style('stroke-opacity', 1e-6).style('fill-opacity', 1e-6);\n            boxplots\n                .attr('class', 'nv-boxplot')\n                .attr('transform', function(d,i,j) { return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05) + ', 0)'; })\n                .classed('hover', function(d) { return d.hover });\n            boxplots\n                .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', .75)\n                .delay(function(d,i) { return i * duration / data.length })\n                .attr('transform', function(d,i) {\n                    return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05) + ', 0)';\n                });\n            boxplots.exit().remove();\n\n            // ----- add the SVG elements for each boxPlot -----\n\n            // conditionally append whisker lines\n            boxEnter.each(function(d,i) {\n              var box = d3.select(this);\n\n              ['low', 'high'].forEach(function(key) {\n                if (d.values.hasOwnProperty('whisker_' + key) && d.values['whisker_' + key] !== null) {\n                  box.append('line')\n                    .style('stroke', (d.color) ? d.color : color(d,i))\n                    .attr('class', 'nv-boxplot-whisker nv-boxplot-' + key);\n\n                  box.append('line')\n                    .style('stroke', (d.color) ? d.color : color(d,i))\n                    .attr('class', 'nv-boxplot-tick nv-boxplot-' + key);\n                }\n              });\n            });\n\n            // outliers\n            // TODO: support custom colors here\n            var outliers = boxplots.selectAll('.nv-boxplot-outlier').data(function(d) {\n                if (d.values.hasOwnProperty('outliers') && d.values.outliers !== null) { return d.values.outliers; }\n                else { return []; }\n            });\n            outliers.enter().append('circle')\n                .style('fill', function(d,i,j) { return color(d,j) }).style('stroke', function(d,i,j) { return color(d,j) })\n                .on('mouseover', function(d,i,j) {\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        series: { key: d, color: color(d,j) },\n                        e: d3.event\n                    });\n                })\n                .on('mouseout', function(d,i,j) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        series: { key: d, color: color(d,j) },\n                        e: d3.event\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({e: d3.event});\n                });\n\n            outliers.attr('class', 'nv-boxplot-outlier');\n            outliers\n              .watchTransition(renderWatch, 'nv-boxplot: nv-boxplot-outlier')\n                .attr('cx', x.rangeBand() * .45)\n                .attr('cy', function(d,i,j) { return y(d); })\n                .attr('r', '3');\n            outliers.exit().remove();\n\n            var box_width = function() { return (maxBoxWidth === null ? x.rangeBand() * .9 : Math.min(75, x.rangeBand() * .9)); };\n            var box_left  = function() { return x.rangeBand() * .45 - box_width()/2; };\n            var box_right = function() { return x.rangeBand() * .45 + box_width()/2; };\n\n            // update whisker lines and ticks\n            ['low', 'high'].forEach(function(key) {\n              var endpoint = (key === 'low') ? 'Q1' : 'Q3';\n\n              boxplots.select('line.nv-boxplot-whisker.nv-boxplot-' + key)\n                .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n                  .attr('x1', x.rangeBand() * .45 )\n                  .attr('y1', function(d,i) { return y(d.values['whisker_' + key]); })\n                  .attr('x2', x.rangeBand() * .45 )\n                  .attr('y2', function(d,i) { return y(d.values[endpoint]); });\n\n              boxplots.select('line.nv-boxplot-tick.nv-boxplot-' + key)\n                .watchTransition(renderWatch, 'nv-boxplot: boxplots')\n                  .attr('x1', box_left )\n                  .attr('y1', function(d,i) { return y(d.values['whisker_' + key]); })\n                  .attr('x2', box_right )\n                  .attr('y2', function(d,i) { return y(d.values['whisker_' + key]); });\n            });\n\n            ['low', 'high'].forEach(function(key) {\n              boxEnter.selectAll('.nv-boxplot-' + key)\n                .on('mouseover', function(d,i,j) {\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        series: { key: d.values['whisker_' + key], color: color(d,j) },\n                        e: d3.event\n                    });\n                })\n                .on('mouseout', function(d,i,j) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        series: { key: d.values['whisker_' + key], color: color(d,j) },\n                        e: d3.event\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({e: d3.event});\n                });\n            });\n\n            // boxes\n            boxEnter.append('rect')\n                .attr('class', 'nv-boxplot-box')\n                // tooltip events\n                .on('mouseover', function(d,i) {\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        key: d.label,\n                        value: d.label,\n                        series: [\n                            { key: 'Q3', value: d.values.Q3, color: d.color || color(d,i) },\n                            { key: 'Q2', value: d.values.Q2, color: d.color || color(d,i) },\n                            { key: 'Q1', value: d.values.Q1, color: d.color || color(d,i) }\n                        ],\n                        data: d,\n                        index: i,\n                        e: d3.event\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        key: d.label,\n                        value: d.label,\n                        series: [\n                            { key: 'Q3', value: d.values.Q3, color: d.color || color(d,i) },\n                            { key: 'Q2', value: d.values.Q2, color: d.color || color(d,i) },\n                            { key: 'Q1', value: d.values.Q1, color: d.color || color(d,i) }\n                        ],\n                        data: d,\n                        index: i,\n                        e: d3.event\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({e: d3.event});\n                });\n\n            // box transitions\n            boxplots.select('rect.nv-boxplot-box')\n              .watchTransition(renderWatch, 'nv-boxplot: boxes')\n                .attr('y', function(d,i) { return y(d.values.Q3); })\n                .attr('width', box_width)\n                .attr('x', box_left )\n\n                .attr('height', function(d,i) { return Math.abs(y(d.values.Q3) - y(d.values.Q1)) || 1 })\n                .style('fill', function(d,i) { return d.color || color(d,i) })\n                .style('stroke', function(d,i) { return d.color || color(d,i) });\n\n            // median line\n            boxEnter.append('line').attr('class', 'nv-boxplot-median');\n\n            boxplots.select('line.nv-boxplot-median')\n              .watchTransition(renderWatch, 'nv-boxplot: boxplots line')\n                .attr('x1', box_left)\n                .attr('y1', function(d,i) { return y(d.values.Q2); })\n                .attr('x2', box_right)\n                .attr('y2', function(d,i) { return y(d.values.Q2); });\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n        });\n\n        renderWatch.renderEnd('nv-boxplot immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:   {get: function(){return width;}, set: function(_){width=_;}},\n        height:  {get: function(){return height;}, set: function(_){height=_;}},\n        maxBoxWidth: {get: function(){return maxBoxWidth;}, set: function(_){maxBoxWidth=_;}},\n        x:       {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:       {get: function(){return getY;}, set: function(_){getY=_;}},\n        xScale:  {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:  {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:  {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:  {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        id:          {get: function(){return id;}, set: function(_){id=_;}},\n        // rectClass: {get: function(){return rectClass;}, set: function(_){rectClass=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\nnv.models.boxPlotChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var boxplot = nv.models.boxPlot()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        ;\n\n    var margin = {top: 15, right: 10, bottom: 50, left: 60}\n        , width = null\n        , height = null\n        , color = nv.utils.getColor()\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , staggerLabels = false\n        , tooltip = nv.models.tooltip()\n        , x\n        , y\n        , noData = \"No Data Available.\"\n        , dispatch = d3.dispatch('beforeUpdate', 'renderEnd')\n        , duration = 250\n        ;\n\n    xAxis\n        .orient('bottom')\n        .showMaxMin(false)\n        .tickFormat(function(d) { return d })\n    ;\n    yAxis\n        .orient((rightAlignYAxis) ? 'right' : 'left')\n        .tickFormat(d3.format(',.1f'))\n    ;\n\n    tooltip.duration(0);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(boxplot);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = (width  || parseInt(container.style('width')) || 960)\n                    - margin.left - margin.right,\n                availableHeight = (height || parseInt(container.style('height')) || 400)\n                    - margin.top - margin.bottom;\n\n            chart.update = function() {\n                dispatch.beforeUpdate();\n                container.transition().duration(duration).call(chart);\n            };\n            chart.container = this;\n\n            // Display No Data message if there's nothing to show. (quartiles required at minimum)\n            if (!data || !data.length ||\n                    !data.filter(function(d) { return d.values.hasOwnProperty(\"Q1\") && d.values.hasOwnProperty(\"Q2\") && d.values.hasOwnProperty(\"Q3\"); }).length) {\n                var noDataText = container.selectAll('.nv-noData').data([noData]);\n\n                noDataText.enter().append('text')\n                    .attr('class', 'nvd3 nv-noData')\n                    .attr('dy', '-.7em')\n                    .style('text-anchor', 'middle');\n\n                noDataText\n                    .attr('x', margin.left + availableWidth / 2)\n                    .attr('y', margin.top + availableHeight / 2)\n                    .text(function(d) { return d });\n\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = boxplot.xScale();\n            y = boxplot.yScale().clamp(true);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-boxPlotWithAxes').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-boxPlotWithAxes').append('g');\n            var defsEnter = gEnter.append('defs');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis')\n                .append('g').attr('class', 'nv-zeroLine')\n                .append('line');\n\n            gEnter.append('g').attr('class', 'nv-barsWrap');\n\n            g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            // Main Chart Component(s)\n            boxplot\n                .width(availableWidth)\n                .height(availableHeight);\n\n            var barsWrap = g.select('.nv-barsWrap')\n                .datum(data.filter(function(d) { return !d.disabled }))\n\n            barsWrap.transition().call(boxplot);\n\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-x-label-clip-' + boxplot.id())\n                .append('rect');\n\n            g.select('#nv-x-label-clip-' + boxplot.id() + ' rect')\n                .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))\n                .attr('height', 16)\n                .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    .ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight, 0);\n\n                g.select('.nv-x.nv-axis').attr('transform', 'translate(0,' + y.range()[0] + ')');\n                g.select('.nv-x.nv-axis').call(xAxis);\n\n                var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n                if (staggerLabels) {\n                    xTicks\n                        .selectAll('text')\n                        .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })\n                }\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    .ticks( Math.floor(availableHeight/36) ) // can't use nv.utils.calcTicksY with Object data\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis').call(yAxis);\n            }\n\n            // Zero line\n            g.select(\".nv-zeroLine line\")\n                .attr(\"x1\",0)\n                .attr(\"x2\",availableWidth)\n                .attr(\"y1\", y(0))\n                .attr(\"y2\", y(0))\n            ;\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n        });\n\n        renderWatch.renderEnd('nv-boxplot chart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    boxplot.dispatch.on('elementMouseover.tooltip', function(evt) {\n        tooltip.data(evt).hidden(false);\n    });\n\n    boxplot.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.data(evt).hidden(true);\n    });\n\n    boxplot.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.boxplot = boxplot;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n        showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        tooltipContent:    {get: function(){return tooltip;}, set: function(_){tooltip=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            boxplot.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            boxplot.color(color);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( (_) ? 'right' : 'left');\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, boxplot);\n    nv.utils.initOptions(chart);\n\n    return chart;\n}\n\n// Chart design based on the recommendations of Stephen Few. Implementation\n// based on the work of Clint Ivy, Jamie Love, and Jason Davies.\n// http://projects.instantcognition.com/protovis/bulletchart/\n\nnv.models.bullet = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , orient = 'left' // TODO top & bottom\n        , reverse = false\n        , ranges = function(d) { return d.ranges }\n        , markers = function(d) { return d.markers ? d.markers : [] }\n        , measures = function(d) { return d.measures }\n        , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] }\n        , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : []  }\n        , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : []  }\n        , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)\n        , width = 380\n        , height = 30\n        , container = null\n        , tickFormat = null\n        , color = nv.utils.getColor(['#1f77b4'])\n        , dispatch = d3.dispatch('elementMouseover', 'elementMouseout', 'elementMousemove')\n        ;\n\n    function chart(selection) {\n        selection.each(function(d, i) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var rangez = ranges.call(this, d, i).slice().sort(d3.descending),\n                markerz = markers.call(this, d, i).slice().sort(d3.descending),\n                measurez = measures.call(this, d, i).slice().sort(d3.descending),\n                rangeLabelz = rangeLabels.call(this, d, i).slice(),\n                markerLabelz = markerLabels.call(this, d, i).slice(),\n                measureLabelz = measureLabels.call(this, d, i).slice();\n\n            // Setup Scales\n            // Compute the new x-scale.\n            var x1 = d3.scale.linear()\n                .domain( d3.extent(d3.merge([forceX, rangez])) )\n                .range(reverse ? [availableWidth, 0] : [0, availableWidth]);\n\n            // Retrieve the old x-scale, if this is an update.\n            var x0 = this.__chart__ || d3.scale.linear()\n                .domain([0, Infinity])\n                .range(x1.range());\n\n            // Stash the new scale.\n            this.__chart__ = x1;\n\n            var rangeMin = d3.min(rangez), //rangez[2]\n                rangeMax = d3.max(rangez), //rangez[0]\n                rangeAvg = rangez[1];\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('rect').attr('class', 'nv-range nv-rangeMax');\n            gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg');\n            gEnter.append('rect').attr('class', 'nv-range nv-rangeMin');\n            gEnter.append('rect').attr('class', 'nv-measure');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0)\n                w1 = function(d) { return Math.abs(x1(d) - x1(0)) };\n            var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) },\n                xp1 = function(d) { return d < 0 ? x1(d) : x1(0) };\n\n            g.select('rect.nv-rangeMax')\n                .attr('height', availableHeight)\n                .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin))\n                .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin))\n                .datum(rangeMax > 0 ? rangeMax : rangeMin)\n\n            g.select('rect.nv-rangeAvg')\n                .attr('height', availableHeight)\n                .attr('width', w1(rangeAvg))\n                .attr('x', xp1(rangeAvg))\n                .datum(rangeAvg)\n\n            g.select('rect.nv-rangeMin')\n                .attr('height', availableHeight)\n                .attr('width', w1(rangeMax))\n                .attr('x', xp1(rangeMax))\n                .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax))\n                .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax))\n                .datum(rangeMax > 0 ? rangeMin : rangeMax)\n\n            g.select('rect.nv-measure')\n                .style('fill', color)\n                .attr('height', availableHeight / 3)\n                .attr('y', availableHeight / 3)\n                .attr('width', measurez < 0 ?\n                    x1(0) - x1(measurez[0])\n                    : x1(measurez[0]) - x1(0))\n                .attr('x', xp1(measurez))\n                .on('mouseover', function() {\n                    dispatch.elementMouseover({\n                        value: measurez[0],\n                        label: measureLabelz[0] || 'Current',\n                        color: d3.select(this).style(\"fill\")\n                    })\n                })\n                .on('mousemove', function() {\n                    dispatch.elementMousemove({\n                        value: measurez[0],\n                        label: measureLabelz[0] || 'Current',\n                        color: d3.select(this).style(\"fill\")\n                    })\n                })\n                .on('mouseout', function() {\n                    dispatch.elementMouseout({\n                        value: measurez[0],\n                        label: measureLabelz[0] || 'Current',\n                        color: d3.select(this).style(\"fill\")\n                    })\n                });\n\n            var h3 =  availableHeight / 6;\n\n            var markerData = markerz.map( function(marker, index) {\n                return {value: marker, label: markerLabelz[index]}\n            });\n            gEnter\n              .selectAll(\"path.nv-markerTriangle\")\n              .data(markerData)\n              .enter()\n              .append('path')\n              .attr('class', 'nv-markerTriangle')\n              .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z')\n              .on('mouseover', function(d) {\n                dispatch.elementMouseover({\n                  value: d.value,\n                  label: d.label || 'Previous',\n                  color: d3.select(this).style(\"fill\"),\n                  pos: [x1(d.value), availableHeight/2]\n                })\n\n              })\n              .on('mousemove', function(d) {\n                  dispatch.elementMousemove({\n                      value: d.value,\n                      label: d.label || 'Previous',\n                      color: d3.select(this).style(\"fill\")\n                  })\n              })\n              .on('mouseout', function(d, i) {\n                  dispatch.elementMouseout({\n                      value: d.value,\n                      label: d.label || 'Previous',\n                      color: d3.select(this).style(\"fill\")\n                  })\n              });\n\n            g.selectAll(\"path.nv-markerTriangle\")\n              .data(markerData)\n              .attr('transform', function(d) { return 'translate(' + x1(d.value) + ',' + (availableHeight / 2) + ')' });\n\n            wrap.selectAll('.nv-range')\n                .on('mouseover', function(d,i) {\n                    var label = rangeLabelz[i] || (!i ? \"Maximum\" : i == 1 ? \"Mean\" : \"Minimum\");\n                    dispatch.elementMouseover({\n                        value: d,\n                        label: label,\n                        color: d3.select(this).style(\"fill\")\n                    })\n                })\n                .on('mousemove', function() {\n                    dispatch.elementMousemove({\n                        value: measurez[0],\n                        label: measureLabelz[0] || 'Previous',\n                        color: d3.select(this).style(\"fill\")\n                    })\n                })\n                .on('mouseout', function(d,i) {\n                    var label = rangeLabelz[i] || (!i ? \"Maximum\" : i == 1 ? \"Mean\" : \"Minimum\");\n                    dispatch.elementMouseout({\n                        value: d,\n                        label: label,\n                        color: d3.select(this).style(\"fill\")\n                    })\n                });\n        });\n\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        ranges:      {get: function(){return ranges;}, set: function(_){ranges=_;}}, // ranges (bad, satisfactory, good)\n        markers:     {get: function(){return markers;}, set: function(_){markers=_;}}, // markers (previous, goal)\n        measures: {get: function(){return measures;}, set: function(_){measures=_;}}, // measures (actual, forecast)\n        forceX:      {get: function(){return forceX;}, set: function(_){forceX=_;}},\n        width:    {get: function(){return width;}, set: function(_){width=_;}},\n        height:    {get: function(){return height;}, set: function(_){height=_;}},\n        tickFormat:    {get: function(){return tickFormat;}, set: function(_){tickFormat=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        orient: {get: function(){return orient;}, set: function(_){ // left, right, top, bottom\n            orient = _;\n            reverse = orient == 'right' || orient == 'bottom';\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\n\n\n// Chart design based on the recommendations of Stephen Few. Implementation\n// based on the work of Clint Ivy, Jamie Love, and Jason Davies.\n// http://projects.instantcognition.com/protovis/bulletchart/\nnv.models.bulletChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var bullet = nv.models.bullet();\n    var tooltip = nv.models.tooltip();\n\n    var orient = 'left' // TODO top & bottom\n        , reverse = false\n        , margin = {top: 5, right: 40, bottom: 20, left: 120}\n        , ranges = function(d) { return d.ranges }\n        , markers = function(d) { return d.markers ? d.markers : [] }\n        , measures = function(d) { return d.measures }\n        , width = null\n        , height = 55\n        , tickFormat = null\n\t, ticks = null\n        , noData = null\n        , dispatch = d3.dispatch()\n        ;\n\n    tooltip\n        .duration(0)\n        .headerEnabled(false);\n\n    function chart(selection) {\n        selection.each(function(d, i) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = height - margin.top - margin.bottom,\n                that = this;\n\n            chart.update = function() { chart(selection) };\n            chart.container = this;\n\n            // Display No Data message if there's nothing to show.\n            if (!d || !ranges.call(this, d, i)) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            var rangez = ranges.call(this, d, i).slice().sort(d3.descending),\n                markerz = markers.call(this, d, i).slice().sort(d3.descending),\n                measurez = measures.call(this, d, i).slice().sort(d3.descending);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-bulletWrap');\n            gEnter.append('g').attr('class', 'nv-titles');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Compute the new x-scale.\n            var x1 = d3.scale.linear()\n                .domain([0, Math.max(rangez[0], (markerz[0] || 0), measurez[0])])  // TODO: need to allow forceX and forceY, and xDomain, yDomain\n                .range(reverse ? [availableWidth, 0] : [0, availableWidth]);\n\n            // Retrieve the old x-scale, if this is an update.\n            var x0 = this.__chart__ || d3.scale.linear()\n                .domain([0, Infinity])\n                .range(x1.range());\n\n            // Stash the new scale.\n            this.__chart__ = x1;\n\n            var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0)\n                w1 = function(d) { return Math.abs(x1(d) - x1(0)) };\n\n            var title = gEnter.select('.nv-titles').append('g')\n                .attr('text-anchor', 'end')\n                .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')');\n            title.append('text')\n                .attr('class', 'nv-title')\n                .text(function(d) { return d.title; });\n\n            title.append('text')\n                .attr('class', 'nv-subtitle')\n                .attr('dy', '1em')\n                .text(function(d) { return d.subtitle; });\n\n            bullet\n                .width(availableWidth)\n                .height(availableHeight)\n\n            var bulletWrap = g.select('.nv-bulletWrap');\n            d3.transition(bulletWrap).call(bullet);\n\n            // Compute the tick format.\n            var format = tickFormat || x1.tickFormat( availableWidth / 100 );\n\n            // Update the tick groups.\n            var tick = g.selectAll('g.nv-tick')\n                .data(x1.ticks( ticks ? ticks : (availableWidth / 50) ), function(d) {\n                    return this.textContent || format(d);\n                });\n\n            // Initialize the ticks with the old scale, x0.\n            var tickEnter = tick.enter().append('g')\n                .attr('class', 'nv-tick')\n                .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' })\n                .style('opacity', 1e-6);\n\n            tickEnter.append('line')\n                .attr('y1', availableHeight)\n                .attr('y2', availableHeight * 7 / 6);\n\n            tickEnter.append('text')\n                .attr('text-anchor', 'middle')\n                .attr('dy', '1em')\n                .attr('y', availableHeight * 7 / 6)\n                .text(format);\n\n            // Transition the updating ticks to the new scale, x1.\n            var tickUpdate = d3.transition(tick)\n                .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' })\n                .style('opacity', 1);\n\n            tickUpdate.select('line')\n                .attr('y1', availableHeight)\n                .attr('y2', availableHeight * 7 / 6);\n\n            tickUpdate.select('text')\n                .attr('y', availableHeight * 7 / 6);\n\n            // Transition the exiting ticks to the new scale, x1.\n            d3.transition(tick.exit())\n                .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' })\n                .style('opacity', 1e-6)\n                .remove();\n        });\n\n        d3.timer.flush();\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    bullet.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt['series'] = {\n            key: evt.label,\n            value: evt.value,\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    bullet.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    bullet.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.bullet = bullet;\n    chart.dispatch = dispatch;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        ranges:      {get: function(){return ranges;}, set: function(_){ranges=_;}}, // ranges (bad, satisfactory, good)\n        markers:     {get: function(){return markers;}, set: function(_){markers=_;}}, // markers (previous, goal)\n        measures: {get: function(){return measures;}, set: function(_){measures=_;}}, // measures (actual, forecast)\n        width:    {get: function(){return width;}, set: function(_){width=_;}},\n        height:    {get: function(){return height;}, set: function(_){height=_;}},\n        tickFormat:    {get: function(){return tickFormat;}, set: function(_){tickFormat=_;}},\n        ticks:    {get: function(){return ticks;}, set: function(_){ticks=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        orient: {get: function(){return orient;}, set: function(_){ // left, right, top, bottom\n            orient = _;\n            reverse = orient == 'right' || orient == 'bottom';\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, bullet);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\n\n\nnv.models.candlestickBar = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = null\n        , height = null\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container\n        , x = d3.scale.linear()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , getOpen = function(d) { return d.open }\n        , getClose = function(d) { return d.close }\n        , getHigh = function(d) { return d.high }\n        , getLow = function(d) { return d.low }\n        , forceX = []\n        , forceY = []\n        , padData     = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart\n        , clipEdge = true\n        , color = nv.utils.defaultColor()\n        , interactive = false\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd', 'chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    function chart(selection) {\n        selection.each(function(data) {\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            nv.utils.initSVG(container);\n\n            // Width of the candlestick bars.\n            var barWidth = (availableWidth / data[0].values.length) * .45;\n\n            // Setup Scales\n            x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ));\n\n            if (padData)\n                x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5)  / data[0].values.length ]);\n            else\n                x.range(xRange || [5 + barWidth / 2, availableWidth - barWidth / 2 - 5]);\n\n            y.domain(yDomain || [\n                    d3.min(data[0].values.map(getLow).concat(forceY)),\n                    d3.max(data[0].values.map(getHigh).concat(forceY))\n                ]\n            ).range(yRange || [availableHeight, 0]);\n\n            // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n            if (x.domain()[0] === x.domain()[1])\n                x.domain()[0] ?\n                    x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n                    : x.domain([-1,1]);\n\n            if (y.domain()[0] === y.domain()[1])\n                y.domain()[0] ?\n                    y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n                    : y.domain([-1,1]);\n\n            // Setup containers and skeleton of chart\n            var wrap = d3.select(this).selectAll('g.nv-wrap.nv-candlestickBar').data([data[0].values]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-candlestickBar');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-ticks');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            container\n                .on('click', function(d,i) {\n                    dispatch.chartClick({\n                        data: d,\n                        index: i,\n                        pos: d3.event,\n                        id: id\n                    });\n                });\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-chart-clip-path-' + id)\n                .append('rect');\n\n            wrap.select('#nv-chart-clip-path-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            g   .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');\n\n            var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick')\n                .data(function(d) { return d });\n            ticks.exit().remove();\n\n            var tickGroups = ticks.enter().append('g');\n\n            // The colors are currently controlled by CSS.\n            ticks\n                .attr('class', function(d, i, j) { return (getOpen(d, i) > getClose(d, i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i});\n\n            var lines = tickGroups.append('line')\n                .attr('class', 'nv-candlestick-lines')\n                .attr('transform', function(d, i) { return 'translate(' + x(getX(d, i)) + ',0)'; })\n                .attr('x1', 0)\n                .attr('y1', function(d, i) { return y(getHigh(d, i)); })\n                .attr('x2', 0)\n                .attr('y2', function(d, i) { return y(getLow(d, i)); });\n\n            var rects = tickGroups.append('rect')\n                .attr('class', 'nv-candlestick-rects nv-bars')\n                .attr('transform', function(d, i) {\n                    return 'translate(' + (x(getX(d, i)) - barWidth/2) + ','\n                    + (y(getY(d, i)) - (getOpen(d, i) > getClose(d, i) ? (y(getClose(d, i)) - y(getOpen(d, i))) : 0))\n                    + ')';\n                })\n                .attr('x', 0)\n                .attr('y', 0)\n                .attr('width', barWidth)\n                .attr('height', function(d, i) {\n                    var open = getOpen(d, i);\n                    var close = getClose(d, i);\n                    return open > close ? y(close) - y(open) : y(open) - y(close);\n                });\n\n            ticks.select('.nv-candlestick-lines').transition()\n                .attr('transform', function(d, i) { return 'translate(' + x(getX(d, i)) + ',0)'; })\n                .attr('x1', 0)\n                .attr('y1', function(d, i) { return y(getHigh(d, i)); })\n                .attr('x2', 0)\n                .attr('y2', function(d, i) { return y(getLow(d, i)); });\n\n            ticks.select('.nv-candlestick-rects').transition()\n                .attr('transform', function(d, i) {\n                    return 'translate(' + (x(getX(d, i)) - barWidth/2) + ','\n                    + (y(getY(d, i)) - (getOpen(d, i) > getClose(d, i) ? (y(getClose(d, i)) - y(getOpen(d, i))) : 0))\n                    + ')';\n                })\n                .attr('x', 0)\n                .attr('y', 0)\n                .attr('width', barWidth)\n                .attr('height', function(d, i) {\n                    var open = getOpen(d, i);\n                    var close = getClose(d, i);\n                    return open > close ? y(close) - y(open) : y(open) - y(close);\n                });\n        });\n\n        return chart;\n    }\n\n\n    //Create methods to allow outside functions to highlight a specific bar.\n    chart.highlightPoint = function(pointIndex, isHoverOver) {\n        chart.clearHighlights();\n        container.select(\".nv-candlestickBar .nv-tick-0-\" + pointIndex)\n            .classed(\"hover\", isHoverOver)\n        ;\n    };\n\n    chart.clearHighlights = function() {\n        container.select(\".nv-candlestickBar .nv-tick.hover\")\n            .classed(\"hover\", false)\n        ;\n    };\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:    {get: function(){return width;}, set: function(_){width=_;}},\n        height:   {get: function(){return height;}, set: function(_){height=_;}},\n        xScale:   {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:   {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain:  {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain:  {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:   {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:   {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        forceX:   {get: function(){return forceX;}, set: function(_){forceX=_;}},\n        forceY:   {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        padData:  {get: function(){return padData;}, set: function(_){padData=_;}},\n        clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        id:       {get: function(){return id;}, set: function(_){id=_;}},\n        interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n        x:     {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:     {get: function(){return getY;}, set: function(_){getY=_;}},\n        open:  {get: function(){return getOpen();}, set: function(_){getOpen=_;}},\n        close: {get: function(){return getClose();}, set: function(_){getClose=_;}},\n        high:  {get: function(){return getHigh;}, set: function(_){getHigh=_;}},\n        low:   {get: function(){return getLow;}, set: function(_){getLow=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    != undefined ? _.top    : margin.top;\n            margin.right  = _.right  != undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   != undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.models.cumulativeLineChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var lines = nv.models.line()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , legend = nv.models.legend()\n        , controls = nv.models.legend()\n        , interactiveLayer = nv.interactiveGuideline()\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 30, right: 30, bottom: 50, left: 60}\n        , color = nv.utils.defaultColor()\n        , width = null\n        , height = null\n        , showLegend = true\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , showControls = true\n        , useInteractiveGuideline = false\n        , rescaleY = true\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , id = lines.id()\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , average = function(d) { return d.average }\n        , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n        , transitionDuration = 250\n        , duration = 250\n        , noErrorCheck = false  //if set to TRUE, will bypass an error check in the indexify function.\n        ;\n\n    state.index = 0;\n    state.rescaleY = rescaleY;\n\n    xAxis.orient('bottom').tickPadding(7);\n    yAxis.orient((rightAlignYAxis) ? 'right' : 'left');\n\n    tooltip.valueFormatter(function(d, i) {\n        return yAxis.tickFormat()(d, i);\n    }).headerFormatter(function(d, i) {\n        return xAxis.tickFormat()(d, i);\n    });\n\n    controls.updateState(false);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var dx = d3.scale.linear()\n        , index = {i: 0, x: 0}\n        , renderWatch = nv.utils.renderWatch(dispatch, duration)\n        ;\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled }),\n                index: index.i,\n                rescaleY: rescaleY\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.index !== undefined)\n                index.i = state.index;\n            if (state.rescaleY !== undefined)\n                rescaleY = state.rescaleY;\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(lines);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n            container.classed('nv-chart-' + id, true);\n            var that = this;\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() {\n                if (duration === 0)\n                    container.call(chart);\n                else\n                    container.transition().duration(duration).call(chart)\n            };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disableddisabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            var indexDrag = d3.behavior.drag()\n                .on('dragstart', dragStart)\n                .on('drag', dragMove)\n                .on('dragend', dragEnd);\n\n\n            function dragStart(d,i) {\n                d3.select(chart.container)\n                    .style('cursor', 'ew-resize');\n            }\n\n            function dragMove(d,i) {\n                index.x = d3.event.x;\n                index.i = Math.round(dx.invert(index.x));\n                updateZero();\n            }\n\n            function dragEnd(d,i) {\n                d3.select(chart.container)\n                    .style('cursor', 'auto');\n\n                // update state and send stateChange with new index\n                state.index = index.i;\n                dispatch.stateChange(state);\n            }\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = lines.xScale();\n            y = lines.yScale();\n\n            if (!rescaleY) {\n                var seriesDomains = data\n                    .filter(function(series) { return !series.disabled })\n                    .map(function(series,i) {\n                        var initialDomain = d3.extent(series.values, lines.y());\n\n                        //account for series being disabled when losing 95% or more\n                        if (initialDomain[0] < -.95) initialDomain[0] = -.95;\n\n                        return [\n                                (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]),\n                                (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0])\n                        ];\n                    });\n\n                var completeDomain = [\n                    d3.min(seriesDomains, function(d) { return d[0] }),\n                    d3.max(seriesDomains, function(d) { return d[1] })\n                ];\n\n                lines.yDomain(completeDomain);\n            } else {\n                lines.yDomain(null);\n            }\n\n            dx.domain([0, data[0].values.length - 1]) //Assumes all series have same length\n                .range([0, availableWidth])\n                .clamp(true);\n\n            var data = indexify(index.i, data);\n\n            // Setup containers and skeleton of chart\n            var interactivePointerEvents = (useInteractiveGuideline) ? \"none\" : \"all\";\n            var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-interactive');\n            gEnter.append('g').attr('class', 'nv-x nv-axis').style(\"pointer-events\",\"none\");\n            gEnter.append('g').attr('class', 'nv-y nv-axis');\n            gEnter.append('g').attr('class', 'nv-background');\n            gEnter.append('g').attr('class', 'nv-linesWrap').style(\"pointer-events\",interactivePointerEvents);\n            gEnter.append('g').attr('class', 'nv-avgLinesWrap').style(\"pointer-events\",\"none\");\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n            gEnter.append('g').attr('class', 'nv-controlsWrap');\n\n            // Legend\n            if (showLegend) {\n                legend.width(availableWidth);\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.nv-legendWrap')\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n            }\n\n            // Controls\n            if (showControls) {\n                var controlsData = [\n                    { key: 'Re-scale y-axis', disabled: !rescaleY }\n                ];\n\n                controls\n                    .width(140)\n                    .color(['#444', '#444', '#444'])\n                    .rightAlign(false)\n                    .margin({top: 5, right: 0, bottom: 5, left: 20})\n                ;\n\n                g.select('.nv-controlsWrap')\n                    .datum(controlsData)\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n                    .call(controls);\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            // Show error if series goes below 100%\n            var tempDisabled = data.filter(function(d) { return d.tempDisabled });\n\n            wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates\n            if (tempDisabled.length) {\n                wrap.append('text').attr('class', 'tempDisabled')\n                    .attr('x', availableWidth / 2)\n                    .attr('y', '-.71em')\n                    .style('text-anchor', 'end')\n                    .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.');\n            }\n\n            //Set up interactive layer\n            if (useInteractiveGuideline) {\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .margin({left:margin.left,top:margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n\n            gEnter.select('.nv-background')\n                .append('rect');\n\n            g.select('.nv-background rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            lines\n                //.x(function(d) { return d.x })\n                .y(function(d) { return d.display.y })\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(data.map(function(d,i) {\n                    return d.color || color(d, i);\n                }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; }));\n\n            var linesWrap = g.select('.nv-linesWrap')\n                .datum(data.filter(function(d) { return  !d.disabled && !d.tempDisabled }));\n\n            linesWrap.call(lines);\n\n            //Store a series index number in the data array.\n            data.forEach(function(d,i) {\n                d.seriesIndex = i;\n            });\n\n            var avgLineData = data.filter(function(d) {\n                return !d.disabled && !!average(d);\n            });\n\n            var avgLines = g.select(\".nv-avgLinesWrap\").selectAll(\"line\")\n                .data(avgLineData, function(d) { return d.key; });\n\n            var getAvgLineY = function(d) {\n                //If average lines go off the svg element, clamp them to the svg bounds.\n                var yVal = y(average(d));\n                if (yVal < 0) return 0;\n                if (yVal > availableHeight) return availableHeight;\n                return yVal;\n            };\n\n            avgLines.enter()\n                .append('line')\n                .style('stroke-width',2)\n                .style('stroke-dasharray','10,10')\n                .style('stroke',function (d,i) {\n                    return lines.color()(d,d.seriesIndex);\n                })\n                .attr('x1',0)\n                .attr('x2',availableWidth)\n                .attr('y1', getAvgLineY)\n                .attr('y2', getAvgLineY);\n\n            avgLines\n                .style('stroke-opacity',function(d){\n                    //If average lines go offscreen, make them transparent\n                    var yVal = y(average(d));\n                    if (yVal < 0 || yVal > availableHeight) return 0;\n                    return 1;\n                })\n                .attr('x1',0)\n                .attr('x2',availableWidth)\n                .attr('y1', getAvgLineY)\n                .attr('y2', getAvgLineY);\n\n            avgLines.exit().remove();\n\n            //Create index line\n            var indexLine = linesWrap.selectAll('.nv-indexLine')\n                .data([index]);\n            indexLine.enter().append('rect').attr('class', 'nv-indexLine')\n                .attr('width', 3)\n                .attr('x', -2)\n                .attr('fill', 'red')\n                .attr('fill-opacity', .5)\n                .style(\"pointer-events\",\"all\")\n                .call(indexDrag);\n\n            indexLine\n                .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' })\n                .attr('height', availableHeight);\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/70, data) )\n                    .tickSize(-availableHeight, 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y.range()[0] + ')');\n                g.select('.nv-x.nv-axis')\n                    .call(xAxis);\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis')\n                    .call(yAxis);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            function updateZero() {\n                indexLine\n                    .data([index]);\n\n                //When dragging the index line, turn off line transitions.\n                // Then turn them back on when done dragging.\n                var oldDuration = chart.duration();\n                chart.duration(0);\n                chart.update();\n                chart.duration(oldDuration);\n            }\n\n            g.select('.nv-background rect')\n                .on('click', function() {\n                    index.x = d3.mouse(this)[0];\n                    index.i = Math.round(dx.invert(index.x));\n\n                    // update state and send stateChange with new index\n                    state.index = index.i;\n                    dispatch.stateChange(state);\n\n                    updateZero();\n                });\n\n            lines.dispatch.on('elementClick', function(e) {\n                index.i = e.pointIndex;\n                index.x = dx(index.i);\n\n                // update state and send stateChange with new index\n                state.index = index.i;\n                dispatch.stateChange(state);\n\n                updateZero();\n            });\n\n            controls.dispatch.on('legendClick', function(d,i) {\n                d.disabled = !d.disabled;\n                rescaleY = !d.disabled;\n\n                state.rescaleY = rescaleY;\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                lines.clearHighlights();\n                var singlePoint, pointIndex, pointXLocation, allData = [];\n\n                data\n                    .filter(function(series, i) {\n                        series.seriesIndex = i;\n                        return !series.disabled;\n                    })\n                    .forEach(function(series,i) {\n                        pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n                        lines.highlightPoint(i, pointIndex, true);\n                        var point = series.values[pointIndex];\n                        if (typeof point === 'undefined') return;\n                        if (typeof singlePoint === 'undefined') singlePoint = point;\n                        if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n                        allData.push({\n                            key: series.key,\n                            value: chart.y()(point, pointIndex),\n                            color: color(series,series.seriesIndex)\n                        });\n                    });\n\n                //Highlight the tooltip entry based on which point the mouse is closest to.\n                if (allData.length > 2) {\n                    var yValue = chart.yScale().invert(e.mouseY);\n                    var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]);\n                    var threshold = 0.03 * domainExtent;\n                    var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold);\n                    if (indexToHighlight !== null)\n                        allData[indexToHighlight].highlight = true;\n                }\n\n                var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex);\n                interactiveLayer.tooltip\n                    .chartContainer(that.parentNode)\n                    .valueFormatter(function(d,i) {\n                        return yAxis.tickFormat()(d);\n                    })\n                    .data(\n                    {\n                        value: xValue,\n                        series: allData\n                    }\n                )();\n\n                interactiveLayer.renderGuideLine(pointXLocation);\n            });\n\n            interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                lines.clearHighlights();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n\n                    state.disabled = e.disabled;\n                }\n\n                if (typeof e.index !== 'undefined') {\n                    index.i = e.index;\n                    index.x = dx(index.i);\n\n                    state.index = e.index;\n\n                    indexLine\n                        .data([index]);\n                }\n\n                if (typeof e.rescaleY !== 'undefined') {\n                    rescaleY = e.rescaleY;\n                }\n\n                chart.update();\n            });\n\n        });\n\n        renderWatch.renderEnd('cumulativeLineChart immediate');\n\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n        var point = {\n            x: chart.x()(evt.point),\n            y: chart.y()(evt.point),\n            color: evt.point.color\n        };\n        evt.point = point;\n        tooltip.data(evt).hidden(false);\n    });\n\n    lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true)\n    });\n\n    //============================================================\n    // Functions\n    //------------------------------------------------------------\n\n    var indexifyYGetter = null;\n    /* Normalize the data according to an index point. */\n    function indexify(idx, data) {\n        if (!indexifyYGetter) indexifyYGetter = lines.y();\n        return data.map(function(line, i) {\n            if (!line.values) {\n                return line;\n            }\n            var indexValue = line.values[idx];\n            if (indexValue == null) {\n                return line;\n            }\n            var v = indexifyYGetter(indexValue, idx);\n\n            //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue\n            if (v < -.95 && !noErrorCheck) {\n                //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100)\n\n                line.tempDisabled = true;\n                return line;\n            }\n\n            line.tempDisabled = false;\n\n            line.values = line.values.map(function(point, pointIndex) {\n                point.display = {'y': (indexifyYGetter(point, pointIndex) - v) / (1 + v) };\n                return point;\n            });\n\n            return line;\n        })\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.lines = lines;\n    chart.legend = legend;\n    chart.controls = controls;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.interactiveLayer = interactiveLayer;\n    chart.state = state;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        rescaleY:     {get: function(){return rescaleY;}, set: function(_){rescaleY=_;}},\n        showControls:     {get: function(){return showControls;}, set: function(_){showControls=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        average: {get: function(){return average;}, set: function(_){average=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n        showXAxis:    {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:    {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        noErrorCheck:    {get: function(){return noErrorCheck;}, set: function(_){noErrorCheck=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n        }},\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = _;\n            if (_ === true) {\n                chart.interactive(false);\n                chart.useVoronoi(false);\n            }\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( (_) ? 'right' : 'left');\n        }},\n        duration:    {get: function(){return duration;}, set: function(_){\n            duration = _;\n            lines.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n            renderWatch.reset(duration);\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, lines);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n//TODO: consider deprecating by adding necessary features to multiBar model\nnv.models.discreteBar = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container\n        , x = d3.scale.ordinal()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n        , color = nv.utils.defaultColor()\n        , showValues = false\n        , valueFormat = d3.format(',.2f')\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        , rectClass = 'discreteBar'\n        , duration = 250\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0;\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            //add series index to each data point for reference\n            data.forEach(function(series, i) {\n                series.values.forEach(function(point) {\n                    point.series = i;\n                });\n            });\n\n            // Setup Scales\n            // remap and flatten the data for use in calculating the scales' domains\n            var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n                data.map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d,i), y: getY(d,i), y0: d.y0 }\n                    })\n                });\n\n            x   .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n                .rangeBands(xRange || [0, availableWidth], .1);\n            y   .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY)));\n\n            // If showValues, pad the Y axis range to account for label height\n            if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]);\n            else y.range(yRange || [availableHeight, 0]);\n\n            //store old scales if they exist\n            x0 = x0 || x;\n            y0 = y0 || y.copy().range([y(0),y(0)]);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-groups');\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later\n            var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n                .data(function(d) { return d }, function(d) { return d.key });\n            groups.enter().append('g')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6);\n            groups.exit()\n                .watchTransition(renderWatch, 'discreteBar: exit groups')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6)\n                .remove();\n            groups\n                .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n                .classed('hover', function(d) { return d.hover });\n            groups\n                .watchTransition(renderWatch, 'discreteBar: groups')\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', .75);\n\n            var bars = groups.selectAll('g.nv-bar')\n                .data(function(d) { return d.values });\n            bars.exit().remove();\n\n            var barsEnter = bars.enter().append('g')\n                .attr('transform', function(d,i,j) {\n                    return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')'\n                })\n                .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('click', function(d,i) {\n                    var element = this;\n                    dispatch.elementClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\"),\n                        event: d3.event,\n                        element: element\n                    });\n                    d3.event.stopPropagation();\n                })\n                .on('dblclick', function(d,i) {\n                    dispatch.elementDblClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                });\n\n            barsEnter.append('rect')\n                .attr('height', 0)\n                .attr('width', x.rangeBand() * .9 / data.length )\n\n            if (showValues) {\n                barsEnter.append('text')\n                    .attr('text-anchor', 'middle')\n                ;\n\n                bars.select('text')\n                    .text(function(d,i) { return valueFormat(getY(d,i)) })\n                    .watchTransition(renderWatch, 'discreteBar: bars text')\n                    .attr('x', x.rangeBand() * .9 / 2)\n                    .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 })\n\n                ;\n            } else {\n                bars.selectAll('text').remove();\n            }\n\n            bars\n                .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' })\n                .style('fill', function(d,i) { return d.color || color(d,i) })\n                .style('stroke', function(d,i) { return d.color || color(d,i) })\n                .select('rect')\n                .attr('class', rectClass)\n                .watchTransition(renderWatch, 'discreteBar: bars rect')\n                .attr('width', x.rangeBand() * .9 / data.length);\n            bars.watchTransition(renderWatch, 'discreteBar: bars')\n                //.delay(function(d,i) { return i * 1200 / data[0].values.length })\n                .attr('transform', function(d,i) {\n                    var left = x(getX(d,i)) + x.rangeBand() * .05,\n                        top = getY(d,i) < 0 ?\n                            y(0) :\n                                y(0) - y(getY(d,i)) < 1 ?\n                            y(0) - 1 : //make 1 px positive bars show up above y=0\n                            y(getY(d,i));\n\n                    return 'translate(' + left + ', ' + top + ')'\n                })\n                .select('rect')\n                .attr('height', function(d,i) {\n                    return  Math.max(Math.abs(y(getY(d,i)) - y(0)), 1)\n                });\n\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n\n        });\n\n        renderWatch.renderEnd('discreteBar immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:   {get: function(){return width;}, set: function(_){width=_;}},\n        height:  {get: function(){return height;}, set: function(_){height=_;}},\n        forceY:  {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}},\n        x:       {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:       {get: function(){return getY;}, set: function(_){getY=_;}},\n        xScale:  {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:  {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:  {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:  {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        valueFormat:    {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n        id:          {get: function(){return id;}, set: function(_){id=_;}},\n        rectClass: {get: function(){return rectClass;}, set: function(_){rectClass=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.discreteBarChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var discretebar = nv.models.discreteBar()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n\t, legend = nv.models.legend()\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 15, right: 10, bottom: 50, left: 60}\n        , width = null\n        , height = null\n        , color = nv.utils.getColor()\n\t, showLegend = false\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , staggerLabels = false\n        , wrapLabels = false\n        , rotateLabels = 0\n        , x\n        , y\n        , noData = null\n        , dispatch = d3.dispatch('beforeUpdate','renderEnd')\n        , duration = 250\n        ;\n\n    xAxis\n        .orient('bottom')\n        .showMaxMin(false)\n        .tickFormat(function(d) { return d })\n    ;\n    yAxis\n        .orient((rightAlignYAxis) ? 'right' : 'left')\n        .tickFormat(d3.format(',.1f'))\n    ;\n\n    tooltip\n        .duration(0)\n        .headerEnabled(false)\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        })\n        .keyFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        });\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(discretebar);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() {\n                dispatch.beforeUpdate();\n                container.transition().duration(duration).call(chart);\n            };\n            chart.container = this;\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container);\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = discretebar.xScale();\n            y = discretebar.yScale().clamp(true);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g');\n            var defsEnter = gEnter.append('defs');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis')\n                .append('g').attr('class', 'nv-zeroLine')\n                .append('line');\n\n            gEnter.append('g').attr('class', 'nv-barsWrap');\n\t    gEnter.append('g').attr('class', 'nv-legendWrap');\n\n            g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\t    \n            if (showLegend) {\n                legend.width(availableWidth);\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                wrap.select('.nv-legendWrap')\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n            }\n            \n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\t    \n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            // Main Chart Component(s)\n            discretebar\n                .width(availableWidth)\n                .height(availableHeight);\n\n            var barsWrap = g.select('.nv-barsWrap')\n                .datum(data.filter(function(d) { return !d.disabled }));\n\n            barsWrap.transition().call(discretebar);\n\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-x-label-clip-' + discretebar.id())\n                .append('rect');\n\n            g.select('#nv-x-label-clip-' + discretebar.id() + ' rect')\n                .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))\n                .attr('height', 16)\n                .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight, 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')');\n                g.select('.nv-x.nv-axis').call(xAxis);\n\n                var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n                if (staggerLabels) {\n                    xTicks\n                        .selectAll('text')\n                        .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })\n                }\n\n                if (rotateLabels) {\n                    xTicks\n                        .selectAll('.tick text')\n                        .attr('transform', 'rotate(' + rotateLabels + ' 0,0)')\n                        .style('text-anchor', rotateLabels > 0 ? 'start' : 'end');\n                }\n\n                if (wrapLabels) {\n                    g.selectAll('.tick text')\n                        .call(nv.utils.wrapTicks, chart.xAxis.rangeBand())\n                }\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis').call(yAxis);\n            }\n\n            // Zero line\n            g.select(\".nv-zeroLine line\")\n                .attr(\"x1\",0)\n                .attr(\"x2\",(rightAlignYAxis) ? -availableWidth : availableWidth)\n                .attr(\"y1\", y(0))\n                .attr(\"y2\", y(0))\n            ;\n        });\n\n        renderWatch.renderEnd('discreteBar chart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    discretebar.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt['series'] = {\n            key: chart.x()(evt.data),\n            value: chart.y()(evt.data),\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    discretebar.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    discretebar.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.discretebar = discretebar;\n    chart.legend = legend;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n\tshowLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n        rotateLabels:  {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n        wrapLabels:  {get: function(){return wrapLabels;}, set: function(_){wrapLabels=!!_;}},\n        showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            discretebar.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            discretebar.color(color);\n\t    legend.color(color);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( (_) ? 'right' : 'left');\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, discretebar);\n    nv.utils.initOptions(chart);\n\n    return chart;\n}\n\nnv.models.distribution = function() {\n    \"use strict\";\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 400 //technically width or height depending on x or y....\n        , size = 8\n        , axis = 'x' // 'x' or 'y'... horizontal or vertical\n        , getData = function(d) { return d[axis] }  // defaults d.x or d.y\n        , color = nv.utils.defaultColor()\n        , scale = d3.scale.linear()\n        , domain\n        , duration = 250\n        , dispatch = d3.dispatch('renderEnd')\n        ;\n\n    //============================================================\n\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var scale0;\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    //============================================================\n\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom),\n                naxis = axis == 'x' ? 'y' : 'x',\n                container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            //------------------------------------------------------------\n            // Setup Scales\n\n            scale0 = scale0 || scale;\n\n            //------------------------------------------------------------\n\n\n            //------------------------------------------------------------\n            // Setup containers and skeleton of chart\n\n            var wrap = container.selectAll('g.nv-distribution').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')\n\n            //------------------------------------------------------------\n\n\n            var distWrap = g.selectAll('g.nv-dist')\n                .data(function(d) { return d }, function(d) { return d.key });\n\n            distWrap.enter().append('g');\n            distWrap\n                .attr('class', function(d,i) { return 'nv-dist nv-series-' + i })\n                .style('stroke', function(d,i) { return color(d, i) });\n\n            var dist = distWrap.selectAll('line.nv-dist' + axis)\n                .data(function(d) { return d.values })\n            dist.enter().append('line')\n                .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) })\n                .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) })\n            renderWatch.transition(distWrap.exit().selectAll('line.nv-dist' + axis), 'dist exit')\n                // .transition()\n                .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })\n                .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })\n                .style('stroke-opacity', 0)\n                .remove();\n            dist\n                .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i })\n                .attr(naxis + '1', 0)\n                .attr(naxis + '2', size);\n            renderWatch.transition(dist, 'dist')\n                // .transition()\n                .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })\n                .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })\n\n\n            scale0 = scale.copy();\n\n        });\n        renderWatch.renderEnd('distribution immediate');\n        return chart;\n    }\n\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n    chart.options = nv.utils.optionsFunc.bind(chart);\n    chart.dispatch = dispatch;\n\n    chart.margin = function(_) {\n        if (!arguments.length) return margin;\n        margin.top    = typeof _.top    != 'undefined' ? _.top    : margin.top;\n        margin.right  = typeof _.right  != 'undefined' ? _.right  : margin.right;\n        margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;\n        margin.left   = typeof _.left   != 'undefined' ? _.left   : margin.left;\n        return chart;\n    };\n\n    chart.width = function(_) {\n        if (!arguments.length) return width;\n        width = _;\n        return chart;\n    };\n\n    chart.axis = function(_) {\n        if (!arguments.length) return axis;\n        axis = _;\n        return chart;\n    };\n\n    chart.size = function(_) {\n        if (!arguments.length) return size;\n        size = _;\n        return chart;\n    };\n\n    chart.getData = function(_) {\n        if (!arguments.length) return getData;\n        getData = d3.functor(_);\n        return chart;\n    };\n\n    chart.scale = function(_) {\n        if (!arguments.length) return scale;\n        scale = _;\n        return chart;\n    };\n\n    chart.color = function(_) {\n        if (!arguments.length) return color;\n        color = nv.utils.getColor(_);\n        return chart;\n    };\n\n    chart.duration = function(_) {\n        if (!arguments.length) return duration;\n        duration = _;\n        renderWatch.reset(duration);\n        return chart;\n    };\n    //============================================================\n\n\n    return chart;\n}\nnv.models.furiousLegend = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 5, right: 0, bottom: 5, left: 0}\n        , width = 400\n        , height = 20\n        , getKey = function(d) { return d.key }\n        , color = nv.utils.getColor()\n        , maxKeyLength = 20 //default value for key lengths\n        , align = true\n        , padding = 28 //define how much space between legend items. - recommend 32 for furious version\n        , rightAlign = true\n        , updateState = true   //If true, legend will update data.disabled and trigger a 'stateChange' dispatch.\n        , radioButtonMode = false   //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time)\n        , expanded = false\n        , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange')\n        , vers = 'classic' //Options are \"classic\" and \"furious\"\n        ;\n\n    function chart(selection) {\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-legend').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g');\n            var g = wrap.select('g');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var series = g.selectAll('.nv-series')\n                .data(function(d) {\n                    if(vers != 'furious') return d;\n\n                    return d.filter(function(n) {\n                        return expanded ? true : !n.disengaged;\n                    });\n                });\n            var seriesEnter = series.enter().append('g').attr('class', 'nv-series')\n\n            var seriesShape;\n\n            if(vers == 'classic') {\n                seriesEnter.append('circle')\n                    .style('stroke-width', 2)\n                    .attr('class','nv-legend-symbol')\n                    .attr('r', 5);\n\n                seriesShape = series.select('circle');\n            } else if (vers == 'furious') {\n                seriesEnter.append('rect')\n                    .style('stroke-width', 2)\n                    .attr('class','nv-legend-symbol')\n                    .attr('rx', 3)\n                    .attr('ry', 3);\n\n                seriesShape = series.select('rect');\n\n                seriesEnter.append('g')\n                    .attr('class', 'nv-check-box')\n                    .property('innerHTML','<path d=\"M0.5,5 L22.5,5 L22.5,26.5 L0.5,26.5 L0.5,5 Z\" class=\"nv-box\"></path><path d=\"M5.5,12.8618467 L11.9185089,19.2803556 L31,0.198864511\" class=\"nv-check\"></path>')\n                    .attr('transform', 'translate(-10,-8)scale(0.5)');\n\n                var seriesCheckbox = series.select('.nv-check-box');\n\n                seriesCheckbox.each(function(d,i) {\n                    d3.select(this).selectAll('path')\n                        .attr('stroke', setTextColor(d,i));\n                });\n            }\n\n            seriesEnter.append('text')\n                .attr('text-anchor', 'start')\n                .attr('class','nv-legend-text')\n                .attr('dy', '.32em')\n                .attr('dx', '8');\n\n            var seriesText = series.select('text.nv-legend-text');\n\n            series\n                .on('mouseover', function(d,i) {\n                    dispatch.legendMouseover(d,i);  //TODO: Make consistent with other event objects\n                })\n                .on('mouseout', function(d,i) {\n                    dispatch.legendMouseout(d,i);\n                })\n                .on('click', function(d,i) {\n                    dispatch.legendClick(d,i);\n                    // make sure we re-get data in case it was modified\n                    var data = series.data();\n                    if (updateState) {\n                        if(vers =='classic') {\n                            if (radioButtonMode) {\n                                //Radio button mode: set every series to disabled,\n                                //  and enable the clicked series.\n                                data.forEach(function(series) { series.disabled = true});\n                                d.disabled = false;\n                            }\n                            else {\n                                d.disabled = !d.disabled;\n                                if (data.every(function(series) { return series.disabled})) {\n                                    //the default behavior of NVD3 legends is, if every single series\n                                    // is disabled, turn all series' back on.\n                                    data.forEach(function(series) { series.disabled = false});\n                                }\n                            }\n                        } else if(vers == 'furious') {\n                            if(expanded) {\n                                d.disengaged = !d.disengaged;\n                                d.userDisabled = d.userDisabled == undefined ? !!d.disabled : d.userDisabled;\n                                d.disabled = d.disengaged || d.userDisabled;\n                            } else if (!expanded) {\n                                d.disabled = !d.disabled;\n                                d.userDisabled = d.disabled;\n                                var engaged = data.filter(function(d) { return !d.disengaged; });\n                                if (engaged.every(function(series) { return series.userDisabled })) {\n                                    //the default behavior of NVD3 legends is, if every single series\n                                    // is disabled, turn all series' back on.\n                                    data.forEach(function(series) {\n                                        series.disabled = series.userDisabled = false;\n                                    });\n                                }\n                            }\n                        }\n                        dispatch.stateChange({\n                            disabled: data.map(function(d) { return !!d.disabled }),\n                            disengaged: data.map(function(d) { return !!d.disengaged })\n                        });\n\n                    }\n                })\n                .on('dblclick', function(d,i) {\n                    if(vers == 'furious' && expanded) return;\n                    dispatch.legendDblclick(d,i);\n                    if (updateState) {\n                        // make sure we re-get data in case it was modified\n                        var data = series.data();\n                        //the default behavior of NVD3 legends, when double clicking one,\n                        // is to set all other series' to false, and make the double clicked series enabled.\n                        data.forEach(function(series) {\n                            series.disabled = true;\n                            if(vers == 'furious') series.userDisabled = series.disabled;\n                        });\n                        d.disabled = false;\n                        if(vers == 'furious') d.userDisabled = d.disabled;\n                        dispatch.stateChange({\n                            disabled: data.map(function(d) { return !!d.disabled })\n                        });\n                    }\n                });\n\n            series.classed('nv-disabled', function(d) { return d.userDisabled });\n            series.exit().remove();\n\n            seriesText\n                .attr('fill', setTextColor)\n                .text(getKey);\n\n            //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option)\n            // NEW ALIGNING CODE, TODO: clean up\n\n            var versPadding;\n            switch(vers) {\n                case 'furious' :\n                    versPadding = 23;\n                    break;\n                case 'classic' :\n                    versPadding = 20;\n            }\n\n            if (align) {\n\n                var seriesWidths = [];\n                series.each(function(d,i) {\n                    var legendText;\n                    if (getKey(d).length > maxKeyLength) { \n                        var trimmedKey = getKey(d).substring(0, maxKeyLength);\n                        legendText = d3.select(this).select('text').text(trimmedKey + \"...\");\n                        d3.select(this).append(\"svg:title\").text(getKey(d));\n                    } else {\n                        legendText = d3.select(this).select('text');\n                    } \n                    var nodeTextLength;\n                    try {\n                        nodeTextLength = legendText.node().getComputedTextLength();\n                        // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead\n                        if(nodeTextLength <= 0) throw Error();\n                    }\n                    catch(e) {\n                        nodeTextLength = nv.utils.calcApproxTextWidth(legendText);\n                    }\n\n                    seriesWidths.push(nodeTextLength + padding);\n                });\n\n                var seriesPerRow = 0;\n                var legendWidth = 0;\n                var columnWidths = [];\n\n                while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) {\n                    columnWidths[seriesPerRow] = seriesWidths[seriesPerRow];\n                    legendWidth += seriesWidths[seriesPerRow++];\n                }\n                if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row\n\n                while ( legendWidth > availableWidth && seriesPerRow > 1 ) {\n                    columnWidths = [];\n                    seriesPerRow--;\n\n                    for (var k = 0; k < seriesWidths.length; k++) {\n                        if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) )\n                            columnWidths[k % seriesPerRow] = seriesWidths[k];\n                    }\n\n                    legendWidth = columnWidths.reduce(function(prev, cur, index, array) {\n                        return prev + cur;\n                    });\n                }\n\n                var xPositions = [];\n                for (var i = 0, curX = 0; i < seriesPerRow; i++) {\n                    xPositions[i] = curX;\n                    curX += columnWidths[i];\n                }\n\n                series\n                    .attr('transform', function(d, i) {\n                        return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * versPadding) + ')';\n                    });\n\n                //position legend as far right as possible within the total width\n                if (rightAlign) {\n                    g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')');\n                }\n                else {\n                    g.attr('transform', 'translate(0' + ',' + margin.top + ')');\n                }\n\n                height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * versPadding);\n\n            } else {\n\n                var ypos = 5,\n                    newxpos = 5,\n                    maxwidth = 0,\n                    xpos;\n                series\n                    .attr('transform', function(d, i) {\n                        var length = d3.select(this).select('text').node().getComputedTextLength() + padding;\n                        xpos = newxpos;\n\n                        if (width < margin.left + margin.right + xpos + length) {\n                            newxpos = xpos = 5;\n                            ypos += versPadding;\n                        }\n\n                        newxpos += length;\n                        if (newxpos > maxwidth) maxwidth = newxpos;\n\n                        return 'translate(' + xpos + ',' + ypos + ')';\n                    });\n\n                //position legend as far right as possible within the total width\n                g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')');\n\n                height = margin.top + margin.bottom + ypos + 15;\n            }\n\n            if(vers == 'furious') {\n                // Size rectangles after text is placed\n                seriesShape\n                    .attr('width', function(d,i) {\n                        return seriesText[0][i].getComputedTextLength() + 27;\n                    })\n                    .attr('height', 18)\n                    .attr('y', -9)\n                    .attr('x', -15)\n            }\n\n            seriesShape\n                .style('fill', setBGColor)\n                .style('stroke', function(d,i) { return d.color || color(d, i) });\n        });\n\n        function setTextColor(d,i) {\n            if(vers != 'furious') return '#000';\n            if(expanded) {\n                return d.disengaged ? color(d,i) : '#fff';\n            } else if (!expanded) {\n                return !!d.disabled ? color(d,i) : '#fff';\n            }\n        }\n\n        function setBGColor(d,i) {\n            if(expanded && vers == 'furious') {\n                return d.disengaged ? '#fff' : color(d,i);\n            } else {\n                return !!d.disabled ? '#fff' : color(d,i);\n            }\n        }\n\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        key:        {get: function(){return getKey;}, set: function(_){getKey=_;}},\n        align:      {get: function(){return align;}, set: function(_){align=_;}},\n        rightAlign:    {get: function(){return rightAlign;}, set: function(_){rightAlign=_;}},\n        maxKeyLength:  {get: function(){return maxKeyLength;}, set: function(_){maxKeyLength=_;}},\n        padding:       {get: function(){return padding;}, set: function(_){padding=_;}},\n        updateState:   {get: function(){return updateState;}, set: function(_){updateState=_;}},\n        radioButtonMode:    {get: function(){return radioButtonMode;}, set: function(_){radioButtonMode=_;}},\n        expanded:   {get: function(){return expanded;}, set: function(_){expanded=_;}},\n        vers:   {get: function(){return vers;}, set: function(_){vers=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n//TODO: consider deprecating and using multibar with single series for this\nnv.models.historicalBar = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = null\n        , height = null\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , x = d3.scale.linear()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , forceX = []\n        , forceY = [0]\n        , padData = false\n        , clipEdge = true\n        , color = nv.utils.defaultColor()\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        , interactive = true\n        ;\n\n    var renderWatch = nv.utils.renderWatch(dispatch, 0);\n\n    function chart(selection) {\n        selection.each(function(data) {\n            renderWatch.reset();\n\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            nv.utils.initSVG(container);\n\n            // Setup Scales\n            x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ));\n\n            if (padData)\n                x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5)  / data[0].values.length ]);\n            else\n                x.range(xRange || [0, availableWidth]);\n\n            y.domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) ))\n                .range(yRange || [availableHeight, 0]);\n\n            // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n            if (x.domain()[0] === x.domain()[1])\n                x.domain()[0] ?\n                    x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n                    : x.domain([-1,1]);\n\n            if (y.domain()[0] === y.domain()[1])\n                y.domain()[0] ?\n                    y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n                    : y.domain([-1,1]);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id);\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-bars');\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            container\n                .on('click', function(d,i) {\n                    dispatch.chartClick({\n                        data: d,\n                        index: i,\n                        pos: d3.event,\n                        id: id\n                    });\n                });\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-chart-clip-path-' + id)\n                .append('rect');\n\n            wrap.select('#nv-chart-clip-path-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            g.attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');\n\n            var bars = wrap.select('.nv-bars').selectAll('.nv-bar')\n                .data(function(d) { return d }, function(d,i) {return getX(d,i)});\n            bars.exit().remove();\n\n            bars.enter().append('rect')\n                .attr('x', 0 )\n                .attr('y', function(d,i) {  return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) })\n                .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) })\n                .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })\n                .on('mouseover', function(d,i) {\n                    if (!interactive) return;\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n\n                })\n                .on('mouseout', function(d,i) {\n                    if (!interactive) return;\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    if (!interactive) return;\n                    dispatch.elementMousemove({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('click', function(d,i) {\n                    if (!interactive) return;\n                    dispatch.elementClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                })\n                .on('dblclick', function(d,i) {\n                    if (!interactive) return;\n                    dispatch.elementDblClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                });\n\n            bars\n                .attr('fill', function(d,i) { return color(d, i); })\n                .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i })\n                .watchTransition(renderWatch, 'bars')\n                .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })\n                //TODO: better width calculations that don't assume always uniform data spacing;w\n                .attr('width', (availableWidth / data[0].values.length) * .9 );\n\n            bars.watchTransition(renderWatch, 'bars')\n                .attr('y', function(d,i) {\n                    var rval = getY(d,i) < 0 ?\n                        y(0) :\n                            y(0) - y(getY(d,i)) < 1 ?\n                        y(0) - 1 :\n                        y(getY(d,i));\n                    return nv.utils.NaNtoZero(rval);\n                })\n                .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) });\n\n        });\n\n        renderWatch.renderEnd('historicalBar immediate');\n        return chart;\n    }\n\n    //Create methods to allow outside functions to highlight a specific bar.\n    chart.highlightPoint = function(pointIndex, isHoverOver) {\n        container\n            .select(\".nv-bars .nv-bar-0-\" + pointIndex)\n            .classed(\"hover\", isHoverOver)\n        ;\n    };\n\n    chart.clearHighlights = function() {\n        container\n            .select(\".nv-bars .nv-bar.hover\")\n            .classed(\"hover\", false)\n        ;\n    };\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:   {get: function(){return width;}, set: function(_){width=_;}},\n        height:  {get: function(){return height;}, set: function(_){height=_;}},\n        forceX:  {get: function(){return forceX;}, set: function(_){forceX=_;}},\n        forceY:  {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        padData: {get: function(){return padData;}, set: function(_){padData=_;}},\n        x:       {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:       {get: function(){return getY;}, set: function(_){getY=_;}},\n        xScale:  {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:  {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:  {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:  {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        clipEdge:    {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        id:          {get: function(){return id;}, set: function(_){id=_;}},\n        interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.historicalBarChart = function(bar_model) {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var bars = bar_model || nv.models.historicalBar()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , legend = nv.models.legend()\n        , interactiveLayer = nv.interactiveGuideline()\n        , tooltip = nv.models.tooltip()\n        ;\n\n\n    var margin = {top: 30, right: 90, bottom: 50, left: 90}\n        , color = nv.utils.defaultColor()\n        , width = null\n        , height = null\n        , showLegend = false\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , useInteractiveGuideline = false\n        , x\n        , y\n        , state = {}\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('tooltipHide', 'stateChange', 'changeState', 'renderEnd')\n        , transitionDuration = 250\n        ;\n\n    xAxis.orient('bottom').tickPadding(7);\n    yAxis.orient( (rightAlignYAxis) ? 'right' : 'left');\n    tooltip\n        .duration(0)\n        .headerEnabled(false)\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        })\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        });\n\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch, 0);\n\n    function chart(selection) {\n        selection.each(function(data) {\n            renderWatch.reset();\n            renderWatch.models(bars);\n            if (showXAxis) renderWatch.models(xAxis);\n            if (showYAxis) renderWatch.models(yAxis);\n\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() { container.transition().duration(transitionDuration).call(chart) };\n            chart.container = this;\n\n            //set state.disabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display noData message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = bars.xScale();\n            y = bars.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-historicalBarChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBarChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis');\n            gEnter.append('g').attr('class', 'nv-barsWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n            gEnter.append('g').attr('class', 'nv-interactive');\n\n            // Legend\n            if (showLegend) {\n                legend.width(availableWidth);\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                wrap.select('.nv-legendWrap')\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n            }\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            //Set up interactive layer\n            if (useInteractiveGuideline) {\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .margin({left:margin.left, top:margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n            bars\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(data.map(function(d,i) {\n                    return d.color || color(d, i);\n                }).filter(function(d,i) { return !data[i].disabled }));\n\n            var barsWrap = g.select('.nv-barsWrap')\n                .datum(data.filter(function(d) { return !d.disabled }));\n            barsWrap.transition().call(bars);\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight, 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y.range()[0] + ')');\n                g.select('.nv-x.nv-axis')\n                    .transition()\n                    .call(xAxis);\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis')\n                    .transition()\n                    .call(yAxis);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                bars.clearHighlights();\n\n                var singlePoint, pointIndex, pointXLocation, allData = [];\n                data\n                    .filter(function(series, i) {\n                        series.seriesIndex = i;\n                        return !series.disabled;\n                    })\n                    .forEach(function(series,i) {\n                        pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n                        bars.highlightPoint(pointIndex,true);\n                        var point = series.values[pointIndex];\n                        if (point === undefined) return;\n                        if (singlePoint === undefined) singlePoint = point;\n                        if (pointXLocation === undefined) pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n                        allData.push({\n                            key: series.key,\n                            value: chart.y()(point, pointIndex),\n                            color: color(series,series.seriesIndex),\n                            data: series.values[pointIndex]\n                        });\n                    });\n\n                var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex));\n                interactiveLayer.tooltip\n                    .chartContainer(that.parentNode)\n                    .valueFormatter(function(d,i) {\n                        return yAxis.tickFormat()(d);\n                    })\n                    .data({\n                        value: xValue,\n                        index: pointIndex,\n                        series: allData\n                    })();\n\n                interactiveLayer.renderGuideLine(pointXLocation);\n\n            });\n\n            interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                dispatch.tooltipHide();\n                bars.clearHighlights();\n            });\n\n            legend.dispatch.on('legendClick', function(d,i) {\n                d.disabled = !d.disabled;\n\n                if (!data.filter(function(d) { return !d.disabled }).length) {\n                    data.map(function(d) {\n                        d.disabled = false;\n                        wrap.selectAll('.nv-series').classed('disabled', false);\n                        return d;\n                    });\n                }\n\n                state.disabled = data.map(function(d) { return !!d.disabled });\n                dispatch.stateChange(state);\n\n                selection.transition().call(chart);\n            });\n\n            legend.dispatch.on('legendDblclick', function(d) {\n                //Double clicking should always enable current series, and disabled all others.\n                data.forEach(function(d) {\n                    d.disabled = true;\n                });\n                d.disabled = false;\n\n                state.disabled = data.map(function(d) { return !!d.disabled });\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n\n                    state.disabled = e.disabled;\n                }\n\n                chart.update();\n            });\n        });\n\n        renderWatch.renderEnd('historicalBarChart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    bars.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt['series'] = {\n            key: chart.x()(evt.data),\n            value: chart.y()(evt.data),\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    bars.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    bars.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.bars = bars;\n    chart.legend = legend;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.interactiveLayer = interactiveLayer;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n            bars.color(color);\n        }},\n        duration:    {get: function(){return transitionDuration;}, set: function(_){\n            transitionDuration=_;\n            renderWatch.reset(transitionDuration);\n            yAxis.duration(transitionDuration);\n            xAxis.duration(transitionDuration);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( (_) ? 'right' : 'left');\n        }},\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = _;\n            if (_ === true) {\n                chart.interactive(false);\n            }\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, bars);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\n\n// ohlcChart is just a historical chart with ohlc bars and some tweaks\nnv.models.ohlcBarChart = function() {\n    var chart = nv.models.historicalBarChart(nv.models.ohlcBar());\n\n    // special default tooltip since we show multiple values per x\n    chart.useInteractiveGuideline(true);\n    chart.interactiveLayer.tooltip.contentGenerator(function(data) {\n        // we assume only one series exists for this chart\n        var d = data.series[0].data;\n        // match line colors as defined in nv.d3.css\n        var color = d.open < d.close ? \"2ca02c\" : \"d62728\";\n        return '' +\n            '<h3 style=\"color: #' + color + '\">' + data.value + '</h3>' +\n            '<table>' +\n            '<tr><td>open:</td><td>' + chart.yAxis.tickFormat()(d.open) + '</td></tr>' +\n            '<tr><td>close:</td><td>' + chart.yAxis.tickFormat()(d.close) + '</td></tr>' +\n            '<tr><td>high</td><td>' + chart.yAxis.tickFormat()(d.high) + '</td></tr>' +\n            '<tr><td>low:</td><td>' + chart.yAxis.tickFormat()(d.low) + '</td></tr>' +\n            '</table>';\n    });\n    return chart;\n};\n\n// candlestickChart is just a historical chart with candlestick bars and some tweaks\nnv.models.candlestickBarChart = function() {\n    var chart = nv.models.historicalBarChart(nv.models.candlestickBar());\n\n    // special default tooltip since we show multiple values per x\n    chart.useInteractiveGuideline(true);\n    chart.interactiveLayer.tooltip.contentGenerator(function(data) {\n        // we assume only one series exists for this chart\n        var d = data.series[0].data;\n        // match line colors as defined in nv.d3.css\n        var color = d.open < d.close ? \"2ca02c\" : \"d62728\";\n        return '' +\n            '<h3 style=\"color: #' + color + '\">' + data.value + '</h3>' +\n            '<table>' +\n            '<tr><td>open:</td><td>' + chart.yAxis.tickFormat()(d.open) + '</td></tr>' +\n            '<tr><td>close:</td><td>' + chart.yAxis.tickFormat()(d.close) + '</td></tr>' +\n            '<tr><td>high</td><td>' + chart.yAxis.tickFormat()(d.high) + '</td></tr>' +\n            '<tr><td>low:</td><td>' + chart.yAxis.tickFormat()(d.low) + '</td></tr>' +\n            '</table>';\n    });\n    return chart;\n};\nnv.models.legend = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 5, right: 0, bottom: 5, left: 0}\n        , width = 400\n        , height = 20\n        , getKey = function(d) { return d.key }\n        , color = nv.utils.getColor()\n        , maxKeyLength = 20 //default value for key lengths\n        , align = true\n        , padding = 32 //define how much space between legend items. - recommend 32 for furious version\n        , rightAlign = true\n        , updateState = true   //If true, legend will update data.disabled and trigger a 'stateChange' dispatch.\n        , radioButtonMode = false   //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time)\n        , expanded = false\n        , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange')\n        , vers = 'classic' //Options are \"classic\" and \"furious\"\n        ;\n\n    function chart(selection) {\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-legend').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g');\n            var g = wrap.select('g');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var series = g.selectAll('.nv-series')\n                .data(function(d) {\n                    if(vers != 'furious') return d;\n\n                    return d.filter(function(n) {\n                        return expanded ? true : !n.disengaged;\n                    });\n                });\n\n            var seriesEnter = series.enter().append('g').attr('class', 'nv-series');\n            var seriesShape;\n\n            var versPadding;\n            switch(vers) {\n                case 'furious' :\n                    versPadding = 23;\n                    break;\n                case 'classic' :\n                    versPadding = 20;\n            }\n\n            if(vers == 'classic') {\n                seriesEnter.append('circle')\n                    .style('stroke-width', 2)\n                    .attr('class','nv-legend-symbol')\n                    .attr('r', 5);\n\n                seriesShape = series.select('circle');\n            } else if (vers == 'furious') {\n                seriesEnter.append('rect')\n                    .style('stroke-width', 2)\n                    .attr('class','nv-legend-symbol')\n                    .attr('rx', 3)\n                    .attr('ry', 3);\n                seriesShape = series.select('.nv-legend-symbol');\n\n                seriesEnter.append('g')\n                    .attr('class', 'nv-check-box')\n                    .property('innerHTML','<path d=\"M0.5,5 L22.5,5 L22.5,26.5 L0.5,26.5 L0.5,5 Z\" class=\"nv-box\"></path><path d=\"M5.5,12.8618467 L11.9185089,19.2803556 L31,0.198864511\" class=\"nv-check\"></path>')\n                    .attr('transform', 'translate(-10,-8)scale(0.5)');\n\n                var seriesCheckbox = series.select('.nv-check-box');\n\n                seriesCheckbox.each(function(d,i) {\n                    d3.select(this).selectAll('path')\n                        .attr('stroke', setTextColor(d,i));\n                });\n            }\n\n            seriesEnter.append('text')\n                .attr('text-anchor', 'start')\n                .attr('class','nv-legend-text')\n                .attr('dy', '.32em')\n                .attr('dx', '8');\n\n            var seriesText = series.select('text.nv-legend-text');\n\n            series\n                .on('mouseover', function(d,i) {\n                    dispatch.legendMouseover(d,i);  //TODO: Make consistent with other event objects\n                })\n                .on('mouseout', function(d,i) {\n                    dispatch.legendMouseout(d,i);\n                })\n                .on('click', function(d,i) {\n                    dispatch.legendClick(d,i);\n                    // make sure we re-get data in case it was modified\n                    var data = series.data();\n                    if (updateState) {\n                        if(vers =='classic') {\n                            if (radioButtonMode) {\n                                //Radio button mode: set every series to disabled,\n                                //  and enable the clicked series.\n                                data.forEach(function(series) { series.disabled = true});\n                                d.disabled = false;\n                            }\n                            else {\n                                d.disabled = !d.disabled;\n                                if (data.every(function(series) { return series.disabled})) {\n                                    //the default behavior of NVD3 legends is, if every single series\n                                    // is disabled, turn all series' back on.\n                                    data.forEach(function(series) { series.disabled = false});\n                                }\n                            }\n                        } else if(vers == 'furious') {\n                            if(expanded) {\n                                d.disengaged = !d.disengaged;\n                                d.userDisabled = d.userDisabled == undefined ? !!d.disabled : d.userDisabled;\n                                d.disabled = d.disengaged || d.userDisabled;\n                            } else if (!expanded) {\n                                d.disabled = !d.disabled;\n                                d.userDisabled = d.disabled;\n                                var engaged = data.filter(function(d) { return !d.disengaged; });\n                                if (engaged.every(function(series) { return series.userDisabled })) {\n                                    //the default behavior of NVD3 legends is, if every single series\n                                    // is disabled, turn all series' back on.\n                                    data.forEach(function(series) {\n                                        series.disabled = series.userDisabled = false;\n                                    });\n                                }\n                            }\n                        }\n                        dispatch.stateChange({\n                            disabled: data.map(function(d) { return !!d.disabled }),\n                            disengaged: data.map(function(d) { return !!d.disengaged })\n                        });\n\n                    }\n                })\n                .on('dblclick', function(d,i) {\n                    if(vers == 'furious' && expanded) return;\n                    dispatch.legendDblclick(d,i);\n                    if (updateState) {\n                        // make sure we re-get data in case it was modified\n                        var data = series.data();\n                        //the default behavior of NVD3 legends, when double clicking one,\n                        // is to set all other series' to false, and make the double clicked series enabled.\n                        data.forEach(function(series) {\n                            series.disabled = true;\n                            if(vers == 'furious') series.userDisabled = series.disabled;\n                        });\n                        d.disabled = false;\n                        if(vers == 'furious') d.userDisabled = d.disabled;\n                        dispatch.stateChange({\n                            disabled: data.map(function(d) { return !!d.disabled })\n                        });\n                    }\n                });\n\n            series.classed('nv-disabled', function(d) { return d.userDisabled });\n            series.exit().remove();\n\n            seriesText\n                .attr('fill', setTextColor)\n                .text(getKey);\n\n            //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option)\n            // NEW ALIGNING CODE, TODO: clean up\n            var legendWidth = 0;\n            if (align) {\n\n                var seriesWidths = [];\n                series.each(function(d,i) {\n                    var legendText;\n                    if (getKey(d).length > maxKeyLength) { \n                        var trimmedKey = getKey(d).substring(0, maxKeyLength);\n                        legendText = d3.select(this).select('text').text(trimmedKey + \"...\");\n                        d3.select(this).append(\"svg:title\").text(getKey(d));\n                    } else {\n                        legendText = d3.select(this).select('text');\n                    } \n                    var nodeTextLength;\n                    try {\n                        nodeTextLength = legendText.node().getComputedTextLength();\n                        // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead\n                        if(nodeTextLength <= 0) throw Error();\n                    }\n                    catch(e) {\n                        nodeTextLength = nv.utils.calcApproxTextWidth(legendText);\n                    }\n\n                    seriesWidths.push(nodeTextLength + padding);\n                });\n\n                var seriesPerRow = 0;\n                var columnWidths = [];\n                legendWidth = 0;\n\n                while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) {\n                    columnWidths[seriesPerRow] = seriesWidths[seriesPerRow];\n                    legendWidth += seriesWidths[seriesPerRow++];\n                }\n                if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row\n\n                while ( legendWidth > availableWidth && seriesPerRow > 1 ) {\n                    columnWidths = [];\n                    seriesPerRow--;\n\n                    for (var k = 0; k < seriesWidths.length; k++) {\n                        if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) )\n                            columnWidths[k % seriesPerRow] = seriesWidths[k];\n                    }\n\n                    legendWidth = columnWidths.reduce(function(prev, cur, index, array) {\n                        return prev + cur;\n                    });\n                }\n\n                var xPositions = [];\n                for (var i = 0, curX = 0; i < seriesPerRow; i++) {\n                    xPositions[i] = curX;\n                    curX += columnWidths[i];\n                }\n\n                series\n                    .attr('transform', function(d, i) {\n                        return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * versPadding) + ')';\n                    });\n\n                //position legend as far right as possible within the total width\n                if (rightAlign) {\n                    g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')');\n                }\n                else {\n                    g.attr('transform', 'translate(0' + ',' + margin.top + ')');\n                }\n\n                height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * versPadding);\n\n            } else {\n\n                var ypos = 5,\n                    newxpos = 5,\n                    maxwidth = 0,\n                    xpos;\n                series\n                    .attr('transform', function(d, i) {\n                        var length = d3.select(this).select('text').node().getComputedTextLength() + padding;\n                        xpos = newxpos;\n\n                        if (width < margin.left + margin.right + xpos + length) {\n                            newxpos = xpos = 5;\n                            ypos += versPadding;\n                        }\n\n                        newxpos += length;\n                        if (newxpos > maxwidth) maxwidth = newxpos;\n\n                        if(legendWidth < xpos + maxwidth) {\n                            legendWidth = xpos + maxwidth;\n                        }\n                        return 'translate(' + xpos + ',' + ypos + ')';\n                    });\n\n                //position legend as far right as possible within the total width\n                g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')');\n\n                height = margin.top + margin.bottom + ypos + 15;\n            }\n\n            if(vers == 'furious') {\n                // Size rectangles after text is placed\n                seriesShape\n                    .attr('width', function(d,i) {\n                        return seriesText[0][i].getComputedTextLength() + 27;\n                    })\n                    .attr('height', 18)\n                    .attr('y', -9)\n                    .attr('x', -15);\n\n                // The background for the expanded legend (UI)\n                gEnter.insert('rect',':first-child')\n                    .attr('class', 'nv-legend-bg')\n                    .attr('fill', '#eee')\n                    // .attr('stroke', '#444')\n                    .attr('opacity',0);\n\n                var seriesBG = g.select('.nv-legend-bg');\n\n                seriesBG\n                .transition().duration(300)\n                    .attr('x', -versPadding )\n                    .attr('width', legendWidth + versPadding - 12)\n                    .attr('height', height + 10)\n                    .attr('y', -margin.top - 10)\n                    .attr('opacity', expanded ? 1 : 0);\n\n\n            }\n\n            seriesShape\n                .style('fill', setBGColor)\n                .style('fill-opacity', setBGOpacity)\n                .style('stroke', setBGColor);\n        });\n\n        function setTextColor(d,i) {\n            if(vers != 'furious') return '#000';\n            if(expanded) {\n                return d.disengaged ? '#000' : '#fff';\n            } else if (!expanded) {\n                if(!d.color) d.color = color(d,i);\n                return !!d.disabled ? d.color : '#fff';\n            }\n        }\n\n        function setBGColor(d,i) {\n            if(expanded && vers == 'furious') {\n                return d.disengaged ? '#eee' : d.color || color(d,i);\n            } else {\n                return d.color || color(d,i);\n            }\n        }\n\n\n        function setBGOpacity(d,i) {\n            if(expanded && vers == 'furious') {\n                return 1;\n            } else {\n                return !!d.disabled ? 0 : 1;\n            }\n        }\n\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        key:        {get: function(){return getKey;}, set: function(_){getKey=_;}},\n        align:      {get: function(){return align;}, set: function(_){align=_;}},\n        maxKeyLength:   {get: function(){return maxKeyLength;}, set: function(_){maxKeyLength=_;}},\n        rightAlign:    {get: function(){return rightAlign;}, set: function(_){rightAlign=_;}},\n        padding:       {get: function(){return padding;}, set: function(_){padding=_;}},\n        updateState:   {get: function(){return updateState;}, set: function(_){updateState=_;}},\n        radioButtonMode:    {get: function(){return radioButtonMode;}, set: function(_){radioButtonMode=_;}},\n        expanded:   {get: function(){return expanded;}, set: function(_){expanded=_;}},\n        vers:   {get: function(){return vers;}, set: function(_){vers=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.line = function() {\n    \"use strict\";\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var  scatter = nv.models.scatter()\n        ;\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , container = null\n        , strokeWidth = 1.5\n        , color = nv.utils.defaultColor() // a function that returns a color\n        , getX = function(d) { return d.x } // accessor to get the x value from a data point\n        , getY = function(d) { return d.y } // accessor to get the y value from a data point\n        , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined\n        , isArea = function(d) { return d.area } // decides if a line is an area or just a line\n        , clipEdge = false // if true, masks lines within x and y scale\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , interpolate = \"linear\" // controls the line interpolation\n        , duration = 250\n        , dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout', 'renderEnd')\n        ;\n\n    scatter\n        .pointSize(16) // default size\n        .pointDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor\n    ;\n\n    //============================================================\n\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0 //used to store previous scales\n        , renderWatch = nv.utils.renderWatch(dispatch, duration)\n        ;\n\n    //============================================================\n\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(scatter);\n        selection.each(function(data) {\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n            nv.utils.initSVG(container);\n\n            // Setup Scales\n            x = scatter.xScale();\n            y = scatter.yScale();\n\n            x0 = x0 || x;\n            y0 = y0 || y;\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-groups');\n            gEnter.append('g').attr('class', 'nv-scatterWrap');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            scatter\n                .width(availableWidth)\n                .height(availableHeight);\n\n            var scatterWrap = wrap.select('.nv-scatterWrap');\n            scatterWrap.call(scatter);\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-edge-clip-' + scatter.id())\n                .append('rect');\n\n            wrap.select('#nv-edge-clip-' + scatter.id() + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', (availableHeight > 0) ? availableHeight : 0);\n\n            g   .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');\n            scatterWrap\n                .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : '');\n\n            var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n                .data(function(d) { return d }, function(d) { return d.key });\n            groups.enter().append('g')\n                .style('stroke-opacity', 1e-6)\n                .style('stroke-width', function(d) { return d.strokeWidth || strokeWidth })\n                .style('fill-opacity', 1e-6);\n\n            groups.exit().remove();\n\n            groups\n                .attr('class', function(d,i) {\n                    return (d.classed || '') + ' nv-group nv-series-' + i;\n                })\n                .classed('hover', function(d) { return d.hover })\n                .style('fill', function(d,i){ return color(d, i) })\n                .style('stroke', function(d,i){ return color(d, i)});\n            groups.watchTransition(renderWatch, 'line: groups')\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', function(d) { return d.fillOpacity || .5});\n\n            var areaPaths = groups.selectAll('path.nv-area')\n                .data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area\n            areaPaths.enter().append('path')\n                .attr('class', 'nv-area')\n                .attr('d', function(d) {\n                    return d3.svg.area()\n                        .interpolate(interpolate)\n                        .defined(defined)\n                        .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })\n                        .y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })\n                        .y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })\n                        //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this\n                        .apply(this, [d.values])\n                });\n            groups.exit().selectAll('path.nv-area')\n                .remove();\n\n            areaPaths.watchTransition(renderWatch, 'line: areaPaths')\n                .attr('d', function(d) {\n                    return d3.svg.area()\n                        .interpolate(interpolate)\n                        .defined(defined)\n                        .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })\n                        .y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })\n                        .y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) })\n                        //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this\n                        .apply(this, [d.values])\n                });\n\n            var linePaths = groups.selectAll('path.nv-line')\n                .data(function(d) { return [d.values] });\n\n            linePaths.enter().append('path')\n                .attr('class', 'nv-line')\n                .attr('d',\n                    d3.svg.line()\n                    .interpolate(interpolate)\n                    .defined(defined)\n                    .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) })\n                    .y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) })\n            );\n\n            linePaths.watchTransition(renderWatch, 'line: linePaths')\n                .attr('d',\n                    d3.svg.line()\n                    .interpolate(interpolate)\n                    .defined(defined)\n                    .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) })\n                    .y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) })\n            );\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n        });\n        renderWatch.renderEnd('line immediate');\n        return chart;\n    }\n\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.scatter = scatter;\n    // Pass through events\n    scatter.dispatch.on('elementClick', function(){ dispatch.elementClick.apply(this, arguments); });\n    scatter.dispatch.on('elementMouseover', function(){ dispatch.elementMouseover.apply(this, arguments); });\n    scatter.dispatch.on('elementMouseout', function(){ dispatch.elementMouseout.apply(this, arguments); });\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        defined: {get: function(){return defined;}, set: function(_){defined=_;}},\n        interpolate:      {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n        clipEdge:    {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            scatter.duration(duration);\n        }},\n        isArea: {get: function(){return isArea;}, set: function(_){\n            isArea = d3.functor(_);\n        }},\n        x: {get: function(){return getX;}, set: function(_){\n            getX = _;\n            scatter.x(_);\n        }},\n        y: {get: function(){return getY;}, set: function(_){\n            getY = _;\n            scatter.y(_);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            scatter.color(color);\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, scatter);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\nnv.models.lineChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var lines = nv.models.line()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , legend = nv.models.legend()\n        , interactiveLayer = nv.interactiveGuideline()\n        , tooltip = nv.models.tooltip()\n        , lines2 = nv.models.line()\n        , x2Axis = nv.models.axis()\n        , y2Axis = nv.models.axis()\n        , brush = d3.svg.brush()\n        ;\n\n    var margin = {top: 30, right: 20, bottom: 50, left: 60}\n        , margin2 = {top: 0, right: 20, bottom: 20, left: 60}\n        , color = nv.utils.defaultColor()\n        , width = null\n        , height = null\n        , showLegend = true\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , useInteractiveGuideline = false\n        , x\n        , y\n        , x2\n        , y2\n        , focusEnable = false\n        , focusShowAxisY = false\n        , focusShowAxisX = true\n        , focusHeight = 50\n        , brushExtent = null\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush', 'stateChange', 'changeState', 'renderEnd')\n        , duration = 250\n        ;\n\n    // set options on sub-objects for this chart\n    xAxis.orient('bottom').tickPadding(7);\n    yAxis.orient(rightAlignYAxis ? 'right' : 'left');\n\n    lines.clipEdge(true).duration(0);\n    lines2.interactive(false);\n    // We don't want any points emitted for the focus chart's scatter graph.\n    lines2.pointActive(function(d) { return false; });\n\n    x2Axis.orient('bottom').tickPadding(5);\n    y2Axis.orient(rightAlignYAxis ? 'right' : 'left');\n\n    tooltip.valueFormatter(function(d, i) {\n        return yAxis.tickFormat()(d, i);\n    }).headerFormatter(function(d, i) {\n        return xAxis.tickFormat()(d, i);\n    });\n    \n    interactiveLayer.tooltip.valueFormatter(function(d, i) {\n        return yAxis.tickFormat()(d, i);\n    }).headerFormatter(function(d, i) {\n        return xAxis.tickFormat()(d, i);\n    });\n\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled; })\n            };\n        };\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        };\n    };\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(lines);\n        renderWatch.models(lines2);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        if (focusShowAxisX) renderWatch.models(x2Axis);\n        if (focusShowAxisY) renderWatch.models(y2Axis);\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight1 = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focusHeight : 0),\n                availableHeight2 = focusHeight - margin2.top - margin2.bottom;\n\n            chart.update = function() { \n                if( duration === 0 ) {\n                    container.call( chart );\n                } else {\n                    container.transition().duration(duration).call(chart);\n                }\n            };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disabled\n            state.disabled = data.map(function(d) { return !!d.disabled; });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display noData message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length; }).length) {\n                nv.utils.noData(chart, container);\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n\n            // Setup Scales\n            x = lines.xScale();\n            y = lines.yScale();\n            x2 = lines2.xScale();\n            y2 = lines2.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n\n            var focusEnter = gEnter.append('g').attr('class', 'nv-focus');\n            focusEnter.append('g').attr('class', 'nv-background').append('rect');\n            focusEnter.append('g').attr('class', 'nv-x nv-axis');\n            focusEnter.append('g').attr('class', 'nv-y nv-axis');\n            focusEnter.append('g').attr('class', 'nv-linesWrap');\n            focusEnter.append('g').attr('class', 'nv-interactive');\n\n            var contextEnter = gEnter.append('g').attr('class', 'nv-context');\n            contextEnter.append('g').attr('class', 'nv-background').append('rect');\n            contextEnter.append('g').attr('class', 'nv-x nv-axis');\n            contextEnter.append('g').attr('class', 'nv-y nv-axis');\n            contextEnter.append('g').attr('class', 'nv-linesWrap');\n            contextEnter.append('g').attr('class', 'nv-brushBackground');\n            contextEnter.append('g').attr('class', 'nv-x nv-brush');\n\n            // Legend\n            if (showLegend) {\n                legend.width(availableWidth);\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight1 = nv.utils.availableHeight(height, container, margin) - (focusEnable ? focusHeight : 0);\n                }\n\n                wrap.select('.nv-legendWrap')\n                    .attr('transform', 'translate(0,' + (-margin.top) +')');\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            //Set up interactive layer\n            if (useInteractiveGuideline) {\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight1)\n                    .margin({left:margin.left, top:margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n\n            g.select('.nv-focus .nv-background rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight1);\n                \n            lines\n                .width(availableWidth)\n                .height(availableHeight1)\n                .color(data.map(function(d,i) {\n                    return d.color || color(d, i);\n\n                }).filter(function(d,i) { return !data[i].disabled; }));\n\n            var linesWrap = g.select('.nv-linesWrap')\n                .datum(data.filter(function(d) { return !d.disabled; }));\n\n\n            // Setup Main (Focus) Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks(nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight1, 0);\n\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight1/36, data) )\n                    .tickSize( -availableWidth, 0);\n            }\n\n            //============================================================\n            // Update Axes\n            //============================================================\n            function updateXAxis() {\n              if(showXAxis) {\n                g.select('.nv-focus .nv-x.nv-axis')\n                  .transition()\n                  .duration(duration)\n                  .call(xAxis)\n                ;\n              }\n            }\n\n            function updateYAxis() {\n              if(showYAxis) {\n                g.select('.nv-focus .nv-y.nv-axis')\n                  .transition()\n                  .duration(duration)\n                  .call(yAxis)\n                ;\n              }\n            }\n            \n            g.select('.nv-focus .nv-x.nv-axis')\n                .attr('transform', 'translate(0,' + availableHeight1 + ')');\n\n            if( !focusEnable )\n            {\n                linesWrap.call(lines);\n                updateXAxis();\n                updateYAxis();\n            }\n            else\n            {\n                lines2\n                    .defined(lines.defined())\n                    .width(availableWidth)\n                    .height(availableHeight2)\n                    .color(data.map(function(d,i) {\n                        return d.color || color(d, i);\n                    }).filter(function(d,i) { return !data[i].disabled; }));\n    \n                g.select('.nv-context')\n                    .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')')\n                    .style('display', focusEnable ? 'initial' : 'none')\n                ;\n    \n                var contextLinesWrap = g.select('.nv-context .nv-linesWrap')\n                    .datum(data.filter(function(d) { return !d.disabled; }))\n                    ;\n                    \n                d3.transition(contextLinesWrap).call(lines2);\n                \n            \n                // Setup Brush\n                brush\n                    .x(x2)\n                    .on('brush', function() {\n                        onBrush();\n                    });\n    \n                if (brushExtent) brush.extent(brushExtent);\n    \n                var brushBG = g.select('.nv-brushBackground').selectAll('g')\n                    .data([brushExtent || brush.extent()]);\n        \n                var brushBGenter = brushBG.enter()\n                    .append('g');\n    \n                brushBGenter.append('rect')\n                    .attr('class', 'left')\n                    .attr('x', 0)\n                    .attr('y', 0)\n                    .attr('height', availableHeight2);\n    \n                brushBGenter.append('rect')\n                    .attr('class', 'right')\n                    .attr('x', 0)\n                    .attr('y', 0)\n                    .attr('height', availableHeight2);\n    \n                var gBrush = g.select('.nv-x.nv-brush')\n                    .call(brush);\n                gBrush.selectAll('rect')\n                    .attr('height', availableHeight2);\n                gBrush.selectAll('.resize').append('path').attr('d', resizePath);\n    \n                onBrush();\n    \n                g.select('.nv-context .nv-background rect')\n                    .attr('width', availableWidth)\n                    .attr('height', availableHeight2);\n    \n                // Setup Secondary (Context) Axes\n                if (focusShowAxisX) {\n                  x2Axis\n                      .scale(x2)\n                      ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                      .tickSize(-availableHeight2, 0);\n      \n                  g.select('.nv-context .nv-x.nv-axis')\n                      .attr('transform', 'translate(0,' + y2.range()[0] + ')');\n                  d3.transition(g.select('.nv-context .nv-x.nv-axis'))\n                      .call(x2Axis);\n                }\n    \n                if (focusShowAxisY) {\n                  y2Axis\n                      .scale(y2)\n                      ._ticks( nv.utils.calcTicksY(availableHeight2/36, data) )\n                      .tickSize( -availableWidth, 0);\n      \n                  d3.transition(g.select('.nv-context .nv-y.nv-axis'))\n                      .call(y2Axis);\n                }\n                \n                g.select('.nv-context .nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y2.range()[0] + ')');\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                lines.clearHighlights();\n                var singlePoint, pointIndex, pointXLocation, allData = [];\n                data\n                    .filter(function(series, i) {\n                        series.seriesIndex = i;\n                        return !series.disabled && !series.disableTooltip;\n                    })\n                    .forEach(function(series,i) {\n                        var extent = focusEnable ? (brush.empty() ? x2.domain() : brush.extent()) : x.domain();\n                        var currentValues = series.values.filter(function(d,i) {\n                            return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n                        });\n\n                        pointIndex = nv.interactiveBisect(currentValues, e.pointXValue, lines.x());\n                        var point = currentValues[pointIndex];\n                        var pointYValue = chart.y()(point, pointIndex);\n                        if (pointYValue !== null) {\n                            lines.highlightPoint(series.seriesIndex, pointIndex, true);\n                        }\n                        if (point === undefined) return;\n                        if (singlePoint === undefined) singlePoint = point;\n                        if (pointXLocation === undefined) pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n                        allData.push({\n                            key: series.key,\n                            value: pointYValue,\n                            color: color(series,series.seriesIndex),\n                            data: point\n                        });\n                    });\n                //Highlight the tooltip entry based on which point the mouse is closest to.\n                if (allData.length > 2) {\n                    var yValue = chart.yScale().invert(e.mouseY);\n                    var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]);\n                    var threshold = 0.03 * domainExtent;\n                    var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value;}),yValue,threshold);\n                    if (indexToHighlight !== null)\n                        allData[indexToHighlight].highlight = true;\n                }\n\n                interactiveLayer.tooltip\n                    .chartContainer(chart.container.parentNode)\n                    .valueFormatter(function(d,i) {\n                        return d === null ? \"N/A\" : yAxis.tickFormat()(d);\n                    })\n                    .data({\n                        value: chart.x()( singlePoint,pointIndex ),\n                        index: pointIndex,\n                        series: allData\n                    })();\n\n                interactiveLayer.renderGuideLine(pointXLocation);\n\n            });\n\n            interactiveLayer.dispatch.on('elementClick', function(e) {\n                var pointXLocation, allData = [];\n\n                data.filter(function(series, i) {\n                    series.seriesIndex = i;\n                    return !series.disabled;\n                }).forEach(function(series) {\n                    var pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n                    var point = series.values[pointIndex];\n                    if (typeof point === 'undefined') return;\n                    if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n                    var yPos = chart.yScale()(chart.y()(point,pointIndex));\n                    allData.push({\n                        point: point,\n                        pointIndex: pointIndex,\n                        pos: [pointXLocation, yPos],\n                        seriesIndex: series.seriesIndex,\n                        series: series\n                    });\n                });\n\n                lines.dispatch.elementClick(allData);\n            });\n\n            interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                lines.clearHighlights();\n            });\n\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n\n                    state.disabled = e.disabled;\n                }\n\n                chart.update();\n            });\n\n            //============================================================\n            // Functions\n            //------------------------------------------------------------\n    \n            // Taken from crossfilter (http://square.github.com/crossfilter/)\n            function resizePath(d) {\n                var e = +(d == 'e'),\n                    x = e ? 1 : -1,\n                    y = availableHeight2 / 3;\n                return 'M' + (0.5 * x) + ',' + y\n                    + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6)\n                    + 'V' + (2 * y - 6)\n                    + 'A6,6 0 0 ' + e + ' ' + (0.5 * x) + ',' + (2 * y)\n                    + 'Z'\n                    + 'M' + (2.5 * x) + ',' + (y + 8)\n                    + 'V' + (2 * y - 8)\n                    + 'M' + (4.5 * x) + ',' + (y + 8)\n                    + 'V' + (2 * y - 8);\n            }\n    \n    \n            function updateBrushBG() {\n                if (!brush.empty()) brush.extent(brushExtent);\n                brushBG\n                    .data([brush.empty() ? x2.domain() : brushExtent])\n                    .each(function(d,i) {\n                        var leftWidth = x2(d[0]) - x.range()[0],\n                            rightWidth = availableWidth - x2(d[1]);\n                        d3.select(this).select('.left')\n                            .attr('width',  leftWidth < 0 ? 0 : leftWidth);\n    \n                        d3.select(this).select('.right')\n                            .attr('x', x2(d[1]))\n                            .attr('width', rightWidth < 0 ? 0 : rightWidth);\n                    });\n            }\n    \n    \n            function onBrush() {\n                brushExtent = brush.empty() ? null : brush.extent();\n                var extent = brush.empty() ? x2.domain() : brush.extent();\n    \n                //The brush extent cannot be less than one.  If it is, don't update the line chart.\n                if (Math.abs(extent[0] - extent[1]) <= 1) {\n                    return;\n                }\n    \n                dispatch.brush({extent: extent, brush: brush});\n    \n    \n                updateBrushBG();\n    \n                // Update Main (Focus)\n                var focusLinesWrap = g.select('.nv-focus .nv-linesWrap')\n                    .datum(\n                    data\n                        .filter(function(d) { return !d.disabled; })\n                        .map(function(d,i) {\n                            return {\n                                key: d.key,\n                                area: d.area,\n                                classed: d.classed,\n                                values: d.values.filter(function(d,i) {\n                                    return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n                                }),\n                                disableTooltip: d.disableTooltip\n                            };\n                        })\n                );\n                focusLinesWrap.transition().duration(duration).call(lines);\n    \n    \n                // Update Main (Focus) Axes\n                updateXAxis();\n                updateYAxis();\n            }\n\n\n        });\n\n        renderWatch.renderEnd('lineChart immediate');\n        return chart;\n    }\n\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n        if(!evt.series.disableTooltip){\n            tooltip.data(evt).hidden(false);\n        }\n    });\n\n    lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.lines = lines;\n    chart.lines2 = lines2;\n    chart.legend = legend;\n    chart.xAxis = xAxis;\n    chart.x2Axis = x2Axis;\n    chart.yAxis = yAxis;\n    chart.y2Axis = y2Axis;\n    chart.interactiveLayer = interactiveLayer;\n    chart.tooltip = tooltip;\n    chart.state = state;\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showXAxis:      {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:    {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        focusEnable:    {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}},\n        focusHeight:     {get: function(){return height2;}, set: function(_){focusHeight=_;}},\n        focusShowAxisX:    {get: function(){return focusShowAxisX;}, set: function(_){focusShowAxisX=_;}},\n        focusShowAxisY:    {get: function(){return focusShowAxisY;}, set: function(_){focusShowAxisY=_;}},\n        brushExtent: {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            lines.duration(duration);\n            xAxis.duration(duration);\n            x2Axis.duration(duration);\n            yAxis.duration(duration);\n            y2Axis.duration(duration);\n        }},\n        focusMargin: {get: function(){return margin2;}, set: function(_){\n            margin2.top    = _.top    !== undefined ? _.top    : margin2.top;\n            margin2.right  = _.right  !== undefined ? _.right  : margin2.right;\n            margin2.bottom = _.bottom !== undefined ? _.bottom : margin2.bottom;\n            margin2.left   = _.left   !== undefined ? _.left   : margin2.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n            lines.color(color);\n        }},\n        interpolate: {get: function(){return lines.interpolate();}, set: function(_){\n            lines.interpolate(_);\n            lines2.interpolate(_);\n        }},\n        xTickFormat: {get: function(){return xAxis.tickFormat();}, set: function(_){\n            xAxis.tickFormat(_);\n            x2Axis.tickFormat(_);\n        }},\n        yTickFormat: {get: function(){return yAxis.tickFormat();}, set: function(_){\n            yAxis.tickFormat(_);\n            y2Axis.tickFormat(_);\n        }},\n        x: {get: function(){return lines.x();}, set: function(_){\n            lines.x(_);\n            lines2.x(_);\n        }},\n        y: {get: function(){return lines.y();}, set: function(_){\n            lines.y(_);\n            lines2.y(_);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n        }},\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = _;\n            if (useInteractiveGuideline) {\n                lines.interactive(false);\n                lines.useVoronoi(false);\n            }\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, lines);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.lineWithFocusChart = function() {\n  return nv.models.lineChart()\n    .margin({ bottom: 30 }) \n    .focusEnable( true );\n};\nnv.models.linePlusBarChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var lines = nv.models.line()\n        , lines2 = nv.models.line()\n        , bars = nv.models.historicalBar()\n        , bars2 = nv.models.historicalBar()\n        , xAxis = nv.models.axis()\n        , x2Axis = nv.models.axis()\n        , y1Axis = nv.models.axis()\n        , y2Axis = nv.models.axis()\n        , y3Axis = nv.models.axis()\n        , y4Axis = nv.models.axis()\n        , legend = nv.models.legend()\n        , brush = d3.svg.brush()\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 30, right: 30, bottom: 30, left: 60}\n        , margin2 = {top: 0, right: 30, bottom: 20, left: 60}\n        , width = null\n        , height = null\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , color = nv.utils.defaultColor()\n        , showLegend = true\n        , focusEnable = true\n        , focusShowAxisY = false\n        , focusShowAxisX = true\n        , focusHeight = 50\n        , extent\n        , brushExtent = null\n        , x\n        , x2\n        , y1\n        , y2\n        , y3\n        , y4\n        , noData = null\n        , dispatch = d3.dispatch('brush', 'stateChange', 'changeState')\n        , transitionDuration = 0\n        , state = nv.utils.state()\n        , defaultState = null\n        , legendLeftAxisHint = ' (left axis)'\n        , legendRightAxisHint = ' (right axis)'\n        , switchYAxisOrder = false\n        ;\n\n    lines.clipEdge(true);\n    lines2.interactive(false);\n    // We don't want any points emitted for the focus chart's scatter graph.\n    lines2.pointActive(function(d) { return false });\n    xAxis.orient('bottom').tickPadding(5);\n    y1Axis.orient('left');\n    y2Axis.orient('right');\n    x2Axis.orient('bottom').tickPadding(5);\n    y3Axis.orient('left');\n    y4Axis.orient('right');\n\n    tooltip.headerEnabled(true).headerFormatter(function(d, i) {\n        return xAxis.tickFormat()(d, i);\n    });\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var getBarsAxis = function() {\n        return switchYAxisOrder\n            ? { main: y1Axis, focus: y3Axis }\n            : { main: y2Axis, focus: y4Axis }\n    }\n\n    var getLinesAxis = function() {\n        return switchYAxisOrder\n            ? { main: y2Axis, focus: y4Axis }\n            : { main: y1Axis, focus: y3Axis }\n    }\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled })\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    var allDisabled = function(data) {\n      return data.every(function(series) {\n        return series.disabled;\n      });\n    }\n\n    function chart(selection) {\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight1 = nv.utils.availableHeight(height, container, margin)\n                    - (focusEnable ? focusHeight : 0),\n                availableHeight2 = focusHeight - margin2.top - margin2.bottom;\n\n            chart.update = function() { container.transition().duration(transitionDuration).call(chart); };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disableddisabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            var dataBars = data.filter(function(d) { return !d.disabled && d.bar });\n            var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240\n\n            x = bars.xScale();\n            x2 = x2Axis.scale();\n\n            // select the scales and series based on the position of the yAxis\n            y1 = switchYAxisOrder ? lines.yScale() : bars.yScale();\n            y2 = switchYAxisOrder ? bars.yScale() : lines.yScale();\n            y3 = switchYAxisOrder ? lines2.yScale() : bars2.yScale();\n            y4 = switchYAxisOrder ? bars2.yScale() : lines2.yScale();\n\n            var series1 = data\n                .filter(function(d) { return !d.disabled && (switchYAxisOrder ? !d.bar : d.bar) })\n                .map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d,i), y: getY(d,i) }\n                    })\n                });\n\n            var series2 = data\n                .filter(function(d) { return !d.disabled && (switchYAxisOrder ? d.bar : !d.bar) })\n                .map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d,i), y: getY(d,i) }\n                    })\n                });\n\n            x.range([0, availableWidth]);\n\n            x2  .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } ))\n                .range([0, availableWidth]);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n\n            // this is the main chart\n            var focusEnter = gEnter.append('g').attr('class', 'nv-focus');\n            focusEnter.append('g').attr('class', 'nv-x nv-axis');\n            focusEnter.append('g').attr('class', 'nv-y1 nv-axis');\n            focusEnter.append('g').attr('class', 'nv-y2 nv-axis');\n            focusEnter.append('g').attr('class', 'nv-barsWrap');\n            focusEnter.append('g').attr('class', 'nv-linesWrap');\n\n            // context chart is where you can focus in\n            var contextEnter = gEnter.append('g').attr('class', 'nv-context');\n            contextEnter.append('g').attr('class', 'nv-x nv-axis');\n            contextEnter.append('g').attr('class', 'nv-y1 nv-axis');\n            contextEnter.append('g').attr('class', 'nv-y2 nv-axis');\n            contextEnter.append('g').attr('class', 'nv-barsWrap');\n            contextEnter.append('g').attr('class', 'nv-linesWrap');\n            contextEnter.append('g').attr('class', 'nv-brushBackground');\n            contextEnter.append('g').attr('class', 'nv-x nv-brush');\n\n            //============================================================\n            // Legend\n            //------------------------------------------------------------\n\n            if (showLegend) {\n                var legendWidth = legend.align() ? availableWidth / 2 : availableWidth;\n                var legendXPosition = legend.align() ? legendWidth : 0;\n\n                legend.width(legendWidth);\n\n                g.select('.nv-legendWrap')\n                    .datum(data.map(function(series) {\n                        series.originalKey = series.originalKey === undefined ? series.key : series.originalKey;\n                        if(switchYAxisOrder) {\n                            series.key = series.originalKey + (series.bar ? legendRightAxisHint : legendLeftAxisHint);\n                        } else {\n                            series.key = series.originalKey + (series.bar ? legendLeftAxisHint : legendRightAxisHint);\n                        }\n                        return series;\n                    }))\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    // FIXME: shouldn't this be \"- (focusEnabled ? focusHeight : 0)\"?\n                    availableHeight1 = nv.utils.availableHeight(height, container, margin) - focusHeight;\n                }\n\n                g.select('.nv-legendWrap')\n                    .attr('transform', 'translate(' + legendXPosition + ',' + (-margin.top) +')');\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            //============================================================\n            // Context chart (focus chart) components\n            //------------------------------------------------------------\n\n            // hide or show the focus context chart\n            g.select('.nv-context').style('display', focusEnable ? 'initial' : 'none');\n\n            bars2\n                .width(availableWidth)\n                .height(availableHeight2)\n                .color(data.map(function (d, i) {\n                    return d.color || color(d, i);\n                }).filter(function (d, i) {\n                    return !data[i].disabled && data[i].bar\n                }));\n            lines2\n                .width(availableWidth)\n                .height(availableHeight2)\n                .color(data.map(function (d, i) {\n                    return d.color || color(d, i);\n                }).filter(function (d, i) {\n                    return !data[i].disabled && !data[i].bar\n                }));\n\n            var bars2Wrap = g.select('.nv-context .nv-barsWrap')\n                .datum(dataBars.length ? dataBars : [\n                    {values: []}\n                ]);\n            var lines2Wrap = g.select('.nv-context .nv-linesWrap')\n                .datum(allDisabled(dataLines) ?\n                       [{values: []}] :\n                       dataLines.filter(function(dataLine) {\n                         return !dataLine.disabled;\n                       }));\n\n            g.select('.nv-context')\n                .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')');\n\n            bars2Wrap.transition().call(bars2);\n            lines2Wrap.transition().call(lines2);\n\n            // context (focus chart) axis controls\n            if (focusShowAxisX) {\n                x2Axis\n                    ._ticks( nv.utils.calcTicksX(availableWidth / 100, data))\n                    .tickSize(-availableHeight2, 0);\n                g.select('.nv-context .nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y3.range()[0] + ')');\n                g.select('.nv-context .nv-x.nv-axis').transition()\n                    .call(x2Axis);\n            }\n\n            if (focusShowAxisY) {\n                y3Axis\n                    .scale(y3)\n                    ._ticks( availableHeight2 / 36 )\n                    .tickSize( -availableWidth, 0);\n                y4Axis\n                    .scale(y4)\n                    ._ticks( availableHeight2 / 36 )\n                    .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none\n\n                g.select('.nv-context .nv-y3.nv-axis')\n                    .style('opacity', dataBars.length ? 1 : 0)\n                    .attr('transform', 'translate(0,' + x2.range()[0] + ')');\n                g.select('.nv-context .nv-y2.nv-axis')\n                    .style('opacity', dataLines.length ? 1 : 0)\n                    .attr('transform', 'translate(' + x2.range()[1] + ',0)');\n\n                g.select('.nv-context .nv-y1.nv-axis').transition()\n                    .call(y3Axis);\n                g.select('.nv-context .nv-y2.nv-axis').transition()\n                    .call(y4Axis);\n            }\n\n            // Setup Brush\n            brush.x(x2).on('brush', onBrush);\n\n            if (brushExtent) brush.extent(brushExtent);\n\n            var brushBG = g.select('.nv-brushBackground').selectAll('g')\n                .data([brushExtent || brush.extent()]);\n\n            var brushBGenter = brushBG.enter()\n                .append('g');\n\n            brushBGenter.append('rect')\n                .attr('class', 'left')\n                .attr('x', 0)\n                .attr('y', 0)\n                .attr('height', availableHeight2);\n\n            brushBGenter.append('rect')\n                .attr('class', 'right')\n                .attr('x', 0)\n                .attr('y', 0)\n                .attr('height', availableHeight2);\n\n            var gBrush = g.select('.nv-x.nv-brush')\n                .call(brush);\n            gBrush.selectAll('rect')\n                //.attr('y', -5)\n                .attr('height', availableHeight2);\n            gBrush.selectAll('.resize').append('path').attr('d', resizePath);\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n                    state.disabled = e.disabled;\n                }\n                chart.update();\n            });\n\n            //============================================================\n            // Functions\n            //------------------------------------------------------------\n\n            // Taken from crossfilter (http://square.github.com/crossfilter/)\n            function resizePath(d) {\n                var e = +(d == 'e'),\n                    x = e ? 1 : -1,\n                    y = availableHeight2 / 3;\n                return 'M' + (.5 * x) + ',' + y\n                    + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6)\n                    + 'V' + (2 * y - 6)\n                    + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y)\n                    + 'Z'\n                    + 'M' + (2.5 * x) + ',' + (y + 8)\n                    + 'V' + (2 * y - 8)\n                    + 'M' + (4.5 * x) + ',' + (y + 8)\n                    + 'V' + (2 * y - 8);\n            }\n\n\n            function updateBrushBG() {\n                if (!brush.empty()) brush.extent(brushExtent);\n                brushBG\n                    .data([brush.empty() ? x2.domain() : brushExtent])\n                    .each(function(d,i) {\n                        var leftWidth = x2(d[0]) - x2.range()[0],\n                            rightWidth = x2.range()[1] - x2(d[1]);\n                        d3.select(this).select('.left')\n                            .attr('width',  leftWidth < 0 ? 0 : leftWidth);\n\n                        d3.select(this).select('.right')\n                            .attr('x', x2(d[1]))\n                            .attr('width', rightWidth < 0 ? 0 : rightWidth);\n                    });\n            }\n\n            function onBrush() {\n                brushExtent = brush.empty() ? null : brush.extent();\n                extent = brush.empty() ? x2.domain() : brush.extent();\n                dispatch.brush({extent: extent, brush: brush});\n                updateBrushBG();\n\n                // Prepare Main (Focus) Bars and Lines\n                bars\n                    .width(availableWidth)\n                    .height(availableHeight1)\n                    .color(data.map(function(d,i) {\n                        return d.color || color(d, i);\n                    }).filter(function(d,i) { return !data[i].disabled && data[i].bar }));\n\n                lines\n                    .width(availableWidth)\n                    .height(availableHeight1)\n                    .color(data.map(function(d,i) {\n                        return d.color || color(d, i);\n                    }).filter(function(d,i) { return !data[i].disabled && !data[i].bar }));\n\n                var focusBarsWrap = g.select('.nv-focus .nv-barsWrap')\n                    .datum(!dataBars.length ? [{values:[]}] :\n                        dataBars\n                            .map(function(d,i) {\n                                return {\n                                    key: d.key,\n                                    values: d.values.filter(function(d,i) {\n                                        return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1];\n                                    })\n                                }\n                            })\n                );\n\n                var focusLinesWrap = g.select('.nv-focus .nv-linesWrap')\n                    .datum(allDisabled(dataLines) ? [{values:[]}] :\n                           dataLines\n                           .filter(function(dataLine) { return !dataLine.disabled; })\n                           .map(function(d,i) {\n                                return {\n                                    area: d.area,\n                                    fillOpacity: d.fillOpacity,\n                                    key: d.key,\n                                    values: d.values.filter(function(d,i) {\n                                        return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1];\n                                    })\n                                }\n                            })\n                );\n\n                // Update Main (Focus) X Axis\n                if (dataBars.length && !switchYAxisOrder) {\n                    x = bars.xScale();\n                } else {\n                    x = lines.xScale();\n                }\n\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight1, 0);\n\n                xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]);\n\n                g.select('.nv-x.nv-axis').transition().duration(transitionDuration)\n                    .call(xAxis);\n\n                // Update Main (Focus) Bars and Lines\n                focusBarsWrap.transition().duration(transitionDuration).call(bars);\n                focusLinesWrap.transition().duration(transitionDuration).call(lines);\n\n                // Setup and Update Main (Focus) Y Axes\n                g.select('.nv-focus .nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y1.range()[0] + ')');\n\n                y1Axis\n                    .scale(y1)\n                    ._ticks( nv.utils.calcTicksY(availableHeight1/36, data) )\n                    .tickSize(-availableWidth, 0);\n                y2Axis\n                    .scale(y2)\n                    ._ticks( nv.utils.calcTicksY(availableHeight1/36, data) )\n                    .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none\n\n                // Calculate opacity of the axis\n                var barsOpacity = dataBars.length ? 1 : 0;\n                var linesOpacity = dataLines.length && !allDisabled(dataLines) ? 1 : 0;\n\n                var y1Opacity = switchYAxisOrder ? linesOpacity : barsOpacity;\n                var y2Opacity = switchYAxisOrder ? barsOpacity : linesOpacity;\n\n                g.select('.nv-focus .nv-y1.nv-axis')\n                    .style('opacity', y1Opacity);\n                g.select('.nv-focus .nv-y2.nv-axis')\n                    .style('opacity', y2Opacity)\n                    .attr('transform', 'translate(' + x.range()[1] + ',0)');\n\n                g.select('.nv-focus .nv-y1.nv-axis').transition().duration(transitionDuration)\n                    .call(y1Axis);\n                g.select('.nv-focus .nv-y2.nv-axis').transition().duration(transitionDuration)\n                    .call(y2Axis);\n            }\n\n            onBrush();\n\n        });\n\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    lines.dispatch.on('elementMouseover.tooltip', function(evt) {\n        tooltip\n            .duration(100)\n            .valueFormatter(function(d, i) {\n                return getLinesAxis().main.tickFormat()(d, i);\n            })\n            .data(evt)\n            .hidden(false);\n    });\n\n    lines.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true)\n    });\n\n    bars.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt.value = chart.x()(evt.data);\n        evt['series'] = {\n            value: chart.y()(evt.data),\n            color: evt.color\n        };\n        tooltip\n            .duration(0)\n            .valueFormatter(function(d, i) {\n                return getBarsAxis().main.tickFormat()(d, i);\n            })\n            .data(evt)\n            .hidden(false);\n    });\n\n    bars.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    bars.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.legend = legend;\n    chart.lines = lines;\n    chart.lines2 = lines2;\n    chart.bars = bars;\n    chart.bars2 = bars2;\n    chart.xAxis = xAxis;\n    chart.x2Axis = x2Axis;\n    chart.y1Axis = y1Axis;\n    chart.y2Axis = y2Axis;\n    chart.y3Axis = y3Axis;\n    chart.y4Axis = y4Axis;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        brushExtent:    {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n        focusEnable:    {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}},\n        focusHeight:    {get: function(){return focusHeight;}, set: function(_){focusHeight=_;}},\n        focusShowAxisX:    {get: function(){return focusShowAxisX;}, set: function(_){focusShowAxisX=_;}},\n        focusShowAxisY:    {get: function(){return focusShowAxisY;}, set: function(_){focusShowAxisY=_;}},\n        legendLeftAxisHint:    {get: function(){return legendLeftAxisHint;}, set: function(_){legendLeftAxisHint=_;}},\n        legendRightAxisHint:    {get: function(){return legendRightAxisHint;}, set: function(_){legendRightAxisHint=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        focusMargin: {get: function(){return margin2;}, set: function(_){\n            margin2.top    = _.top    !== undefined ? _.top    : margin2.top;\n            margin2.right  = _.right  !== undefined ? _.right  : margin2.right;\n            margin2.bottom = _.bottom !== undefined ? _.bottom : margin2.bottom;\n            margin2.left   = _.left   !== undefined ? _.left   : margin2.left;\n        }},\n        duration: {get: function(){return transitionDuration;}, set: function(_){\n            transitionDuration = _;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n        }},\n        x: {get: function(){return getX;}, set: function(_){\n            getX = _;\n            lines.x(_);\n            lines2.x(_);\n            bars.x(_);\n            bars2.x(_);\n        }},\n        y: {get: function(){return getY;}, set: function(_){\n            getY = _;\n            lines.y(_);\n            lines2.y(_);\n            bars.y(_);\n            bars2.y(_);\n        }},\n        switchYAxisOrder:    {get: function(){return switchYAxisOrder;}, set: function(_){\n            // Switch the tick format for the yAxis\n            if(switchYAxisOrder !== _) {\n                var tickFormat = y1Axis.tickFormat();\n                y1Axis.tickFormat(y2Axis.tickFormat());\n                y2Axis.tickFormat(tickFormat);\n            }\n            switchYAxisOrder=_;\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, lines);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.multiBar = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , x = d3.scale.ordinal()\n        , y = d3.scale.linear()\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n        , clipEdge = true\n        , stacked = false\n        , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function\n        , color = nv.utils.defaultColor()\n        , hideable = false\n        , barColor = null // adding the ability to set the color for each rather than the whole group\n        , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled\n        , duration = 500\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , groupSpacing = 0.1\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0 //used to store previous scales\n        , renderWatch = nv.utils.renderWatch(dispatch, duration)\n        ;\n\n    var last_datalength = 0;\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n            var nonStackableCount = 0;\n            // This function defines the requirements for render complete\n            var endFn = function(d, i) {\n                if (d.series === data.length - 1 && i === data[0].values.length - 1)\n                    return true;\n                return false;\n            };\n\n            if(hideable && data.length) hideable = [{\n                values: data[0].values.map(function(d) {\n                        return {\n                            x: d.x,\n                            y: 0,\n                            series: d.series,\n                            size: 0.01\n                        };}\n                )}];\n\n            if (stacked) {\n                var parsed = d3.layout.stack()\n                    .offset(stackOffset)\n                    .values(function(d){ return d.values })\n                    .y(getY)\n                (!data.length && hideable ? hideable : data);\n\n                parsed.forEach(function(series, i){\n                    // if series is non-stackable, use un-parsed data\n                    if (series.nonStackable) {\n                        data[i].nonStackableSeries = nonStackableCount++;\n                        parsed[i] = data[i];\n                    } else {\n                        // don't stack this seires on top of the nonStackable seriees\n                        if (i > 0 && parsed[i - 1].nonStackable){\n                            parsed[i].values.map(function(d,j){\n                                d.y0 -= parsed[i - 1].values[j].y;\n                                d.y1 = d.y0 + d.y;\n                            });\n                        }\n                    }\n                });\n                data = parsed;\n            }\n            //add series index and key to each data point for reference\n            data.forEach(function(series, i) {\n                series.values.forEach(function(point) {\n                    point.series = i;\n                    point.key = series.key;\n                });\n            });\n\n            // HACK for negative value stacking\n            if (stacked) {\n                data[0].values.map(function(d,i) {\n                    var posBase = 0, negBase = 0;\n                    data.map(function(d, idx) {\n                        if (!data[idx].nonStackable) {\n                            var f = d.values[i]\n                            f.size = Math.abs(f.y);\n                            if (f.y<0)  {\n                                f.y1 = negBase;\n                                negBase = negBase - f.size;\n                            } else\n                            {\n                                f.y1 = f.size + posBase;\n                                posBase = posBase + f.size;\n                            }\n                        }\n\n                    });\n                });\n            }\n            // Setup Scales\n            // remap and flatten the data for use in calculating the scales' domains\n            var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n                data.map(function(d, idx) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1, idx:idx }\n                    })\n                });\n\n            x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n                .rangeBands(xRange || [0, availableWidth], groupSpacing);\n\n            y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) {\n                var domain = d.y;\n                // increase the domain range if this series is stackable\n                if (stacked && !data[d.idx].nonStackable) {\n                    if (d.y > 0){\n                        domain = d.y1\n                    } else {\n                        domain = d.y1 + d.y\n                    }\n                }\n                return domain;\n            }).concat(forceY)))\n            .range(yRange || [availableHeight, 0]);\n\n            // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n            if (x.domain()[0] === x.domain()[1])\n                x.domain()[0] ?\n                    x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n                    : x.domain([-1,1]);\n\n            if (y.domain()[0] === y.domain()[1])\n                y.domain()[0] ?\n                    y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n                    : y.domain([-1,1]);\n\n            x0 = x0 || x;\n            y0 = y0 || y;\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-groups');\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-edge-clip-' + id)\n                .append('rect');\n            wrap.select('#nv-edge-clip-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n            var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n                .data(function(d) { return d }, function(d,i) { return i });\n            groups.enter().append('g')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6);\n\n            var exitTransition = renderWatch\n                .transition(groups.exit().selectAll('rect.nv-bar'), 'multibarExit', Math.min(100, duration))\n                .attr('y', function(d, i, j) {\n                    var yVal = y0(0) || 0;\n                    if (stacked) {\n                        if (data[d.series] && !data[d.series].nonStackable) {\n                            yVal = y0(d.y0);\n                        }\n                    }\n                    return yVal;\n                })\n                .attr('height', 0)\n                .remove();\n            if (exitTransition.delay)\n                exitTransition.delay(function(d,i) {\n                    var delay = i * (duration / (last_datalength + 1)) - i;\n                    return delay;\n                });\n            groups\n                .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n                .classed('hover', function(d) { return d.hover })\n                .style('fill', function(d,i){ return color(d, i) })\n                .style('stroke', function(d,i){ return color(d, i) });\n            groups\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', 0.75);\n\n            var bars = groups.selectAll('rect.nv-bar')\n                .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });\n            bars.exit().remove();\n\n            var barsEnter = bars.enter().append('rect')\n                    .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n                    .attr('x', function(d,i,j) {\n                        return stacked && !data[j].nonStackable ? 0 : (j * x.rangeBand() / data.length )\n                    })\n                    .attr('y', function(d,i,j) { return y0(stacked && !data[j].nonStackable ? d.y0 : 0) || 0 })\n                    .attr('height', 0)\n                    .attr('width', function(d,i,j) { return x.rangeBand() / (stacked && !data[j].nonStackable ? 1 : data.length) })\n                    .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })\n                ;\n            bars\n                .style('fill', function(d,i,j){ return color(d, j, i);  })\n                .style('stroke', function(d,i,j){ return color(d, j, i); })\n                .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('click', function(d,i) {\n                    var element = this;\n                    dispatch.elementClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\"),\n                        event: d3.event,\n                        element: element\n                    });\n                    d3.event.stopPropagation();\n                })\n                .on('dblclick', function(d,i) {\n                    dispatch.elementDblClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                });\n            bars\n                .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n                .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })\n\n            if (barColor) {\n                if (!disabled) disabled = data.map(function() { return true });\n                bars\n                    .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(  disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i]  })[j]   ).toString(); })\n                    .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(  disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i]  })[j]   ).toString(); });\n            }\n\n            var barSelection =\n                bars.watchTransition(renderWatch, 'multibar', Math.min(250, duration))\n                    .delay(function(d,i) {\n                        return i * duration / data[0].values.length;\n                    });\n            if (stacked){\n                barSelection\n                    .attr('y', function(d,i,j) {\n                        var yVal = 0;\n                        // if stackable, stack it on top of the previous series\n                        if (!data[j].nonStackable) {\n                            yVal = y(d.y1);\n                        } else {\n                            if (getY(d,i) < 0){\n                                yVal = y(0);\n                            } else {\n                                if (y(0) - y(getY(d,i)) < -1){\n                                    yVal = y(0) - 1;\n                                } else {\n                                    yVal = y(getY(d, i)) || 0;\n                                }\n                            }\n                        }\n                        return yVal;\n                    })\n                    .attr('height', function(d,i,j) {\n                        if (!data[j].nonStackable) {\n                            return Math.max(Math.abs(y(d.y+d.y0) - y(d.y0)), 0);\n                        } else {\n                            return Math.max(Math.abs(y(getY(d,i)) - y(0)), 0) || 0;\n                        }\n                    })\n                    .attr('x', function(d,i,j) {\n                        var width = 0;\n                        if (data[j].nonStackable) {\n                            width = d.series * x.rangeBand() / data.length;\n                            if (data.length !== nonStackableCount){\n                                width = data[j].nonStackableSeries * x.rangeBand()/(nonStackableCount*2);\n                            }\n                        }\n                        return width;\n                    })\n                    .attr('width', function(d,i,j){\n                        if (!data[j].nonStackable) {\n                            return x.rangeBand();\n                        } else {\n                            // if all series are nonStacable, take the full width\n                            var width = (x.rangeBand() / nonStackableCount);\n                            // otherwise, nonStackable graph will be only taking the half-width\n                            // of the x rangeBand\n                            if (data.length !== nonStackableCount) {\n                                width = x.rangeBand()/(nonStackableCount*2);\n                            }\n                            return width;\n                        }\n                    });\n            }\n            else {\n                barSelection\n                    .attr('x', function(d,i) {\n                        return d.series * x.rangeBand() / data.length;\n                    })\n                    .attr('width', x.rangeBand() / data.length)\n                    .attr('y', function(d,i) {\n                        return getY(d,i) < 0 ?\n                            y(0) :\n                                y(0) - y(getY(d,i)) < 1 ?\n                            y(0) - 1 :\n                            y(getY(d,i)) || 0;\n                    })\n                    .attr('height', function(d,i) {\n                        return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0;\n                    });\n            }\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n\n            // keep track of the last data value length for transition calculations\n            if (data[0] && data[0].values) {\n                last_datalength = data[0].values.length;\n            }\n\n        });\n\n        renderWatch.renderEnd('multibar immediate');\n\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:   {get: function(){return width;}, set: function(_){width=_;}},\n        height:  {get: function(){return height;}, set: function(_){height=_;}},\n        x:       {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:       {get: function(){return getY;}, set: function(_){getY=_;}},\n        xScale:  {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:  {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:  {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:  {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        forceY:  {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}},\n        stackOffset: {get: function(){return stackOffset;}, set: function(_){stackOffset=_;}},\n        clipEdge:    {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        disabled:    {get: function(){return disabled;}, set: function(_){disabled=_;}},\n        id:          {get: function(){return id;}, set: function(_){id=_;}},\n        hideable:    {get: function(){return hideable;}, set: function(_){hideable=_;}},\n        groupSpacing:{get: function(){return groupSpacing;}, set: function(_){groupSpacing=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        barColor:  {get: function(){return barColor;}, set: function(_){\n            barColor = _ ? nv.utils.getColor(_) : null;\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};nv.models.multiBarChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var multibar = nv.models.multiBar()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , interactiveLayer = nv.interactiveGuideline()\n        , legend = nv.models.legend()\n        , controls = nv.models.legend()\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 30, right: 20, bottom: 50, left: 60}\n        , width = null\n        , height = null\n        , color = nv.utils.defaultColor()\n        , showControls = true\n        , controlLabels = {}\n        , showLegend = true\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , reduceXTicks = true // if false a tick will show for every data point\n        , staggerLabels = false\n        , wrapLabels = false\n        , rotateLabels = 0\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n        , controlWidth = function() { return showControls ? 180 : 0 }\n        , duration = 250\n        , useInteractiveGuideline = false\n        ;\n\n    state.stacked = false // DEPRECATED Maintained for backward compatibility\n\n    multibar.stacked(false);\n    xAxis\n        .orient('bottom')\n        .tickPadding(7)\n        .showMaxMin(false)\n        .tickFormat(function(d) { return d })\n    ;\n    yAxis\n        .orient((rightAlignYAxis) ? 'right' : 'left')\n        .tickFormat(d3.format(',.1f'))\n    ;\n\n    tooltip\n        .duration(0)\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        })\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        });\n\n    controls.updateState(false);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n    var stacked = false;\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled }),\n                stacked: stacked\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.stacked !== undefined)\n                stacked = state.stacked;\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(multibar);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() {\n                if (duration === 0)\n                    container.call(chart);\n                else\n                    container.transition()\n                        .duration(duration)\n                        .call(chart);\n            };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disableddisabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display noData message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = multibar.xScale();\n            y = multibar.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis');\n            gEnter.append('g').attr('class', 'nv-barsWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n            gEnter.append('g').attr('class', 'nv-controlsWrap');\n            gEnter.append('g').attr('class', 'nv-interactive');\n\n            // Legend\n            if (showLegend) {\n                legend.width(availableWidth - controlWidth());\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.nv-legendWrap')\n                    .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')');\n            }\n\n            // Controls\n            if (showControls) {\n                var controlsData = [\n                    { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() },\n                    { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() }\n                ];\n\n                controls.width(controlWidth()).color(['#444', '#444', '#444']);\n                g.select('.nv-controlsWrap')\n                    .datum(controlsData)\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n                    .call(controls);\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            // Main Chart Component(s)\n            multibar\n                .disabled(data.map(function(series) { return series.disabled }))\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(data.map(function(d,i) {\n                    return d.color || color(d, i);\n                }).filter(function(d,i) { return !data[i].disabled }));\n\n\n            var barsWrap = g.select('.nv-barsWrap')\n                .datum(data.filter(function(d) { return !d.disabled }));\n\n            barsWrap.call(multibar);\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize(-availableHeight, 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y.range()[0] + ')');\n                g.select('.nv-x.nv-axis')\n                    .call(xAxis);\n\n                var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g');\n\n                xTicks\n                    .selectAll('line, text')\n                    .style('opacity', 1)\n\n                if (staggerLabels) {\n                    var getTranslate = function(x,y) {\n                        return \"translate(\" + x + \",\" + y + \")\";\n                    };\n\n                    var staggerUp = 5, staggerDown = 17;  //pixels to stagger by\n                    // Issue #140\n                    xTicks\n                        .selectAll(\"text\")\n                        .attr('transform', function(d,i,j) {\n                            return  getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown));\n                        });\n\n                    var totalInBetweenTicks = d3.selectAll(\".nv-x.nv-axis .nv-wrap g g text\")[0].length;\n                    g.selectAll(\".nv-x.nv-axis .nv-axisMaxMin text\")\n                        .attr(\"transform\", function(d,i) {\n                            return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp);\n                        });\n                }\n\n                if (wrapLabels) {\n                    g.selectAll('.tick text')\n                        .call(nv.utils.wrapTicks, chart.xAxis.rangeBand())\n                }\n\n                if (reduceXTicks)\n                    xTicks\n                        .filter(function(d,i) {\n                            return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0;\n                        })\n                        .selectAll('text, line')\n                        .style('opacity', 0);\n\n                if(rotateLabels)\n                    xTicks\n                        .selectAll('.tick text')\n                        .attr('transform', 'rotate(' + rotateLabels + ' 0,0)')\n                        .style('text-anchor', rotateLabels > 0 ? 'start' : 'end');\n\n                g.select('.nv-x.nv-axis').selectAll('g.nv-axisMaxMin text')\n                    .style('opacity', 1);\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis')\n                    .call(yAxis);\n            }\n\n            //Set up interactive layer\n            if (useInteractiveGuideline) {\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .margin({left:margin.left, top:margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            controls.dispatch.on('legendClick', function(d,i) {\n                if (!d.disabled) return;\n                controlsData = controlsData.map(function(s) {\n                    s.disabled = true;\n                    return s;\n                });\n                d.disabled = false;\n\n                switch (d.key) {\n                    case 'Grouped':\n                    case controlLabels.grouped:\n                        multibar.stacked(false);\n                        break;\n                    case 'Stacked':\n                    case controlLabels.stacked:\n                        multibar.stacked(true);\n                        break;\n                }\n\n                state.stacked = multibar.stacked();\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n                    state.disabled = e.disabled;\n                }\n                if (typeof e.stacked !== 'undefined') {\n                    multibar.stacked(e.stacked);\n                    state.stacked = e.stacked;\n                    stacked = e.stacked;\n                }\n                chart.update();\n            });\n\n            if (useInteractiveGuideline) {\n                interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                    if (e.pointXValue == undefined) return;\n\n                    var singlePoint, pointIndex, pointXLocation, xValue, allData = [];\n                    data\n                        .filter(function(series, i) {\n                            series.seriesIndex = i;\n                            return !series.disabled;\n                        })\n                        .forEach(function(series,i) {\n                            pointIndex = x.domain().indexOf(e.pointXValue)\n\n                            var point = series.values[pointIndex];\n                            if (point === undefined) return;\n\n                            xValue = point.x;\n                            if (singlePoint === undefined) singlePoint = point;\n                            if (pointXLocation === undefined) pointXLocation = e.mouseX\n                            allData.push({\n                                key: series.key,\n                                value: chart.y()(point, pointIndex),\n                                color: color(series,series.seriesIndex),\n                                data: series.values[pointIndex]\n                            });\n                        });\n\n                    interactiveLayer.tooltip\n                        .chartContainer(that.parentNode)\n                        .data({\n                            value: xValue,\n                            index: pointIndex,\n                            series: allData\n                        })();\n\n                    interactiveLayer.renderGuideLine(pointXLocation);\n                });\n\n                interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                    interactiveLayer.tooltip.hidden(true);\n                });\n            }\n            else {\n                multibar.dispatch.on('elementMouseover.tooltip', function(evt) {\n                    evt.value = chart.x()(evt.data);\n                    evt['series'] = {\n                        key: evt.data.key,\n                        value: chart.y()(evt.data),\n                        color: evt.color\n                    };\n                    tooltip.data(evt).hidden(false);\n                });\n\n                multibar.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true);\n                });\n\n                multibar.dispatch.on('elementMousemove.tooltip', function(evt) {\n                    tooltip();\n                });\n            }\n        });\n\n        renderWatch.renderEnd('multibarchart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.multibar = multibar;\n    chart.legend = legend;\n    chart.controls = controls;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.state = state;\n    chart.tooltip = tooltip;\n    chart.interactiveLayer = interactiveLayer;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n        controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n        showXAxis:      {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:    {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n        reduceXTicks:    {get: function(){return reduceXTicks;}, set: function(_){reduceXTicks=_;}},\n        rotateLabels:    {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}},\n        staggerLabels:    {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}},\n        wrapLabels:   {get: function(){return wrapLabels;}, set: function(_){wrapLabels=!!_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            multibar.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n            renderWatch.reset(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n        }},\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = _;\n        }},\n        barColor:  {get: function(){return multibar.barColor;}, set: function(_){\n            multibar.barColor(_);\n            legend.color(function(d,i) {return d3.rgb('#ccc').darker(i * 1.5).toString();})\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, multibar);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.multiBarHorizontal = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , x = d3.scale.ordinal()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , getYerr = function(d) { return d.yErr }\n        , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove\n        , color = nv.utils.defaultColor()\n        , barColor = null // adding the ability to set the color for each rather than the whole group\n        , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled\n        , stacked = false\n        , showValues = false\n        , showBarLabels = false\n        , valuePadding = 60\n        , groupSpacing = 0.1\n        , valueFormat = d3.format(',.2f')\n        , delay = 1200\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , duration = 250\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0; //used to store previous scales\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            if (stacked)\n                data = d3.layout.stack()\n                    .offset('zero')\n                    .values(function(d){ return d.values })\n                    .y(getY)\n                (data);\n\n            //add series index and key to each data point for reference\n            data.forEach(function(series, i) {\n                series.values.forEach(function(point) {\n                    point.series = i;\n                    point.key = series.key;\n                });\n            });\n\n            // HACK for negative value stacking\n            if (stacked)\n                data[0].values.map(function(d,i) {\n                    var posBase = 0, negBase = 0;\n                    data.map(function(d) {\n                        var f = d.values[i]\n                        f.size = Math.abs(f.y);\n                        if (f.y<0)  {\n                            f.y1 = negBase - f.size;\n                            negBase = negBase - f.size;\n                        } else\n                        {\n                            f.y1 = posBase;\n                            posBase = posBase + f.size;\n                        }\n                    });\n                });\n\n            // Setup Scales\n            // remap and flatten the data for use in calculating the scales' domains\n            var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate\n                data.map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 }\n                    })\n                });\n\n            x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))\n                .rangeBands(xRange || [0, availableHeight], groupSpacing);\n\n            y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 + d.y : d.y1 ) : d.y }).concat(forceY)))\n\n            if (showValues && !stacked)\n                y.range(yRange || [(y.domain()[0] < 0 ? valuePadding : 0), availableWidth - (y.domain()[1] > 0 ? valuePadding : 0) ]);\n            else\n                y.range(yRange || [0, availableWidth]);\n\n            x0 = x0 || x;\n            y0 = y0 || d3.scale.linear().domain(y.domain()).range([y(0),y(0)]);\n\n            // Setup containers and skeleton of chart\n            var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibarHorizontal').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibarHorizontal');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-groups');\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n                .data(function(d) { return d }, function(d,i) { return i });\n            groups.enter().append('g')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6);\n            groups.exit().watchTransition(renderWatch, 'multibarhorizontal: exit groups')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6)\n                .remove();\n            groups\n                .attr('class', function(d,i) { return 'nv-group nv-series-' + i })\n                .classed('hover', function(d) { return d.hover })\n                .style('fill', function(d,i){ return color(d, i) })\n                .style('stroke', function(d,i){ return color(d, i) });\n            groups.watchTransition(renderWatch, 'multibarhorizontal: groups')\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', .75);\n\n            var bars = groups.selectAll('g.nv-bar')\n                .data(function(d) { return d.values });\n            bars.exit().remove();\n\n            var barsEnter = bars.enter().append('g')\n                .attr('transform', function(d,i,j) {\n                    return 'translate(' + y0(stacked ? d.y0 : 0) + ',' + (stacked ? 0 : (j * x.rangeBand() / data.length ) + x(getX(d,i))) + ')'\n                });\n\n            barsEnter.append('rect')\n                .attr('width', 0)\n                .attr('height', x.rangeBand() / (stacked ? 1 : data.length) )\n\n            bars\n                .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here\n                    d3.select(this).classed('hover', true);\n                    dispatch.elementMouseover({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.elementMouseout({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    dispatch.elementMouseout({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mousemove', function(d,i) {\n                    dispatch.elementMousemove({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('click', function(d,i) {\n                    dispatch.elementClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                })\n                .on('dblclick', function(d,i) {\n                    dispatch.elementDblClick({\n                        data: d,\n                        index: i,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                    d3.event.stopPropagation();\n                });\n\n            if (getYerr(data[0],0)) {\n                barsEnter.append('polyline');\n\n                bars.select('polyline')\n                    .attr('fill', 'none')\n                    .attr('points', function(d,i) {\n                        var xerr = getYerr(d,i)\n                            , mid = 0.8 * x.rangeBand() / ((stacked ? 1 : data.length) * 2);\n                        xerr = xerr.length ? xerr : [-Math.abs(xerr), Math.abs(xerr)];\n                        xerr = xerr.map(function(e) { return y(e) - y(0); });\n                        var a = [[xerr[0],-mid], [xerr[0],mid], [xerr[0],0], [xerr[1],0], [xerr[1],-mid], [xerr[1],mid]];\n                        return a.map(function (path) { return path.join(',') }).join(' ');\n                    })\n                    .attr('transform', function(d,i) {\n                        var mid = x.rangeBand() / ((stacked ? 1 : data.length) * 2);\n                        return 'translate(' + (getY(d,i) < 0 ? 0 : y(getY(d,i)) - y(0)) + ', ' + mid + ')'\n                    });\n            }\n\n            barsEnter.append('text');\n\n            if (showValues && !stacked) {\n                bars.select('text')\n                    .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'end' : 'start' })\n                    .attr('y', x.rangeBand() / (data.length * 2))\n                    .attr('dy', '.32em')\n                    .text(function(d,i) {\n                        var t = valueFormat(getY(d,i))\n                            , yerr = getYerr(d,i);\n                        if (yerr === undefined)\n                            return t;\n                        if (!yerr.length)\n                            return t + '±' + valueFormat(Math.abs(yerr));\n                        return t + '+' + valueFormat(Math.abs(yerr[1])) + '-' + valueFormat(Math.abs(yerr[0]));\n                    });\n                bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n                    .select('text')\n                    .attr('x', function(d,i) { return getY(d,i) < 0 ? -4 : y(getY(d,i)) - y(0) + 4 })\n            } else {\n                bars.selectAll('text').text('');\n            }\n\n            if (showBarLabels && !stacked) {\n                barsEnter.append('text').classed('nv-bar-label',true);\n                bars.select('text.nv-bar-label')\n                    .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'start' : 'end' })\n                    .attr('y', x.rangeBand() / (data.length * 2))\n                    .attr('dy', '.32em')\n                    .text(function(d,i) { return getX(d,i) });\n                bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n                    .select('text.nv-bar-label')\n                    .attr('x', function(d,i) { return getY(d,i) < 0 ? y(0) - y(getY(d,i)) + 4 : -4 });\n            }\n            else {\n                bars.selectAll('text.nv-bar-label').text('');\n            }\n\n            bars\n                .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})\n\n            if (barColor) {\n                if (!disabled) disabled = data.map(function() { return true });\n                bars\n                    .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(  disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i]  })[j]   ).toString(); })\n                    .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker(  disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i]  })[j]   ).toString(); });\n            }\n\n            if (stacked)\n                bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n                    .attr('transform', function(d,i) {\n                        return 'translate(' + y(d.y1) + ',' + x(getX(d,i)) + ')'\n                    })\n                    .select('rect')\n                    .attr('width', function(d,i) {\n                        return Math.abs(y(getY(d,i) + d.y0) - y(d.y0)) || 0\n                    })\n                    .attr('height', x.rangeBand() );\n            else\n                bars.watchTransition(renderWatch, 'multibarhorizontal: bars')\n                    .attr('transform', function(d,i) {\n                        //TODO: stacked must be all positive or all negative, not both?\n                        return 'translate(' +\n                            (getY(d,i) < 0 ? y(getY(d,i)) : y(0))\n                            + ',' +\n                            (d.series * x.rangeBand() / data.length\n                                +\n                                x(getX(d,i)) )\n                            + ')'\n                    })\n                    .select('rect')\n                    .attr('height', x.rangeBand() / data.length )\n                    .attr('width', function(d,i) {\n                        return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0\n                    });\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n\n        });\n\n        renderWatch.renderEnd('multibarHorizontal immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:   {get: function(){return width;}, set: function(_){width=_;}},\n        height:  {get: function(){return height;}, set: function(_){height=_;}},\n        x:       {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:       {get: function(){return getY;}, set: function(_){getY=_;}},\n        yErr:       {get: function(){return getYerr;}, set: function(_){getYerr=_;}},\n        xScale:  {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:  {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:  {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:  {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        forceY:  {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}},\n        showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}},\n        // this shows the group name, seems pointless?\n        //showBarLabels:    {get: function(){return showBarLabels;}, set: function(_){showBarLabels=_;}},\n        disabled:     {get: function(){return disabled;}, set: function(_){disabled=_;}},\n        id:           {get: function(){return id;}, set: function(_){id=_;}},\n        valueFormat:  {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n        valuePadding: {get: function(){return valuePadding;}, set: function(_){valuePadding=_;}},\n        groupSpacing:{get: function(){return groupSpacing;}, set: function(_){groupSpacing=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        barColor:  {get: function(){return barColor;}, set: function(_){\n            barColor = _ ? nv.utils.getColor(_) : null;\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.multiBarHorizontalChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var multibar = nv.models.multiBarHorizontal()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , legend = nv.models.legend().height(30)\n        , controls = nv.models.legend().height(30)\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 30, right: 20, bottom: 50, left: 60}\n        , width = null\n        , height = null\n        , color = nv.utils.defaultColor()\n        , showControls = true\n        , controlLabels = {}\n        , showLegend = true\n        , showXAxis = true\n        , showYAxis = true\n        , stacked = false\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n        , controlWidth = function() { return showControls ? 180 : 0 }\n        , duration = 250\n        ;\n\n    state.stacked = false; // DEPRECATED Maintained for backward compatibility\n\n    multibar.stacked(stacked);\n\n    xAxis\n        .orient('left')\n        .tickPadding(5)\n        .showMaxMin(false)\n        .tickFormat(function(d) { return d })\n    ;\n    yAxis\n        .orient('bottom')\n        .tickFormat(d3.format(',.1f'))\n    ;\n\n    tooltip\n        .duration(0)\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        })\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        });\n\n    controls.updateState(false);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled }),\n                stacked: stacked\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.stacked !== undefined)\n                stacked = state.stacked;\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(multibar);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() { container.transition().duration(duration).call(chart) };\n            chart.container = this;\n\n            stacked = multibar.stacked();\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disableddisabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = multibar.xScale();\n            y = multibar.yScale().clamp(true);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarHorizontalChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis')\n                .append('g').attr('class', 'nv-zeroLine')\n                .append('line');\n            gEnter.append('g').attr('class', 'nv-barsWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n            gEnter.append('g').attr('class', 'nv-controlsWrap');\n\n            // Legend\n            if (showLegend) {\n                legend.width(availableWidth - controlWidth());\n\n                g.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.nv-legendWrap')\n                    .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')');\n            }\n\n            // Controls\n            if (showControls) {\n                var controlsData = [\n                    { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() },\n                    { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() }\n                ];\n\n                controls.width(controlWidth()).color(['#444', '#444', '#444']);\n                g.select('.nv-controlsWrap')\n                    .datum(controlsData)\n                    .attr('transform', 'translate(0,' + (-margin.top) +')')\n                    .call(controls);\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Main Chart Component(s)\n            multibar\n                .disabled(data.map(function(series) { return series.disabled }))\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(data.map(function(d,i) {\n                    return d.color || color(d, i);\n                }).filter(function(d,i) { return !data[i].disabled }));\n\n            var barsWrap = g.select('.nv-barsWrap')\n                .datum(data.filter(function(d) { return !d.disabled }));\n\n            barsWrap.transition().call(multibar);\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/24, data) )\n                    .tickSize(-availableWidth, 0);\n\n                g.select('.nv-x.nv-axis').call(xAxis);\n\n                var xTicks = g.select('.nv-x.nv-axis').selectAll('g');\n\n                xTicks\n                    .selectAll('line, text');\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize( -availableHeight, 0);\n\n                g.select('.nv-y.nv-axis')\n                    .attr('transform', 'translate(0,' + availableHeight + ')');\n                g.select('.nv-y.nv-axis').call(yAxis);\n            }\n\n            // Zero line\n            g.select(\".nv-zeroLine line\")\n                .attr(\"x1\", y(0))\n                .attr(\"x2\", y(0))\n                .attr(\"y1\", 0)\n                .attr(\"y2\", -availableHeight)\n            ;\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            controls.dispatch.on('legendClick', function(d,i) {\n                if (!d.disabled) return;\n                controlsData = controlsData.map(function(s) {\n                    s.disabled = true;\n                    return s;\n                });\n                d.disabled = false;\n\n                switch (d.key) {\n                    case 'Grouped':\n                    case controlLabels.grouped:\n                        multibar.stacked(false);\n                        break;\n                    case 'Stacked':\n                    case controlLabels.stacked:\n                        multibar.stacked(true);\n                        break;\n                }\n\n                state.stacked = multibar.stacked();\n                dispatch.stateChange(state);\n                stacked = multibar.stacked();\n\n                chart.update();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n\n                    state.disabled = e.disabled;\n                }\n\n                if (typeof e.stacked !== 'undefined') {\n                    multibar.stacked(e.stacked);\n                    state.stacked = e.stacked;\n                    stacked = e.stacked;\n                }\n\n                chart.update();\n            });\n        });\n        renderWatch.renderEnd('multibar horizontal chart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    multibar.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt.value = chart.x()(evt.data);\n        evt['series'] = {\n            key: evt.data.key,\n            value: chart.y()(evt.data),\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    multibar.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    multibar.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.multibar = multibar;\n    chart.legend = legend;\n    chart.controls = controls;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.state = state;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}},\n        controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n        showXAxis:      {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:    {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            multibar.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n        }},\n        barColor:  {get: function(){return multibar.barColor;}, set: function(_){\n            multibar.barColor(_);\n            legend.color(function(d,i) {return d3.rgb('#ccc').darker(i * 1.5).toString();})\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, multibar);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\nnv.models.multiChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 30, right: 20, bottom: 50, left: 60},\n        color = nv.utils.defaultColor(),\n        width = null,\n        height = null,\n        showLegend = true,\n        noData = null,\n        yDomain1,\n        yDomain2,\n        getX = function(d) { return d.x },\n        getY = function(d) { return d.y},\n        interpolate = 'monotone',\n        useVoronoi = true,\n        interactiveLayer = nv.interactiveGuideline(),\n        useInteractiveGuideline = false,\n        legendRightAxisHint = ' (right axis)'\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x = d3.scale.linear(),\n        yScale1 = d3.scale.linear(),\n        yScale2 = d3.scale.linear(),\n\n        lines1 = nv.models.line().yScale(yScale1),\n        lines2 = nv.models.line().yScale(yScale2),\n\n        scatters1 = nv.models.scatter().yScale(yScale1),\n        scatters2 = nv.models.scatter().yScale(yScale2),\n\n        bars1 = nv.models.multiBar().stacked(false).yScale(yScale1),\n        bars2 = nv.models.multiBar().stacked(false).yScale(yScale2),\n\n        stack1 = nv.models.stackedArea().yScale(yScale1),\n        stack2 = nv.models.stackedArea().yScale(yScale2),\n\n        xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5),\n        yAxis1 = nv.models.axis().scale(yScale1).orient('left'),\n        yAxis2 = nv.models.axis().scale(yScale2).orient('right'),\n\n        legend = nv.models.legend().height(30),\n        tooltip = nv.models.tooltip(),\n        dispatch = d3.dispatch();\n\n    var charts = [lines1, lines2, scatters1, scatters2, bars1, bars2, stack1, stack2];\n\n    function chart(selection) {\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n\n            chart.update = function() { container.transition().call(chart); };\n            chart.container = this;\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            var dataLines1 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 1});\n            var dataLines2 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 2});\n            var dataScatters1 = data.filter(function(d) {return d.type == 'scatter' && d.yAxis == 1});\n            var dataScatters2 = data.filter(function(d) {return d.type == 'scatter' && d.yAxis == 2});\n            var dataBars1 =  data.filter(function(d) {return d.type == 'bar'  && d.yAxis == 1});\n            var dataBars2 =  data.filter(function(d) {return d.type == 'bar'  && d.yAxis == 2});\n            var dataStack1 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 1});\n            var dataStack2 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 2});\n\n            // Display noData message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container);\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            var series1 = data.filter(function(d) {return !d.disabled && d.yAxis == 1})\n                .map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d), y: getY(d) }\n                    })\n                });\n\n            var series2 = data.filter(function(d) {return !d.disabled && d.yAxis == 2})\n                .map(function(d) {\n                    return d.values.map(function(d,i) {\n                        return { x: getX(d), y: getY(d) }\n                    })\n                });\n\n            x   .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return getX(d) }))\n                .range([0, availableWidth]);\n\n            var wrap = container.selectAll('g.wrap.multiChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g');\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y1 nv-axis');\n            gEnter.append('g').attr('class', 'nv-y2 nv-axis');\n            gEnter.append('g').attr('class', 'stack1Wrap');\n            gEnter.append('g').attr('class', 'stack2Wrap');\n            gEnter.append('g').attr('class', 'bars1Wrap');\n            gEnter.append('g').attr('class', 'bars2Wrap');\n            gEnter.append('g').attr('class', 'scatters1Wrap');\n            gEnter.append('g').attr('class', 'scatters2Wrap');\n            gEnter.append('g').attr('class', 'lines1Wrap');\n            gEnter.append('g').attr('class', 'lines2Wrap');\n            gEnter.append('g').attr('class', 'legendWrap');\n            gEnter.append('g').attr('class', 'nv-interactive');\n\n            var g = wrap.select('g');\n\n            var color_array = data.map(function(d,i) {\n                return data[i].color || color(d, i);\n            });\n\n            if (showLegend) {\n                var legendWidth = legend.align() ? availableWidth / 2 : availableWidth;\n                var legendXPosition = legend.align() ? legendWidth : 0;\n\n                legend.width(legendWidth);\n                legend.color(color_array);\n\n                g.select('.legendWrap')\n                    .datum(data.map(function(series) {\n                        series.originalKey = series.originalKey === undefined ? series.key : series.originalKey;\n                        series.key = series.originalKey + (series.yAxis == 1 ? '' : legendRightAxisHint);\n                        return series;\n                    }))\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.legendWrap')\n                    .attr('transform', 'translate(' + legendXPosition + ',' + (-margin.top) +')');\n            }\n\n            lines1\n                .width(availableWidth)\n                .height(availableHeight)\n                .interpolate(interpolate)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'line'}));\n            lines2\n                .width(availableWidth)\n                .height(availableHeight)\n                .interpolate(interpolate)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'line'}));\n            scatters1\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'scatter'}));\n            scatters2\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'scatter'}));\n            bars1\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'bar'}));\n            bars2\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'bar'}));\n            stack1\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'area'}));\n            stack2\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'area'}));\n\n            g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            var lines1Wrap = g.select('.lines1Wrap')\n                .datum(dataLines1.filter(function(d){return !d.disabled}));\n            var scatters1Wrap = g.select('.scatters1Wrap')\n                .datum(dataScatters1.filter(function(d){return !d.disabled}));\n            var bars1Wrap = g.select('.bars1Wrap')\n                .datum(dataBars1.filter(function(d){return !d.disabled}));\n            var stack1Wrap = g.select('.stack1Wrap')\n                .datum(dataStack1.filter(function(d){return !d.disabled}));\n            var lines2Wrap = g.select('.lines2Wrap')\n                .datum(dataLines2.filter(function(d){return !d.disabled}));\n            var scatters2Wrap = g.select('.scatters2Wrap')\n                .datum(dataScatters2.filter(function(d){return !d.disabled}));\n            var bars2Wrap = g.select('.bars2Wrap')\n                .datum(dataBars2.filter(function(d){return !d.disabled}));\n            var stack2Wrap = g.select('.stack2Wrap')\n                .datum(dataStack2.filter(function(d){return !d.disabled}));\n\n            var extraValue1 = dataStack1.length ? dataStack1.map(function(a){return a.values}).reduce(function(a,b){\n                return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}})\n            }).concat([{x:0, y:0}]) : [];\n            var extraValue2 = dataStack2.length ? dataStack2.map(function(a){return a.values}).reduce(function(a,b){\n                return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}})\n            }).concat([{x:0, y:0}]) : [];\n\n            yScale1 .domain(yDomain1 || d3.extent(d3.merge(series1).concat(extraValue1), function(d) { return d.y } ))\n                .range([0, availableHeight]);\n\n            yScale2 .domain(yDomain2 || d3.extent(d3.merge(series2).concat(extraValue2), function(d) { return d.y } ))\n                .range([0, availableHeight]);\n\n            lines1.yDomain(yScale1.domain());\n            scatters1.yDomain(yScale1.domain());\n            bars1.yDomain(yScale1.domain());\n            stack1.yDomain(yScale1.domain());\n\n            lines2.yDomain(yScale2.domain());\n            scatters2.yDomain(yScale2.domain());\n            bars2.yDomain(yScale2.domain());\n            stack2.yDomain(yScale2.domain());\n\n            if(dataStack1.length){d3.transition(stack1Wrap).call(stack1);}\n            if(dataStack2.length){d3.transition(stack2Wrap).call(stack2);}\n\n            if(dataBars1.length){d3.transition(bars1Wrap).call(bars1);}\n            if(dataBars2.length){d3.transition(bars2Wrap).call(bars2);}\n\n            if(dataLines1.length){d3.transition(lines1Wrap).call(lines1);}\n            if(dataLines2.length){d3.transition(lines2Wrap).call(lines2);}\n\n            if(dataScatters1.length){d3.transition(scatters1Wrap).call(scatters1);}\n            if(dataScatters2.length){d3.transition(scatters2Wrap).call(scatters2);}\n\n            xAxis\n                ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                .tickSize(-availableHeight, 0);\n\n            g.select('.nv-x.nv-axis')\n                .attr('transform', 'translate(0,' + availableHeight + ')');\n            d3.transition(g.select('.nv-x.nv-axis'))\n                .call(xAxis);\n\n            yAxis1\n                ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                .tickSize( -availableWidth, 0);\n\n\n            d3.transition(g.select('.nv-y1.nv-axis'))\n                .call(yAxis1);\n\n            yAxis2\n                ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                .tickSize( -availableWidth, 0);\n\n            d3.transition(g.select('.nv-y2.nv-axis'))\n                .call(yAxis2);\n\n            g.select('.nv-y1.nv-axis')\n                .classed('nv-disabled', series1.length ? false : true)\n                .attr('transform', 'translate(' + x.range()[0] + ',0)');\n\n            g.select('.nv-y2.nv-axis')\n                .classed('nv-disabled', series2.length ? false : true)\n                .attr('transform', 'translate(' + x.range()[1] + ',0)');\n\n            legend.dispatch.on('stateChange', function(newState) {\n                chart.update();\n            });\n\n            if(useInteractiveGuideline){\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .margin({left:margin.left, top:margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching\n            //------------------------------------------------------------\n\n            function mouseover_line(evt) {\n                var yaxis = data[evt.seriesIndex].yAxis === 2 ? yAxis2 : yAxis1;\n                evt.value = evt.point.x;\n                evt.series = {\n                    value: evt.point.y,\n                    color: evt.point.color,\n                    key: evt.series.key\n                };\n                tooltip\n                    .duration(0)\n                    .valueFormatter(function(d, i) {\n                        return yaxis.tickFormat()(d, i);\n                    })\n                    .data(evt)\n                    .hidden(false);\n            }\n\n            function mouseover_scatter(evt) {\n                var yaxis = data[evt.seriesIndex].yAxis === 2 ? yAxis2 : yAxis1;\n                evt.value = evt.point.x;\n                evt.series = {\n                    value: evt.point.y,\n                    color: evt.point.color,\n                    key: evt.series.key\n                };\n                tooltip\n                    .duration(100)\n                    .valueFormatter(function(d, i) {\n                        return yaxis.tickFormat()(d, i);\n                    })\n                    .data(evt)\n                    .hidden(false);\n            }\n\n            function mouseover_stack(evt) {\n                var yaxis = data[evt.seriesIndex].yAxis === 2 ? yAxis2 : yAxis1;\n                evt.point['x'] = stack1.x()(evt.point);\n                evt.point['y'] = stack1.y()(evt.point);\n                tooltip\n                    .duration(0)\n                    .valueFormatter(function(d, i) {\n                        return yaxis.tickFormat()(d, i);\n                    })\n                    .data(evt)\n                    .hidden(false);\n            }\n\n            function mouseover_bar(evt) {\n                var yaxis = data[evt.data.series].yAxis === 2 ? yAxis2 : yAxis1;\n\n                evt.value = bars1.x()(evt.data);\n                evt['series'] = {\n                    value: bars1.y()(evt.data),\n                    color: evt.color,\n                    key: evt.data.key\n                };\n                tooltip\n                    .duration(0)\n                    .valueFormatter(function(d, i) {\n                        return yaxis.tickFormat()(d, i);\n                    })\n                    .data(evt)\n                    .hidden(false);\n            }\n\n\n\n            function clearHighlights() {\n              for(var i=0, il=charts.length; i < il; i++){\n                var chart = charts[i];\n                try {\n                  chart.clearHighlights();\n                } catch(e){}\n              }\n            }\n\n            function highlightPoint(serieIndex, pointIndex, b){\n              for(var i=0, il=charts.length; i < il; i++){\n                var chart = charts[i];\n                try {\n                  chart.highlightPoint(serieIndex, pointIndex, b);\n                } catch(e){}\n              }\n            }\n\n            if(useInteractiveGuideline){\n                interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                    clearHighlights();\n                    var singlePoint, pointIndex, pointXLocation, allData = [];\n                    data\n                    .filter(function(series, i) {\n                        series.seriesIndex = i;\n                        return !series.disabled;\n                    })\n                    .forEach(function(series,i) {\n                        var extent = x.domain();\n                        var currentValues = series.values.filter(function(d,i) {\n                            return chart.x()(d,i) >= extent[0] && chart.x()(d,i) <= extent[1];\n                        });\n\n                        pointIndex = nv.interactiveBisect(currentValues, e.pointXValue, chart.x());\n                        var point = currentValues[pointIndex];\n                        var pointYValue = chart.y()(point, pointIndex);\n                        if (pointYValue !== null) {\n                            highlightPoint(i, pointIndex, true);\n                        }\n                        if (point === undefined) return;\n                        if (singlePoint === undefined) singlePoint = point;\n                        if (pointXLocation === undefined) pointXLocation = x(chart.x()(point,pointIndex));\n                        allData.push({\n                            key: series.key,\n                            value: pointYValue,\n                            color: color(series,series.seriesIndex),\n                            data: point,\n                            yAxis: series.yAxis == 2 ? yAxis2 : yAxis1\n                        });\n                    });\n\n                    interactiveLayer.tooltip\n                    .chartContainer(chart.container.parentNode)\n                    .valueFormatter(function(d,i) {\n                        var yAxis = allData[i].yAxis;\n                        return d === null ? \"N/A\" : yAxis.tickFormat()(d);\n                    })\n                    .data({\n                        value: chart.x()( singlePoint,pointIndex ),\n                        index: pointIndex,\n                        series: allData\n                    })();\n\n                    interactiveLayer.renderGuideLine(pointXLocation);\n                });\n\n                interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                    clearHighlights();\n                });\n            } else {\n                lines1.dispatch.on('elementMouseover.tooltip', mouseover_line);\n                lines2.dispatch.on('elementMouseover.tooltip', mouseover_line);\n                lines1.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n                lines2.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n\n                scatters1.dispatch.on('elementMouseover.tooltip', mouseover_scatter);\n                scatters2.dispatch.on('elementMouseover.tooltip', mouseover_scatter);\n                scatters1.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n                scatters2.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n\n                stack1.dispatch.on('elementMouseover.tooltip', mouseover_stack);\n                stack2.dispatch.on('elementMouseover.tooltip', mouseover_stack);\n                stack1.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n                stack2.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true)\n                });\n\n                bars1.dispatch.on('elementMouseover.tooltip', mouseover_bar);\n                bars2.dispatch.on('elementMouseover.tooltip', mouseover_bar);\n\n                bars1.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true);\n                });\n                bars2.dispatch.on('elementMouseout.tooltip', function(evt) {\n                    tooltip.hidden(true);\n                });\n                bars1.dispatch.on('elementMousemove.tooltip', function(evt) {\n                    tooltip();\n                });\n                bars2.dispatch.on('elementMousemove.tooltip', function(evt) {\n                    tooltip();\n                });\n            }\n        });\n\n        return chart;\n    }\n\n    //============================================================\n    // Global getters and setters\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.legend = legend;\n    chart.lines1 = lines1;\n    chart.lines2 = lines2;\n    chart.scatters1 = scatters1;\n    chart.scatters2 = scatters2;\n    chart.bars1 = bars1;\n    chart.bars2 = bars2;\n    chart.stack1 = stack1;\n    chart.stack2 = stack2;\n    chart.xAxis = xAxis;\n    chart.yAxis1 = yAxis1;\n    chart.yAxis2 = yAxis2;\n    chart.tooltip = tooltip;\n    chart.interactiveLayer = interactiveLayer;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        yDomain1:      {get: function(){return yDomain1;}, set: function(_){yDomain1=_;}},\n        yDomain2:    {get: function(){return yDomain2;}, set: function(_){yDomain2=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n        interpolate:    {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n        legendRightAxisHint:    {get: function(){return legendRightAxisHint;}, set: function(_){legendRightAxisHint=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        x: {get: function(){return getX;}, set: function(_){\n            getX = _;\n            lines1.x(_);\n            lines2.x(_);\n            scatters1.x(_);\n            scatters2.x(_);\n            bars1.x(_);\n            bars2.x(_);\n            stack1.x(_);\n            stack2.x(_);\n        }},\n        y: {get: function(){return getY;}, set: function(_){\n            getY = _;\n            lines1.y(_);\n            lines2.y(_);\n            scatters1.y(_);\n            scatters2.y(_);\n            stack1.y(_);\n            stack2.y(_);\n            bars1.y(_);\n            bars2.y(_);\n        }},\n        useVoronoi: {get: function(){return useVoronoi;}, set: function(_){\n            useVoronoi=_;\n            lines1.useVoronoi(_);\n            lines2.useVoronoi(_);\n            stack1.useVoronoi(_);\n            stack2.useVoronoi(_);\n        }},\n\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = _;\n            if (useInteractiveGuideline) {\n                lines1.interactive(false);\n                lines1.useVoronoi(false);\n                lines2.interactive(false);\n                lines2.useVoronoi(false);\n                stack1.interactive(false);\n                stack1.useVoronoi(false);\n                stack2.interactive(false);\n                stack2.useVoronoi(false);\n                scatters1.interactive(false);\n                scatters2.interactive(false);\n            }\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.ohlcBar = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = null\n        , height = null\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , x = d3.scale.linear()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , getOpen = function(d) { return d.open }\n        , getClose = function(d) { return d.close }\n        , getHigh = function(d) { return d.high }\n        , getLow = function(d) { return d.low }\n        , forceX = []\n        , forceY = []\n        , padData     = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart\n        , clipEdge = true\n        , color = nv.utils.defaultColor()\n        , interactive = false\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd', 'chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    function chart(selection) {\n        selection.each(function(data) {\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            nv.utils.initSVG(container);\n\n            // ohlc bar width.\n            var w = (availableWidth / data[0].values.length) * .9;\n\n            // Setup Scales\n            x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ));\n\n            if (padData)\n                x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5)  / data[0].values.length ]);\n            else\n                x.range(xRange || [5 + w/2, availableWidth - w/2 - 5]);\n\n            y.domain(yDomain || [\n                    d3.min(data[0].values.map(getLow).concat(forceY)),\n                    d3.max(data[0].values.map(getHigh).concat(forceY))\n                ]\n            ).range(yRange || [availableHeight, 0]);\n\n            // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n            if (x.domain()[0] === x.domain()[1])\n                x.domain()[0] ?\n                    x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n                    : x.domain([-1,1]);\n\n            if (y.domain()[0] === y.domain()[1])\n                y.domain()[0] ?\n                    y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])\n                    : y.domain([-1,1]);\n\n            // Setup containers and skeleton of chart\n            var wrap = d3.select(this).selectAll('g.nv-wrap.nv-ohlcBar').data([data[0].values]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-ohlcBar');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-ticks');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            container\n                .on('click', function(d,i) {\n                    dispatch.chartClick({\n                        data: d,\n                        index: i,\n                        pos: d3.event,\n                        id: id\n                    });\n                });\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-chart-clip-path-' + id)\n                .append('rect');\n\n            wrap.select('#nv-chart-clip-path-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            g   .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');\n\n            var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick')\n                .data(function(d) { return d });\n            ticks.exit().remove();\n\n            ticks.enter().append('path')\n                .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i })\n                .attr('d', function(d,i) {\n                    return 'm0,0l0,'\n                        + (y(getOpen(d,i))\n                            - y(getHigh(d,i)))\n                        + 'l'\n                        + (-w/2)\n                        + ',0l'\n                        + (w/2)\n                        + ',0l0,'\n                        + (y(getLow(d,i)) - y(getOpen(d,i)))\n                        + 'l0,'\n                        + (y(getClose(d,i))\n                            - y(getLow(d,i)))\n                        + 'l'\n                        + (w/2)\n                        + ',0l'\n                        + (-w/2)\n                        + ',0z';\n                })\n                .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; })\n                .attr('fill', function(d,i) { return color[0]; })\n                .attr('stroke', function(d,i) { return color[0]; })\n                .attr('x', 0 )\n                .attr('y', function(d,i) {  return y(Math.max(0, getY(d,i))) })\n                .attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) });\n\n            // the bar colors are controlled by CSS currently\n            ticks.attr('class', function(d,i,j) {\n                return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i;\n            });\n\n            d3.transition(ticks)\n                .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; })\n                .attr('d', function(d,i) {\n                    var w = (availableWidth / data[0].values.length) * .9;\n                    return 'm0,0l0,'\n                        + (y(getOpen(d,i))\n                            - y(getHigh(d,i)))\n                        + 'l'\n                        + (-w/2)\n                        + ',0l'\n                        + (w/2)\n                        + ',0l0,'\n                        + (y(getLow(d,i))\n                            - y(getOpen(d,i)))\n                        + 'l0,'\n                        + (y(getClose(d,i))\n                            - y(getLow(d,i)))\n                        + 'l'\n                        + (w/2)\n                        + ',0l'\n                        + (-w/2)\n                        + ',0z';\n                });\n        });\n\n        return chart;\n    }\n\n\n    //Create methods to allow outside functions to highlight a specific bar.\n    chart.highlightPoint = function(pointIndex, isHoverOver) {\n        chart.clearHighlights();\n        container.select(\".nv-ohlcBar .nv-tick-0-\" + pointIndex)\n            .classed(\"hover\", isHoverOver)\n        ;\n    };\n\n    chart.clearHighlights = function() {\n        container.select(\".nv-ohlcBar .nv-tick.hover\")\n            .classed(\"hover\", false)\n        ;\n    };\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:    {get: function(){return width;}, set: function(_){width=_;}},\n        height:   {get: function(){return height;}, set: function(_){height=_;}},\n        xScale:   {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:   {get: function(){return y;}, set: function(_){y=_;}},\n        xDomain:  {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain:  {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:   {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:   {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        forceX:   {get: function(){return forceX;}, set: function(_){forceX=_;}},\n        forceY:   {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        padData:  {get: function(){return padData;}, set: function(_){padData=_;}},\n        clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        id:       {get: function(){return id;}, set: function(_){id=_;}},\n        interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}},\n\n        x:     {get: function(){return getX;}, set: function(_){getX=_;}},\n        y:     {get: function(){return getY;}, set: function(_){getY=_;}},\n        open:  {get: function(){return getOpen();}, set: function(_){getOpen=_;}},\n        close: {get: function(){return getClose();}, set: function(_){getClose=_;}},\n        high:  {get: function(){return getHigh;}, set: function(_){getHigh=_;}},\n        low:   {get: function(){return getLow;}, set: function(_){getLow=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    != undefined ? _.top    : margin.top;\n            margin.right  = _.right  != undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   != undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\n// Code adapted from Jason Davies' \"Parallel Coordinates\"\n// http://bl.ocks.org/jasondavies/1341281\nnv.models.parallelCoordinates = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 30, right: 0, bottom: 10, left: 0}\n        , width = null\n        , height = null\n        , x = d3.scale.ordinal()\n        , y = {}\n        , dimensionData = []\n        , enabledDimensions = []\n        , dimensionNames = []\n        , displayBrush = true\n        , color = nv.utils.defaultColor()\n        , filters = []\n        , active = []\n        , dragging = []\n        , axisWithUndefinedValues = []\n        , lineTension = 1\n        , foreground\n        , background\n        , dimensions\n        , line = d3.svg.line()\n        , axis = d3.svg.axis()\n        , dispatch = d3.dispatch('brushstart', 'brush', 'brushEnd', 'dimensionsOrder', \"stateChange\", 'elementClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd', 'activeChanged')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            nv.utils.initSVG(container);\n\n\n           //Convert old data to new format (name, values)\n            if (data[0].values === undefined) {\n                var newData = [];\n                data.forEach(function (d) {\n                        var val = {};\n                        var key = Object.keys(d);\n                        key.forEach(function (k) { if (k !== \"name\") val[k] = d[k] });\n                        newData.push({ key: d.name, values: val });\n                });\n                data = newData;\n            }\n\n            var dataValues = data.map(function (d) {return d.values});\n            if (active.length === 0) {\n                active = data;\n            }; //set all active before first brush call\n            \n            dimensionNames = dimensionData.sort(function (a, b) { return a.currentPosition - b.currentPosition; }).map(function (d) { return d.key });\n            enabledDimensions = dimensionData.filter(function (d) { return !d.disabled; });\n            \n\n            // Setup Scales\n            x.rangePoints([0, availableWidth], 1).domain(enabledDimensions.map(function (d) { return d.key; }));\n\n            //Set as true if all values on an axis are missing.\n            // Extract the list of dimensions and create a scale for each.\n            var oldDomainMaxValue = {};\n            var displayMissingValuesline = false;\n\n            dimensionNames.forEach(function(d) {\n                var extent = d3.extent(dataValues, function (p) { return +p[d]; });\n                var min = extent[0];\n                var max = extent[1];\n                var onlyUndefinedValues = false;\n                //If there is no values to display on an axis, set the extent to 0\n                if (isNaN(min) || isNaN(max)) {\n                    onlyUndefinedValues = true;\n                    min = 0;\n                    max = 0;\n                }\n                //Scale axis if there is only one value\n                if (min === max) {\n                    min = min - 1;\n                    max = max + 1;\n                }\n                var f = filters.filter(function (k) { return k.dimension == d; });\n                if (f.length !== 0) {\n                    //If there is only NaN values, keep the existing domain.\n                    if (onlyUndefinedValues) {\n                        min = y[d].domain()[0];\n                        max = y[d].domain()[1];\n                    }\n                        //If the brush extent is > max (< min), keep the extent value.\n                    else if (!f[0].hasOnlyNaN && displayBrush) {\n                        min = min > f[0].extent[0] ? f[0].extent[0] : min;\n                        max = max < f[0].extent[1] ? f[0].extent[1] : max;\n                    }\n                        //If there is NaN values brushed be sure the brush extent is on the domain.\n                    else if (f[0].hasNaN) {\n                        max = max < f[0].extent[1] ? f[0].extent[1] : max;\n                        oldDomainMaxValue[d] = y[d].domain()[1];\n                        displayMissingValuesline = true;\n                    }\n                }\n                //Use 90% of (availableHeight - 12) for the axis range, 12 reprensenting the space necessary to display \"undefined values\" text.\n                //The remaining 10% are used to display the missingValue line.\n                y[d] = d3.scale.linear()\n                    .domain([min, max])\n                    .range([(availableHeight - 12) * 0.9, 0]);\n\n                axisWithUndefinedValues = [];\n\n                y[d].brush = d3.svg.brush().y(y[d]).on('brushstart', brushstart).on('brush', brush).on('brushend', brushend);\n            });\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinates').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinates');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-parallelCoordinates background');\n            gEnter.append('g').attr('class', 'nv-parallelCoordinates foreground');\n            gEnter.append('g').attr('class', 'nv-parallelCoordinates missingValuesline');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            line.interpolate('cardinal').tension(lineTension);\n            axis.orient('left');\n            var axisDrag = d3.behavior.drag()\n                        .on('dragstart', dragStart)\n                        .on('drag', dragMove)\n                        .on('dragend', dragEnd);\n\n            //Add missing value line at the bottom of the chart\n            var missingValuesline, missingValueslineText;\n            var step = x.range()[1] - x.range()[0];\n            if (!isNaN(step)) {\n                var lineData = [0 + step / 2, availableHeight - 12, availableWidth - step / 2, availableHeight - 12];\n                missingValuesline = wrap.select('.missingValuesline').selectAll('line').data([lineData]);\n                missingValuesline.enter().append('line');\n                missingValuesline.exit().remove();\n                missingValuesline.attr(\"x1\", function(d) { return d[0]; })\n                        .attr(\"y1\", function(d) { return d[1]; })\n                        .attr(\"x2\", function(d) { return d[2]; })\n                        .attr(\"y2\", function(d) { return d[3]; });\n    \n                //Add the text \"undefined values\" under the missing value line\n                missingValueslineText = wrap.select('.missingValuesline').selectAll('text').data([\"undefined values\"]);\n                missingValueslineText.append('text').data([\"undefined values\"]);\n                missingValueslineText.enter().append('text');\n                missingValueslineText.exit().remove();\n                missingValueslineText.attr(\"y\", availableHeight)\n                        //To have the text right align with the missingValues line, substract 92 representing the text size.\n                        .attr(\"x\", availableWidth - 92 - step / 2)\n                        .text(function(d) { return d; });\n            }\n            // Add grey background lines for context.\n            background = wrap.select('.background').selectAll('path').data(data);\n            background.enter().append('path');\n            background.exit().remove();\n            background.attr('d', path);\n\n            // Add blue foreground lines for focus.\n            foreground = wrap.select('.foreground').selectAll('path').data(data);\n            foreground.enter().append('path')\n            foreground.exit().remove();\n            foreground.attr('d', path)\n                .style(\"stroke-width\", function (d, i) {\n                if (isNaN(d.strokeWidth)) { d.strokeWidth = 1;} return d.strokeWidth;})\n                .attr('stroke', function (d, i) { return d.color || color(d, i); });\n            foreground.on(\"mouseover\", function (d, i) {\n                d3.select(this).classed('hover', true).style(\"stroke-width\", d.strokeWidth + 2 + \"px\").style(\"stroke-opacity\", 1);\n                dispatch.elementMouseover({\n                    label: d.name,\n                    color: d.color || color(d, i)\n                });\n\n            });\n            foreground.on(\"mouseout\", function (d, i) {\n                d3.select(this).classed('hover', false).style(\"stroke-width\", d.strokeWidth + \"px\").style(\"stroke-opacity\", 0.7);\n                dispatch.elementMouseout({\n                    label: d.name,\n                    index: i\n                });\n            });\n            foreground.on('mousemove', function (d, i) {\n                dispatch.elementMousemove();\n            });\n            foreground.on('click', function (d) {\n                dispatch.elementClick({\n                    id: d.id\n                });\n            });\n            // Add a group element for each dimension.\n            dimensions = g.selectAll('.dimension').data(enabledDimensions);\n            var dimensionsEnter = dimensions.enter().append('g').attr('class', 'nv-parallelCoordinates dimension');\n\n            dimensions.attr('transform', function(d) { return 'translate(' + x(d.key) + ',0)'; });\n            dimensionsEnter.append('g').attr('class', 'nv-axis');\n\n            // Add an axis and title.\n            dimensionsEnter.append('text')\n                    .attr('class', 'nv-label')\n                .style(\"cursor\", \"move\")\n                .attr('dy', '-1em')\n                .attr('text-anchor', 'middle')\n                .on(\"mouseover\", function(d, i) {\n                    dispatch.elementMouseover({\n                        label: d.tooltip || d.key\n                    });\n                })\n                .on(\"mouseout\", function(d, i) {\n                    dispatch.elementMouseout({\n                        label: d.tooltip\n                    });\n                })\n                .on('mousemove', function (d, i) {\n                    dispatch.elementMousemove();\n                })\n                .call(axisDrag);\n\n            dimensionsEnter.append('g').attr('class', 'nv-brushBackground');\n            dimensions.exit().remove();\n            dimensions.select('.nv-label').text(function (d) { return d.key });\n            dimensions.select('.nv-axis')\n                .each(function (d, i) {\n                    d3.select(this).call(axis.scale(y[d.key]).tickFormat(d3.format(d.format)));\n                });\n\n            // Add and store a brush for each axis.\n            restoreBrush(displayBrush);\n\n            var actives = dimensionNames.filter(function (p) { return !y[p].brush.empty(); }),\n                    extents = actives.map(function (p) { return y[p].brush.extent(); });\n            var formerActive = active.slice(0);\n\n            //Restore active values\n            active = [];\n            foreground.style(\"display\", function (d) {\n                var isActive = actives.every(function (p, i) {\n                    if ((isNaN(d.values[p]) || isNaN(parseFloat(d.values[p]))) && extents[i][0] == y[p].brush.y().domain()[0]) {\n                        return true;\n                    }\n                    return (extents[i][0] <= d.values[p] && d.values[p] <= extents[i][1]) && !isNaN(parseFloat(d.values[p]));\n                });\n                if (isActive)\n                    active.push(d);\n                return !isActive ? \"none\" : null;\n\n            });\n\n            if (filters.length > 0 || !nv.utils.arrayEquals(active, formerActive)) {\n               dispatch.activeChanged(active);\n            }\n\n            // Returns the path for a given data point.\n            function path(d) {\n                return line(enabledDimensions.map(function (p) {\n                    //If value if missing, put the value on the missing value line\n                    if (isNaN(d.values[p.key]) || isNaN(parseFloat(d.values[p.key])) || displayMissingValuesline) {\n                        var domain = y[p.key].domain();\n                        var range = y[p.key].range();\n                        var min = domain[0] - (domain[1] - domain[0]) / 9;\n\n                        //If it's not already the case, allow brush to select undefined values\n                        if (axisWithUndefinedValues.indexOf(p.key) < 0) {\n\n                            var newscale = d3.scale.linear().domain([min, domain[1]]).range([availableHeight - 12, range[1]]);\n                            y[p.key].brush.y(newscale);\n                            axisWithUndefinedValues.push(p.key);\n                        }\n                        if (isNaN(d.values[p.key]) || isNaN(parseFloat(d.values[p.key]))) {\n                            return [x(p.key), y[p.key](min)];\n                        }\n                    }\n\n                    //If parallelCoordinate contain missing values show the missing values line otherwise, hide it.\n                    if (missingValuesline !== undefined) {\n                        if (axisWithUndefinedValues.length > 0 || displayMissingValuesline) {\n                            missingValuesline.style(\"display\", \"inline\");\n                            missingValueslineText.style(\"display\", \"inline\");\n                        } else {\n                            missingValuesline.style(\"display\", \"none\");\n                            missingValueslineText.style(\"display\", \"none\");\n                        }\n                    }\n                    return [x(p.key), y[p.key](d.values[p.key])];\n                }));\n            }\n\n            function restoreBrush(visible) {\n                filters.forEach(function (f) {\n                    //If filter brushed NaN values, keep the brush on the bottom of the axis.\n                    var brushDomain = y[f.dimension].brush.y().domain();\n                    if (f.hasOnlyNaN) {\n                        f.extent[1] = (y[f.dimension].domain()[1] - brushDomain[0]) * (f.extent[1] - f.extent[0]) / (oldDomainMaxValue[f.dimension] - f.extent[0]) + brushDomain[0];\n                    }\n                    if (f.hasNaN) {\n                        f.extent[0] = brushDomain[0];\n                    }\n                    if (visible)\n                        y[f.dimension].brush.extent(f.extent);\n                });\n                \n                dimensions.select('.nv-brushBackground')\n                .each(function (d) {\n                    d3.select(this).call(y[d.key].brush);\n\n                })\n                .selectAll('rect')\n                .attr('x', -8)\n                .attr('width', 16);\n            }\n            \n            // Handles a brush event, toggling the display of foreground lines.\n            function brushstart() {\n                //If brush aren't visible, show it before brushing again.\n                if (displayBrush === false) {\n                    restoreBrush(true);\n                }\n            }\n            \n            // Handles a brush event, toggling the display of foreground lines.\n            function brush() {\n                actives = dimensionNames.filter(function (p) { return !y[p].brush.empty(); }),\n                    extents = actives.map(function(p) { return y[p].brush.extent(); });\n\n                filters = []; //erase current filters\n                actives.forEach(function(d,i) {\n                    filters[i] = {\n                        dimension: d,\n                        extent: extents[i],\n                        hasNaN: false,\n                        hasOnlyNaN: false\n                    }\n                });\n\n                active = []; //erase current active list\n                foreground.style('display', function(d) {\n                    var isActive = actives.every(function(p, i) {\n                        if ((isNaN(d.values[p]) || isNaN(parseFloat(d.values[p]))) && extents[i][0] == y[p].brush.y().domain()[0]) return true;\n                        return (extents[i][0] <= d.values[p] && d.values[p] <= extents[i][1]) && !isNaN(parseFloat(d.values[p]));\n                    });\n                    if (isActive) active.push(d);\n                    return isActive ? null : 'none';\n                });\n\n                dispatch.brush({\n                    filters: filters,\n                    active: active\n                });\n            }\n            function brushend() {\n                var hasActiveBrush = actives.length > 0 ? true : false;\n                filters.forEach(function (f) {\n                    if (f.extent[0] === y[f.dimension].brush.y().domain()[0] && axisWithUndefinedValues.indexOf(f.dimension) >= 0)\n                        f.hasNaN = true;\n                    if (f.extent[1] < y[f.dimension].domain()[0])\n                        f.hasOnlyNaN = true;\n                });\n                dispatch.brushEnd(active, hasActiveBrush);\n            }\n            function dragStart(d) {\n                dragging[d.key] = this.parentNode.__origin__ = x(d.key);\n                background.attr(\"visibility\", \"hidden\");\n\n            }\n\n            function dragMove(d) {\n                dragging[d.key] = Math.min(availableWidth, Math.max(0, this.parentNode.__origin__ += d3.event.x));\n                foreground.attr(\"d\", path);\n                enabledDimensions.sort(function (a, b) { return dimensionPosition(a.key) - dimensionPosition(b.key); });\n                enabledDimensions.forEach(function (d, i) { return d.currentPosition = i; });\n                x.domain(enabledDimensions.map(function (d) { return d.key; }));\n                dimensions.attr(\"transform\", function(d) { return \"translate(\" + dimensionPosition(d.key) + \")\"; });\n            }\n\n            function dragEnd(d, i) {\n                delete this.parentNode.__origin__;\n                delete dragging[d.key];\n                d3.select(this.parentNode).attr(\"transform\", \"translate(\" + x(d.key) + \")\");\n                foreground\n                  .attr(\"d\", path);\n                background\n                  .attr(\"d\", path)\n                  .attr(\"visibility\", null);\n\n                dispatch.dimensionsOrder(enabledDimensions);\n            }\n            function resetBrush() {\n                filters = [];\n                active = [];\n                dispatch.stateChange();\n            }\n            function resetDrag() {\n                dimensionName.map(function (d, i) { return d.currentPosition = d.originalPosition; });\n                dispatch.stateChange();\n            }\n\n            function dimensionPosition(d) {\n                var v = dragging[d];\n                return v == null ? x(d) : v;\n            }\n        });\n\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:         {get: function(){return width;},           set: function(_){width= _;}},\n        height:        {get: function(){return height;},          set: function(_){height= _;}},\n        dimensionData: { get: function () { return dimensionData; }, set: function (_) { dimensionData = _; } },\n        displayBrush: { get: function () { return displayBrush; }, set: function (_) { displayBrush = _; } },\n        filters: { get: function () { return filters; }, set: function (_) { filters = _; } },\n        active: { get: function () { return active; }, set: function (_) { active = _; } },\n        lineTension:   {get: function(){return lineTension;},     set: function(_){lineTension = _;}},\n\n        // deprecated options\n        dimensions: {get: function () { return dimensionData.map(function (d){return d.key}); }, set: function (_) {\n            // deprecated after 1.8.1\n            nv.deprecated('dimensions', 'use dimensionData instead');\n            if (dimensionData.length === 0) {\n                _.forEach(function (k) { dimensionData.push({ key: k }) })\n            } else {\n                _.forEach(function (k, i) { dimensionData[i].key= k })\n            }\n        }\n        },\n        dimensionNames: {get: function () { return dimensionData.map(function (d){return d.key}); }, set: function (_) {\n            // deprecated after 1.8.1\n            nv.deprecated('dimensionNames', 'use dimensionData instead');\n            dimensionNames = [];\n            if (dimensionData.length === 0) {\n                _.forEach(function (k) { dimensionData.push({ key: k }) })\n            } else {\n                _.forEach(function (k, i) { dimensionData[i].key = k })\n            }\n \n        }},\n        dimensionFormats: {get: function () { return dimensionData.map(function (d) { return d.format }); }, set: function (_) {\n            // deprecated after 1.8.1\n            nv.deprecated('dimensionFormats', 'use dimensionData instead');\n            if (dimensionData.length === 0) {\n                _.forEach(function (f) { dimensionData.push({ format: f }) })\n            } else {\n                _.forEach(function (f, i) { dimensionData[i].format = f })\n            }\n\n        }},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    =  _.top    !== undefined ? _.top    : margin.top;\n            margin.right  =  _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom =  _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   =  _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\nnv.models.parallelCoordinatesChart = function () {\n        \"use strict\";\n        //============================================================\n        // Public Variables with Default Settings\n        //------------------------------------------------------------\n\n        var parallelCoordinates = nv.models.parallelCoordinates()\n        var legend = nv.models.legend()\n        var tooltip = nv.models.tooltip();\n        var dimensionTooltip = nv.models.tooltip();\n\n        var margin = { top: 0, right: 0, bottom: 0, left: 0 }\n        , width = null\n\t\t, height = null\n        , showLegend = true\n\t\t, color = nv.utils.defaultColor()\n        , state = nv.utils.state()\n        , dimensionData = []\n        , dimensionNames = []\n        , displayBrush = true\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('dimensionsOrder', 'brushEnd', 'stateChange', 'changeState', 'renderEnd')\n        , controlWidth = function () { return showControls ? 180 : 0 }\n        ;\n\n\t    //============================================================\n\t\n\t\t//============================================================\n        // Private Variables\n        //------------------------------------------------------------\n\n        var renderWatch = nv.utils.renderWatch(dispatch);\n\n        var stateGetter = function(data) {\n            return function() {\n                return {\n                    active: data.map(function(d) { return !d.disabled })\n                };\n            }\n        };\n\n        var stateSetter = function(data) {\n            return function(state) {\n                if(state.active !== undefined) {\n                    data.forEach(function(series, i) {\n                        series.disabled = !state.active[i];\n                    });\n                }\n            }\n        };\n\n        //============================================================\n        // Chart function\n        //------------------------------------------------------------\n\n        function chart(selection) {\n            renderWatch.reset();\n            renderWatch.models(parallelCoordinates);\n\n            selection.each(function(data) {\n                var container = d3.select(this);\n                nv.utils.initSVG(container);\n\n                var that = this;\n\n                var availableWidth = nv.utils.availableWidth(width, container, margin),\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n\n                chart.update = function() { container.call(chart); };\n                chart.container = this;\n\n                state.setter(stateSetter(dimensionData), chart.update)\n                    .getter(stateGetter(dimensionData))\n                    .update();\n\n                //set state.disabled\n                state.disabled = dimensionData.map(function (d) { return !!d.disabled });\n\n                //Keep dimensions position in memory\n                dimensionData = dimensionData.map(function (d) {d.disabled = !!d.disabled; return d});\n                dimensionData.forEach(function (d, i) {\n                    d.originalPosition = isNaN(d.originalPosition) ? i : d.originalPosition;\n                    d.currentPosition = isNaN(d.currentPosition) ? i : d.currentPosition;\n                });\n\n                var currentDimensions = dimensionNames.map(function (d) { return d.key; });\n                var newDimensions = dimensionData.map(function (d) { return d.key; });\n                dimensionData.forEach(function (k, i) {\n                    var idx = currentDimensions.indexOf(k.key);\n                        if (idx < 0) {\n                            dimensionNames.splice(i, 0, k);\n                        } else {\n                            var gap = dimensionNames[idx].currentPosition - dimensionNames[idx].originalPosition;\n                            dimensionNames[idx].originalPosition = k.originalPosition;\n                            dimensionNames[idx].currentPosition = k.originalPosition + gap;\n                        }\n                });\n                //Remove old dimensions\n                dimensionNames = dimensionNames.filter(function (d) { return newDimensions.indexOf(d.key) >= 0; });\n\n               if (!defaultState) {\n                    var key;\n                    defaultState = {};\n                    for(key in state) {\n                        if(state[key] instanceof Array)\n                            defaultState[key] = state[key].slice(0);\n                        else\n                            defaultState[key] = state[key];\n                    }\n                }\n\n                // Display No Data message if there's nothing to show.\n                if(!data || !data.length) {\n                    nv.utils.noData(chart, container);\n                    return chart;\n                } else {\n                    container.selectAll('.nv-noData').remove();\n                }\n                \n                //------------------------------------------------------------\n                // Setup containers and skeleton of chart\n\n                var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinatesChart').data([data]);\n                var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinatesChart').append('g');\n\n                var g = wrap.select('g');\n                \n                gEnter.append('g').attr('class', 'nv-parallelCoordinatesWrap');\n                gEnter.append('g').attr('class', 'nv-legendWrap');\n\n                g.select(\"rect\")\n                    .attr(\"width\", availableWidth)\n                    .attr(\"height\", (availableHeight > 0) ? availableHeight : 0);\n\n                // Legend\n                if (showLegend) {\n                    legend.width(availableWidth)\n                        .color(function (d) { return \"rgb(188,190,192)\"; });\n\n                    g.select('.nv-legendWrap')\n                        .datum(dimensionNames.sort(function (a, b) { return a.originalPosition - b.originalPosition; }))\n                        .call(legend);\n\n                    if (margin.top != legend.height()) {\n                        margin.top = legend.height();\n                        availableHeight = nv.utils.availableHeight(height, container, margin);\n                    }\n                    wrap.select('.nv-legendWrap')\n                       .attr('transform', 'translate( 0 ,' + (-margin.top) + ')');\n                }\n                wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n                \n               \n\n                // Main Chart Component(s)\n                parallelCoordinates\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .dimensionData(dimensionNames)\n                    .displayBrush(displayBrush);\n\t\t\n\t\t        var parallelCoordinatesWrap = g.select('.nv-parallelCoordinatesWrap ')\n                  .datum(data);\n\n\t\t        parallelCoordinatesWrap.transition().call(parallelCoordinates);\n\t\t  \n\t\t\t\t//============================================================\n                // Event Handling/Dispatching (in chart's scope)\n                //------------------------------------------------------------\n                //Display reset brush button\n\t\t        parallelCoordinates.dispatch.on('brushEnd', function (active, hasActiveBrush) {\n\t\t            if (hasActiveBrush) {\n\t\t                displayBrush = true;\n\t\t                dispatch.brushEnd(active);\n\t\t            } else {\n\n\t\t                displayBrush = false;\n\t\t            }\n\t\t        });\n\n\t\t        legend.dispatch.on('stateChange', function(newState) {\n\t\t            for(var key in newState) {\n\t\t                state[key] = newState[key];\n\t\t            }\n\t\t            dispatch.stateChange(state);\n\t\t            chart.update();\n\t\t        });\n\n                //Update dimensions order and display reset sorting button\n\t\t        parallelCoordinates.dispatch.on('dimensionsOrder', function (e) {\n\t\t            dimensionNames.sort(function (a, b) { return a.currentPosition - b.currentPosition; });\n\t\t            var isSorted = false;\n\t\t            dimensionNames.forEach(function (d, i) {\n\t\t                d.currentPosition = i;\n\t\t                if (d.currentPosition !== d.originalPosition)\n\t\t                    isSorted = true;\n\t\t            });\n\t\t            dispatch.dimensionsOrder(dimensionNames, isSorted);\n\t\t        });\n\n\t\t\t\t// Update chart from a state object passed to event handler\n                dispatch.on('changeState', function (e) {\n\n                    if (typeof e.disabled !== 'undefined') {\n                        dimensionNames.forEach(function (series, i) {\n                            series.disabled = e.disabled[i];\n                        });\n                        state.disabled = e.disabled;\n                    }\n                    chart.update();\n                });\n            });\n\n            renderWatch.renderEnd('parraleleCoordinateChart immediate');\n            return chart;\n        }\n\n\t\t//============================================================\n        // Event Handling/Dispatching (out of chart's scope)\n        //------------------------------------------------------------\n\n        parallelCoordinates.dispatch.on('elementMouseover.tooltip', function (evt) {\n            evt['series'] = {\n                key: evt.label,\n                color: evt.color\n            };\n            tooltip.data(evt).hidden(false);\n        });\n\n        parallelCoordinates.dispatch.on('elementMouseout.tooltip', function(evt) {\n            tooltip.hidden(true)\n        });\n\n        parallelCoordinates.dispatch.on('elementMousemove.tooltip', function () {\n            tooltip();\n        });\n\t\t //============================================================\n        // Expose Public Variables\n        //------------------------------------------------------------\n\t\t\n\t\t// expose chart's sub-components\n        chart.dispatch = dispatch;\n        chart.parallelCoordinates = parallelCoordinates;\n        chart.legend = legend;\n        chart.tooltip = tooltip;\n\n        chart.options = nv.utils.optionsFunc.bind(chart);\n\n        chart._options = Object.create({}, {\n            // simple options, just get/set the necessary values\n            width: { get: function () { return width; }, set: function (_) { width = _; } },\n            height: { get: function () { return height; }, set: function (_) { height = _; } },\n            showLegend: { get: function () { return showLegend; }, set: function (_) { showLegend = _; } },\n            defaultState: { get: function () { return defaultState; }, set: function (_) { defaultState = _; } },\n            dimensionData: { get: function () { return dimensionData; }, set: function (_) { dimensionData = _; } },\n            displayBrush: { get: function () { return displayBrush; }, set: function (_) { displayBrush = _; } },\n            noData: { get: function () { return noData; }, set: function (_) { noData = _; } },\n\n            // options that require extra logic in the setter\n            margin: {\n                get: function () { return margin; },\n                set: function (_) {\n                    margin.top = _.top !== undefined ? _.top : margin.top;\n                    margin.right = _.right !== undefined ? _.right : margin.right;\n                    margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n                    margin.left = _.left !== undefined ? _.left : margin.left;\n                }\n            },\n            color: {get: function(){return color;}, set: function(_){\n                    color = nv.utils.getColor(_);\n                    legend.color(color);\n                    parallelCoordinates.color(color);\n                }}\n        });\n\n        nv.utils.inheritOptions(chart, parallelCoordinates);\n        nv.utils.initOptions(chart);\n\n        return chart;\n    };nv.models.pie = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 500\n        , height = 500\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , color = nv.utils.defaultColor()\n        , valueFormat = d3.format(',.2f')\n        , showLabels = true\n        , labelsOutside = false\n        , labelType = \"key\"\n        , labelThreshold = .02 //if slice percentage is under this, don't show label\n        , donut = false\n        , title = false\n        , growOnHover = true\n        , titleOffset = 0\n        , labelSunbeamLayout = false\n        , startAngle = false\n        , padAngle = false\n        , endAngle = false\n        , cornerRadius = 0\n        , donutRatio = 0.5\n        , arcsRadius = []\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'elementMousemove', 'renderEnd')\n        ;\n\n    var arcs = [];\n    var arcsOver = [];\n\n    //============================================================\n    // chart function\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right\n                , availableHeight = height - margin.top - margin.bottom\n                , radius = Math.min(availableWidth, availableHeight) / 2\n                , arcsRadiusOuter = []\n                , arcsRadiusInner = []\n                ;\n\n            container = d3.select(this)\n            if (arcsRadius.length === 0) {\n                var outer = radius - radius / 5;\n                var inner = donutRatio * radius;\n                for (var i = 0; i < data[0].length; i++) {\n                    arcsRadiusOuter.push(outer);\n                    arcsRadiusInner.push(inner);\n                }\n            } else {\n                arcsRadiusOuter = arcsRadius.map(function (d) { return (d.outer - d.outer / 5) * radius; });\n                arcsRadiusInner = arcsRadius.map(function (d) { return (d.inner - d.inner / 5) * radius; });\n                donutRatio = d3.min(arcsRadius.map(function (d) { return (d.inner - d.inner / 5); }));\n            }\n            nv.utils.initSVG(container);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('.nv-wrap.nv-pie').data(data);\n            var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id);\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n            var g_pie = gEnter.append('g').attr('class', 'nv-pie');\n            gEnter.append('g').attr('class', 'nv-pieLabels');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n            g.select('.nv-pie').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')');\n            g.select('.nv-pieLabels').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')');\n\n            //\n            container.on('click', function(d,i) {\n                dispatch.chartClick({\n                    data: d,\n                    index: i,\n                    pos: d3.event,\n                    id: id\n                });\n            });\n\n            arcs = [];\n            arcsOver = [];\n            for (var i = 0; i < data[0].length; i++) {\n\n                var arc = d3.svg.arc().outerRadius(arcsRadiusOuter[i]);\n                var arcOver = d3.svg.arc().outerRadius(arcsRadiusOuter[i] + 5);\n\n                if (startAngle !== false) {\n                    arc.startAngle(startAngle);\n                    arcOver.startAngle(startAngle);\n                }\n                if (endAngle !== false) {\n                    arc.endAngle(endAngle);\n                    arcOver.endAngle(endAngle);\n                }\n                if (donut) {\n                    arc.innerRadius(arcsRadiusInner[i]);\n                    arcOver.innerRadius(arcsRadiusInner[i]);\n                }\n\n                if (arc.cornerRadius && cornerRadius) {\n                    arc.cornerRadius(cornerRadius);\n                    arcOver.cornerRadius(cornerRadius);\n                }\n\n                arcs.push(arc);\n                arcsOver.push(arcOver);\n            }\n\n            // Setup the Pie chart and choose the data element\n            var pie = d3.layout.pie()\n                .sort(null)\n                .value(function(d) { return d.disabled ? 0 : getY(d) });\n\n            // padAngle added in d3 3.5\n            if (pie.padAngle && padAngle) {\n                pie.padAngle(padAngle);\n            }\n\n            // if title is specified and donut, put it in the middle\n            if (donut && title) {\n                g_pie.append(\"text\").attr('class', 'nv-pie-title');\n\n                wrap.select('.nv-pie-title')\n                    .style(\"text-anchor\", \"middle\")\n                    .text(function (d) {\n                        return title;\n                    })\n                    .style(\"font-size\", (Math.min(availableWidth, availableHeight)) * donutRatio * 2 / (title.length + 2) + \"px\")\n                    .attr(\"dy\", \"0.35em\") // trick to vertically center text\n                    .attr('transform', function(d, i) {\n                        return 'translate(0, '+ titleOffset + ')';\n                    });\n            }\n\n            var slices = wrap.select('.nv-pie').selectAll('.nv-slice').data(pie);\n            var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label').data(pie);\n\n            slices.exit().remove();\n            pieLabels.exit().remove();\n\n            var ae = slices.enter().append('g');\n            ae.attr('class', 'nv-slice');\n            ae.on('mouseover', function(d, i) {\n                d3.select(this).classed('hover', true);\n                if (growOnHover) {\n                    d3.select(this).select(\"path\").transition()\n                        .duration(70)\n                        .attr(\"d\", arcsOver[i]);\n                }\n                dispatch.elementMouseover({\n                    data: d.data,\n                    index: i,\n                    color: d3.select(this).style(\"fill\")\n                });\n            });\n            ae.on('mouseout', function(d, i) {\n                d3.select(this).classed('hover', false);\n                if (growOnHover) {\n                    d3.select(this).select(\"path\").transition()\n                        .duration(50)\n                        .attr(\"d\", arcs[i]);\n                }\n                dispatch.elementMouseout({data: d.data, index: i});\n            });\n            ae.on('mousemove', function(d, i) {\n                dispatch.elementMousemove({data: d.data, index: i});\n            });\n            ae.on('click', function(d, i) {\n                var element = this;\n                dispatch.elementClick({\n                    data: d.data,\n                    index: i,\n                    color: d3.select(this).style(\"fill\"),\n                    event: d3.event,\n                    element: element\n                });\n            });\n            ae.on('dblclick', function(d, i) {\n                dispatch.elementDblClick({\n                    data: d.data,\n                    index: i,\n                    color: d3.select(this).style(\"fill\")\n                });\n            });\n\n            slices.attr('fill', function(d,i) { return color(d.data, i); });\n            slices.attr('stroke', function(d,i) { return color(d.data, i); });\n\n            var paths = ae.append('path').each(function(d) {\n                this._current = d;\n            });\n\n            slices.select('path')\n                .transition()\n                .attr('d', function (d, i) { return arcs[i](d); })\n                .attrTween('d', arcTween);\n\n            if (showLabels) {\n                // This does the normal label\n                var labelsArc = [];\n                for (var i = 0; i < data[0].length; i++) {\n                    labelsArc.push(arcs[i]);\n\n                    if (labelsOutside) {\n                        if (donut) {\n                            labelsArc[i] = d3.svg.arc().outerRadius(arcs[i].outerRadius());\n                            if (startAngle !== false) labelsArc[i].startAngle(startAngle);\n                            if (endAngle !== false) labelsArc[i].endAngle(endAngle);\n                        }\n                    } else if (!donut) {\n                            labelsArc[i].innerRadius(0);\n                    }\n                }\n\n                pieLabels.enter().append(\"g\").classed(\"nv-label\",true).each(function(d,i) {\n                    var group = d3.select(this);\n\n                    group.attr('transform', function (d, i) {\n                        if (labelSunbeamLayout) {\n                            d.outerRadius = arcsRadiusOuter[i] + 10; // Set Outer Coordinate\n                            d.innerRadius = arcsRadiusOuter[i] + 15; // Set Inner Coordinate\n                            var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI);\n                            if ((d.startAngle + d.endAngle) / 2 < Math.PI) {\n                                rotateAngle -= 90;\n                            } else {\n                                rotateAngle += 90;\n                            }\n                            return 'translate(' + labelsArc[i].centroid(d) + ') rotate(' + rotateAngle + ')';\n                        } else {\n                            d.outerRadius = radius + 10; // Set Outer Coordinate\n                            d.innerRadius = radius + 15; // Set Inner Coordinate\n                            return 'translate(' + labelsArc[i].centroid(d) + ')'\n                        }\n                    });\n\n                    group.append('rect')\n                        .style('stroke', '#fff')\n                        .style('fill', '#fff')\n                        .attr(\"rx\", 3)\n                        .attr(\"ry\", 3);\n\n                    group.append('text')\n                        .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned\n                        .style('fill', '#000')\n                });\n\n                var labelLocationHash = {};\n                var avgHeight = 14;\n                var avgWidth = 140;\n                var createHashKey = function(coordinates) {\n                    return Math.floor(coordinates[0]/avgWidth) * avgWidth + ',' + Math.floor(coordinates[1]/avgHeight) * avgHeight;\n                };\n                var getSlicePercentage = function(d) {\n                    return (d.endAngle - d.startAngle) / (2 * Math.PI);\n                };\n\n                pieLabels.watchTransition(renderWatch, 'pie labels').attr('transform', function (d, i) {\n                    if (labelSunbeamLayout) {\n                        d.outerRadius = arcsRadiusOuter[i] + 10; // Set Outer Coordinate\n                        d.innerRadius = arcsRadiusOuter[i] + 15; // Set Inner Coordinate\n                        var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI);\n                        if ((d.startAngle + d.endAngle) / 2 < Math.PI) {\n                            rotateAngle -= 90;\n                        } else {\n                            rotateAngle += 90;\n                        }\n                        return 'translate(' + labelsArc[i].centroid(d) + ') rotate(' + rotateAngle + ')';\n                    } else {\n                        d.outerRadius = radius + 10; // Set Outer Coordinate\n                        d.innerRadius = radius + 15; // Set Inner Coordinate\n\n                        /*\n                        Overlapping pie labels are not good. What this attempts to do is, prevent overlapping.\n                        Each label location is hashed, and if a hash collision occurs, we assume an overlap.\n                        Adjust the label's y-position to remove the overlap.\n                        */\n                        var center = labelsArc[i].centroid(d);\n                        var percent = getSlicePercentage(d);\n                        if (d.value && percent >= labelThreshold) {\n                            var hashKey = createHashKey(center);\n                            if (labelLocationHash[hashKey]) {\n                                center[1] -= avgHeight;\n                            }\n                            labelLocationHash[createHashKey(center)] = true;\n                        }\n                        return 'translate(' + center + ')'\n                    }\n                });\n\n                pieLabels.select(\".nv-label text\")\n                    .style('text-anchor', function(d,i) {\n                        //center the text on it's origin or begin/end if orthogonal aligned\n                        return labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle';\n                    })\n                    .text(function(d, i) {\n                        var percent = getSlicePercentage(d);\n                        var label = '';\n                        if (!d.value || percent < labelThreshold) return '';\n\n                        if(typeof labelType === 'function') {\n                            label = labelType(d, i, {\n                                'key': getX(d.data),\n                                'value': getY(d.data),\n                                'percent': valueFormat(percent)\n                            });\n                        } else {\n                            switch (labelType) {\n                                case 'key':\n                                    label = getX(d.data);\n                                    break;\n                                case 'value':\n                                    label = valueFormat(getY(d.data));\n                                    break;\n                                case 'percent':\n                                    label = d3.format('%')(percent);\n                                    break;\n                            }\n                        }\n                        return label;\n                    })\n                ;\n            }\n\n\n            // Computes the angle of an arc, converting from radians to degrees.\n            function angle(d) {\n                var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90;\n                return a > 90 ? a - 180 : a;\n            }\n\n            function arcTween(a, idx) {\n                a.endAngle = isNaN(a.endAngle) ? 0 : a.endAngle;\n                a.startAngle = isNaN(a.startAngle) ? 0 : a.startAngle;\n                if (!donut) a.innerRadius = 0;\n                var i = d3.interpolate(this._current, a);\n                this._current = i(0);\n                return function (t) {\n                    return arcs[idx](i(t));\n                };\n            }\n        });\n\n        renderWatch.renderEnd('pie immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        arcsRadius: { get: function () { return arcsRadius; }, set: function (_) { arcsRadius = _; } },\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLabels: {get: function(){return showLabels;}, set: function(_){showLabels=_;}},\n        title:      {get: function(){return title;}, set: function(_){title=_;}},\n        titleOffset:    {get: function(){return titleOffset;}, set: function(_){titleOffset=_;}},\n        labelThreshold: {get: function(){return labelThreshold;}, set: function(_){labelThreshold=_;}},\n        valueFormat:    {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}},\n        x:          {get: function(){return getX;}, set: function(_){getX=_;}},\n        id:         {get: function(){return id;}, set: function(_){id=_;}},\n        endAngle:   {get: function(){return endAngle;}, set: function(_){endAngle=_;}},\n        startAngle: {get: function(){return startAngle;}, set: function(_){startAngle=_;}},\n        padAngle:   {get: function(){return padAngle;}, set: function(_){padAngle=_;}},\n        cornerRadius: {get: function(){return cornerRadius;}, set: function(_){cornerRadius=_;}},\n        donutRatio:   {get: function(){return donutRatio;}, set: function(_){donutRatio=_;}},\n        labelsOutside: {get: function(){return labelsOutside;}, set: function(_){labelsOutside=_;}},\n        labelSunbeamLayout: {get: function(){return labelSunbeamLayout;}, set: function(_){labelSunbeamLayout=_;}},\n        donut:              {get: function(){return donut;}, set: function(_){donut=_;}},\n        growOnHover:        {get: function(){return growOnHover;}, set: function(_){growOnHover=_;}},\n\n        // depreciated after 1.7.1\n        pieLabelsOutside: {get: function(){return labelsOutside;}, set: function(_){\n            labelsOutside=_;\n            nv.deprecated('pieLabelsOutside', 'use labelsOutside instead');\n        }},\n        // depreciated after 1.7.1\n        donutLabelsOutside: {get: function(){return labelsOutside;}, set: function(_){\n            labelsOutside=_;\n            nv.deprecated('donutLabelsOutside', 'use labelsOutside instead');\n        }},\n        // deprecated after 1.7.1\n        labelFormat: {get: function(){ return valueFormat;}, set: function(_) {\n            valueFormat=_;\n            nv.deprecated('labelFormat','use valueFormat instead');\n        }},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = typeof _.top    != 'undefined' ? _.top    : margin.top;\n            margin.right  = typeof _.right  != 'undefined' ? _.right  : margin.right;\n            margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;\n            margin.left   = typeof _.left   != 'undefined' ? _.left   : margin.left;\n        }},\n        y: {get: function(){return getY;}, set: function(_){\n            getY=d3.functor(_);\n        }},\n        color: {get: function(){return color;}, set: function(_){\n            color=nv.utils.getColor(_);\n        }},\n        labelType:          {get: function(){return labelType;}, set: function(_){\n            labelType= _ || 'key';\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\nnv.models.pieChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var pie = nv.models.pie();\n    var legend = nv.models.legend();\n    var tooltip = nv.models.tooltip();\n\n    var margin = {top: 30, right: 20, bottom: 20, left: 20}\n        , width = null\n        , height = null\n        , showLegend = true\n        , legendPosition = \"top\"\n        , color = nv.utils.defaultColor()\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , duration = 250\n        , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n        ;\n\n    tooltip\n        .duration(0)\n        .headerEnabled(false)\n        .valueFormatter(function(d, i) {\n            return pie.valueFormat()(d, i);\n        });\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled })\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.active !== undefined) {\n                data.forEach(function (series, i) {\n                    series.disabled = !state.active[i];\n                });\n            }\n        }\n    };\n\n    //============================================================\n    // Chart function\n    //------------------------------------------------------------\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(pie);\n\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var that = this;\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() { container.transition().call(chart); };\n            chart.container = this;\n\n            state.setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            //set state.disabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length) {\n                nv.utils.noData(chart, container);\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-pieWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n\n            // Legend\n            if (showLegend) {\n                if (legendPosition === \"top\") {\n                    legend.width( availableWidth ).key(pie.x());\n\n                    wrap.select('.nv-legendWrap')\n                        .datum(data)\n                        .call(legend);\n\n                    if ( margin.top != legend.height()) {\n                        margin.top = legend.height();\n                        availableHeight = nv.utils.availableHeight(height, container, margin);\n                    }\n\n                    wrap.select('.nv-legendWrap')\n                        .attr('transform', 'translate(0,' + (-margin.top) +')');\n                } else if (legendPosition === \"right\") {\n                    var legendWidth = nv.models.legend().width();\n                    if (availableWidth / 2 < legendWidth) {\n                        legendWidth = (availableWidth / 2)\n                    }\n                    legend.height(availableHeight).key(pie.x());\n                    legend.width(legendWidth);\n                    availableWidth -= legend.width();\n\n                    wrap.select('.nv-legendWrap')\n                        .datum(data)\n                        .call(legend)\n                        .attr('transform', 'translate(' + (availableWidth) +',0)');\n                }\n            }\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Main Chart Component(s)\n            pie.width(availableWidth).height(availableHeight);\n            var pieWrap = g.select('.nv-pieWrap').datum([data]);\n            d3.transition(pieWrap).call(pie);\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState) {\n                    state[key] = newState[key];\n                }\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n                    state.disabled = e.disabled;\n                }\n                chart.update();\n            });\n        });\n\n        renderWatch.renderEnd('pieChart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    pie.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt['series'] = {\n            key: chart.x()(evt.data),\n            value: chart.y()(evt.data),\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    pie.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    pie.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.legend = legend;\n    chart.dispatch = dispatch;\n    chart.pie = pie;\n    chart.tooltip = tooltip;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    // use Object get/set functionality to map between vars and chart functions\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        noData:         {get: function(){return noData;},         set: function(_){noData=_;}},\n        showLegend:     {get: function(){return showLegend;},     set: function(_){showLegend=_;}},\n        legendPosition: {get: function(){return legendPosition;}, set: function(_){legendPosition=_;}},\n        defaultState:   {get: function(){return defaultState;},   set: function(_){defaultState=_;}},\n\n        // options that require extra logic in the setter\n        color: {get: function(){return color;}, set: function(_){\n            color = _;\n            legend.color(color);\n            pie.color(color);\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }},\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }}\n    });\n    nv.utils.inheritOptions(chart, pie);\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.models.scatter = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin       = {top: 0, right: 0, bottom: 0, left: 0}\n        , width        = null\n        , height       = null\n        , color        = nv.utils.defaultColor() // chooses color\n        , id           = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't select one\n        , container    = null\n        , x            = d3.scale.linear()\n        , y            = d3.scale.linear()\n        , z            = d3.scale.linear() //linear because d3.svg.shape.size is treated as area\n        , getX         = function(d) { return d.x } // accessor to get the x value\n        , getY         = function(d) { return d.y } // accessor to get the y value\n        , getSize      = function(d) { return d.size || 1} // accessor to get the point size\n        , getShape     = function(d) { return d.shape || 'circle' } // accessor to get point shape\n        , forceX       = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)\n        , forceY       = [] // List of numbers to Force into the Y scale\n        , forceSize    = [] // List of numbers to Force into the Size scale\n        , interactive  = true // If true, plots a voronoi overlay for advanced point intersection\n        , pointActive  = function(d) { return !d.notActive } // any points that return false will be filtered out\n        , padData      = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart\n        , padDataOuter = .1 //outerPadding to imitate ordinal scale outer padding\n        , clipEdge     = false // if true, masks points within x and y scale\n        , clipVoronoi  = true // if true, masks each point with a circle... can turn off to slightly increase performance\n        , showVoronoi  = false // display the voronoi areas\n        , clipRadius   = function() { return 25 } // function to get the radius for voronoi point clips\n        , xDomain      = null // Override x domain (skips the calculation from data)\n        , yDomain      = null // Override y domain\n        , xRange       = null // Override x range\n        , yRange       = null // Override y range\n        , sizeDomain   = null // Override point size domain\n        , sizeRange    = null\n        , singlePoint  = false\n        , dispatch     = d3.dispatch('elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd')\n        , useVoronoi   = true\n        , duration     = 250\n        , interactiveUpdateDelay = 300\n        ;\n\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0, z0 // used to store previous scales\n        , timeoutID\n        , needsUpdate = false // Flag for when the points are visually updating, but the interactive layer is behind, to disable tooltips\n        , renderWatch = nv.utils.renderWatch(dispatch, duration)\n        , _sizeRange_def = [16, 256]\n        ;\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            nv.utils.initSVG(container);\n\n            //add series index to each data point for reference\n            data.forEach(function(series, i) {\n                series.values.forEach(function(point) {\n                    point.series = i;\n                });\n            });\n\n            // Setup Scales\n            // remap and flatten the data for use in calculating the scales' domains\n            var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance\n                d3.merge(\n                    data.map(function(d) {\n                        return d.values.map(function(d,i) {\n                            return { x: getX(d,i), y: getY(d,i), size: getSize(d,i) }\n                        })\n                    })\n                );\n\n            x   .domain(xDomain || d3.extent(seriesData.map(function(d) { return d.x; }).concat(forceX)))\n\n            if (padData && data[0])\n                x.range(xRange || [(availableWidth * padDataOuter +  availableWidth) / (2 *data[0].values.length), availableWidth - availableWidth * (1 + padDataOuter) / (2 * data[0].values.length)  ]);\n            //x.range([availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5)  / data[0].values.length ]);\n            else\n                x.range(xRange || [0, availableWidth]);\n\n             if (chart.yScale().name === \"o\") {\n                    var min = d3.min(seriesData.map(function(d) { if (d.y !== 0) return d.y; }));\n                    y.clamp(true)\n                        .domain(yDomain || d3.extent(seriesData.map(function(d) {\n                            if (d.y !== 0) return d.y;\n                            else return min * 0.1;\n                        }).concat(forceY)))\n                        .range(yRange || [availableHeight, 0]);\n                } else {\n                        y.domain(yDomain || d3.extent(seriesData.map(function (d) { return d.y;}).concat(forceY)))\n                        .range(yRange || [availableHeight, 0]);\n                }\n\n            z   .domain(sizeDomain || d3.extent(seriesData.map(function(d) { return d.size }).concat(forceSize)))\n                .range(sizeRange || _sizeRange_def);\n\n            // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point\n            singlePoint = x.domain()[0] === x.domain()[1] || y.domain()[0] === y.domain()[1];\n\n            if (x.domain()[0] === x.domain()[1])\n                x.domain()[0] ?\n                    x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])\n                    : x.domain([-1,1]);\n\n            if (y.domain()[0] === y.domain()[1])\n                y.domain()[0] ?\n                    y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01])\n                    : y.domain([-1,1]);\n\n            if ( isNaN(x.domain()[0])) {\n                x.domain([-1,1]);\n            }\n\n            if ( isNaN(y.domain()[0])) {\n                y.domain([-1,1]);\n            }\n\n            x0 = x0 || x;\n            y0 = y0 || y;\n            z0 = z0 || z;\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-scatter').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatter nv-chart-' + id);\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            wrap.classed('nv-single-point', singlePoint);\n            gEnter.append('g').attr('class', 'nv-groups');\n            gEnter.append('g').attr('class', 'nv-point-paths');\n            wrapEnter.append('g').attr('class', 'nv-point-clips');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-edge-clip-' + id)\n                .append('rect');\n\n            wrap.select('#nv-edge-clip-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', (availableHeight > 0) ? availableHeight : 0);\n\n            g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n            function updateInteractiveLayer() {\n                // Always clear needs-update flag regardless of whether or not\n                // we will actually do anything (avoids needless invocations).\n                needsUpdate = false;\n\n                if (!interactive) return false;\n\n                // inject series and point index for reference into voronoi\n                if (useVoronoi === true) {\n                    var vertices = d3.merge(data.map(function(group, groupIndex) {\n                            return group.values\n                                .map(function(point, pointIndex) {\n                                    // *Adding noise to make duplicates very unlikely\n                                    // *Injecting series and point index for reference\n                                    /* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi.\n                                     */\n                                    var pX = getX(point,pointIndex);\n                                    var pY = getY(point,pointIndex);\n\n                                    return [x(pX)+ Math.random() * 1e-4,\n                                            y(pY)+ Math.random() * 1e-4,\n                                        groupIndex,\n                                        pointIndex, point]; //temp hack to add noise until I think of a better way so there are no duplicates\n                                })\n                                .filter(function(pointArray, pointIndex) {\n                                    return pointActive(pointArray[4], pointIndex); // Issue #237.. move filter to after map, so pointIndex is correct!\n                                })\n                        })\n                    );\n\n                    if (vertices.length == 0) return false;  // No active points, we're done\n                    if (vertices.length < 3) {\n                        // Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work\n                        vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]);\n                        vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]);\n                        vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]);\n                        vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]);\n                    }\n\n                    // keep voronoi sections from going more than 10 outside of graph\n                    // to avoid overlap with other things like legend etc\n                    var bounds = d3.geom.polygon([\n                        [-10,-10],\n                        [-10,height + 10],\n                        [width + 10,height + 10],\n                        [width + 10,-10]\n                    ]);\n\n                    var voronoi = d3.geom.voronoi(vertices).map(function(d, i) {\n                        return {\n                            'data': bounds.clip(d),\n                            'series': vertices[i][2],\n                            'point': vertices[i][3]\n                        }\n                    });\n\n                    // nuke all voronoi paths on reload and recreate them\n                    wrap.select('.nv-point-paths').selectAll('path').remove();\n                    var pointPaths = wrap.select('.nv-point-paths').selectAll('path').data(voronoi);\n                    var vPointPaths = pointPaths\n                        .enter().append(\"svg:path\")\n                        .attr(\"d\", function(d) {\n                            if (!d || !d.data || d.data.length === 0)\n                                return 'M 0 0';\n                            else\n                                return \"M\" + d.data.join(\",\") + \"Z\";\n                        })\n                        .attr(\"id\", function(d,i) {\n                            return \"nv-path-\"+i; })\n                        .attr(\"clip-path\", function(d,i) { return \"url(#nv-clip-\"+id+\"-\"+i+\")\"; })\n                        ;\n\n                    // good for debugging point hover issues\n                    if (showVoronoi) {\n                        vPointPaths.style(\"fill\", d3.rgb(230, 230, 230))\n                            .style('fill-opacity', 0.4)\n                            .style('stroke-opacity', 1)\n                            .style(\"stroke\", d3.rgb(200,200,200));\n                    }\n\n                    if (clipVoronoi) {\n                        // voronoi sections are already set to clip,\n                        // just create the circles with the IDs they expect\n                        wrap.select('.nv-point-clips').selectAll('*').remove(); // must do * since it has sub-dom\n                        var pointClips = wrap.select('.nv-point-clips').selectAll('clipPath').data(vertices);\n                        var vPointClips = pointClips\n                            .enter().append(\"svg:clipPath\")\n                            .attr(\"id\", function(d, i) { return \"nv-clip-\"+id+\"-\"+i;})\n                            .append(\"svg:circle\")\n                            .attr('cx', function(d) { return d[0]; })\n                            .attr('cy', function(d) { return d[1]; })\n                            .attr('r', clipRadius);\n                    }\n\n                    var mouseEventCallback = function(d, mDispatch) {\n                        if (needsUpdate) return 0;\n                        var series = data[d.series];\n                        if (series === undefined) return;\n                        var point  = series.values[d.point];\n                        point['color'] = color(series, d.series);\n\n                        // standardize attributes for tooltip.\n                        point['x'] = getX(point);\n                        point['y'] = getY(point);\n\n                        // can't just get box of event node since it's actually a voronoi polygon\n                        var box = container.node().getBoundingClientRect();\n                        var scrollTop  = window.pageYOffset || document.documentElement.scrollTop;\n                        var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;\n\n                        var pos = {\n                            left: x(getX(point, d.point)) + box.left + scrollLeft + margin.left + 10,\n                            top: y(getY(point, d.point)) + box.top + scrollTop + margin.top + 10\n                        };\n\n                        mDispatch({\n                            point: point,\n                            series: series,\n                            pos: pos,\n                            relativePos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top],\n                            seriesIndex: d.series,\n                            pointIndex: d.point\n                        });\n                    };\n\n                    pointPaths\n                        .on('click', function(d) {\n                            mouseEventCallback(d, dispatch.elementClick);\n                        })\n                        .on('dblclick', function(d) {\n                            mouseEventCallback(d, dispatch.elementDblClick);\n                        })\n                        .on('mouseover', function(d) {\n                            mouseEventCallback(d, dispatch.elementMouseover);\n                        })\n                        .on('mouseout', function(d, i) {\n                            mouseEventCallback(d, dispatch.elementMouseout);\n                        });\n\n                } else {\n                    // add event handlers to points instead voronoi paths\n                    wrap.select('.nv-groups').selectAll('.nv-group')\n                        .selectAll('.nv-point')\n                        //.data(dataWithPoints)\n                        //.style('pointer-events', 'auto') // recativate events, disabled by css\n                        .on('click', function(d,i) {\n                            //nv.log('test', d, i);\n                            if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n                            var series = data[d.series],\n                                point  = series.values[i];\n\n                            dispatch.elementClick({\n                                point: point,\n                                series: series,\n                                pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], //TODO: make this pos base on the page\n                                relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n                                seriesIndex: d.series,\n                                pointIndex: i\n                            });\n                        })\n                        .on('dblclick', function(d,i) {\n                            if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n                            var series = data[d.series],\n                                point  = series.values[i];\n\n                            dispatch.elementDblClick({\n                                point: point,\n                                series: series,\n                                pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n                                relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n                                seriesIndex: d.series,\n                                pointIndex: i\n                            });\n                        })\n                        .on('mouseover', function(d,i) {\n                            if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n                            var series = data[d.series],\n                                point  = series.values[i];\n\n                            dispatch.elementMouseover({\n                                point: point,\n                                series: series,\n                                pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n                                relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n                                seriesIndex: d.series,\n                                pointIndex: i,\n                                color: color(d, i)\n                            });\n                        })\n                        .on('mouseout', function(d,i) {\n                            if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point\n                            var series = data[d.series],\n                                point  = series.values[i];\n\n                            dispatch.elementMouseout({\n                                point: point,\n                                series: series,\n                                pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],//TODO: make this pos base on the page\n                                relativePos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top],\n                                seriesIndex: d.series,\n                                pointIndex: i,\n                                color: color(d, i)\n                            });\n                        });\n                }\n            }\n\n            needsUpdate = true;\n            var groups = wrap.select('.nv-groups').selectAll('.nv-group')\n                .data(function(d) { return d }, function(d) { return d.key });\n            groups.enter().append('g')\n                .style('stroke-opacity', 1e-6)\n                .style('fill-opacity', 1e-6);\n            groups.exit()\n                .remove();\n            groups\n                .attr('class', function(d,i) {\n                    return (d.classed || '') + ' nv-group nv-series-' + i;\n                })\n                .classed('hover', function(d) { return d.hover });\n            groups.watchTransition(renderWatch, 'scatter: groups')\n                .style('fill', function(d,i) { return color(d, i) })\n                .style('stroke', function(d,i) { return color(d, i) })\n                .style('stroke-opacity', 1)\n                .style('fill-opacity', .5);\n\n            // create the points, maintaining their IDs from the original data set\n            var points = groups.selectAll('path.nv-point')\n                .data(function(d) {\n                    return d.values.map(\n                        function (point, pointIndex) {\n                            return [point, pointIndex]\n                        }).filter(\n                            function(pointArray, pointIndex) {\n                                return pointActive(pointArray[0], pointIndex)\n                            })\n                    });\n            points.enter().append('path')\n                .style('fill', function (d) { return d.color })\n                .style('stroke', function (d) { return d.color })\n                .attr('transform', function(d) {\n                    return 'translate(' + nv.utils.NaNtoZero(x0(getX(d[0],d[1]))) + ',' + nv.utils.NaNtoZero(y0(getY(d[0],d[1]))) + ')'\n                })\n                .attr('d',\n                    nv.utils.symbol()\n                    .type(function(d) { return getShape(d[0]); })\n                    .size(function(d) { return z(getSize(d[0],d[1])) })\n            );\n            points.exit().remove();\n            groups.exit().selectAll('path.nv-point')\n                .watchTransition(renderWatch, 'scatter exit')\n                .attr('transform', function(d) {\n                    return 'translate(' + nv.utils.NaNtoZero(x(getX(d[0],d[1]))) + ',' + nv.utils.NaNtoZero(y(getY(d[0],d[1]))) + ')'\n                })\n                .remove();\n            points.each(function(d) {\n                d3.select(this)\n                    .classed('nv-point', true)\n                    .classed('nv-point-' + d[1], true)\n                    .classed('nv-noninteractive', !interactive)\n                    .classed('hover',false)\n                ;\n            });\n            points\n                .watchTransition(renderWatch, 'scatter points')\n                .attr('transform', function(d) {\n                    //nv.log(d, getX(d[0],d[1]), x(getX(d[0],d[1])));\n                    return 'translate(' + nv.utils.NaNtoZero(x(getX(d[0],d[1]))) + ',' + nv.utils.NaNtoZero(y(getY(d[0],d[1]))) + ')'\n                })\n                .attr('d',\n                    nv.utils.symbol()\n                    .type(function(d) { return getShape(d[0]); })\n                    .size(function(d) { return z(getSize(d[0],d[1])) })\n            );\n\n            // Delay updating the invisible interactive layer for smoother animation\n            if( interactiveUpdateDelay )\n            {\n                clearTimeout(timeoutID); // stop repeat calls to updateInteractiveLayer\n                timeoutID = setTimeout(updateInteractiveLayer, interactiveUpdateDelay );\n            }\n            else\n            {\n                updateInteractiveLayer();\n            }\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n            z0 = z.copy();\n\n        });\n        renderWatch.renderEnd('scatter immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    // utility function calls provided by this chart\n    chart._calls = new function() {\n        this.clearHighlights = function () {\n            nv.dom.write(function() {\n                container.selectAll(\".nv-point.hover\").classed(\"hover\", false);\n            });\n            return null;\n        };\n        this.highlightPoint = function (seriesIndex, pointIndex, isHoverOver) {\n            nv.dom.write(function() {\n                container.select('.nv-groups')\n                  .selectAll(\".nv-series-\" + seriesIndex)\n                  .selectAll(\".nv-point-\" + pointIndex)\n                  .classed(\"hover\", isHoverOver);\n            });\n        };\n    };\n\n    // trigger calls from events too\n    dispatch.on('elementMouseover.point', function(d) {\n        if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,true);\n    });\n\n    dispatch.on('elementMouseout.point', function(d) {\n        if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,false);\n    });\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:        {get: function(){return width;}, set: function(_){width=_;}},\n        height:       {get: function(){return height;}, set: function(_){height=_;}},\n        xScale:       {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:       {get: function(){return y;}, set: function(_){y=_;}},\n        pointScale:   {get: function(){return z;}, set: function(_){z=_;}},\n        xDomain:      {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain:      {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        pointDomain:  {get: function(){return sizeDomain;}, set: function(_){sizeDomain=_;}},\n        xRange:       {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:       {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        pointRange:   {get: function(){return sizeRange;}, set: function(_){sizeRange=_;}},\n        forceX:       {get: function(){return forceX;}, set: function(_){forceX=_;}},\n        forceY:       {get: function(){return forceY;}, set: function(_){forceY=_;}},\n        forcePoint:   {get: function(){return forceSize;}, set: function(_){forceSize=_;}},\n        interactive:  {get: function(){return interactive;}, set: function(_){interactive=_;}},\n        pointActive:  {get: function(){return pointActive;}, set: function(_){pointActive=_;}},\n        padDataOuter: {get: function(){return padDataOuter;}, set: function(_){padDataOuter=_;}},\n        padData:      {get: function(){return padData;}, set: function(_){padData=_;}},\n        clipEdge:     {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        clipVoronoi:  {get: function(){return clipVoronoi;}, set: function(_){clipVoronoi=_;}},\n        clipRadius:   {get: function(){return clipRadius;}, set: function(_){clipRadius=_;}},\n        showVoronoi:   {get: function(){return showVoronoi;}, set: function(_){showVoronoi=_;}},\n        id:           {get: function(){return id;}, set: function(_){id=_;}},\n        interactiveUpdateDelay: {get:function(){return interactiveUpdateDelay;}, set: function(_){interactiveUpdateDelay=_;}},\n\n\n        // simple functor options\n        x:     {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}},\n        y:     {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}},\n        pointSize: {get: function(){return getSize;}, set: function(_){getSize = d3.functor(_);}},\n        pointShape: {get: function(){return getShape;}, set: function(_){getShape = d3.functor(_);}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n        }},\n        color: {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        useVoronoi: {get: function(){return useVoronoi;}, set: function(_){\n            useVoronoi = _;\n            if (useVoronoi === false) {\n                clipVoronoi = false;\n            }\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.models.scatterChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var scatter      = nv.models.scatter()\n        , xAxis        = nv.models.axis()\n        , yAxis        = nv.models.axis()\n        , legend       = nv.models.legend()\n        , distX        = nv.models.distribution()\n        , distY        = nv.models.distribution()\n        , tooltip      = nv.models.tooltip()\n        ;\n\n    var margin       = {top: 30, right: 20, bottom: 50, left: 75}\n        , width        = null\n        , height       = null\n        , container    = null\n        , color        = nv.utils.defaultColor()\n        , x            = scatter.xScale()\n        , y            = scatter.yScale()\n        , showDistX    = false\n        , showDistY    = false\n        , showLegend   = true\n        , showXAxis    = true\n        , showYAxis    = true\n        , rightAlignYAxis = false\n        , state = nv.utils.state()\n        , defaultState = null\n        , dispatch = d3.dispatch('stateChange', 'changeState', 'renderEnd')\n        , noData       = null\n        , duration = 250\n        ;\n\n    scatter.xScale(x).yScale(y);\n    xAxis.orient('bottom').tickPadding(10);\n    yAxis\n        .orient((rightAlignYAxis) ? 'right' : 'left')\n        .tickPadding(10)\n    ;\n    distX.axis('x');\n    distY.axis('y');\n    tooltip\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        })\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        });\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var x0, y0\n        , renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled })\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(scatter);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n        if (showDistX) renderWatch.models(distX);\n        if (showDistY) renderWatch.models(distY);\n\n        selection.each(function(data) {\n            var that = this;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() {\n                if (duration === 0)\n                    container.call(chart);\n                else\n                    container.transition().duration(duration).call(chart);\n            };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disableddisabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display noData message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container);\n                renderWatch.renderEnd('scatter immediate');\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = scatter.xScale();\n            y = scatter.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id());\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            // background for pointer events\n            gEnter.append('rect').attr('class', 'nvd3 nv-background').style(\"pointer-events\",\"none\");\n\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis');\n            gEnter.append('g').attr('class', 'nv-scatterWrap');\n            gEnter.append('g').attr('class', 'nv-regressionLinesWrap');\n            gEnter.append('g').attr('class', 'nv-distWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            // Legend\n            if (showLegend) {\n                var legendWidth = availableWidth;\n                legend.width(legendWidth);\n\n                wrap.select('.nv-legendWrap')\n                    .datum(data)\n                    .call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                wrap.select('.nv-legendWrap')\n                    .attr('transform', 'translate(0' + ',' + (-margin.top) +')');\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Main Chart Component(s)\n            scatter\n                .width(availableWidth)\n                .height(availableHeight)\n                .color(data.map(function(d,i) {\n                    d.color = d.color || color(d, i);\n                    return d.color;\n                }).filter(function(d,i) { return !data[i].disabled }));\n\n            wrap.select('.nv-scatterWrap')\n                .datum(data.filter(function(d) { return !d.disabled }))\n                .call(scatter);\n\n\n            wrap.select('.nv-regressionLinesWrap')\n                .attr('clip-path', 'url(#nv-edge-clip-' + scatter.id() + ')');\n\n            var regWrap = wrap.select('.nv-regressionLinesWrap').selectAll('.nv-regLines')\n                .data(function (d) {\n                    return d;\n                });\n\n            regWrap.enter().append('g').attr('class', 'nv-regLines');\n\n            var regLine = regWrap.selectAll('.nv-regLine')\n                .data(function (d) {\n                    return [d]\n                });\n\n            regLine.enter()\n                .append('line').attr('class', 'nv-regLine')\n                .style('stroke-opacity', 0);\n\n            // don't add lines unless we have slope and intercept to use\n            regLine.filter(function(d) {\n                return d.intercept && d.slope;\n            })\n                .watchTransition(renderWatch, 'scatterPlusLineChart: regline')\n                .attr('x1', x.range()[0])\n                .attr('x2', x.range()[1])\n                .attr('y1', function (d, i) {\n                    return y(x.domain()[0] * d.slope + d.intercept)\n                })\n                .attr('y2', function (d, i) {\n                    return y(x.domain()[1] * d.slope + d.intercept)\n                })\n                .style('stroke', function (d, i, j) {\n                    return color(d, j)\n                })\n                .style('stroke-opacity', function (d, i) {\n                    return (d.disabled || typeof d.slope === 'undefined' || typeof d.intercept === 'undefined') ? 0 : 1\n                });\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis\n                    .scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize( -availableHeight , 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + y.range()[0] + ')')\n                    .call(xAxis);\n            }\n\n            if (showYAxis) {\n                yAxis\n                    .scale(y)\n                    ._ticks( nv.utils.calcTicksY(availableHeight/36, data) )\n                    .tickSize( -availableWidth, 0);\n\n                g.select('.nv-y.nv-axis')\n                    .call(yAxis);\n            }\n\n            // Setup Distribution\n            if (showDistX) {\n                distX\n                    .getData(scatter.x())\n                    .scale(x)\n                    .width(availableWidth)\n                    .color(data.map(function(d,i) {\n                        return d.color || color(d, i);\n                    }).filter(function(d,i) { return !data[i].disabled }));\n                gEnter.select('.nv-distWrap').append('g')\n                    .attr('class', 'nv-distributionX');\n                g.select('.nv-distributionX')\n                    .attr('transform', 'translate(0,' + y.range()[0] + ')')\n                    .datum(data.filter(function(d) { return !d.disabled }))\n                    .call(distX);\n            }\n\n            if (showDistY) {\n                distY\n                    .getData(scatter.y())\n                    .scale(y)\n                    .width(availableHeight)\n                    .color(data.map(function(d,i) {\n                        return d.color || color(d, i);\n                    }).filter(function(d,i) { return !data[i].disabled }));\n                gEnter.select('.nv-distWrap').append('g')\n                    .attr('class', 'nv-distributionY');\n                g.select('.nv-distributionY')\n                    .attr('transform', 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)')\n                    .datum(data.filter(function(d) { return !d.disabled }))\n                    .call(distY);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n                if (typeof e.disabled !== 'undefined') {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n                    state.disabled = e.disabled;\n                }\n                chart.update();\n            });\n\n            // mouseover needs availableHeight so we just keep scatter mouse events inside the chart block\n            scatter.dispatch.on('elementMouseout.tooltip', function(evt) {\n                tooltip.hidden(true);\n                container.select('.nv-chart-' + scatter.id() + ' .nv-series-' + evt.seriesIndex + ' .nv-distx-' + evt.pointIndex)\n                    .attr('y1', 0);\n                container.select('.nv-chart-' + scatter.id() + ' .nv-series-' + evt.seriesIndex + ' .nv-disty-' + evt.pointIndex)\n                    .attr('x2', distY.size());\n            });\n\n            scatter.dispatch.on('elementMouseover.tooltip', function(evt) {\n                container.select('.nv-series-' + evt.seriesIndex + ' .nv-distx-' + evt.pointIndex)\n                    .attr('y1', evt.relativePos[1] - availableHeight);\n                container.select('.nv-series-' + evt.seriesIndex + ' .nv-disty-' + evt.pointIndex)\n                    .attr('x2', evt.relativePos[0] + distX.size());\n                tooltip.data(evt).hidden(false);\n            });\n\n            //store old scales for use in transitions on update\n            x0 = x.copy();\n            y0 = y.copy();\n\n        });\n\n        renderWatch.renderEnd('scatter with line immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.scatter = scatter;\n    chart.legend = legend;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.distX = distX;\n    chart.distY = distY;\n    chart.tooltip = tooltip;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        container:  {get: function(){return container;}, set: function(_){container=_;}},\n        showDistX:  {get: function(){return showDistX;}, set: function(_){showDistX=_;}},\n        showDistY:  {get: function(){return showDistY;}, set: function(_){showDistY=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showXAxis:  {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:  {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        defaultState:     {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:     {get: function(){return noData;}, set: function(_){noData=_;}},\n        duration:   {get: function(){return duration;}, set: function(_){duration=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( (_) ? 'right' : 'left');\n        }},\n        color: {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n            distX.color(color);\n            distY.color(color);\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, scatter);\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.models.sparkline = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 2, right: 0, bottom: 2, left: 0}\n        , width = 400\n        , height = 32\n        , container = null\n        , animate = true\n        , x = d3.scale.linear()\n        , y = d3.scale.linear()\n        , getX = function(d) { return d.x }\n        , getY = function(d) { return d.y }\n        , color = nv.utils.getColor(['#000'])\n        , xDomain\n        , yDomain\n        , xRange\n        , yRange\n        , dispatch = d3.dispatch('renderEnd')\n        ;\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n    \n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup Scales\n            x   .domain(xDomain || d3.extent(data, getX ))\n                .range(xRange || [0, availableWidth]);\n\n            y   .domain(yDomain || d3.extent(data, getY ))\n                .range(yRange || [availableHeight, 0]);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')\n\n            var paths = wrap.selectAll('path')\n                .data(function(d) { return [d] });\n            paths.enter().append('path');\n            paths.exit().remove();\n            paths\n                .style('stroke', function(d,i) { return d.color || color(d, i) })\n                .attr('d', d3.svg.line()\n                    .x(function(d,i) { return x(getX(d,i)) })\n                    .y(function(d,i) { return y(getY(d,i)) })\n            );\n\n            // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent)\n            var points = wrap.selectAll('circle.nv-point')\n                .data(function(data) {\n                    var yValues = data.map(function(d, i) { return getY(d,i); });\n                    function pointIndex(index) {\n                        if (index != -1) {\n                            var result = data[index];\n                            result.pointIndex = index;\n                            return result;\n                        } else {\n                            return null;\n                        }\n                    }\n                    var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])),\n                        minPoint = pointIndex(yValues.indexOf(y.domain()[0])),\n                        currentPoint = pointIndex(yValues.length - 1);\n                    return [minPoint, maxPoint, currentPoint].filter(function (d) {return d != null;});\n                });\n            points.enter().append('circle');\n            points.exit().remove();\n            points\n                .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) })\n                .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) })\n                .attr('r', 2)\n                .attr('class', function(d,i) {\n                    return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' :\n                            getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue'\n                });\n        });\n        \n        renderWatch.renderEnd('sparkline immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:     {get: function(){return width;}, set: function(_){width=_;}},\n        height:    {get: function(){return height;}, set: function(_){height=_;}},\n        xDomain:   {get: function(){return xDomain;}, set: function(_){xDomain=_;}},\n        yDomain:   {get: function(){return yDomain;}, set: function(_){yDomain=_;}},\n        xRange:    {get: function(){return xRange;}, set: function(_){xRange=_;}},\n        yRange:    {get: function(){return yRange;}, set: function(_){yRange=_;}},\n        xScale:    {get: function(){return x;}, set: function(_){x=_;}},\n        yScale:    {get: function(){return y;}, set: function(_){y=_;}},\n        animate:   {get: function(){return animate;}, set: function(_){animate=_;}},\n\n        //functor options\n        x: {get: function(){return getX;}, set: function(_){getX=d3.functor(_);}},\n        y: {get: function(){return getY;}, set: function(_){getY=d3.functor(_);}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }}\n    });\n\n    chart.dispatch = dispatch;\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.models.sparklinePlus = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var sparkline = nv.models.sparkline();\n\n    var margin = {top: 15, right: 100, bottom: 10, left: 50}\n        , width = null\n        , height = null\n        , x\n        , y\n        , index = []\n        , paused = false\n        , xTickFormat = d3.format(',r')\n        , yTickFormat = d3.format(',.2f')\n        , showLastValue = true\n        , alignValue = true\n        , rightAlignValue = false\n        , noData = null\n        , dispatch = d3.dispatch('renderEnd')\n        ;\n        \n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(sparkline);\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() { container.call(chart); };\n            chart.container = this;\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            var currentValue = sparkline.y()(data[data.length-1], data.length-1);\n\n            // Setup Scales\n            x = sparkline.xScale();\n            y = sparkline.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-sparklineWrap');\n            gEnter.append('g').attr('class', 'nv-valueWrap');\n            gEnter.append('g').attr('class', 'nv-hoverArea');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Main Chart Component(s)\n            var sparklineWrap = g.select('.nv-sparklineWrap');\n\n            sparkline.width(availableWidth).height(availableHeight);\n            sparklineWrap.call(sparkline);\n\n            if (showLastValue) {\n                var valueWrap = g.select('.nv-valueWrap');\n                var value = valueWrap.selectAll('.nv-currentValue')\n                    .data([currentValue]);\n\n                value.enter().append('text').attr('class', 'nv-currentValue')\n                    .attr('dx', rightAlignValue ? -8 : 8)\n                    .attr('dy', '.9em')\n                    .style('text-anchor', rightAlignValue ? 'end' : 'start');\n\n                value\n                    .attr('x', availableWidth + (rightAlignValue ? margin.right : 0))\n                    .attr('y', alignValue ? function (d) {\n                        return y(d)\n                    } : 0)\n                    .style('fill', sparkline.color()(data[data.length - 1], data.length - 1))\n                    .text(yTickFormat(currentValue));\n            }\n\n            gEnter.select('.nv-hoverArea').append('rect')\n                .on('mousemove', sparklineHover)\n                .on('click', function() { paused = !paused })\n                .on('mouseout', function() { index = []; updateValueLine(); });\n\n            g.select('.nv-hoverArea rect')\n                .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' })\n                .attr('width', availableWidth + margin.left + margin.right)\n                .attr('height', availableHeight + margin.top);\n\n            //index is currently global (within the chart), may or may not keep it that way\n            function updateValueLine() {\n                if (paused) return;\n\n                var hoverValue = g.selectAll('.nv-hoverValue').data(index);\n\n                var hoverEnter = hoverValue.enter()\n                    .append('g').attr('class', 'nv-hoverValue')\n                    .style('stroke-opacity', 0)\n                    .style('fill-opacity', 0);\n\n                hoverValue.exit()\n                    .transition().duration(250)\n                    .style('stroke-opacity', 0)\n                    .style('fill-opacity', 0)\n                    .remove();\n\n                hoverValue\n                    .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' })\n                    .transition().duration(250)\n                    .style('stroke-opacity', 1)\n                    .style('fill-opacity', 1);\n\n                if (!index.length) return;\n\n                hoverEnter.append('line')\n                    .attr('x1', 0)\n                    .attr('y1', -margin.top)\n                    .attr('x2', 0)\n                    .attr('y2', availableHeight);\n\n                hoverEnter.append('text').attr('class', 'nv-xValue')\n                    .attr('x', -6)\n                    .attr('y', -margin.top)\n                    .attr('text-anchor', 'end')\n                    .attr('dy', '.9em');\n\n                g.select('.nv-hoverValue .nv-xValue')\n                    .text(xTickFormat(sparkline.x()(data[index[0]], index[0])));\n\n                hoverEnter.append('text').attr('class', 'nv-yValue')\n                    .attr('x', 6)\n                    .attr('y', -margin.top)\n                    .attr('text-anchor', 'start')\n                    .attr('dy', '.9em');\n\n                g.select('.nv-hoverValue .nv-yValue')\n                    .text(yTickFormat(sparkline.y()(data[index[0]], index[0])));\n            }\n\n            function sparklineHover() {\n                if (paused) return;\n\n                var pos = d3.mouse(this)[0] - margin.left;\n\n                function getClosestIndex(data, x) {\n                    var distance = Math.abs(sparkline.x()(data[0], 0) - x);\n                    var closestIndex = 0;\n                    for (var i = 0; i < data.length; i++){\n                        if (Math.abs(sparkline.x()(data[i], i) - x) < distance) {\n                            distance = Math.abs(sparkline.x()(data[i], i) - x);\n                            closestIndex = i;\n                        }\n                    }\n                    return closestIndex;\n                }\n\n                index = [getClosestIndex(data, Math.round(x.invert(pos)))];\n                updateValueLine();\n            }\n\n        });\n        renderWatch.renderEnd('sparklinePlus immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.sparkline = sparkline;\n\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:           {get: function(){return width;}, set: function(_){width=_;}},\n        height:          {get: function(){return height;}, set: function(_){height=_;}},\n        xTickFormat:     {get: function(){return xTickFormat;}, set: function(_){xTickFormat=_;}},\n        yTickFormat:     {get: function(){return yTickFormat;}, set: function(_){yTickFormat=_;}},\n        showLastValue:   {get: function(){return showLastValue;}, set: function(_){showLastValue=_;}},\n        alignValue:      {get: function(){return alignValue;}, set: function(_){alignValue=_;}},\n        rightAlignValue: {get: function(){return rightAlignValue;}, set: function(_){rightAlignValue=_;}},\n        noData:          {get: function(){return noData;}, set: function(_){noData=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, sparkline);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.stackedArea = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = 960\n        , height = 500\n        , color = nv.utils.defaultColor() // a function that computes the color\n        , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one\n        , container = null\n        , getX = function(d) { return d.x } // accessor to get the x value from a data point\n        , getY = function(d) { return d.y } // accessor to get the y value from a data point\n        , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined\n        , style = 'stack'\n        , offset = 'zero'\n        , order = 'default'\n        , interpolate = 'linear'  // controls the line interpolation\n        , clipEdge = false // if true, masks lines within x and y scale\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , scatter = nv.models.scatter()\n        , duration = 250\n        , dispatch =  d3.dispatch('areaClick', 'areaMouseover', 'areaMouseout','renderEnd', 'elementClick', 'elementMouseover', 'elementMouseout')\n        ;\n\n    scatter\n        .pointSize(2.2) // default size\n        .pointDomain([2.2, 2.2]) // all the same size by default\n    ;\n\n    /************************************\n     * offset:\n     *   'wiggle' (stream)\n     *   'zero' (stacked)\n     *   'expand' (normalize to 100%)\n     *   'silhouette' (simple centered)\n     *\n     * order:\n     *   'inside-out' (stream)\n     *   'default' (input order)\n     ************************************/\n\n    var renderWatch = nv.utils.renderWatch(dispatch, duration);\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(scatter);\n        selection.each(function(data) {\n            var availableWidth = width - margin.left - margin.right,\n                availableHeight = height - margin.top - margin.bottom;\n\n            container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            // Setup Scales\n            x = scatter.xScale();\n            y = scatter.yScale();\n\n            var dataRaw = data;\n            // Injecting point index into each point because d3.layout.stack().out does not give index\n            data.forEach(function(aseries, i) {\n                aseries.seriesIndex = i;\n                aseries.values = aseries.values.map(function(d, j) {\n                    d.index = j;\n                    d.seriesIndex = i;\n                    return d;\n                });\n            });\n\n            var dataFiltered = data.filter(function(series) {\n                return !series.disabled;\n            });\n\n            data = d3.layout.stack()\n                .order(order)\n                .offset(offset)\n                .values(function(d) { return d.values })  //TODO: make values customizeable in EVERY model in this fashion\n                .x(getX)\n                .y(getY)\n                .out(function(d, y0, y) {\n                    d.display = {\n                        y: y,\n                        y0: y0\n                    };\n                })\n            (dataFiltered);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea');\n            var defsEnter = wrapEnter.append('defs');\n            var gEnter = wrapEnter.append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-areaWrap');\n            gEnter.append('g').attr('class', 'nv-scatterWrap');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n            \n            // If the user has not specified forceY, make sure 0 is included in the domain\n            // Otherwise, use user-specified values for forceY\n            if (scatter.forceY().length == 0) {\n                scatter.forceY().push(0);\n            }\n            \n            scatter\n                .width(availableWidth)\n                .height(availableHeight)\n                .x(getX)\n                .y(function(d) {\n                    if (d.display !== undefined) { return d.display.y + d.display.y0; }\n                })\n                .forceY([0])\n                .color(data.map(function(d,i) {\n                    d.color = d.color || color(d, d.seriesIndex);\n                    return d.color;\n                }));\n\n            var scatterWrap = g.select('.nv-scatterWrap')\n                .datum(data);\n\n            scatterWrap.call(scatter);\n\n            defsEnter.append('clipPath')\n                .attr('id', 'nv-edge-clip-' + id)\n                .append('rect');\n\n            wrap.select('#nv-edge-clip-' + id + ' rect')\n                .attr('width', availableWidth)\n                .attr('height', availableHeight);\n\n            g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');\n\n            var area = d3.svg.area()\n                .defined(defined)\n                .x(function(d,i)  { return x(getX(d,i)) })\n                .y0(function(d) {\n                    return y(d.display.y0)\n                })\n                .y1(function(d) {\n                    return y(d.display.y + d.display.y0)\n                })\n                .interpolate(interpolate);\n\n            var zeroArea = d3.svg.area()\n                .defined(defined)\n                .x(function(d,i)  { return x(getX(d,i)) })\n                .y0(function(d) { return y(d.display.y0) })\n                .y1(function(d) { return y(d.display.y0) });\n\n            var path = g.select('.nv-areaWrap').selectAll('path.nv-area')\n                .data(function(d) { return d });\n\n            path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i })\n                .attr('d', function(d,i){\n                    return zeroArea(d.values, d.seriesIndex);\n                })\n                .on('mouseover', function(d,i) {\n                    d3.select(this).classed('hover', true);\n                    dispatch.areaMouseover({\n                        point: d,\n                        series: d.key,\n                        pos: [d3.event.pageX, d3.event.pageY],\n                        seriesIndex: d.seriesIndex\n                    });\n                })\n                .on('mouseout', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.areaMouseout({\n                        point: d,\n                        series: d.key,\n                        pos: [d3.event.pageX, d3.event.pageY],\n                        seriesIndex: d.seriesIndex\n                    });\n                })\n                .on('click', function(d,i) {\n                    d3.select(this).classed('hover', false);\n                    dispatch.areaClick({\n                        point: d,\n                        series: d.key,\n                        pos: [d3.event.pageX, d3.event.pageY],\n                        seriesIndex: d.seriesIndex\n                    });\n                });\n\n            path.exit().remove();\n            path.style('fill', function(d,i){\n                    return d.color || color(d, d.seriesIndex)\n                })\n                .style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) });\n            path.watchTransition(renderWatch,'stackedArea path')\n                .attr('d', function(d,i) {\n                    return area(d.values,i)\n                });\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            scatter.dispatch.on('elementMouseover.area', function(e) {\n                g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true);\n            });\n            scatter.dispatch.on('elementMouseout.area', function(e) {\n                g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false);\n            });\n\n            //Special offset functions\n            chart.d3_stackedOffset_stackPercent = function(stackData) {\n                var n = stackData.length,    //How many series\n                    m = stackData[0].length,     //how many points per series\n                    i,\n                    j,\n                    o,\n                    y0 = [];\n\n                for (j = 0; j < m; ++j) { //Looping through all points\n                    for (i = 0, o = 0; i < dataRaw.length; i++) { //looping through all series\n                        o += getY(dataRaw[i].values[j]); //total y value of all series at a certian point in time.\n                    }\n\n                    if (o) for (i = 0; i < n; i++) { //(total y value of all series at point in time i) != 0\n                        stackData[i][j][1] /= o;\n                    } else { //(total y value of all series at point in time i) == 0\n                        for (i = 0; i < n; i++) {\n                            stackData[i][j][1] = 0;\n                        }\n                    }\n                }\n                for (j = 0; j < m; ++j) y0[j] = 0;\n                return y0;\n            };\n\n        });\n\n        renderWatch.renderEnd('stackedArea immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Global getters and setters\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.scatter = scatter;\n\n    scatter.dispatch.on('elementClick', function(){ dispatch.elementClick.apply(this, arguments); });\n    scatter.dispatch.on('elementMouseover', function(){ dispatch.elementMouseover.apply(this, arguments); });\n    scatter.dispatch.on('elementMouseout', function(){ dispatch.elementMouseout.apply(this, arguments); });\n\n    chart.interpolate = function(_) {\n        if (!arguments.length) return interpolate;\n        interpolate = _;\n        return chart;\n    };\n\n    chart.duration = function(_) {\n        if (!arguments.length) return duration;\n        duration = _;\n        renderWatch.reset(duration);\n        scatter.duration(duration);\n        return chart;\n    };\n\n    chart.dispatch = dispatch;\n    chart.scatter = scatter;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        defined: {get: function(){return defined;}, set: function(_){defined=_;}},\n        clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}},\n        offset:      {get: function(){return offset;}, set: function(_){offset=_;}},\n        order:    {get: function(){return order;}, set: function(_){order=_;}},\n        interpolate:    {get: function(){return interpolate;}, set: function(_){interpolate=_;}},\n\n        // simple functor options\n        x:     {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}},\n        y:     {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n        }},\n        style: {get: function(){return style;}, set: function(_){\n            style = _;\n            switch (style) {\n                case 'stack':\n                    chart.offset('zero');\n                    chart.order('default');\n                    break;\n                case 'stream':\n                    chart.offset('wiggle');\n                    chart.order('inside-out');\n                    break;\n                case 'stream-center':\n                    chart.offset('silhouette');\n                    chart.order('inside-out');\n                    break;\n                case 'expand':\n                    chart.offset('expand');\n                    chart.order('default');\n                    break;\n                case 'stack_percent':\n                    chart.offset(chart.d3_stackedOffset_stackPercent);\n                    chart.order('default');\n                    break;\n            }\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            scatter.duration(duration);\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, scatter);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n\nnv.models.stackedAreaChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var stacked = nv.models.stackedArea()\n        , xAxis = nv.models.axis()\n        , yAxis = nv.models.axis()\n        , legend = nv.models.legend()\n        , controls = nv.models.legend()\n        , interactiveLayer = nv.interactiveGuideline()\n        , tooltip = nv.models.tooltip()\n        ;\n\n    var margin = {top: 30, right: 25, bottom: 50, left: 60}\n        , width = null\n        , height = null\n        , color = nv.utils.defaultColor()\n        , showControls = true\n        , showLegend = true\n        , showXAxis = true\n        , showYAxis = true\n        , rightAlignYAxis = false\n        , useInteractiveGuideline = false\n        , showTotalInTooltip = true\n        , totalLabel = 'TOTAL'\n        , x //can be accessed via chart.xScale()\n        , y //can be accessed via chart.yScale()\n        , state = nv.utils.state()\n        , defaultState = null\n        , noData = null\n        , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n        , controlWidth = 250\n        , controlOptions = ['Stacked','Stream','Expanded']\n        , controlLabels = {}\n        , duration = 250\n        ;\n\n    state.style = stacked.style();\n    xAxis.orient('bottom').tickPadding(7);\n    yAxis.orient((rightAlignYAxis) ? 'right' : 'left');\n\n    tooltip\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        })\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        });\n\n    interactiveLayer.tooltip\n        .headerFormatter(function(d, i) {\n            return xAxis.tickFormat()(d, i);\n        })\n        .valueFormatter(function(d, i) {\n            return yAxis.tickFormat()(d, i);\n        });\n\n    var oldYTickFormat = null,\n        oldValueFormatter = null;\n\n    controls.updateState(false);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n    var style = stacked.style();\n\n    var stateGetter = function(data) {\n        return function(){\n            return {\n                active: data.map(function(d) { return !d.disabled }),\n                style: stacked.style()\n            };\n        }\n    };\n\n    var stateSetter = function(data) {\n        return function(state) {\n            if (state.style !== undefined)\n                style = state.style;\n            if (state.active !== undefined)\n                data.forEach(function(series,i) {\n                    series.disabled = !state.active[i];\n                });\n        }\n    };\n\n    var percentFormatter = d3.format('%');\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(stacked);\n        if (showXAxis) renderWatch.models(xAxis);\n        if (showYAxis) renderWatch.models(yAxis);\n\n        selection.each(function(data) {\n            var container = d3.select(this),\n                that = this;\n            nv.utils.initSVG(container);\n\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() { container.transition().duration(duration).call(chart); };\n            chart.container = this;\n\n            state\n                .setter(stateSetter(data), chart.update)\n                .getter(stateGetter(data))\n                .update();\n\n            // DEPRECATED set state.disabled\n            state.disabled = data.map(function(d) { return !!d.disabled });\n\n            if (!defaultState) {\n                var key;\n                defaultState = {};\n                for (key in state) {\n                    if (state[key] instanceof Array)\n                        defaultState[key] = state[key].slice(0);\n                    else\n                        defaultState[key] = state[key];\n                }\n            }\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {\n                nv.utils.noData(chart, container)\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup Scales\n            x = stacked.xScale();\n            y = stacked.yScale();\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append(\"rect\").style(\"opacity\",0);\n            gEnter.append('g').attr('class', 'nv-x nv-axis');\n            gEnter.append('g').attr('class', 'nv-y nv-axis');\n            gEnter.append('g').attr('class', 'nv-stackedWrap');\n            gEnter.append('g').attr('class', 'nv-legendWrap');\n            gEnter.append('g').attr('class', 'nv-controlsWrap');\n            gEnter.append('g').attr('class', 'nv-interactive');\n\n            g.select(\"rect\").attr(\"width\",availableWidth).attr(\"height\",availableHeight);\n\n            // Legend\n            if (showLegend) {\n                var legendWidth = (showControls) ? availableWidth - controlWidth : availableWidth;\n\n                legend.width(legendWidth);\n                g.select('.nv-legendWrap').datum(data).call(legend);\n\n                if ( margin.top != legend.height()) {\n                    margin.top = legend.height();\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.nv-legendWrap')\n                    .attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')');\n            }\n\n            // Controls\n            if (showControls) {\n                var controlsData = [\n                    {\n                        key: controlLabels.stacked || 'Stacked',\n                        metaKey: 'Stacked',\n                        disabled: stacked.style() != 'stack',\n                        style: 'stack'\n                    },\n                    {\n                        key: controlLabels.stream || 'Stream',\n                        metaKey: 'Stream',\n                        disabled: stacked.style() != 'stream',\n                        style: 'stream'\n                    },\n                    {\n                        key: controlLabels.expanded || 'Expanded',\n                        metaKey: 'Expanded',\n                        disabled: stacked.style() != 'expand',\n                        style: 'expand'\n                    },\n                    {\n                        key: controlLabels.stack_percent || 'Stack %',\n                        metaKey: 'Stack_Percent',\n                        disabled: stacked.style() != 'stack_percent',\n                        style: 'stack_percent'\n                    }\n                ];\n\n                controlWidth = (controlOptions.length/3) * 260;\n                controlsData = controlsData.filter(function(d) {\n                    return controlOptions.indexOf(d.metaKey) !== -1;\n                });\n\n                controls\n                    .width( controlWidth )\n                    .color(['#444', '#444', '#444']);\n\n                g.select('.nv-controlsWrap')\n                    .datum(controlsData)\n                    .call(controls);\n\n                if ( margin.top != Math.max(controls.height(), legend.height()) ) {\n                    margin.top = Math.max(controls.height(), legend.height());\n                    availableHeight = nv.utils.availableHeight(height, container, margin);\n                }\n\n                g.select('.nv-controlsWrap')\n                    .attr('transform', 'translate(0,' + (-margin.top) +')');\n            }\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            if (rightAlignYAxis) {\n                g.select(\".nv-y.nv-axis\")\n                    .attr(\"transform\", \"translate(\" + availableWidth + \",0)\");\n            }\n\n            //Set up interactive layer\n            if (useInteractiveGuideline) {\n                interactiveLayer\n                    .width(availableWidth)\n                    .height(availableHeight)\n                    .margin({left: margin.left, top: margin.top})\n                    .svgContainer(container)\n                    .xScale(x);\n                wrap.select(\".nv-interactive\").call(interactiveLayer);\n            }\n\n            stacked\n                .width(availableWidth)\n                .height(availableHeight);\n\n            var stackedWrap = g.select('.nv-stackedWrap')\n                .datum(data);\n\n            stackedWrap.transition().call(stacked);\n\n            // Setup Axes\n            if (showXAxis) {\n                xAxis.scale(x)\n                    ._ticks( nv.utils.calcTicksX(availableWidth/100, data) )\n                    .tickSize( -availableHeight, 0);\n\n                g.select('.nv-x.nv-axis')\n                    .attr('transform', 'translate(0,' + availableHeight + ')');\n\n                g.select('.nv-x.nv-axis')\n                    .transition().duration(0)\n                    .call(xAxis);\n            }\n\n            if (showYAxis) {\n                var ticks;\n                if (stacked.offset() === 'wiggle') {\n                    ticks = 0;\n                }\n                else {\n                    ticks = nv.utils.calcTicksY(availableHeight/36, data);\n                }\n                yAxis.scale(y)\n                    ._ticks(ticks)\n                    .tickSize(-availableWidth, 0);\n\n                    if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {\n                        var currentFormat = yAxis.tickFormat();\n\n                        if ( !oldYTickFormat || currentFormat !== percentFormatter )\n                            oldYTickFormat = currentFormat;\n\n                        //Forces the yAxis to use percentage in 'expand' mode.\n                        yAxis.tickFormat(percentFormatter);\n                    }\n                    else {\n                        if (oldYTickFormat) {\n                            yAxis.tickFormat(oldYTickFormat);\n                            oldYTickFormat = null;\n                        }\n                    }\n\n                g.select('.nv-y.nv-axis')\n                    .transition().duration(0)\n                    .call(yAxis);\n            }\n\n            //============================================================\n            // Event Handling/Dispatching (in chart's scope)\n            //------------------------------------------------------------\n\n            stacked.dispatch.on('areaClick.toggle', function(e) {\n                if (data.filter(function(d) { return !d.disabled }).length === 1)\n                    data.forEach(function(d) {\n                        d.disabled = false;\n                    });\n                else\n                    data.forEach(function(d,i) {\n                        d.disabled = (i != e.seriesIndex);\n                    });\n\n                state.disabled = data.map(function(d) { return !!d.disabled });\n                dispatch.stateChange(state);\n\n                chart.update();\n            });\n\n            legend.dispatch.on('stateChange', function(newState) {\n                for (var key in newState)\n                    state[key] = newState[key];\n                dispatch.stateChange(state);\n                chart.update();\n            });\n\n            controls.dispatch.on('legendClick', function(d,i) {\n                if (!d.disabled) return;\n\n                controlsData = controlsData.map(function(s) {\n                    s.disabled = true;\n                    return s;\n                });\n                d.disabled = false;\n\n                stacked.style(d.style);\n\n\n                state.style = stacked.style();\n                dispatch.stateChange(state);\n\n                chart.update();\n            });\n\n            interactiveLayer.dispatch.on('elementMousemove', function(e) {\n                stacked.clearHighlights();\n                var singlePoint, pointIndex, pointXLocation, allData = [], valueSum = 0;\n                data\n                    .filter(function(series, i) {\n                        series.seriesIndex = i;\n                        return !series.disabled;\n                    })\n                    .forEach(function(series,i) {\n                        pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x());\n                        var point = series.values[pointIndex];\n                        var pointYValue = chart.y()(point, pointIndex);\n                        if (pointYValue != null) {\n                            stacked.highlightPoint(i, pointIndex, true);\n                        }\n                        if (typeof point === 'undefined') return;\n                        if (typeof singlePoint === 'undefined') singlePoint = point;\n                        if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex));\n\n                        //If we are in 'expand' mode, use the stacked percent value instead of raw value.\n                        var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex);\n                        allData.push({\n                            key: series.key,\n                            value: tooltipValue,\n                            color: color(series,series.seriesIndex),\n                            stackedValue: point.display\n                        });\n\n                        if (showTotalInTooltip && stacked.style() != 'expand') {\n                          valueSum += tooltipValue;\n                        };\n                    });\n\n                allData.reverse();\n\n                //Highlight the tooltip entry based on which stack the mouse is closest to.\n                if (allData.length > 2) {\n                    var yValue = chart.yScale().invert(e.mouseY);\n                    var yDistMax = Infinity, indexToHighlight = null;\n                    allData.forEach(function(series,i) {\n\n                        //To handle situation where the stacked area chart is negative, we need to use absolute values\n                        //when checking if the mouse Y value is within the stack area.\n                        yValue = Math.abs(yValue);\n                        var stackedY0 = Math.abs(series.stackedValue.y0);\n                        var stackedY = Math.abs(series.stackedValue.y);\n                        if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0))\n                        {\n                            indexToHighlight = i;\n                            return;\n                        }\n                    });\n                    if (indexToHighlight != null)\n                        allData[indexToHighlight].highlight = true;\n                }\n\n                //If we are not in 'expand' mode, add a 'Total' row to the tooltip.\n                if (showTotalInTooltip && stacked.style() != 'expand' && allData.length >= 2) {\n                    allData.push({\n                        key: totalLabel,\n                        value: valueSum,\n                        total: true\n                    });\n                }\n\n                var xValue = chart.x()(singlePoint,pointIndex);\n\n                var valueFormatter = interactiveLayer.tooltip.valueFormatter();\n                // Keeps track of the tooltip valueFormatter if the chart changes to expanded view\n                if (stacked.style() === 'expand' || stacked.style() === 'stack_percent') {\n                    if ( !oldValueFormatter ) {\n                        oldValueFormatter = valueFormatter;\n                    }\n                    //Forces the tooltip to use percentage in 'expand' mode.\n                    valueFormatter = d3.format(\".1%\");\n                }\n                else {\n                    if (oldValueFormatter) {\n                        valueFormatter = oldValueFormatter;\n                        oldValueFormatter = null;\n                    }\n                }\n\n                interactiveLayer.tooltip\n                    .chartContainer(that.parentNode)\n                    .valueFormatter(valueFormatter)\n                    .data(\n                    {\n                        value: xValue,\n                        series: allData\n                    }\n                )();\n\n                interactiveLayer.renderGuideLine(pointXLocation);\n\n            });\n\n            interactiveLayer.dispatch.on(\"elementMouseout\",function(e) {\n                stacked.clearHighlights();\n            });\n\n            // Update chart from a state object passed to event handler\n            dispatch.on('changeState', function(e) {\n\n                if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) {\n                    data.forEach(function(series,i) {\n                        series.disabled = e.disabled[i];\n                    });\n\n                    state.disabled = e.disabled;\n                }\n\n                if (typeof e.style !== 'undefined') {\n                    stacked.style(e.style);\n                    style = e.style;\n                }\n\n                chart.update();\n            });\n\n        });\n\n        renderWatch.renderEnd('stacked Area chart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    stacked.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt.point['x'] = stacked.x()(evt.point);\n        evt.point['y'] = stacked.y()(evt.point);\n        tooltip.data(evt).hidden(false);\n    });\n\n    stacked.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true)\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.stacked = stacked;\n    chart.legend = legend;\n    chart.controls = controls;\n    chart.xAxis = xAxis;\n    chart.yAxis = yAxis;\n    chart.interactiveLayer = interactiveLayer;\n    chart.tooltip = tooltip;\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}},\n        showXAxis:      {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}},\n        showYAxis:    {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}},\n        defaultState:    {get: function(){return defaultState;}, set: function(_){defaultState=_;}},\n        noData:    {get: function(){return noData;}, set: function(_){noData=_;}},\n        showControls:    {get: function(){return showControls;}, set: function(_){showControls=_;}},\n        controlLabels:    {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}},\n        controlOptions:    {get: function(){return controlOptions;}, set: function(_){controlOptions=_;}},\n        showTotalInTooltip:      {get: function(){return showTotalInTooltip;}, set: function(_){showTotalInTooltip=_;}},\n        totalLabel:      {get: function(){return totalLabel;}, set: function(_){totalLabel=_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            stacked.duration(duration);\n            xAxis.duration(duration);\n            yAxis.duration(duration);\n        }},\n        color:  {get: function(){return color;}, set: function(_){\n            color = nv.utils.getColor(_);\n            legend.color(color);\n            stacked.color(color);\n        }},\n        rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){\n            rightAlignYAxis = _;\n            yAxis.orient( rightAlignYAxis ? 'right' : 'left');\n        }},\n        useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){\n            useInteractiveGuideline = !!_;\n            chart.interactive(!_);\n            chart.useVoronoi(!_);\n            stacked.scatter.interactive(!_);\n        }}\n    });\n\n    nv.utils.inheritOptions(chart, stacked);\n    nv.utils.initOptions(chart);\n\n    return chart;\n};\n// based on http://bl.ocks.org/kerryrodden/477c1bfb081b783f80ad\nnv.models.sunburst = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var margin = {top: 0, right: 0, bottom: 0, left: 0}\n        , width = null\n        , height = null\n        , mode = \"count\"\n        , modes = {count: function(d) { return 1; }, size: function(d) { return d.size }}\n        , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one\n        , container = null\n        , color = nv.utils.defaultColor()\n        , groupColorByParent = true\n        , duration = 500\n        , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMousemove', 'elementMouseover', 'elementMouseout', 'renderEnd')\n        ;\n\n    var x = d3.scale.linear().range([0, 2 * Math.PI]);\n    var y = d3.scale.sqrt();\n\n    var partition = d3.layout.partition()\n        .sort(null)\n        .value(function(d) { return 1; });\n\n    var arc = d3.svg.arc()\n        .startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x))); })\n        .endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))); })\n        .innerRadius(function(d) { return Math.max(0, y(d.y)); })\n        .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });\n\n    // Keep track of the current and previous node being displayed as the root.\n    var node, prevNode;\n    // Keep track of the root node\n    var rootNode;\n\n    //============================================================\n    // chart function\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n\n    function chart(selection) {\n        renderWatch.reset();\n        selection.each(function(data) {\n            container = d3.select(this);\n            var availableWidth = nv.utils.availableWidth(width, container, margin);\n            var availableHeight = nv.utils.availableHeight(height, container, margin);\n            var radius = Math.min(availableWidth, availableHeight) / 2;\n            var path;\n\n            nv.utils.initSVG(container);\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('.nv-wrap.nv-sunburst').data(data);\n            var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sunburst nv-chart-' + id);\n\n            var g = wrapEnter.selectAll('nv-sunburst');\n\n            chart.update = function() { \n                if ( duration === 0 ) {\n                    container.call(chart);\n                } else {\n                    container.transition().duration(duration).call(chart);\n                }\n            };\n            chart.container = this;\n\n\n            wrap.attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')');\n\n            container.on('click', function (d, i) {\n                dispatch.chartClick({\n                    data: d,\n                    index: i,\n                    pos: d3.event,\n                    id: id\n                });\n            });\n\n            y.range([0, radius]);\n\n            node = node || data;\n            rootNode = data[0];\n            partition.value(modes[mode] || modes[\"count\"]);\n            path = g.data(partition.nodes).enter()\n                .append(\"path\")\n                .attr(\"d\", arc)\n                .style(\"fill\", function (d) {\n                    if (d.color) {\n                        return d.color;\n                    }\n                    else if (groupColorByParent) {\n                        return color((d.children ? d : d.parent).name);\n                    }\n                    else {\n                        return color(d.name);\n                    }\n                })\n                .style(\"stroke\", \"#FFF\")\n                .on(\"click\", function(d) {\n                    if (prevNode !== node && node !== d) prevNode = node;\n                    node = d;\n                    path.transition()\n                        .duration(duration)\n                        .attrTween(\"d\", arcTweenZoom(d));\n                })\n                .each(stash)\n                .on(\"dblclick\", function(d) {\n                    if (prevNode.parent == d) {\n                        path.transition()\n                            .duration(duration)\n                            .attrTween(\"d\", arcTweenZoom(rootNode));\n                    }\n                })\n                .each(stash)\n                .on('mouseover', function(d,i){\n                    d3.select(this).classed('hover', true).style('opacity', 0.8);\n                    dispatch.elementMouseover({\n                        data: d,\n                        color: d3.select(this).style(\"fill\")\n                    });\n                })\n                .on('mouseout', function(d,i){\n                    d3.select(this).classed('hover', false).style('opacity', 1);\n                    dispatch.elementMouseout({\n                        data: d\n                    });\n                })\n                .on('mousemove', function(d,i){\n                    dispatch.elementMousemove({\n                        data: d\n                    });\n                });\n\n\n\n            // Setup for switching data: stash the old values for transition.\n            function stash(d) {\n                d.x0 = d.x;\n                d.dx0 = d.dx;\n            }\n\n            // When switching data: interpolate the arcs in data space.\n            function arcTweenData(a, i) {\n                var oi = d3.interpolate({x: a.x0, dx: a.dx0}, a);\n\n                function tween(t) {\n                    var b = oi(t);\n                    a.x0 = b.x;\n                    a.dx0 = b.dx;\n                    return arc(b);\n                }\n\n                if (i == 0) {\n                    // If we are on the first arc, adjust the x domain to match the root node\n                    // at the current zoom level. (We only need to do this once.)\n                    var xd = d3.interpolate(x.domain(), [node.x, node.x + node.dx]);\n                    return function (t) {\n                        x.domain(xd(t));\n                        return tween(t);\n                    };\n                } else {\n                    return tween;\n                }\n            }\n\n            // When zooming: interpolate the scales.\n            function arcTweenZoom(d) {\n                var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),\n                    yd = d3.interpolate(y.domain(), [d.y, 1]),\n                    yr = d3.interpolate(y.range(), [d.y ? 20 : 0, radius]);\n                return function (d, i) {\n                    return i\n                        ? function (t) {\n                        return arc(d);\n                    }\n                        : function (t) {\n                        x.domain(xd(t));\n                        y.domain(yd(t)).range(yr(t));\n                        return arc(d);\n                    };\n                };\n            }\n\n        });\n\n        renderWatch.renderEnd('sunburst immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    chart.dispatch = dispatch;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        width:      {get: function(){return width;}, set: function(_){width=_;}},\n        height:     {get: function(){return height;}, set: function(_){height=_;}},\n        mode:       {get: function(){return mode;}, set: function(_){mode=_;}},\n        id:         {get: function(){return id;}, set: function(_){id=_;}},\n        duration:   {get: function(){return duration;}, set: function(_){duration=_;}},\n        groupColorByParent: {get: function(){return groupColorByParent;}, set: function(_){groupColorByParent=!!_;}},\n\n        // options that require extra logic in the setter\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    != undefined ? _.top    : margin.top;\n            margin.right  = _.right  != undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   != undefined ? _.left   : margin.left;\n        }},\n        color: {get: function(){return color;}, set: function(_){\n            color=nv.utils.getColor(_);\n        }}\n    });\n\n    nv.utils.initOptions(chart);\n    return chart;\n};\nnv.models.sunburstChart = function() {\n    \"use strict\";\n\n    //============================================================\n    // Public Variables with Default Settings\n    //------------------------------------------------------------\n\n    var sunburst = nv.models.sunburst();\n    var tooltip = nv.models.tooltip();\n\n    var margin = {top: 30, right: 20, bottom: 20, left: 20}\n        , width = null\n        , height = null\n        , color = nv.utils.defaultColor()\n        , id = Math.round(Math.random() * 100000)\n        , defaultState = null\n        , noData = null\n        , duration = 250\n        , dispatch = d3.dispatch('stateChange', 'changeState','renderEnd')\n        ;\n\n    tooltip.duration(0);\n\n    //============================================================\n    // Private Variables\n    //------------------------------------------------------------\n\n    var renderWatch = nv.utils.renderWatch(dispatch);\n    tooltip\n        .headerEnabled(false)\n        .valueFormatter(function(d, i) {\n            return d;\n        });\n\n    //============================================================\n    // Chart function\n    //------------------------------------------------------------\n\n    function chart(selection) {\n        renderWatch.reset();\n        renderWatch.models(sunburst);\n\n        selection.each(function(data) {\n            var container = d3.select(this);\n            nv.utils.initSVG(container);\n\n            var that = this;\n            var availableWidth = nv.utils.availableWidth(width, container, margin),\n                availableHeight = nv.utils.availableHeight(height, container, margin);\n\n            chart.update = function() {\n                if (duration === 0) {\n                    container.call(chart);\n                } else {\n                    container.transition().duration(duration).call(chart);\n                }\n            };\n            chart.container = this;\n\n            // Display No Data message if there's nothing to show.\n            if (!data || !data.length) {\n                nv.utils.noData(chart, container);\n                return chart;\n            } else {\n                container.selectAll('.nv-noData').remove();\n            }\n\n            // Setup containers and skeleton of chart\n            var wrap = container.selectAll('g.nv-wrap.nv-sunburstChart').data(data);\n            var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sunburstChart').append('g');\n            var g = wrap.select('g');\n\n            gEnter.append('g').attr('class', 'nv-sunburstWrap');\n\n            wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');\n\n            // Main Chart Component(s)\n            sunburst.width(availableWidth).height(availableHeight);\n            var sunWrap = g.select('.nv-sunburstWrap').datum(data);\n            d3.transition(sunWrap).call(sunburst);\n\n        });\n\n        renderWatch.renderEnd('sunburstChart immediate');\n        return chart;\n    }\n\n    //============================================================\n    // Event Handling/Dispatching (out of chart's scope)\n    //------------------------------------------------------------\n\n    sunburst.dispatch.on('elementMouseover.tooltip', function(evt) {\n        evt['series'] = {\n            key: evt.data.name,\n            value: evt.data.size,\n            color: evt.color\n        };\n        tooltip.data(evt).hidden(false);\n    });\n\n    sunburst.dispatch.on('elementMouseout.tooltip', function(evt) {\n        tooltip.hidden(true);\n    });\n\n    sunburst.dispatch.on('elementMousemove.tooltip', function(evt) {\n        tooltip();\n    });\n\n    //============================================================\n    // Expose Public Variables\n    //------------------------------------------------------------\n\n    // expose chart's sub-components\n    chart.dispatch = dispatch;\n    chart.sunburst = sunburst;\n    chart.tooltip = tooltip;\n    chart.options = nv.utils.optionsFunc.bind(chart);\n\n    // use Object get/set functionality to map between vars and chart functions\n    chart._options = Object.create({}, {\n        // simple options, just get/set the necessary values\n        noData:         {get: function(){return noData;},         set: function(_){noData=_;}},\n        defaultState:   {get: function(){return defaultState;},   set: function(_){defaultState=_;}},\n\n        // options that require extra logic in the setter\n        color: {get: function(){return color;}, set: function(_){\n            color = _;\n            sunburst.color(color);\n        }},\n        duration: {get: function(){return duration;}, set: function(_){\n            duration = _;\n            renderWatch.reset(duration);\n            sunburst.duration(duration);\n        }},\n        margin: {get: function(){return margin;}, set: function(_){\n            margin.top    = _.top    !== undefined ? _.top    : margin.top;\n            margin.right  = _.right  !== undefined ? _.right  : margin.right;\n            margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom;\n            margin.left   = _.left   !== undefined ? _.left   : margin.left;\n        }}\n    });\n    nv.utils.inheritOptions(chart, sunburst);\n    nv.utils.initOptions(chart);\n    return chart;\n};\n\nnv.version = \"1.8.2\";\n})();"
  },
  {
    "path": "html/lib/seiyria-bootstrap-slider/bootstrap-slider.css",
    "content": "/*! =======================================================\n                      VERSION  6.1.8              \n========================================================= */\n/*! =========================================================\n * bootstrap-slider.js\n *\n * Maintainers:\n *\t\tKyle Kemp\n *\t\t\t- Twitter: @seiyria\n *\t\t\t- Github:  seiyria\n *\t\tRohit Kalkur\n *\t\t\t- Twitter: @Rovolutionary\n *\t\t\t- Github:  rovolution\n *\n * =========================================================\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ========================================================= */\n.slider {\n  display: inline-block;\n  vertical-align: middle;\n  position: relative;\n}\n.slider.slider-horizontal {\n  width: 210px;\n  height: 20px;\n}\n.slider.slider-horizontal .slider-track {\n  height: 10px;\n  width: 100%;\n  margin-top: -5px;\n  top: 50%;\n  left: 0;\n}\n.slider.slider-horizontal .slider-selection,\n.slider.slider-horizontal .slider-track-low,\n.slider.slider-horizontal .slider-track-high {\n  height: 100%;\n  top: 0;\n  bottom: 0;\n}\n.slider.slider-horizontal .slider-tick,\n.slider.slider-horizontal .slider-handle {\n  margin-left: -10px;\n  margin-top: -5px;\n}\n.slider.slider-horizontal .slider-tick.triangle,\n.slider.slider-horizontal .slider-handle.triangle {\n  border-width: 0 10px 10px 10px;\n  width: 0;\n  height: 0;\n  border-bottom-color: #0480be;\n  margin-top: 0;\n}\n.slider.slider-horizontal .slider-tick-label-container {\n  white-space: nowrap;\n  margin-top: 20px;\n}\n.slider.slider-horizontal .slider-tick-label-container .slider-tick-label {\n  padding-top: 4px;\n  display: inline-block;\n  text-align: center;\n}\n.slider.slider-vertical {\n  height: 210px;\n  width: 20px;\n}\n.slider.slider-vertical .slider-track {\n  width: 10px;\n  height: 100%;\n  margin-left: -5px;\n  left: 50%;\n  top: 0;\n}\n.slider.slider-vertical .slider-selection {\n  width: 100%;\n  left: 0;\n  top: 0;\n  bottom: 0;\n}\n.slider.slider-vertical .slider-track-low,\n.slider.slider-vertical .slider-track-high {\n  width: 100%;\n  left: 0;\n  right: 0;\n}\n.slider.slider-vertical .slider-tick,\n.slider.slider-vertical .slider-handle {\n  margin-left: -5px;\n  margin-top: -10px;\n}\n.slider.slider-vertical .slider-tick.triangle,\n.slider.slider-vertical .slider-handle.triangle {\n  border-width: 10px 0 10px 10px;\n  width: 1px;\n  height: 1px;\n  border-left-color: #0480be;\n  margin-left: 0;\n}\n.slider.slider-vertical .slider-tick-label-container {\n  white-space: nowrap;\n}\n.slider.slider-vertical .slider-tick-label-container .slider-tick-label {\n  padding-left: 4px;\n}\n.slider.slider-disabled .slider-handle {\n  background-image: -webkit-linear-gradient(top, #dfdfdf 0%, #bebebe 100%);\n  background-image: -o-linear-gradient(top, #dfdfdf 0%, #bebebe 100%);\n  background-image: linear-gradient(to bottom, #dfdfdf 0%, #bebebe 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdfdfdf', endColorstr='#ffbebebe', GradientType=0);\n}\n.slider.slider-disabled .slider-track {\n  background-image: -webkit-linear-gradient(top, #e5e5e5 0%, #e9e9e9 100%);\n  background-image: -o-linear-gradient(top, #e5e5e5 0%, #e9e9e9 100%);\n  background-image: linear-gradient(to bottom, #e5e5e5 0%, #e9e9e9 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe5e5e5', endColorstr='#ffe9e9e9', GradientType=0);\n  cursor: not-allowed;\n}\n.slider input {\n  display: none;\n}\n.slider .tooltip.top {\n  margin-top: -36px;\n}\n.slider .tooltip-inner {\n  white-space: nowrap;\n  max-width: none;\n}\n.slider .hide {\n  display: none;\n}\n.slider-track {\n  position: absolute;\n  cursor: pointer;\n  background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #f9f9f9 100%);\n  background-image: -o-linear-gradient(top, #f5f5f5 0%, #f9f9f9 100%);\n  background-image: linear-gradient(to bottom, #f5f5f5 0%, #f9f9f9 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#fff9f9f9', GradientType=0);\n  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);\n  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);\n  border-radius: 4px;\n}\n.slider-selection {\n  position: absolute;\n  background-image: -webkit-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%);\n  background-image: -o-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%);\n  background-image: linear-gradient(to bottom, #f9f9f9 0%, #f5f5f5 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9', endColorstr='#fff5f5f5', GradientType=0);\n  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);\n  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n  border-radius: 4px;\n}\n.slider-selection.tick-slider-selection {\n  background-image: -webkit-linear-gradient(top, #89cdef 0%, #81bfde 100%);\n  background-image: -o-linear-gradient(top, #89cdef 0%, #81bfde 100%);\n  background-image: linear-gradient(to bottom, #89cdef 0%, #81bfde 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff89cdef', endColorstr='#ff81bfde', GradientType=0);\n}\n.slider-track-low,\n.slider-track-high {\n  position: absolute;\n  background: transparent;\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n  border-radius: 4px;\n}\n.slider-handle {\n  position: absolute;\n  width: 20px;\n  height: 20px;\n  background-color: #337ab7;\n  background-image: -webkit-linear-gradient(top, #149bdf 0%, #0480be 100%);\n  background-image: -o-linear-gradient(top, #149bdf 0%, #0480be 100%);\n  background-image: linear-gradient(to bottom, #149bdf 0%, #0480be 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf', endColorstr='#ff0480be', GradientType=0);\n  filter: none;\n  -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);\n  border: 0px solid transparent;\n}\n.slider-handle.round {\n  border-radius: 50%;\n}\n.slider-handle.triangle {\n  background: transparent none;\n}\n.slider-handle.custom {\n  background: transparent none;\n}\n.slider-handle.custom::before {\n  line-height: 20px;\n  font-size: 20px;\n  content: '\\2605';\n  color: #726204;\n}\n.slider-tick {\n  position: absolute;\n  width: 20px;\n  height: 20px;\n  background-image: -webkit-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%);\n  background-image: -o-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%);\n  background-image: linear-gradient(to bottom, #f9f9f9 0%, #f5f5f5 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9', endColorstr='#fff5f5f5', GradientType=0);\n  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);\n  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n  filter: none;\n  opacity: 0.8;\n  border: 0px solid transparent;\n}\n.slider-tick.round {\n  border-radius: 50%;\n}\n.slider-tick.triangle {\n  background: transparent none;\n}\n.slider-tick.custom {\n  background: transparent none;\n}\n.slider-tick.custom::before {\n  line-height: 20px;\n  font-size: 20px;\n  content: '\\2605';\n  color: #726204;\n}\n.slider-tick.in-selection {\n  background-image: -webkit-linear-gradient(top, #89cdef 0%, #81bfde 100%);\n  background-image: -o-linear-gradient(top, #89cdef 0%, #81bfde 100%);\n  background-image: linear-gradient(to bottom, #89cdef 0%, #81bfde 100%);\n  background-repeat: repeat-x;\n  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff89cdef', endColorstr='#ff81bfde', GradientType=0);\n  opacity: 1;\n}\n"
  },
  {
    "path": "html/lib/seiyria-bootstrap-slider/bootstrap-slider.js",
    "content": "/*! =======================================================\n                      VERSION  6.1.8              \n========================================================= */\n\"use strict\";\n\nfunction _typeof(obj) { return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; }\n\n/*! =========================================================\n * bootstrap-slider.js\n *\n * Maintainers:\n *\t\tKyle Kemp\n *\t\t\t- Twitter: @seiyria\n *\t\t\t- Github:  seiyria\n *\t\tRohit Kalkur\n *\t\t\t- Twitter: @Rovolutionary\n *\t\t\t- Github:  rovolution\n *\n * =========================================================\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ========================================================= */\n\n/**\n * Bridget makes jQuery widgets\n * v1.0.1\n * MIT license\n */\n\n(function (factory) {\n\tif (typeof define === \"function\" && define.amd) {\n\t\tdefine([\"jquery\"], factory);\n\t} else if ((typeof module === \"undefined\" ? \"undefined\" : _typeof(module)) === \"object\" && module.exports) {\n\t\tvar jQuery;\n\t\ttry {\n\t\t\tjQuery = require(\"jquery\");\n\t\t} catch (err) {\n\t\t\tjQuery = null;\n\t\t}\n\t\tmodule.exports = factory(jQuery);\n\t} else if (window) {\n\t\twindow.Slider = factory(window.jQuery);\n\t}\n})(function ($) {\n\t// Reference to Slider constructor\n\tvar Slider;\n\n\t(function ($) {\n\n\t\t'use strict';\n\n\t\t// -------------------------- utils -------------------------- //\n\n\t\tvar slice = Array.prototype.slice;\n\n\t\tfunction noop() {}\n\n\t\t// -------------------------- definition -------------------------- //\n\n\t\tfunction defineBridget($) {\n\n\t\t\t// bail if no jQuery\n\t\t\tif (!$) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// -------------------------- addOptionMethod -------------------------- //\n\n\t\t\t/**\n    * adds option method -> $().plugin('option', {...})\n    * @param {Function} PluginClass - constructor class\n    */\n\t\t\tfunction addOptionMethod(PluginClass) {\n\t\t\t\t// don't overwrite original option method\n\t\t\t\tif (PluginClass.prototype.option) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// option setter\n\t\t\t\tPluginClass.prototype.option = function (opts) {\n\t\t\t\t\t// bail out if not an object\n\t\t\t\t\tif (!$.isPlainObject(opts)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis.options = $.extend(true, this.options, opts);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// -------------------------- plugin bridge -------------------------- //\n\n\t\t\t// helper function for logging errors\n\t\t\t// $.error breaks jQuery chaining\n\t\t\tvar logError = typeof console === 'undefined' ? noop : function (message) {\n\t\t\t\tconsole.error(message);\n\t\t\t};\n\n\t\t\t/**\n    * jQuery plugin bridge, access methods like $elem.plugin('method')\n    * @param {String} namespace - plugin name\n    * @param {Function} PluginClass - constructor class\n    */\n\t\t\tfunction bridge(namespace, PluginClass) {\n\t\t\t\t// add to jQuery fn namespace\n\t\t\t\t$.fn[namespace] = function (options) {\n\t\t\t\t\tif (typeof options === 'string') {\n\t\t\t\t\t\t// call plugin method when first argument is a string\n\t\t\t\t\t\t// get arguments for method\n\t\t\t\t\t\tvar args = slice.call(arguments, 1);\n\n\t\t\t\t\t\tfor (var i = 0, len = this.length; i < len; i++) {\n\t\t\t\t\t\t\tvar elem = this[i];\n\t\t\t\t\t\t\tvar instance = $.data(elem, namespace);\n\t\t\t\t\t\t\tif (!instance) {\n\t\t\t\t\t\t\t\tlogError(\"cannot call methods on \" + namespace + \" prior to initialization; \" + \"attempted to call '\" + options + \"'\");\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!$.isFunction(instance[options]) || options.charAt(0) === '_') {\n\t\t\t\t\t\t\t\tlogError(\"no such method '\" + options + \"' for \" + namespace + \" instance\");\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// trigger method with arguments\n\t\t\t\t\t\t\tvar returnValue = instance[options].apply(instance, args);\n\n\t\t\t\t\t\t\t// break look and return first value if provided\n\t\t\t\t\t\t\tif (returnValue !== undefined && returnValue !== instance) {\n\t\t\t\t\t\t\t\treturn returnValue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// return this if no return value\n\t\t\t\t\t\treturn this;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar objects = this.map(function () {\n\t\t\t\t\t\t\tvar instance = $.data(this, namespace);\n\t\t\t\t\t\t\tif (instance) {\n\t\t\t\t\t\t\t\t// apply options & init\n\t\t\t\t\t\t\t\tinstance.option(options);\n\t\t\t\t\t\t\t\tinstance._init();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// initialize new instance\n\t\t\t\t\t\t\t\tinstance = new PluginClass(this, options);\n\t\t\t\t\t\t\t\t$.data(this, namespace, instance);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn $(this);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!objects || objects.length > 1) {\n\t\t\t\t\t\t\treturn objects;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn objects[0];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// -------------------------- bridget -------------------------- //\n\n\t\t\t/**\n    * converts a Prototypical class into a proper jQuery plugin\n    *   the class must have a ._init method\n    * @param {String} namespace - plugin name, used in $().pluginName\n    * @param {Function} PluginClass - constructor class\n    */\n\t\t\t$.bridget = function (namespace, PluginClass) {\n\t\t\t\taddOptionMethod(PluginClass);\n\t\t\t\tbridge(namespace, PluginClass);\n\t\t\t};\n\n\t\t\treturn $.bridget;\n\t\t}\n\n\t\t// get jquery from browser global\n\t\tdefineBridget($);\n\t})($);\n\n\t/*************************************************\n \t\t\tBOOTSTRAP-SLIDER SOURCE CODE\n \t**************************************************/\n\n\t(function ($) {\n\n\t\tvar ErrorMsgs = {\n\t\t\tformatInvalidInputErrorMsg: function formatInvalidInputErrorMsg(input) {\n\t\t\t\treturn \"Invalid input value '\" + input + \"' passed in\";\n\t\t\t},\n\t\t\tcallingContextNotSliderInstance: \"Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method\"\n\t\t};\n\n\t\tvar SliderScale = {\n\t\t\tlinear: {\n\t\t\t\ttoValue: function toValue(percentage) {\n\t\t\t\t\tvar rawValue = percentage / 100 * (this.options.max - this.options.min);\n\t\t\t\t\tvar shouldAdjustWithBase = true;\n\t\t\t\t\tif (this.options.ticks_positions.length > 0) {\n\t\t\t\t\t\tvar minv,\n\t\t\t\t\t\t    maxv,\n\t\t\t\t\t\t    minp,\n\t\t\t\t\t\t    maxp = 0;\n\t\t\t\t\t\tfor (var i = 1; i < this.options.ticks_positions.length; i++) {\n\t\t\t\t\t\t\tif (percentage <= this.options.ticks_positions[i]) {\n\t\t\t\t\t\t\t\tminv = this.options.ticks[i - 1];\n\t\t\t\t\t\t\t\tminp = this.options.ticks_positions[i - 1];\n\t\t\t\t\t\t\t\tmaxv = this.options.ticks[i];\n\t\t\t\t\t\t\t\tmaxp = this.options.ticks_positions[i];\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar partialPercentage = (percentage - minp) / (maxp - minp);\n\t\t\t\t\t\trawValue = minv + partialPercentage * (maxv - minv);\n\t\t\t\t\t\tshouldAdjustWithBase = false;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar adjustment = shouldAdjustWithBase ? this.options.min : 0;\n\t\t\t\t\tvar value = adjustment + Math.round(rawValue / this.options.step) * this.options.step;\n\t\t\t\t\tif (value < this.options.min) {\n\t\t\t\t\t\treturn this.options.min;\n\t\t\t\t\t} else if (value > this.options.max) {\n\t\t\t\t\t\treturn this.options.max;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\ttoPercentage: function toPercentage(value) {\n\t\t\t\t\tif (this.options.max === this.options.min) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.options.ticks_positions.length > 0) {\n\t\t\t\t\t\tvar minv,\n\t\t\t\t\t\t    maxv,\n\t\t\t\t\t\t    minp,\n\t\t\t\t\t\t    maxp = 0;\n\t\t\t\t\t\tfor (var i = 0; i < this.options.ticks.length; i++) {\n\t\t\t\t\t\t\tif (value <= this.options.ticks[i]) {\n\t\t\t\t\t\t\t\tminv = i > 0 ? this.options.ticks[i - 1] : 0;\n\t\t\t\t\t\t\t\tminp = i > 0 ? this.options.ticks_positions[i - 1] : 0;\n\t\t\t\t\t\t\t\tmaxv = this.options.ticks[i];\n\t\t\t\t\t\t\t\tmaxp = this.options.ticks_positions[i];\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (i > 0) {\n\t\t\t\t\t\t\tvar partialPercentage = (value - minv) / (maxv - minv);\n\t\t\t\t\t\t\treturn minp + partialPercentage * (maxp - minp);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn 100 * (value - this.options.min) / (this.options.max - this.options.min);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tlogarithmic: {\n\t\t\t\t/* Based on http://stackoverflow.com/questions/846221/logarithmic-slider */\n\t\t\t\ttoValue: function toValue(percentage) {\n\t\t\t\t\tvar min = this.options.min === 0 ? 0 : Math.log(this.options.min);\n\t\t\t\t\tvar max = Math.log(this.options.max);\n\t\t\t\t\tvar value = Math.exp(min + (max - min) * percentage / 100);\n\t\t\t\t\tvalue = this.options.min + Math.round((value - this.options.min) / this.options.step) * this.options.step;\n\t\t\t\t\t/* Rounding to the nearest step could exceed the min or\n      * max, so clip to those values. */\n\t\t\t\t\tif (value < this.options.min) {\n\t\t\t\t\t\treturn this.options.min;\n\t\t\t\t\t} else if (value > this.options.max) {\n\t\t\t\t\t\treturn this.options.max;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\ttoPercentage: function toPercentage(value) {\n\t\t\t\t\tif (this.options.max === this.options.min) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar max = Math.log(this.options.max);\n\t\t\t\t\t\tvar min = this.options.min === 0 ? 0 : Math.log(this.options.min);\n\t\t\t\t\t\tvar v = value === 0 ? 0 : Math.log(value);\n\t\t\t\t\t\treturn 100 * (v - min) / (max - min);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t/*************************************************\n  \t\t\t\t\t\tCONSTRUCTOR\n  \t**************************************************/\n\t\tSlider = function (element, options) {\n\t\t\tcreateNewSlider.call(this, element, options);\n\t\t\treturn this;\n\t\t};\n\n\t\tfunction createNewSlider(element, options) {\n\n\t\t\t/*\n   \tThe internal state object is used to store data about the current 'state' of slider.\n   \t\tThis includes values such as the `value`, `enabled`, etc...\n   */\n\t\t\tthis._state = {\n\t\t\t\tvalue: null,\n\t\t\t\tenabled: null,\n\t\t\t\toffset: null,\n\t\t\t\tsize: null,\n\t\t\t\tpercentage: null,\n\t\t\t\tinDrag: false,\n\t\t\t\tover: false\n\t\t\t};\n\n\t\t\tif (typeof element === \"string\") {\n\t\t\t\tthis.element = document.querySelector(element);\n\t\t\t} else if (element instanceof HTMLElement) {\n\t\t\t\tthis.element = element;\n\t\t\t}\n\n\t\t\t/*************************************************\n   \t\t\t\t\tProcess Options\n   \t**************************************************/\n\t\t\toptions = options ? options : {};\n\t\t\tvar optionTypes = Object.keys(this.defaultOptions);\n\n\t\t\tfor (var i = 0; i < optionTypes.length; i++) {\n\t\t\t\tvar optName = optionTypes[i];\n\n\t\t\t\t// First check if an option was passed in via the constructor\n\t\t\t\tvar val = options[optName];\n\t\t\t\t// If no data attrib, then check data atrributes\n\t\t\t\tval = typeof val !== 'undefined' ? val : getDataAttrib(this.element, optName);\n\t\t\t\t// Finally, if nothing was specified, use the defaults\n\t\t\t\tval = val !== null ? val : this.defaultOptions[optName];\n\n\t\t\t\t// Set all options on the instance of the Slider\n\t\t\t\tif (!this.options) {\n\t\t\t\t\tthis.options = {};\n\t\t\t\t}\n\t\t\t\tthis.options[optName] = val;\n\t\t\t}\n\n\t\t\t/*\n   \tValidate `tooltip_position` against 'orientation`\n   \t- if `tooltip_position` is incompatible with orientation, swith it to a default compatible with specified `orientation`\n   \t\t-- default for \"vertical\" -> \"right\"\n   \t\t-- default for \"horizontal\" -> \"left\"\n   */\n\t\t\tif (this.options.orientation === \"vertical\" && (this.options.tooltip_position === \"top\" || this.options.tooltip_position === \"bottom\")) {\n\n\t\t\t\tthis.options.tooltip_position = \"right\";\n\t\t\t} else if (this.options.orientation === \"horizontal\" && (this.options.tooltip_position === \"left\" || this.options.tooltip_position === \"right\")) {\n\n\t\t\t\tthis.options.tooltip_position = \"top\";\n\t\t\t}\n\n\t\t\tfunction getDataAttrib(element, optName) {\n\t\t\t\tvar dataName = \"data-slider-\" + optName.replace(/_/g, '-');\n\t\t\t\tvar dataValString = element.getAttribute(dataName);\n\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(dataValString);\n\t\t\t\t} catch (err) {\n\t\t\t\t\treturn dataValString;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/*************************************************\n   \t\t\t\t\tCreate Markup\n   \t**************************************************/\n\n\t\t\tvar origWidth = this.element.style.width;\n\t\t\tvar updateSlider = false;\n\t\t\tvar parent = this.element.parentNode;\n\t\t\tvar sliderTrackSelection;\n\t\t\tvar sliderTrackLow, sliderTrackHigh;\n\t\t\tvar sliderMinHandle;\n\t\t\tvar sliderMaxHandle;\n\n\t\t\tif (this.sliderElem) {\n\t\t\t\tupdateSlider = true;\n\t\t\t} else {\n\t\t\t\t/* Create elements needed for slider */\n\t\t\t\tthis.sliderElem = document.createElement(\"div\");\n\t\t\t\tthis.sliderElem.className = \"slider\";\n\n\t\t\t\t/* Create slider track elements */\n\t\t\t\tvar sliderTrack = document.createElement(\"div\");\n\t\t\t\tsliderTrack.className = \"slider-track\";\n\n\t\t\t\tsliderTrackLow = document.createElement(\"div\");\n\t\t\t\tsliderTrackLow.className = \"slider-track-low\";\n\n\t\t\t\tsliderTrackSelection = document.createElement(\"div\");\n\t\t\t\tsliderTrackSelection.className = \"slider-selection\";\n\n\t\t\t\tsliderTrackHigh = document.createElement(\"div\");\n\t\t\t\tsliderTrackHigh.className = \"slider-track-high\";\n\n\t\t\t\tsliderMinHandle = document.createElement(\"div\");\n\t\t\t\tsliderMinHandle.className = \"slider-handle min-slider-handle\";\n\t\t\t\tsliderMinHandle.setAttribute('role', 'slider');\n\t\t\t\tsliderMinHandle.setAttribute('aria-valuemin', this.options.min);\n\t\t\t\tsliderMinHandle.setAttribute('aria-valuemax', this.options.max);\n\n\t\t\t\tsliderMaxHandle = document.createElement(\"div\");\n\t\t\t\tsliderMaxHandle.className = \"slider-handle max-slider-handle\";\n\t\t\t\tsliderMaxHandle.setAttribute('role', 'slider');\n\t\t\t\tsliderMaxHandle.setAttribute('aria-valuemin', this.options.min);\n\t\t\t\tsliderMaxHandle.setAttribute('aria-valuemax', this.options.max);\n\n\t\t\t\tsliderTrack.appendChild(sliderTrackLow);\n\t\t\t\tsliderTrack.appendChild(sliderTrackSelection);\n\t\t\t\tsliderTrack.appendChild(sliderTrackHigh);\n\n\t\t\t\t/* Add aria-labelledby to handle's */\n\t\t\t\tvar isLabelledbyArray = Array.isArray(this.options.labelledby);\n\t\t\t\tif (isLabelledbyArray && this.options.labelledby[0]) {\n\t\t\t\t\tsliderMinHandle.setAttribute('aria-labelledby', this.options.labelledby[0]);\n\t\t\t\t}\n\t\t\t\tif (isLabelledbyArray && this.options.labelledby[1]) {\n\t\t\t\t\tsliderMaxHandle.setAttribute('aria-labelledby', this.options.labelledby[1]);\n\t\t\t\t}\n\t\t\t\tif (!isLabelledbyArray && this.options.labelledby) {\n\t\t\t\t\tsliderMinHandle.setAttribute('aria-labelledby', this.options.labelledby);\n\t\t\t\t\tsliderMaxHandle.setAttribute('aria-labelledby', this.options.labelledby);\n\t\t\t\t}\n\n\t\t\t\t/* Create ticks */\n\t\t\t\tthis.ticks = [];\n\t\t\t\tif (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {\n\t\t\t\t\tfor (i = 0; i < this.options.ticks.length; i++) {\n\t\t\t\t\t\tvar tick = document.createElement('div');\n\t\t\t\t\t\ttick.className = 'slider-tick';\n\n\t\t\t\t\t\tthis.ticks.push(tick);\n\t\t\t\t\t\tsliderTrack.appendChild(tick);\n\t\t\t\t\t}\n\n\t\t\t\t\tsliderTrackSelection.className += \" tick-slider-selection\";\n\t\t\t\t}\n\n\t\t\t\tsliderTrack.appendChild(sliderMinHandle);\n\t\t\t\tsliderTrack.appendChild(sliderMaxHandle);\n\n\t\t\t\tthis.tickLabels = [];\n\t\t\t\tif (Array.isArray(this.options.ticks_labels) && this.options.ticks_labels.length > 0) {\n\t\t\t\t\tthis.tickLabelContainer = document.createElement('div');\n\t\t\t\t\tthis.tickLabelContainer.className = 'slider-tick-label-container';\n\n\t\t\t\t\tfor (i = 0; i < this.options.ticks_labels.length; i++) {\n\t\t\t\t\t\tvar label = document.createElement('div');\n\t\t\t\t\t\tvar noTickPositionsSpecified = this.options.ticks_positions.length === 0;\n\t\t\t\t\t\tvar tickLabelsIndex = this.options.reversed && noTickPositionsSpecified ? this.options.ticks_labels.length - (i + 1) : i;\n\t\t\t\t\t\tlabel.className = 'slider-tick-label';\n\t\t\t\t\t\tlabel.innerHTML = this.options.ticks_labels[tickLabelsIndex];\n\n\t\t\t\t\t\tthis.tickLabels.push(label);\n\t\t\t\t\t\tthis.tickLabelContainer.appendChild(label);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar createAndAppendTooltipSubElements = function createAndAppendTooltipSubElements(tooltipElem) {\n\t\t\t\t\tvar arrow = document.createElement(\"div\");\n\t\t\t\t\tarrow.className = \"tooltip-arrow\";\n\n\t\t\t\t\tvar inner = document.createElement(\"div\");\n\t\t\t\t\tinner.className = \"tooltip-inner\";\n\n\t\t\t\t\ttooltipElem.appendChild(arrow);\n\t\t\t\t\ttooltipElem.appendChild(inner);\n\t\t\t\t};\n\n\t\t\t\t/* Create tooltip elements */\n\t\t\t\tvar sliderTooltip = document.createElement(\"div\");\n\t\t\t\tsliderTooltip.className = \"tooltip tooltip-main\";\n\t\t\t\tsliderTooltip.setAttribute('role', 'presentation');\n\t\t\t\tcreateAndAppendTooltipSubElements(sliderTooltip);\n\n\t\t\t\tvar sliderTooltipMin = document.createElement(\"div\");\n\t\t\t\tsliderTooltipMin.className = \"tooltip tooltip-min\";\n\t\t\t\tsliderTooltipMin.setAttribute('role', 'presentation');\n\t\t\t\tcreateAndAppendTooltipSubElements(sliderTooltipMin);\n\n\t\t\t\tvar sliderTooltipMax = document.createElement(\"div\");\n\t\t\t\tsliderTooltipMax.className = \"tooltip tooltip-max\";\n\t\t\t\tsliderTooltipMax.setAttribute('role', 'presentation');\n\t\t\t\tcreateAndAppendTooltipSubElements(sliderTooltipMax);\n\n\t\t\t\t/* Append components to sliderElem */\n\t\t\t\tthis.sliderElem.appendChild(sliderTrack);\n\t\t\t\tthis.sliderElem.appendChild(sliderTooltip);\n\t\t\t\tthis.sliderElem.appendChild(sliderTooltipMin);\n\t\t\t\tthis.sliderElem.appendChild(sliderTooltipMax);\n\n\t\t\t\tif (this.tickLabelContainer) {\n\t\t\t\t\tthis.sliderElem.appendChild(this.tickLabelContainer);\n\t\t\t\t}\n\n\t\t\t\t/* Append slider element to parent container, right before the original <input> element */\n\t\t\t\tparent.insertBefore(this.sliderElem, this.element);\n\n\t\t\t\t/* Hide original <input> element */\n\t\t\t\tthis.element.style.display = \"none\";\n\t\t\t}\n\t\t\t/* If JQuery exists, cache JQ references */\n\t\t\tif ($) {\n\t\t\t\tthis.$element = $(this.element);\n\t\t\t\tthis.$sliderElem = $(this.sliderElem);\n\t\t\t}\n\n\t\t\t/*************************************************\n   \t\t\t\t\t\tSetup\n   \t**************************************************/\n\t\t\tthis.eventToCallbackMap = {};\n\t\t\tthis.sliderElem.id = this.options.id;\n\n\t\t\tthis.touchCapable = 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch;\n\n\t\t\tthis.touchX = 0;\n\t\t\tthis.touchY = 0;\n\n\t\t\tthis.tooltip = this.sliderElem.querySelector('.tooltip-main');\n\t\t\tthis.tooltipInner = this.tooltip.querySelector('.tooltip-inner');\n\n\t\t\tthis.tooltip_min = this.sliderElem.querySelector('.tooltip-min');\n\t\t\tthis.tooltipInner_min = this.tooltip_min.querySelector('.tooltip-inner');\n\n\t\t\tthis.tooltip_max = this.sliderElem.querySelector('.tooltip-max');\n\t\t\tthis.tooltipInner_max = this.tooltip_max.querySelector('.tooltip-inner');\n\n\t\t\tif (SliderScale[this.options.scale]) {\n\t\t\t\tthis.options.scale = SliderScale[this.options.scale];\n\t\t\t}\n\n\t\t\tif (updateSlider === true) {\n\t\t\t\t// Reset classes\n\t\t\t\tthis._removeClass(this.sliderElem, 'slider-horizontal');\n\t\t\t\tthis._removeClass(this.sliderElem, 'slider-vertical');\n\t\t\t\tthis._removeClass(this.tooltip, 'hide');\n\t\t\t\tthis._removeClass(this.tooltip_min, 'hide');\n\t\t\t\tthis._removeClass(this.tooltip_max, 'hide');\n\n\t\t\t\t// Undo existing inline styles for track\n\t\t\t\t[\"left\", \"top\", \"width\", \"height\"].forEach(function (prop) {\n\t\t\t\t\tthis._removeProperty(this.trackLow, prop);\n\t\t\t\t\tthis._removeProperty(this.trackSelection, prop);\n\t\t\t\t\tthis._removeProperty(this.trackHigh, prop);\n\t\t\t\t}, this);\n\n\t\t\t\t// Undo inline styles on handles\n\t\t\t\t[this.handle1, this.handle2].forEach(function (handle) {\n\t\t\t\t\tthis._removeProperty(handle, 'left');\n\t\t\t\t\tthis._removeProperty(handle, 'top');\n\t\t\t\t}, this);\n\n\t\t\t\t// Undo inline styles and classes on tooltips\n\t\t\t\t[this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function (tooltip) {\n\t\t\t\t\tthis._removeProperty(tooltip, 'left');\n\t\t\t\t\tthis._removeProperty(tooltip, 'top');\n\t\t\t\t\tthis._removeProperty(tooltip, 'margin-left');\n\t\t\t\t\tthis._removeProperty(tooltip, 'margin-top');\n\n\t\t\t\t\tthis._removeClass(tooltip, 'right');\n\t\t\t\t\tthis._removeClass(tooltip, 'top');\n\t\t\t\t}, this);\n\t\t\t}\n\n\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\tthis._addClass(this.sliderElem, 'slider-vertical');\n\t\t\t\tthis.stylePos = 'top';\n\t\t\t\tthis.mousePos = 'pageY';\n\t\t\t\tthis.sizePos = 'offsetHeight';\n\t\t\t} else {\n\t\t\t\tthis._addClass(this.sliderElem, 'slider-horizontal');\n\t\t\t\tthis.sliderElem.style.width = origWidth;\n\t\t\t\tthis.options.orientation = 'horizontal';\n\t\t\t\tthis.stylePos = 'left';\n\t\t\t\tthis.mousePos = 'pageX';\n\t\t\t\tthis.sizePos = 'offsetWidth';\n\t\t\t}\n\t\t\tthis._setTooltipPosition();\n\t\t\t/* In case ticks are specified, overwrite the min and max bounds */\n\t\t\tif (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {\n\t\t\t\tthis.options.max = Math.max.apply(Math, this.options.ticks);\n\t\t\t\tthis.options.min = Math.min.apply(Math, this.options.ticks);\n\t\t\t}\n\n\t\t\tif (Array.isArray(this.options.value)) {\n\t\t\t\tthis.options.range = true;\n\t\t\t\tthis._state.value = this.options.value;\n\t\t\t} else if (this.options.range) {\n\t\t\t\t// User wants a range, but value is not an array\n\t\t\t\tthis._state.value = [this.options.value, this.options.max];\n\t\t\t} else {\n\t\t\t\tthis._state.value = this.options.value;\n\t\t\t}\n\n\t\t\tthis.trackLow = sliderTrackLow || this.trackLow;\n\t\t\tthis.trackSelection = sliderTrackSelection || this.trackSelection;\n\t\t\tthis.trackHigh = sliderTrackHigh || this.trackHigh;\n\n\t\t\tif (this.options.selection === 'none') {\n\t\t\t\tthis._addClass(this.trackLow, 'hide');\n\t\t\t\tthis._addClass(this.trackSelection, 'hide');\n\t\t\t\tthis._addClass(this.trackHigh, 'hide');\n\t\t\t}\n\n\t\t\tthis.handle1 = sliderMinHandle || this.handle1;\n\t\t\tthis.handle2 = sliderMaxHandle || this.handle2;\n\n\t\t\tif (updateSlider === true) {\n\t\t\t\t// Reset classes\n\t\t\t\tthis._removeClass(this.handle1, 'round triangle');\n\t\t\t\tthis._removeClass(this.handle2, 'round triangle hide');\n\n\t\t\t\tfor (i = 0; i < this.ticks.length; i++) {\n\t\t\t\t\tthis._removeClass(this.ticks[i], 'round triangle hide');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar availableHandleModifiers = ['round', 'triangle', 'custom'];\n\t\t\tvar isValidHandleType = availableHandleModifiers.indexOf(this.options.handle) !== -1;\n\t\t\tif (isValidHandleType) {\n\t\t\t\tthis._addClass(this.handle1, this.options.handle);\n\t\t\t\tthis._addClass(this.handle2, this.options.handle);\n\n\t\t\t\tfor (i = 0; i < this.ticks.length; i++) {\n\t\t\t\t\tthis._addClass(this.ticks[i], this.options.handle);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._state.offset = this._offset(this.sliderElem);\n\t\t\tthis._state.size = this.sliderElem[this.sizePos];\n\t\t\tthis.setValue(this._state.value);\n\n\t\t\t/******************************************\n   \t\t\t\tBind Event Listeners\n   \t******************************************/\n\n\t\t\t// Bind keyboard handlers\n\t\t\tthis.handle1Keydown = this._keydown.bind(this, 0);\n\t\t\tthis.handle1.addEventListener(\"keydown\", this.handle1Keydown, false);\n\n\t\t\tthis.handle2Keydown = this._keydown.bind(this, 1);\n\t\t\tthis.handle2.addEventListener(\"keydown\", this.handle2Keydown, false);\n\n\t\t\tthis.mousedown = this._mousedown.bind(this);\n\t\t\tthis.touchstart = this._touchstart.bind(this);\n\t\t\tthis.touchmove = this._touchmove.bind(this);\n\n\t\t\tif (this.touchCapable) {\n\t\t\t\t// Bind touch handlers\n\t\t\t\tthis.sliderElem.addEventListener(\"touchstart\", this.touchstart, false);\n\t\t\t\tthis.sliderElem.addEventListener(\"touchmove\", this.touchmove, false);\n\t\t\t}\n\t\t\tthis.sliderElem.addEventListener(\"mousedown\", this.mousedown, false);\n\n\t\t\t// Bind window handlers\n\t\t\tthis.resize = this._resize.bind(this);\n\t\t\twindow.addEventListener(\"resize\", this.resize, false);\n\n\t\t\t// Bind tooltip-related handlers\n\t\t\tif (this.options.tooltip === 'hide') {\n\t\t\t\tthis._addClass(this.tooltip, 'hide');\n\t\t\t\tthis._addClass(this.tooltip_min, 'hide');\n\t\t\t\tthis._addClass(this.tooltip_max, 'hide');\n\t\t\t} else if (this.options.tooltip === 'always') {\n\t\t\t\tthis._showTooltip();\n\t\t\t\tthis._alwaysShowTooltip = true;\n\t\t\t} else {\n\t\t\t\tthis.showTooltip = this._showTooltip.bind(this);\n\t\t\t\tthis.hideTooltip = this._hideTooltip.bind(this);\n\n\t\t\t\tthis.sliderElem.addEventListener(\"mouseenter\", this.showTooltip, false);\n\t\t\t\tthis.sliderElem.addEventListener(\"mouseleave\", this.hideTooltip, false);\n\n\t\t\t\tthis.handle1.addEventListener(\"focus\", this.showTooltip, false);\n\t\t\t\tthis.handle1.addEventListener(\"blur\", this.hideTooltip, false);\n\n\t\t\t\tthis.handle2.addEventListener(\"focus\", this.showTooltip, false);\n\t\t\t\tthis.handle2.addEventListener(\"blur\", this.hideTooltip, false);\n\t\t\t}\n\n\t\t\tif (this.options.enabled) {\n\t\t\t\tthis.enable();\n\t\t\t} else {\n\t\t\t\tthis.disable();\n\t\t\t}\n\t\t}\n\n\t\t/*************************************************\n  \t\t\t\tINSTANCE PROPERTIES/METHODS\n  \t- Any methods bound to the prototype are considered\n  part of the plugin's `public` interface\n  \t**************************************************/\n\t\tSlider.prototype = {\n\t\t\t_init: function _init() {}, // NOTE: Must exist to support bridget\n\n\t\t\tconstructor: Slider,\n\n\t\t\tdefaultOptions: {\n\t\t\t\tid: \"\",\n\t\t\t\tmin: 0,\n\t\t\t\tmax: 10,\n\t\t\t\tstep: 1,\n\t\t\t\tprecision: 0,\n\t\t\t\torientation: 'horizontal',\n\t\t\t\tvalue: 5,\n\t\t\t\trange: false,\n\t\t\t\tselection: 'before',\n\t\t\t\ttooltip: 'show',\n\t\t\t\ttooltip_split: false,\n\t\t\t\thandle: 'round',\n\t\t\t\treversed: false,\n\t\t\t\tenabled: true,\n\t\t\t\tformatter: function formatter(val) {\n\t\t\t\t\tif (Array.isArray(val)) {\n\t\t\t\t\t\treturn val[0] + \" : \" + val[1];\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn val;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tnatural_arrow_keys: false,\n\t\t\t\tticks: [],\n\t\t\t\tticks_positions: [],\n\t\t\t\tticks_labels: [],\n\t\t\t\tticks_snap_bounds: 0,\n\t\t\t\tscale: 'linear',\n\t\t\t\tfocus: false,\n\t\t\t\ttooltip_position: null,\n\t\t\t\tlabelledby: null\n\t\t\t},\n\n\t\t\tgetElement: function getElement() {\n\t\t\t\treturn this.sliderElem;\n\t\t\t},\n\n\t\t\tgetValue: function getValue() {\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\treturn this._state.value;\n\t\t\t\t} else {\n\t\t\t\t\treturn this._state.value[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tsetValue: function setValue(val, triggerSlideEvent, triggerChangeEvent) {\n\t\t\t\tif (!val) {\n\t\t\t\t\tval = 0;\n\t\t\t\t}\n\t\t\t\tvar oldValue = this.getValue();\n\t\t\t\tthis._state.value = this._validateInputValue(val);\n\t\t\t\tvar applyPrecision = this._applyPrecision.bind(this);\n\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tthis._state.value[0] = applyPrecision(this._state.value[0]);\n\t\t\t\t\tthis._state.value[1] = applyPrecision(this._state.value[1]);\n\n\t\t\t\t\tthis._state.value[0] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[0]));\n\t\t\t\t\tthis._state.value[1] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[1]));\n\t\t\t\t} else {\n\t\t\t\t\tthis._state.value = applyPrecision(this._state.value);\n\t\t\t\t\tthis._state.value = [Math.max(this.options.min, Math.min(this.options.max, this._state.value))];\n\t\t\t\t\tthis._addClass(this.handle2, 'hide');\n\t\t\t\t\tif (this.options.selection === 'after') {\n\t\t\t\t\t\tthis._state.value[1] = this.options.max;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._state.value[1] = this.options.min;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.options.max > this.options.min) {\n\t\t\t\t\tthis._state.percentage = [this._toPercentage(this._state.value[0]), this._toPercentage(this._state.value[1]), this.options.step * 100 / (this.options.max - this.options.min)];\n\t\t\t\t} else {\n\t\t\t\t\tthis._state.percentage = [0, 0, 100];\n\t\t\t\t}\n\n\t\t\t\tthis._layout();\n\t\t\t\tvar newValue = this.options.range ? this._state.value : this._state.value[0];\n\n\t\t\t\tthis._setDataVal(newValue);\n\t\t\t\tif (triggerSlideEvent === true) {\n\t\t\t\t\tthis._trigger('slide', newValue);\n\t\t\t\t}\n\t\t\t\tif (oldValue !== newValue && triggerChangeEvent === true) {\n\t\t\t\t\tthis._trigger('change', {\n\t\t\t\t\t\toldValue: oldValue,\n\t\t\t\t\t\tnewValue: newValue\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\tdestroy: function destroy() {\n\t\t\t\t// Remove event handlers on slider elements\n\t\t\t\tthis._removeSliderEventHandlers();\n\n\t\t\t\t// Remove the slider from the DOM\n\t\t\t\tthis.sliderElem.parentNode.removeChild(this.sliderElem);\n\t\t\t\t/* Show original <input> element */\n\t\t\t\tthis.element.style.display = \"\";\n\n\t\t\t\t// Clear out custom event bindings\n\t\t\t\tthis._cleanUpEventCallbacksMap();\n\n\t\t\t\t// Remove data values\n\t\t\t\tthis.element.removeAttribute(\"data\");\n\n\t\t\t\t// Remove JQuery handlers/data\n\t\t\t\tif ($) {\n\t\t\t\t\tthis._unbindJQueryEventHandlers();\n\t\t\t\t\tthis.$element.removeData('slider');\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tdisable: function disable() {\n\t\t\t\tthis._state.enabled = false;\n\t\t\t\tthis.handle1.removeAttribute(\"tabindex\");\n\t\t\t\tthis.handle2.removeAttribute(\"tabindex\");\n\t\t\t\tthis._addClass(this.sliderElem, 'slider-disabled');\n\t\t\t\tthis._trigger('slideDisabled');\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\tenable: function enable() {\n\t\t\t\tthis._state.enabled = true;\n\t\t\t\tthis.handle1.setAttribute(\"tabindex\", 0);\n\t\t\t\tthis.handle2.setAttribute(\"tabindex\", 0);\n\t\t\t\tthis._removeClass(this.sliderElem, 'slider-disabled');\n\t\t\t\tthis._trigger('slideEnabled');\n\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\ttoggle: function toggle() {\n\t\t\t\tif (this._state.enabled) {\n\t\t\t\t\tthis.disable();\n\t\t\t\t} else {\n\t\t\t\t\tthis.enable();\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\tisEnabled: function isEnabled() {\n\t\t\t\treturn this._state.enabled;\n\t\t\t},\n\n\t\t\ton: function on(evt, callback) {\n\t\t\t\tthis._bindNonQueryEventHandler(evt, callback);\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\toff: function off(evt, callback) {\n\t\t\t\tif ($) {\n\t\t\t\t\tthis.$element.off(evt, callback);\n\t\t\t\t\tthis.$sliderElem.off(evt, callback);\n\t\t\t\t} else {\n\t\t\t\t\tthis._unbindNonQueryEventHandler(evt, callback);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tgetAttribute: function getAttribute(attribute) {\n\t\t\t\tif (attribute) {\n\t\t\t\t\treturn this.options[attribute];\n\t\t\t\t} else {\n\t\t\t\t\treturn this.options;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tsetAttribute: function setAttribute(attribute, value) {\n\t\t\t\tthis.options[attribute] = value;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\trefresh: function refresh() {\n\t\t\t\tthis._removeSliderEventHandlers();\n\t\t\t\tcreateNewSlider.call(this, this.element, this.options);\n\t\t\t\tif ($) {\n\t\t\t\t\t// Bind new instance of slider to the element\n\t\t\t\t\t$.data(this.element, 'slider', this);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\trelayout: function relayout() {\n\t\t\t\tthis._resize();\n\t\t\t\tthis._layout();\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t/******************************+\n   \t\t\t\tHELPERS\n   \t- Any method that is not part of the public interface.\n   - Place it underneath this comment block and write its signature like so:\n   \t  \t\t\t\t\t_fnName : function() {...}\n   \t********************************/\n\t\t\t_removeSliderEventHandlers: function _removeSliderEventHandlers() {\n\t\t\t\t// Remove keydown event listeners\n\t\t\t\tthis.handle1.removeEventListener(\"keydown\", this.handle1Keydown, false);\n\t\t\t\tthis.handle2.removeEventListener(\"keydown\", this.handle2Keydown, false);\n\n\t\t\t\tif (this.showTooltip) {\n\t\t\t\t\tthis.handle1.removeEventListener(\"focus\", this.showTooltip, false);\n\t\t\t\t\tthis.handle2.removeEventListener(\"focus\", this.showTooltip, false);\n\t\t\t\t}\n\t\t\t\tif (this.hideTooltip) {\n\t\t\t\t\tthis.handle1.removeEventListener(\"blur\", this.hideTooltip, false);\n\t\t\t\t\tthis.handle2.removeEventListener(\"blur\", this.hideTooltip, false);\n\t\t\t\t}\n\n\t\t\t\t// Remove event listeners from sliderElem\n\t\t\t\tif (this.showTooltip) {\n\t\t\t\t\tthis.sliderElem.removeEventListener(\"mouseenter\", this.showTooltip, false);\n\t\t\t\t}\n\t\t\t\tif (this.hideTooltip) {\n\t\t\t\t\tthis.sliderElem.removeEventListener(\"mouseleave\", this.hideTooltip, false);\n\t\t\t\t}\n\t\t\t\tthis.sliderElem.removeEventListener(\"touchstart\", this.touchstart, false);\n\t\t\t\tthis.sliderElem.removeEventListener(\"touchmove\", this.touchmove, false);\n\t\t\t\tthis.sliderElem.removeEventListener(\"mousedown\", this.mousedown, false);\n\n\t\t\t\t// Remove window event listener\n\t\t\t\twindow.removeEventListener(\"resize\", this.resize, false);\n\t\t\t},\n\t\t\t_bindNonQueryEventHandler: function _bindNonQueryEventHandler(evt, callback) {\n\t\t\t\tif (this.eventToCallbackMap[evt] === undefined) {\n\t\t\t\t\tthis.eventToCallbackMap[evt] = [];\n\t\t\t\t}\n\t\t\t\tthis.eventToCallbackMap[evt].push(callback);\n\t\t\t},\n\t\t\t_unbindNonQueryEventHandler: function _unbindNonQueryEventHandler(evt, callback) {\n\t\t\t\tvar callbacks = this.eventToCallbackMap[evt];\n\t\t\t\tif (callbacks !== undefined) {\n\t\t\t\t\tfor (var i = 0; i < callbacks.length; i++) {\n\t\t\t\t\t\tif (callbacks[i] === callback) {\n\t\t\t\t\t\t\tcallbacks.splice(i, 1);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t_cleanUpEventCallbacksMap: function _cleanUpEventCallbacksMap() {\n\t\t\t\tvar eventNames = Object.keys(this.eventToCallbackMap);\n\t\t\t\tfor (var i = 0; i < eventNames.length; i++) {\n\t\t\t\t\tvar eventName = eventNames[i];\n\t\t\t\t\tthis.eventToCallbackMap[eventName] = null;\n\t\t\t\t}\n\t\t\t},\n\t\t\t_showTooltip: function _showTooltip() {\n\t\t\t\tif (this.options.tooltip_split === false) {\n\t\t\t\t\tthis._addClass(this.tooltip, 'in');\n\t\t\t\t\tthis.tooltip_min.style.display = 'none';\n\t\t\t\t\tthis.tooltip_max.style.display = 'none';\n\t\t\t\t} else {\n\t\t\t\t\tthis._addClass(this.tooltip_min, 'in');\n\t\t\t\t\tthis._addClass(this.tooltip_max, 'in');\n\t\t\t\t\tthis.tooltip.style.display = 'none';\n\t\t\t\t}\n\t\t\t\tthis._state.over = true;\n\t\t\t},\n\t\t\t_hideTooltip: function _hideTooltip() {\n\t\t\t\tif (this._state.inDrag === false && this.alwaysShowTooltip !== true) {\n\t\t\t\t\tthis._removeClass(this.tooltip, 'in');\n\t\t\t\t\tthis._removeClass(this.tooltip_min, 'in');\n\t\t\t\t\tthis._removeClass(this.tooltip_max, 'in');\n\t\t\t\t}\n\t\t\t\tthis._state.over = false;\n\t\t\t},\n\t\t\t_layout: function _layout() {\n\t\t\t\tvar positionPercentages;\n\n\t\t\t\tif (this.options.reversed) {\n\t\t\t\t\tpositionPercentages = [100 - this._state.percentage[0], this.options.range ? 100 - this._state.percentage[1] : this._state.percentage[1]];\n\t\t\t\t} else {\n\t\t\t\t\tpositionPercentages = [this._state.percentage[0], this._state.percentage[1]];\n\t\t\t\t}\n\n\t\t\t\tthis.handle1.style[this.stylePos] = positionPercentages[0] + '%';\n\t\t\t\tthis.handle1.setAttribute('aria-valuenow', this._state.value[0]);\n\n\t\t\t\tthis.handle2.style[this.stylePos] = positionPercentages[1] + '%';\n\t\t\t\tthis.handle2.setAttribute('aria-valuenow', this._state.value[1]);\n\n\t\t\t\t/* Position ticks and labels */\n\t\t\t\tif (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {\n\n\t\t\t\t\tvar styleSize = this.options.orientation === 'vertical' ? 'height' : 'width';\n\t\t\t\t\tvar styleMargin = this.options.orientation === 'vertical' ? 'marginTop' : 'marginLeft';\n\t\t\t\t\tvar labelSize = this._state.size / (this.options.ticks.length - 1);\n\n\t\t\t\t\tif (this.tickLabelContainer) {\n\t\t\t\t\t\tvar extraMargin = 0;\n\t\t\t\t\t\tif (this.options.ticks_positions.length === 0) {\n\t\t\t\t\t\t\tif (this.options.orientation !== 'vertical') {\n\t\t\t\t\t\t\t\tthis.tickLabelContainer.style[styleMargin] = -labelSize / 2 + 'px';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\textraMargin = this.tickLabelContainer.offsetHeight;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t/* Chidren are position absolute, calculate height by finding the max offsetHeight of a child */\n\t\t\t\t\t\t\tfor (i = 0; i < this.tickLabelContainer.childNodes.length; i++) {\n\t\t\t\t\t\t\t\tif (this.tickLabelContainer.childNodes[i].offsetHeight > extraMargin) {\n\t\t\t\t\t\t\t\t\textraMargin = this.tickLabelContainer.childNodes[i].offsetHeight;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.options.orientation === 'horizontal') {\n\t\t\t\t\t\t\tthis.sliderElem.style.marginBottom = extraMargin + 'px';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (var i = 0; i < this.options.ticks.length; i++) {\n\n\t\t\t\t\t\tvar percentage = this.options.ticks_positions[i] || this._toPercentage(this.options.ticks[i]);\n\n\t\t\t\t\t\tif (this.options.reversed) {\n\t\t\t\t\t\t\tpercentage = 100 - percentage;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.ticks[i].style[this.stylePos] = percentage + '%';\n\n\t\t\t\t\t\t/* Set class labels to denote whether ticks are in the selection */\n\t\t\t\t\t\tthis._removeClass(this.ticks[i], 'in-selection');\n\t\t\t\t\t\tif (!this.options.range) {\n\t\t\t\t\t\t\tif (this.options.selection === 'after' && percentage >= positionPercentages[0]) {\n\t\t\t\t\t\t\t\tthis._addClass(this.ticks[i], 'in-selection');\n\t\t\t\t\t\t\t} else if (this.options.selection === 'before' && percentage <= positionPercentages[0]) {\n\t\t\t\t\t\t\t\tthis._addClass(this.ticks[i], 'in-selection');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (percentage >= positionPercentages[0] && percentage <= positionPercentages[1]) {\n\t\t\t\t\t\t\tthis._addClass(this.ticks[i], 'in-selection');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.tickLabels[i]) {\n\t\t\t\t\t\t\tthis.tickLabels[i].style[styleSize] = labelSize + 'px';\n\n\t\t\t\t\t\t\tif (this.options.orientation !== 'vertical' && this.options.ticks_positions[i] !== undefined) {\n\t\t\t\t\t\t\t\tthis.tickLabels[i].style.position = 'absolute';\n\t\t\t\t\t\t\t\tthis.tickLabels[i].style[this.stylePos] = percentage + '%';\n\t\t\t\t\t\t\t\tthis.tickLabels[i].style[styleMargin] = -labelSize / 2 + 'px';\n\t\t\t\t\t\t\t} else if (this.options.orientation === 'vertical') {\n\t\t\t\t\t\t\t\tthis.tickLabels[i].style['marginLeft'] = this.sliderElem.offsetWidth + 'px';\n\t\t\t\t\t\t\t\tthis.tickLabelContainer.style['marginTop'] = this.sliderElem.offsetWidth / 2 * -1 + 'px';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar formattedTooltipVal;\n\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tformattedTooltipVal = this.options.formatter(this._state.value);\n\t\t\t\t\tthis._setText(this.tooltipInner, formattedTooltipVal);\n\t\t\t\t\tthis.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + '%';\n\n\t\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');\n\t\t\t\t\t}\n\n\t\t\t\t\tvar innerTooltipMinText = this.options.formatter(this._state.value[0]);\n\t\t\t\t\tthis._setText(this.tooltipInner_min, innerTooltipMinText);\n\n\t\t\t\t\tvar innerTooltipMaxText = this.options.formatter(this._state.value[1]);\n\t\t\t\t\tthis._setText(this.tooltipInner_max, innerTooltipMaxText);\n\n\t\t\t\t\tthis.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%';\n\n\t\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\t\tthis._css(this.tooltip_min, 'margin-top', -this.tooltip_min.offsetHeight / 2 + 'px');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._css(this.tooltip_min, 'margin-left', -this.tooltip_min.offsetWidth / 2 + 'px');\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.tooltip_max.style[this.stylePos] = positionPercentages[1] + '%';\n\n\t\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\t\tthis._css(this.tooltip_max, 'margin-top', -this.tooltip_max.offsetHeight / 2 + 'px');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tformattedTooltipVal = this.options.formatter(this._state.value[0]);\n\t\t\t\t\tthis._setText(this.tooltipInner, formattedTooltipVal);\n\n\t\t\t\t\tthis.tooltip.style[this.stylePos] = positionPercentages[0] + '%';\n\t\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\tthis.trackLow.style.top = '0';\n\t\t\t\t\tthis.trackLow.style.height = Math.min(positionPercentages[0], positionPercentages[1]) + '%';\n\n\t\t\t\t\tthis.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) + '%';\n\t\t\t\t\tthis.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';\n\n\t\t\t\t\tthis.trackHigh.style.bottom = '0';\n\t\t\t\t\tthis.trackHigh.style.height = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';\n\t\t\t\t} else {\n\t\t\t\t\tthis.trackLow.style.left = '0';\n\t\t\t\t\tthis.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) + '%';\n\n\t\t\t\t\tthis.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%';\n\t\t\t\t\tthis.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';\n\n\t\t\t\t\tthis.trackHigh.style.right = '0';\n\t\t\t\t\tthis.trackHigh.style.width = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%';\n\n\t\t\t\t\tvar offset_min = this.tooltip_min.getBoundingClientRect();\n\t\t\t\t\tvar offset_max = this.tooltip_max.getBoundingClientRect();\n\n\t\t\t\t\tif (this.options.tooltip_position === 'bottom') {\n\t\t\t\t\t\tif (offset_min.right > offset_max.left) {\n\t\t\t\t\t\t\tthis._removeClass(this.tooltip_max, 'bottom');\n\t\t\t\t\t\t\tthis._addClass(this.tooltip_max, 'top');\n\t\t\t\t\t\t\tthis.tooltip_max.style.top = '';\n\t\t\t\t\t\t\tthis.tooltip_max.style.bottom = 22 + 'px';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._removeClass(this.tooltip_max, 'top');\n\t\t\t\t\t\t\tthis._addClass(this.tooltip_max, 'bottom');\n\t\t\t\t\t\t\tthis.tooltip_max.style.top = this.tooltip_min.style.top;\n\t\t\t\t\t\t\tthis.tooltip_max.style.bottom = '';\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (offset_min.right > offset_max.left) {\n\t\t\t\t\t\t\tthis._removeClass(this.tooltip_max, 'top');\n\t\t\t\t\t\t\tthis._addClass(this.tooltip_max, 'bottom');\n\t\t\t\t\t\t\tthis.tooltip_max.style.top = 18 + 'px';\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._removeClass(this.tooltip_max, 'bottom');\n\t\t\t\t\t\t\tthis._addClass(this.tooltip_max, 'top');\n\t\t\t\t\t\t\tthis.tooltip_max.style.top = this.tooltip_min.style.top;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t_resize: function _resize(ev) {\n\t\t\t\t/*jshint unused:false*/\n\t\t\t\tthis._state.offset = this._offset(this.sliderElem);\n\t\t\t\tthis._state.size = this.sliderElem[this.sizePos];\n\t\t\t\tthis._layout();\n\t\t\t},\n\t\t\t_removeProperty: function _removeProperty(element, prop) {\n\t\t\t\tif (element.style.removeProperty) {\n\t\t\t\t\telement.style.removeProperty(prop);\n\t\t\t\t} else {\n\t\t\t\t\telement.style.removeAttribute(prop);\n\t\t\t\t}\n\t\t\t},\n\t\t\t_mousedown: function _mousedown(ev) {\n\t\t\t\tif (!this._state.enabled) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthis._state.offset = this._offset(this.sliderElem);\n\t\t\t\tthis._state.size = this.sliderElem[this.sizePos];\n\n\t\t\t\tvar percentage = this._getPercentage(ev);\n\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tvar diff1 = Math.abs(this._state.percentage[0] - percentage);\n\t\t\t\t\tvar diff2 = Math.abs(this._state.percentage[1] - percentage);\n\t\t\t\t\tthis._state.dragged = diff1 < diff2 ? 0 : 1;\n\t\t\t\t} else {\n\t\t\t\t\tthis._state.dragged = 0;\n\t\t\t\t}\n\n\t\t\t\tthis._state.percentage[this._state.dragged] = percentage;\n\t\t\t\tthis._layout();\n\n\t\t\t\tif (this.touchCapable) {\n\t\t\t\t\tdocument.removeEventListener(\"touchmove\", this.mousemove, false);\n\t\t\t\t\tdocument.removeEventListener(\"touchend\", this.mouseup, false);\n\t\t\t\t}\n\n\t\t\t\tif (this.mousemove) {\n\t\t\t\t\tdocument.removeEventListener(\"mousemove\", this.mousemove, false);\n\t\t\t\t}\n\t\t\t\tif (this.mouseup) {\n\t\t\t\t\tdocument.removeEventListener(\"mouseup\", this.mouseup, false);\n\t\t\t\t}\n\n\t\t\t\tthis.mousemove = this._mousemove.bind(this);\n\t\t\t\tthis.mouseup = this._mouseup.bind(this);\n\n\t\t\t\tif (this.touchCapable) {\n\t\t\t\t\t// Touch: Bind touch events:\n\t\t\t\t\tdocument.addEventListener(\"touchmove\", this.mousemove, false);\n\t\t\t\t\tdocument.addEventListener(\"touchend\", this.mouseup, false);\n\t\t\t\t}\n\t\t\t\t// Bind mouse events:\n\t\t\t\tdocument.addEventListener(\"mousemove\", this.mousemove, false);\n\t\t\t\tdocument.addEventListener(\"mouseup\", this.mouseup, false);\n\n\t\t\t\tthis._state.inDrag = true;\n\t\t\t\tvar newValue = this._calculateValue();\n\n\t\t\t\tthis._trigger('slideStart', newValue);\n\n\t\t\t\tthis._setDataVal(newValue);\n\t\t\t\tthis.setValue(newValue, false, true);\n\n\t\t\t\tthis._pauseEvent(ev);\n\n\t\t\t\tif (this.options.focus) {\n\t\t\t\t\tthis._triggerFocusOnHandle(this._state.dragged);\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\t_touchstart: function _touchstart(ev) {\n\t\t\t\tif (ev.changedTouches === undefined) {\n\t\t\t\t\tthis._mousedown(ev);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar touch = ev.changedTouches[0];\n\t\t\t\tthis.touchX = touch.pageX;\n\t\t\t\tthis.touchY = touch.pageY;\n\t\t\t},\n\t\t\t_triggerFocusOnHandle: function _triggerFocusOnHandle(handleIdx) {\n\t\t\t\tif (handleIdx === 0) {\n\t\t\t\t\tthis.handle1.focus();\n\t\t\t\t}\n\t\t\t\tif (handleIdx === 1) {\n\t\t\t\t\tthis.handle2.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\t_keydown: function _keydown(handleIdx, ev) {\n\t\t\t\tif (!this._state.enabled) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tvar dir;\n\t\t\t\tswitch (ev.keyCode) {\n\t\t\t\t\tcase 37: // left\n\t\t\t\t\tcase 40:\n\t\t\t\t\t\t// down\n\t\t\t\t\t\tdir = -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 39: // right\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\t// up\n\t\t\t\t\t\tdir = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!dir) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// use natural arrow keys instead of from min to max\n\t\t\t\tif (this.options.natural_arrow_keys) {\n\t\t\t\t\tvar ifVerticalAndNotReversed = this.options.orientation === 'vertical' && !this.options.reversed;\n\t\t\t\t\tvar ifHorizontalAndReversed = this.options.orientation === 'horizontal' && this.options.reversed;\n\n\t\t\t\t\tif (ifVerticalAndNotReversed || ifHorizontalAndReversed) {\n\t\t\t\t\t\tdir = -dir;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar val = this._state.value[handleIdx] + dir * this.options.step;\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tval = [!handleIdx ? val : this._state.value[0], handleIdx ? val : this._state.value[1]];\n\t\t\t\t}\n\n\t\t\t\tthis._trigger('slideStart', val);\n\t\t\t\tthis._setDataVal(val);\n\t\t\t\tthis.setValue(val, true, true);\n\n\t\t\t\tthis._setDataVal(val);\n\t\t\t\tthis._trigger('slideStop', val);\n\t\t\t\tthis._layout();\n\n\t\t\t\tthis._pauseEvent(ev);\n\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\t_pauseEvent: function _pauseEvent(ev) {\n\t\t\t\tif (ev.stopPropagation) {\n\t\t\t\t\tev.stopPropagation();\n\t\t\t\t}\n\t\t\t\tif (ev.preventDefault) {\n\t\t\t\t\tev.preventDefault();\n\t\t\t\t}\n\t\t\t\tev.cancelBubble = true;\n\t\t\t\tev.returnValue = false;\n\t\t\t},\n\t\t\t_mousemove: function _mousemove(ev) {\n\t\t\t\tif (!this._state.enabled) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tvar percentage = this._getPercentage(ev);\n\t\t\t\tthis._adjustPercentageForRangeSliders(percentage);\n\t\t\t\tthis._state.percentage[this._state.dragged] = percentage;\n\t\t\t\tthis._layout();\n\n\t\t\t\tvar val = this._calculateValue(true);\n\t\t\t\tthis.setValue(val, true, true);\n\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\t_touchmove: function _touchmove(ev) {\n\t\t\t\tif (ev.changedTouches === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar touch = ev.changedTouches[0];\n\n\t\t\t\tvar xDiff = touch.pageX - this.touchX;\n\t\t\t\tvar yDiff = touch.pageY - this.touchY;\n\n\t\t\t\tif (!this._state.inDrag) {\n\t\t\t\t\t// Vertical Slider\n\t\t\t\t\tif (this.options.orientation === 'vertical' && xDiff <= 5 && xDiff >= -5 && (yDiff >= 15 || yDiff <= -15)) {\n\t\t\t\t\t\tthis._mousedown(ev);\n\t\t\t\t\t}\n\t\t\t\t\t// Horizontal slider.\n\t\t\t\t\telse if (yDiff <= 5 && yDiff >= -5 && (xDiff >= 15 || xDiff <= -15)) {\n\t\t\t\t\t\t\tthis._mousedown(ev);\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t_adjustPercentageForRangeSliders: function _adjustPercentageForRangeSliders(percentage) {\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tvar precision = this._getNumDigitsAfterDecimalPlace(percentage);\n\t\t\t\t\tprecision = precision ? precision - 1 : 0;\n\t\t\t\t\tvar percentageWithAdjustedPrecision = this._applyToFixedAndParseFloat(percentage, precision);\n\t\t\t\t\tif (this._state.dragged === 0 && this._applyToFixedAndParseFloat(this._state.percentage[1], precision) < percentageWithAdjustedPrecision) {\n\t\t\t\t\t\tthis._state.percentage[0] = this._state.percentage[1];\n\t\t\t\t\t\tthis._state.dragged = 1;\n\t\t\t\t\t} else if (this._state.dragged === 1 && this._applyToFixedAndParseFloat(this._state.percentage[0], precision) > percentageWithAdjustedPrecision) {\n\t\t\t\t\t\tthis._state.percentage[1] = this._state.percentage[0];\n\t\t\t\t\t\tthis._state.dragged = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t_mouseup: function _mouseup() {\n\t\t\t\tif (!this._state.enabled) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this.touchCapable) {\n\t\t\t\t\t// Touch: Unbind touch event handlers:\n\t\t\t\t\tdocument.removeEventListener(\"touchmove\", this.mousemove, false);\n\t\t\t\t\tdocument.removeEventListener(\"touchend\", this.mouseup, false);\n\t\t\t\t}\n\t\t\t\t// Unbind mouse event handlers:\n\t\t\t\tdocument.removeEventListener(\"mousemove\", this.mousemove, false);\n\t\t\t\tdocument.removeEventListener(\"mouseup\", this.mouseup, false);\n\n\t\t\t\tthis._state.inDrag = false;\n\t\t\t\tif (this._state.over === false) {\n\t\t\t\t\tthis._hideTooltip();\n\t\t\t\t}\n\t\t\t\tvar val = this._calculateValue(true);\n\n\t\t\t\tthis._layout();\n\t\t\t\tthis._setDataVal(val);\n\t\t\t\tthis._trigger('slideStop', val);\n\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\t_calculateValue: function _calculateValue(snapToClosestTick) {\n\t\t\t\tvar val;\n\t\t\t\tif (this.options.range) {\n\t\t\t\t\tval = [this.options.min, this.options.max];\n\t\t\t\t\tif (this._state.percentage[0] !== 0) {\n\t\t\t\t\t\tval[0] = this._toValue(this._state.percentage[0]);\n\t\t\t\t\t\tval[0] = this._applyPrecision(val[0]);\n\t\t\t\t\t}\n\t\t\t\t\tif (this._state.percentage[1] !== 100) {\n\t\t\t\t\t\tval[1] = this._toValue(this._state.percentage[1]);\n\t\t\t\t\t\tval[1] = this._applyPrecision(val[1]);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tval = this._toValue(this._state.percentage[0]);\n\t\t\t\t\tval = parseFloat(val);\n\t\t\t\t\tval = this._applyPrecision(val);\n\t\t\t\t}\n\n\t\t\t\tif (snapToClosestTick) {\n\t\t\t\t\tvar min = [val, Infinity];\n\t\t\t\t\tfor (var i = 0; i < this.options.ticks.length; i++) {\n\t\t\t\t\t\tvar diff = Math.abs(this.options.ticks[i] - val);\n\t\t\t\t\t\tif (diff <= min[1]) {\n\t\t\t\t\t\t\tmin = [this.options.ticks[i], diff];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (min[1] <= this.options.ticks_snap_bounds) {\n\t\t\t\t\t\treturn min[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn val;\n\t\t\t},\n\t\t\t_applyPrecision: function _applyPrecision(val) {\n\t\t\t\tvar precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.options.step);\n\t\t\t\treturn this._applyToFixedAndParseFloat(val, precision);\n\t\t\t},\n\t\t\t_getNumDigitsAfterDecimalPlace: function _getNumDigitsAfterDecimalPlace(num) {\n\t\t\t\tvar match = ('' + num).match(/(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/);\n\t\t\t\tif (!match) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));\n\t\t\t},\n\t\t\t_applyToFixedAndParseFloat: function _applyToFixedAndParseFloat(num, toFixedInput) {\n\t\t\t\tvar truncatedNum = num.toFixed(toFixedInput);\n\t\t\t\treturn parseFloat(truncatedNum);\n\t\t\t},\n\t\t\t/*\n   \tCredits to Mike Samuel for the following method!\n   \tSource: http://stackoverflow.com/questions/10454518/javascript-how-to-retrieve-the-number-of-decimals-of-a-string-number\n   */\n\t\t\t_getPercentage: function _getPercentage(ev) {\n\t\t\t\tif (this.touchCapable && (ev.type === 'touchstart' || ev.type === 'touchmove')) {\n\t\t\t\t\tev = ev.touches[0];\n\t\t\t\t}\n\n\t\t\t\tvar eventPosition = ev[this.mousePos];\n\t\t\t\tvar sliderOffset = this._state.offset[this.stylePos];\n\t\t\t\tvar distanceToSlide = eventPosition - sliderOffset;\n\t\t\t\t// Calculate what percent of the length the slider handle has slid\n\t\t\t\tvar percentage = distanceToSlide / this._state.size * 100;\n\t\t\t\tpercentage = Math.round(percentage / this._state.percentage[2]) * this._state.percentage[2];\n\t\t\t\tif (this.options.reversed) {\n\t\t\t\t\tpercentage = 100 - percentage;\n\t\t\t\t}\n\n\t\t\t\t// Make sure the percent is within the bounds of the slider.\n\t\t\t\t// 0% corresponds to the 'min' value of the slide\n\t\t\t\t// 100% corresponds to the 'max' value of the slide\n\t\t\t\treturn Math.max(0, Math.min(100, percentage));\n\t\t\t},\n\t\t\t_validateInputValue: function _validateInputValue(val) {\n\t\t\t\tif (typeof val === 'number') {\n\t\t\t\t\treturn val;\n\t\t\t\t} else if (Array.isArray(val)) {\n\t\t\t\t\tthis._validateArray(val);\n\t\t\t\t\treturn val;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(ErrorMsgs.formatInvalidInputErrorMsg(val));\n\t\t\t\t}\n\t\t\t},\n\t\t\t_validateArray: function _validateArray(val) {\n\t\t\t\tfor (var i = 0; i < val.length; i++) {\n\t\t\t\t\tvar input = val[i];\n\t\t\t\t\tif (typeof input !== 'number') {\n\t\t\t\t\t\tthrow new Error(ErrorMsgs.formatInvalidInputErrorMsg(input));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t_setDataVal: function _setDataVal(val) {\n\t\t\t\tthis.element.setAttribute('data-value', val);\n\t\t\t\tthis.element.setAttribute('value', val);\n\t\t\t\tthis.element.value = val;\n\t\t\t},\n\t\t\t_trigger: function _trigger(evt, val) {\n\t\t\t\tval = val || val === 0 ? val : undefined;\n\n\t\t\t\tvar callbackFnArray = this.eventToCallbackMap[evt];\n\t\t\t\tif (callbackFnArray && callbackFnArray.length) {\n\t\t\t\t\tfor (var i = 0; i < callbackFnArray.length; i++) {\n\t\t\t\t\t\tvar callbackFn = callbackFnArray[i];\n\t\t\t\t\t\tcallbackFn(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* If JQuery exists, trigger JQuery events */\n\t\t\t\tif ($) {\n\t\t\t\t\tthis._triggerJQueryEvent(evt, val);\n\t\t\t\t}\n\t\t\t},\n\t\t\t_triggerJQueryEvent: function _triggerJQueryEvent(evt, val) {\n\t\t\t\tvar eventData = {\n\t\t\t\t\ttype: evt,\n\t\t\t\t\tvalue: val\n\t\t\t\t};\n\t\t\t\tthis.$element.trigger(eventData);\n\t\t\t\tthis.$sliderElem.trigger(eventData);\n\t\t\t},\n\t\t\t_unbindJQueryEventHandlers: function _unbindJQueryEventHandlers() {\n\t\t\t\tthis.$element.off();\n\t\t\t\tthis.$sliderElem.off();\n\t\t\t},\n\t\t\t_setText: function _setText(element, text) {\n\t\t\t\tif (typeof element.textContent !== \"undefined\") {\n\t\t\t\t\telement.textContent = text;\n\t\t\t\t} else if (typeof element.innerText !== \"undefined\") {\n\t\t\t\t\telement.innerText = text;\n\t\t\t\t}\n\t\t\t},\n\t\t\t_removeClass: function _removeClass(element, classString) {\n\t\t\t\tvar classes = classString.split(\" \");\n\t\t\t\tvar newClasses = element.className;\n\n\t\t\t\tfor (var i = 0; i < classes.length; i++) {\n\t\t\t\t\tvar classTag = classes[i];\n\t\t\t\t\tvar regex = new RegExp(\"(?:\\\\s|^)\" + classTag + \"(?:\\\\s|$)\");\n\t\t\t\t\tnewClasses = newClasses.replace(regex, \" \");\n\t\t\t\t}\n\n\t\t\t\telement.className = newClasses.trim();\n\t\t\t},\n\t\t\t_addClass: function _addClass(element, classString) {\n\t\t\t\tvar classes = classString.split(\" \");\n\t\t\t\tvar newClasses = element.className;\n\n\t\t\t\tfor (var i = 0; i < classes.length; i++) {\n\t\t\t\t\tvar classTag = classes[i];\n\t\t\t\t\tvar regex = new RegExp(\"(?:\\\\s|^)\" + classTag + \"(?:\\\\s|$)\");\n\t\t\t\t\tvar ifClassExists = regex.test(newClasses);\n\n\t\t\t\t\tif (!ifClassExists) {\n\t\t\t\t\t\tnewClasses += \" \" + classTag;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\telement.className = newClasses.trim();\n\t\t\t},\n\t\t\t_offsetLeft: function _offsetLeft(obj) {\n\t\t\t\treturn obj.getBoundingClientRect().left;\n\t\t\t},\n\t\t\t_offsetTop: function _offsetTop(obj) {\n\t\t\t\tvar offsetTop = obj.offsetTop;\n\t\t\t\twhile ((obj = obj.offsetParent) && !isNaN(obj.offsetTop)) {\n\t\t\t\t\toffsetTop += obj.offsetTop;\n\t\t\t\t\tif (obj.tagName !== 'BODY') {\n\t\t\t\t\t\toffsetTop -= obj.scrollTop;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn offsetTop;\n\t\t\t},\n\t\t\t_offset: function _offset(obj) {\n\t\t\t\treturn {\n\t\t\t\t\tleft: this._offsetLeft(obj),\n\t\t\t\t\ttop: this._offsetTop(obj)\n\t\t\t\t};\n\t\t\t},\n\t\t\t_css: function _css(elementRef, styleName, value) {\n\t\t\t\tif ($) {\n\t\t\t\t\t$.style(elementRef, styleName, value);\n\t\t\t\t} else {\n\t\t\t\t\tvar style = styleName.replace(/^-ms-/, \"ms-\").replace(/-([\\da-z])/gi, function (all, letter) {\n\t\t\t\t\t\treturn letter.toUpperCase();\n\t\t\t\t\t});\n\t\t\t\t\telementRef.style[style] = value;\n\t\t\t\t}\n\t\t\t},\n\t\t\t_toValue: function _toValue(percentage) {\n\t\t\t\treturn this.options.scale.toValue.apply(this, [percentage]);\n\t\t\t},\n\t\t\t_toPercentage: function _toPercentage(value) {\n\t\t\t\treturn this.options.scale.toPercentage.apply(this, [value]);\n\t\t\t},\n\t\t\t_setTooltipPosition: function _setTooltipPosition() {\n\t\t\t\tvar tooltips = [this.tooltip, this.tooltip_min, this.tooltip_max];\n\t\t\t\tif (this.options.orientation === 'vertical') {\n\t\t\t\t\tvar tooltipPos = this.options.tooltip_position || 'right';\n\t\t\t\t\tvar oppositeSide = tooltipPos === 'left' ? 'right' : 'left';\n\t\t\t\t\ttooltips.forEach((function (tooltip) {\n\t\t\t\t\t\tthis._addClass(tooltip, tooltipPos);\n\t\t\t\t\t\ttooltip.style[oppositeSide] = '100%';\n\t\t\t\t\t}).bind(this));\n\t\t\t\t} else if (this.options.tooltip_position === 'bottom') {\n\t\t\t\t\ttooltips.forEach((function (tooltip) {\n\t\t\t\t\t\tthis._addClass(tooltip, 'bottom');\n\t\t\t\t\t\ttooltip.style.top = 22 + 'px';\n\t\t\t\t\t}).bind(this));\n\t\t\t\t} else {\n\t\t\t\t\ttooltips.forEach((function (tooltip) {\n\t\t\t\t\t\tthis._addClass(tooltip, 'top');\n\t\t\t\t\t\ttooltip.style.top = -this.tooltip.outerHeight - 14 + 'px';\n\t\t\t\t\t}).bind(this));\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t/*********************************\n  \t\tAttach to global namespace\n  \t*********************************/\n\t\tif ($) {\n\t\t\tvar namespace = $.fn.slider ? 'bootstrapSlider' : 'slider';\n\t\t\t$.bridget(namespace, Slider);\n\n\t\t\t// Auto-Register data-provide=\"slider\" Elements\n\t\t\t$(function () {\n\t\t\t\t$(\"input[data-provide=slider]\")[namespace]();\n\t\t\t});\n\t\t}\n\t})($);\n\n\treturn Slider;\n});\n"
  },
  {
    "path": "html/studio.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-us\" xml:lang=\"en-us\" >\n<head>\n\n    <title>CubesViewer Studio (Local)</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-32x32.png\" sizes=\"32x32\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-194x194.png\" sizes=\"194x194\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-96x96.png\" sizes=\"96x96\">\n    <link rel=\"shortcut icon\" href=\"img/favicon/favicon.ico\">\n\n\n    <link rel=\"stylesheet\" href=\"lib/angular-ui-grid/ui-grid.css\" />\n    <link rel=\"stylesheet\" href=\"lib/font-awesome/css/font-awesome.css\" />\n    <link rel=\"stylesheet\" href=\"lib/nvd3/nv.d3.css\" />\n    <link rel=\"stylesheet\" href=\"../dist/cubesviewer.css\" />\n    <link rel=\"stylesheet\" href=\"lib/bootstrap-submenu/css/bootstrap-submenu.css\" /> <!-- after cubesviewer.css! -->\n\n    <link rel=\"stylesheet\" href=\"cvapp.css\" />\n\n    <script src=\"lib/jquery/jquery.js\"></script>\n    <script src=\"lib/bootstrap/bootstrap.js\"></script>\n    <script src=\"lib/bootstrap-submenu/js/bootstrap-submenu.js\"></script>\n    <script src=\"lib/angular/angular.js\"></script>\n    <script src=\"lib/angular-cookies/angular-cookies.js\"></script>\n    <script src=\"lib/angular-bootstrap/ui-bootstrap-tpls.js\"></script>\n    <script src=\"lib/angular-ui-grid/ui-grid.js\"></script>\n    <script src=\"lib/d3/d3.js\"></script>\n    <script src=\"lib/nvd3/nv.d3.js\"></script>\n    <script src=\"lib/flotr2/flotr2.min.js\"></script>\n    <script src=\"lib/masonry/masonry.pkgd.min.js\"></script>  <!-- needed for CubesViewer Studio only, not embedded views -->\n    <script src=\"../dist/cubesviewer.js\"></script>\n\n</head>\n\n<body>\n\n<script type=\"text/javascript\">\n\n    // Initialize CubesViewer when document is ready\n    $(document).ready(function() {\n\n    \tvar cubesUrl = prompt (\"Enter your Cubes Server URL\\n(or try http://cubesdemo.cubesviewer.com)\", \"http://localhost:5000\");\n        //var cubesUrl = \"http://localhost:5000\";\n\n        cubesviewerStudio.init({\n        \tcubesUrl: cubesUrl,\n            container: $('#cubesviewer').get(0),\n            debug: true\n        });\n\n    });\n\n</script>\n\n<div>\n\n    <div class=\"header\">\n        <div style=\"float: left;\">\n            <img class=\"cv-logo\" title=\"CubesViewer\" src=\"img/cubesviewer-logo.png\" />\n        </div>\n\n        <h1>CubesViewer Studio</h1>\n        <small>Local HTML version (<a href=\"https://github.com/jjmontesl/cubesviewer-server\" target=\"_blank\">server-side features</a> are not available)</small>\n\n    </div>\n\n    <div style=\"clear: both;\"></div>\n\n\n    <!-- Cubes Viewer container -->\n    <div id=\"cubesviewer\">\n    </div>\n\n\n    <div class=\"footer\" style=\"clear: both; padding-top: 20px;\">\n    \t<div style=\"height: 1px; border-top: 1px solid #DDDDDD; padding-top: 4px;\"></div>\n    \t<div style=\"float: right; white-space: nowrap;\">\n    \t\t<p style=\"vertical-align: middle; margin: 2px;\">\n    \t\t<a href=\"http://databrewery.org/\" target=\"_blank\"><img title=\"Powered by Databrewery Cubes\" style=\"width: 70px; height: 25px;\" src=\"img/cubes-logo.png\" /></a>\n            <a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\"><img title=\"Powered by CubesViewer\" style=\"width: 50px; height: 25px;\" src=\"img/cubesviewer-logo.png\" /></a>\n    \t\t</p>\n    \t</div>\n    \t<div>\n    \t\t<p><a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\">CubesViewer</a> <span class=\"cv-version\"></span> - Cubes OLAP explorer</p>\n    \t</div>\n    </div>\n\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "html/views-angular.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-us\" xml:lang=\"en-us\" >\n<head>\n\n    <title>CubesViewer Embedded View in AngularJS Example</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-32x32.png\" sizes=\"32x32\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-194x194.png\" sizes=\"194x194\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-96x96.png\" sizes=\"96x96\">\n    <link rel=\"shortcut icon\" href=\"img/favicon/favicon.ico\">\n\n    <link rel=\"stylesheet\" href=\"lib/angular-ui-grid/ui-grid.css\" />\n    <link rel=\"stylesheet\" href=\"lib/font-awesome/css/font-awesome.css\" />\n    <link rel=\"stylesheet\" href=\"lib/nvd3/nv.d3.css\" />\n    <link rel=\"stylesheet\" href=\"lib/bootstrap-submenu/css/bootstrap-submenu.css\" />\n    <link rel=\"stylesheet\" href=\"../dist/cubesviewer.css\" />\n\n    <link rel=\"stylesheet\" href=\"cvapp.css\" />\n\n    <script src=\"lib/jquery/jquery.js\"></script>\n    <script src=\"lib/bootstrap/bootstrap.js\"></script>\n    <script src=\"lib/bootstrap-submenu/js/bootstrap-submenu.js\"></script>\n    <script src=\"lib/angular/angular.js\"></script>\n    <script src=\"lib/angular-cookies/angular-cookies.js\"></script>\n    <script src=\"lib/angular-bootstrap/ui-bootstrap-tpls.js\"></script>\n    <script src=\"lib/angular-ui-grid/ui-grid.js\"></script>\n    <script src=\"lib/d3/d3.js\"></script>\n    <script src=\"lib/nvd3/nv.d3.js\"></script>\n    <script src=\"lib/flotr2/flotr2.min.js\"></script>\n    <script src=\"../dist/cubesviewer.js\"></script>\n\n</head>\n\n<body ng-app=\"MyApp\">\n\n<div ng-controller=\"MyAppController\">\n\n    <div class=\"header\">\n        <div style=\"float: left;\">\n            <img class=\"cv-logo\" title=\"CubesViewer\" src=\"img/cubesviewer-logo.png\" />\n        </div>\n\n        <h1>CubesViewer Static Views example</h1>\n        <small>Shows how CubesViewer views can be embedded within an AngularJS app.</small>\n\n    </div>\n\n    <div style=\"clear: both;\"></div>\n\n    <div >\n        <h2>CubesViewer View integrated in AngularJS app</h2>\n\n        <p>\n        The view below is a CubesViewer view naturally loaded as an angular directive in this page (with data\n        from the Cubes <a href=\"https://github.com/jjmontesl/cubes-examples/tree/master/webshop\">example webshop</a> project).\n        </p>\n\n        <div style=\"border: none; margin-top: 22px; margin-bottom: 22px;\">\n\n            <!-- CubesViewer view -->\n            <div ng-if=\"view1\" class=\"cv-bootstrap\">\n                <div cv-view-cube view=\"view1\" style=\"width: 100%; min-height: 120px;\">Loading...</div>\n            </div>\n            <div>The view can be scripted from AngularJS: <a href=\"\" ng-click=\"view1.setControlsHidden(! view1.params.controlsHidden)\">Toggle Controls</a></div>\n\n        </div>\n\n        <h2>Code</h2>\n\n        <p>Check the <a href=\"https://github.com/jjmontesl/cubesviewer/blob/master/src/html/cv-angular.html\">source code of this page</a> to see how this CubesViewer view is initialized.</p>\n\n        <p>More information can be found in the documentation page\n            <a href=\"\">Embedding CubesViewer static views</a>.\n        </p>\n    </div>\n\n\n    <div class=\"footer\" style=\"clear: both; padding-top: 20px;\">\n        <div style=\"height: 1px; border-top: 1px solid #DDDDDD; padding-top: 4px;\"></div>\n        <div style=\"float: right; white-space: nowrap;\">\n            <p style=\"vertical-align: middle; margin: 2px;\">\n            <a href=\"http://databrewery.org/\" target=\"_blank\"><img title=\"Powered by Databrewery Cubes\" style=\"width: 70px; height: 25px;\" src=\"img/cubes-logo.png\" /></a>\n            <a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\"><img title=\"Powered by CubesViewer\" style=\"width: 50px; height: 25px;\" src=\"img/cubesviewer-logo.png\" /></a>\n            </p>\n        </div>\n        <div>\n            <p><a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\">CubesViewer</a> <span class=\"cv-version\"></span> - Cubes OLAP explorer</p>\n        </div>\n    </div>\n\n</div>\n\n\n<script type=\"text/javascript\">\n\n\n\tangular.module('cv').constant('cvOptions', {\n\t\tcubesUrl: \"http://cubesdemo.cubesviewer.com\",\n\t\tdebug: true\n\t});\n\n    angular.module('MyApp', [ 'cv' ]);\n\n    angular.module('MyApp').controller(\"MyAppController\", ['$scope', 'viewsService',\n                                        function($scope, viewsService) {\n\n        var serializedView = '{\"cubename\":\"webshop_sales\",\"name\":\"Cube Webshop / Sales\",\"mode\":\"chart\",\"drilldown\":[\"country:continent\"],\"cuts\":[],\"datefilters\":[{\"dimension\":\"date_sale@daily\",\"mode\":\"auto-last24m\",\"date_from\":\"\",\"date_to\":\"\"}],\"rangefilters\":[],\"xaxis\":\"date_sale@daily:month\",\"yaxis\":\"price_total_sum\",\"charttype\":\"lines-stacked\",\"columnHide\":{},\"columnWidths\":{},\"columnSort\":{},\"chart-barsvertical-stacked\":true,\"chart-disabledseries\":{\"key\":\"product@product:product_category\",\"disabled\":{\"Books\":false,\"Sports\":false,\"Various\":false,\"Videos\":false}}}';\n    \t$scope.view1 = viewsService.createView(\"cube\", serializedView);\n\n    }]);\n\n</script>\n\n</body>\n</html>\n"
  },
  {
    "path": "html/views.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-us\" xml:lang=\"en-us\" >\n<head>\n\n    <title>CubesViewer Embedded View Example</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-32x32.png\" sizes=\"32x32\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-194x194.png\" sizes=\"194x194\">\n    <link rel=\"icon\" type=\"image/png\" href=\"img/favicon/favicon-96x96.png\" sizes=\"96x96\">\n    <link rel=\"shortcut icon\" href=\"img/favicon/favicon.ico\">\n\n    <link rel=\"stylesheet\" href=\"lib/angular-ui-grid/ui-grid.css\" />\n    <link rel=\"stylesheet\" href=\"lib/font-awesome/css/font-awesome.css\" />\n    <link rel=\"stylesheet\" href=\"lib/nvd3/nv.d3.css\" />\n    <link rel=\"stylesheet\" href=\"../dist/cubesviewer.css\" />\n    <link rel=\"stylesheet\" href=\"lib/bootstrap-submenu/css/bootstrap-submenu.css\" /> <!-- after cubesviewer.css! -->\n\n    <link rel=\"stylesheet\" href=\"cvapp.css\" />\n\n    <script src=\"lib/jquery/jquery.js\"></script>\n    <script src=\"lib/bootstrap/bootstrap.js\"></script>\n    <script src=\"lib/bootstrap-submenu/js/bootstrap-submenu.js\"></script>\n    <script src=\"lib/angular/angular.js\"></script>\n    <script src=\"lib/angular-cookies/angular-cookies.js\"></script>\n    <script src=\"lib/angular-bootstrap/ui-bootstrap-tpls.js\"></script>\n    <script src=\"lib/angular-ui-grid/ui-grid.js\"></script>\n    <script src=\"lib/d3/d3.js\"></script>\n    <script src=\"lib/nvd3/nv.d3.js\"></script>\n    <script src=\"lib/flotr2/flotr2.min.js\"></script>\n    <script src=\"../dist/cubesviewer.js\"></script>\n\n</head>\n\n<body>\n\n<script type=\"text/javascript\">\n\n    // Reference to the created view\n    var view1 = null;\n\n    // Initialize CubesViewer when document is ready\n    $(document).ready(function() {\n\n        // Get user Cubes information for the example\n        var cubesUrl = prompt (\"Enter your Cubes Server URL\", \"http://cubesdemo.cubesviewer.com\");\n\n        // Initialize CubesViewer system\n        cubesviewer.init({\n            cubesUrl: cubesUrl,\n            debug: true\n        });\n\n        // Create views\n\n        // Sample serialized view (based on cubes-examples project data)\n        var serializedView = '{\"cubename\":\"webshop_sales\",\"name\":\"Cube Webshop / Sales\",\"mode\":\"chart\",\"drilldown\":[\"country:continent\"],\"cuts\":[],\"datefilters\":[{\"dimension\":\"date_sale@daily\",\"mode\":\"auto-last24m\",\"date_from\":\"\",\"date_to\":\"\"}],\"rangefilters\":[],\"xaxis\":\"date_sale@daily:month\",\"yaxis\":\"price_total_sum\",\"charttype\":\"lines-stacked\",\"columnHide\":{},\"columnWidths\":{},\"columnSort\":{},\"chart-barsvertical-stacked\":true,\"chart-disabledseries\":{\"key\":\"product@product:product_category\",\"disabled\":{\"Books\":false,\"Sports\":false,\"Various\":false,\"Videos\":false}}}';\n\n        // Using a JSON string for view parameters:\n        cubesviewer.apply(function() {\n        \tview1 = cubesviewer.createView(\"#cv-view-1\", \"cube\", serializedView);\n        });\n\n        // Using a Javascript object for view parameters:\n        //cubesviewer.apply(function() {\n        //    view2 = cubesviewer.createView('#cv-view-1', \"cube\", { \"cubename\": \"webshop_visits\" });\n        //});\n    });\n\n    function switchMode(mode) {\n    \tcubesviewer.apply(function() {\n    \t\tview1.setViewMode(mode);\n    \t});\n    }\n\n    function toggleControls() {\n        cubesviewer.apply(function() {\n            view1.setControlsHidden(! view1.params.controlsHidden);\n        });\n    }\n\n</script>\n\n\n<div>\n\n    <div class=\"header\">\n        <div style=\"float: left;\">\n            <img class=\"cv-logo\" title=\"CubesViewer\" src=\"img/cubesviewer-logo.png\" />\n        </div>\n\n        <h1>CubesViewer Static Views example</h1>\n        <small>Shows how CubesViewer views can be embedded in other web pages.</small>\n\n    </div>\n\n    <div style=\"clear: both;\"></div>\n\n    <div>\n        <h2>Example Embedded View</h2>\n\n        <p>\n        This is an example CubesView inserted in this page. It loads a serialized view which uses the\n        Cubes <a href=\"https://github.com/jjmontesl/cubes-examples/tree/master/webshop\">example webshop</a> project.\n        </p>\n\n        <div style=\"border: none; margin-top: 22px; margin-bottom: 22px;\">\n            <div id=\"cv-view-1\" style=\"width: 100%; min-height: 120px;\">Loading CubesViewer...</div>\n        </div>\n\n        <h2>Scripting</h2>\n\n        <p>\n        The view above can be scripted using CubesViewer View API.\n        </p>\n        <p>\n        Click to switch to <a href=\"\" onclick=\"switchMode('series'); return false;\">series table</a> mode or\n        <a href=\"\" onclick=\"switchMode('chart'); return false;\">chart mode</a>, or\n        <a href=\"\" onclick=\"toggleControls(); return false;\">toggle controls visibility</a>.\n        </p>\n\n        <h2>Code</h2>\n\n        <p>Check the <a href=\"https://github.com/jjmontesl/cubesviewer/blob/master/src/html/views.html\">source code of this page</a> to see how this CubesViewer view is initialized.</p>\n\n        <p>More information can be found in the documentation page\n        <a href=\"\">Embedding CubesViewer static views</a>.\n        </p>\n    </div>\n\n\n    <div class=\"footer\" style=\"clear: both; padding-top: 20px;\">\n        <div style=\"height: 1px; border-top: 1px solid #DDDDDD; padding-top: 4px;\"></div>\n        <div style=\"float: right; white-space: nowrap;\">\n            <p style=\"vertical-align: middle; margin: 2px;\">\n            <a href=\"http://databrewery.org/\" target=\"_blank\"><img title=\"Powered by Databrewery Cubes\" style=\"width: 70px; height: 25px;\" src=\"img/cubes-logo.png\" /></a>\n            <a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\"><img title=\"Powered by CubesViewer\" style=\"width: 50px; height: 25px;\" src=\"img/cubesviewer-logo.png\" /></a>\n            </p>\n        </div>\n        <div>\n            <p><a href=\"https://github.com/jjmontesl/cubesviewer\" target=\"_blank\">CubesViewer</a> <span class=\"cv-version\"></span> - Cubes OLAP explorer</p>\n        </div>\n    </div>\n\n</div>\n\n</body>\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"cubesviewer\",\n  \"version\": \"2.0.3-devel\",\n  \"devDependencies\": {\n    \"bower\": \"^1.7.9\",\n    \"grunt\": \"^0.4.5\",\n    \"grunt-angular-templates\": \"^1.0.3\",\n    \"grunt-bower-task\": \"^0.4.0\",\n    \"grunt-contrib-concat\": \"^1.0.0\",\n    \"grunt-contrib-copy\": \"^1.0.0\",\n    \"grunt-contrib-jshint\": \"~0.6.3\",\n    \"grunt-contrib-less\": \"^1.3.0\",\n    \"grunt-contrib-nodeunit\": \"~0.2.0\",\n    \"grunt-contrib-requirejs\": \"^1.0.0\",\n    \"grunt-contrib-uglify\": \"~0.2.2\",\n    \"grunt-contrib-watch\": \"^1.0.0\",\n    \"grunt-jsdoc\": \"^2.0.0\",\n    \"grunt-wiredep\": \"^3.0.1\"\n  }\n}\n"
  }
]