You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/09/10 09:19:09 UTC

[1/6] [OLINGO-429] add headers, extend rat module, remove dependencies

Repository: olingo-odata4-js
Updated Branches:
  refs/heads/master cf77b73e5 -> 733b57dd8


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/package.json
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/package.json b/odatajs/grunt-config/custom-tasks/rat/package.json
index 6753173..f5fa8bb 100644
--- a/odatajs/grunt-config/custom-tasks/rat/package.json
+++ b/odatajs/grunt-config/custom-tasks/rat/package.json
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 {
   "name": "grunt-rat",
   "version": "0.0.1",
@@ -14,6 +32,7 @@
     "chalk": "~0.4.0"
   },
   "devDependencies": {
+    "async": "^0.9.0",
     "grunt": "~0.4.0",
     "xml2js": "^0.4.4"
   },

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/readme.md
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/readme.md b/odatajs/grunt-config/custom-tasks/rat/readme.md
index 82051fe..fd2795c 100644
--- a/odatajs/grunt-config/custom-tasks/rat/readme.md
+++ b/odatajs/grunt-config/custom-tasks/rat/readme.md
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 Download "apache-rat-0.11-bin.zip" from http://creadur.apache.org/rat/download_rat.cgi and unpack it to 
 "extern-tools/apache-rat-0.11"
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
index ba9d773..287f1a4 100644
--- a/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
+++ b/odatajs/grunt-config/custom-tasks/rat/tasks/rat.js
@@ -16,73 +16,95 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 module.exports = function (grunt) {
   grunt.registerMultiTask('rat', 'Run Apache Rat', function () {
-    var path = require('path');
+    var async = require("async");
     var chalk = require('chalk');
     var childProcess = require('child_process');
-    var xml2js = require('xml2js');
+    var path = require('path');
     var fs = require('fs');
+    var xml2js = require('xml2js');
 
-    var cb = this.async();
-
-
-
-    var options = this.options({ xml : true, tmpDir : './build/tmp'});
-    var dir = this.data.dir;
-    var out = options.tmpDir + '/' + (options.xml ? 'rat.xml' : 'rat.txt');
-
-    var pathToRat =  path.resolve(__dirname,'./../extern-tools/apache-rat-0.11/apache-rat-0.11.jar');
+    var globalCB = this.async();
     
-    if(!fs.existsSync(options.tmpDir)){
-         fs.mkdirSync(options.tmpDir, 0766, function(err){
-           if(err){ 
-             grunt.fail.warn('rat --> ' + 'Output directory could not be created: ' + options.tmpDir, 1); 
-           }
-         });   
-     }
-
-
-
+    var ratJarFile =  path.resolve(__dirname,'./../extern-tools/apache-rat-0.11/apache-rat-0.11.jar');
+    var options = this.options({ xml : true, dest : './build/tmp'});
 
+    //check output directory
+    if(!fs.existsSync(options.dest)){
+      grunt.file.mkdir(options.dest,0766);
+    }
+    
+    //collect directories which should be checked
+    var checkDirs = [];
+    for(var i = 0; i < this.files.length; i++) {
+      for(var ii = 0; ii < this.files[i].src.length; ii++) {
+        var checkDir = {
+          dir : this.files[i].src[ii],
+          options : {
+            xml : options.xml,
+            dest : options.dest,
+            tag : this.files[i].options.tag,
+            exclude : options.exclude || this.files[i].options.exclude
+          }
+        };
+        checkDirs.push(checkDir);
+      }
+    }
 
-    //sample command java -jar apache-rat-0.10.jar -x -d ./src > ./build/tmp/rat.txt
-    var cmd = 'java -jar ' + pathToRat+ ' ';
-    cmd += options.xml ? ' -x' : '';
-    cmd += ' --force -d ' + dir + ' > ' + out;
+    var processDirectory = function processDirectory(data,cb) {
+      var checkDir = data.dir; 
+      var options = data.options;
+      var outPutFile = options.dest + '/'+ 'rat_' + (options.tag ? options.tag:'') + (options.xml ? '.xml' : '.txt');
+      
+      //sample command java -jar apache-rat-0.10.jar -x -d ./src > ./build/tmp/rat.txt
+      var cmd = 'java -jar ' + ratJarFile+ ' ';
+      cmd += options.xml ? ' -x' : '';
+      cmd += ' --force -d ' + checkDir;
+      //cmd += ' -E ./grunt-config/custom-tasks/rat/.rat-excludes'
+      if (options.exclude)  {
+        for (var i = 0;  i< options.exclude.length; i ++) {
+          cmd += ' -e '+ options.exclude[i];
+        }
+      }
+      cmd +=  ' > ' + outPutFile;
 
-    grunt.verbose.writeln('Directory: '+dir);
+      grunt.verbose.writeln('Command:', chalk.yellow(cmd));
+      var cp = childProcess.exec(cmd, options.execOptions, function (error, stdout, stderr) {
+        if (error) {
+          grunt.fail.warn('rat --> ' + error, 1); //exit grunt with error code 1
+        }
+        checkOutFile(outPutFile,data,cb);
+      });
+    };
 
-    var cp = childProcess.exec(cmd, options.execOptions, function (err, stdout, stderr) {
-      if (err) {
-        grunt.fail.warn('rat --> ' + err, 1); //exit grunt with error code 1
-      }
-      
-      if (!options.xml) {
-        grunt.fail.warn('rat --> ' + 'No XML output: checkRatLogFile skipped!', 1); 
+    var checkOutFile = function(outFile,data,cb) {
+      //check out files
+      if (path.extname(outFile) !== '.xml') {
+        grunt.log.writeln(chalk.yellow('\nrat --> ' + 'No XML output: ('+outFile+') skipped!\n')); 
+        cb();
+        return;
       }
 
-      var xml = grunt.file.read(out);
+      var xml = grunt.file.read(outFile);
       var parser = new xml2js.Parser();
 
       parser.parseString(xml, function (err, result) {
-
           if (err) {
-            grunt.fail.warn('rat --> ' + err, 1); 
+            grunt.fail.warn('rat --> XML parse error: ' + err, 1); 
           }
           
           if (checkRatLogFile(result)) {
-            grunt.fail.warn('rat --> ' + 'Missing or Invalied license header detected ( see "'+out+'")', 1);
+            grunt.fail.warn('rat --> check license error:  ' + 'Missing or Invalied license header detected ( see "'+outFile+'")', 1);
           }
-
           
+          grunt.log.ok('rat --> check on ' + data.dir + ' ok -> see'  + outFile);
       });
-      cb(); 
-      
-    }.bind(this));
+      cb();
+    };
 
     var checkRatLogFile = function(result) {
-
       var list = result['rat-report']['resource'];
       for (var i = 0; i < list.length; i++ ){
         var item = list[i];
@@ -94,7 +116,7 @@ module.exports = function (grunt) {
         }
       }
       return false;
-    }
+    };
 
     var captureOutput = function (child, output) {
       if (grunt.option('color') === false) {
@@ -106,8 +128,19 @@ module.exports = function (grunt) {
       }
     };
 
-    grunt.verbose.writeln('Command:', chalk.yellow(cmd));
+    //files
+    async.each(checkDirs,
+      function (checkDir,cb) {
+        processDirectory(checkDir,cb);
+      },
+      function(err) {
+        grunt.log.ok('rat --> finished');
+        globalCB();
+      }
+    );
 
+    
+  /*
     captureOutput(cp.stdout, process.stdout);
       captureOutput(cp.stderr, process.stderr);
 
@@ -115,7 +148,7 @@ module.exports = function (grunt) {
       process.stdin.resume();
       process.stdin.setEncoding('utf8');
       process.stdin.pipe(cp.stdin);
-    }
+    }*/
   });
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/rat-config.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat-config.js b/odatajs/grunt-config/rat-config.js
index 1793b5e..f797a45 100644
--- a/odatajs/grunt-config/rat-config.js
+++ b/odatajs/grunt-config/rat-config.js
@@ -18,25 +18,46 @@
  */
 module.exports = function(grunt) {
   grunt.config('rat', {
-    options: { xml : true, tmpDir : './build/tmp' },
-    src: {                      
-      dir: './src',
+    dist:  { 
+      options: { 
+        dest : './build/tmp', 
+        exclude: [
+          "node_modules","extern-tools",".gitignore",
+          "DEPENDENCIES","LICENSE","NOTICE",
+          "JSLib.sln","package.json"
+        ] },
+      files: [
+        /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/
+        /*{ src: ['./../dist/<%= artifactname %>/lib'], options:{ tag:"dist-lib"}},very slow*/
+        { src: ['./../dist/<%= artifactname %>/sources'], options:{ tag:"dist-src"}},
+      ]
     },
-    test: {                      
-      dir: './tests'
+    "manual-dist":  { 
+      options: { xml:false, 
+        dest : './build/tmp', 
+        exclude: [
+          "node_modules","extern-tools",".gitignore",
+          "DEPENDENCIES","LICENSE","NOTICE",
+          "JSLib.sln","package.json"
+        ] },
+      files: [
+        /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/
+        /*{ src: ['./../dist/<%= artifactname %>/lib'], options:{ tag:"dist-lib"}},very slow*/
+        { src: ['./../dist/<%= artifactname %>/sources'], options:{ tag:"dist-src"}},
+      ]
     },
-    'src-manual': {                      
-      options: { xml : false, tmpDir : './build/tmp' },
-      dir: './src',
+    manual:  {  // with txt output
+      options: { xml:false, 
+        dest : './build/tmp', 
+        exclude: ["node_modules","extern-tools",".gitignore"] },
+      files: [
+        { src: ['./src'], options:{ tag:"src"}},
+        { src: ['./tests'], options:{ tag:"tests"}},
+        { src: ['./demo'], options:{ tag:"demo"}},
+        { src: ['./grunt-config'], options:{ tag:"grunt-config" }}
+      ]
     },
-    'test-manual': {                      
-      options: { xml : false, tmpDir : './build/tmp' },
-      dir: './tests'
-    },
-
   });
 
- 
   grunt.loadTasks('grunt-config/custom-tasks/rat/tasks');
-  grunt.registerTask('custom-license-check',['rat:src','rat:test']);
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/release.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/release.js b/odatajs/grunt-config/release.js
index 2309510..3333d85 100644
--- a/odatajs/grunt-config/release.js
+++ b/odatajs/grunt-config/release.js
@@ -30,9 +30,11 @@ module.exports = function(grunt) {
     return hay.indexOf(needle) > -1;
   }
 
+  
+
   // clean
   grunt.config.merge( { 
-    'clean': {
+    'npm-clean': {
       'release-dist': {
         options: { force: true },
         src: [ "./../dist/<%= artifactname %>*"]
@@ -60,7 +62,7 @@ module.exports = function(grunt) {
     'copy' : {
       'release-lib' : {
         files: [
-          { expand: true, cwd: 'build', src: ['<%= artifactname %>*.*'], dest: './../dist/<%= artifactname %>/lib/lib', filter: 'isFile'},
+          { expand: true, cwd: 'build/lib', src: ['<%= artifactname %>*.*'], dest: './../dist/<%= artifactname %>/lib/lib', filter: 'isFile'},
           { expand: true, src :'LICENSE',dest: './../dist/<%= artifactname %>/lib', filter: 'isFile' },
           { expand: true, src :'NOTICE',dest: './../dist/<%= artifactname %>/lib', filter: 'isFile' },
           { expand: true, src :'DEPENDENCIES',dest: './../dist/<%= artifactname %>/lib', filter: 'isFile' }
@@ -79,7 +81,7 @@ module.exports = function(grunt) {
             { expand: true, src :'LICENSE',dest: './../dist/<%= artifactname %>/sources', filter: 'isFile' },
             { expand: true, src :'NOTICE',dest: './../dist/<%= artifactname %>/sources', filter: 'isFile' },
             { expand: true, src :'DEPENDENCIES',dest: './../dist/<%= artifactname %>/sources', filter: 'isFile' },
-            { dot: true, expand: true, cwd: './../', src: ['odatajs/**'], dest: './../dist/<%= artifactname %>/sources',
+            { dot: true, expand: true, cwd: './', src: ['**'], dest: './../dist/<%= artifactname %>/sources/odatajs',
             filter: function(srcPath)  {
               // no node_modules
               if (srcPath === 'node_modules' || contains(srcPath, 'node_modules\\')|| contains(srcPath, 'node_modules/')) {
@@ -99,20 +101,20 @@ module.exports = function(grunt) {
               }
 
               // no c# files
-              if (srcPath === 'obj' || contains(srcPath, 'odatajs\\obj')|| contains(srcPath, 'odatajs/obj')) {
+              if (srcPath === 'obj' || contains(srcPath, 'obj')|| contains(srcPath, 'obj')) {
                 return false; 
               }
 
-              if (srcPath === 'bin' || contains(srcPath, 'odatajs\\bin')|| contains(srcPath, 'odatajs/bin')) {
+              if (srcPath === 'bin' || contains(srcPath, 'bin')|| contains(srcPath, 'bin')) {
                 return false; 
               }
 
-              if (srcPath === 'packages' || contains(srcPath, 'odatajs\\packages')|| contains(srcPath, 'odatajs/packages')) {
+              if (srcPath === 'packages' || contains(srcPath, 'packages')|| contains(srcPath, 'packages')) {
                 return false; 
               }
 
               // no build retults
-              if (srcPath === 'build' || contains(srcPath, 'odatajs\\build')|| contains(srcPath, 'odatajs/build')) {
+              if (srcPath === 'build' || contains(srcPath, 'build')|| contains(srcPath, 'build')) {
                 return false; 
               }
 
@@ -122,6 +124,12 @@ module.exports = function(grunt) {
               if (endsWith(srcPath, 'localgrunt.config')) {
                 return false; 
               }
+              if (endsWith(srcPath, 'JSLib.suo')) {
+                return false; 
+              }
+              if (endsWith(srcPath, 'JSLib.csproj.user')) {
+                return false; 
+              }
               
               console.log(' + ' + srcPath);
               return true;
@@ -161,10 +169,11 @@ module.exports = function(grunt) {
 
   //tasks
   grunt.registerTask('dist',[
-    'clean:release-dist',
+    'npm-clean:release-dist',
     'build',
     'doc',
     'copy:release-lib','copy:release-doc','copy:release-sources',
+    'rat:dist',
     'compress:release-lib','compress:release-doc','compress:release-sources']);
 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/package.json
----------------------------------------------------------------------
diff --git a/odatajs/package.json b/odatajs/package.json
index 36dd3d7..3f66eb4 100644
--- a/odatajs/package.json
+++ b/odatajs/package.json
@@ -4,8 +4,8 @@
   "postfix": "beta-01",
   "releaseCandidate" : "RC01",
 
-  "title": "Olingo OData Client for Java Script",
-  "description": "the Olingo OData Client for Java Script library is a new cross-browser JavaScript library that enables data-centric web applications by leveraging modern protocols such as JSON and OData and HTML5-enabled browser features. It's designed to be small, fast and easy to use.",
+  "title": "Olingo OData Client for JavaScript",
+  "description": "the Olingo OData Client for JavaScript library is a new cross-browser JavaScript library that enables data-centric web applications by leveraging modern protocols such as JSON and OData and HTML5-enabled browser features. It's designed to be small, fast and easy to use.",
   "homepage": "http://olingo.apache.org",
   "main": "index.js",
   "repository": {

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/common/djstest-browser.js
----------------------------------------------------------------------
diff --git a/odatajs/tests/common/djstest-browser.js b/odatajs/tests/common/djstest-browser.js
index 366ca33..c37f7e9 100644
--- a/odatajs/tests/common/djstest-browser.js
+++ b/odatajs/tests/common/djstest-browser.js
@@ -21,7 +21,7 @@
 // Because this code contains a init function to be useable directly inside the browser as well as in nodejs
 // we define the @namespace djstest here instead of the a @module name djstest
 
-/** Create namespace djstest in window.djstest when this file is loaded as java script by the browser
+/** Create namespace djstest in window.djstest when this file is loaded as JavaScript by the browser
  * @namespace djstest
  */
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/common/djstest.js
----------------------------------------------------------------------
diff --git a/odatajs/tests/common/djstest.js b/odatajs/tests/common/djstest.js
index 5dda9ff..5268467 100644
--- a/odatajs/tests/common/djstest.js
+++ b/odatajs/tests/common/djstest.js
@@ -21,7 +21,7 @@
 // Because this code contains a init function to be useable directly inside the browser as well as in nodejs
 // we define the @namespace djstest here instead of the a @module name djstest
 
-/** Create namespace djstest in window.djstest when this file is loaded as java script by the browser
+/** Create namespace djstest in window.djstest when this file is loaded as JavaScript by the browser
  * @namespace djstest
  */
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/tests/e2etest/Test.html
----------------------------------------------------------------------
diff --git a/odatajs/tests/e2etest/Test.html b/odatajs/tests/e2etest/Test.html
index c9b5989..56646c9 100644
--- a/odatajs/tests/e2etest/Test.html
+++ b/odatajs/tests/e2etest/Test.html
@@ -22,8 +22,10 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <title>odatajs side-by-side test (V3 & V4)</title>
-    <script type="text/javascript" src="../../demo/scripts/datajs-1.1.2.js"></script>
+    <!--<script type="text/javascript" src="../../demo/scripts/datajs-1.1.2.js"></script>-->
+    <script type="text/javascript" src="http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=datajs&DownloadId=784667&FileTime=130354527569270000&Build=20928"></script>
     <script type="text/javascript" src="../../build/odatajs-4.0.0-beta-01.js"></script>
+    https://datajs.codeplex.com/downloads/get/784666
 </head>
 <body>
     <h3>


[4/6] [OLINGO-429] add headers, extend rat module, remove dependencies

Posted by ko...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/scripts/datajs-1.1.1.min.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/datajs-1.1.1.min.js b/odatajs/demo/scripts/datajs-1.1.1.min.js
deleted file mode 100644
index 0d862a1..0000000
--- a/odatajs/demo/scripts/datajs-1.1.1.min.js
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) Microsoft.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-(function(n,t){var pt=n.datajs||{},r=n.OData||{},co,lo,ei,ly,ip;typeof define=="function"&&define.amd?(define("datajs",pt),define("OData",r)):(n.datajs=pt,n.OData=r),pt.version={major:1,minor:1,build:1};var bo=function(t){return n.ActiveXObject?new n.ActiveXObject(t):null},ot=function(n){return n!==null&&n!==t},fr=function(n,t){for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return!0;return!1},it=function(n,i){return n!==t?n:i},o=function(t){if(arguments.length===1){n.setTimeout(t,0);return}var i=Array.prototype.slice.call(arguments,1);n.setTimeout(function(){t.apply(this,i)},0)},g=function(n,t){for(var i in t)n[i]=t[i];return n},er=function(n,t){if(n)for(var i=0,r=n.length;i<r;i++)if(t(n[i]))return n[i];return null},e=function(n){return Object.prototype.toString.call(n)==="[object Array]"},cf=function(n){return Object.prototype.toString.call(n)==="[object Date]"},lf=function(n){return typeof n=="object"},s=function(n){return parseInt(n,10)},iu=function(n,t,i){n.hasOwnProperty(t)&&(n[
 i]=n[t],delete n[t])},ru=function(n){throw n;},ko=function(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")},af=function(n,i){return n!==t?n:i},rp=/^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#:]+)?(\?[^#]*)?(#.*)?/,go=["scheme","authority","path","query","fragment"],vf=function(n){var i={isAbsolute:!1},r,t,u;if(n){if(r=rp.exec(n),r)for(t=0,u=go.length;t<u;t++)r[t+1]&&(i[go[t]]=r[t+1]);i.scheme&&(i.isAbsolute=!0)}return i},ns=function(n){return"".concat(n.scheme||"",n.authority||"",n.path||"",n.query||"",n.fragment||"")},up=/^\/{0,2}(?:([^@]*)@)?([^:]+)(?::{1}(\d+))?/,fp=/%[0-9A-F]{2}/ig,ep=function(n){var i=vf(n),r=i.scheme,u=i.authority,t;return r&&(i.scheme=r.toLowerCase(),u&&(t=up.exec(u),t&&(i.authority="//"+(t[1]?t[1]+"@":"")+t[2].toLowerCase()+(t[3]?":"+t[3]:"")))),n=ns(i),n.replace(fp,function(n){return n.toLowerCase()})},c=function(n,t){var i,u,r,f;return t?(i=vf(n),i.isAbsolute)?n:(u=vf(t),r={},i.authority?(r.authority=i.authority,f=i.path,r.query=i.query):(i.path?(f=i.path.charA
 t(0)==="/"?i.path:op(i.path,u.path),r.query=i.query):(f=u.path,r.query=i.query||u.query),r.authority=u.authority),r.path=sp(f),r.scheme=u.scheme,r.fragment=i.fragment,ns(r)):n},op=function(n,t){var i="/",r;return t&&(r=t.lastIndexOf("/"),i=t.substring(0,r),i.charAt(i.length-1)!=="/"&&(i=i+"/")),i+n},sp=function(n){for(var t="",r="",i;n;)n.indexOf("..")===0||n.indexOf(".")===0?n=n.replace(/^\.\.?\/?/g,""):n.indexOf("/..")===0?(n=n.replace(/^\/\..\/?/g,"/"),i=t.lastIndexOf("/"),t=i===-1?"":t.substring(0,i)):n.indexOf("/.")===0?n=n.replace(/^\/\.\/?/g,"/"):(r=n,i=n.indexOf("/",1),i!==-1&&(r=n.substring(0,i)),t=t+r,n=n.replace(r,""));return t},hp=function(i){var r=[],o,u,f,s,e,h;if(n.atob===t)r=cp(i);else for(o=n.atob(i),u=0;u<o.length;u++)r.push(o.charCodeAt(u));for(f="",s="0123456789ABCDEF",e=0;e<r.length;e++)h=r[e],f+=s[h>>4],f+=s[h&15];return f},cp=function(n){for(var i="",r,u,f,e,o,t=0;t<n.length;t++)r=lp(n[t]),u="",r!==null&&(u=r.toString(2),i+=ap(u));for(f=[],e=parseInt(i.length/
 8,10),t=0;t<e;t++)o=parseInt(i.substring(t*8,(t+1)*8),2),f.push(o);return f},lp=function(n){var t=n.charCodeAt(0),i=65,r=6;return t>=65&&t<=90?t-i:t>=97&&t<=122?t-i-r:t>=48&&t<=57?t+4:n=="+"?62:n=="/"?63:null},ap=function(n){while(n.length<6)n="0"+n;return n},uu="http://",or=uu+"www.w3.org/",ts=or+"1999/xhtml",sr=or+"2000/xmlns/",yi=or+"XML/1998/namespace",is=uu+"www.mozilla.org/newlayout/xml/parsererror.xml",vp=function(n){var t=/(^\s)|(\s$)/;return t.test(n)},yp=function(n){var t=/^\s*$/;return n===null||t.test(n)},pp=function(n){while(n!==null&&n.nodeType===1){var t=st(n,"space",yi);if(t==="preserve")return!0;if(t==="default")break;else n=n.parentNode}return!1},wp=function(n){var t=n.nodeName;return t=="xmlns"||t.indexOf("xmlns:")===0},fu=function(n,t,i){try{n.setProperty(t,i)}catch(r){}},bp=function(){var n=bo("Msxml2.DOMDocument.3.0");return n&&(fu(n,"ProhibitDTD",!0),fu(n,"MaxElementDepth",256),fu(n,"AllowDocumentFunction",!1),fu(n,"AllowXsltScript",!1)),n},rs=function(){try{v
 ar n=bo("Msxml2.DOMDocument.6.0");return n&&(n.async=!0),n}catch(t){return bp()}},kp=function(n){var t=rs(),i;return t?(t.loadXML(n),i=t.parseError,i.errorCode!==0&&hr(i.reason,i.srcText,n),t):null},hr=function(n,t,i){typeof n=="string"&&(n={message:n});throw g(n,{srcText:t||"",errorXmlText:i||""});},eu=function(t){var s=n.DOMParser&&new n.DOMParser,r,e,l;if(!s)return r=kp(t),r||hr("XML DOM parser not supported"),r;try{r=s.parseFromString(t,"text/xml")}catch(v){hr(v,"",t)}var i=r.documentElement,h=i.namespaceURI,c=f(i);if(c==="parsererror"&&h===is&&(e=b(i,is,"sourcetext"),l=e?bi(e):"",hr(k(i)||"",l,t)),c==="h3"&&h===ts||nw(i,ts,"h3")){for(var o="",a=[],u=i.firstChild;u;)u.nodeType===1&&(o+=k(u)||""),a.push(u.nextSibling),u=u.firstChild||a.shift();o+=k(i)||"",hr(o,"",t)}return r},wt=function(n,t){return n?n+":"+t:t},dp=function(n,t){if(vp(t.data)){var i=wi(n,yi,"space");i||(i=si(n.ownerDocument,yi,wt("xml","space")),l(n,i)),i.value="preserve"}return n.appendChild(t),n},pi=function(n,
 t){for(var r=n.attributes,i=0,u=r.length;i<u;i++)t(r.item(i))},st=function(n,t,i){var r=wi(n,t,i);return r?bi(r):null},wi=function(n,t,i){var r=n.attributes;return r.getNamedItemNS?r.getNamedItemNS(i||null,t):r.getQualifiedItem(t,i)||null},rt=function(n,t){var i=wi(n,"base",yi);return(i?c(i.value,t):t)||null},p=function(n,t){yf(n,!1,function(n){return n.nodeType===1&&t(n),!0})},us=function(n,t,i){for(var u=i.split("/"),r=0,f=u.length;r<f;r++)n=n&&b(n,t,u[r]);return n||null},gp=function(n,t,i){var f=i.lastIndexOf("/"),r=i.substring(f+1),e=i.substring(0,f),u=e?us(n,t,e):n;return u?r.charAt(0)==="@"?wi(u,r.substring(1),t):b(u,t,r):null},b=function(n,t,i){return fs(n,t,i,!1)},nw=function(n,t,i){if(n.getElementsByTagNameNS){var r=n.getElementsByTagNameNS(t,i);return r.length>0?r[0]:null}return fs(n,t,i,!0)},fs=function(n,t,i,r){var e=null;return yf(n,r,function(n){if(n.nodeType===1){var r=!t||u(n)===t,o=!i||f(n)===i;r&&o&&(e=n)}return e===null}),e},k=function(n){var i=null,r=n.nodeType==
 =9&&n.documentElement?n.documentElement:n,f=r.ownerDocument.preserveWhiteSpace===!1,u;return yf(r,!1,function(n){if(n.nodeType===3||n.nodeType===4){var e=bi(n),o=f||!yp(e);o||(u===t&&(u=pp(r)),o=u),o&&(i?i+=e:i=e)}return!0}),i},f=function(n){return n.localName||n.baseName},u=function(n){return n.namespaceURI||null},bi=function(n){return n.nodeType===1?k(n):n.nodeValue},yf=function(n,t,i){for(var f=[],r=n.firstChild,u=!0;r&&u;)u=i(r),u&&(t&&r.firstChild&&f.push(r.firstChild),r=r.nextSibling||f.shift())},tw=function(n,t,i){for(var r=n.nextSibling,e,o;r;){if(r.nodeType===1&&(e=!t||u(r)===t,o=!i||f(r)===i,e&&o))return r;r=r.nextSibling}return null},es=function(){var t=n.document.implementation;return t&&t.createDocument?t.createDocument(null,null,null):rs()},ou=function(n,t){if(!e(t))return l(n,t);for(var i=0,r=t.length;i<r;i++)t[i]&&l(n,t[i]);return n},l=function(n,t){if(t){if(typeof t=="string")return dp(n,rw(n.ownerDocument,t));t.nodeType===2?n.setAttributeNodeNS?n.setAttributeNodeNS
 (t):n.setAttributeNode(t):n.appendChild(t)}return n},si=function(n,i,r,u){var f=n.createAttributeNS&&n.createAttributeNS(i,r)||n.createNode(2,r,i||t);return f.value=u||"",f},cr=function(n,i,r,u){var f=n.createElementNS&&n.createElementNS(i,r)||n.createNode(1,r,i||t);return ou(f,u||[])},os=function(n,t,i){return si(n,sr,wt("xmlns",i),t)},iw=function(n,t){for(var f="<c>"+t+"<\/c>",e=eu(f),r=e.documentElement,o=("importNode"in n)?n.importNode(r,!0):r,u=n.createDocumentFragment(),i=o.firstChild;i;)u.appendChild(i),i=i.nextSibling;return u},rw=function(n,t){return n.createTextNode(t)},uw=function(n,t,i,r,u){for(var f="",h=u.split("/"),c=b,a=cr,o=t,e,s=0,v=h.length;s<v;s++)f=h[s],f.charAt(0)==="@"&&(f=f.substring(1),c=wi,a=si),e=c(o,i,f),e||(e=a(n,i,wt(r,f)),l(o,e)),o=e;return o},pf=function(t){var i=n.XMLSerializer,r;if(i)return r=new i,r.serializeToString(t);if(t.xml)return t.xml;throw{message:"XML serialization unsupported"};},fw=function(n){var f=n.childNodes,t,r=f.length,i;if(r===0)r
 eturn"";var e=n.ownerDocument,o=e.createDocumentFragment(),u=e.createElement("c");for(o.appendChild(u),t=0;t<r;t++)u.appendChild(f[t]);for(i=pf(o),i=i.substr(3,i.length-7),t=0;t<r;t++)n.appendChild(u.childNodes[t]);return i},vit=function(i){var r=i.xml,u;if(r!==t)return r;if(n.XMLSerializer)return u=new n.XMLSerializer,u.serializeToString(i);throw{message:"XML serialization unsupported"};},ew=function(n,t,i){return function(){return n[t].apply(n,arguments),i}},ki=function(){this._arguments=t,this._done=t,this._fail=t,this._resolved=!1,this._rejected=!1};ki.prototype={then:function(n,t){return n&&(this._done?this._done.push(n):this._done=[n]),t&&(this._fail?this._fail.push(t):this._fail=[t]),this._resolved?this.resolve.apply(this,this._arguments):this._rejected&&this.reject.apply(this,this._arguments),this},resolve:function(){if(this._done){for(var n=0,i=this._done.length;n<i;n++)this._done[n].apply(null,arguments);this._done=t,this._resolved=!1,this._arguments=t}else this._resolved=
 !0,this._arguments=arguments},reject:function(){if(this._fail){for(var n=0,i=this._fail.length;n<i;n++)this._fail[n].apply(null,arguments);this._fail=t,this._rejected=!1,this._arguments=t}else this._rejected=!0,this._arguments=arguments},promise:function(){var n={};return n.then=ew(this,"then",n),n}};var su=function(){return n.jQuery&&n.jQuery.Deferred?new n.jQuery.Deferred:new ki},ss=function(n,t){var i=(n&&n.__metadata||{}).type;return i||(t?t.type:null)},v="Edm.",hs=v+"Binary",cs=v+"Boolean",ls=v+"Byte",hu=v+"DateTime",cu=v+"DateTimeOffset",as=v+"Decimal",vs=v+"Double",ys=v+"Guid",ps=v+"Int16",ws=v+"Int32",bs=v+"Int64",ks=v+"SByte",ds=v+"Single",lr=v+"String",lu=v+"Time",ht=v+"Geography",gs=ht+"Point",nh=ht+"LineString",th=ht+"Polygon",ih=ht+"Collection",rh=ht+"MultiPolygon",uh=ht+"MultiLineString",fh=ht+"MultiPoint",et=v+"Geometry",eh=et+"Point",oh=et+"LineString",sh=et+"Polygon",hh=et+"Collection",ch=et+"MultiPolygon",lh=et+"MultiLineString",ah=et+"MultiPoint",wf="Point",bf="Li
 neString",kf="Polygon",df="MultiPoint",gf="MultiLineString",ne="MultiPolygon",te="GeometryCollection",ow=[lr,ws,bs,cs,vs,ds,hu,cu,lu,as,ys,ls,ps,ks,hs],sw=[et,eh,oh,sh,hh,ch,lh,ah],hw=[ht,gs,nh,th,ih,rh,uh,fh],hi=function(n,t){if(!n)return null;if(e(n)){for(var r,i=0,u=n.length;i<u;i++)if(r=hi(n[i],t),r)return r;return null}return n.dataServices?hi(n.dataServices.schema,t):t(n)},vh=function(n,t){return n=n===0?"":"."+a(n.toString(),3),t>0&&(n===""&&(n=".000"),n+=a(t.toString(),4)),n},yh=function(n){var u,t,e;if(typeof n=="string")return n;if(u=vw(n),t=wh(n.__offset),u&&t!=="Z"){n=new Date(n.valueOf());var i=ec(t),o=n.getUTCHours()+i.d*i.h,s=n.getUTCMinutes()+i.d*i.m;n.setUTCHours(o,s)}else u||(t="");var r=n.getUTCFullYear(),h=n.getUTCMonth()+1,f="";return r<=0&&(r=-(r-1),f="-"),e=vh(n.getUTCMilliseconds(),n.__ns),f+a(r,4)+"-"+a(h,2)+"-"+a(n.getUTCDate(),2)+"T"+a(n.getUTCHours(),2)+":"+a(n.getUTCMinutes(),2)+":"+a(n.getUTCSeconds(),2)+e+t},ph=function(n){var t=n.ms,e="",i,r,u,f;retur
 n t<0&&(e="-",t=-t),i=Math.floor(t/864e5),t-=864e5*i,r=Math.floor(t/36e5),t-=36e5*r,u=Math.floor(t/6e4),t-=6e4*u,f=Math.floor(t/1e3),t-=f*1e3,e+"P"+a(i,2)+"DT"+a(r,2)+"H"+a(u,2)+"M"+a(f,2)+vh(t,n.ns)+"S"},a=function(n,t,i){for(var r=n.toString(10);r.length<t;)i?r+="0":r="0"+r;return r},wh=function(n){return!n||n==="Z"||n==="+00:00"||n==="-00:00"?"Z":n},au=function(n){if(typeof n=="string"){var t=n.indexOf(")",10);if(n.indexOf("Collection(")===0&&t>0)return n.substring(11,t)}return null},cw=function(n,i,r,u,f,e){return f.request(n,function(f){try{f.headers&&ee(f.headers),f.data===t&&f.statusCode!==204&&u.read(f,e)}catch(o){o.request===t&&(o.request=n),o.response===t&&(o.response=f),r(o);return}i(f.data,f)},r)},lw=function(n){return d(n)&&e(n.__batchRequests)},aw=/Collection\((.*)\)/,bh=function(n,t){var i=n&&n.results||n;return!!i&&vu(t)||!t&&e(i)&&!d(i[0])},vu=function(n){return aw.test(n)},d=function(n){return!!n&&lf(n)&&!e(n)&&!cf(n)},vw=function(n){return n.__edmType==="Edm.DateT
 imeOffset"||!n.__edmType&&n.__offset},kh=function(n){if(!n&&!d(n))return!1;var t=n.__metadata||{},i=n.__deferred||{};return!t.type&&!!i.uri},dh=function(n){return d(n)&&n.__metadata&&"uri"in n.__metadata},ar=function(n,t){var i=n&&n.results||n;return e(i)&&!vu(t)&&d(i[0])},ie=function(n){return fr(hw,n)},re=function(n){return fr(sw,n)},gh=function(n){if(!n&&!d(n))return!1;var i=n.__metadata,t=n.__mediaresource;return!i&&!!t&&!!t.media_src},yu=function(n){return cf(n)||typeof n=="string"||typeof n=="number"||typeof n=="boolean"},ue=function(n){return fr(ow,n)},nc=function(n,i){return kh(n)?"deferred":dh(n)?"entry":ar(n)?"feed":i&&i.relationship?n===null||n===t||!ar(n)?"entry":"feed":null},bt=function(n,t){return er(n,function(n){return n.name===t})},fe=function(n,t,i){return n?hi(t,function(t){return dw(n,t,i)}):null},yw=function(n,t){return er(n,function(n){return n.name===t})},di=function(n,t){return fe(n,t,"complexType")},kt=function(n,t){return fe(n,t,"entityType")},tc=function(n
 ){return hi(n,function(n){return er(n.entityContainer,function(n){return oe(n.isDefaultEntityContainer)})})},ic=function(n,t){return fe(n,t,"entityContainer")},pw=function(n,t){return er(n,function(n){return n.name===t})},ww=function(n,t){var u=null,f,i,r;return n&&(f=n.relationship,i=hi(t,function(n){var r=rc(n.namespace,f),i=n.association,t,u;if(r&&i)for(t=0,u=i.length;t<u;t++)if(i[t].name===r)return i[t];return null}),i&&(r=i.end[0],r.role!==n.toRole&&(r=i.end[1]),u=r.type)),u},bw=function(n,t,i){if(n){var u=n.relationship,r=hi(i,function(n){for(var f=n.entityContainer,t,i,r=0;r<f.length;r++)if(t=f[r].associationSet,t)for(i=0;i<t.length;i++)if(t[i].association==u)return t[i];return null});if(r&&r.end[0]&&r.end[1])return r.end[0].entitySet==t?r.end[1].entitySet:r.end[0].entitySet}return null},kw=function(n,t){return hi(t,function(t){for(var f=t.entityContainer,r,u,i=0;i<f.length;i++)if(r=f[i].entitySet,r)for(u=0;u<r.length;u++)if(r[u].name==n)return{entitySet:r[u],containerName:f[
 i].name,functionImport:f[i].functionImport};return null})},rc=function(n,t){return t.indexOf(n)===0&&t.charAt(n.length)==="."?t.substr(n.length+1):null},dw=function(n,t,i){if(n&&t){var r=rc(t.namespace,n);if(r)return er(t[i],function(n){return n.name===r})}return null},ct=function(n,t){var i,f,e;if(n===t)return n;var r=n.split("."),u=t.split("."),o=r.length>=u.length?r.length:u.length;for(i=0;i<o;i++){if(f=r[i]&&s(r[i]),e=u[i]&&s(u[i]),f>e)return n;if(f<e)return t}},gw={accept:"Accept","content-type":"Content-Type",dataserviceversion:"DataServiceVersion",maxdataserviceversion:"MaxDataServiceVersion"},ee=function(n){var t,r,i,u;for(t in n)r=t.toLowerCase(),i=gw[r],i&&t!==i&&(u=n[t],delete n[t],n[i]=u)},oe=function(n){return typeof n=="boolean"?n:typeof n=="string"&&n.toLowerCase()==="true"},nb=/^(-?\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d+))?(.*)$/,uc=function(n,t,i){var r=nb.exec(n),o=r?wh(r[8]):null,h,u,e,c,l,f;if(!r||!t&&o!=="Z"){if(i)return null;throw{message:
 "Invalid date/time value"};}if(h=s(r[1]),h<=0&&h++,u=r[7],e=0,u){if(u.length>7){if(i)return null;throw{message:"Cannot parse date/time value to given precision."};}e=a(u.substring(3),4,!0),u=a(u.substring(0,3),3,!0),u=s(u),e=s(e)}else u=0;var v=s(r[4]),y=s(r[5]),p=s(r[6])||0;if(o!=="Z"&&(c=ec(o),l=-c.d,v+=c.h*l,y+=c.m*l),f=new Date,f.setUTCFullYear(h,s(r[2])-1,s(r[3])),f.setUTCHours(v,y,p,u),isNaN(f.valueOf())){if(i)return null;throw{message:"Invalid date/time value"};}return t&&(f.__edmType="Edm.DateTimeOffset",f.__offset=o),e&&(f.__ns=e),f},pu=function(n,t){return uc(n,!1,t)},se=function(n,t){return uc(n,!0,t)},fc=/^([+-])?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d+))?S)?)?/,yit=function(n){fc.test(n)},he=function(n){var i=fc.exec(n),t,r,u;if(i===null)throw{message:"Invalid duration value."};var f=i[2]||"0",e=i[3]||"0",o=s(i[4]||0),h=s(i[5]||0),c=s(i[6]||0),l=parseFloat(i[7]||0);if(f!=="0"||e!=="0")throw{message:"Unsupported duration value."};if(t
 =i[8],r=0,t){if(t.length>7)throw{message:"Cannot parse duration value to given precision."};r=a(t.substring(3),4,!0),t=a(t.substring(0,3),3,!0),t=s(t),r=s(r)}else t=0;return t+=l*1e3+c*6e4+h*36e5+o*864e5,i[1]==="-"&&(t=-t),u={ms:t,__edmType:"Edm.Time"},r&&(u.ns=r),u},ec=function(n){var t=n.substring(0,1),i,r;return t=t==="+"?1:-1,i=s(n.substring(1)),r=s(n.substring(n.indexOf(":")+1)),{d:t,h:i,m:r}},oc=function(n,i,r){n.method||(n.method="GET"),n.headers?ee(n.headers):n.headers={},n.headers.Accept===t&&(n.headers.Accept=i.accept),ot(n.data)&&n.body===t&&i.write(n,r),ot(n.headers.MaxDataServiceVersion)||(n.headers.MaxDataServiceVersion=i.maxDataServiceVersion||"1.0")},sc=function(n,i,r){var u,e,f;if(n&&typeof n=="object")for(u in n)e=n[u],f=sc(e,u,r),f=r(u,f,i),f!==e&&(e===t?delete n[u]:n[u]=f);return n},tb=function(n,t){return t("",sc(n,"",t))},wu=0,ib=function(n){return n.method&&n.method!=="GET"?!1:!0},rb=function(t){var i=n.document.createElement("IFRAME");i.style.display="none";v
 ar r=t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/\</g,"&lt;"),u='<html><head><script type="text/javascript" src="'+r+'"><\/script><\/head><body><\/body><\/html>',f=n.document.getElementsByTagName("BODY")[0];return f.appendChild(i),hc(i,u),i},ub=function(){if(n.XMLHttpRequest)return new n.XMLHttpRequest;var t;if(n.ActiveXObject)try{return new n.ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(i){try{return new n.ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(r){t=r}}else t={message:"XMLHttpRequest not supported"};throw t;},fb=function(n){return n.indexOf("http://")===0||n.indexOf("https://")===0||n.indexOf("file://")===0},eb=function(t){if(!fb(t))return!0;var i=n.location,r=i.protocol+"//"+i.host+"/";return t.indexOf(r)===0},ob=function(i,r){try{delete n[i]}catch(u){n[i]=t,r===wu-1&&(wu-=1)}},bu=function(n){return n&&(hc(n,""),n.parentNode.removeChild(n)),null},sb=function(n,t){for(var r=n.getAllResponseHeaders().split(/\r?\n/),u,i=0,f=r.length;i<f;i++)r[i]&&(u=r[i].split(": "),t[u[0
 ]]=u[1])},hc=function(n,t){var i=n.contentWindow?n.contentWindow.document:n.contentDocument.document;i.open(),i.write(t),i.close()};r.defaultHttpClient={callbackParameterName:"$callback",formatQueryString:"$format=json",enableJsonpCallback:!1,request:function(i,r,u){var y={},f=null,h=!1,s,a,w,b,k,d,l,v;y.abort=function(){(s=bu(s),h)||(h=!0,f&&(f.abort(),f=null),u({message:"Request aborted"}))};var p=function(){s=bu(s),h||(h=!0,f=null,u({message:"Request timed out"}))},c,e=i.requestUri,g=it(i.enableJsonpCallback,this.enableJsonpCallback),nt=it(i.callbackParameterName,this.callbackParameterName),tt=it(i.formatQueryString,this.formatQueryString);if(!g||eb(e)){if(f=ub(),f.onreadystatechange=function(){var t,n,o,s;h||f===null||f.readyState!==4||(t=f.statusText,n=f.status,n===1223&&(n=204,t="No Content"),o=[],sb(f,o),s={requestUri:e,statusCode:n,statusText:t,headers:o,body:f.responseText},h=!0,f=null,n>=200&&n<=299?r(s):u({message:"HTTP request failed",request:i,response:s}))},f.open(i.me
 thod||"GET",e,!0,i.user,i.password),i.headers)for(c in i.headers)f.setRequestHeader(c,i.headers[c]);i.timeoutMS&&(f.timeout=i.timeoutMS,f.ontimeout=p),f.send(i.body)}else{if(!ib(i))throw{message:"Request is not local and cannot be done through JSONP."};a=wu,wu+=1,w=a.toString(),b=!1,c="handleJSONP_"+w,n[c]=function(i){if(s=bu(s),!h){b=!0,n.clearTimeout(k),ob(c,a),n.ActiveXObject&&(i=n.JSON.parse(n.JSON.stringify(i)));var u;u=i.d===t?{"Content-Type":"application/json;odata.metadata=minimal",dataServiceVersion:"4.0"}:{"Content-Type":"application/json"},o(function(){bu(s),r({body:i,statusCode:200,headers:u})})}},d=i.timeoutMS?i.timeoutMS:12e4,k=n.setTimeout(p,d),l=nt+"=parent."+c,this.formatQueryString&&(l+="&"+tt),v=e.indexOf("?"),e=v===-1?e+"?"+l:v===e.length-1?e+l:e+"&"+l,s=rb(e)}return y}};var ci="4.0",gi=function(n){var t,r,i,f,u;if(!n)return null;for(t=n.split(";"),r={},i=1,f=t.length;i<f;i++)u=t[i].split("="),r[ko(u[0])]=u[1];return{mediaType:ko(t[0]),properties:r}},hb=function(
 n){if(!n)return t;var r=n.mediaType,i;for(i in n.properties)r+=";"+i+"="+n.properties[i];return r},cc=function(n,t,i,r){var u={};return g(u,i),g(u,{contentType:n,dataServiceVersion:t,handler:r}),u},lc=function(n,t,i){if(n){var r=n.headers;r[t]||(r[t]=i)}},cb=function(n,t){if(n){var i=n.headers,r=i.DataServiceVersion;i.DataServiceVersion=r?ct(r,t):t}},ac=function(n,i){var r=n.headers;return r&&r[i]||t},vc=function(n){return gi(ac(n,"Content-Type"))},lb=/^\s?(\d+\.\d+);?.*$/,yc=function(n){var i=ac(n,"DataServiceVersion"),t;if(i&&(t=lb.exec(i),t&&t.length))return t[1]},pc=function(n,t){return n.accept.indexOf(t.mediaType)>=0},ab=function(n,i,r,u){var f;if(!r||!r.headers)return!1;var e=vc(r),s=yc(r)||"",o=r.body;return ot(o)?pc(n,e)?(f=cc(e,s,u,n),f.response=r,r.data=i(n,o,f),r.data!==t):!1:!1},vb=function(n,i,r,u){var e,o,f;return!r||!r.headers?!1:(e=vc(r),o=yc(r),(!e||pc(n,e))&&(f=cc(e,o,u,n),f.request=r,r.body=i(n,r.data,f),r.body!==t))?(cb(r,f.dataServiceVersion||"1.0"),lc(r,"Conte
 nt-Type",hb(f.contentType)),lc(r,"MaxDataServiceVersion",n.maxDataServiceVersion),!0):!1},li=function(n,t,i,r){return{accept:i,maxDataServiceVersion:r,read:function(t,i){return ab(this,n,t,i)},write:function(n,i){return vb(this,t,n,i)}}},yb=function(n,t){return t},pb=function(n,i){return ot(i)?i.toString():t};r.textHandler=li(yb,pb,"text/plain",ci);var wc=uu+"www.opengis.net",ut=wc+"/gml",bc=wc+"/def/crs/EPSG/0/",kc="gml",vr=function(n,t,i){var r={type:n};return r[t]=i,r},ce=function(n){if(e(n)&&n.length>=2){var t=n[0];n[0]=n[1],n[1]=t}return n},le=function(n,t,i,r,u,f){var e=dc(n,i,r,u,f);return vr(t,"coordinates",e)},dc=function(n,t,i,r,e){var o=[];return p(n,function(n){var s,h,c;if(u(n)===ut){if(s=f(n),s===t){h=b(n,ut),h&&(c=r(h,e),c&&o.push(c));return}s===i&&p(n,function(n){if(u(n)===ut){var t=r(n,e);t&&o.push(t)}})}}),o},wb=function(n,t){var i=dc(n,"geometryMember","geometryMembers",tl,t);return vr(te,"geometries",i)},bb=function(n,t){return vr(bf,"coordinates",ae(n,t))},kb=fu
 nction(n,t){return le(n,gf,"curveMember","curveMembers",ae,t)},db=function(n,t){return le(n,df,"pointMember","pointMembers",ve,t)},gb=function(n,t){return le(n,ne,"surfaceMember","surfaceMembers",gc,t)},nk=function(n,t){return vr(wf,"coordinates",ve(n,t))},tk=function(n,t){return vr(kf,"coordinates",gc(n,t))},ae=function(n,t){var i=[];return p(n,function(n){var e=u(n),r;if(e===ut){if(r=f(n),r==="posList"){i=rk(n,t);return}if(r==="pointProperty"){i.push(ik(n,t));return}if(r==="pos"){i.push(ye(n,t));return}}}),i},ve=function(n,t){var i=b(n,ut,"pos");return i?ye(i,t):[]},ik=function(n,t){var i=b(n,ut,"Point");return i?ve(i,t):[]},gc=function(n,t){var i=[],r=!1;return p(n,function(n){if(u(n)===ut){var e=f(n);if(e==="exterior"){r=!0,i.unshift(nl(n,t));return}if(e==="interior"){i.push(nl(n,t));return}}}),!r&&i.length>0&&i.unshift([[]]),i},nl=function(n,t){var i=[];return p(n,function(n){u(n)===ut&&f(n)==="LinearRing"&&(i=ae(n,t))}),i},rk=function(n,t){var f=ye(n,!1),e=f.length,r,i,u;if(e%
 2!=0)throw{message:"GML posList element has an uneven number of numeric values"};for(r=[],i=0;i<e;i+=2)u=f.slice(i,i+2),r.push(t?ce(u):u);return r},ye=function(n,t){var u=[],o=" \t\r\n",r=k(n),f;if(r)for(var s=r.length,e=0,i=0;i<=s;)o.indexOf(r.charAt(i))!==-1&&(f=r.substring(e,i),f&&u.push(parseFloat(f)),e=i+1),i++;return t?ce(u):u},tl=function(n,t){var o=f(n),i,u,r,e;switch(o){case"Point":i=nk;break;case"Polygon":i=tk;break;case"LineString":i=bb;break;case"MultiPoint":i=db;break;case"MultiCurve":i=kb;break;case"MultiSurface":i=gb;break;case"MultiGeometry":i=wb;break;default:throw{message:"Unsupported element: "+o,element:n};}if(u=i(n,t),r=st(n,"srsName",ut)||st(n,"srsName"),r){if(r.indexOf(bc)!==0)throw{message:"Unsupported srs name: "+r,element:n};e=r.substring(bc.length),e&&(u.crs={type:"name",properties:{name:"EPSG:"+e}})}return u},il=function(n,t,i,r){var u,o,e,s,f,h,c;switch(i){case wf:u=uk;break;case bf:u=fk;break;case kf:u=ek;break;case df:u=ok;break;case gf:u=sk;break;case
  ne:u=hk;break;case te:u=lk;break;default:return null}return o=u(n,t,r),e=t.crs,e&&e.type==="name"&&(s=e.properties,f=s&&s.name,f&&f.indexOf("ESPG:")===0&&f.length>5&&(h=f.substring(5),c=si(n,null,"srsName",kc+h),l(o,c))),o},dt=function(n,t,i){return cr(n,ut,wt(kc,t),i)},rl=function(n,t,i){var r=e(t)?t:[];return r=i?ce(r):r,dt(n,"pos",r.join(" "))},ul=function(n,t,i,r){var f=dt(n,t),u,o;if(e(i)){for(u=0,o=i.length;u<o;u++)l(f,rl(n,i[u],r));o===0&&l(f,dt(n,"posList"))}return f},fl=function(n,t,i){return dt(n,"Point",rl(n,t,i))},el=function(n,t,i){return ul(n,"LineString",t,i)},ol=function(n,t,i,r){var u=dt(n,t),f;return e(i)&&i.length>0&&(f=ul(n,"LinearRing",i,r),l(u,f)),u},sl=function(n,t,i){var f=t&&t.length,u=dt(n,"Polygon"),r;if(e(t)&&f>0)for(l(u,ol(n,"exterior",t[0],i)),r=1;r<f;r++)l(u,ol(n,"interior",t[r],i));return u},uk=function(n,t,i){return fl(n,t.coordinates,i)},fk=function(n,t,i){return el(n,t.coordinates,i)},ek=function(n,t,i){return sl(n,t.coordinates,i)},ku=function(n,
 t,i,r,u,f){var h=r&&r.length,c=dt(n,t),s,o;if(e(r)&&h>0){for(s=dt(n,i),o=0;o<h;o++)l(s,u(n,r[o],f));l(c,s)}return c},ok=function(n,t,i){return ku(n,"MultiPoint","pointMembers",t.coordinates,fl,i)},sk=function(n,t,i){return ku(n,"MultiCurve","curveMembers",t.coordinates,el,i)},hk=function(n,t,i){return ku(n,"MultiSurface","surfaceMembers",t.coordinates,sl,i)},ck=function(n,t,i){return il(n,t,t.type,i)},lk=function(n,t,i){return ku(n,"MultiGeometry","geometryMembers",t.geometries,ck,i)},du="application/xml",ak=uu+"docs.oasis-open.org/odata/",lt=ak+"ns",gu=lt+"/edmx",vk=lt+"/edm",at=lt,nt=lt+"/metadata",pe=lt+"/related/",hl=lt+"/scheme",cl="d",we="m",gt=function(n,t){var i={name:f(n),value:n.value};return i[t?"namespaceURI":"namespace"]=u(n),i},yr=function(n,t){for(var s=[],h=[],c=n.attributes,e,i,o,r=0,l=c.length;r<l;r++)e=c[r],u(e)!==sr&&s.push(gt(e,t));for(i=n.firstChild;i!=null;)i.nodeType===1&&h.push(yr(i,t)),i=i.nextSibling;return o={name:f(n),value:k(n),attributes:s,children:h},
 o[t?"namespaceURI":"namespace"]=u(n),o},be=function(n){return u(n)===at&&f(n)==="element"},ll=function(n,t){return{type:n,extensions:t}},yk=function(n){var t,i;return b(n,ut)?et:(t=b(n,at),!t)?lr:be(t)&&(i=tw(t,at),i&&be(i))?"Collection()":null},al=function(n){var t=null,i=!1,r=[];return pi(n,function(n){var e=u(n),o=f(n),s=bi(n);if(e===nt){if(o==="null"){i=s.toLowerCase()==="true";return}if(o==="type"){t=s;return}}if(e!==yi&&e!==sr){r.push(gt(n,!0));return}}),{type:!t&&i?lr:t,isNull:i,extensions:r}},vl=function(n){if(u(n)!==at)return null;var e=f(n),t=al(n),o=t.isNull,i=t.type,r=ll(i,t.extensions),s=o?null:yl(n,i,r);return{name:e,value:s,metadata:r}},yl=function(n,t,i){t||(t=yk(n),i.type=t);var r=ie(t);return r||re(t)?pk(n,t,r):ue(t)?pl(n,t):vu(t)?bk(n,t,i):wk(n,t,i)},pk=function(n,t,i){var u=b(n,ut),r=tl(u,i);return r.__metadata={type:t},r},pl=function(n,t){var i=bi(n)||"";switch(t){case cs:return oe(i);case hs:case as:case ys:case bs:case lr:return i;case ls:case ps:case ws:case 
 ks:return s(i);case vs:case ds:return parseFloat(i);case lu:return he(i);case hu:return pu(i);case cu:return se(i)}return i},wk=function(n,t,i){var r={__metadata:{type:t}};return p(n,function(n){var t=vl(n),u=t.name;i.properties=i.properties||{},i.properties[u]=t.metadata,r[u]=t.value}),r},bk=function(n,t,i){var r=[],u=i.elements=[],f=au(t);return p(n,function(n){if(be(n)){var t=al(n),o=t.extensions,i=t.type||f,e=ll(i,o),s=yl(n,i,e);r.push(s),u.push(e)}}),{__metadata:{type:t==="Collection()"?null:t},results:r}},kk=function(n,i){if(u(n)===at){i=rt(n,i);var r=f(n);if(r==="links")return dk(n,i);if(r==="uri")return wl(n,i)}return t},dk=function(n,t){var i=[];return p(n,function(n){f(n)==="uri"&&u(n)===at&&i.push(wl(n,t))}),{results:i}},wl=function(n,t){var i=k(n)||"";return{uri:c(i,t)}},gk=function(n,t){return t===et||t===ht?n&&n.type:t===eh||t===gs?wf:t===oh||t===nh?bf:t===sh||t===th?kf:t===hh||t===ih?te:t===ch||t===rh?ne:t===lh||t===uh?gf:t===ah||t===fh?df:null},bl=function(n,t,i){ret
 urn cr(n,nt,wt(we,t),i)},ke=function(n,t,i){return si(n,nt,wt(we,t),i)},kl=function(n,t,i){return cr(n,at,wt(cl,t),i)},nd=function(n,t){return t===hu||t===cu||cf(n)?yh(n):t===lu?ph(n):n.toString()},vt=function(n,t){return{element:n,dsv:t}},pr=function(n,t,i,r){var u=i?ke(n,"type",i):null,f=kl(n,t,u);return ou(f,r)},td=function(n,t,i,r){var u=nd(i,r),f=pr(n,t,r,u);return vt(f,"1.0")},id=function(n,t,i,r){var u=ke(n,"null","true"),f=pr(n,t,i,u),e=di(i,r)?"2.0":"1.0";return vt(f,e)},rd=function(n,t,i,r,u,f,o){var c=au(r),a=e(i)?i:i.results,v=r?{type:c}:{},h,s,y,p,w;for(v.properties=u.properties,h=pr(n,t,c?r:null),s=0,y=a.length;s<y;s++)p=a[s],w=de(n,"element",p,v,f,o),l(h,w.element);return vt(h,"4.0")},ud=function(n,t,i,r,u,f,e){var h=pr(n,t,r),a=u.properties||{},v=di(r,e)||{},s="1.0",o;for(o in i)if(o!=="__metadata"){var y=i[o],p=bt(v.property,o),w=a[o]||{},c=de(n,o,y,w,p,e);s=ct(s,c.dsv),l(h,c.element)}return vt(h,s)},fd=function(n,t,i,r,u){var f=gk(i,r),e=il(n,i,f,u),o=pr(n,t,r,e);r
 eturn vt(o,".0")},de=function(n,t,i,r,u,f){var e=ss(i,r,u),o,s;return yu(i)?td(n,t,i,e||lr):(o=ie(e),o||re(e))?fd(n,t,i,e,o):bh(i,e)?rd(n,t,i,e,r,u,f):gh(i)?null:(s=nc(i,u),s!==null)?null:i===null?id(n,t,e):ud(n,t,i,e,r,u,f)},ed=function(n){if(n&&lf(n)){var t=es();return l(t,kl(t,"uri",n.uri))}},od=function(n,t){if(t){var r=eu(t),i=b(r);if(i)return kk(i)}},sd=function(n,i,r){var u=r.contentType=r.contentType||gi(du);return u&&u.mediaType===du?pf(ed(i)):t};r.xmlHandler=li(od,sd,du,ci);var dl="a",ni=or+"2005/Atom",wr=or+"2007/app",gl=lt+"/edit-media/",na=lt+"/mediaresource/",ta=lt+"/relatedlinks/",ia=["application/atom+xml","application/atomsvc+xml","application/xml"],ra=ia[0],hd=[ni,wr,yi,sr],cd={SyndicationAuthorEmail:"author/email",SyndicationAuthorName:"author/name",SyndicationAuthorUri:"author/uri",SyndicationContributorEmail:"contributor/email",SyndicationContributorName:"contributor/name",SyndicationContributorUri:"contributor/uri",SyndicationPublished:"published",SyndicationRi
 ghts:"rights",SyndicationSummary:"summary",SyndicationTitle:"title",SyndicationUpdated:"updated"},ld=function(n){return cd[n]||n},br=function(n){return!fr(hd,n)},ua=function(n,t,i,r,u){var f;if(u=u||"",f=n["FC_TargetPath"+u],!f)return null;var e=n["FC_SourcePath"+u],s=ld(f),o=r?r+(e?"/"+e:""):e,l=o&&bd(i,t,o),h=n["FC_NsUri"+u]||null,c=n["FC_NsPrefix"+u]||null,a=n["FC_KeepInContent"+u]||"";return f!==s&&(h=ni,c=dl),{contentKind:n["FC_ContentKind"+u],keepInContent:a.toLowerCase()==="true",nsPrefix:c,nsURI:h,propertyPath:o,propertyType:l,entryPath:s}},fa=function(n,t,i){for(var c=[],l,r,f,u,e;n;){for(l=n.FC_SourcePath,r=ua(n,n,t),r&&i(r),f=n.property||[],u=0,e=f.length;u<e;u++)for(var o=f[u],s=0,h="";r=ua(o,n,t,o.name,h);)i(r),s++,h="_"+s;n=kt(n.baseType,t)}return c},nf=function(n){var t=[];return pi(n,function(n){var i=u(n);br(i)&&t.push(gt(n,!0))}),t},ea=function(n){return yr(n,!0)},oa=function(n,t,i){var e=u(n),r=f(n);if(e===wr&&r==="service")return fg(n,t);if(e===ni){if(r==="feed")
 return ad(n,t,i);if(r==="entry")return aa(n,t,i)}},sa=function(n,t){var r=[],i={extensions:r};return pi(n,function(e){var o=f(e),s=u(e),h=bi(e);if(s===null){if(o==="title"||o==="metadata"){i[o]=h;return}if(o==="target"){i.target=c(h,rt(n,t));return}}br(s)&&r.push(gt(e,!0))}),i},ha=function(n,t,i){var r=i.actions=i.actions||[];r.push(sa(n,t))},ca=function(n,t,i){var r=i.functions=i.functions||[];r.push(sa(n,t))},ad=function(n,t,i){var o=nf(n),r={feed_extensions:o},s=[],e={__metadata:r,results:s};return t=rt(n,t),p(n,function(n){var l=u(n),h=f(n);if(l===nt){if(h==="count"){e.__count=parseInt(k(n),10);return}if(h==="action"){ha(n,t,r);return}if(h==="function"){ca(n,t,r);return}}if(br(l)){o.push(yr(n));return}if(h==="entry"){s.push(aa(n,t,i));return}if(h==="link"){vd(n,e,t);return}if(h==="id"){r.uri=c(k(n),t),r.uri_extensions=nf(n);return}if(h==="title"){r.title=k(n)||"",r.title_extensions=nf(n);return}}),e},vd=function(n,t,i){var r=la(n,i),f=r.href,e=r.rel,o=r.extensions,u=t.__metadata
 ;if(e==="next"){t.__next=f,u.next_extensions=o;return}if(e==="self"){u.self=f,u.self_extensions=o;return}},la=function(n,t){t=rt(n,t);var r=[],i={extensions:r,baseURI:t};if(pi(n,function(n){var s=u(n),e=f(n),o=n.value;if(e==="href"){i.href=c(o,t);return}if(e==="type"||e==="rel"){i[e]=o;return}br(s)&&r.push(gt(n,!0))}),!i.href)throw{error:"href attribute missing on link element",element:n};return i},yd=function(n,i){if(n.indexOf("/")===-1)return i[n];for(var u=n.split("/"),r=0,f=u.length;r<f;r++){if(i===null)return t;if(i=i[u[r]],i===t)return i}return i},pd=function(n,i,r,u){var o,s,f,h,e;if(n.indexOf("/")===-1)i[n]=r,o=n;else{for(s=n.split("/"),f=0,h=s.length-1;f<h;f++){if(e=i[s[f]],e===t)e={},i[s[f]]=e;else if(e===null)return;i=e}o=s[f],i[o]=r}if(u){var c=i.__metadata=i.__metadata||{},l=c.properties=c.properties||{},a=l[o]=l[o]||{};a.type=u}},wd=function(n,t,i){var e=n.propertyPath,r,u,f;n.keepInContent||yd(e,i)===null||(r=gp(t,n.nsURI,n.entryPath),r)&&(u=n.propertyType,f=n.content
 Kind==="xhtml"?fw(r):pl(r,u||"Edm.String"),pd(e,i,f,u))},bd=function(n,t,i){for(var s=i.split("/"),u,h,f,e,o,r;t;){for(f=t,u=0,h=s.length;u<h;u++){if(e=f.property,!e)break;if(o=bt(e,s[u]),!o)break;if(r=o.type,!r||ue(r))return r||null;if(f=di(r,n),!f)return null}t=kt(t.baseType,n)}return null},aa=function(n,t,i){var r={},e={__metadata:r},o=st(n,"etag",nt),s;return o&&(r.etag=o),t=rt(n,t),p(n,function(n){var s=u(n),o=f(n);if(s===ni){if(o==="id"){kd(n,r,t);return}if(o==="category"){dd(n,r);return}if(o==="content"){gd(n,e,r,t);return}if(o==="link"){ng(n,e,r,t,i);return}return}if(s===nt){if(o==="properties"){pa(n,e,r);return}if(o==="action"){ha(n,t,r);return}if(o==="function"){ca(n,t,r);return}}}),s=kt(r.type,i),fa(s,i,function(t){wd(t,n,e)}),e},kd=function(n,t,i){t.uri=c(k(n),rt(n,i)),t.uri_extensions=nf(n)},dd=function(n,t){if(st(n,"scheme")===hl){if(t.type)throw{message:"Invalid AtomPub document: multiple category elements defining the entry type were encounterd withing an entry",elem
 ent:n};var i=[];pi(n,function(n){var t=u(n),r=f(n);if(!t){r!=="scheme"&&r!=="term"&&i.push(gt(n,!0));return}br(t)&&i.push(gt(n,!0))}),t.type=st(n,"term"),t.type_extensions=i}},gd=function(n,t,i,r){var e=st(n,"src"),o=st(n,"type");if(e){if(!o)throw{message:"Invalid AtomPub document: content element must specify the type attribute if the src attribute is also specified",element:n};i.media_src=c(e,rt(n,r)),i.content_type=o}p(n,function(r){if(e)throw{message:"Invalid AtomPub document: content element must not have child elements if the src attribute is specified",element:n};u(r)===nt&&f(r)==="properties"&&pa(r,t,i)})},ng=function(n,t,i,r,u){var f=la(n,r),e=f.rel,s=f.href,o=f.extensions;if(e==="self"){i.self=s,i.self_link_extensions=o;return}if(e==="edit"){i.edit=s,i.edit_link_extensions=o;return}if(e==="edit-media"){i.edit_media=f.href,i.edit_media_extensions=o,ya(f,i);return}if(e.indexOf(gl)===0){rg(f,t,i);return}if(e.indexOf(na)===0){ug(f,t,i);return}if(e.indexOf(pe)===0){ig(n,f,t,i,u
 );return}if(e.indexOf(ta)===0){tg(f,i);return}},tg=function(n,t){var r=n.rel.substring(ta.length),i;t.properties=t.properties||{},i=t.properties[r]=t.properties[r]||{},i.associationuri=n.href,i.associationuri_extensions=n.extensions},ig=function(n,t,i,r,u){var e,o=b(n,nt,"inline"),s,h,f,c;o?(s=b(o),h=rt(o,t.baseURI),e=s?oa(s,h,u):null):e={__deferred:{uri:t.href}},f=t.rel.substring(pe.length),i[f]=e,r.properties=r.properties||{},c=r.properties[f]=r.properties[f]||{},c.extensions=t.extensions},rg=function(n,t,i){var o=n.rel.substring(gl.length),f=va(o,t,i),r=f.value,u=f.metadata,e=n.href;r.edit_media=e,r.content_type=n.type,u.edit_media_extensions=n.extensions,r.media_src=r.media_src||e,u.media_src_extensions=u.media_src_extensions||[],ya(n,r)},ug=function(n,t,i){var f=n.rel.substring(na.length),r=va(f,t,i),u=r.value,e=r.metadata;u.media_src=n.href,e.media_src_extensions=n.extensions,u.content_type=n.type},va=function(n,t,i){i.properties=i.properties||{};var u=i.properties[n],r=t[n]&&
 t[n].__mediaresource;return r||(r={},t[n]={__mediaresource:r},i.properties[n]=u={}),{value:r,metadata:u}},ya=function(n,t){for(var r=n.extensions,i=0,u=r.length;i<u;i++)if(r[i].namespaceURI===nt&&r[i].name==="etag"){t.media_etag=r[i].value,r.splice(i,1);return}},pa=function(n,t,i){p(n,function(n){var r=vl(n),u,f;r&&(u=r.name,f=i.properties=i.properties||{},f[u]=r.metadata,t[u]=r.value)})},fg=function(n,t){var i=[],r=[];if(t=rt(n,t),p(n,function(n){if(u(n)===wr&&f(n)==="workspace"){i.push(eg(n,t));return}r.push(yr(n))}),i.length===0)throw{message:"Invalid AtomPub service document: No workspace element found.",element:n};return{workspaces:i,extensions:r}},eg=function(n,i){var e=[],o=[],r;return i=rt(n,i),p(n,function(n){var s=u(n),h=f(n);if(s===ni&&h==="title"){if(r!==t)throw{message:"Invalid AtomPub service document: workspace has more than one child title element",element:n};r=k(n);return}if(s===wr){h==="collection"&&e.push(og(n,i));return}o.push(ea(n))}),{title:r||"",collections:e,
 extensions:o}},og=function(n,i){var r=st(n,"href"),o,e;if(!r)throw{message:"Invalid AtomPub service document: collection has no href attribute",element:n};if(i=rt(n,i),r=c(r,rt(n,i)),o=[],p(n,function(i){var r=u(i),s=f(i);if(r===ni){if(s==="title"){if(e!==t)throw{message:"Invalid AtomPub service document: collection has more than one child title element",element:i};e=k(i)}return}r!==wr&&o.push(ea(n))}),!e)throw{message:"Invalid AtomPub service document: collection has no title element",element:n};return{title:e,href:r,extensions:o}},ti=function(n,t,i){return cr(n,ni,wt(dl,t),i)},nr=function(n,t,i){return si(n,null,t,i)},sg=function(n){var t,e,i,o,r;if(n.childNodes.length>0)return!1;for(t=!0,e=n.attributes,i=0,o=e.length;i<o&&t;i++)r=e[i],t=t&&wp(r)||u(r)==nt&&f(r)==="type";return t},hg=function(n,t,i,r,u){var s=null,e=null,f=null,o="",h;return i!=="deferred"?(s=nr(n,"type","application/atom+xml;type="+i),e=bl(n,"inline"),r&&(o=r.__metadata&&r.__metadata.uri||"",f=wa(n,r,u)||ge(n,r,u
 ),l(e,f.element))):o=r.__deferred.uri,h=ti(n,"link",[nr(n,"href",o),nr(n,"rel",c(t,pe)),s,e]),vt(h,f?f.dsv:"1.0")},cg=function(n,t,i,r,u,f){var e,o;return gh(i)?null:(e=de(n,t,i,r,u,f),e||(o=nc(i,u),e=hg(n,t,o,i,f)),e)},lg=function(n,t,i,r){var u=us(i,at,r.propertyPath),l=u&&wi(u,"null",nt),o,s="1.0",f,e,h,c;if(l&&l.value==="true")return s;if(u&&(o=k(u)||"",!r.keepInContent))for(s="2.0",f=u.parentNode,e=f,f.removeChild(u);e!==i&&sg(e);)f=e.parentNode,f.removeChild(e),e=f;return(h=uw(n,t,r.nsURI,r.nsPrefix,r.entryPath),h.nodeType===2)?(h.value=o,s):(c=r.contentKind,ou(h,[c&&si(n,null,"type",c),c==="xhtml"?iw(n,o):o]),s)},ge=function(n,t,i){var e=t.__metadata||{},b=e.properties||{},y=e.etag,p=e.uri,s=e.type,o=kt(s,i),h=bl(n,"properties"),c=ti(n,"entry",[ti(n,"author",ti(n,"name")),y&&ke(n,"etag",y),p&&ti(n,"id",p),s&&ti(n,"category",[nr(n,"term",s),nr(n,"scheme",hl)]),ti(n,"content",[nr(n,"type","application/xml"),h])]),f="1.0",r,v,w;for(r in t)if(r!=="__metadata"){var k=b[r]||{},d=o&
 &(bt(o.property,r)||bt(o.navigationProperty,r)),a=cg(n,r,t[r],k,d,i);a&&(v=a.element,w=u(v)===ni?c:h,l(w,v),f=ct(f,a.dsv))}return fa(o,i,function(t){var i=lg(n,c,h,t);f=ct(f,i)}),vt(c,f)},wa=function(n,t,i){var f=e(t)?t:t.results,r,o,u,h,s;if(!f)return null;for(r="1.0",o=ti(n,"feed"),u=0,h=f.length;u<h;u++)s=ge(n,f[u],i),l(o,s.element),r=ct(r,s.dsv);return vt(o,r)},ag=function(n,t){var u,i,r,f;return n&&(u=ar(n)&&wa||lf(n)&&ge,u&&(i=es(),r=u(i,n,t),r))?(f=r.element,ou(f,[os(i,nt,we),os(i,at,cl)]),vt(l(i,f),r.dsv)):null},vg=function(n,t,i){if(t){var u=eu(t),r=b(u);if(r)return oa(r,null,i.metadata)}},yg=function(n,t,i){var u=i.contentType=i.contentType||gi(ra),r;if(u&&u.mediaType===ra&&(r=ag(t,i.metadata),r))return i.dataServiceVersion=ct(i.dataServiceVersion||"1.0",r.dsv),pf(r.element)};r.atomHandler=li(vg,yg,ia.join(","),ci);var i=function(n,t,i,r){return{attributes:n,elements:t,text:i||!1,ns:r}},tt={elements:{Annotations:i(["Target","Qualifier"],["TypeAnnotation*","ValueAnnotation*
 "]),Association:i(["Name"],["End*","ReferentialConstraint","TypeAnnotation*","ValueAnnotation*"]),AssociationSet:i(["Name","Association"],["End*","TypeAnnotation*","ValueAnnotation*"]),Binary:i(null,null,!0),Bool:i(null,null,!0),Collection:i(null,["String*","Int*","Float*","Decimal*","Bool*","DateTime*","DateTimeOffset*","Guid*","Binary*","Time*","Collection*","Record*"]),CollectionType:i(["ElementType","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"],["CollectionType","ReferenceType","RowType","TypeRef"]),ComplexType:i(["Name","BaseType","Abstract"],["Property*","TypeAnnotation*","ValueAnnotation*"]),DateTime:i(null,null,!0),DateTimeOffset:i(null,null,!0),Decimal:i(null,null,!0),DefiningExpression:i(null,null,!0),Dependent:i(["Role"],["PropertyRef*"]),Documentation:i(null,null,!0),End:i(["Type","Role","Multiplicity","EntitySet"],["OnDelete"]),EntityContainer:i(["Name","Extends"],["EntitySet*","AssociationSet*","FunctionImport*","
 TypeAnnotation*","ValueAnnotation*"]),EntitySet:i(["Name","EntityType"],["TypeAnnotation*","ValueAnnotation*"]),EntityType:i(["Name","BaseType","Abstract","OpenType"],["Key","Property*","NavigationProperty*","TypeAnnotation*","ValueAnnotation*"]),EnumType:i(["Name","UnderlyingType","IsFlags"],["Member*"]),Float:i(null,null,!0),Function:i(["Name","ReturnType"],["Parameter*","DefiningExpression","ReturnType","TypeAnnotation*","ValueAnnotation*"]),FunctionImport:i(["Name","ReturnType","EntitySet","IsSideEffecting","IsComposable","IsBindable","EntitySetPath"],["Parameter*","ReturnType","TypeAnnotation*","ValueAnnotation*"]),Guid:i(null,null,!0),Int:i(null,null,!0),Key:i(null,["PropertyRef*"]),LabeledElement:i(["Name"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Null"]),Member:i(["Name","Value"]),NavigationProperty:i(["Name","Relationship","ToRole","FromRole","ContainsTarget"],["TypeAnnotation*
 ","ValueAnnotation*"]),Null:i(null,null),OnDelete:i(["Action"]),Path:i(null,null,!0),Parameter:i(["Name","Type","Mode","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","SRID"],["CollectionType","ReferenceType","RowType","TypeRef","TypeAnnotation*","ValueAnnotation*"]),Principal:i(["Role"],["PropertyRef*"]),Property:i(["Name","Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","CollectionKind","SRID"],["CollectionType","ReferenceType","RowType","TypeAnnotation*","ValueAnnotation*"]),PropertyRef:i(["Name"]),PropertyValue:i(["Property","Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Null"]),ReferenceType:i(["Type"]),ReferentialConstraint:i(null,["Principal","Dependent"]),
 ReturnType:i(["ReturnType","Type","EntitySet"],["CollectionType","ReferenceType","RowType"]),RowType:i(["Property*"]),String:i(null,null,!0),Schema:i(["Namespace","Alias"],["Using*","EntityContainer*","EntityType*","Association*","ComplexType*","Function*","ValueTerm*","Annotations*"]),Time:i(null,null,!0),TypeAnnotation:i(["Term","Qualifier"],["PropertyValue*"]),TypeRef:i(["Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"]),Using:i(["Namespace","Alias"]),ValueAnnotation:i(["Term","Qualifier","Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Null"]),ValueTerm:i(["Name","Type"],["TypeAnnotation*","ValueAnnotation*"]),Edmx:i(["Version"],["DataServices","Reference*","AnnotationsReference*"],!1,gu),DataServices:i(null,["Schema*"],!1,gu)}},ba=["m
 :FC_ContentKind","m:FC_KeepInContent","m:FC_NsPrefix","m:FC_NsUri","m:FC_SourcePath","m:FC_TargetPath"];tt.elements.Property.attributes=tt.elements.Property.attributes.concat(ba),tt.elements.EntityType.attributes=tt.elements.EntityType.attributes.concat(ba),tt.elements.Edmx={attributes:["Version"],elements:["DataServices"],ns:gu},tt.elements.DataServices={elements:["Schema*"],ns:gu},tt.elements.EntityContainer.attributes.push("m:IsDefaultEntityContainer"),tt.elements.Property.attributes.push("m:MimeType"),tt.elements.FunctionImport.attributes.push("m:HttpMethod"),tt.elements.FunctionImport.attributes.push("m:IsAlwaysBindable"),tt.elements.EntityType.attributes.push("m:HasStream"),tt.elements.DataServices.attributes=["m:DataServiceVersion","m:MaxDataServiceVersion"];var ka=function(n){if(!n)return n;if(n.length>1){var t=n.substr(0,2);return t===t.toUpperCase()?n:n.charAt(0).toLowerCase()+n.substr(1)}return n.charAt(0).toLowerCase()},pg=function(n,t){var r,u,e,i,f,o;if(t==="Documentat
 ion")return{isArray:!0,propertyName:"documentation"};if(r=n.elements,!r)return null;for(u=0,e=r.length;u<e;u++)if(i=r[u],f=!1,i.charAt(i.length-1)==="*"&&(f=!0,i=i.substr(0,i.length-1)),t===i)return o=ka(i),{isArray:f,propertyName:o};return null},wg=/^(m:FC_.*)_[0-9]+$/,da=function(n){return n===vk},no=function(n){var o=f(n),e=u(n),i=tt.elements[o];if(!i)return null;if(i.ns){if(e!==i.ns)return null}else if(!da(e))return null;var t={},r=[],s=i.attributes||[];return pi(n,function(n){var c=f(n),e=u(n),l=n.value,i,o,h;e!==sr&&(i=null,o=!1,da(e)||e===null?i="":e===nt&&(i="m:"),i!==null&&(i+=c,h=wg.exec(i),h&&(i=h[1]),fr(s,i)&&(o=!0,t[ka(c)]=l)),o||r.push(gt(n)))}),p(n,function(n){var o=f(n),u=pg(i,o),e;u?u.isArray?(e=t[u.propertyName],e||(e=[],t[u.propertyName]=e),e.push(no(n))):t[u.propertyName]=no(n):r.push(yr(n))}),i.text&&(t.text=k(n)),r.length&&(t.extensions=r),t},ga=function(n,i){var r=eu(i),u=b(r);return no(u)||t};r.metadataHandler=li(ga,null,du,ci);var nv="o",to="f",tv="p",iv="c"
 ,rv="s",uv="l",bg="odata",ii=bg+".",kg="@"+ii+"bind",io=ii+"metadata",fv=ii+"navigationLinkUrl",tr=ii+"type",tf={readLink:"self",editLink:"edit",nextLink:"__next",mediaReadLink:"media_src",mediaEditLink:"edit_media",mediaContentType:"content_type",mediaETag:"media_etag",count:"__count",media_src:"mediaReadLink",edit_media:"mediaEditLink",content_type:"mediaContentType",media_etag:"mediaETag",url:"uri"},h={metadata:"odata.metadata",count:"odata.count",next:"odata.nextLink",id:"odata.id",etag:"odata.etag",read:"odata.readLink",edit:"odata.editLink",mediaRead:"odata.mediaReadLink",mediaEdit:"odata.mediaEditLink",mediaEtag:"odata.mediaETag",mediaContentType:"odata.mediaContentType",actions:"odata.actions",functions:"odata.functions",navigationUrl:"odata.navigationLinkUrl",associationUrl:"odata.associationLinkUrl",type:"odata.type"},dg=function(n){if(n.indexOf(".")>0){var t=n.indexOf("@"),r=t>-1?n.substring(0,t):null,i=n.substring(t+1);return{target:r,name:i,isOData:i.indexOf(ii)===0}}re
 turn null},ro=function(n,t,i,r,u){return d(t)&&t[tr]||i&&i[n+"@"+tr]||r&&r.type||ww(r,u)||null},uo=function(n,t){return t?bt(t.property,n)||bt(t.navigationProperty,n):null},ev=function(n){return d(n)&&ii+"id"in n},gg=function(n,t,i){if(!!t[n+"@"+fv]||i&&i.relationship)return!0;var r=e(t[n])?t[n][0]:t[n];return ev(r)},fo=function(n){return ue(n)||ie(n)||re(n)},ri=function(n,t,i,r,u){var f,e;for(f in n)if(f.indexOf(".")>0&&f.charAt(0)!=="#"&&(e=dg(f),e)){var c=e.name,o=e.target,s=null,h=null;o&&(s=uo(o,r),h=ro(o,n[o],n,s,u)),e.isOData?nn(c,o,h,n[f],n,t,i):t[f]=n[f]}return t},nn=function(n,t,i,r,u,f,e){var o=n.substring(ii.length);switch(o){case"navigationLinkUrl":fn(o,t,i,r,u,f,e);return;case"nextLink":case"count":rn(o,t,r,f,e);return;case"mediaReadLink":case"mediaEditLink":case"mediaContentType":case"mediaETag":un(o,t,i,r,f,e);return;default:tn(o,t,r,f,e);return}},tn=function(n,t,i,r,u){var f=r.__metadata=r.__metadata||{},e=tf[n]||n,s,o;if(n==="editLink"){f.uri=c(i,u),f[e]=f.uri;retu
 rn}if((n==="readLink"||n==="associationLinkUrl")&&(i=c(i,u)),t){if(s=f.properties=f.properties||{},o=s[t]=s[t]||{},n==="type"){o[e]=o[e]||i;return}o[e]=i;return}f[e]=i},rn=function(n,t,i,r,u){var f=tf[n],e=t?r[t]:r;e[f]=n==="nextLink"?c(i,u):i},un=function(n,t,i,r,u,f){var e=u.__metadata=u.__metadata||{},h=tf[n],o,s;if((n==="mediaReadLink"||n==="mediaEditLink")&&(r=c(r,f)),t){o=e.properties=e.properties||{},s=o[t]=o[t]||{},s.type=s.type||i,u.__metadata=e,u[t]=u[t]||{__mediaresource:{}},u[t].__mediaresource[h]=r;return}e[h]=r},fn=function(n,t,i,r,u,f,e){var s=f.__metadata=f.__metadata||{},h=s.properties=s.properties||{},o=h[t]=h[t]||{},l=c(r,e);if(u.hasOwnProperty(t)){o.navigationLinkUrl=l;return}f[t]={__deferred:{uri:l}},o.type=o.type||i},eo=function(n,t,i,r,u,f,o){if(typeof n=="string")return en(n,t,o);if(!fo(t)){if(e(n))return ov(n,t,i,r,f,o);if(d(n))return on(n,t,i,r,f,o)}return n},en=function(n,t,i){switch(t){case lu:return he(n);case hu:return pu(n,!1);case cu:return se(n,!1)}r
 eturn i?pu(n,!0)||se(n,!0)||n:n},ov=function(n,t,i,r,u,f){for(var a=au(t),o=[],h=[],e=0,c=n.length;e<c;e++){var s=ro(null,n[e])||a,l={type:s},v=eo(n[e],s,l,r,null,u,f);fo(s)||yu(n[e])||o.push(l),h.push(v)}return o.length>0&&(i.elements=o),{__metadata:{type:t},results:h}},on=function(n,t,i,r,u,f){var e=rf(n,{type:t},r,u,f),o=e.__metadata,s=o.properties;return s&&(i.properties=s,delete o.properties),e},sn=function(n,t,i,r,u){return e(n)?hv(n,t,i,r,u):d(n)?rf(n,t,i,r,u):null},rf=function(n,i,r,u,f){var d,v,g,o,y,h,c,nt;i=i||{};var l=n[tr]||i.type||null,s=kt(l,u),k=!0;s||(k=!1,s=di(l,u));var p={type:l},a={__metadata:p},w={},e;if(k&&s&&i.entitySet&&i.contentTypeOdata=="minimalmetadata"){for(d=r.substring(0,r.lastIndexOf("$metadata")),e=null,s.key||(e=s);!!e&&!e.key&&e.baseType;)e=kt(e.baseType,u);(s.key||!!e&&e.key)&&(v=s.key?cv(n,s):cv(n,e),v&&(g={key:v,entitySet:i.entitySet,functionImport:i.functionImport,containerName:i.containerName},hn(n,g,l,d,s,e)))}for(o in n)if(o.indexOf("#")===0
 )sv(o.substring(1),n[o],a,r,u);else if(o.indexOf(".")===-1){for(p.properties||(p.properties=w),y=n[o],h=h=uo(o,s),e=s;!!s&&h===null&&e.baseType;)e=kt(e.baseType,u),h=h=uo(o,e);var tt=gg(o,n,h),b=ro(o,y,n,h,u),it=w[o]=w[o]||{type:b};tt?(c={},i.entitySet!==t&&(nt=bw(h,i.entitySet.name,u),c=kw(nt,u)),c.contentTypeOdata=i.contentTypeOdata,c.kind=i.kind,c.type=b,a[o]=sn(y,c,r,u,f)):a[o]=eo(y,b,it,r,h,u,f)}return ri(n,a,r,s,u)},sv=function(n,t,i,r,u){var f,s,g,nt;if(n&&(e(t)||d(t))){var l=!1,h=n.lastIndexOf("."),a=n.substring(h+1),v=h>-1?n.substring(0,h):"",y=a===n||v.indexOf(".")===-1?tc(u):ic(v,u);y&&(f=pw(y.functionImport,a),f&&!!f.isSideEffecting&&(l=!oe(f.isSideEffecting)));for(var p=i.__metadata,w=l?"functions":"actions",tt=c(n,r),b=e(t)?t:[t],o=0,k=b.length;o<k;o++)s=b[o],s&&(g=p[w]=p[w]||[],nt={metadata:tt,title:s.title,target:c(s.target,r)},g.push(nt))}},hv=function(n,t,i,r,u){for(var h=e(n)?n:n.value,c=[],l,f,s,o=0,a=h.length;o<a;o++)l=rf(h[o],t,i,r,u),c.push(l);if(f={results:c}
 ,d(n)){for(s in n)s.indexOf("#")===0&&(f.__metadata=f.__metadata||{},sv(s.substring(1),n[s],f,i,r));f=ri(n,f,i)}return f},cv=function(n,t){var r,i=t.key.propertyRef,f,e,u;if(r="(",i.length==1)f=bt(t.property,i[0].name).type,r+=oo(n[i[0].name],f);else for(e=!0,u=0;u<i.length;u++)e?e=!1:r+=",",f=bt(t.property,i[u].name).type,r+=i[u].name+"="+oo(n[i[u].name],f);return r+=")"},hn=function(n,t,i,r,u,f){var o=n[h.id]||n[h.read]||n[h.edit]||t.entitySet.name+t.key,e;n[h.id]=r+o,n[h.edit]||(n[h.edit]=t.entitySet.name+t.key,t.entitySet.entityType!=i&&(n[h.edit]+="/"+i)),n[h.read]=n[h.read]||n[h.edit],n[h.etag]||(e=cn(n,u,f),!e||(n[h.etag]=e)),yn(n,u,f),ln(n,u,f),vn(n,t)},cn=function(n,t,i){for(var u="",f,r=0;t.property&&r<t.property.length;r++)f=t.property[r],u=lv(n,u,f);if(i)for(r=0;i.property&&r<i.property.length;r++)f=i.property[r],u=lv(n,u,f);return u.length>0?u+'"':null},lv=function(n,t,i){return i.concurrencyMode=="Fixed"&&(t+=t.length>0?",":'W/"',t+=n[i.name]!==null?oo(n[i.name],i.type
 ):"null"),t},ln=function(n,i,r){for(var s="@odata.navigationLinkUrl",c="@odata.associationLinkUrl",u,e,o,f=0;i.navigationProperty&&f<i.navigationProperty.length;f++)u=i.navigationProperty[f].name,e=u+s,n[e]===t&&(n[e]=n[h.edit]+"/"+encodeURIComponent(u)),o=u+c,n[o]===t&&(n[o]=n[h.edit]+"/$links/"+encodeURIComponent(u));if(r&&r.navigationProperty)for(f=0;f<r.navigationProperty.length;f++)u=r.navigationProperty[f].name,e=u+s,n[e]===t&&(n[e]=n[h.edit]+"/"+encodeURIComponent(u)),o=u+c,n[o]===t&&(n[o]=n[h.edit]+"/$links/"+encodeURIComponent(u))},oo=function(n,t){n=""+an(n,t),n=encodeURIComponent(n.replace("'","''"));switch(t){case"Edm.Binary":return"X'"+n+"'";case"Edm.DateTime":return"datetime'"+n+"'";case"Edm.DateTimeOffset":return"datetimeoffset'"+n+"'";case"Edm.Decimal":return n+"M";case"Edm.Guid":return"guid'"+n+"'";case"Edm.Int64":return n+"L";case"Edm.Float":return n+"f";case"Edm.Double":return n+"D";case"Edm.Geography":return"geography'"+n+"'";case"Edm.Geometry":return"geometry'"+
 n+"'";case"Edm.Time":return"time'"+n+"'";case"Edm.String":return"'"+n+"'";default:return n}},an=function(n,t){switch(t){case"Edm.Binary":return hp(n);default:return n}},vn=function(n,i){for(var u=i.functionImport||[],f,r=0;r<u.length;r++)u[r].isBindable&&u[r].parameter[0]&&u[r].parameter[0].type==i.entitySet.entityType&&(f="#"+i.containerName+"."+u[r].name,n[f]==t&&(n[f]={title:u[r].name,target:n[h.edit]+"/"+u[r].name}))},yn=function(n,t,i){(t.hasStream||i&&i.hasStream)&&(n[h.mediaEdit]=n[h.mediaEdit]||n[h.mediaEdit]+"/$value",n[h.mediaRead]=n[h.mediaRead]||n[h.mediaEdit])},pn=function(n,t,i,r){var u={type:t},f=eo(n.value,t,u,i,null,null,r);return ri(n,{__metadata:u,value:f},i)},wn=function(n,t,i,r,u){var f={},e=ov(n.value,t,f,i,r,u);return g(e.__metadata,f),ri(n,e,i)},bn=function(n,t){var r=n.value,u,i,f,o;if(!e(r))return av(n,t);for(u=[],i=0,f=r.length;i<f;i++)u.push(av(r[i],t));return o={results:u},ri(n,o,t)},av=function(n,t){var i={uri:c(n.url,t)},u,r;return i=ri(n,i,t),u=i.__me
 tadata||{},r=u.properties||{},uf(r.url),iu(r,"url","uri"),i},uf=function(n){n&&delete n.type},kn=function(n,t){var o=n.value,s=[],h=ri(n,{collections:s},t),e=h.__metadata||{},i=e.properties||{},u,l,f,r;for(uf(i.value),iu(i,"value","collections"),u=0,l=o.length;u<l;u++)f=o[u],r={title:f.name,href:c(f.url,t)},r=ri(f,r,t),e=r.__metadata||{},i=e.properties||{},uf(i.name),uf(i.url),iu(i,"name","title"),iu(i,"url","href"),s.push(r);return{workspaces:[h]}},ui=function(n,t){return{kind:n,type:t||null}},dn=function(n,t,i){var f=n[io],s,v,o,y,l,r,p,h,c,w,b,u,k;if(!f||typeof f!="string")return null;if(s=f.lastIndexOf("#"),s===-1)return ui(rv);if(v=f.indexOf("@Element",s),o=v-1,o<0&&(o=f.indexOf("?",s),o===-1&&(o=f.length)),y=f.substring(s+1,o),y.indexOf("/$links/")>0)return ui(uv);if(l=y.split("/"),l.length>=0){if(r=l[0],p=l[1],fo(r))return ui(tv,r);if(vu(r))return ui(iv,r);if(h=p,!p){var d=r.lastIndexOf("."),g=r.substring(d+1),a=g===r?tc(t):ic(r.substring(0,d),t);a&&(c=yw(a.entitySet,g),w=a.f
 unctionImport,b=a.name,h=!c?null:c.entityType)}return v>0?(u=ui(nv,h),u.entitySet=c,u.functionImport=w,u.containerName=b,u):h?(u=ui(to,h),u.entitySet=c,u.functionImport=w,u.containerName=b,u):e(n.value)&&!di(r,t)&&(k=n.value[0],!yu(k)&&(ev(k)||!i))?ui(to,null):ui(nv,r)}return null},gn=function(n,t,i,r,u){var e,f,o;if(!d(n))return n;if(u=u||"minimalmetadata",e=n[io],f=dn(n,t,r),ot(f)&&(f.contentTypeOdata=u),o=null,f){delete n[io],o=f.type;switch(f.kind){case to:return hv(n,f,e,t,i);case iv:return wn(n,o,e,t,i);case tv:return pn(n,o,e,i);case rv:return kn(n,e);case uv:return bn(n,e)}}return rf(n,f,e,t,i)},vv=["type","etag","media_src","edit_media","content_type","media_etag"],yv=function(n,t){var u=/\/\$links\//,i={},r=n.__metadata,f=t&&u.test(t.request.requestUri);return so(n,r&&r.properties,i,f),i},ntt=function(n,t){var i,u,r,f;if(n)for(i=0,u=vv.length;i<u;i++)r=vv[i],f=ii+(tf[r]||r),kr(f,null,n[r],t)},so=function(n,t,i,r){var u,f;for(u in n)f=n[u],u==="__metadata"?ntt(f,i):u.indexO
 f(".")===-1?r&&u==="uri"?itt(f,i):ttt(u,f,t,i,r):i[u]=f},ttt=function(n,i,r,u){var e=r&&r[n]||{properties:t,type:t},f=ss(i,e);if(yu(i)||!i){kr(tr,n,f,u),u[n]=i;return}if(ar(i,f)||dh(i)){ftt(n,i,u);return}if(!f&&kh(i)){rtt(n,i,u);return}if(bh(i,f)){au(f)&&kr(tr,n,f,u),utt(n,i,u);return}u[n]={},kr(tr,null,f,u[n]),so(i,e.properties,u[n])},itt=function(n,t){t.url=n},rtt=function(n,t,i){kr(fv,n,t.__deferred.uri,i)},utt=function(n,t,i){i[n]=[];var r=e(t)?t:t.results;so(r,null,i[n])},ftt=function(n,t,i){if(ar(t)){i[n]=[];for(var u=e(t)?t:t.results,r=0,f=u.length;r<f;r++)pv(n,u[r],!0,i);return}pv(n,t,!1,i)},pv=function(n,t,i,r){var f=t.__metadata&&t.__metadata.uri,u;if(f){ett(n,f,i,r);return}if(u=yv(t),i){r[n].push(u);return}r[n]=u},ett=function(n,t,i,r){var u=n+kg;if(i){r[u]=r[u]||[],r[u].push(t);return}r[u]=t},kr=function(n,i,r,u){r!==t&&(i?u[i+"@"+n]=r:u[n]=r)},wv="application/json",bv=gi(wv),kv=function(n){var r=[],t,i,u;for(t in n)for(i=0,u=n[t].length;i<u;i++)r.push(g({metadata:t},n[t
 ][i]));return r},ott=function(n,t,i,r){var c,f,l,u,o,s,v,e,h,a;if(n&&typeof n=="object")if(f=n.__metadata,f&&(f.actions&&(f.actions=kv(f.actions)),f.functions&&(f.functions=kv(f.functions)),c=f&&f.type),l=kt(c,t)||di(c,t),l){if(o=l.property,o)for(s=0,v=o.length;s<v;s++)if(e=o[s],h=e.name,u=n[h],e.type==="Edm.DateTime"||e.type==="Edm.DateTimeOffset"){if(u){if(u=i(u),!u)throw{message:"Invalid date/time value"};n[h]=u}}else e.type==="Edm.Time"&&(n[h]=he(u))}else if(r)for(a in n)u=n[a],typeof u=="string"&&(n[a]=i(u)||u);return n},dv=function(n){if(n){var t=n.properties.odata;return t==="nometadata"||t==="minimalmetadata"||t==="fullmetadata"}return!1},stt=function(n,t){for(var u={collections:[]},r,e,i=0,f=n.EntitySets.length;i<f;i++)r=n.EntitySets[i],e={title:r,href:c(r,t)},u.collections.push(e);return{workspaces:[u]}},htt=/^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/,ctt=function(n){var t,i;return n<0?(t="-",n=-n):t="+",i=Math.floor(n/60),n=n-60*i,t+a(i,2)+":"+a(n,2)},ltt=function(n){var i=n&&ht
 t.exec(n),t,r,u;if(i&&(t=new Date(s(i[1])),i[2]&&(r=s(i[3]),i[2]==="-"&&(r=-r),u=t.getUTCMinutes(),t.setUTCMinutes(u-r),t.__edmType="Edm.DateTimeOffset",t.__offset=ctt(r)),!isNaN(t.valueOf())))return t},att=function(t,i,r){var f=it(r.recognizeDates,t.recognizeDates),h=it(r.inferJsonLightFeedAsObject,t.inferJsonLightFeedAsObject),e=r.metadata,o=r.dataServiceVersion,s=ltt,u=typeof i=="string"?n.JSON.parse(i):i;if(ct("4.0",o)===o){if(dv(r.contentType))return gn(u,e,f,h,r.contentType.properties.odata);s=pu}return u=tb(u.d,function(n,t){return ott(t,e,s,f)}),u=wtt(u,r.dataServiceVersion),ptt(u,r.response.requestUri)},gv=function(t){var i,r=Date.prototype.toJSON;try{Date.prototype.toJSON=function(){return yh(this)},i=n.JSON.stringify(t,ytt)}finally{Date.prototype.toJSON=r}return i},vtt=function(n,i,r){var e=r.dataServiceVersion||"1.0",o=it(r.useJsonLight,n.useJsonLight),u=r.contentType=r.contentType||bv,f;return u&&u.mediaType===bv.mediaType?(f=i,o||dv(u))?(r.dataServiceVersion=ct(e,"4.0"
 ),f=yv(i,r),gv(f)):(ct("4.0",e)===e&&(u.properties.odata="verbose",r.contentType=u),gv(f)):t},ytt=function(n,t){return t&&t.__edmType==="Edm.Time"?ph(t):t},ptt=function(n,t){var i=d(n)&&!n.__metadata&&e(n.EntitySets);return i?stt(n,t):n},wtt=function(n,t){return t&&t.lastIndexOf(";")===t.length-1&&(t=t.substr(0,t.length-1)),t&&t!=="1.0"||e(n)&&(n={results:n}),n},ff=li(att,vtt,wv,ci);ff.recognizeDates=!1,ff.useJsonLight=!1,ff.inferJsonLightFeedAsObject=!1,r.jsonHandler=ff;var dr="multipart/mixed",btt=/^HTTP\/1\.\d (\d{3}) (.*)$/i,ktt=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,ho=function(){return Math.floor((1+Math.random())*65536).toString(16).substr(1)},ny=function(n){return n+ho()+"-"+ho()+"-"+ho()},ty=function(n){return n.handler.partHandler},iy=function(n){var t=n.boundaries;return t[t.length-1]},dtt=function(n,t,i){var r=i.contentType.properties.boundary;return{__batchResponses:ry(t,{boundaries:[r],handlerContext:i})}},gtt=function(n,t,i){var r=i.contentType=i.contentType||gi(
 dr);if(r.mediaType===dr)return nit(t,i)},ry=function(n,t){var f="--"+iy(t),u,o,s,r,e,i;for(ef(n,t,f),ir(n,t),u=[];o!=="--"&&t.position<n.length;){if(s=uy(n,t),r=gi(s["Content-Type"]),r&&r.mediaType===dr){t.boundaries.push(r.properties.boundary);try{e=ry(n,t)}catch(h){h.response=fy(n,t,f),e=[h]}u.push({__changeResponses:e}),t.boundaries.pop(),ef(n,t,"--"+iy(t))}else{if(!r||r.mediaType!=="application/http")throw{message:"invalid MIME part type "};ir(n,t),i=fy(n,t,f);try{i.statusCode>=200&&i.statusCode<=299?ty(t.handlerContext).read(i,t.handlerContext):i={message:"HTTP request failed",response:i}}catch(h){i=h}u.push(i)}o=n.substr(t.position,2),ir(n,t)}return u},uy=function(n,t){var r={},i,u,f;do f=t.position,u=ir(n,t),i=ktt.exec(u),i!==null?r[i[1]]=i[2]:t.position=f;while(u&&i);return ee(r),r},fy=function(n,t,i){var o=t.position,r=btt.exec(ir(n,t)),u,f,e;return r?(u=r[1],f=r[2],e=uy(n,t),ir(n,t)):t.position=o,{statusCode:u,statusText:f,headers:e,body:ef(n,t,"\r\n"+i)}},ir=function(n,t)
 {return ef(n,t,"\r\n")},ef=function(n,t,i){var u=t.position||0,r=n.length;if(i){if(r=n.indexOf(i,u),r===-1)return null;t.position=r+i.length}else t.position=r;return n.substring(u,r)},nit=function(n,t){var o;if(!lw(n))throw{message:"Data is not a batch object."};for(var r=ny("batch_"),f=n.__batchRequests,u="",i=0,e=f.length;i<e;i++)u+=of(r,!1)+ey(f[i],t);return u+=of(r,!0),o=t.contentType.properties,o.boundary=r,u},of=function(n,t){var i="\r\n--"+n;return t&&(i+="--"),i+"\r\n"},ey=function(n,t,i){var s=n.__changeRequests,r,f,o,h,u;if(e(s)){if(i)throw{message:"Not Supported: change set nested in other change set"};for(f=ny("changeset_"),r="Content-Type: "+dr+"; boundary="+f+"\r\n",o=0,h=s.length;o<h;o++)r+=of(f,!1)+ey(s[o],t,!0);r+=of(f,!0)}else r="Content-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\n",u=g({},t),u.handler=li,u.request=n,u.contentType=null,oc(n,ty(t),u),r+=tit(n);return r},tit=function(n){var t=(n.method?n.method:"GET")+" "+n.requestUri+" HTTP/1.
 1\r\n",i;for(i in n.headers)n.headers[i]&&(t=t+i+": "+n.headers[i]+"\r\n");return t+="\r\n",n.body&&(t+=n.body),t};r.batchHandler=li(dtt,gtt,dr,ci),co=[r.jsonHandler,r.atomHandler,r.xmlHandler,r.textHandler],lo=function(n,t,i){for(var r=0,u=co.length;r<u&&!co[r][n](t,i);r++);if(r===u)throw{message:"no handler for data"};},r.defaultSuccess=function(t){n.alert(n.JSON.stringify(t))},r.defaultError=ru,r.defaultHandler={read:function(n,t){n&&ot(n.body)&&n.headers["Content-Type"]&&lo("read",n,t)},write:function(n,t){lo("write",n,t)},maxDataServiceVersion:ci,accept:"application/atomsvc+xml;q=0.8, application/json;odata.metadata=full;q=0.7, application/json;q=0.5, */*;q=0.1"},r.defaultMetadata=[],r.read=function(n,t,i,u,f,e){var o;return o=n instanceof String||typeof n=="string"?{requestUri:n}:n,r.request(o,t,i,u,f,e)},r.request=function(n,t,i,u,f,e){t=t||r.defaultSuccess,i=i||r.defaultError,u=u||r.defaultHandler,f=f||r.defaultHttpClient,e=e||r.defaultMetadata,n.recognizeDates=it(n.recogniz
 eDates,r.jsonHandler.recognizeDates),n.callbackParameterName=it(n.callbackParameterName,r.defaultHttpClient.callbackParameterName),n.formatQueryString=it(n.formatQueryString,r.defaultHttpClient.formatQueryString),n.enableJsonpCallback=it(n.enableJsonpCallback,r.defaultHttpClient.enableJsonpCallback),n.useJsonLight=it(n.useJsonLight,r.jsonHandler.enableJsonpCallback),n.inferJsonLightFeedAsObject=it(n.inferJsonLightFeedAsObject,r.jsonHandler.inferJsonLightFeedAsObject);var o={metadata:e,recognizeDates:n.recognizeDates,callbackParameterName:n.callbackParameterName,formatQueryString:n.formatQueryString,enableJsonpCallback:n.enableJsonpCallback,useJsonLight:n.useJsonLight,inferJsonLightFeedAsObject:n.inferJsonLightFeedAsObject};try{return oc(n,u,o),cw(n,t,i,u,f,o)}catch(s){i(s)}},r.parseMetadata=function(n){return ga(null,n)},r.batchHandler.partHandler=r.defaultHandler;var ft=null,iit=function(){var t={v:this.valueOf(),t:"[object Date]"},n;for(n in this)t[n]=this[n];return t},rit=functio
 n(n,t){var r,i;if(t&&t.t==="[object Date]"){r=new Date(t.v);for(i in t)i!=="t"&&i!=="v"&&(r[i]=t[i]);t=r}return t},sf=function(n,t){return n.name+"#!#"+t},oy=function(n,t){return t.replace(n.name+"#!#","")},y=function(n){this.name=n};y.create=function(t){if(y.isSupported())return ft=ft||n.localStorage,new y(t);throw{message:"Web Storage not supported by the browser"};},y.isSupported=function(){return!!n.localStorage},y.prototype.add=function(n,t,i,r){r=r||this.defaultError;var u=this;this.contains(n,function(f){f?o(r,{message:"key already exists",key:n}):u.addOrUpdate(n,t,i,r)},r)},y.prototype.addOrUpdate=function(i,r,u,f){var s,h,e;if(f=f||this.defaultError,i instanceof Array)f({message:"Array of keys not supported"});else{s=sf(this,i),h=Date.prototype.toJSON;try{e=r,e!==t&&(Date.prototype.toJSON=iit,e=n.JSON.stringify(r)),ft.setItem(s,e),o(u,i,r)}catch(c){c.code===22||c.number===2147942414?o(f,{name:"QUOTA_EXCEEDED_ERR",error:c}):o(f,c)}finally{Date.prototype.toJSON=h}}},y.prototy
 pe.clear=function(n,t){var i,r,u,f;t=t||this.defaultError;try{for(i=0,r=ft.length;r>0&&i<r;)u=ft.key(i),f=oy(this,u),u!==f?(ft.removeItem(u),r=ft.length):i++;o(n)}catch(e){o(t,e)}},y.prototype.close=function(){},y.prototype.contains=function(n,t,i){i=i||this.defaultError;try{var r=sf(this,n),u=ft.getItem(r);o(t,u!==null)}catch(f){o(i,f)}},y.prototype.defaultError=ru,y.prototype.getAllKeys=function(n,t){var r,i,e,u,f;t=t||this.defaultError,r=[];try{for(i=0,e=ft.length;i<e;i++)u=ft.key(i),f=oy(this,u),u!==f&&r.push(f);o(n,r)}catch(s){o(t,s)}},y.prototype.mechanism="dom",y.prototype.read=function(i,r,u){if(u=u||this.defaultError,i instanceof Array)u({message:"Array of keys not supported"});else try{var e=sf(this,i),f=ft.getItem(e);f=f!==null&&f!=="undefined"?n.JSON.parse(f,rit):t,o(r,i,f)}catch(s){o(u,s)}},y.prototype.remove=function(n,t,i){if(i=i||this.defaultError,n instanceof Array)i({message:"Batches not supported"});else try{var r=sf(this,n);ft.removeItem(r),o(t)}catch(u){o(i,u)}}
 ,y.prototype.update=function(n,t,i,r){r=r||this.defaultError;var u=this;this.contains(n,function(f){f?u.addOrUpdate(n,t,i,r):o(r,{message:"key not found",key:n})},r)};var sy=n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.indexedDB,uit=n.IDBKeyRange||n.webkitIDBKeyRange,hy=n.IDBTransaction||n.webkitIDBTransaction||{},cy=hy.READ_ONLY||"readonly",rr=hy.READ_WRITE||"readwrite",yt=function(n,t){return function(i){var r=n||t,u,f;if(r){if(Object.prototype.toString.call(i)==="[object IDBDatabaseException]"){if(i.code===11){r({name:"QuotaExceededError",error:i});return}r(i);return}try{f=i.target.error||i,u=f.name}catch(e){u=i.type==="blocked"?"IndexedDBBlocked":"UnknownError"}r({name:u,error:i})}}},fit=function(n,t,i){var u=n.name,f="_datajs_"+u,r=sy.open(f);r.onblocked=i,r.onerror=i,r.onupgradeneeded=function(){var n=r.result;n.objectStoreNames.contains(u)||n.createObjectStore(u)},r.onsuccess=function(n){var f=r.result,e;if(!f.objectStoreNames.contains(u)){if("setVersion"in f){e=f.setV
 ersion("1.0"),e.onsuccess=function(){var n=e.transaction;n.oncomplete=function(){t(f)},f.createObjectStore(u,null,!1)},e.onerror=i,e.onblocked=i;return}n.target.error={name:"DBSchemaMismatch"},i(n);return}f.onversionchange=function(n){n.target.close()},t(f)}},fi=function(n,t,i,r){var u=n.name,f=n.db,e=yt(r,n.defaultError);if(f){i(f.transaction(u,t));return}fit(n,function(r){n.db=r,i(r.transaction(u,t))},e)},w=function(n){this.name=n};w.create=function(n){if(w.isSupported())return new w(n);throw{message:"IndexedDB is not supported on this browser"};},w.isSupported=function(){return!!sy},w.prototype.add=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n instanceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,rr,function(s){s.onabort=yt(r,o,n,"add"),s.oncomplete=function(){n instanceof Array?i(u,f):i(n,t)};for(var h=0;h<u.length&&h<f.length;h++)s.objectStore(e).add({v:f[h]},u[h])},r)},w.prototype.addOrUpdate=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n inst
 anceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,rr,function(s){var h,c;for(s.onabort=yt(r,o),s.oncomplete=function(){n instanceof Array?i(u,f):i(n,t)},h=0;h<u.length&&h<f.length;h++)c={v:f[h]},s.objectStore(e).put(c,u[h])},r)},w.prototype.clear=function(n,t){var i=this.name,r=this.defaultError;fi(this,rr,function(u){u.onerror=yt(t,r),u.oncomplete=function(){n()},u.objectStore(i).clear()},t)},w.prototype.close=function(){this.db&&(this.db.close(),this.db=null)},w.prototype.contains=function(n,t,i){var r=this.name,u=this.defaultError;fi(this,cy,function(f){var e=f.objectStore(r),o=e.get(n);f.oncomplete=function(){t(!!o.result)},f.onerror=yt(i,u)},i)},w.prototype.defaultError=ru,w.prototype.getAllKeys=function(n,t){var i=this.name,r=this.defaultError;fi(this,rr,function(u){var e=[],f;u.oncomplete=function(){n(e)},f=u.objectStore(i).openCursor(),f.onerror=yt(t,r),f.onsuccess=function(n){var t=n.target.result;t&&(e.push(t.key),t["continue"].call(t))}},t)},w.prototype.mechanism="indexeddb",w
 .prototype.read=function(n,i,r){var f=this.name,e=this.defaultError,u=n instanceof Array?n:[n];fi(this,cy,function(o){var h=[],s,c,l;for(o.onerror=yt(r,e,n,"read"),o.oncomplete=function(){n instanceof Array?i(u,h):i(u[0],h[0])},s=0;s<u.length;s++)c=o.objectStore(f),l=c.get.call(c,u[s]),l.onsuccess=function(n){var i=n.target.result;h.push(i?i.v:t)}},r)},w.prototype.remove=function(n,t,i){var u=this.name,f=this.defaultError,r=n instanceof Array?n:[n];fi(this,rr,function(n){var e,o;for(n.onerror=yt(i,f),n.oncomplete=function(){t()},e=0;e<r.length;e++)o=n.objectStore(u),o["delete"].call(o,r[e])},i)},w.prototype.update=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n instanceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,rr,function(s){var h,c,l;for(s.onabort=yt(r,o),s.oncomplete=function(){n instanceof Array?i(u,f):i(n,t)},h=0;h<u.length&&h<f.length;h++)c=s.objectStore(e).openCursor(uit.only(u[h])),l={v:f[h]},c.pair={key:u[h],value:l},c.onsuccess=function(n){var t=n.target.re
 sult;t?t.update(n.target.pair.value):s.abort()}},r)},ei=function(n){var e=[],r=[],i={},u,f;this.name=n,u=function(n){return n||this.defaultError},f=function(n,i){var r;return(n instanceof Array&&(r="Array of keys not supported"),(n===t||n===null)&&(r="Invalid key"),r)?(o(i,{message:r}),!1):!0},this.add=function(n,t,r,e){e=u(e),f(n,e)&&(i.hasOwnProperty(n)?e({message:"key already exists",key:n}):this.addOrUpdate(n,t,r,e))},this.addOrUpdate=function(n,s,h,c){if(c=u(c),f(n,c)){var l=i[n];l===t&&(l=e.length>0?e.splice(0,1):r.length),r[l]=s,i[n]=l,o(h,n,s)}},this.clear=function(n){r=[],i={},e=[],o(n)},this.contains=function(n,t){var r=i.hasOwnProperty(n);o(t,r)},this.getAllKeys=function(n){var t=[],r;for(r in i)t.push(r);o(n,t)},this.read=function(n,t,e){if(e=u(e),f(n,e)){var s=i[n];o(t,n,r[s])}},this.remove=function(n,s,h){if(h=u(h),f(n,h)){var c=i[n];c!==t&&(c===r.length-1?r.pop():(r[c]=t,e.push(c)),delete i[n],r.length===0&&(e=[])),o(s)}},this.update=function(n,t,r,e){e=u(e),f(n,e)&&(
 i.hasOwnProperty(n)?this.addOrUpdate(n,t,r,e):e({message:"key not found",key:n}))}},ei.create=function(n){return new ei(n)},ei.isSupported=function(){return!0},ei.prototype.close=function(){},ei.prototype.defaultError=ru,ei.prototype.mechanism="memory",ly={indexeddb:w,dom:y,memory:ei},pt.defaultStoreMechanism="best",pt.createStore=function(n,t){t||(t=pt.defaultStoreMechanism),t==="best"&&(t=y.isSupported()?"dom":"memory");var i=ly[t];if(i)return i.create(n);throw{message:"Failed to create store",name:n,mechanism:t};};var eit=function(n,t){var i=n.indexOf("?")>=0?"&":"?";return n+i+t},oit=function(n,t){var i=n.indexOf("?"),r="";return i>=0&&(r=n.substr(i),n=n.substr(0,i)),n[n.length-1]!=="/"&&(n+="/"),n+t+r},ay=function(n,t){return{method:"GET",requestUri:n,user:t.user,password:t.password,enableJsonpCallback:t.enableJsonpCallback,callbackParameterName:t.callbackParameterName,formatQueryString:t.formatQueryString}},pit=function(n,t){var u=-1,r=n.indexOf("?"),i;return r!==-1&&(i=n.inde
 xOf("?"+t+"=",r),i===-1&&(i=n.indexOf("&"+t+"=",r)),i!==-1&&(u=i+t.length+2)),u},sit=function(n,t,i,r){return vy(n,t,[],i,r)},vy=function(n,i,u,f,e){var s=ay(n,i),o=r.request(s,function(n){var t=n.__next,r=n.results;u=u.concat(r),t?o=vy(t,i,u,f,e):f(u)},e,t,i.httpClient,i.metadata);return{abort:function(){o.abort()}}},hit=function(n){var i=this,u=n.source;return i.identifier=ep(encodeURI(decodeURI(u))),i.options=n,i.count=function(n,f){var e=i.options;return r.request(ay(oit(u,"$count"),e),function(t){var i=s(t.toString());isNaN(i)?f({message:"Count is NaN",count:i}):n(i)},f,t,e.httpClient,e.metadata)},i.read=function(n,t,r,f){var e="$skip="+n+"&$top="+t;return sit(eit(u,e),i.options,r,f)},i},cit=function(n,t){var r=lit(n,t),i,u;r&&(i=r.i-t.i,u=i+(n.c-n.d.length),n.d=n.d.concat(t.d.slice(i,u)))},lit=function(n,t){var r=n.i+n.c,u=t.i+t.c,i=n.i>t.i?n.i:t.i,f=r<u?r:u,e;return f>=i&&(e={i:i,c:f-i}),e},yy=function(n,i){if(n===t||typeof n!="number")throw{message:"'"+i+"' must be a number.
 "};if(isNaN(n)||n<0||!isFinite(n))throw{message:"'"+i+"' must be greater than or equal to zero."};},ait=function(n,i){if(n!==t){if(typeof n!="number")throw{message:"'"+i+"' must be a number."};if(isNaN(n)||n<=0||!isFinite(n))throw{message:"'"+i+"' must be greater than zero."};}},py=function(n,i){if(n!==t&&(typeof n!="number"||isNaN(n)||!isFinite(n)))throw{message:"'"+i+"' must be a number."};},ao=function(n,t){for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return n.splice(i,1),!0;return!1},wy=function(n){var t=0,r=typeof n,i;if(r==="object"&&n)for(i in n)t+=i.length*2+wy(n[i]);else t=r==="string"?n.length*2:8;return t},by=function(n,t,i){return n=Math.floor(n/i)*i,t=Math.ceil((t+1)/i)*i,{i:n,c:t-n}},hf="destroy",ai="idle",ky="init",vo="read",yo="prefetch",po="write",gr="cancel",oi="end",wo="error",vi="start",dy="wait",gy="clear",nu="done",tu="local",np="save",tp="source",ur=function(n,t,i,r,u,f,e){var h,c,o=this,l,s;return o.p=t,o.i=r,o.c=u,o.d=f,o.s=vi,o.canceled=!1,o.pending=e,o.oncom
 plete=null,o.cancel=function(){if(i){var n=o.s;n!==wo&&n!==oi&&n!==gr&&(o.canceled=!0,s(gr,h))}},o.complete=function(){s(oi,h)},o.error=function(n){o.canceled||s(wo,n)},o.run=function(n){c=n,o.transition(o.s,h)},o.wait=function(n){s(dy,n)},l=function(t,i,r){switch(t){case vi:i!==ky&&n(o,t,i,r);break;case dy:n(o,t,i,r);break;case gr:n(o,t,i,r),o.fireCanceled(),s(oi);break;case wo:n(o,t,i,r),o.canceled=!0,o.fireRejected(r),s(oi);break;case oi:if(o.oncomplete)o.oncomplete(o);o.canceled||o.fireResolved(),n(o,t,i,r);break;default:n(o,t,i,r)}},s=function(n,t){o.s=n,h=t,l(n,c,t)},o.transition=s,o};ur.prototype.fireResolved=function(){var n=this.p;n&&(this.p=null,n.resolve(this.d))},ur.prototype.fireRejected=function(n){var t=this.p;t&&(this.p=null,t.reject(n))},ur.prototype.fireCanceled=function(){this.fireRejected({canceled:!0,message:"Operation canceled"})},ip=function(i){var it=ky,y={counts:0,netReads:0,prefetches:0,cacheReads:0},c=[],b=[],p=[],nt=0,l=!1,k=af(i.cacheSize,1048576),a=0,h=
 0,d=0,tt=k===0,r=af(i.pageSize,50),ut=af(i.prefetchSize,r),ht="1.0",f,ft=0,w=i.source,v,u;typeof w=="string"&&(w=new hit(i)),w.options=i,v=pt.createStore(i.name,i.mechanism),u=this,u.onidle=i.idle,u.stats=y,u.count=function(){var n,i,t;if(f)throw f;return(n=su(),i=!1,l)?(o(function(){n.resolve(a)}),n.promise()):(t=w.count(function(i){t=null,y.counts++,n.resolve(i)},function(r){t=null,n.reject(g(r,{canceled:i}))}),g(n.promise(),{cancel:function(){t&&(i=!0,t.abort(),t=null)}}))},u.clear=function(){if(f)throw f;if(c.length===0){var n=su(),t=new ur(ii,n,!1);return et(t,c),n.promise()}return c[0].p},u.filterForward=function(n,t,i){return lt(n,t,i,!1)},u.filterBack=function(n,t,i){return lt(n,t,i,!0)},u.readRange=function(n,t){if(yy(n,"index"),yy(t,"count"),f)throw f;var i=su(),r=new ur(ui,i,!0,n,t,[],0);return et(r,b),g(i.promise(),{cancel:function(){r.cancel()}})},u.ToObservable=u.toObservable=function(){if(!n.Rx||!n.Rx.Observable)throw{message:"Rx library not available - include rx.js"
 };if(f)throw f;return n.Rx.Observable.CreateWithDisposable(function(n){var t=!1,i=0,f=function(i){t||n.OnError(i)},e=function(o){if(!t){for(var s=0,h=o.length;s<h;s++)n.OnNext(o[s]);o.length<r?n.OnCompleted():(i+=r,u.readRange(i,r).then(e,f))}};return u.readRange(i,r).then(e,f),{Dispose:function(){t=!0}}})};var rt=function(n){return function(t){f={message:n,error:t};for(var i=0,r=b.length;i<r;i++)b[i].fireRejected(f);for(i=0,r=c.length;i<r;i++)c[i].fireRejected(f);b=c=null}},e=function(n){if(n!==it){it=n;for(var i=c.concat(b,p),t=0,r=i.length;t<r;t++)i[t].run(it)}},ct=function(){var n=new ki;return v.clear(function(){nt=0,l=!1,a=0,h=0,d=0,tt=k===0,y={counts:0,netReads:0,prefetches:0,cacheReads:0},u.stats=y,v.close(),n.resolve()},function(t){n.reject(t)}),n},kt=function(n){var t=ao(c,n);t||(t=ao(b,n),t||ao(p,n)),ft--,e(ai)},dt=function(n){var t=new ki,u=!1,i=w.read(n,r,function(i){var r={i:n,c:i.length,d:i};t.resolve(r)},function(n){t.reject(n)});return g(t,{cancel:function(){i&&(i.a
 bort(),u=!0,i=null)}})},lt=function(n,t,i,e){if(n=s(n),t=s(t),isNaN(n))throw{message:"'index' must be a valid number.",index:n};if(isNaN(t))throw{message:"'count' must be a valid number.",count:t};if(f)throw f;n=Math.max(n,0);var h=su(),o=[],a=!1,l=null,v=function(n,f){a||(t>=0&&o.length>=t?h.resolve(o):l=u.readRange(n,f).then(function(u){for(var l,a,y,p,s=0,c=u.length;s<c&&(t<0||o.length<t);s++)l=e?c-s-1:s,a=u[l],i(a)&&(y={index:n+l,item:a},e?o.unshift(y):o.push(y));!e&&u.length<f||e&&n<=0?h.resolve(o):(p=e?Math.max(n-r,0):n+f,v(p,r))},function(n){h.reject(n)}))},c=by(n,n,r),y=e?c.i:n,p=e?n-c.i+1:c.i+c.c-n;return v(y,p),g(h.promise(),{cancel:function(){l&&l.cancel(),a=!0}})},at=function(){u.onidle&&ft===0&&u.onidle()},gt=function(n){if(!l&&ut!==0&&!tt&&(p.length===0||p[0]&&p[0].c!==-1)){var t=new ur(ri,null,!0,n,ut,null,ut);et(t,p)}},et=function(n,t){n.oncomplete=kt,t.push(n),ft++,n.run(it)},ni=function(n){var r=!1,i=g(new ki,{cancel:function(){r=!0}}),u=vt(i,"Read page from store 
 failure");return v.contains(n,function(f){if(!r){if(f){v.read(n,function(n,u){r||i.resolve(u!==t,u)},u);return}i.resolve(!1)}},u),i},ti=function(n,t){var e=!1,i=g(new ki,{cancel:function(){e=!0}}),r=vt(i,"Save page to store failure"),u=function(){i.resolve(!0)},f;return t.c>0?(f=wy(t),tt=k>=0&&k<nt+f,tt?u():v.addOrUpdate(n,t,function(){yt(t,f),st(u,r)},r)):(yt(t,0),st(u,r)),i},st=function(n,t){var i={actualCacheSize:nt,allDataLocal:l,cacheSize:k,collectionCount:a,highestSavedPage:h,highestSavedPageSize:d,pageSize:r,sourceId:w.identifier,version:ht};v.addOrUpdate("__settings",i,n,t)},vt=function(n){return function(){n.resolve(!1)}},yt=function(n,t){var i=n.c,u=n.i;i===0?h===u-r&&(a=h+d):(h=Math.max(h,u),h===u&&(d=i),nt+=t,i<r&&!a&&(a=u+i)),l||a!==h+d||(l=!0)},wt=function(n,t,i,r){var u=n.canceled&&t!==oi;return u&&t===gr&&r&&r.cancel&&r.cancel(),u},ii=function(n,t,i){var r=n.transition;if(i!==hf)return e(hf),!0;switch(t){case vi:r(gy);break;case oi:at();break;case gy:ct().then(functi
 on(){n.complete()}),n.wait();break;default:return!1}return!0},ri=function(n,t,i,u){var o,f;if(!wt(n,t,i,u)){if(o=n.transition,i!==yo)return i===hf?t!==gr&&n.cancel():i===ai&&e(yo),!0;switch(t){case vi:p[0]===n&&o(tu,n.i);break;case nu:f=n.pending,f>0&&(f-=Math.min(f,u.c)),l||f===0||u.c<r||tt?n.complete():(n.pending=f,o(tu,u.i+r));break;default:return bt(n,t,i,u,!0)}}return!0},ui=function(n,t,i,u){var f,o,s;if(!wt(n,t,i,u)){if(f=n.transition,i!==vo&&t!==vi)return i===hf?t!==vi&&n.cancel():i!==po&&e(vo),!0;switch(t){case vi:(i===ai||i===yo)&&(e(vo),n.c>0?(o=by(n.i,n.c,r),f(tu,o.i)):f(nu,n));break;case nu:cit(n,u),s=n.d.length,n.c===s||u.c<r?(y.cacheReads++,gt(u.i+u.c),n.complete()):f(tu,u.i+r);break;default:return bt(n,t,i,u,!1)}}return!0},bt=function(n,t,i,r,u){var s=n.error,o=n.transition,h=n.wait,f;switch(t){case oi:at();break;case tu:f=ni(r).then(function(t,i){n.canceled||(t?o(nu,i):o(tp,r))});break;case tp:f=dt(r).then(function(t){n.canceled||(u?y.prefetches++:y.netReads++,o(np,t
 ))},s);break;case np:i!==po&&(e(po),f=ti(r.i,r).then(function(t){n.canceled||(!t&&u&&(n.pending=0),o(nu,r)),e(ai)}));break;default:return!1}return f&&(n.canceled?f.cancel():n.s===t&&h(f)),!0};return v.read("__settings",function(n,t){if(ot(t)){var i=t.version;if(!i||i.indexOf("1.")!==0){rt("Unsupported cache store version "+i)();return}r!==t.pageSize||w.identifier!==t.sourceId?ct().then(function(){e(ai)},rt("Unable to clear store during initialization")):(nt=t.actualCacheSize,l=t.allDataLocal,k=t.cacheSize,a=t.collectionCount,h=t.highestSavedPage,d=t.highestSavedPageSize,ht=i,e(ai))}else st(function(){e(ai)},rt("Unable to write settings during initialization."))},rt("Unable to read settings from store.")),u},pt.createDataCache=function(n){if(ait(n.pageSize,"pageSize"),py(n.cacheSize,"cacheSize"),py(n.prefetchSize,"prefetchSize"),!ot(n.name))throw{message:"Undefined or null name",options:n};if(!ot(n.source))throw{message:"Undefined source",options:n};return new ip(n)}})(this)
\ No newline at end of file


[5/6] [OLINGO-429] add headers, extend rat module, remove dependencies

Posted by ko...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/scripts/datajs-1.1.1.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/datajs-1.1.1.js b/odatajs/demo/scripts/datajs-1.1.1.js
deleted file mode 100644
index 339b153..0000000
--- a/odatajs/demo/scripts/datajs-1.1.1.js
+++ /dev/null
@@ -1,10710 +0,0 @@
-// Copyright (c) Microsoft.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// odatajs.js
-
-(function (window, undefined) {
-
-    var datajs = window.odatajs || {};
-    var odata = window.OData || {};
-
-    // AMD support
-    if (typeof define === 'function' && define.amd) {
-        define('datajs', datajs);
-        define('OData', odata);
-    } else {
-        window.odatajs = datajs;
-        window.OData = odata;
-    }
-
-    odatajs.version = {
-        major: 1,
-        minor: 1,
-        build: 1
-    };
-
-
-    var activeXObject = function (progId) {
-        /// <summary>Creates a new ActiveXObject from the given progId.</summary>
-        /// <param name="progId" type="String" mayBeNull="false" optional="false">
-        ///    ProgId string of the desired ActiveXObject.
-        /// </param>
-        /// <remarks>
-        ///    This function throws whatever exception might occur during the creation
-        ///    of the ActiveXObject.
-        /// </remarks>
-        /// <returns type="Object">
-        ///     The ActiveXObject instance. Null if ActiveX is not supported by the
-        ///     browser.
-        /// </returns>
-        if (window.ActiveXObject) {
-            return new window.ActiveXObject(progId);
-        }
-        return null;
-    };
-
-    var assigned = function (value) {
-        /// <summary>Checks whether the specified value is different from null and undefined.</summary>
-        /// <param name="value" mayBeNull="true" optional="true">Value to check.</param>
-        /// <returns type="Boolean">true if the value is assigned; false otherwise.</returns>
-        return value !== null && value !== undefined;
-    };
-
-    var contains = function (arr, item) {
-        /// <summary>Checks whether the specified item is in the array.</summary>
-        /// <param name="arr" type="Array" optional="false" mayBeNull="false">Array to check in.</param>
-        /// <param name="item">Item to look for.</param>
-        /// <returns type="Boolean">true if the item is contained, false otherwise.</returns>
-
-        var i, len;
-        for (i = 0, len = arr.length; i < len; i++) {
-            if (arr[i] === item) {
-                return true;
-            }
-        }
-
-        return false;
-    };
-
-    var defined = function (a, b) {
-        /// <summary>Given two values, picks the first one that is not undefined.</summary>
-        /// <param name="a">First value.</param>
-        /// <param name="b">Second value.</param>
-        /// <returns>a if it's a defined value; else b.</returns>
-        return (a !== undefined) ? a : b;
-    };
-
-    var delay = function (callback) {
-        /// <summary>Delays the invocation of the specified function until execution unwinds.</summary>
-        /// <param name="callback" type="Function">Callback function.</param>
-        if (arguments.length === 1) {
-            window.setTimeout(callback, 0);
-            return;
-        }
-
-        var args = Array.prototype.slice.call(arguments, 1);
-        window.setTimeout(function () {
-            callback.apply(this, args);
-        }, 0);
-    };
-
-
-    var extend = function (target, values) {
-        /// <summary>Extends the target with the specified values.</summary>
-        /// <param name="target" type="Object">Object to add properties to.</param>
-        /// <param name="values" type="Object">Object with properties to add into target.</param>
-        /// <returns type="Object">The target object.</returns>
-
-        for (var name in values) {
-            target[name] = values[name];
-        }
-
-        return target;
-    };
-
-    var find = function (arr, callback) {
-        /// <summary>Returns the first item in the array that makes the callback function true.</summary>
-        /// <param name="arr" type="Array" optional="false" mayBeNull="true">Array to check in.</param>
-        /// <param name="callback" type="Function">Callback function to invoke once per item in the array.</param>
-        /// <returns>The first item that makes the callback return true; null otherwise or if the array is null.</returns>
-
-        if (arr) {
-            var i, len;
-            for (i = 0, len = arr.length; i < len; i++) {
-                if (callback(arr[i])) {
-                    return arr[i];
-                }
-            }
-        }
-        return null;
-    };
-
-    var isArray = function (value) {
-        /// <summary>Checks whether the specified value is an array object.</summary>
-        /// <param name="value">Value to check.</param>
-        /// <returns type="Boolean">true if the value is an array object; false otherwise.</returns>
-
-        return Object.prototype.toString.call(value) === "[object Array]";
-    };
-
-    var isDate = function (value) {
-        /// <summary>Checks whether the specified value is a Date object.</summary>
-        /// <param name="value">Value to check.</param>
-        /// <returns type="Boolean">true if the value is a Date object; false otherwise.</returns>
-
-        return Object.prototype.toString.call(value) === "[object Date]";
-    };
-
-    var isObject = function (value) {
-        /// <summary>Tests whether a value is an object.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <remarks>
-        ///     Per javascript rules, null and array values are objects and will cause this function to return true.
-        /// </remarks>
-        /// <returns type="Boolean">True is the value is an object; false otherwise.</returns>
-
-        return typeof value === "object";
-    };
-
-    var parseInt10 = function (value) {
-        /// <summary>Parses a value in base 10.</summary>
-        /// <param name="value" type="String">String value to parse.</param>
-        /// <returns type="Number">The parsed value, NaN if not a valid value.</returns>
-
-        return parseInt(value, 10);
-    };
-
-    var renameProperty = function (obj, oldName, newName) {
-        /// <summary>Renames a property in an object.</summary>
-        /// <param name="obj" type="Object">Object in which the property will be renamed.</param>
-        /// <param name="oldName" type="String">Name of the property that will be renamed.</param>
-        /// <param name="newName" type="String">New name of the property.</param>
-        /// <remarks>
-        ///    This function will not do anything if the object doesn't own a property with the specified old name.
-        /// </remarks>
-
-        if (obj.hasOwnProperty(oldName)) {
-            obj[newName] = obj[oldName];
-            delete obj[oldName];
-        }
-    };
-
-    var throwErrorCallback = function (error) {
-        /// <summary>Default error handler.</summary>
-        /// <param name="error" type="Object">Error to handle.</param>
-        throw error;
-    };
-
-    var trimString = function (str) {
-        /// <summary>Removes leading and trailing whitespaces from a string.</summary>
-        /// <param name="str" type="String" optional="false" mayBeNull="false">String to trim</param>
-        /// <returns type="String">The string with no leading or trailing whitespace.</returns>
-
-        if (str.trim) {
-            return str.trim();
-        }
-
-        return str.replace(/^\s+|\s+$/g, '');
-    };
-
-    var undefinedDefault = function (value, defaultValue) {
-        /// <summary>Returns a default value in place of undefined.</summary>
-        /// <param name="value" mayBeNull="true" optional="true">Value to check.</param>
-        /// <param name="defaultValue">Value to return if value is undefined.</param>
-        /// <returns>value if it's defined; defaultValue otherwise.</returns>
-        /// <remarks>
-        /// This should only be used for cases where falsy values are valid;
-        /// otherwise the pattern should be 'x = (value) ? value : defaultValue;'.
-        /// </remarks>
-        return (value !== undefined) ? value : defaultValue;
-    };
-
-    // Regular expression that splits a uri into its components:
-    // 0 - is the matched string.
-    // 1 - is the scheme.
-    // 2 - is the authority.
-    // 3 - is the path.
-    // 4 - is the query.
-    // 5 - is the fragment.
-    var uriRegEx = /^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#:]+)?(\?[^#]*)?(#.*)?/;
-    var uriPartNames = ["scheme", "authority", "path", "query", "fragment"];
-
-    var getURIInfo = function (uri) {
-        /// <summary>Gets information about the components of the specified URI.</summary>
-        /// <param name="uri" type="String">URI to get information from.</param>
-        /// <returns type="Object">
-        /// An object with an isAbsolute flag and part names (scheme, authority, etc.) if available.
-        /// </returns>
-
-        var result = { isAbsolute: false };
-
-        if (uri) {
-            var matches = uriRegEx.exec(uri);
-            if (matches) {
-                var i, len;
-                for (i = 0, len = uriPartNames.length; i < len; i++) {
-                    if (matches[i + 1]) {
-                        result[uriPartNames[i]] = matches[i + 1];
-                    }
-                }
-            }
-            if (result.scheme) {
-                result.isAbsolute = true;
-            }
-        }
-
-        return result;
-    };
-
-    var getURIFromInfo = function (uriInfo) {
-        /// <summary>Builds a URI string from its components.</summary>
-        /// <param name="uriInfo" type="Object"> An object with uri parts (scheme, authority, etc.).</param>
-        /// <returns type="String">URI string.</returns>
-
-        return "".concat(
-            uriInfo.scheme || "",
-            uriInfo.authority || "",
-            uriInfo.path || "",
-            uriInfo.query || "",
-            uriInfo.fragment || "");
-    };
-
-    // Regular expression that splits a uri authority into its subcomponents:
-    // 0 - is the matched string.
-    // 1 - is the userinfo subcomponent.
-    // 2 - is the host subcomponent.
-    // 3 - is the port component.
-    var uriAuthorityRegEx = /^\/{0,2}(?:([^@]*)@)?([^:]+)(?::{1}(\d+))?/;
-
-    // Regular expression that matches percentage enconded octects (i.e %20 or %3A);
-    var pctEncodingRegEx = /%[0-9A-F]{2}/ig;
-
-    var normalizeURICase = function (uri) {
-        /// <summary>Normalizes the casing of a URI.</summary>
-        /// <param name="uri" type="String">URI to normalize, absolute or relative.</param>
-        /// <returns type="String">The URI normalized to lower case.</returns>
-
-        var uriInfo = getURIInfo(uri);
-        var scheme = uriInfo.scheme;
-        var authority = uriInfo.authority;
-
-        if (scheme) {
-            uriInfo.scheme = scheme.toLowerCase();
-            if (authority) {
-                var matches = uriAuthorityRegEx.exec(authority);
-                if (matches) {
-                    uriInfo.authority = "//" +
-                    (matches[1] ? matches[1] + "@" : "") +
-                    (matches[2].toLowerCase()) +
-                    (matches[3] ? ":" + matches[3] : "");
-                }
-            }
-        }
-
-        uri = getURIFromInfo(uriInfo);
-
-        return uri.replace(pctEncodingRegEx, function (str) {
-            return str.toLowerCase();
-        });
-    };
-
-    var normalizeURI = function (uri, base) {
-        /// <summary>Normalizes a possibly relative URI with a base URI.</summary>
-        /// <param name="uri" type="String">URI to normalize, absolute or relative.</param>
-        /// <param name="base" type="String" mayBeNull="true">Base URI to compose with.</param>
-        /// <returns type="String">The composed URI if relative; the original one if absolute.</returns>
-
-        if (!base) {
-            return uri;
-        }
-
-        var uriInfo = getURIInfo(uri);
-        if (uriInfo.isAbsolute) {
-            return uri;
-        }
-
-        var baseInfo = getURIInfo(base);
-        var normInfo = {};
-        var path;
-
-        if (uriInfo.authority) {
-            normInfo.authority = uriInfo.authority;
-            path = uriInfo.path;
-            normInfo.query = uriInfo.query;
-        } else {
-            if (!uriInfo.path) {
-                path = baseInfo.path;
-                normInfo.query = uriInfo.query || baseInfo.query;
-            } else {
-                if (uriInfo.path.charAt(0) === '/') {
-                    path = uriInfo.path;
-                } else {
-                    path = mergeUriPathWithBase(uriInfo.path, baseInfo.path);
-                }
-                normInfo.query = uriInfo.query;
-            }
-            normInfo.authority = baseInfo.authority;
-        }
-
-        normInfo.path = removeDotsFromPath(path);
-
-        normInfo.scheme = baseInfo.scheme;
-        normInfo.fragment = uriInfo.fragment;
-
-        return getURIFromInfo(normInfo);
-    };
-
-    var mergeUriPathWithBase = function (uriPath, basePath) {
-        /// <summary>Merges the path of a relative URI and a base URI.</summary>
-        /// <param name="uriPath" type="String>Relative URI path.</param>
-        /// <param name="basePath" type="String">Base URI path.</param>
-        /// <returns type="String">A string with the merged path.</returns>
-
-        var path = "/";
-        var end;
-
-        if (basePath) {
-            end = basePath.lastIndexOf("/");
-            path = basePath.substring(0, end);
-
-            if (path.charAt(path.length - 1) !== "/") {
-                path = path + "/";
-            }
-        }
-
-        return path + uriPath;
-    };
-
-    var removeDotsFromPath = function (path) {
-        /// <summary>Removes the special folders . and .. from a URI's path.</summary>
-        /// <param name="path" type="string">URI path component.</param>
-        /// <returns type="String">Path without any . and .. folders.</returns>
-
-        var result = "";
-        var segment = "";
-        var end;
-
-        while (path) {
-            if (path.indexOf("..") === 0 || path.indexOf(".") === 0) {
-                path = path.replace(/^\.\.?\/?/g, "");
-            } else if (path.indexOf("/..") === 0) {
-                path = path.replace(/^\/\..\/?/g, "/");
-                end = result.lastIndexOf("/");
-                if (end === -1) {
-                    result = "";
-                } else {
-                    result = result.substring(0, end);
-                }
-            } else if (path.indexOf("/.") === 0) {
-                path = path.replace(/^\/\.\/?/g, "/");
-            } else {
-                segment = path;
-                end = path.indexOf("/", 1);
-                if (end !== -1) {
-                    segment = path.substring(0, end);
-                }
-                result = result + segment;
-                path = path.replace(segment, "");
-            }
-        }
-        return result;
-    };
-
-    var convertByteArrayToHexString = function (str) {
-        var arr = [];
-        if (window.atob === undefined) {
-            arr = decodeBase64(str);
-        } else {
-            var binaryStr = window.atob(str);
-            for (var i = 0; i < binaryStr.length; i++) {
-                arr.push(binaryStr.charCodeAt(i));
-            }
-        }
-        var hexValue = "";
-        var hexValues = "0123456789ABCDEF";
-        for (var j = 0; j < arr.length; j++) {
-            var t = arr[j];
-            hexValue += hexValues[t >> 4];
-            hexValue += hexValues[t & 0x0F];
-        }
-        return hexValue;
-    };
-
-    var decodeBase64 = function (str) {
-        var binaryString = "";
-        for (var i = 0; i < str.length; i++) {
-            var base65IndexValue = getBase64IndexValue(str[i]);
-            var binaryValue = "";
-            if (base65IndexValue !== null) {
-                binaryValue = base65IndexValue.toString(2);
-                binaryString += addBase64Padding(binaryValue);
-            }
-        }
-        var byteArray = [];
-        var numberOfBytes = parseInt(binaryString.length / 8, 10);
-        for (i = 0; i < numberOfBytes; i++) {
-            var intValue = parseInt(binaryString.substring(i * 8, (i + 1) * 8), 2);
-            byteArray.push(intValue);
-        }
-        return byteArray;
-    };
-
-    var getBase64IndexValue = function (character) {
-        var asciiCode = character.charCodeAt(0);
-        var asciiOfA = 65;
-        var differenceBetweenZanda = 6;
-        if (asciiCode >= 65 && asciiCode <= 90) {           // between "A" and "Z" inclusive
-            return asciiCode - asciiOfA;
-        } else if (asciiCode >= 97 && asciiCode <= 122) {   // between 'a' and 'z' inclusive
-            return asciiCode - asciiOfA - differenceBetweenZanda;
-        } else if (asciiCode >= 48 && asciiCode <= 57) {    // between '0' and '9' inclusive
-            return asciiCode + 4;
-        } else if (character == "+") {
-            return 62;
-        } else if (character == "/") {
-            return 63;
-        } else {
-            return null;
-        }
-    };
-
-    var addBase64Padding = function (binaryString) {
-        while (binaryString.length < 6) {
-            binaryString = "0" + binaryString;
-        }
-        return binaryString;
-    };
-
-    var getJsonValueArraryLength = function (data) {
-        if (data && data.value) {
-            return data.value.length;
-        }
-
-        return 0;
-    };
-
-    var sliceJsonValueArray = function (data, start, end) {
-        if (data == undefined || data.value == undefined) {
-            return data;
-        }
-
-        if (start < 0) {
-            start = 0;
-        }
-
-        var length = getJsonValueArraryLength(data);
-        if (length < end) {
-            end = length;
-        }
-
-        var newdata = {};
-        for (var property in data) {
-            if (property == "value") {
-                newdata[property] = data[property].slice(start, end);
-            } else {
-                newdata[property] = data[property];
-            }
-        }
-
-        return newdata;
-    };
-
-    var concatJsonValueArray = function (data, concatData) {
-        if (concatData == undefined || concatData.value == undefined) {
-            return data;
-        }
-
-        if (data == undefined || Object.keys(data).length == 0) {
-            return concatData;
-        }
-
-        if (data.value == undefined) {
-            data.value = concatData.value;
-            return data;
-        }
-
-        data.value = data.value.concat(concatData.value);
-
-        return data;
-    };
-
-
-
-    // URI prefixes to generate smaller code.
-    var http = "http://";
-    var w3org = http + "www.w3.org/";               // http://www.w3.org/
-
-    var xhtmlNS = w3org + "1999/xhtml";             // http://www.w3.org/1999/xhtml
-    var xmlnsNS = w3org + "2000/xmlns/";            // http://www.w3.org/2000/xmlns/
-    var xmlNS = w3org + "XML/1998/namespace";       // http://www.w3.org/XML/1998/namespace
-
-    var mozillaParserErroNS = http + "www.mozilla.org/newlayout/xml/parsererror.xml";
-
-    var hasLeadingOrTrailingWhitespace = function (text) {
-        /// <summary>Checks whether the specified string has leading or trailing spaces.</summary>
-        /// <param name="text" type="String">String to check.</param>
-        /// <returns type="Boolean">true if text has any leading or trailing whitespace; false otherwise.</returns>
-
-        var re = /(^\s)|(\s$)/;
-        return re.test(text);
-    };
-
-    var isWhitespace = function (text) {
-        /// <summary>Determines whether the specified text is empty or whitespace.</summary>
-        /// <param name="text" type="String">Value to inspect.</param>
-        /// <returns type="Boolean">true if the text value is empty or all whitespace; false otherwise.</returns>
-
-        var ws = /^\s*$/;
-        return text === null || ws.test(text);
-    };
-
-    var isWhitespacePreserveContext = function (domElement) {
-        /// <summary>Determines whether the specified element has xml:space='preserve' applied.</summary>
-        /// <param name="domElement">Element to inspect.</param>
-        /// <returns type="Boolean">Whether xml:space='preserve' is in effect.</returns>
-
-        while (domElement !== null && domElement.nodeType === 1) {
-            var val = xmlAttributeValue(domElement, "space", xmlNS);
-            if (val === "preserve") {
-                return true;
-            } else if (val === "default") {
-                break;
-            } else {
-                domElement = domElement.parentNode;
-            }
-        }
-
-        return false;
-    };
-
-    var isXmlNSDeclaration = function (domAttribute) {
-        /// <summary>Determines whether the attribute is a XML namespace declaration.</summary>
-        /// <param name="domAttribute">Element to inspect.</param>
-        /// <returns type="Boolean">
-        ///    True if the attribute is a namespace declaration (its name is 'xmlns' or starts with 'xmlns:'; false otherwise.
-        /// </returns>
-
-        var nodeName = domAttribute.nodeName;
-        return nodeName == "xmlns" || nodeName.indexOf("xmlns:") === 0;
-    };
-
-    var safeSetProperty = function (obj, name, value) {
-        /// <summary>Safely set as property in an object by invoking obj.setProperty.</summary>
-        /// <param name="obj">Object that exposes a setProperty method.</param>
-        /// <param name="name" type="String" mayBeNull="false">Property name.</param>
-        /// <param name="value">Property value.</param>
-
-        try {
-            obj.setProperty(name, value);
-        } catch (_) { }
-    };
-
-    var msXmlDom3 = function () {
-        /// <summary>Creates an configures new MSXML 3.0 ActiveX object.</summary>
-        /// <remakrs>
-        ///    This function throws any exception that occurs during the creation
-        ///    of the MSXML 3.0 ActiveX object.
-        /// <returns type="Object">New MSXML 3.0 ActiveX object.</returns>
-
-        var msxml3 = activeXObject("Msxml2.DOMDocument.3.0");
-        if (msxml3) {
-            safeSetProperty(msxml3, "ProhibitDTD", true);
-            safeSetProperty(msxml3, "MaxElementDepth", 256);
-            safeSetProperty(msxml3, "AllowDocumentFunction", false);
-            safeSetProperty(msxml3, "AllowXsltScript", false);
-        }
-        return msxml3;
-    };
-
-    var msXmlDom = function () {
-        /// <summary>Creates an configures new MSXML 6.0 or MSXML 3.0 ActiveX object.</summary>
-        /// <remakrs>
-        ///    This function will try to create a new MSXML 6.0 ActiveX object. If it fails then
-        ///    it will fallback to create a new MSXML 3.0 ActiveX object. Any exception that
-        ///    happens during the creation of the MSXML 6.0 will be handled by the function while
-        ///    the ones that happend during the creation of the MSXML 3.0 will be thrown.
-        /// <returns type="Object">New MSXML 3.0 ActiveX object.</returns>
-
-        try {
-            var msxml = activeXObject("Msxml2.DOMDocument.6.0");
-            if (msxml) {
-                msxml.async = true;
-            }
-            return msxml;
-        } catch (_) {
-            return msXmlDom3();
-        }
-    };
-
-    var msXmlParse = function (text) {
-        /// <summary>Parses an XML string using the MSXML DOM.</summary>
-        /// <remakrs>
-        ///    This function throws any exception that occurs during the creation
-        ///    of the MSXML ActiveX object.  It also will throw an exception
-        ///    in case of a parsing error.
-        /// <returns type="Object">New MSXML DOMDocument node representing the parsed XML string.</returns>
-
-        var dom = msXmlDom();
-        if (!dom) {
-            return null;
-        }
-
-        dom.loadXML(text);
-        var parseError = dom.parseError;
-        if (parseError.errorCode !== 0) {
-            xmlThrowParserError(parseError.reason, parseError.srcText, text);
-        }
-        return dom;
-    };
-
-    var xmlThrowParserError = function (exceptionOrReason, srcText, errorXmlText) {
-        /// <summary>Throws a new exception containing XML parsing error information.</summary>
-        /// <param name="exceptionOrReason">
-        ///    String indicatin the reason of the parsing failure or
-        ///    Object detailing the parsing error.
-        /// </param>
-        /// <param name="srcText" type="String">
-        ///    String indicating the part of the XML string that caused the parsing error.
-        /// </param>
-        /// <param name="errorXmlText" type="String">XML string for wich the parsing failed.</param>
-
-        if (typeof exceptionOrReason === "string") {
-            exceptionOrReason = { message: exceptionOrReason };
-        }
-        throw extend(exceptionOrReason, { srcText: srcText || "", errorXmlText: errorXmlText || "" });
-    };
-
-    var xmlParse = function (text) {
-        /// <summary>Returns an XML DOM document from the specified text.</summary>
-        /// <param name="text" type="String">Document text.</param>
-        /// <returns>XML DOM document.</returns>
-        /// <remarks>This function will throw an exception in case of a parse error.</remarks>
-
-        var domParser = window.DOMParser && new window.DOMParser();
-        var dom;
-
-        if (!domParser) {
-            dom = msXmlParse(text);
-            if (!dom) {
-                xmlThrowParserError("XML DOM parser not supported");
-            }
-            return dom;
-        }
-
-        try {
-            dom = domParser.parseFromString(text, "text/xml");
-        } catch (e) {
-            xmlThrowParserError(e, "", text);
-        }
-
-        var element = dom.documentElement;
-        var nsURI = element.namespaceURI;
-        var localName = xmlLocalName(element);
-
-        // Firefox reports errors by returing the DOM for an xml document describing the problem.
-        if (localName === "parsererror" && nsURI === mozillaParserErroNS) {
-            var srcTextElement = xmlFirstChildElement(element, mozillaParserErroNS, "sourcetext");
-            var srcText = srcTextElement ? xmlNodeValue(srcTextElement) : "";
-            xmlThrowParserError(xmlInnerText(element) || "", srcText, text);
-        }
-
-        // Chrome (and maybe other webkit based browsers) report errors by injecting a header with an error message.
-        // The error may be localized, so instead we simply check for a header as the
-        // top element or descendant child of the document.
-        if (localName === "h3" && nsURI === xhtmlNS || xmlFirstDescendantElement(element, xhtmlNS, "h3")) {
-            var reason = "";
-            var siblings = [];
-            var cursor = element.firstChild;
-            while (cursor) {
-                if (cursor.nodeType === 1) {
-                    reason += xmlInnerText(cursor) || "";
-                }
-                siblings.push(cursor.nextSibling);
-                cursor = cursor.firstChild || siblings.shift();
-            }
-            reason += xmlInnerText(element) || "";
-            xmlThrowParserError(reason, "", text);
-        }
-
-        return dom;
-    };
-
-    var xmlQualifiedName = function (prefix, name) {
-        /// <summary>Builds a XML qualified name string in the form of "prefix:name".</summary>
-        /// <param name="prefix" type="String" maybeNull="true">Prefix string.</param>
-        /// <param name="name" type="String">Name string to qualify with the prefix.</param>
-        /// <returns type="String">Qualified name.</returns>
-
-        return prefix ? prefix + ":" + name : name;
-    };
-
-    var xmlAppendText = function (domNode, textNode) {
-        /// <summary>Appends a text node into the specified DOM element node.</summary>
-        /// <param name="domNode">DOM node for the element.</param>
-        /// <param name="text" type="String" mayBeNull="false">Text to append as a child of element.</param>
-        if (hasLeadingOrTrailingWhitespace(textNode.data)) {
-            var attr = xmlAttributeNode(domNode, xmlNS, "space");
-            if (!attr) {
-                attr = xmlNewAttribute(domNode.ownerDocument, xmlNS, xmlQualifiedName("xml", "space"));
-                xmlAppendChild(domNode, attr);
-            }
-            attr.value = "preserve";
-        }
-        domNode.appendChild(textNode);
-        return domNode;
-    };
-
-    var xmlAttributes = function (element, onAttributeCallback) {
-        /// <summary>Iterates through the XML element's attributes and invokes the callback function for each one.</summary>
-        /// <param name="element">Wrapped element to iterate over.</param>
-        /// <param name="onAttributeCallback" type="Function">Callback function to invoke with wrapped attribute nodes.</param>
-
-        var attributes = element.attributes;
-        var i, len;
-        for (i = 0, len = attributes.length; i < len; i++) {
-            onAttributeCallback(attributes.item(i));
-        }
-    };
-
-    var xmlAttributeValue = function (domNode, localName, nsURI) {
-        /// <summary>Returns the value of a DOM element's attribute.</summary>
-        /// <param name="domNode">DOM node for the owning element.</param>
-        /// <param name="localName" type="String">Local name of the attribute.</param>
-        /// <param name="nsURI" type="String">Namespace URI of the attribute.</param>
-        /// <returns type="String" maybeNull="true">The attribute value, null if not found.</returns>
-
-        var attribute = xmlAttributeNode(domNode, localName, nsURI);
-        return attribute ? xmlNodeValue(attribute) : null;
-    };
-
-    var xmlAttributeNode = function (domNode, localName, nsURI) {
-        /// <summary>Gets an attribute node from a DOM element.</summary>
-        /// <param name="domNode">DOM node for the owning element.</param>
-        /// <param name="localName" type="String">Local name of the attribute.</param>
-        /// <param name="nsURI" type="String">Namespace URI of the attribute.</param>
-        /// <returns>The attribute node, null if not found.</returns>
-
-        var attributes = domNode.attributes;
-        if (attributes.getNamedItemNS) {
-            return attributes.getNamedItemNS(nsURI || null, localName);
-        }
-
-        return attributes.getQualifiedItem(localName, nsURI) || null;
-    };
-
-    var xmlBaseURI = function (domNode, baseURI) {
-        /// <summary>Gets the value of the xml:base attribute on the specified element.</summary>
-        /// <param name="domNode">Element to get xml:base attribute value from.</param>
-        /// <param name="baseURI" mayBeNull="true" optional="true">Base URI used to normalize the value of the xml:base attribute.</param>
-        /// <returns type="String">Value of the xml:base attribute if found; the baseURI or null otherwise.</returns>
-
-        var base = xmlAttributeNode(domNode, "base", xmlNS);
-        return (base ? normalizeURI(base.value, baseURI) : baseURI) || null;
-    };
-
-
-    var xmlChildElements = function (domNode, onElementCallback) {
-        /// <summary>Iterates through the XML element's child DOM elements and invokes the callback function for each one.</summary>
-        /// <param name="element">DOM Node containing the DOM elements to iterate over.</param>
-        /// <param name="onElementCallback" type="Function">Callback function to invoke for each child DOM element.</param>
-
-        xmlTraverse(domNode, /*recursive*/false, function (child) {
-            if (child.nodeType === 1) {
-                onElementCallback(child);
-            }
-            // continue traversing.
-            return true;
-        });
-    };
-
-    var xmlFindElementByPath = function (root, namespaceURI, path) {
-        /// <summary>Gets the descendant element under root that corresponds to the specified path and namespace URI.</summary>
-        /// <param name="root">DOM element node from which to get the descendant element.</param>
-        /// <param name="namespaceURI" type="String">The namespace URI of the element to match.</param>
-        /// <param name="path" type="String">Path to the desired descendant element.</param>
-        /// <returns>The element specified by path and namespace URI.</returns>
-        /// <remarks>
-        ///     All the elements in the path are matched against namespaceURI.
-        ///     The function will stop searching on the first element that doesn't match the namespace and the path.
-        /// </remarks>
-
-        var parts = path.split("/");
-        var i, len;
-        for (i = 0, len = parts.length; i < len; i++) {
-            root = root && xmlFirstChildElement(root, namespaceURI, parts[i]);
-        }
-        return root || null;
-    };
-
-    var xmlFindNodeByPath = function (root, namespaceURI, path) {
-        /// <summary>Gets the DOM element or DOM attribute node under root that corresponds to the specified path and namespace URI.</summary>
-        /// <param name="root">DOM element node from which to get the descendant node.</param>
-        /// <param name="namespaceURI" type="String">The namespace URI of the node to match.</param>
-        /// <param name="path" type="String">Path to the desired descendant node.</param>
-        /// <returns>The node specified by path and namespace URI.</returns>
-        /// <remarks>
-        ///     This function will traverse the path and match each node associated to a path segement against the namespace URI.
-        ///     The traversal stops when the whole path has been exahusted or a node that doesn't belogong the specified namespace is encountered.
-        ///
-        ///     The last segment of the path may be decorated with a starting @ character to indicate that the desired node is a DOM attribute.
-        /// </remarks>
-
-        var lastSegmentStart = path.lastIndexOf("/");
-        var nodePath = path.substring(lastSegmentStart + 1);
-        var parentPath = path.substring(0, lastSegmentStart);
-
-        var node = parentPath ? xmlFindElementByPath(root, namespaceURI, parentPath) : root;
-        if (node) {
-            if (nodePath.charAt(0) === "@") {
-                return xmlAttributeNode(node, nodePath.substring(1), namespaceURI);
-            }
-            return xmlFirstChildElement(node, namespaceURI, nodePath);
-        }
-        return null;
-    };
-
-    var xmlFirstChildElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the first child DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the child DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's first child DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/false);
-    };
-
-    var xmlFirstDescendantElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the descendant DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        if (domNode.getElementsByTagNameNS) {
-            var result = domNode.getElementsByTagNameNS(namespaceURI, localName);
-            return result.length > 0 ? result[0] : null;
-        }
-        return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/true);
-    };
-
-    var xmlFirstElementMaybeRecursive = function (domNode, namespaceURI, localName, recursive) {
-        /// <summary>Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the descendant DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <param name="recursive" type="Boolean">
-        ///     True if the search should include all the descendants of the DOM node.
-        ///     False if the search should be scoped only to the direct children of the DOM node.
-        /// </param>
-        /// <returns>The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        var firstElement = null;
-        xmlTraverse(domNode, recursive, function (child) {
-            if (child.nodeType === 1) {
-                var isExpectedNamespace = !namespaceURI || xmlNamespaceURI(child) === namespaceURI;
-                var isExpectedNodeName = !localName || xmlLocalName(child) === localName;
-
-                if (isExpectedNamespace && isExpectedNodeName) {
-                    firstElement = child;
-                }
-            }
-            return firstElement === null;
-        });
-        return firstElement;
-    };
-
-    var xmlInnerText = function (xmlElement) {
-        /// <summary>Gets the concatenated value of all immediate child text and CDATA nodes for the specified element.</summary>
-        /// <param name="domElement">Element to get values for.</param>
-        /// <returns type="String">Text for all direct children.</returns>
-
-        var result = null;
-        var root = (xmlElement.nodeType === 9 && xmlElement.documentElement) ? xmlElement.documentElement : xmlElement;
-        var whitespaceAlreadyRemoved = root.ownerDocument.preserveWhiteSpace === false;
-        var whitespacePreserveContext;
-
-        xmlTraverse(root, false, function (child) {
-            if (child.nodeType === 3 || child.nodeType === 4) {
-                // isElementContentWhitespace indicates that this is 'ignorable whitespace',
-                // but it's not defined by all browsers, and does not honor xml:space='preserve'
-                // in some implementations.
-                //
-                // If we can't tell either way, we walk up the tree to figure out whether
-                // xml:space is set to preserve; otherwise we discard pure-whitespace.
-                //
-                // For example <a>  <b>1</b></a>. The space between <a> and <b> is usually 'ignorable'.
-                var text = xmlNodeValue(child);
-                var shouldInclude = whitespaceAlreadyRemoved || !isWhitespace(text);
-                if (!shouldInclude) {
-                    // Walk up the tree to figure out whether we are in xml:space='preserve' context
-                    // for the cursor (needs to happen only once).
-                    if (whitespacePreserveContext === undefined) {
-                        whitespacePreserveContext = isWhitespacePreserveContext(root);
-                    }
-
-                    shouldInclude = whitespacePreserveContext;
-                }
-
-                if (shouldInclude) {
-                    if (!result) {
-                        result = text;
-                    } else {
-                        result += text;
-                    }
-                }
-            }
-            // Continue traversing?
-            return true;
-        });
-        return result;
-    };
-
-    var xmlLocalName = function (domNode) {
-        /// <summary>Returns the localName of a XML node.</summary>
-        /// <param name="domNode">DOM node to get the value from.</param>
-        /// <returns type="String">localName of domNode.</returns>
-
-        return domNode.localName || domNode.baseName;
-    };
-
-    var xmlNamespaceURI = function (domNode) {
-        /// <summary>Returns the namespace URI of a XML node.</summary>
-        /// <param name="node">DOM node to get the value from.</param>
-        /// <returns type="String">Namespace URI of domNode.</returns>
-
-        return domNode.namespaceURI || null;
-    };
-
-    var xmlNodeValue = function (domNode) {
-        /// <summary>Returns the value or the inner text of a XML node.</summary>
-        /// <param name="node">DOM node to get the value from.</param>
-        /// <returns>Value of the domNode or the inner text if domNode represents a DOM element node.</returns>
-        
-        if (domNode.nodeType === 1) {
-            return xmlInnerText(domNode);
-        }
-        return domNode.nodeValue;
-    };
-
-    var xmlTraverse = function (domNode, recursive, onChildCallback) {
-        /// <summary>Walks through the descendants of the domNode and invokes a callback for each node.</summary>
-        /// <param name="domNode">DOM node whose descendants are going to be traversed.</param>
-        /// <param name="recursive" type="Boolean">
-        ///    True if the traversal should include all the descenants of the DOM node.
-        ///    False if the traversal should be scoped only to the direct children of the DOM node.
-        /// </param>
-        /// <returns type="String">Namespace URI of node.</returns>
-
-        var subtrees = [];
-        var child = domNode.firstChild;
-        var proceed = true;
-        while (child && proceed) {
-            proceed = onChildCallback(child);
-            if (proceed) {
-                if (recursive && child.firstChild) {
-                    subtrees.push(child.firstChild);
-                }
-                child = child.nextSibling || subtrees.shift();
-            }
-        }
-    };
-
-    var xmlSiblingElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the next sibling DOM element of the specified DOM node.</summary>
-        /// <param name="domNode">DOM node from which the next sibling is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's next sibling DOM element, null if there is none.</returns>
-
-        var sibling = domNode.nextSibling;
-        while (sibling) {
-            if (sibling.nodeType === 1) {
-                var isExpectedNamespace = !namespaceURI || xmlNamespaceURI(sibling) === namespaceURI;
-                var isExpectedNodeName = !localName || xmlLocalName(sibling) === localName;
-
-                if (isExpectedNamespace && isExpectedNodeName) {
-                    return sibling;
-                }
-            }
-            sibling = sibling.nextSibling;
-        }
-        return null;
-    };
-
-    var xmlDom = function () {
-        /// <summary>Creates a new empty DOM document node.</summary>
-        /// <returns>New DOM document node.</returns>
-        /// <remarks>
-        ///    This function will first try to create a native DOM document using
-        ///    the browsers createDocument function.  If the browser doesn't
-        ///    support this but supports ActiveXObject, then an attempt to create
-        ///    an MSXML 6.0 DOM will be made. If this attempt fails too, then an attempt
-        ///    for creating an MXSML 3.0 DOM will be made.  If this last attemp fails or
-        ///    the browser doesn't support ActiveXObject then an exception will be thrown.
-        /// </remarks>
-
-        var implementation = window.document.implementation;
-        return (implementation && implementation.createDocument) ?
-           implementation.createDocument(null, null, null) :
-           msXmlDom();
-    };
-
-    var xmlAppendChildren = function (parent, children) {
-        /// <summary>Appends a collection of child nodes or string values to a parent DOM node.</summary>
-        /// <param name="parent">DOM node to which the children will be appended.</param>
-        /// <param name="children" type="Array">Array containing DOM nodes or string values that will be appended to the parent.</param>
-        /// <returns>The parent with the appended children or string values.</returns>
-        /// <remarks>
-        ///    If a value in the children collection is a string, then a new DOM text node is going to be created
-        ///    for it and then appended to the parent.
-        /// </remarks>
-
-        if (!isArray(children)) {
-            return xmlAppendChild(parent, children);
-        }
-
-        var i, len;
-        for (i = 0, len = children.length; i < len; i++) {
-            children[i] && xmlAppendChild(parent, children[i]);
-        }
-        return parent;
-    };
-
-    var xmlAppendChild = function (parent, child) {
-        /// <summary>Appends a child node or a string value to a parent DOM node.</summary>
-        /// <param name="parent">DOM node to which the child will be appended.</param>
-        /// <param name="child">Child DOM node or string value to append to the parent.</param>
-        /// <returns>The parent with the appended child or string value.</returns>
-        /// <remarks>
-        ///    If child is a string value, then a new DOM text node is going to be created
-        ///    for it and then appended to the parent.
-        /// </remarks>
-
-        if (child) {
-            if (typeof child === "string") {
-                return xmlAppendText(parent, xmlNewText(parent.ownerDocument, child));
-            }
-            if (child.nodeType === 2) {
-                parent.setAttributeNodeNS ? parent.setAttributeNodeNS(child) : parent.setAttributeNode(child);
-            } else {
-                parent.appendChild(child);
-            }
-        }
-        return parent;
-    };
-
-    var xmlNewAttribute = function (dom, namespaceURI, qualifiedName, value) {
-        /// <summary>Creates a new DOM attribute node.</summary>
-        /// <param name="dom">DOM document used to create the attribute.</param>
-        /// <param name="prefix" type="String">Namespace prefix.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI.</param>
-        /// <returns>DOM attribute node for the namespace declaration.</returns>
-
-        var attribute =
-            dom.createAttributeNS && dom.createAttributeNS(namespaceURI, qualifiedName) ||
-            dom.createNode(2, qualifiedName, namespaceURI || undefined);
-
-        attribute.value = value || "";
-        return attribute;
-    };
-
-    var xmlNewElement = function (dom, nampespaceURI, qualifiedName, children) {
-        /// <summary>Creates a new DOM element node.</summary>
-        /// <param name="dom">DOM document used to create the DOM element.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI of the new DOM element.</param>
-        /// <param name="qualifiedName" type="String">Qualified name in the form of "prefix:name" of the new DOM element.</param>
-        /// <param name="children" type="Array" optional="true">
-        ///     Collection of child DOM nodes or string values that are going to be appended to the new DOM element.
-        /// </param>
-        /// <returns>New DOM element.</returns>
-        /// <remarks>
-        ///    If a value in the children collection is a string, then a new DOM text node is going to be created
-        ///    for it and then appended to the new DOM element.
-        /// </remarks>
-
-        var element =
-            dom.createElementNS && dom.createElementNS(nampespaceURI, qualifiedName) ||
-            dom.createNode(1, qualifiedName, nampespaceURI || undefined);
-
-        return xmlAppendChildren(element, children || []);
-    };
-
-    var xmlNewNSDeclaration = function (dom, namespaceURI, prefix) {
-        /// <summary>Creates a namespace declaration attribute.</summary>
-        /// <param name="dom">DOM document used to create the attribute.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI.</param>
-        /// <param name="prefix" type="String">Namespace prefix.</param>
-        /// <returns>DOM attribute node for the namespace declaration.</returns>
-
-        return xmlNewAttribute(dom, xmlnsNS, xmlQualifiedName("xmlns", prefix), namespaceURI);
-    };
-
-    var xmlNewFragment = function (dom, text) {
-        /// <summary>Creates a new DOM document fragment node for the specified xml text.</summary>
-        /// <param name="dom">DOM document from which the fragment node is going to be created.</param>
-        /// <param name="text" type="String" mayBeNull="false">XML text to be represented by the XmlFragment.</param>
-        /// <returns>New DOM document fragment object.</returns>
-
-        var value = "<c>" + text + "</c>";
-        var tempDom = xmlParse(value);
-        var tempRoot = tempDom.documentElement;
-        var imported = ("importNode" in dom) ? dom.importNode(tempRoot, true) : tempRoot;
-        var fragment = dom.createDocumentFragment();
-
-        var importedChild = imported.firstChild;
-        while (importedChild) {
-            fragment.appendChild(importedChild);
-            importedChild = importedChild.nextSibling;
-        }
-        return fragment;
-    };
-
-    var xmlNewText = function (dom, text) {
-        /// <summary>Creates new DOM text node.</summary>
-        /// <param name="dom">DOM document used to create the text node.</param>
-        /// <param name="text" type="String">Text value for the DOM text node.</param>
-        /// <returns>DOM text node.</returns>
-
-        return dom.createTextNode(text);
-    };
-
-    var xmlNewNodeByPath = function (dom, root, namespaceURI, prefix, path) {
-        /// <summary>Creates a new DOM element or DOM attribute node as specified by path and appends it to the DOM tree pointed by root.</summary>
-        /// <param name="dom">DOM document used to create the new node.</param>
-        /// <param name="root">DOM element node used as root of the subtree on which the new nodes are going to be created.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI of the new DOM element or attribute.</param>
-        /// <param name="namespacePrefix" type="String">Prefix used to qualify the name of the new DOM element or attribute.</param>
-        /// <param name="Path" type="String">Path string describing the location of the new DOM element or attribute from the root element.</param>
-        /// <returns>DOM element or attribute node for the last segment of the path.</returns>
-        /// <remarks>
-        ///     This function will traverse the path and will create a new DOM element with the specified namespace URI and prefix
-        ///     for each segment that doesn't have a matching element under root.
-        ///
-        ///     The last segment of the path may be decorated with a starting @ character. In this case a new DOM attribute node
-        ///     will be created.
-        /// </remarks>
-
-        var name = "";
-        var parts = path.split("/");
-        var xmlFindNode = xmlFirstChildElement;
-        var xmlNewNode = xmlNewElement;
-        var xmlNode = root;
-
-        var i, len;
-        for (i = 0, len = parts.length; i < len; i++) {
-            name = parts[i];
-            if (name.charAt(0) === "@") {
-                name = name.substring(1);
-                xmlFindNode = xmlAttributeNode;
-                xmlNewNode = xmlNewAttribute;
-            }
-
-            var childNode = xmlFindNode(xmlNode, namespaceURI, name);
-            if (!childNode) {
-                childNode = xmlNewNode(dom, namespaceURI, xmlQualifiedName(prefix, name));
-                xmlAppendChild(xmlNode, childNode);
-            }
-            xmlNode = childNode;
-        }
-        return xmlNode;
-    };
-
-    var xmlSerialize = function (domNode) {
-        /// <summary>
-        /// Returns the text representation of the document to which the specified node belongs.
-        /// </summary>
-        /// <param name="root">Wrapped element in the document to serialize.</param>
-        /// <returns type="String">Serialized document.</returns>
-
-        var xmlSerializer = window.XMLSerializer;
-        if (xmlSerializer) {
-            var serializer = new xmlSerializer();
-            return serializer.serializeToString(domNode);
-        }
-
-        if (domNode.xml) {
-            return domNode.xml;
-        }
-
-        throw { message: "XML serialization unsupported" };
-    };
-
-    var xmlSerializeDescendants = function (domNode) {
-        /// <summary>Returns the XML representation of the all the descendants of the node.</summary>
-        /// <param name="domNode" optional="false" mayBeNull="false">Node to serialize.</param>
-        /// <returns type="String">The XML representation of all the descendants of the node.</returns>
-
-        var children = domNode.childNodes;
-        var i, len = children.length;
-        if (len === 0) {
-            return "";
-        }
-
-        // Some implementations of the XMLSerializer don't deal very well with fragments that
-        // don't have a DOMElement as their first child. The work around is to wrap all the
-        // nodes in a dummy root node named "c", serialize it and then just extract the text between
-        // the <c> and the </c> substrings.
-
-        var dom = domNode.ownerDocument;
-        var fragment = dom.createDocumentFragment();
-        var fragmentRoot = dom.createElement("c");
-
-        fragment.appendChild(fragmentRoot);
-        // Move the children to the fragment tree.
-        for (i = 0; i < len; i++) {
-            fragmentRoot.appendChild(children[i]);
-        }
-
-        var xml = xmlSerialize(fragment);
-        xml = xml.substr(3, xml.length - 7);
-
-        // Move the children back to the original dom tree.
-        for (i = 0; i < len; i++) {
-            domNode.appendChild(fragmentRoot.childNodes[i]);
-        }
-
-        return xml;
-    };
-
-    var xmlSerializeNode = function (domNode) {
-        /// <summary>Returns the XML representation of the node and all its descendants.</summary>
-        /// <param name="domNode" optional="false" mayBeNull="false">Node to serialize.</param>
-        /// <returns type="String">The XML representation of the node and all its descendants.</returns>
-
-        var xml = domNode.xml;
-        if (xml !== undefined) {
-            return xml;
-        }
-
-        if (window.XMLSerializer) {
-            var serializer = new window.XMLSerializer();
-            return serializer.serializeToString(domNode);
-        }
-
-        throw { message: "XML serialization unsupported" };
-    };
-
-
-
-
-    var forwardCall = function (thisValue, name, returnValue) {
-        /// <summary>Creates a new function to forward a call.</summary>
-        /// <param name="thisValue" type="Object">Value to use as the 'this' object.</param>
-        /// <param name="name" type="String">Name of function to forward to.</param>
-        /// <param name="returnValue" type="Object">Return value for the forward call (helps keep identity when chaining calls).</param>
-        /// <returns type="Function">A new function that will forward a call.</returns>
-
-        return function () {
-            thisValue[name].apply(thisValue, arguments);
-            return returnValue;
-        };
-    };
-
-    var DjsDeferred = function () {
-        /// <summary>Initializes a new DjsDeferred object.</summary>
-        /// <remarks>
-        /// Compability Note A - Ordering of callbacks through chained 'then' invocations
-        ///
-        /// The Wiki entry at http://wiki.commonjs.org/wiki/Promises/A
-        /// implies that .then() returns a distinct object.
-        ////
-        /// For compatibility with http://api.jquery.com/category/deferred-object/
-        /// we return this same object. This affects ordering, as
-        /// the jQuery version will fire callbacks in registration
-        /// order regardless of whether they occur on the result
-        /// or the original object.
-        ///
-        /// Compability Note B - Fulfillment value
-        ///
-        /// The Wiki entry at http://wiki.commonjs.org/wiki/Promises/A
-        /// implies that the result of a success callback is the
-        /// fulfillment value of the object and is received by
-        /// other success callbacks that are chained.
-        ///
-        /// For compatibility with http://api.jquery.com/category/deferred-object/
-        /// we disregard this value instead.
-        /// </remarks>
-
-        this._arguments = undefined;
-        this._done = undefined;
-        this._fail = undefined;
-        this._resolved = false;
-        this._rejected = false;
-    };
-
-    DjsDeferred.prototype = {
-        then: function (fulfilledHandler, errorHandler /*, progressHandler */) {
-            /// <summary>Adds success and error callbacks for this deferred object.</summary>
-            /// <param name="fulfilledHandler" type="Function" mayBeNull="true" optional="true">Success callback.</param>
-            /// <param name="errorHandler" type="Function" mayBeNull="true" optional="true">Error callback.</param>
-            /// <remarks>See Compatibility Note A.</remarks>
-
-            if (fulfilledHandler) {
-                if (!this._done) {
-                    this._done = [fulfilledHandler];
-                } else {
-                    this._done.push(fulfilledHandler);
-                }
-            }
-
-            if (errorHandler) {
-                if (!this._fail) {
-                    this._fail = [errorHandler];
-                } else {
-                    this._fail.push(errorHandler);
-                }
-            }
-
-            //// See Compatibility Note A in the DjsDeferred constructor.
-            //// if (!this._next) {
-            ////    this._next = createDeferred();
-            //// }
-            //// return this._next.promise();
-
-            if (this._resolved) {
-                this.resolve.apply(this, this._arguments);
-            } else if (this._rejected) {
-                this.reject.apply(this, this._arguments);
-            }
-
-            return this;
-        },
-
-        resolve: function (/* args */) {
-            /// <summary>Invokes success callbacks for this deferred object.</summary>
-            /// <remarks>All arguments are forwarded to success callbacks.</remarks>
-
-
-            if (this._done) {
-                var i, len;
-                for (i = 0, len = this._done.length; i < len; i++) {
-                    //// See Compability Note B - Fulfillment value.
-                    //// var nextValue =
-                    this._done[i].apply(null, arguments);
-                }
-
-                //// See Compatibility Note A in the DjsDeferred constructor.
-                //// this._next.resolve(nextValue);
-                //// delete this._next;
-
-                this._done = undefined;
-                this._resolved = false;
-                this._arguments = undefined;
-            } else {
-                this._resolved = true;
-                this._arguments = arguments;
-            }
-        },
-
-        reject: function (/* args */) {
-            /// <summary>Invokes error callbacks for this deferred object.</summary>
-            /// <remarks>All arguments are forwarded to error callbacks.</remarks>
-            if (this._fail) {
-                var i, len;
-                for (i = 0, len = this._fail.length; i < len; i++) {
-                    this._fail[i].apply(null, arguments);
-                }
-
-                this._fail = undefined;
-                this._rejected = false;
-                this._arguments = undefined;
-            } else {
-                this._rejected = true;
-                this._arguments = arguments;
-            }
-        },
-
-        promise: function () {
-            /// <summary>Returns a version of this object that has only the read-only methods available.</summary>
-            /// <returns>An object with only the promise object.</returns>
-
-            var result = {};
-            result.then = forwardCall(this, "then", result);
-            return result;
-        }
-    };
-
-    var createDeferred = function () {
-        /// <summary>Creates a deferred object.</summary>
-        /// <returns type="DjsDeferred">
-        /// A new deferred object. If jQuery is installed, then a jQuery
-        /// Deferred object is returned, which provides a superset of features.
-        /// </returns>
-
-        if (window.jQuery && window.jQuery.Deferred) {
-            return new window.jQuery.Deferred();
-        } else {
-            return new DjsDeferred();
-        }
-    };
-
-
-
-
-    var dataItemTypeName = function (value, metadata) {
-        /// <summary>Gets the type name of a data item value that belongs to a feed, an entry, a complex type property, or a collection property.</summary>
-        /// <param name="value">Value of the data item from which the type name is going to be retrieved.</param>
-        /// <param name="metadata" type="object" optional="true">Object containing metadata about the data tiem.</param>
-        /// <remarks>
-        ///    This function will first try to get the type name from the data item's value itself if it is an object with a __metadata property; otherwise
-        ///    it will try to recover it from the metadata.  If both attempts fail, it will return null.
-        /// </remarks>
-        /// <returns type="String">Data item type name; null if the type name cannot be found within the value or the metadata</returns>
-
-        var valueTypeName = ((value && value.__metadata) || {}).type;
-        return valueTypeName || (metadata ? metadata.type : null);
-    };
-
-    var EDM = "Edm.";
-    var EDM_BINARY = EDM + "Binary";
-    var EDM_BOOLEAN = EDM + "Boolean";
-    var EDM_BYTE = EDM + "Byte";
-    var EDM_DATETIME = EDM + "DateTime";
-    var EDM_DATETIMEOFFSET = EDM + "DateTimeOffset";
-    var EDM_DECIMAL = EDM + "Decimal";
-    var EDM_DOUBLE = EDM + "Double";
-    var EDM_GUID = EDM + "Guid";
-    var EDM_INT16 = EDM + "Int16";
-    var EDM_INT32 = EDM + "Int32";
-    var EDM_INT64 = EDM + "Int64";
-    var EDM_SBYTE = EDM + "SByte";
-    var EDM_SINGLE = EDM + "Single";
-    var EDM_STRING = EDM + "String";
-    var EDM_TIME = EDM + "Time";
-
-    var EDM_GEOGRAPHY = EDM + "Geography";
-    var EDM_GEOGRAPHY_POINT = EDM_GEOGRAPHY + "Point";
-    var EDM_GEOGRAPHY_LINESTRING = EDM_GEOGRAPHY + "LineString";
-    var EDM_GEOGRAPHY_POLYGON = EDM_GEOGRAPHY + "Polygon";
-    var EDM_GEOGRAPHY_COLLECTION = EDM_GEOGRAPHY + "Collection";
-    var EDM_GEOGRAPHY_MULTIPOLYGON = EDM_GEOGRAPHY + "MultiPolygon";
-    var EDM_GEOGRAPHY_MULTILINESTRING = EDM_GEOGRAPHY + "MultiLineString";
-    var EDM_GEOGRAPHY_MULTIPOINT = EDM_GEOGRAPHY + "MultiPoint";
-
-    var EDM_GEOMETRY = EDM + "Geometry";
-    var EDM_GEOMETRY_POINT = EDM_GEOMETRY + "Point";
-    var EDM_GEOMETRY_LINESTRING = EDM_GEOMETRY + "LineString";
-    var EDM_GEOMETRY_POLYGON = EDM_GEOMETRY + "Polygon";
-    var EDM_GEOMETRY_COLLECTION = EDM_GEOMETRY + "Collection";
-    var EDM_GEOMETRY_MULTIPOLYGON = EDM_GEOMETRY + "MultiPolygon";
-    var EDM_GEOMETRY_MULTILINESTRING = EDM_GEOMETRY + "MultiLineString";
-    var EDM_GEOMETRY_MULTIPOINT = EDM_GEOMETRY + "MultiPoint";
-
-    var GEOJSON_POINT = "Point";
-    var GEOJSON_LINESTRING = "LineString";
-    var GEOJSON_POLYGON = "Polygon";
-    var GEOJSON_MULTIPOINT = "MultiPoint";
-    var GEOJSON_MULTILINESTRING = "MultiLineString";
-    var GEOJSON_MULTIPOLYGON = "MultiPolygon";
-    var GEOJSON_GEOMETRYCOLLECTION = "GeometryCollection";
-
-    var primitiveEdmTypes = [
-        EDM_STRING,
-        EDM_INT32,
-        EDM_INT64,
-        EDM_BOOLEAN,
-        EDM_DOUBLE,
-        EDM_SINGLE,
-        EDM_DATETIME,
-        EDM_DATETIMEOFFSET,
-        EDM_TIME,
-        EDM_DECIMAL,
-        EDM_GUID,
-        EDM_BYTE,
-        EDM_INT16,
-        EDM_SBYTE,
-        EDM_BINARY
-    ];
-
-    var geometryEdmTypes = [
-        EDM_GEOMETRY,
-        EDM_GEOMETRY_POINT,
-        EDM_GEOMETRY_LINESTRING,
-        EDM_GEOMETRY_POLYGON,
-        EDM_GEOMETRY_COLLECTION,
-        EDM_GEOMETRY_MULTIPOLYGON,
-        EDM_GEOMETRY_MULTILINESTRING,
-        EDM_GEOMETRY_MULTIPOINT
-    ];
-
-    var geographyEdmTypes = [
-        EDM_GEOGRAPHY,
-        EDM_GEOGRAPHY_POINT,
-        EDM_GEOGRAPHY_LINESTRING,
-        EDM_GEOGRAPHY_POLYGON,
-        EDM_GEOGRAPHY_COLLECTION,
-        EDM_GEOGRAPHY_MULTIPOLYGON,
-        EDM_GEOGRAPHY_MULTILINESTRING,
-        EDM_GEOGRAPHY_MULTIPOINT
-    ];
-
-    var forEachSchema = function (metadata, callback) {
-        /// <summary>Invokes a function once per schema in metadata.</summary>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <param name="callback" type="Function">Callback function to invoke once per schema.</param>
-        /// <returns>
-        /// The first truthy value to be returned from the callback; null or the last falsy value otherwise.
-        /// </returns>
-
-        if (!metadata) {
-            return null;
-        }
-
-        if (isArray(metadata)) {
-            var i, len, result;
-            for (i = 0, len = metadata.length; i < len; i++) {
-                result = forEachSchema(metadata[i], callback);
-                if (result) {
-                    return result;
-                }
-            }
-
-            return null;
-        } else {
-            if (metadata.dataServices) {
-                return forEachSchema(metadata.dataServices.schema, callback);
-            }
-
-            return callback(metadata);
-        }
-    };
-
-    var formatMilliseconds = function (ms, ns) {
-        /// <summary>Formats a millisecond and a nanosecond value into a single string.</summary>
-        /// <param name="ms" type="Number" mayBeNull="false">Number of milliseconds to format.</param>
-        /// <param name="ns" type="Number" mayBeNull="false">Number of nanoseconds to format.</param>
-        /// <returns type="String">Formatted text.</returns>
-        /// <remarks>If the value is already as string it's returned as-is.</remarks>
-
-        // Avoid generating milliseconds if not necessary.
-        if (ms === 0) {
-            ms = "";
-        } else {
-            ms = "." + formatNumberWidth(ms.toString(), 3);
-        }
-        if (ns > 0) {
-            if (ms === "") {
-                ms = ".000";
-            }
-            ms += formatNumberWidth(ns.toString(), 4);
-        }
-        return ms;
-    };
-
-    var formatDateTimeOffset = function (value) {
-        /// <summary>Formats a DateTime or DateTimeOffset value a string.</summary>
-        /// <param name="value" type="Date" mayBeNull="false">Value to format.</param>
-        /// <returns type="String">Formatted text.</returns>
-        /// <remarks>If the value is already as string it's returned as-is.</remarks>
-
-        if (typeof value === "string") {
-            return value;
-        }
-
-        var hasOffset = isDateTimeOffset(value);
-        var offset = getCanonicalTimezone(value.__offset);
-        if (hasOffset && offset !== "Z") {
-            // We're about to change the value, so make a copy.
-            value = new Date(value.valueOf());
-
-            var timezone = parseTimezone(offset);
-            var hours = value.getUTCHours() + (timezone.d * timezone.h);
-            var minutes = value.getUTCMinutes() + (timezone.d * timezone.m);
-
-            value.setUTCHours(hours, minutes);
-        } else if (!hasOffset) {
-            // Don't suffix a 'Z' for Edm.DateTime values.
-            offset = "";
-        }
-
-        var year = value.getUTCFullYear();
-        var month = value.getUTCMonth() + 1;
-        var sign = "";
-        if (year <= 0) {
-            year = -(year - 1);
-            sign = "-";
-        }
-
-        var ms = formatMilliseconds(value.getUTCMilliseconds(), value.__ns);
-
-        return sign +
-            formatNumberWidth(year, 4) + "-" +
-            formatNumberWidth(month, 2) + "-" +
-            formatNumberWidth(value.getUTCDate(), 2) + "T" +
-            formatNumberWidth(value.getUTCHours(), 2) + ":" +
-            formatNumberWidth(value.getUTCMinutes(), 2) + ":" +
-            formatNumberWidth(value.getUTCSeconds(), 2) +
-            ms + offset;
-    };
-
-    var formatDuration = function (value) {
-        /// <summary>Converts a duration to a string in xsd:duration format.</summary>
-        /// <param name="value" type="Object">Object with ms and __edmType properties.</param>
-        /// <returns type="String">String representation of the time object in xsd:duration format.</returns>
-
-        var ms = value.ms;
-
-        var sign = "";
-        if (ms < 0) {
-            sign = "-";
-            ms = -ms;
-        }
-
-        var days = Math.floor(ms / 86400000);
-        ms -= 86400000 * days;
-        var hours = Math.floor(ms / 3600000);
-        ms -= 3600000 * hours;
-        var minutes = Math.floor(ms / 60000);
-        ms -= 60000 * minutes;
-        var seconds = Math.floor(ms / 1000);
-        ms -= seconds * 1000;
-
-        return sign + "P" +
-               formatNumberWidth(days, 2) + "DT" +
-               formatNumberWidth(hours, 2) + "H" +
-               formatNumberWidth(minutes, 2) + "M" +
-               formatNumberWidth(seconds, 2) +
-               formatMilliseconds(ms, value.ns) + "S";
-    };
-
-    var formatNumberWidth = function (value, width, append) {
-        /// <summary>Formats the specified value to the given width.</summary>
-        /// <param name="value" type="Number">Number to format (non-negative).</param>
-        /// <param name="width" type="Number">Minimum width for number.</param>
-        /// <param name="append" type="Boolean">Flag indicating if the value is padded at the beginning (false) or at the end (true).</param>
-        /// <returns type="String">Text representation.</returns>
-        var result = value.toString(10);
-        while (result.length < width) {
-            if (append) {
-                result += "0";
-            } else {
-                result = "0" + result;
-            }
-        }
-
-        return result;
-    };
-
-    var getCanonicalTimezone = function (timezone) {
-        /// <summary>Gets the canonical timezone representation.</summary>
-        /// <param name="timezone" type="String">Timezone representation.</param>
-        /// <returns type="String">An 'Z' string if the timezone is absent or 0; the timezone otherwise.</returns>
-
-        return (!timezone || timezone === "Z" || timezone === "+00:00" || timezone === "-00:00") ? "Z" : timezone;
-    };
-
-    var getCollectionType = function (typeName) {
-        /// <summary>Gets the type of a collection type name.</summary>
-        /// <param name="typeName" type="String">Type name of the collection.</param>
-        /// <returns type="String">Type of the collection; null if the type name is not a collection type.</returns>
-
-        if (typeof typeName === "string") {
-            var end = typeName.indexOf(")", 10);
-            if (typeName.indexOf("Collection(") === 0 && end > 0) {
-                return typeName.substring(11, end);
-            }
-        }
-        return null;
-    };
-
-    var invokeRequest = function (request, success, error, handler, httpClient, context) {
-        /// <summary>Sends a request containing OData payload to a server.</summary>
-        /// <param name="request">Object that represents the request to be sent..</param>
-        /// <param name="success">Callback for a successful read operation.</param>
-        /// <param name="error">Callback for handling errors.</param>
-        /// <param name="handler">Handler for data serialization.</param>
-        /// <param name="httpClient">HTTP client layer.</param>
-        /// <param name="context">Context used for processing the request</param>
-
-        return httpClient.request(request, function (response) {
-            try {
-                if (response.headers) {
-                    normalizeHeaders(response.headers);
-                }
-
-                if (response.data === undefined && response.statusCode !== 204) {
-                    handler.read(response, context);
-                }
-            } catch (err) {
-                if (err.request === undefined) {
-                    err.request = request;
-                }
-                if (err.response === undefined) {
-                    err.response = response;
-                }
-                error(err);
-                return;
-            }
-
-            success(response.data, response);
-        }, error);
-    };
-
-    var isBatch = function (value) {
-        /// <summary>Tests whether a value is a batch object in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a batch object; false otherwise.</returns>
-
-        return isComplex(value) && isArray(value.__batchRequests);
-    };
-
-    // Regular expression used for testing and parsing for a collection type.
-    var collectionTypeRE = /Collection\((.*)\)/;
-
-    var isCollection = function (value, typeName) {
-        /// <summary>Tests whether a value is a collection value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <param name="typeName" type="Sting">Type name of the value. This is used to disambiguate from a collection property value.</param>
-        /// <returns type="Boolean">True is the value is a feed value; false otherwise.</returns>
-
-        var colData = value && value.results || value;
-        return !!colData &&
-            (isCollectionType(typeName)) ||
-            (!typeName && isArray(colData) && !isComplex(colData[0]));
-    };
-
-    var isCollectionType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a collection type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is the name of a collection type; false otherwise.</returns>
-        return collectionTypeRE.test(typeName);
-    };
-
-    var isComplex = function (value) {
-        /// <summary>Tests whether a value is a complex type value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a complex type value; false otherwise.</returns>
-
-        return !!value &&
-            isObject(value) &&
-            !isArray(value) &&
-            !isDate(value);
-    };
-
-    var isDateTimeOffset = function (value) {
-        /// <summary>Checks whether a Date object is DateTimeOffset value</summary>
-        /// <param name="value" type="Date" mayBeNull="false">Value to check.</param>
-        /// <returns type="Boolean">true if the value is a DateTimeOffset, false otherwise.</returns>
-        return (value.__edmType === "Edm.DateTimeOffset" || (!value.__edmType && value.__offset));
-    };
-
-    var isDeferred = function (value) {
-        /// <summary>Tests whether a value is a deferred navigation property in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a deferred navigation property; false otherwise.</returns>
-
-        if (!value && !isComplex(value)) {
-            return false;
-        }
-        var metadata = value.__metadata || {};
-        var deferred = value.__deferred || {};
-        return !metadata.type && !!deferred.uri;
-    };
-
-    var isEntry = function (value) {
-        /// <summary>Tests whether a value is an entry object in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is an entry object; false otherwise.</returns>
-
-        return isComplex(value) && value.__metadata && "uri" in value.__metadata;
-    };
-
-    var isFeed = function (value, typeName) {
-        /// <summary>Tests whether a value is a feed value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <param name="typeName" type="Sting">Type name of the value. This is used to disambiguate from a collection property value.</param>
-        /// <returns type="Boolean">True is the value is a feed value; false otherwise.</returns>
-
-        var feedData = value && value.results || value;
-        return isArray(feedData) && (
-            (!isCollectionType(typeName)) &&
-            (isComplex(feedData[0]))
-        );
-    };
-
-    var isGeographyEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a geography EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a geography EDM type; false otherwise.</returns>
-
-        return contains(geographyEdmTypes, typeName);
-    };
-
-    var isGeometryEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a geometry EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a geometry EDM type; false otherwise.</returns>
-
-        return contains(geometryEdmTypes, typeName);
-    };
-
-    var isNamedStream = function (value) {
-        /// <summary>Tests whether a value is a named stream value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a named stream; false otherwise.</returns>
-
-        if (!value && !isComplex(value)) {
-            return false;
-        }
-        var metadata = value.__metadata;
-        var mediaResource = value.__mediaresource;
-        return !metadata && !!mediaResource && !!mediaResource.media_src;
-    };
-
-    var isPrimitive = function (value) {
-        /// <summary>Tests whether a value is a primitive type value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <remarks>
-        ///    Date objects are considered primitive types by the library.
-        /// </remarks>
-        /// <returns type="Boolean">True is the value is a primitive type value.</returns>
-
-        return isDate(value) ||
-            typeof value === "string" ||
-            typeof value === "number" ||
-            typeof value === "boolean";
-    };
-
-    var isPrimitiveEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a primitive EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a primitive EDM type; false otherwise.</returns>
-
-        return contains(primitiveEdmTypes, typeName);
-    };
-
-    var navigationPropertyKind = function (value, propertyModel) {
-        /// <summary>Gets the kind of a navigation property value.</summary>
-        /// <param name="value">Value of the navigation property.</param>
-        /// <param name="propertyModel" type="Object" optional="true">
-        ///     Object that describes the navigation property in an OData conceptual schema.
-        /// </param>
-        /// <remarks>
-        ///     The returned string is as follows
-        /// </remarks>
-        /// <returns type="String">String value describing the kind of the navigation property; null if the kind cannot be determined.</returns>
-
-        if (isDeferred(value)) {
-            return "deferred";
-        }
-        if (isEntry(value)) {
-            return "entry";
-        }
-        if (isFeed(value)) {
-            return "feed";
-        }
-        if (propertyModel && propertyModel.relationship) {
-            if (value === null || value === undefined || !isFeed(value)) {
-                return "entry";
-            }
-            return "feed";
-        }
-        return null;
-    };
-
-    var lookupProperty = function (properties, name) {
-        /// <summary>Looks up a property by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of property objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The property object; null if not found.</returns>
-
-        return find(properties, function (property) {
-            return property.name === name;
-        });
-    };
-
-    var lookupInMetadata = function (name, metadata, kind) {
-        /// <summary>Looks up a type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <param name="kind" type="String">Kind of object to look for as per EDM metadata.</param>
-        /// <returns>An type description if the name is found; null otherwise.</returns>
-
-        return (name) ? forEachSchema(metadata, function (schema) {
-            return lookupInSchema(name, schema, kind);
-        }) : null;
-    };
-
-    var lookupEntitySet = function (entitySets, name) {
-        /// <summary>Looks up a entity set by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of entity set objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The entity set object; null if not found.</returns>
-
-        return find(entitySets, function (entitySet) {
-            return entitySet.name === name;
-        });
-    };
-
-    var lookupComplexType = function (name, metadata) {
-        /// <summary>Looks up a complex type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>A complex type description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "complexType");
-    };
-
-    var lookupEntityType = function (name, metadata) {
-        /// <summary>Looks up an entity type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity type description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "entityType");
-    };
-
-    var lookupDefaultEntityContainer = function (metadata) {
-        /// <summary>Looks up an</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity container description if the name is found; null otherwise.</returns>
-
-        return forEachSchema(metadata, function (schema) {
-            return find(schema.entityContainer, function (container) {
-                return parseBool(container.isDefaultEntityContainer);
-            });
-        });
-    };
-
-    var lookupEntityContainer = function (name, metadata) {
-        /// <summary>Looks up an entity container object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity container description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "entityContainer");
-    };
-
-    var lookupFunctionImport = function (functionImports, name) {
-        /// <summary>Looks up a function import by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of function import objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The entity set object; null if not found.</returns>
-
-        return find(functionImports, function (functionImport) {
-            return functionImport.name === name;
-        });
-    };
-
-    var lookupNavigationPropertyType = function (navigationProperty, metadata) {
-        /// <summary>Looks up the target entity type for a navigation property.</summary>
-        /// <param name="navigationProperty" type="Object"></param>
-        /// <param name="metadata" type="Object"></param>
-        /// <returns type="String">The entity type name for the specified property, null if not found.</returns>
-
-        var result = null;
-        if (navigationProperty) {
-            var rel = navigationProperty.relationship;
-            var association = forEachSchema(metadata, function (schema) {
-                // The name should be the namespace qualified name in 'ns'.'type' format.
-                var nameOnly = removeNamespace(schema["namespace"], rel);
-                var associations = schema.association;
-                if (nameOnly && associations) {
-                    var i, len;
-                    for (i = 0, len = associations.length; i < len; i++) {
-                        if (associations[i].name === nameOnly) {
-                            return associations[i];
-                        }
-                    }
-                }
-                return null;
-            });
-
-            if (association) {
-                var end = association.end[0];
-                if (end.role !== navigationProperty.toRole) {
-                    end = association.end[1];
-                    // For metadata to be valid, end.role === navigationProperty.toRole now.
-                }
-                result = end.type;
-            }
-        }
-        return result;
-    };
-
-    var lookupNavigationPropertyEntitySet = function (navigationProperty, sourceEntitySetName, metadata) {
-        /// <summary>Looks up the target entityset name for a navigation property.</summary>
-        /// <param name="navigationProperty" type="Object"></param>
-        /// <param name="metadata" type="Object"></param>
-        /// <returns type="String">The entityset name for the specified property, null if not found.</returns>
-
-        if (navigationProperty) {
-            var rel = navigationProperty.relationship;
-            var associationSet = forEachSchema(metadata, function (schema) {
-                var containers = schema.en

<TRUNCATED>

[2/6] [OLINGO-429] add headers, extend rat module, remove dependencies

Posted by ko...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/scripts/datajs-1.1.2.min.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/datajs-1.1.2.min.js b/odatajs/demo/scripts/datajs-1.1.2.min.js
deleted file mode 100644
index 9b65217..0000000
--- a/odatajs/demo/scripts/datajs-1.1.2.min.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-(function(n,t){var yt=n.datajs||{},r=n.OData||{},lo,ao,ei,ay,rp;typeof define=="function"&&define.amd?(define("datajs",yt),define("OData",r)):(n.datajs=yt,n.OData=r),yt.version={major:1,minor:1,build:1};var ko=function(t){return n.ActiveXObject?new n.ActiveXObject(t):null},ot=function(n){return n!==null&&n!==t},er=function(n,t){for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return!0;return!1},it=function(n,i){return n!==t?n:i},o=function(t){if(arguments.length===1){n.setTimeout(t,0);return}var i=Array.prototype.slice.call(arguments,1);n.setTimeout(function(){t.apply(this,i)},0)},g=function(n,t){for(var i in t)n[i]=t[i];return n},or=function(n,t){if(n)for(var i=0,r=n.length;i<r;i++)if(t(n[i]))return n[i];return null},e=function(n){return Object.prototype.toString.call(n)==="[object Array]"},lf=function(n){return Object.prototype.toString.call(n)==="[object Date]"},af=function(n){return typeof n=="object"},s=function(n){return parseInt(n,10)},ru=function(n,t,i){n.hasOwnProperty(t)&&(n[
 i]=n[t],delete n[t])},uu=function(n){throw n;},go=function(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")},vf=function(n,i){return n!==t?n:i},up=/^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#:]+)?(\?[^#]*)?(#.*)?/,ns=["scheme","authority","path","query","fragment"],yf=function(n){var i={isAbsolute:!1},r,t,u;if(n){if(r=up.exec(n),r)for(t=0,u=ns.length;t<u;t++)r[t+1]&&(i[ns[t]]=r[t+1]);i.scheme&&(i.isAbsolute=!0)}return i},ts=function(n){return"".concat(n.scheme||"",n.authority||"",n.path||"",n.query||"",n.fragment||"")},fp=/^\/{0,2}(?:([^@]*)@)?([^:]+)(?::{1}(\d+))?/,ep=/%[0-9A-F]{2}/ig,op=function(n){var i=yf(n),r=i.scheme,u=i.authority,t;return r&&(i.scheme=r.toLowerCase(),u&&(t=fp.exec(u),t&&(i.authority="//"+(t[1]?t[1]+"@":"")+t[2].toLowerCase()+(t[3]?":"+t[3]:"")))),n=ts(i),n.replace(ep,function(n){return n.toLowerCase()})},c=function(n,t){var i,u,r,f;return t?(i=yf(n),i.isAbsolute)?n:(u=yf(t),r={},i.authority?(r.authority=i.authority,f=i.path,r.query=i.query):(i.path?(f=i.path.charA
 t(0)==="/"?i.path:sp(i.path,u.path),r.query=i.query):(f=u.path,r.query=i.query||u.query),r.authority=u.authority),r.path=hp(f),r.scheme=u.scheme,r.fragment=i.fragment,ts(r)):n},sp=function(n,t){var i="/",r;return t&&(r=t.lastIndexOf("/"),i=t.substring(0,r),i.charAt(i.length-1)!=="/"&&(i=i+"/")),i+n},hp=function(n){for(var t="",r="",i;n;)n.indexOf("..")===0||n.indexOf(".")===0?n=n.replace(/^\.\.?\/?/g,""):n.indexOf("/..")===0?(n=n.replace(/^\/\..\/?/g,"/"),i=t.lastIndexOf("/"),t=i===-1?"":t.substring(0,i)):n.indexOf("/.")===0?n=n.replace(/^\/\.\/?/g,"/"):(r=n,i=n.indexOf("/",1),i!==-1&&(r=n.substring(0,i)),t=t+r,n=n.replace(r,""));return t},cp=function(i){var r=[],o,u,f,s,e,h;if(n.atob===t)r=lp(i);else for(o=n.atob(i),u=0;u<o.length;u++)r.push(o.charCodeAt(u));for(f="",s="0123456789ABCDEF",e=0;e<r.length;e++)h=r[e],f+=s[h>>4],f+=s[h&15];return f},lp=function(n){for(var i="",r,u,f,e,o,t=0;t<n.length;t++)r=ap(n[t]),u="",r!==null&&(u=r.toString(2),i+=vp(u));for(f=[],e=parseInt(i.length/
 8,10),t=0;t<e;t++)o=parseInt(i.substring(t*8,(t+1)*8),2),f.push(o);return f},ap=function(n){var t=n.charCodeAt(0),i=65,r=6;return t>=65&&t<=90?t-i:t>=97&&t<=122?t-i-r:t>=48&&t<=57?t+4:n=="+"?62:n=="/"?63:null},vp=function(n){while(n.length<6)n="0"+n;return n},fu="http://",sr=fu+"www.w3.org/",is=sr+"1999/xhtml",hr=sr+"2000/xmlns/",pi=sr+"XML/1998/namespace",rs=fu+"www.mozilla.org/newlayout/xml/parsererror.xml",yp=function(n){var t=/(^\s)|(\s$)/;return t.test(n)},pp=function(n){var t=/^\s*$/;return n===null||t.test(n)},wp=function(n){while(n!==null&&n.nodeType===1){var t=st(n,"space",pi);if(t==="preserve")return!0;if(t==="default")break;else n=n.parentNode}return!1},bp=function(n){var t=n.nodeName;return t=="xmlns"||t.indexOf("xmlns:")===0},eu=function(n,t,i){try{n.setProperty(t,i)}catch(r){}},kp=function(){var n=ko("Msxml2.DOMDocument.3.0");return n&&(eu(n,"ProhibitDTD",!0),eu(n,"MaxElementDepth",256),eu(n,"AllowDocumentFunction",!1),eu(n,"AllowXsltScript",!1)),n},us=function(){try{v
 ar n=ko("Msxml2.DOMDocument.6.0");return n&&(n.async=!0),n}catch(t){return kp()}},dp=function(n){var t=us(),i;return t?(t.loadXML(n),i=t.parseError,i.errorCode!==0&&cr(i.reason,i.srcText,n),t):null},cr=function(n,t,i){typeof n=="string"&&(n={message:n});throw g(n,{srcText:t||"",errorXmlText:i||""});},ou=function(t){var s=n.DOMParser&&new n.DOMParser,r,e,l;if(!s)return r=dp(t),r||cr("XML DOM parser not supported"),r;try{r=s.parseFromString(t,"text/xml")}catch(v){cr(v,"",t)}var i=r.documentElement,h=i.namespaceURI,c=f(i);if(c==="parsererror"&&h===rs&&(e=b(i,rs,"sourcetext"),l=e?ki(e):"",cr(k(i)||"",l,t)),c==="h3"&&h===is||tw(i,is,"h3")){for(var o="",a=[],u=i.firstChild;u;)u.nodeType===1&&(o+=k(u)||""),a.push(u.nextSibling),u=u.firstChild||a.shift();o+=k(i)||"",cr(o,"",t)}return r},pt=function(n,t){return n?n+":"+t:t},gp=function(n,t){if(yp(t.data)){var i=bi(n,pi,"space");i||(i=si(n.ownerDocument,pi,pt("xml","space")),l(n,i)),i.value="preserve"}return n.appendChild(t),n},wi=function(n,
 t){for(var r=n.attributes,i=0,u=r.length;i<u;i++)t(r.item(i))},st=function(n,t,i){var r=bi(n,t,i);return r?ki(r):null},bi=function(n,t,i){var r=n.attributes;return r.getNamedItemNS?r.getNamedItemNS(i||null,t):r.getQualifiedItem(t,i)||null},rt=function(n,t){var i=bi(n,"base",pi);return(i?c(i.value,t):t)||null},p=function(n,t){pf(n,!1,function(n){return n.nodeType===1&&t(n),!0})},fs=function(n,t,i){for(var u=i.split("/"),r=0,f=u.length;r<f;r++)n=n&&b(n,t,u[r]);return n||null},nw=function(n,t,i){var f=i.lastIndexOf("/"),r=i.substring(f+1),e=i.substring(0,f),u=e?fs(n,t,e):n;return u?r.charAt(0)==="@"?bi(u,r.substring(1),t):b(u,t,r):null},b=function(n,t,i){return es(n,t,i,!1)},tw=function(n,t,i){if(n.getElementsByTagNameNS){var r=n.getElementsByTagNameNS(t,i);return r.length>0?r[0]:null}return es(n,t,i,!0)},es=function(n,t,i,r){var e=null;return pf(n,r,function(n){if(n.nodeType===1){var r=!t||u(n)===t,o=!i||f(n)===i;r&&o&&(e=n)}return e===null}),e},k=function(n){var i=null,r=n.nodeType==
 =9&&n.documentElement?n.documentElement:n,f=r.ownerDocument.preserveWhiteSpace===!1,u;return pf(r,!1,function(n){if(n.nodeType===3||n.nodeType===4){var e=ki(n),o=f||!pp(e);o||(u===t&&(u=wp(r)),o=u),o&&(i?i+=e:i=e)}return!0}),i},f=function(n){return n.localName||n.baseName},u=function(n){return n.namespaceURI||null},ki=function(n){return n.nodeType===1?k(n):n.nodeValue},pf=function(n,t,i){for(var f=[],r=n.firstChild,u=!0;r&&u;)u=i(r),u&&(t&&r.firstChild&&f.push(r.firstChild),r=r.nextSibling||f.shift())},iw=function(n,t,i){for(var r=n.nextSibling,e,o;r;){if(r.nodeType===1&&(e=!t||u(r)===t,o=!i||f(r)===i,e&&o))return r;r=r.nextSibling}return null},os=function(){var t=n.document.implementation;return t&&t.createDocument?t.createDocument(null,null,null):us()},su=function(n,t){if(!e(t))return l(n,t);for(var i=0,r=t.length;i<r;i++)t[i]&&l(n,t[i]);return n},l=function(n,t){if(t){if(typeof t=="string")return gp(n,uw(n.ownerDocument,t));t.nodeType===2?n.setAttributeNodeNS?n.setAttributeNodeNS
 (t):n.setAttributeNode(t):n.appendChild(t)}return n},si=function(n,i,r,u){var f=n.createAttributeNS&&n.createAttributeNS(i,r)||n.createNode(2,r,i||t);return f.value=u||"",f},lr=function(n,i,r,u){var f=n.createElementNS&&n.createElementNS(i,r)||n.createNode(1,r,i||t);return su(f,u||[])},ss=function(n,t,i){return si(n,hr,pt("xmlns",i),t)},rw=function(n,t){for(var f="<c>"+t+"<\/c>",e=ou(f),r=e.documentElement,o=("importNode"in n)?n.importNode(r,!0):r,u=n.createDocumentFragment(),i=o.firstChild;i;)u.appendChild(i),i=i.nextSibling;return u},uw=function(n,t){return n.createTextNode(t)},fw=function(n,t,i,r,u){for(var f="",h=u.split("/"),c=b,a=lr,o=t,e,s=0,v=h.length;s<v;s++)f=h[s],f.charAt(0)==="@"&&(f=f.substring(1),c=bi,a=si),e=c(o,i,f),e||(e=a(n,i,pt(r,f)),l(o,e)),o=e;return o},wf=function(t){var i=n.XMLSerializer,r;if(i)return r=new i,r.serializeToString(t);if(t.xml)return t.xml;throw{message:"XML serialization unsupported"};},ew=function(n){var f=n.childNodes,t,r=f.length,i;if(r===0)r
 eturn"";var e=n.ownerDocument,o=e.createDocumentFragment(),u=e.createElement("c");for(o.appendChild(u),t=0;t<r;t++)u.appendChild(f[t]);for(i=wf(o),i=i.substr(3,i.length-7),t=0;t<r;t++)n.appendChild(u.childNodes[t]);return i},kit=function(i){var r=i.xml,u;if(r!==t)return r;if(n.XMLSerializer)return u=new n.XMLSerializer,u.serializeToString(i);throw{message:"XML serialization unsupported"};},ow=function(n,t,i){return function(){return n[t].apply(n,arguments),i}},di=function(){this._arguments=t,this._done=t,this._fail=t,this._resolved=!1,this._rejected=!1};di.prototype={then:function(n,t){return n&&(this._done?this._done.push(n):this._done=[n]),t&&(this._fail?this._fail.push(t):this._fail=[t]),this._resolved?this.resolve.apply(this,this._arguments):this._rejected&&this.reject.apply(this,this._arguments),this},resolve:function(){if(this._done){for(var n=0,i=this._done.length;n<i;n++)this._done[n].apply(null,arguments);this._done=t,this._resolved=!1,this._arguments=t}else this._resolved=
 !0,this._arguments=arguments},reject:function(){if(this._fail){for(var n=0,i=this._fail.length;n<i;n++)this._fail[n].apply(null,arguments);this._fail=t,this._rejected=!1,this._arguments=t}else this._rejected=!0,this._arguments=arguments},promise:function(){var n={};return n.then=ow(this,"then",n),n}};var hu=function(){return n.jQuery&&n.jQuery.Deferred?new n.jQuery.Deferred:new di},hs=function(n,t){var i=(n&&n.__metadata||{}).type;return i||(t?t.type:null)},v="Edm.",cs=v+"Binary",ls=v+"Boolean",as=v+"Byte",cu=v+"DateTime",lu=v+"DateTimeOffset",vs=v+"Decimal",ys=v+"Double",ps=v+"Guid",ws=v+"Int16",bs=v+"Int32",ks=v+"Int64",ds=v+"SByte",gs=v+"Single",ar=v+"String",au=v+"Time",ht=v+"Geography",nh=ht+"Point",th=ht+"LineString",ih=ht+"Polygon",rh=ht+"Collection",uh=ht+"MultiPolygon",fh=ht+"MultiLineString",eh=ht+"MultiPoint",et=v+"Geometry",oh=et+"Point",sh=et+"LineString",hh=et+"Polygon",ch=et+"Collection",lh=et+"MultiPolygon",ah=et+"MultiLineString",vh=et+"MultiPoint",bf="Point",kf="Li
 neString",df="Polygon",gf="MultiPoint",ne="MultiLineString",te="MultiPolygon",ie="GeometryCollection",sw=[ar,bs,ks,ls,ys,gs,cu,lu,au,vs,ps,as,ws,ds,cs],hw=[et,oh,sh,hh,ch,lh,ah,vh],cw=[ht,nh,th,ih,rh,uh,fh,eh],hi=function(n,t){if(!n)return null;if(e(n)){for(var r,i=0,u=n.length;i<u;i++)if(r=hi(n[i],t),r)return r;return null}return n.dataServices?hi(n.dataServices.schema,t):t(n)},yh=function(n,t){return n=n===0?"":"."+a(n.toString(),3),t>0&&(n===""&&(n=".000"),n+=a(t.toString(),4)),n},ph=function(n){var u,t,e;if(typeof n=="string")return n;if(u=yw(n),t=bh(n.__offset),u&&t!=="Z"){n=new Date(n.valueOf());var i=oc(t),o=n.getUTCHours()+i.d*i.h,s=n.getUTCMinutes()+i.d*i.m;n.setUTCHours(o,s)}else u||(t="");var r=n.getUTCFullYear(),h=n.getUTCMonth()+1,f="";return r<=0&&(r=-(r-1),f="-"),e=yh(n.getUTCMilliseconds(),n.__ns),f+a(r,4)+"-"+a(h,2)+"-"+a(n.getUTCDate(),2)+"T"+a(n.getUTCHours(),2)+":"+a(n.getUTCMinutes(),2)+":"+a(n.getUTCSeconds(),2)+e+t},wh=function(n){var t=n.ms,e="",i,r,u,f;retur
 n t<0&&(e="-",t=-t),i=Math.floor(t/864e5),t-=864e5*i,r=Math.floor(t/36e5),t-=36e5*r,u=Math.floor(t/6e4),t-=6e4*u,f=Math.floor(t/1e3),t-=f*1e3,e+"P"+a(i,2)+"DT"+a(r,2)+"H"+a(u,2)+"M"+a(f,2)+yh(t,n.ns)+"S"},a=function(n,t,i){for(var r=n.toString(10);r.length<t;)i?r+="0":r="0"+r;return r},bh=function(n){return!n||n==="Z"||n==="+00:00"||n==="-00:00"?"Z":n},vu=function(n){if(typeof n=="string"){var t=n.indexOf(")",10);if(n.indexOf("Collection(")===0&&t>0)return n.substring(11,t)}return null},lw=function(n,i,r,u,f,e){return f.request(n,function(f){try{f.headers&&oe(f.headers),f.data===t&&f.statusCode!==204&&u.read(f,e)}catch(o){o.request===t&&(o.request=n),o.response===t&&(o.response=f),r(o);return}i(f.data,f)},r)},aw=function(n){return d(n)&&e(n.__batchRequests)},vw=/Collection\((.*)\)/,kh=function(n,t){var i=n&&n.results||n;return!!i&&yu(t)||!t&&e(i)&&!d(i[0])},yu=function(n){return vw.test(n)},d=function(n){return!!n&&af(n)&&!e(n)&&!lf(n)},yw=function(n){return n.__edmType==="Edm.DateT
 imeOffset"||!n.__edmType&&n.__offset},dh=function(n){if(!n&&!d(n))return!1;var t=n.__metadata||{},i=n.__deferred||{};return!t.type&&!!i.uri},gh=function(n){return d(n)&&n.__metadata&&"uri"in n.__metadata},vr=function(n,t){var i=n&&n.results||n;return e(i)&&!yu(t)&&d(i[0])},re=function(n){return er(cw,n)},ue=function(n){return er(hw,n)},nc=function(n){if(!n&&!d(n))return!1;var i=n.__metadata,t=n.__mediaresource;return!i&&!!t&&!!t.media_src},pu=function(n){return lf(n)||typeof n=="string"||typeof n=="number"||typeof n=="boolean"},fe=function(n){return er(sw,n)},tc=function(n,i){return dh(n)?"deferred":gh(n)?"entry":vr(n)?"feed":i&&i.relationship?n===null||n===t||!vr(n)?"entry":"feed":null},wt=function(n,t){return or(n,function(n){return n.name===t})},ee=function(n,t,i){return n?hi(t,function(t){return gw(n,t,i)}):null},pw=function(n,t){return or(n,function(n){return n.name===t})},gi=function(n,t){return ee(n,t,"complexType")},bt=function(n,t){return ee(n,t,"entityType")},ic=function(n
 ){return hi(n,function(n){return or(n.entityContainer,function(n){return se(n.isDefaultEntityContainer)})})},rc=function(n,t){return ee(n,t,"entityContainer")},ww=function(n,t){return or(n,function(n){return n.name===t})},bw=function(n,t){var u=null,f,i,r;return n&&(f=n.relationship,i=hi(t,function(n){var r=uc(n.namespace,f),i=n.association,t,u;if(r&&i)for(t=0,u=i.length;t<u;t++)if(i[t].name===r)return i[t];return null}),i&&(r=i.end[0],r.role!==n.toRole&&(r=i.end[1]),u=r.type)),u},kw=function(n,t,i){if(n){var u=n.relationship,r=hi(i,function(n){for(var f=n.entityContainer,t,i,r=0;r<f.length;r++)if(t=f[r].associationSet,t)for(i=0;i<t.length;i++)if(t[i].association==u)return t[i];return null});if(r&&r.end[0]&&r.end[1])return r.end[0].entitySet==t?r.end[1].entitySet:r.end[0].entitySet}return null},dw=function(n,t){return hi(t,function(t){for(var f=t.entityContainer,r,u,i=0;i<f.length;i++)if(r=f[i].entitySet,r)for(u=0;u<r.length;u++)if(r[u].name==n)return{entitySet:r[u],containerName:f[
 i].name,functionImport:f[i].functionImport};return null})},uc=function(n,t){return t.indexOf(n)===0&&t.charAt(n.length)==="."?t.substr(n.length+1):null},gw=function(n,t,i){if(n&&t){var r=uc(t.namespace,n);if(r)return or(t[i],function(n){return n.name===r})}return null},ct=function(n,t){var i,f,e;if(n===t)return n;var r=n.split("."),u=t.split("."),o=r.length>=u.length?r.length:u.length;for(i=0;i<o;i++){if(f=r[i]&&s(r[i]),e=u[i]&&s(u[i]),f>e)return n;if(f<e)return t}},nb={accept:"Accept","content-type":"Content-Type",dataserviceversion:"DataServiceVersion",maxdataserviceversion:"MaxDataServiceVersion"},oe=function(n){var t,r,i,u;for(t in n)r=t.toLowerCase(),i=nb[r],i&&t!==i&&(u=n[t],delete n[t],n[i]=u)},se=function(n){return typeof n=="boolean"?n:typeof n=="string"&&n.toLowerCase()==="true"},tb=/^(-?\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d+))?(.*)$/,fc=function(n,t,i){var r=tb.exec(n),o=r?bh(r[8]):null,h,u,e,c,l,f;if(!r||!t&&o!=="Z"){if(i)return null;throw{message:
 "Invalid date/time value"};}if(h=s(r[1]),h<=0&&h++,u=r[7],e=0,u){if(u.length>7){if(i)return null;throw{message:"Cannot parse date/time value to given precision."};}e=a(u.substring(3),4,!0),u=a(u.substring(0,3),3,!0),u=s(u),e=s(e)}else u=0;var v=s(r[4]),y=s(r[5]),p=s(r[6])||0;if(o!=="Z"&&(c=oc(o),l=-c.d,v+=c.h*l,y+=c.m*l),f=new Date,f.setUTCFullYear(h,s(r[2])-1,s(r[3])),f.setUTCHours(v,y,p,u),isNaN(f.valueOf())){if(i)return null;throw{message:"Invalid date/time value"};}return t&&(f.__edmType="Edm.DateTimeOffset",f.__offset=o),e&&(f.__ns=e),f},wu=function(n,t){return fc(n,!1,t)},he=function(n,t){return fc(n,!0,t)},ec=/^([+-])?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d+))?S)?)?/,dit=function(n){ec.test(n)},ce=function(n){var i=ec.exec(n),t,r,u;if(i===null)throw{message:"Invalid duration value."};var f=i[2]||"0",e=i[3]||"0",o=s(i[4]||0),h=s(i[5]||0),c=s(i[6]||0),l=parseFloat(i[7]||0);if(f!=="0"||e!=="0")throw{message:"Unsupported duration value."};if(t
 =i[8],r=0,t){if(t.length>7)throw{message:"Cannot parse duration value to given precision."};r=a(t.substring(3),4,!0),t=a(t.substring(0,3),3,!0),t=s(t),r=s(r)}else t=0;return t+=l*1e3+c*6e4+h*36e5+o*864e5,i[1]==="-"&&(t=-t),u={ms:t,__edmType:"Edm.Time"},r&&(u.ns=r),u},oc=function(n){var t=n.substring(0,1),i,r;return t=t==="+"?1:-1,i=s(n.substring(1)),r=s(n.substring(n.indexOf(":")+1)),{d:t,h:i,m:r}},sc=function(n,i,r){n.method||(n.method="GET"),n.headers?oe(n.headers):n.headers={},n.headers.Accept===t&&(n.headers.Accept=i.accept),ot(n.data)&&n.body===t&&i.write(n,r),ot(n.headers.MaxDataServiceVersion)||(n.headers.MaxDataServiceVersion=i.maxDataServiceVersion||"1.0")},hc=function(n,i,r){var u,e,f;if(n&&typeof n=="object")for(u in n)e=n[u],f=hc(e,u,r),f=r(u,f,i),f!==e&&(e===t?delete n[u]:n[u]=f);return n},ib=function(n,t){return t("",hc(n,"",t))},bu=0,rb=function(n){return n.method&&n.method!=="GET"?!1:!0},ub=function(t){var i=n.document.createElement("IFRAME");i.style.display="none";v
 ar r=t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/\</g,"&lt;"),u='<html><head><script type="text/javascript" src="'+r+'"><\/script><\/head><body><\/body><\/html>',f=n.document.getElementsByTagName("BODY")[0];return f.appendChild(i),cc(i,u),i},fb=function(){if(n.XMLHttpRequest)return new n.XMLHttpRequest;var t;if(n.ActiveXObject)try{return new n.ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(i){try{return new n.ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(r){t=r}}else t={message:"XMLHttpRequest not supported"};throw t;},eb=function(n){return n.indexOf("http://")===0||n.indexOf("https://")===0||n.indexOf("file://")===0},ob=function(t){if(!eb(t))return!0;var i=n.location,r=i.protocol+"//"+i.host+"/";return t.indexOf(r)===0},sb=function(i,r){try{delete n[i]}catch(u){n[i]=t,r===bu-1&&(bu-=1)}},ku=function(n){return n&&(cc(n,""),n.parentNode.removeChild(n)),null},hb=function(n,t){for(var r=n.getAllResponseHeaders().split(/\r?\n/),u,i=0,f=r.length;i<f;i++)r[i]&&(u=r[i].split(": "),t[u[0
 ]]=u[1])},cc=function(n,t){var i=n.contentWindow?n.contentWindow.document:n.contentDocument.document;i.open(),i.write(t),i.close()};r.defaultHttpClient={callbackParameterName:"$callback",formatQueryString:"$format=json",enableJsonpCallback:!1,request:function(i,r,u){var y={},f=null,h=!1,s,a,w,b,k,d,l,v;y.abort=function(){(s=ku(s),h)||(h=!0,f&&(f.abort(),f=null),u({message:"Request aborted"}))};var p=function(){s=ku(s),h||(h=!0,f=null,u({message:"Request timed out"}))},c,e=i.requestUri,g=it(i.enableJsonpCallback,this.enableJsonpCallback),nt=it(i.callbackParameterName,this.callbackParameterName),tt=it(i.formatQueryString,this.formatQueryString);if(!g||ob(e)){if(f=fb(),f.onreadystatechange=function(){var t,n,o,s;h||f===null||f.readyState!==4||(t=f.statusText,n=f.status,n===1223&&(n=204,t="No Content"),o=[],hb(f,o),s={requestUri:e,statusCode:n,statusText:t,headers:o,body:f.responseText},h=!0,f=null,n>=200&&n<=299?r(s):u({message:"HTTP request failed",request:i,response:s}))},f.open(i.me
 thod||"GET",e,!0,i.user,i.password),i.headers)for(c in i.headers)f.setRequestHeader(c,i.headers[c]);i.timeoutMS&&(f.timeout=i.timeoutMS,f.ontimeout=p),f.send(i.body)}else{if(!rb(i))throw{message:"Request is not local and cannot be done through JSONP."};a=bu,bu+=1,w=a.toString(),b=!1,c="handleJSONP_"+w,n[c]=function(i){if(s=ku(s),!h){b=!0,n.clearTimeout(k),sb(c,a),n.ActiveXObject&&(i=n.JSON.parse(n.JSON.stringify(i)));var u;u=i.d===t?{"Content-Type":"application/json;odata=minimalmetadata",dataServiceVersion:"3.0"}:{"Content-Type":"application/json"},o(function(){ku(s),r({body:i,statusCode:200,headers:u})})}},d=i.timeoutMS?i.timeoutMS:12e4,k=n.setTimeout(p,d),l=nt+"=parent."+c,this.formatQueryString&&(l+="&"+tt),v=e.indexOf("?"),e=v===-1?e+"?"+l:v===e.length-1?e+l:e+"&"+l,s=ub(e)}return y}};var ci="3.0",nr=function(n){var t,r,i,f,u;if(!n)return null;for(t=n.split(";"),r={},i=1,f=t.length;i<f;i++)u=t[i].split("="),r[go(u[0])]=u[1];return{mediaType:go(t[0]),properties:r}},cb=function(n
 ){if(!n)return t;var r=n.mediaType,i;for(i in n.properties)r+=";"+i+"="+n.properties[i];return r},lc=function(n,t,i,r){var u={};return g(u,i),g(u,{contentType:n,dataServiceVersion:t,handler:r}),u},ac=function(n,t,i){if(n){var r=n.headers;r[t]||(r[t]=i)}},lb=function(n,t){if(n){var i=n.headers,r=i.DataServiceVersion;i.DataServiceVersion=r?ct(r,t):t}},vc=function(n,i){var r=n.headers;return r&&r[i]||t},yc=function(n){return nr(vc(n,"Content-Type"))},ab=/^\s?(\d+\.\d+);?.*$/,pc=function(n){var i=vc(n,"DataServiceVersion"),t;if(i&&(t=ab.exec(i),t&&t.length))return t[1]},wc=function(n,t){return n.accept.indexOf(t.mediaType)>=0},vb=function(n,i,r,u){var f;if(!r||!r.headers)return!1;var e=yc(r),s=pc(r)||"",o=r.body;return ot(o)?wc(n,e)?(f=lc(e,s,u,n),f.response=r,r.data=i(n,o,f),r.data!==t):!1:!1},yb=function(n,i,r,u){var e,o,f;return!r||!r.headers?!1:(e=yc(r),o=pc(r),(!e||wc(n,e))&&(f=lc(e,o,u,n),f.request=r,r.body=i(n,r.data,f),r.body!==t))?(lb(r,f.dataServiceVersion||"1.0"),ac(r,"Conten
 t-Type",cb(f.contentType)),ac(r,"MaxDataServiceVersion",n.maxDataServiceVersion),!0):!1},li=function(n,t,i,r){return{accept:i,maxDataServiceVersion:r,read:function(t,i){return vb(this,n,t,i)},write:function(n,i){return yb(this,t,n,i)}}},pb=function(n,t){return t},wb=function(n,i){return ot(i)?i.toString():t};r.textHandler=li(pb,wb,"text/plain",ci);var bc=fu+"www.opengis.net",ut=bc+"/gml",kc=bc+"/def/crs/EPSG/0/",dc="gml",yr=function(n,t,i){var r={type:n};return r[t]=i,r},le=function(n){if(e(n)&&n.length>=2){var t=n[0];n[0]=n[1],n[1]=t}return n},ae=function(n,t,i,r,u,f){var e=gc(n,i,r,u,f);return yr(t,"coordinates",e)},gc=function(n,t,i,r,e){var o=[];return p(n,function(n){var s,h,c;if(u(n)===ut){if(s=f(n),s===t){h=b(n,ut),h&&(c=r(h,e),c&&o.push(c));return}s===i&&p(n,function(n){if(u(n)===ut){var t=r(n,e);t&&o.push(t)}})}}),o},bb=function(n,t){var i=gc(n,"geometryMember","geometryMembers",il,t);return yr(ie,"geometries",i)},kb=function(n,t){return yr(kf,"coordinates",ve(n,t))},db=fun
 ction(n,t){return ae(n,ne,"curveMember","curveMembers",ve,t)},gb=function(n,t){return ae(n,gf,"pointMember","pointMembers",ye,t)},nk=function(n,t){return ae(n,te,"surfaceMember","surfaceMembers",nl,t)},tk=function(n,t){return yr(bf,"coordinates",ye(n,t))},ik=function(n,t){return yr(df,"coordinates",nl(n,t))},ve=function(n,t){var i=[];return p(n,function(n){var e=u(n),r;if(e===ut){if(r=f(n),r==="posList"){i=uk(n,t);return}if(r==="pointProperty"){i.push(rk(n,t));return}if(r==="pos"){i.push(pe(n,t));return}}}),i},ye=function(n,t){var i=b(n,ut,"pos");return i?pe(i,t):[]},rk=function(n,t){var i=b(n,ut,"Point");return i?ye(i,t):[]},nl=function(n,t){var i=[],r=!1;return p(n,function(n){if(u(n)===ut){var e=f(n);if(e==="exterior"){r=!0,i.unshift(tl(n,t));return}if(e==="interior"){i.push(tl(n,t));return}}}),!r&&i.length>0&&i.unshift([[]]),i},tl=function(n,t){var i=[];return p(n,function(n){u(n)===ut&&f(n)==="LinearRing"&&(i=ve(n,t))}),i},uk=function(n,t){var f=pe(n,!1),e=f.length,r,i,u;if(e%2
 !=0)throw{message:"GML posList element has an uneven number of numeric values"};for(r=[],i=0;i<e;i+=2)u=f.slice(i,i+2),r.push(t?le(u):u);return r},pe=function(n,t){var u=[],o=" \t\r\n",r=k(n),f;if(r)for(var s=r.length,e=0,i=0;i<=s;)o.indexOf(r.charAt(i))!==-1&&(f=r.substring(e,i),f&&u.push(parseFloat(f)),e=i+1),i++;return t?le(u):u},il=function(n,t){var o=f(n),i,u,r,e;switch(o){case"Point":i=tk;break;case"Polygon":i=ik;break;case"LineString":i=kb;break;case"MultiPoint":i=gb;break;case"MultiCurve":i=db;break;case"MultiSurface":i=nk;break;case"MultiGeometry":i=bb;break;default:throw{message:"Unsupported element: "+o,element:n};}if(u=i(n,t),r=st(n,"srsName",ut)||st(n,"srsName"),r){if(r.indexOf(kc)!==0)throw{message:"Unsupported srs name: "+r,element:n};e=r.substring(kc.length),e&&(u.crs={type:"name",properties:{name:"EPSG:"+e}})}return u},rl=function(n,t,i,r){var u,o,e,s,f,h,c;switch(i){case bf:u=fk;break;case kf:u=ek;break;case df:u=ok;break;case gf:u=sk;break;case ne:u=hk;break;case 
 te:u=ck;break;case ie:u=ak;break;default:return null}return o=u(n,t,r),e=t.crs,e&&e.type==="name"&&(s=e.properties,f=s&&s.name,f&&f.indexOf("ESPG:")===0&&f.length>5&&(h=f.substring(5),c=si(n,null,"srsName",dc+h),l(o,c))),o},kt=function(n,t,i){return lr(n,ut,pt(dc,t),i)},ul=function(n,t,i){var r=e(t)?t:[];return r=i?le(r):r,kt(n,"pos",r.join(" "))},fl=function(n,t,i,r){var f=kt(n,t),u,o;if(e(i)){for(u=0,o=i.length;u<o;u++)l(f,ul(n,i[u],r));o===0&&l(f,kt(n,"posList"))}return f},el=function(n,t,i){return kt(n,"Point",ul(n,t,i))},ol=function(n,t,i){return fl(n,"LineString",t,i)},sl=function(n,t,i,r){var u=kt(n,t),f;return e(i)&&i.length>0&&(f=fl(n,"LinearRing",i,r),l(u,f)),u},hl=function(n,t,i){var f=t&&t.length,u=kt(n,"Polygon"),r;if(e(t)&&f>0)for(l(u,sl(n,"exterior",t[0],i)),r=1;r<f;r++)l(u,sl(n,"interior",t[r],i));return u},fk=function(n,t,i){return el(n,t.coordinates,i)},ek=function(n,t,i){return ol(n,t.coordinates,i)},ok=function(n,t,i){return hl(n,t.coordinates,i)},du=function(n,t
 ,i,r,u,f){var h=r&&r.length,c=kt(n,t),s,o;if(e(r)&&h>0){for(s=kt(n,i),o=0;o<h;o++)l(s,u(n,r[o],f));l(c,s)}return c},sk=function(n,t,i){return du(n,"MultiPoint","pointMembers",t.coordinates,el,i)},hk=function(n,t,i){return du(n,"MultiCurve","curveMembers",t.coordinates,ol,i)},ck=function(n,t,i){return du(n,"MultiSurface","surfaceMembers",t.coordinates,hl,i)},lk=function(n,t,i){return rl(n,t,t.type,i)},ak=function(n,t,i){return du(n,"MultiGeometry","geometryMembers",t.geometries,lk,i)},gu="application/xml",dt=fu+"schemas.microsoft.com/ado/",ai=dt+"2007/08/dataservices",nf=dt+"2007/06/edmx",vk=dt+"2006/04/edm",yk=dt+"2007/05/edm",pk=dt+"2008/01/edm",wk=dt+"2008/09/edm",bk=dt+"2009/08/edm",kk=dt+"2009/11/edm",lt=ai,nt=ai+"/metadata",we=ai+"/related/",cl=ai+"/scheme",ll="d",be="m",gt=function(n,t){var i={name:f(n),value:n.value};return i[t?"namespaceURI":"namespace"]=u(n),i},pr=function(n,t){for(var s=[],h=[],c=n.attributes,e,i,o,r=0,l=c.length;r<l;r++)e=c[r],u(e)!==hr&&s.push(gt(e,t));f
 or(i=n.firstChild;i!=null;)i.nodeType===1&&h.push(pr(i,t)),i=i.nextSibling;return o={name:f(n),value:k(n),attributes:s,children:h},o[t?"namespaceURI":"namespace"]=u(n),o},ke=function(n){return u(n)===lt&&f(n)==="element"},al=function(n,t){return{type:n,extensions:t}},dk=function(n){var t,i;return b(n,ut)?et:(t=b(n,lt),!t)?ar:ke(t)&&(i=iw(t,lt),i&&ke(i))?"Collection()":null},vl=function(n){var t=null,i=!1,r=[];return wi(n,function(n){var e=u(n),o=f(n),s=ki(n);if(e===nt){if(o==="null"){i=s.toLowerCase()==="true";return}if(o==="type"){t=s;return}}if(e!==pi&&e!==hr){r.push(gt(n,!0));return}}),{type:!t&&i?ar:t,isNull:i,extensions:r}},yl=function(n){if(u(n)!==lt)return null;var e=f(n),t=vl(n),o=t.isNull,i=t.type,r=al(i,t.extensions),s=o?null:pl(n,i,r);return{name:e,value:s,metadata:r}},pl=function(n,t,i){t||(t=dk(n),i.type=t);var r=re(t);return r||ue(t)?gk(n,t,r):fe(t)?wl(n,t):yu(t)?td(n,t,i):nd(n,t,i)},gk=function(n,t,i){var u=b(n,ut),r=il(u,i);return r.__metadata={type:t},r},wl=function
 (n,t){var i=ki(n)||"";switch(t){case ls:return se(i);case cs:case vs:case ps:case ks:case ar:return i;case as:case ws:case bs:case ds:return s(i);case ys:case gs:return parseFloat(i);case au:return ce(i);case cu:return wu(i);case lu:return he(i)}return i},nd=function(n,t,i){var r={__metadata:{type:t}};return p(n,function(n){var t=yl(n),u=t.name;i.properties=i.properties||{},i.properties[u]=t.metadata,r[u]=t.value}),r},td=function(n,t,i){var r=[],u=i.elements=[],f=vu(t);return p(n,function(n){if(ke(n)){var t=vl(n),o=t.extensions,i=t.type||f,e=al(i,o),s=pl(n,i,e);r.push(s),u.push(e)}}),{__metadata:{type:t==="Collection()"?null:t},results:r}},id=function(n,i){if(u(n)===lt){i=rt(n,i);var r=f(n);if(r==="links")return rd(n,i);if(r==="uri")return bl(n,i)}return t},rd=function(n,t){var i=[];return p(n,function(n){f(n)==="uri"&&u(n)===lt&&i.push(bl(n,t))}),{results:i}},bl=function(n,t){var i=k(n)||"";return{uri:c(i,t)}},ud=function(n,t){return t===et||t===ht?n&&n.type:t===oh||t===nh?bf:t===s
 h||t===th?kf:t===hh||t===ih?df:t===ch||t===rh?ie:t===lh||t===uh?te:t===ah||t===fh?ne:t===vh||t===eh?gf:null},kl=function(n,t,i){return lr(n,nt,pt(be,t),i)},de=function(n,t,i){return si(n,nt,pt(be,t),i)},dl=function(n,t,i){return lr(n,lt,pt(ll,t),i)},fd=function(n,t){return t===cu||t===lu||lf(n)?ph(n):t===au?wh(n):n.toString()},at=function(n,t){return{element:n,dsv:t}},wr=function(n,t,i,r){var u=i?de(n,"type",i):null,f=dl(n,t,u);return su(f,r)},ed=function(n,t,i,r){var u=fd(i,r),f=wr(n,t,r,u);return at(f,"1.0")},od=function(n,t,i,r){var u=de(n,"null","true"),f=wr(n,t,i,u),e=gi(i,r)?"2.0":"1.0";return at(f,e)},sd=function(n,t,i,r,u,f,o){var c=vu(r),a=e(i)?i:i.results,v=r?{type:c}:{},h,s,y,p,w;for(v.properties=u.properties,h=wr(n,t,c?r:null),s=0,y=a.length;s<y;s++)p=a[s],w=ge(n,"element",p,v,f,o),l(h,w.element);return at(h,"3.0")},hd=function(n,t,i,r,u,f,e){var h=wr(n,t,r),a=u.properties||{},v=gi(r,e)||{},s="1.0",o;for(o in i)if(o!=="__metadata"){var y=i[o],p=wt(v.property,o),w=a[o]||{
 },c=ge(n,o,y,w,p,e);s=ct(s,c.dsv),l(h,c.element)}return at(h,s)},cd=function(n,t,i,r,u){var f=ud(i,r),e=rl(n,i,f,u),o=wr(n,t,r,e);return at(o,"3.0")},ge=function(n,t,i,r,u,f){var e=hs(i,r,u),o,s;return pu(i)?ed(n,t,i,e||ar):(o=re(e),o||ue(e))?cd(n,t,i,e,o):kh(i,e)?sd(n,t,i,e,r,u,f):nc(i)?null:(s=tc(i,u),s!==null)?null:i===null?od(n,t,e):hd(n,t,i,e,r,u,f)},ld=function(n){if(n&&af(n)){var t=os();return l(t,dl(t,"uri",n.uri))}},ad=function(n,t){if(t){var r=ou(t),i=b(r);if(i)return id(i)}},vd=function(n,i,r){var u=r.contentType=r.contentType||nr(gu);return u&&u.mediaType===gu?wf(ld(i)):t};r.xmlHandler=li(ad,vd,gu,ci);var gl="a",ni=sr+"2005/Atom",br=sr+"2007/app",na=ai+"/edit-media/",ta=ai+"/mediaresource/",ia=ai+"/relatedlinks/",ra=["application/atom+xml","application/atomsvc+xml","application/xml"],ua=ra[0],yd=[ni,br,pi,hr],pd={SyndicationAuthorEmail:"author/email",SyndicationAuthorName:"author/name",SyndicationAuthorUri:"author/uri",SyndicationContributorEmail:"contributor/email",Synd
 icationContributorName:"contributor/name",SyndicationContributorUri:"contributor/uri",SyndicationPublished:"published",SyndicationRights:"rights",SyndicationSummary:"summary",SyndicationTitle:"title",SyndicationUpdated:"updated"},wd=function(n){return pd[n]||n},kr=function(n){return!er(yd,n)},fa=function(n,t,i,r,u){var f;if(u=u||"",f=n["FC_TargetPath"+u],!f)return null;var e=n["FC_SourcePath"+u],s=wd(f),o=r?r+(e?"/"+e:""):e,l=o&&tg(i,t,o),h=n["FC_NsUri"+u]||null,c=n["FC_NsPrefix"+u]||null,a=n["FC_KeepInContent"+u]||"";return f!==s&&(h=ni,c=gl),{contentKind:n["FC_ContentKind"+u],keepInContent:a.toLowerCase()==="true",nsPrefix:c,nsURI:h,propertyPath:o,propertyType:l,entryPath:s}},ea=function(n,t,i){for(var c=[],l,r,f,u,e;n;){for(l=n.FC_SourcePath,r=fa(n,n,t),r&&i(r),f=n.property||[],u=0,e=f.length;u<e;u++)for(var o=f[u],s=0,h="";r=fa(o,n,t,o.name,h);)i(r),s++,h="_"+s;n=bt(n.baseType,t)}return c},tf=function(n){var t=[];return wi(n,function(n){var i=u(n);kr(i)&&t.push(gt(n,!0))}),t},oa
 =function(n){return pr(n,!0)},sa=function(n,t,i){var e=u(n),r=f(n);if(e===br&&r==="service")return cg(n,t);if(e===ni){if(r==="feed")return bd(n,t,i);if(r==="entry")return va(n,t,i)}},ha=function(n,t){var r=[],i={extensions:r};return wi(n,function(e){var o=f(e),s=u(e),h=ki(e);if(s===null){if(o==="title"||o==="metadata"){i[o]=h;return}if(o==="target"){i.target=c(h,rt(n,t));return}}kr(s)&&r.push(gt(e,!0))}),i},ca=function(n,t,i){var r=i.actions=i.actions||[];r.push(ha(n,t))},la=function(n,t,i){var r=i.functions=i.functions||[];r.push(ha(n,t))},bd=function(n,t,i){var o=tf(n),r={feed_extensions:o},s=[],e={__metadata:r,results:s};return t=rt(n,t),p(n,function(n){var l=u(n),h=f(n);if(l===nt){if(h==="count"){e.__count=parseInt(k(n),10);return}if(h==="action"){ca(n,t,r);return}if(h==="function"){la(n,t,r);return}}if(kr(l)){o.push(pr(n));return}if(h==="entry"){s.push(va(n,t,i));return}if(h==="link"){kd(n,e,t);return}if(h==="id"){r.uri=c(k(n),t),r.uri_extensions=tf(n);return}if(h==="title"){r.
 title=k(n)||"",r.title_extensions=tf(n);return}}),e},kd=function(n,t,i){var r=aa(n,i),f=r.href,e=r.rel,o=r.extensions,u=t.__metadata;if(e==="next"){t.__next=f,u.next_extensions=o;return}if(e==="self"){u.self=f,u.self_extensions=o;return}},aa=function(n,t){t=rt(n,t);var r=[],i={extensions:r,baseURI:t};if(wi(n,function(n){var s=u(n),e=f(n),o=n.value;if(e==="href"){i.href=c(o,t);return}if(e==="type"||e==="rel"){i[e]=o;return}kr(s)&&r.push(gt(n,!0))}),!i.href)throw{error:"href attribute missing on link element",element:n};return i},dd=function(n,i){if(n.indexOf("/")===-1)return i[n];for(var u=n.split("/"),r=0,f=u.length;r<f;r++){if(i===null)return t;if(i=i[u[r]],i===t)return i}return i},gd=function(n,i,r,u){var o,s,f,h,e;if(n.indexOf("/")===-1)i[n]=r,o=n;else{for(s=n.split("/"),f=0,h=s.length-1;f<h;f++){if(e=i[s[f]],e===t)e={},i[s[f]]=e;else if(e===null)return;i=e}o=s[f],i[o]=r}if(u){var c=i.__metadata=i.__metadata||{},l=c.properties=c.properties||{},a=l[o]=l[o]||{};a.type=u}},ng=functi
 on(n,t,i){var e=n.propertyPath,r,u,f;n.keepInContent||dd(e,i)===null||(r=nw(t,n.nsURI,n.entryPath),r)&&(u=n.propertyType,f=n.contentKind==="xhtml"?ew(r):wl(r,u||"Edm.String"),gd(e,i,f,u))},tg=function(n,t,i){for(var s=i.split("/"),u,h,f,e,o,r;t;){for(f=t,u=0,h=s.length;u<h;u++){if(e=f.property,!e)break;if(o=wt(e,s[u]),!o)break;if(r=o.type,!r||fe(r))return r||null;if(f=gi(r,n),!f)return null}t=bt(t.baseType,n)}return null},va=function(n,t,i){var r={},e={__metadata:r},o=st(n,"etag",nt),s;return o&&(r.etag=o),t=rt(n,t),p(n,function(n){var s=u(n),o=f(n);if(s===ni){if(o==="id"){ig(n,r,t);return}if(o==="category"){rg(n,r);return}if(o==="content"){ug(n,e,r,t);return}if(o==="link"){fg(n,e,r,t,i);return}return}if(s===nt){if(o==="properties"){wa(n,e,r);return}if(o==="action"){ca(n,t,r);return}if(o==="function"){la(n,t,r);return}}}),s=bt(r.type,i),ea(s,i,function(t){ng(t,n,e)}),e},ig=function(n,t,i){t.uri=c(k(n),rt(n,i)),t.uri_extensions=tf(n)},rg=function(n,t){if(st(n,"scheme")===cl){if(t.typ
 e)throw{message:"Invalid AtomPub document: multiple category elements defining the entry type were encounterd withing an entry",element:n};var i=[];wi(n,function(n){var t=u(n),r=f(n);if(!t){r!=="scheme"&&r!=="term"&&i.push(gt(n,!0));return}kr(t)&&i.push(gt(n,!0))}),t.type=st(n,"term"),t.type_extensions=i}},ug=function(n,t,i,r){var e=st(n,"src"),o=st(n,"type");if(e){if(!o)throw{message:"Invalid AtomPub document: content element must specify the type attribute if the src attribute is also specified",element:n};i.media_src=c(e,rt(n,r)),i.content_type=o}p(n,function(r){if(e)throw{message:"Invalid AtomPub document: content element must not have child elements if the src attribute is specified",element:n};u(r)===nt&&f(r)==="properties"&&wa(r,t,i)})},fg=function(n,t,i,r,u){var f=aa(n,r),e=f.rel,s=f.href,o=f.extensions;if(e==="self"){i.self=s,i.self_link_extensions=o;return}if(e==="edit"){i.edit=s,i.edit_link_extensions=o;return}if(e==="edit-media"){i.edit_media=f.href,i.edit_media_extensio
 ns=o,pa(f,i);return}if(e.indexOf(na)===0){sg(f,t,i);return}if(e.indexOf(ta)===0){hg(f,t,i);return}if(e.indexOf(we)===0){og(n,f,t,i,u);return}if(e.indexOf(ia)===0){eg(f,i);return}},eg=function(n,t){var r=n.rel.substring(ia.length),i;t.properties=t.properties||{},i=t.properties[r]=t.properties[r]||{},i.associationuri=n.href,i.associationuri_extensions=n.extensions},og=function(n,t,i,r,u){var e,o=b(n,nt,"inline"),s,h,f,c;o?(s=b(o),h=rt(o,t.baseURI),e=s?sa(s,h,u):null):e={__deferred:{uri:t.href}},f=t.rel.substring(we.length),i[f]=e,r.properties=r.properties||{},c=r.properties[f]=r.properties[f]||{},c.extensions=t.extensions},sg=function(n,t,i){var o=n.rel.substring(na.length),f=ya(o,t,i),r=f.value,u=f.metadata,e=n.href;r.edit_media=e,r.content_type=n.type,u.edit_media_extensions=n.extensions,r.media_src=r.media_src||e,u.media_src_extensions=u.media_src_extensions||[],pa(n,r)},hg=function(n,t,i){var f=n.rel.substring(ta.length),r=ya(f,t,i),u=r.value,e=r.metadata;u.media_src=n.href,e.medi
 a_src_extensions=n.extensions,u.content_type=n.type},ya=function(n,t,i){i.properties=i.properties||{};var u=i.properties[n],r=t[n]&&t[n].__mediaresource;return r||(r={},t[n]={__mediaresource:r},i.properties[n]=u={}),{value:r,metadata:u}},pa=function(n,t){for(var r=n.extensions,i=0,u=r.length;i<u;i++)if(r[i].namespaceURI===nt&&r[i].name==="etag"){t.media_etag=r[i].value,r.splice(i,1);return}},wa=function(n,t,i){p(n,function(n){var r=yl(n),u,f;r&&(u=r.name,f=i.properties=i.properties||{},f[u]=r.metadata,t[u]=r.value)})},cg=function(n,t){var i=[],r=[];if(t=rt(n,t),p(n,function(n){if(u(n)===br&&f(n)==="workspace"){i.push(lg(n,t));return}r.push(pr(n))}),i.length===0)throw{message:"Invalid AtomPub service document: No workspace element found.",element:n};return{workspaces:i,extensions:r}},lg=function(n,i){var e=[],o=[],r;return i=rt(n,i),p(n,function(n){var s=u(n),h=f(n);if(s===ni&&h==="title"){if(r!==t)throw{message:"Invalid AtomPub service document: workspace has more than one child tit
 le element",element:n};r=k(n);return}if(s===br){h==="collection"&&e.push(ag(n,i));return}o.push(oa(n))}),{title:r||"",collections:e,extensions:o}},ag=function(n,i){var r=st(n,"href"),o,e;if(!r)throw{message:"Invalid AtomPub service document: collection has no href attribute",element:n};if(i=rt(n,i),r=c(r,rt(n,i)),o=[],p(n,function(i){var r=u(i),s=f(i);if(r===ni){if(s==="title"){if(e!==t)throw{message:"Invalid AtomPub service document: collection has more than one child title element",element:i};e=k(i)}return}r!==br&&o.push(oa(n))}),!e)throw{message:"Invalid AtomPub service document: collection has no title element",element:n};return{title:e,href:r,extensions:o}},ti=function(n,t,i){return lr(n,ni,pt(gl,t),i)},tr=function(n,t,i){return si(n,null,t,i)},vg=function(n){var t,e,i,o,r;if(n.childNodes.length>0)return!1;for(t=!0,e=n.attributes,i=0,o=e.length;i<o&&t;i++)r=e[i],t=t&&bp(r)||u(r)==nt&&f(r)==="type";return t},yg=function(n,t,i,r,u){var s=null,e=null,f=null,o="",h;return i!=="defe
 rred"?(s=tr(n,"type","application/atom+xml;type="+i),e=kl(n,"inline"),r&&(o=r.__metadata&&r.__metadata.uri||"",f=ba(n,r,u)||no(n,r,u),l(e,f.element))):o=r.__deferred.uri,h=ti(n,"link",[tr(n,"href",o),tr(n,"rel",c(t,we)),s,e]),at(h,f?f.dsv:"1.0")},pg=function(n,t,i,r,u,f){var e,o;return nc(i)?null:(e=ge(n,t,i,r,u,f),e||(o=tc(i,u),e=yg(n,t,o,i,f)),e)},wg=function(n,t,i,r){var u=fs(i,lt,r.propertyPath),l=u&&bi(u,"null",nt),o,s="1.0",f,e,h,c;if(l&&l.value==="true")return s;if(u&&(o=k(u)||"",!r.keepInContent))for(s="2.0",f=u.parentNode,e=f,f.removeChild(u);e!==i&&vg(e);)f=e.parentNode,f.removeChild(e),e=f;return(h=fw(n,t,r.nsURI,r.nsPrefix,r.entryPath),h.nodeType===2)?(h.value=o,s):(c=r.contentKind,su(h,[c&&si(n,null,"type",c),c==="xhtml"?rw(n,o):o]),s)},no=function(n,t,i){var e=t.__metadata||{},b=e.properties||{},y=e.etag,p=e.uri,s=e.type,o=bt(s,i),h=kl(n,"properties"),c=ti(n,"entry",[ti(n,"author",ti(n,"name")),y&&de(n,"etag",y),p&&ti(n,"id",p),s&&ti(n,"category",[tr(n,"term",s),tr(n,"
 scheme",cl)]),ti(n,"content",[tr(n,"type","application/xml"),h])]),f="1.0",r,v,w;for(r in t)if(r!=="__metadata"){var k=b[r]||{},d=o&&(wt(o.property,r)||wt(o.navigationProperty,r)),a=pg(n,r,t[r],k,d,i);a&&(v=a.element,w=u(v)===ni?c:h,l(w,v),f=ct(f,a.dsv))}return ea(o,i,function(t){var i=wg(n,c,h,t);f=ct(f,i)}),at(c,f)},ba=function(n,t,i){var f=e(t)?t:t.results,r,o,u,h,s;if(!f)return null;for(r="1.0",o=ti(n,"feed"),u=0,h=f.length;u<h;u++)s=no(n,f[u],i),l(o,s.element),r=ct(r,s.dsv);return at(o,r)},bg=function(n,t){var u,i,r,f;return n&&(u=vr(n)&&ba||af(n)&&no,u&&(i=os(),r=u(i,n,t),r))?(f=r.element,su(f,[ss(i,nt,be),ss(i,lt,ll)]),at(l(i,f),r.dsv)):null},kg=function(n,t,i){if(t){var u=ou(t),r=b(u);if(r)return sa(r,null,i.metadata)}},dg=function(n,t,i){var u=i.contentType=i.contentType||nr(ua),r;if(u&&u.mediaType===ua&&(r=bg(t,i.metadata),r))return i.dataServiceVersion=ct(i.dataServiceVersion||"1.0",r.dsv),wf(r.element)};r.atomHandler=li(kg,dg,ra.join(","),ci);var i=function(n,t,i,r){retu
 rn{attributes:n,elements:t,text:i||!1,ns:r}},tt={elements:{Annotations:i(["Target","Qualifier"],["TypeAnnotation*","ValueAnnotation*"]),Association:i(["Name"],["End*","ReferentialConstraint","TypeAnnotation*","ValueAnnotation*"]),AssociationSet:i(["Name","Association"],["End*","TypeAnnotation*","ValueAnnotation*"]),Binary:i(null,null,!0),Bool:i(null,null,!0),Collection:i(null,["String*","Int*","Float*","Decimal*","Bool*","DateTime*","DateTimeOffset*","Guid*","Binary*","Time*","Collection*","Record*"]),CollectionType:i(["ElementType","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"],["CollectionType","ReferenceType","RowType","TypeRef"]),ComplexType:i(["Name","BaseType","Abstract"],["Property*","TypeAnnotation*","ValueAnnotation*"]),DateTime:i(null,null,!0),DateTimeOffset:i(null,null,!0),Decimal:i(null,null,!0),DefiningExpression:i(null,null,!0),Dependent:i(["Role"],["PropertyRef*"]),Documentation:i(null,null,!0),End:i(["Type","Role
 ","Multiplicity","EntitySet"],["OnDelete"]),EntityContainer:i(["Name","Extends"],["EntitySet*","AssociationSet*","FunctionImport*","TypeAnnotation*","ValueAnnotation*"]),EntitySet:i(["Name","EntityType"],["TypeAnnotation*","ValueAnnotation*"]),EntityType:i(["Name","BaseType","Abstract","OpenType"],["Key","Property*","NavigationProperty*","TypeAnnotation*","ValueAnnotation*"]),EnumType:i(["Name","UnderlyingType","IsFlags"],["Member*"]),Float:i(null,null,!0),Function:i(["Name","ReturnType"],["Parameter*","DefiningExpression","ReturnType","TypeAnnotation*","ValueAnnotation*"]),FunctionImport:i(["Name","ReturnType","EntitySet","IsSideEffecting","IsComposable","IsBindable","EntitySetPath"],["Parameter*","ReturnType","TypeAnnotation*","ValueAnnotation*"]),Guid:i(null,null,!0),Int:i(null,null,!0),Key:i(null,["PropertyRef*"]),LabeledElement:i(["Name"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Nu
 ll"]),Member:i(["Name","Value"]),NavigationProperty:i(["Name","Relationship","ToRole","FromRole","ContainsTarget"],["TypeAnnotation*","ValueAnnotation*"]),Null:i(null,null),OnDelete:i(["Action"]),Path:i(null,null,!0),Parameter:i(["Name","Type","Mode","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","SRID"],["CollectionType","ReferenceType","RowType","TypeRef","TypeAnnotation*","ValueAnnotation*"]),Principal:i(["Role"],["PropertyRef*"]),Property:i(["Name","Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","CollectionKind","SRID"],["CollectionType","ReferenceType","RowType","TypeAnnotation*","ValueAnnotation*"]),PropertyRef:i(["Name"]),PropertyValue:i(["Property","Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time
 ","Collection","Record","LabeledElement","Null"]),ReferenceType:i(["Type"]),ReferentialConstraint:i(null,["Principal","Dependent"]),ReturnType:i(["ReturnType","Type","EntitySet"],["CollectionType","ReferenceType","RowType"]),RowType:i(["Property*"]),String:i(null,null,!0),Schema:i(["Namespace","Alias"],["Using*","EntityContainer*","EntityType*","Association*","ComplexType*","Function*","ValueTerm*","Annotations*"]),Time:i(null,null,!0),TypeAnnotation:i(["Term","Qualifier"],["PropertyValue*"]),TypeRef:i(["Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"]),Using:i(["Namespace","Alias"]),ValueAnnotation:i(["Term","Qualifier","Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Null"]),ValueTerm:i(["Name","Type"],["TypeAnnotation*","ValueAnnotation
 *"]),Edmx:i(["Version"],["DataServices","Reference*","AnnotationsReference*"],!1,nf),DataServices:i(null,["Schema*"],!1,nf)}},ka=["m:FC_ContentKind","m:FC_KeepInContent","m:FC_NsPrefix","m:FC_NsUri","m:FC_SourcePath","m:FC_TargetPath"];tt.elements.Property.attributes=tt.elements.Property.attributes.concat(ka),tt.elements.EntityType.attributes=tt.elements.EntityType.attributes.concat(ka),tt.elements.Edmx={attributes:["Version"],elements:["DataServices"],ns:nf},tt.elements.DataServices={elements:["Schema*"],ns:nf},tt.elements.EntityContainer.attributes.push("m:IsDefaultEntityContainer"),tt.elements.Property.attributes.push("m:MimeType"),tt.elements.FunctionImport.attributes.push("m:HttpMethod"),tt.elements.FunctionImport.attributes.push("m:IsAlwaysBindable"),tt.elements.EntityType.attributes.push("m:HasStream"),tt.elements.DataServices.attributes=["m:DataServiceVersion","m:MaxDataServiceVersion"];var da=function(n){if(!n)return n;if(n.length>1){var t=n.substr(0,2);return t===t.toUpper
 Case()?n:n.charAt(0).toLowerCase()+n.substr(1)}return n.charAt(0).toLowerCase()},gg=function(n,t){var r,u,e,i,f,o;if(t==="Documentation")return{isArray:!0,propertyName:"documentation"};if(r=n.elements,!r)return null;for(u=0,e=r.length;u<e;u++)if(i=r[u],f=!1,i.charAt(i.length-1)==="*"&&(f=!0,i=i.substr(0,i.length-1)),t===i)return o=da(i),{isArray:f,propertyName:o};return null},nn=/^(m:FC_.*)_[0-9]+$/,ga=function(n){return n===vk||n===yk||n===pk||n===wk||n===bk||n===kk},to=function(n){var o=f(n),e=u(n),i=tt.elements[o];if(!i)return null;if(i.ns){if(e!==i.ns)return null}else if(!ga(e))return null;var t={},r=[],s=i.attributes||[];return wi(n,function(n){var c=f(n),e=u(n),l=n.value,i,o,h;e!==hr&&(i=null,o=!1,ga(e)||e===null?i="":e===nt&&(i="m:"),i!==null&&(i+=c,h=nn.exec(i),h&&(i=h[1]),er(s,i)&&(o=!0,t[da(c)]=l)),o||r.push(gt(n)))}),p(n,function(n){var o=f(n),u=gg(i,o),e;u?u.isArray?(e=t[u.propertyName],e||(e=[],t[u.propertyName]=e),e.push(to(n))):t[u.propertyName]=to(n):r.push(pr(n))}),
 i.text&&(t.text=k(n)),r.length&&(t.extensions=r),t},nv=function(n,i){var r=ou(i),u=b(r);return to(u)||t};r.metadataHandler=li(nv,null,gu,ci);var tv="o",io="f",iv="p",rv="c",uv="s",fv="l",tn="odata",ii=tn+".",rn="@"+ii+"bind",ro=ii+"metadata",ev=ii+"navigationLinkUrl",ir=ii+"type",rf={readLink:"self",editLink:"edit",nextLink:"__next",mediaReadLink:"media_src",mediaEditLink:"edit_media",mediaContentType:"content_type",mediaETag:"media_etag",count:"__count",media_src:"mediaReadLink",edit_media:"mediaEditLink",content_type:"mediaContentType",media_etag:"mediaETag",url:"uri"},h={metadata:"odata.metadata",count:"odata.count",next:"odata.nextLink",id:"odata.id",etag:"odata.etag",read:"odata.readLink",edit:"odata.editLink",mediaRead:"odata.mediaReadLink",mediaEdit:"odata.mediaEditLink",mediaEtag:"odata.mediaETag",mediaContentType:"odata.mediaContentType",actions:"odata.actions",functions:"odata.functions",navigationUrl:"odata.navigationLinkUrl",associationUrl:"odata.associationLinkUrl",type
 :"odata.type"},un=function(n){if(n.indexOf(".")>0){var t=n.indexOf("@"),r=t>-1?n.substring(0,t):null,i=n.substring(t+1);return{target:r,name:i,isOData:i.indexOf(ii)===0}}return null},uo=function(n,t,i,r,u){return d(t)&&t[ir]||i&&i[n+"@"+ir]||r&&r.type||bw(r,u)||null},fo=function(n,t){return t?wt(t.property,n)||wt(t.navigationProperty,n):null},ov=function(n){return d(n)&&ii+"id"in n},fn=function(n,t,i){if(!!t[n+"@"+ev]||i&&i.relationship)return!0;var r=e(t[n])?t[n][0]:t[n];return ov(r)},eo=function(n){return fe(n)||re(n)||ue(n)},ri=function(n,t,i,r,u){var f,e;for(f in n)if(f.indexOf(".")>0&&f.charAt(0)!=="#"&&(e=un(f),e)){var c=e.name,o=e.target,s=null,h=null;o&&(s=fo(o,r),h=uo(o,n[o],n,s,u)),e.isOData?en(c,o,h,n[f],n,t,i):t[f]=n[f]}return t},en=function(n,t,i,r,u,f,e){var o=n.substring(ii.length);switch(o){case"navigationLinkUrl":cn(o,t,i,r,u,f,e);return;case"nextLink":case"count":sn(o,t,r,f,e);return;case"mediaReadLink":case"mediaEditLink":case"mediaContentType":case"mediaETag":hn(
 o,t,i,r,f,e);return;default:on(o,t,r,f,e);return}},on=function(n,t,i,r,u){var f=r.__metadata=r.__metadata||{},e=rf[n]||n,s,o;if(n==="editLink"){f.uri=c(i,u),f[e]=f.uri;return}if((n==="readLink"||n==="associationLinkUrl")&&(i=c(i,u)),t){if(s=f.properties=f.properties||{},o=s[t]=s[t]||{},n==="type"){o[e]=o[e]||i;return}o[e]=i;return}f[e]=i},sn=function(n,t,i,r,u){var f=rf[n],e=t?r[t]:r;e[f]=n==="nextLink"?c(i,u):i},hn=function(n,t,i,r,u,f){var e=u.__metadata=u.__metadata||{},h=rf[n],o,s;if((n==="mediaReadLink"||n==="mediaEditLink")&&(r=c(r,f)),t){o=e.properties=e.properties||{},s=o[t]=o[t]||{},s.type=s.type||i,u.__metadata=e,u[t]=u[t]||{__mediaresource:{}},u[t].__mediaresource[h]=r;return}e[h]=r},cn=function(n,t,i,r,u,f,e){var s=f.__metadata=f.__metadata||{},h=s.properties=s.properties||{},o=h[t]=h[t]||{},l=c(r,e);if(u.hasOwnProperty(t)){o.navigationLinkUrl=l;return}f[t]={__deferred:{uri:l}},o.type=o.type||i},oo=function(n,t,i,r,u,f,o){if(typeof n=="string")return ln(n,t,o);if(!eo(t))
 {if(e(n))return sv(n,t,i,r,f,o);if(d(n))return an(n,t,i,r,f,o)}return n},ln=function(n,t,i){switch(t){case au:return ce(n);case cu:return wu(n,!1);case lu:return he(n,!1)}return i?wu(n,!0)||he(n,!0)||n:n},sv=function(n,t,i,r,u,f){for(var a=vu(t),o=[],h=[],e=0,c=n.length;e<c;e++){var s=uo(null,n[e])||a,l={type:s},v=oo(n[e],s,l,r,null,u,f);eo(s)||pu(n[e])||o.push(l),h.push(v)}return o.length>0&&(i.elements=o),{__metadata:{type:t},results:h}},an=function(n,t,i,r,u,f){var e=uf(n,{type:t},r,u,f),o=e.__metadata,s=o.properties;return s&&(i.properties=s,delete o.properties),e},vn=function(n,t,i,r,u){return e(n)?cv(n,t,i,r,u):d(n)?uf(n,t,i,r,u):null},uf=function(n,i,r,u,f){var d,v,g,o,y,h,c,nt;i=i||{};var l=n[ir]||i.type||null,s=bt(l,u),k=!0;s||(k=!1,s=gi(l,u));var p={type:l},a={__metadata:p},w={},e;if(k&&s&&i.entitySet&&i.contentTypeOdata=="minimalmetadata"){for(d=r.substring(0,r.lastIndexOf("$metadata")),e=null,s.key||(e=s);!!e&&!e.key&&e.baseType;)e=bt(e.baseType,u);(s.key||!!e&&e.key)&&(
 v=s.key?lv(n,s):lv(n,e),v&&(g={key:v,entitySet:i.entitySet,functionImport:i.functionImport,containerName:i.containerName},yn(n,g,l,d,s,e)))}for(o in n)if(o.indexOf("#")===0)hv(o.substring(1),n[o],a,r,u);else if(o.indexOf(".")===-1){for(p.properties||(p.properties=w),y=n[o],h=h=fo(o,s),e=s;!!s&&h===null&&e.baseType;)e=bt(e.baseType,u),h=h=fo(o,e);var tt=fn(o,n,h),b=uo(o,y,n,h,u),it=w[o]=w[o]||{type:b};tt?(c={},i.entitySet!==t&&(nt=kw(h,i.entitySet.name,u),c=dw(nt,u)),c.contentTypeOdata=i.contentTypeOdata,c.kind=i.kind,c.type=b,a[o]=vn(y,c,r,u,f)):a[o]=oo(y,b,it,r,h,u,f)}return ri(n,a,r,s,u)},hv=function(n,t,i,r,u){var f,s,g,nt;if(n&&(e(t)||d(t))){var l=!1,h=n.lastIndexOf("."),a=n.substring(h+1),v=h>-1?n.substring(0,h):"",y=a===n||v.indexOf(".")===-1?ic(u):rc(v,u);y&&(f=ww(y.functionImport,a),f&&!!f.isSideEffecting&&(l=!se(f.isSideEffecting)));for(var p=i.__metadata,w=l?"functions":"actions",tt=c(n,r),b=e(t)?t:[t],o=0,k=b.length;o<k;o++)s=b[o],s&&(g=p[w]=p[w]||[],nt={metadata:tt,title
 :s.title,target:c(s.target,r)},g.push(nt))}},cv=function(n,t,i,r,u){for(var h=e(n)?n:n.value,c=[],l,f,s,o=0,a=h.length;o<a;o++)l=uf(h[o],t,i,r,u),c.push(l);if(f={results:c},d(n)){for(s in n)s.indexOf("#")===0&&(f.__metadata=f.__metadata||{},hv(s.substring(1),n[s],f,i,r));f=ri(n,f,i)}return f},lv=function(n,t){var r,i=t.key.propertyRef,f,e,u;if(r="(",i.length==1)f=wt(t.property,i[0].name).type,r+=so(n[i[0].name],f);else for(e=!0,u=0;u<i.length;u++)e?e=!1:r+=",",f=wt(t.property,i[u].name).type,r+=i[u].name+"="+so(n[i[u].name],f);return r+=")"},yn=function(n,t,i,r,u,f){var o=n[h.id]||n[h.read]||n[h.edit]||t.entitySet.name+t.key,e;n[h.id]=r+o,n[h.edit]||(n[h.edit]=t.entitySet.name+t.key,t.entitySet.entityType!=i&&(n[h.edit]+="/"+i)),n[h.read]=n[h.read]||n[h.edit],n[h.etag]||(e=pn(n,u,f),!e||(n[h.etag]=e)),dn(n,u,f),wn(n,u,f),kn(n,t)},pn=function(n,t,i){for(var u="",f,r=0;t.property&&r<t.property.length;r++)f=t.property[r],u=av(n,u,f);if(i)for(r=0;i.property&&r<i.property.length;r++)f=i.
 property[r],u=av(n,u,f);return u.length>0?u+'"':null},av=function(n,t,i){return i.concurrencyMode=="Fixed"&&(t+=t.length>0?",":'W/"',t+=n[i.name]!==null?so(n[i.name],i.type):"null"),t},wn=function(n,i,r){for(var s="@odata.navigationLinkUrl",c="@odata.associationLinkUrl",u,e,o,f=0;i.navigationProperty&&f<i.navigationProperty.length;f++)u=i.navigationProperty[f].name,e=u+s,n[e]===t&&(n[e]=n[h.edit]+"/"+encodeURIComponent(u)),o=u+c,n[o]===t&&(n[o]=n[h.edit]+"/$links/"+encodeURIComponent(u));if(r&&r.navigationProperty)for(f=0;f<r.navigationProperty.length;f++)u=r.navigationProperty[f].name,e=u+s,n[e]===t&&(n[e]=n[h.edit]+"/"+encodeURIComponent(u)),o=u+c,n[o]===t&&(n[o]=n[h.edit]+"/$links/"+encodeURIComponent(u))},so=function(n,t){n=""+bn(n,t),n=encodeURIComponent(n.replace("'","''"));switch(t){case"Edm.Binary":return"X'"+n+"'";case"Edm.DateTime":return"datetime'"+n+"'";case"Edm.DateTimeOffset":return"datetimeoffset'"+n+"'";case"Edm.Decimal":return n+"M";case"Edm.Guid":return"guid'"+n+"'
 ";case"Edm.Int64":return n+"L";case"Edm.Float":return n+"f";case"Edm.Double":return n+"D";case"Edm.Geography":return"geography'"+n+"'";case"Edm.Geometry":return"geometry'"+n+"'";case"Edm.Time":return"time'"+n+"'";case"Edm.String":return"'"+n+"'";default:return n}},bn=function(n,t){switch(t){case"Edm.Binary":return cp(n);default:return n}},kn=function(n,i){for(var u=i.functionImport||[],f,r=0;r<u.length;r++)u[r].isBindable&&u[r].parameter[0]&&u[r].parameter[0].type==i.entitySet.entityType&&(f="#"+i.containerName+"."+u[r].name,n[f]==t&&(n[f]={title:u[r].name,target:n[h.edit]+"/"+u[r].name}))},dn=function(n,t,i){(t.hasStream||i&&i.hasStream)&&(n[h.mediaEdit]=n[h.mediaEdit]||n[h.mediaEdit]+"/$value",n[h.mediaRead]=n[h.mediaRead]||n[h.mediaEdit])},gn=function(n,t,i,r){var u={type:t},f=oo(n.value,t,u,i,null,null,r);return ri(n,{__metadata:u,value:f},i)},ntt=function(n,t,i,r,u){var f={},e=sv(n.value,t,f,i,r,u);return g(e.__metadata,f),ri(n,e,i)},ttt=function(n,t){var r=n.value,u,i,f,o;if(!
 e(r))return vv(n,t);for(u=[],i=0,f=r.length;i<f;i++)u.push(vv(r[i],t));return o={results:u},ri(n,o,t)},vv=function(n,t){var i={uri:c(n.url,t)},u,r;return i=ri(n,i,t),u=i.__metadata||{},r=u.properties||{},ff(r.url),ru(r,"url","uri"),i},ff=function(n){n&&delete n.type},itt=function(n,t){var o=n.value,s=[],h=ri(n,{collections:s},t),e=h.__metadata||{},i=e.properties||{},u,l,f,r;for(ff(i.value),ru(i,"value","collections"),u=0,l=o.length;u<l;u++)f=o[u],r={title:f.name,href:c(f.url,t)},r=ri(f,r,t),e=r.__metadata||{},i=e.properties||{},ff(i.name),ff(i.url),ru(i,"name","title"),ru(i,"url","href"),s.push(r);return{workspaces:[h]}},ui=function(n,t){return{kind:n,type:t||null}},rtt=function(n,t,i){var f=n[ro],s,v,o,y,l,r,p,h,c,w,b,u,k;if(!f||typeof f!="string")return null;if(s=f.lastIndexOf("#"),s===-1)return ui(uv);if(v=f.indexOf("@Element",s),o=v-1,o<0&&(o=f.indexOf("?",s),o===-1&&(o=f.length)),y=f.substring(s+1,o),y.indexOf("/$links/")>0)return ui(fv);if(l=y.split("/"),l.length>=0){if(r=l[0]
 ,p=l[1],eo(r))return ui(iv,r);if(yu(r))return ui(rv,r);if(h=p,!p){var d=r.lastIndexOf("."),g=r.substring(d+1),a=g===r?ic(t):rc(r.substring(0,d),t);a&&(c=pw(a.entitySet,g),w=a.functionImport,b=a.name,h=!c?null:c.entityType)}return v>0?(u=ui(tv,h),u.entitySet=c,u.functionImport=w,u.containerName=b,u):h?(u=ui(io,h),u.entitySet=c,u.functionImport=w,u.containerName=b,u):e(n.value)&&!gi(r,t)&&(k=n.value[0],!pu(k)&&(ov(k)||!i))?ui(io,null):ui(tv,r)}return null},utt=function(n,t,i,r,u){var e,f,o;if(!d(n))return n;if(u=u||"minimalmetadata",e=n[ro],f=rtt(n,t,r),ot(f)&&(f.contentTypeOdata=u),o=null,f){delete n[ro],o=f.type;switch(f.kind){case io:return cv(n,f,e,t,i);case rv:return ntt(n,o,e,t,i);case iv:return gn(n,o,e,i);case uv:return itt(n,e);case fv:return ttt(n,e)}}return uf(n,f,e,t,i)},yv=["type","etag","media_src","edit_media","content_type","media_etag"],pv=function(n,t){var u=/\/\$links\//,i={},r=n.__metadata,f=t&&u.test(t.request.requestUri);return ho(n,r&&r.properties,i,f),i},ftt=fu
 nction(n,t){var i,u,r,f;if(n)for(i=0,u=yv.length;i<u;i++)r=yv[i],f=ii+(rf[r]||r),dr(f,null,n[r],t)},ho=function(n,t,i,r){var u,f;for(u in n)f=n[u],u==="__metadata"?ftt(f,i):u.indexOf(".")===-1?r&&u==="uri"?ott(f,i):ett(u,f,t,i,r):i[u]=f},ett=function(n,i,r,u){var e=r&&r[n]||{properties:t,type:t},f=hs(i,e);if(pu(i)||!i){dr(ir,n,f,u),u[n]=i;return}if(vr(i,f)||gh(i)){ctt(n,i,u);return}if(!f&&dh(i)){stt(n,i,u);return}if(kh(i,f)){vu(f)&&dr(ir,n,f,u),htt(n,i,u);return}u[n]={},dr(ir,null,f,u[n]),ho(i,e.properties,u[n])},ott=function(n,t){t.url=n},stt=function(n,t,i){dr(ev,n,t.__deferred.uri,i)},htt=function(n,t,i){i[n]=[];var r=e(t)?t:t.results;ho(r,null,i[n])},ctt=function(n,t,i){if(vr(t)){i[n]=[];for(var u=e(t)?t:t.results,r=0,f=u.length;r<f;r++)wv(n,u[r],!0,i);return}wv(n,t,!1,i)},wv=function(n,t,i,r){var f=t.__metadata&&t.__metadata.uri,u;if(f){ltt(n,f,i,r);return}if(u=pv(t),i){r[n].push(u);return}r[n]=u},ltt=function(n,t,i,r){var u=n+rn;if(i){r[u]=r[u]||[],r[u].push(t);return}r[u]=t},
 dr=function(n,i,r,u){r!==t&&(i?u[i+"@"+n]=r:u[n]=r)},bv="application/json",kv=nr(bv),dv=function(n){var r=[],t,i,u;for(t in n)for(i=0,u=n[t].length;i<u;i++)r.push(g({metadata:t},n[t][i]));return r},att=function(n,t,i,r){var c,f,l,u,o,s,v,e,h,a;if(n&&typeof n=="object")if(f=n.__metadata,f&&(f.actions&&(f.actions=dv(f.actions)),f.functions&&(f.functions=dv(f.functions)),c=f&&f.type),l=bt(c,t)||gi(c,t),l){if(o=l.property,o)for(s=0,v=o.length;s<v;s++)if(e=o[s],h=e.name,u=n[h],e.type==="Edm.DateTime"||e.type==="Edm.DateTimeOffset"){if(u){if(u=i(u),!u)throw{message:"Invalid date/time value"};n[h]=u}}else e.type==="Edm.Time"&&(n[h]=ce(u))}else if(r)for(a in n)u=n[a],typeof u=="string"&&(n[a]=i(u)||u);return n},gv=function(n){if(n){var t=n.properties.odata;return t==="nometadata"||t==="minimalmetadata"||t==="fullmetadata"}return!1},vtt=function(n,t){for(var u={collections:[]},r,e,i=0,f=n.EntitySets.length;i<f;i++)r=n.EntitySets[i],e={title:r,href:c(r,t)},u.collections.push(e);return{workspa
 ces:[u]}},ytt=/^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/,ptt=function(n){var t,i;return n<0?(t="-",n=-n):t="+",i=Math.floor(n/60),n=n-60*i,t+a(i,2)+":"+a(n,2)},wtt=function(n){var i=n&&ytt.exec(n),t,r,u;if(i&&(t=new Date(s(i[1])),i[2]&&(r=s(i[3]),i[2]==="-"&&(r=-r),u=t.getUTCMinutes(),t.setUTCMinutes(u-r),t.__edmType="Edm.DateTimeOffset",t.__offset=ptt(r)),!isNaN(t.valueOf())))return t},btt=function(t,i,r){var f=it(r.recognizeDates,t.recognizeDates),h=it(r.inferJsonLightFeedAsObject,t.inferJsonLightFeedAsObject),e=r.metadata,o=r.dataServiceVersion,s=wtt,u=typeof i=="string"?n.JSON.parse(i):i;if(ct("3.0",o)===o){if(gv(r.contentType))return utt(u,e,f,h,r.contentType.properties.odata);s=wu}return u=ib(u.d,function(n,t){return att(t,e,s,f)}),u=nit(u,r.dataServiceVersion),gtt(u,r.response.requestUri)},ny=function(t){var i,r=Date.prototype.toJSON;try{Date.prototype.toJSON=function(){return ph(this)},i=n.JSON.stringify(t,dtt)}finally{Date.prototype.toJSON=r}return i},ktt=function(n,i,r){var e=r.
 dataServiceVersion||"1.0",o=it(r.useJsonLight,n.useJsonLight),u=r.contentType=r.contentType||kv,f;return u&&u.mediaType===kv.mediaType?(f=i,o||gv(u))?(r.dataServiceVersion=ct(e,"3.0"),f=pv(i,r),ny(f)):(ct("3.0",e)===e&&(u.properties.odata="verbose",r.contentType=u),ny(f)):t},dtt=function(n,t){return t&&t.__edmType==="Edm.Time"?wh(t):t},gtt=function(n,t){var i=d(n)&&!n.__metadata&&e(n.EntitySets);return i?vtt(n,t):n},nit=function(n,t){return t&&t.lastIndexOf(";")===t.length-1&&(t=t.substr(0,t.length-1)),t&&t!=="1.0"||e(n)&&(n={results:n}),n},ef=li(btt,ktt,bv,ci);ef.recognizeDates=!1,ef.useJsonLight=!1,ef.inferJsonLightFeedAsObject=!1,r.jsonHandler=ef;var gr="multipart/mixed",tit=/^HTTP\/1\.\d (\d{3}) (.*)$/i,iit=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/,co=function(){return Math.floor((1+Math.random())*65536).toString(16).substr(1)},ty=function(n){return n+co()+"-"+co()+"-"+co()},iy=function(n){return n.handler.partHandler},ry=function(n){var t=n.boundaries;return t[t.length-1]},ri
 t=function(n,t,i){var r=i.contentType.properties.boundary;return{__batchResponses:uy(t,{boundaries:[r],handlerContext:i})}},uit=function(n,t,i){var r=i.contentType=i.contentType||nr(gr);if(r.mediaType===gr)return fit(t,i)},uy=function(n,t){var f="--"+ry(t),u,o,s,r,e,i;for(of(n,t,f),rr(n,t),u=[];o!=="--"&&t.position<n.length;){if(s=fy(n,t),r=nr(s["Content-Type"]),r&&r.mediaType===gr){t.boundaries.push(r.properties.boundary);try{e=uy(n,t)}catch(h){h.response=ey(n,t,f),e=[h]}u.push({__changeResponses:e}),t.boundaries.pop(),of(n,t,"--"+ry(t))}else{if(!r||r.mediaType!=="application/http")throw{message:"invalid MIME part type "};rr(n,t),i=ey(n,t,f);try{i.statusCode>=200&&i.statusCode<=299?iy(t.handlerContext).read(i,t.handlerContext):i={message:"HTTP request failed",response:i}}catch(h){i=h}u.push(i)}o=n.substr(t.position,2),rr(n,t)}return u},fy=function(n,t){var r={},i,u,f;do f=t.position,u=rr(n,t),i=iit.exec(u),i!==null?r[i[1]]=i[2]:t.position=f;while(u&&i);return oe(r),r},ey=function(n
 ,t,i){var o=t.position,r=tit.exec(rr(n,t)),u,f,e;return r?(u=r[1],f=r[2],e=fy(n,t),rr(n,t)):t.position=o,{statusCode:u,statusText:f,headers:e,body:of(n,t,"\r\n"+i)}},rr=function(n,t){return of(n,t,"\r\n")},of=function(n,t,i){var u=t.position||0,r=n.length;if(i){if(r=n.indexOf(i,u),r===-1)return null;t.position=r+i.length}else t.position=r;return n.substring(u,r)},fit=function(n,t){var o;if(!aw(n))throw{message:"Data is not a batch object."};for(var r=ty("batch_"),f=n.__batchRequests,u="",i=0,e=f.length;i<e;i++)u+=sf(r,!1)+oy(f[i],t);return u+=sf(r,!0),o=t.contentType.properties,o.boundary=r,u},sf=function(n,t){var i="\r\n--"+n;return t&&(i+="--"),i+"\r\n"},oy=function(n,t,i){var s=n.__changeRequests,r,f,o,h,u;if(e(s)){if(i)throw{message:"Not Supported: change set nested in other change set"};for(f=ty("changeset_"),r="Content-Type: "+gr+"; boundary="+f+"\r\n",o=0,h=s.length;o<h;o++)r+=sf(f,!1)+oy(s[o],t,!0);r+=sf(f,!0)}else r="Content-Type: application/http\r\nContent-Transfer-Encodi
 ng: binary\r\n\r\n",u=g({},t),u.handler=li,u.request=n,u.contentType=null,sc(n,iy(t),u),r+=eit(n);return r},eit=function(n){var t=(n.method?n.method:"GET")+" "+n.requestUri+" HTTP/1.1\r\n",i;for(i in n.headers)n.headers[i]&&(t=t+i+": "+n.headers[i]+"\r\n");return t+="\r\n",n.body&&(t+=n.body),t};r.batchHandler=li(rit,uit,gr,ci),lo=[r.jsonHandler,r.atomHandler,r.xmlHandler,r.textHandler],ao=function(n,t,i){for(var r=0,u=lo.length;r<u&&!lo[r][n](t,i);r++);if(r===u)throw{message:"no handler for data"};},r.defaultSuccess=function(t){n.alert(n.JSON.stringify(t))},r.defaultError=uu,r.defaultHandler={read:function(n,t){n&&ot(n.body)&&n.headers["Content-Type"]&&ao("read",n,t)},write:function(n,t){ao("write",n,t)},maxDataServiceVersion:ci,accept:"application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1"},r.defaultMetadata=[],r.read=function(n,t,i,u,f,e){var o;return o=n instanceof String||typeof n=="string"?{requestUri:n}:n,r.request(o,t,i,u
 ,f,e)},r.request=function(n,t,i,u,f,e){t=t||r.defaultSuccess,i=i||r.defaultError,u=u||r.defaultHandler,f=f||r.defaultHttpClient,e=e||r.defaultMetadata,n.recognizeDates=it(n.recognizeDates,r.jsonHandler.recognizeDates),n.callbackParameterName=it(n.callbackParameterName,r.defaultHttpClient.callbackParameterName),n.formatQueryString=it(n.formatQueryString,r.defaultHttpClient.formatQueryString),n.enableJsonpCallback=it(n.enableJsonpCallback,r.defaultHttpClient.enableJsonpCallback),n.useJsonLight=it(n.useJsonLight,r.jsonHandler.enableJsonpCallback),n.inferJsonLightFeedAsObject=it(n.inferJsonLightFeedAsObject,r.jsonHandler.inferJsonLightFeedAsObject);var o={metadata:e,recognizeDates:n.recognizeDates,callbackParameterName:n.callbackParameterName,formatQueryString:n.formatQueryString,enableJsonpCallback:n.enableJsonpCallback,useJsonLight:n.useJsonLight,inferJsonLightFeedAsObject:n.inferJsonLightFeedAsObject};try{return sc(n,u,o),lw(n,t,i,u,f,o)}catch(s){i(s)}},r.parseMetadata=function(n){re
 turn nv(null,n)},r.batchHandler.partHandler=r.defaultHandler;var ft=null,oit=function(){var t={v:this.valueOf(),t:"[object Date]"},n;for(n in this)t[n]=this[n];return t},sit=function(n,t){var r,i;if(t&&t.t==="[object Date]"){r=new Date(t.v);for(i in t)i!=="t"&&i!=="v"&&(r[i]=t[i]);t=r}return t},hf=function(n,t){return n.name+"#!#"+t},sy=function(n,t){return t.replace(n.name+"#!#","")},y=function(n){this.name=n};y.create=function(t){if(y.isSupported())return ft=ft||n.localStorage,new y(t);throw{message:"Web Storage not supported by the browser"};},y.isSupported=function(){return!!n.localStorage},y.prototype.add=function(n,t,i,r){r=r||this.defaultError;var u=this;this.contains(n,function(f){f?o(r,{message:"key already exists",key:n}):u.addOrUpdate(n,t,i,r)},r)},y.prototype.addOrUpdate=function(i,r,u,f){var s,h,e;if(f=f||this.defaultError,i instanceof Array)f({message:"Array of keys not supported"});else{s=hf(this,i),h=Date.prototype.toJSON;try{e=r,e!==t&&(Date.prototype.toJSON=oit,e=n
 .JSON.stringify(r)),ft.setItem(s,e),o(u,i,r)}catch(c){c.code===22||c.number===2147942414?o(f,{name:"QUOTA_EXCEEDED_ERR",error:c}):o(f,c)}finally{Date.prototype.toJSON=h}}},y.prototype.clear=function(n,t){var i,r,u,f;t=t||this.defaultError;try{for(i=0,r=ft.length;r>0&&i<r;)u=ft.key(i),f=sy(this,u),u!==f?(ft.removeItem(u),r=ft.length):i++;o(n)}catch(e){o(t,e)}},y.prototype.close=function(){},y.prototype.contains=function(n,t,i){i=i||this.defaultError;try{var r=hf(this,n),u=ft.getItem(r);o(t,u!==null)}catch(f){o(i,f)}},y.prototype.defaultError=uu,y.prototype.getAllKeys=function(n,t){var r,i,e,u,f;t=t||this.defaultError,r=[];try{for(i=0,e=ft.length;i<e;i++)u=ft.key(i),f=sy(this,u),u!==f&&r.push(f);o(n,r)}catch(s){o(t,s)}},y.prototype.mechanism="dom",y.prototype.read=function(i,r,u){if(u=u||this.defaultError,i instanceof Array)u({message:"Array of keys not supported"});else try{var e=hf(this,i),f=ft.getItem(e);f=f!==null&&f!=="undefined"?n.JSON.parse(f,sit):t,o(r,i,f)}catch(s){o(u,s)}},y
 .prototype.remove=function(n,t,i){if(i=i||this.defaultError,n instanceof Array)i({message:"Batches not supported"});else try{var r=hf(this,n);ft.removeItem(r),o(t)}catch(u){o(i,u)}},y.prototype.update=function(n,t,i,r){r=r||this.defaultError;var u=this;this.contains(n,function(f){f?u.addOrUpdate(n,t,i,r):o(r,{message:"key not found",key:n})},r)};var hy=n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB||n.indexedDB,hit=n.IDBKeyRange||n.webkitIDBKeyRange,cy=n.IDBTransaction||n.webkitIDBTransaction||{},ly=cy.READ_ONLY||"readonly",ur=cy.READ_WRITE||"readwrite",vt=function(n,t){return function(i){var r=n||t,u,f;if(r){if(Object.prototype.toString.call(i)==="[object IDBDatabaseException]"){if(i.code===11){r({name:"QuotaExceededError",error:i});return}r(i);return}try{f=i.target.error||i,u=f.name}catch(e){u=i.type==="blocked"?"IndexedDBBlocked":"UnknownError"}r({name:u,error:i})}}},cit=function(n,t,i){var u=n.name,f="_datajs_"+u,r=hy.open(f);r.onblocked=i,r.onerror=i,r.onupgradeneeded=functio
 n(){var n=r.result;n.objectStoreNames.contains(u)||n.createObjectStore(u)},r.onsuccess=function(n){var f=r.result,e;if(!f.objectStoreNames.contains(u)){if("setVersion"in f){e=f.setVersion("1.0"),e.onsuccess=function(){var n=e.transaction;n.oncomplete=function(){t(f)},f.createObjectStore(u,null,!1)},e.onerror=i,e.onblocked=i;return}n.target.error={name:"DBSchemaMismatch"},i(n);return}f.onversionchange=function(n){n.target.close()},t(f)}},fi=function(n,t,i,r){var u=n.name,f=n.db,e=vt(r,n.defaultError);if(f){i(f.transaction(u,t));return}cit(n,function(r){n.db=r,i(r.transaction(u,t))},e)},w=function(n){this.name=n};w.create=function(n){if(w.isSupported())return new w(n);throw{message:"IndexedDB is not supported on this browser"};},w.isSupported=function(){return!!hy},w.prototype.add=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n instanceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,ur,function(s){s.onabort=vt(r,o,n,"add"),s.oncomplete=function(){n instanceof Array?i(u,f):i
 (n,t)};for(var h=0;h<u.length&&h<f.length;h++)s.objectStore(e).add({v:f[h]},u[h])},r)},w.prototype.addOrUpdate=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n instanceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,ur,function(s){var h,c;for(s.onabort=vt(r,o),s.oncomplete=function(){n instanceof Array?i(u,f):i(n,t)},h=0;h<u.length&&h<f.length;h++)c={v:f[h]},s.objectStore(e).put(c,u[h])},r)},w.prototype.clear=function(n,t){var i=this.name,r=this.defaultError;fi(this,ur,function(u){u.onerror=vt(t,r),u.oncomplete=function(){n()},u.objectStore(i).clear()},t)},w.prototype.close=function(){this.db&&(this.db.close(),this.db=null)},w.prototype.contains=function(n,t,i){var r=this.name,u=this.defaultError;fi(this,ly,function(f){var e=f.objectStore(r),o=e.get(n);f.oncomplete=function(){t(!!o.result)},f.onerror=vt(i,u)},i)},w.prototype.defaultError=uu,w.prototype.getAllKeys=function(n,t){var i=this.name,r=this.defaultError;fi(this,ur,function(u){var e=[],f;u.oncomplete=function(){n(e
 )},f=u.objectStore(i).openCursor(),f.onerror=vt(t,r),f.onsuccess=function(n){var t=n.target.result;t&&(e.push(t.key),t["continue"].call(t))}},t)},w.prototype.mechanism="indexeddb",w.prototype.read=function(n,i,r){var f=this.name,e=this.defaultError,u=n instanceof Array?n:[n];fi(this,ly,function(o){var h=[],s,c,l;for(o.onerror=vt(r,e,n,"read"),o.oncomplete=function(){n instanceof Array?i(u,h):i(u[0],h[0])},s=0;s<u.length;s++)c=o.objectStore(f),l=c.get.call(c,u[s]),l.onsuccess=function(n){var i=n.target.result;h.push(i?i.v:t)}},r)},w.prototype.remove=function(n,t,i){var u=this.name,f=this.defaultError,r=n instanceof Array?n:[n];fi(this,ur,function(n){var e,o;for(n.onerror=vt(i,f),n.oncomplete=function(){t()},e=0;e<r.length;e++)o=n.objectStore(u),o["delete"].call(o,r[e])},i)},w.prototype.update=function(n,t,i,r){var e=this.name,o=this.defaultError,u=[],f=[];n instanceof Array?(u=n,f=t):(u=[n],f=[t]),fi(this,ur,function(s){var h,c,l;for(s.onabort=vt(r,o),s.oncomplete=function(){n instan
 ceof Array?i(u,f):i(n,t)},h=0;h<u.length&&h<f.length;h++)c=s.objectStore(e).openCursor(hit.only(u[h])),l={v:f[h]},c.pair={key:u[h],value:l},c.onsuccess=function(n){var t=n.target.result;t?t.update(n.target.pair.value):s.abort()}},r)},ei=function(n){var e=[],r=[],i={},u,f;this.name=n,u=function(n){return n||this.defaultError},f=function(n,i){var r;return(n instanceof Array&&(r="Array of keys not supported"),(n===t||n===null)&&(r="Invalid key"),r)?(o(i,{message:r}),!1):!0},this.add=function(n,t,r,e){e=u(e),f(n,e)&&(i.hasOwnProperty(n)?e({message:"key already exists",key:n}):this.addOrUpdate(n,t,r,e))},this.addOrUpdate=function(n,s,h,c){if(c=u(c),f(n,c)){var l=i[n];l===t&&(l=e.length>0?e.splice(0,1):r.length),r[l]=s,i[n]=l,o(h,n,s)}},this.clear=function(n){r=[],i={},e=[],o(n)},this.contains=function(n,t){var r=i.hasOwnProperty(n);o(t,r)},this.getAllKeys=function(n){var t=[],r;for(r in i)t.push(r);o(n,t)},this.read=function(n,t,e){if(e=u(e),f(n,e)){var s=i[n];o(t,n,r[s])}},this.remove=f
 unction(n,s,h){if(h=u(h),f(n,h)){var c=i[n];c!==t&&(c===r.length-1?r.pop():(r[c]=t,e.push(c)),delete i[n],r.length===0&&(e=[])),o(s)}},this.update=function(n,t,r,e){e=u(e),f(n,e)&&(i.hasOwnProperty(n)?this.addOrUpdate(n,t,r,e):e({message:"key not found",key:n}))}},ei.create=function(n){return new ei(n)},ei.isSupported=function(){return!0},ei.prototype.close=function(){},ei.prototype.defaultError=uu,ei.prototype.mechanism="memory",ay={indexeddb:w,dom:y,memory:ei},yt.defaultStoreMechanism="best",yt.createStore=function(n,t){t||(t=yt.defaultStoreMechanism),t==="best"&&(t=y.isSupported()?"dom":"memory");var i=ay[t];if(i)return i.create(n);throw{message:"Failed to create store",name:n,mechanism:t};};var lit=function(n,t){var i=n.indexOf("?")>=0?"&":"?";return n+i+t},ait=function(n,t){var i=n.indexOf("?"),r="";return i>=0&&(r=n.substr(i),n=n.substr(0,i)),n[n.length-1]!=="/"&&(n+="/"),n+t+r},vy=function(n,t){return{method:"GET",requestUri:n,user:t.user,password:t.password,enableJsonpCallba
 ck:t.enableJsonpCallback,callbackParameterName:t.callbackParameterName,formatQueryString:t.formatQueryString}},git=function(n,t){var u=-1,r=n.indexOf("?"),i;return r!==-1&&(i=n.indexOf("?"+t+"=",r),i===-1&&(i=n.indexOf("&"+t+"=",r)),i!==-1&&(u=i+t.length+2)),u},vit=function(n,t,i,r){return yy(n,t,[],i,r)},yy=function(n,i,u,f,e){var s=vy(n,i),o=r.request(s,function(n){var t=n.__next,r=n.results;u=u.concat(r),t?o=yy(t,i,u,f,e):f(u)},e,t,i.httpClient,i.metadata);return{abort:function(){o.abort()}}},yit=function(n){var i=this,u=n.source;return i.identifier=op(encodeURI(decodeURI(u))),i.options=n,i.count=function(n,f){var e=i.options;return r.request(vy(ait(u,"$count"),e),function(t){var i=s(t.toString());isNaN(i)?f({message:"Count is NaN",count:i}):n(i)},f,t,e.httpClient,e.metadata)},i.read=function(n,t,r,f){var e="$skip="+n+"&$top="+t;return vit(lit(u,e),i.options,r,f)},i},pit=function(n,t){var r=wit(n,t),i,u;r&&(i=r.i-t.i,u=i+(n.c-n.d.length),n.d=n.d.concat(t.d.slice(i,u)))},wit=funct
 ion(n,t){var r=n.i+n.c,u=t.i+t.c,i=n.i>t.i?n.i:t.i,f=r<u?r:u,e;return f>=i&&(e={i:i,c:f-i}),e},py=function(n,i){if(n===t||typeof n!="number")throw{message:"'"+i+"' must be a number."};if(isNaN(n)||n<0||!isFinite(n))throw{message:"'"+i+"' must be greater than or equal to zero."};},bit=function(n,i){if(n!==t){if(typeof n!="number")throw{message:"'"+i+"' must be a number."};if(isNaN(n)||n<=0||!isFinite(n))throw{message:"'"+i+"' must be greater than zero."};}},wy=function(n,i){if(n!==t&&(typeof n!="number"||isNaN(n)||!isFinite(n)))throw{message:"'"+i+"' must be a number."};},vo=function(n,t){for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return n.splice(i,1),!0;return!1},by=function(n){var t=0,r=typeof n,i;if(r==="object"&&n)for(i in n)t+=i.length*2+by(n[i]);else t=r==="string"?n.length*2:8;return t},ky=function(n,t,i){return n=Math.floor(n/i)*i,t=Math.ceil((t+1)/i)*i,{i:n,c:t-n}},cf="destroy",vi="idle",dy="init",yo="read",po="prefetch",wo="write",nu="cancel",oi="end",bo="error",yi="start",
 gy="wait",np="clear",tu="done",iu="local",tp="save",ip="source",fr=function(n,t,i,r,u,f,e){var h,c,o=this,l,s;return o.p=t,o.i=r,o.c=u,o.d=f,o.s=yi,o.canceled=!1,o.pending=e,o.oncomplete=null,o.cancel=function(){if(i){var n=o.s;n!==bo&&n!==oi&&n!==nu&&(o.canceled=!0,s(nu,h))}},o.complete=function(){s(oi,h)},o.error=function(n){o.canceled||s(bo,n)},o.run=function(n){c=n,o.transition(o.s,h)},o.wait=function(n){s(gy,n)},l=function(t,i,r){switch(t){case yi:i!==dy&&n(o,t,i,r);break;case gy:n(o,t,i,r);break;case nu:n(o,t,i,r),o.fireCanceled(),s(oi);break;case bo:n(o,t,i,r),o.canceled=!0,o.fireRejected(r),s(oi);break;case oi:if(o.oncomplete)o.oncomplete(o);o.canceled||o.fireResolved(),n(o,t,i,r);break;default:n(o,t,i,r)}},s=function(n,t){o.s=n,h=t,l(n,c,t)},o.transition=s,o};fr.prototype.fireResolved=function(){var n=this.p;n&&(this.p=null,n.resolve(this.d))},fr.prototype.fireRejected=function(n){var t=this.p;t&&(this.p=null,t.reject(n))},fr.prototype.fireCanceled=function(){this.fireRejec
 ted({canceled:!0,message:"Operation canceled"})},rp=function(i){var it=dy,y={counts:0,netReads:0,prefetches:0,cacheReads:0},c=[],b=[],p=[],nt=0,l=!1,k=vf(i.cacheSize,1048576),a=0,h=0,d=0,tt=k===0,r=vf(i.pageSize,50),ut=vf(i.prefetchSize,r),ht="1.0",f,ft=0,w=i.source,v,u;typeof w=="string"&&(w=new yit(i)),w.options=i,v=yt.createStore(i.name,i.mechanism),u=this,u.onidle=i.idle,u.stats=y,u.count=function(){var n,i,t;if(f)throw f;return(n=hu(),i=!1,l)?(o(function(){n.resolve(a)}),n.promise()):(t=w.count(function(i){t=null,y.counts++,n.resolve(i)},function(r){t=null,n.reject(g(r,{canceled:i}))}),g(n.promise(),{cancel:function(){t&&(i=!0,t.abort(),t=null)}}))},u.clear=function(){if(f)throw f;if(c.length===0){var n=hu(),t=new fr(ii,n,!1);return et(t,c),n.promise()}return c[0].p},u.filterForward=function(n,t,i){return lt(n,t,i,!1)},u.filterBack=function(n,t,i){return lt(n,t,i,!0)},u.readRange=function(n,t){if(py(n,"index"),py(t,"count"),f)throw f;var i=hu(),r=new fr(ui,i,!0,n,t,[],0);return
  et(r,b),g(i.promise(),{cancel:function(){r.cancel()}})},u.ToObservable=u.toObservable=function(){if(!n.Rx||!n.Rx.Observable)throw{message:"Rx library not available - include rx.js"};if(f)throw f;return n.Rx.Observable.CreateWithDisposable(function(n){var t=!1,i=0,f=function(i){t||n.OnError(i)},e=function(o){if(!t){for(var s=0,h=o.length;s<h;s++)n.OnNext(o[s]);o.length<r?n.OnCompleted():(i+=r,u.readRange(i,r).then(e,f))}};return u.readRange(i,r).then(e,f),{Dispose:function(){t=!0}}})};var rt=function(n){return function(t){f={message:n,error:t};for(var i=0,r=b.length;i<r;i++)b[i].fireRejected(f);for(i=0,r=c.length;i<r;i++)c[i].fireRejected(f);b=c=null}},e=function(n){if(n!==it){it=n;for(var i=c.concat(b,p),t=0,r=i.length;t<r;t++)i[t].run(it)}},ct=function(){var n=new di;return v.clear(function(){nt=0,l=!1,a=0,h=0,d=0,tt=k===0,y={counts:0,netReads:0,prefetches:0,cacheReads:0},u.stats=y,v.close(),n.resolve()},function(t){n.reject(t)}),n},kt=function(n){var t=vo(c,n);t||(t=vo(b,n),t||vo
 (p,n)),ft--,e(vi)},dt=function(n){var t=new di,u=!1,i=w.read(n,r,function(i){var r={i:n,c:i.length,d:i};t.resolve(r)},function(n){t.reject(n)});return g(t,{cancel:function(){i&&(i.abort(),u=!0,i=null)}})},lt=function(n,t,i,e){if(n=s(n),t=s(t),isNaN(n))throw{message:"'index' must be a valid number.",index:n};if(isNaN(t))throw{message:"'count' must be a valid number.",count:t};if(f)throw f;n=Math.max(n,0);var h=hu(),o=[],a=!1,l=null,v=function(n,f){a||(t>=0&&o.length>=t?h.resolve(o):l=u.readRange(n,f).then(function(u){for(var l,a,y,p,s=0,c=u.length;s<c&&(t<0||o.length<t);s++)l=e?c-s-1:s,a=u[l],i(a)&&(y={index:n+l,item:a},e?o.unshift(y):o.push(y));!e&&u.length<f||e&&n<=0?h.resolve(o):(p=e?Math.max(n-r,0):n+f,v(p,r))},function(n){h.reject(n)}))},c=ky(n,n,r),y=e?c.i:n,p=e?n-c.i+1:c.i+c.c-n;return v(y,p),g(h.promise(),{cancel:function(){l&&l.cancel(),a=!0}})},at=function(){u.onidle&&ft===0&&u.onidle()},gt=function(n){if(!l&&ut!==0&&!tt&&(p.length===0||p[0]&&p[0].c!==-1)){var t=new fr(ri,n
 ull,!0,n,ut,null,ut);et(t,p)}},et=function(n,t){n.oncomplete=kt,t.push(n),ft++,n.run(it)},ni=function(n){var r=!1,i=g(new di,{cancel:function(){r=!0}}),u=vt(i,"Read page from store failure");return v.contains(n,function(f){if(!r){if(f){v.read(n,function(n,u){r||i.resolve(u!==t,u)},u);return}i.resolve(!1)}},u),i},ti=function(n,t){var e=!1,i=g(new di,{cancel:function(){e=!0}}),r=vt(i,"Save page to store failure"),u=function(){i.resolve(!0)},f;return t.c>0?(f=by(t),tt=k>=0&&k<nt+f,tt?u():v.addOrUpdate(n,t,function(){pt(t,f),st(u,r)},r)):(pt(t,0),st(u,r)),i},st=function(n,t){var i={actualCacheSize:nt,allDataLocal:l,cacheSize:k,collectionCount:a,highestSavedPage:h,highestSavedPageSize:d,pageSize:r,sourceId:w.identifier,version:ht};v.addOrUpdate("__settings",i,n,t)},vt=function(n){return function(){n.resolve(!1)}},pt=function(n,t){var i=n.c,u=n.i;i===0?h===u-r&&(a=h+d):(h=Math.max(h,u),h===u&&(d=i),nt+=t,i<r&&!a&&(a=u+i)),l||a!==h+d||(l=!0)},wt=function(n,t,i,r){var u=n.canceled&&t!==oi;r
 eturn u&&t===nu&&r&&r.cancel&&r.cancel(),u},ii=function(n,t,i){var r=n.transition;if(i!==cf)return e(cf),!0;switch(t){case yi:r(np);break;case oi:at();break;case np:ct().then(function(){n.complete()}),n.wait();break;default:return!1}return!0},ri=function(n,t,i,u){var o,f;if(!wt(n,t,i,u)){if(o=n.transition,i!==po)return i===cf?t!==nu&&n.cancel():i===vi&&e(po),!0;switch(t){case yi:p[0]===n&&o(iu,n.i);break;case tu:f=n.pending,f>0&&(f-=Math.min(f,u.c)),l||f===0||u.c<r||tt?n.complete():(n.pending=f,o(iu,u.i+r));break;default:return bt(n,t,i,u,!0)}}return!0},ui=function(n,t,i,u){var f,o,s;if(!wt(n,t,i,u)){if(f=n.transition,i!==yo&&t!==yi)return i===cf?t!==yi&&n.cancel():i!==wo&&e(yo),!0;switch(t){case yi:(i===vi||i===po)&&(e(yo),n.c>0?(o=ky(n.i,n.c,r),f(iu,o.i)):f(tu,n));break;case tu:pit(n,u),s=n.d.length,n.c===s||u.c<r?(y.cacheReads++,gt(u.i+u.c),n.complete()):f(iu,u.i+r);break;default:return bt(n,t,i,u,!1)}}return!0},bt=function(n,t,i,r,u){var s=n.error,o=n.transition,h=n.wait,f;switc
 h(t){case oi:at();break;case iu:f=ni(r).then(function(t,i){n.canceled||(t?o(tu,i):o(ip,r))});break;case ip:f=dt(r).then(function(t){n.canceled||(u?y.prefetches++:y.netReads++,o(tp,t))},s);break;case tp:i!==wo&&(e(wo),f=ti(r.i,r).then(function(t){n.canceled||(!t&&u&&(n.pending=0),o(tu,r)),e(vi)}));break;default:return!1}return f&&(n.canceled?f.cancel():n.s===t&&h(f)),!0};return v.read("__settings",function(n,t){if(ot(t)){var i=t.version;if(!i||i.indexOf("1.")!==0){rt("Unsupported cache store version "+i)();return}r!==t.pageSize||w.identifier!==t.sourceId?ct().then(function(){e(vi)},rt("Unable to clear store during initialization")):(nt=t.actualCacheSize,l=t.allDataLocal,k=t.cacheSize,a=t.collectionCount,h=t.highestSavedPage,d=t.highestSavedPageSize,ht=i,e(vi))}else st(function(){e(vi)},rt("Unable to write settings during initialization."))},rt("Unable to read settings from store.")),u},yt.createDataCache=function(n){if(bit(n.pageSize,"pageSize"),wy(n.cacheSize,"cacheSize"),wy(n.prefe
 tchSize,"prefetchSize"),!ot(n.name))throw{message:"Undefined or null name",options:n};if(!ot(n.source))throw{message:"Undefined source",options:n};return new rp(n)}})(this)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/scripts/tools.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/tools.js b/odatajs/demo/scripts/tools.js
index 7359f03..3d3f395 100644
--- a/odatajs/demo/scripts/tools.js
+++ b/odatajs/demo/scripts/tools.js
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 (function($) {
   $.fn.prettify = function(options) {
     return this.each(function() {

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/tester.html
----------------------------------------------------------------------
diff --git a/odatajs/demo/tester.html b/odatajs/demo/tester.html
index 512b9e1..2658d45 100644
--- a/odatajs/demo/tester.html
+++ b/odatajs/demo/tester.html
@@ -1,9 +1,29 @@
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
 <html>
     <head>
         <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
         <title>datajs startup perf test</title>
         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-        <script type="text/javascript" src="./scripts/odatajs-4.0.0-beta-01.js"></script>
+        <script type="text/javascript" src="./../build/lib/odatajs-4.0.0-beta-01-RC01.js"></script>
         <script type="text/javascript" src="./scripts/tools.js" ></script>
         <style type="text/css">
             .code{font-family:"Courier New",monospace;font-size:13px;line-height:18px;}
@@ -151,8 +171,7 @@
                 var metadataRequest =
                 {
                     headers: oHeaders,
-                    //requestUri: "http://services.odata.org/OData/OData.svc/$metadata",
-                    requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", //"http://localhost:6630/PrimitiveKeys.svc/$metadata",
+                    requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", 
                     data: null,
                 };
                 odatajs.oData.read(metadataRequest, metaDatasuccess, errorFunc,odatajs.oData.metadataHandler);
@@ -170,8 +189,8 @@
                 var metadataRequest =
                 {
                     headers: oHeaders,
-                    //requestUri: "http://services.odata.org/OData/OData.svc/$metadata",
-                    requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", //"http://localhost:6630/PrimitiveKeys.svc/$metadata",
+                    requestUri: "https://ldcigmd.wdf.sap.corp:44355/sap/bc/ds/odata/v4/$metadata", 
+                    //requestUri: "http://localhost:4002/tests/endpoints/FoodStoreDataServiceV4.svc/$metadata", 
                     data: null,
                 };
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/browserify_transforms/stripheader/package.json
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/browserify_transforms/stripheader/package.json b/odatajs/grunt-config/browserify_transforms/stripheader/package.json
index b8837af..a86cfca 100644
--- a/odatajs/grunt-config/browserify_transforms/stripheader/package.json
+++ b/odatajs/grunt-config/browserify_transforms/stripheader/package.json
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 {
   "name": "grunt-rat",
   "version": "0.0.1",

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/grunt-config/custom-tasks/rat/extern-tools/info.md
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/custom-tasks/rat/extern-tools/info.md b/odatajs/grunt-config/custom-tasks/rat/extern-tools/info.md
index 97fdb71..f925cb2 100644
--- a/odatajs/grunt-config/custom-tasks/rat/extern-tools/info.md
+++ b/odatajs/grunt-config/custom-tasks/rat/extern-tools/info.md
@@ -1,2 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 Place apache-rat-0.11.jar in ./apache-rat-0.11/apache-rat-0.11.jar.
 See ./../readme.md for details
\ No newline at end of file


[6/6] git commit: [OLINGO-429] add headers, extend rat module, remove dependencies

Posted by ko...@apache.org.
[OLINGO-429] add headers, extend rat module, remove dependencies


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/commit/733b57dd
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/733b57dd
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/733b57dd

Branch: refs/heads/master
Commit: 733b57dd808269cfa5fabe22e8f7b4bd735000fb
Parents: cf77b73
Author: Sven Kobler <sv...@sap.com>
Authored: Wed Sep 10 09:18:45 2014 +0200
Committer: Sven Kobler <sv...@sap.com>
Committed: Wed Sep 10 09:18:45 2014 +0200

----------------------------------------------------------------------
 odatajs/Gruntfile.js                            |    81 +-
 odatajs/JSLib.csproj                            |    19 +
 odatajs/JSLib.sln                               |     3 +-
 odatajs/Web.config                              |    19 +
 odatajs/demo/mypage.html                        |    28 -
 odatajs/demo/scripts/datajs-1.1.1.js            | 10710 -----------------
 odatajs/demo/scripts/datajs-1.1.1.min.js        |    14 -
 odatajs/demo/scripts/datajs-1.1.2.js            | 10577 ----------------
 odatajs/demo/scripts/datajs-1.1.2.min.js        |    13 -
 odatajs/demo/scripts/tools.js                   |    18 +
 odatajs/demo/tester.html                        |    29 +-
 .../stripheader/package.json                    |    18 +
 .../custom-tasks/rat/extern-tools/info.md       |    18 +
 .../grunt-config/custom-tasks/rat/package.json  |    19 +
 odatajs/grunt-config/custom-tasks/rat/readme.md |    18 +
 .../grunt-config/custom-tasks/rat/tasks/rat.js  |   123 +-
 odatajs/grunt-config/rat-config.js              |    51 +-
 odatajs/grunt-config/release.js                 |    25 +-
 odatajs/package.json                            |     4 +-
 odatajs/tests/common/djstest-browser.js         |     2 +-
 odatajs/tests/common/djstest.js                 |     2 +-
 odatajs/tests/e2etest/Test.html                 |     4 +-
 22 files changed, 337 insertions(+), 21458 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/Gruntfile.js
----------------------------------------------------------------------
diff --git a/odatajs/Gruntfile.js b/odatajs/Gruntfile.js
index d138ebf..58e0633 100644
--- a/odatajs/Gruntfile.js
+++ b/odatajs/Gruntfile.js
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 module.exports = function(grunt) {
   'use strict';
   var pkg = grunt.file.readJSON('package.json');
@@ -13,48 +31,39 @@ module.exports = function(grunt) {
     banner: grunt.file.read('src/banner.txt'),
     artifactname : artifactname,
 
-    browserify: { // convert code from nodejs style to browser style
+    "browserify": { // convert code from nodejs style to browser style
       src: {
-        files: { 'build/<%= artifactname %>.js': ['src/index.js'] },
+        files: { 'build/lib/<%= artifactname %>.js': ['src/index.js'] },
         options: { // remove apache license headers before contatenating
           transform: ['./grunt-config/browserify_transforms/stripheader/stripheader.js'], 
         }
       }
     },
-    uglify: { // uglify and minify the lib
+    "uglify": { // uglify and minify the lib
       options: {
         sourceMap : true,
-        sourceMapName : 'build/<%= artifactname %>.map',
+        sourceMapName : 'build/lib/<%= artifactname %>.map',
         sourceMapIncludeSources : true,
       },
       build: {
-        src: 'build/<%= artifactname %>.js',
-        dest: 'build/<%= artifactname %>.min.js'
+        src: 'build/lib/<%= artifactname %>.js',
+        dest: 'build/lib/<%= artifactname %>.min.js'
       }
     },
-    concat : { // add the apache license headers
+    "concat" : { // add the apache license headers
       options : {
         banner : '<%= banner %>'
       },
       licence: {
-        src: 'build/<%= artifactname %>.js',
-        dest: 'build/<%= artifactname %>.js',
+        src: 'build/lib/<%= artifactname %>.js',
+        dest: 'build/lib/<%= artifactname %>.js',
       },
       licence_min: {
-        src: 'build/<%= artifactname %>.min.js',
-        dest: 'build/<%= artifactname %>.min.js',
+        src: 'build/lib/<%= artifactname %>.min.js',
+        dest: 'build/lib/<%= artifactname %>.min.js',
       },
     },
-    'copy': { // copy odatajs library files to demo folder withch contains samples
-      forDemo: {
-        files: [{ 
-          expand: true, cwd: 'build/', filter: 'isFile',
-          src: ['<%= artifactname %>*.*'], 
-          dest: 'demo/scripts/' 
-        }]
-      }
-    },
-    'jsdoc' : { // generate documentation
+    "jsdoc" : { // generate documentation
         src : {
             src: ['src/**/*.js'], 
             options: { destination: 'build/doc-src', verbose : false }
@@ -64,24 +73,25 @@ module.exports = function(grunt) {
             options: { destination: 'build/doc-test', verbose : false }
         }
     },
-    'npm-clean': {
-      tmp: {
+    "npm-clean": {
+      options: {force: true},
+      "build": {
+        src: [ "build"],
+      },
+      "lib": {
+        src: [ "build/lib"]
+      },
+      "tmp": {
         src: [ "build/tmp"]
       },
-      doc: {
+      "doc": {
         src: ["build/doc"],
-          options: {
-            force: true
-          }
       },
       "doc-test": {
         src: ["build/doc-test"],
-          options: {
-              force: true
-            }
       },
     },
-    curl: {
+    "curl": {
       'license': {
         src: {
           url: 'http://apache.org/licenses/LICENSE-2.0.txt',
@@ -128,23 +138,22 @@ module.exports = function(grunt) {
 
   /*** E N D U S E R   T A S K S ***/
 
-  grunt.registerTask('clean', ['npm-clean:doc','npm-clean:tmp']);
+  grunt.registerTask('clean', ['npm-clean']);
 
   //    Runs the license header check to verify the any source file contains a license header
-  grunt.registerTask('license-check', ['custom-license-check']);
+  grunt.registerTask('license-check', ['rat:manual']);
 
   //    Create documentation in /build/doc
   grunt.registerTask('doc', ['clearEnv', 'jsdoc:src']);
   grunt.registerTask('doc-test', ['clearEnv', 'jsdoc:test']);
 
   //    Build the odatajs library
-  grunt.registerTask('build', ['browserify:src', 'uglify:build', 'concat','copy:forDemo']);
-
+  grunt.registerTask('build', ['clean:lib','browserify:src', 'uglify:build', 'concat']);
 
   grunt.registerTask('test-browser', ['configureProxies:test-browser', 'connect:test-browser']);
   grunt.registerTask('test-node', ['node-qunit:default-tests']);
   //grunt.registerTask('release', ['build','doc','compress']);
-  grunt.registerTask('update-legal', ['curl:license']);
+  //grunt.registerTask('update-legal', ['curl:license']);
 
   
 };

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/JSLib.csproj
----------------------------------------------------------------------
diff --git a/odatajs/JSLib.csproj b/odatajs/JSLib.csproj
index 27253b1..847691f 100644
--- a/odatajs/JSLib.csproj
+++ b/odatajs/JSLib.csproj
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */-->
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/JSLib.sln
----------------------------------------------------------------------
diff --git a/odatajs/JSLib.sln b/odatajs/JSLib.sln
index d265e52..61927d4 100644
--- a/odatajs/JSLib.sln
+++ b/odatajs/JSLib.sln
@@ -1,5 +1,4 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
+Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JSLib", "JSLib.csproj", "{73ADF1A7-613B-4679-885B-2AE4AFAA9A6A}"
 EndProject

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/Web.config
----------------------------------------------------------------------
diff --git a/odatajs/Web.config b/odatajs/Web.config
index e45c79e..5441da1 100644
--- a/odatajs/Web.config
+++ b/odatajs/Web.config
@@ -1,4 +1,23 @@
 <?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */-->
 <configuration>
   <system.web>
     <compilation debug="true" targetFramework="4.0">

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/mypage.html
----------------------------------------------------------------------
diff --git a/odatajs/demo/mypage.html b/odatajs/demo/mypage.html
deleted file mode 100644
index 16517a4..0000000
--- a/odatajs/demo/mypage.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-    <title>data js demo</title>
-    <script type="text/javascript" src="scripts/datajs-2.0.0.js"></script>
-    <script type="text/javascript" src="scripts/jquery-2.0.3.js"></script>
-    <script type="text/javascript" src="scripts/datajs_demo.js"></script>
-    <style type="text/css">.title { font-size: 30px;font-style: italic;}</style>
-</head>
-<body onload="run()"> 
-    <div>
-        <span class="title">Simple Read</span>
-        <pre id="simpleRead"></pre>
-    </div>
-    <div>
-        <span class="title">Simple Read With Metadata</span>
-        <pre id="simpleReadWithMetadata"></pre>
-    </div>
-    <div>
-        <span class="title">Simple Read with JSONP</span>
-        <pre id="simpleReadWithJSONP"></pre>
-    </div>
-    <div>
-        <span class="title">Metadata</span>
-        <pre id="metadata"></pre>
-    </div>
-</body>
-</html>


[3/6] [OLINGO-429] add headers, extend rat module, remove dependencies

Posted by ko...@apache.org.
http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/733b57dd/odatajs/demo/scripts/datajs-1.1.2.js
----------------------------------------------------------------------
diff --git a/odatajs/demo/scripts/datajs-1.1.2.js b/odatajs/demo/scripts/datajs-1.1.2.js
deleted file mode 100644
index 5040efc..0000000
--- a/odatajs/demo/scripts/datajs-1.1.2.js
+++ /dev/null
@@ -1,10577 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.
-// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal  in the Software without restriction, including without limitation the rights  to use, copy,
-// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-// WARRANTIES OF MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// odatajs.js
-
-(function (window, undefined) {
-
-    var datajs = window.odatajs || {};
-    var odata = window.OData || {};
-
-    // AMD support
-    if (typeof define === 'function' && define.amd) {
-        define('datajs', datajs);
-        define('OData', odata);
-    } else {
-        window.odatajs = datajs;
-        window.OData = odata;
-    }
-
-    odatajs.version = {
-        major: 1,
-        minor: 1,
-        build: 1
-    };
-
-
-    var activeXObject = function (progId) {
-        /// <summary>Creates a new ActiveXObject from the given progId.</summary>
-        /// <param name="progId" type="String" mayBeNull="false" optional="false">
-        ///    ProgId string of the desired ActiveXObject.
-        /// </param>
-        /// <remarks>
-        ///    This function throws whatever exception might occur during the creation
-        ///    of the ActiveXObject.
-        /// </remarks>
-        /// <returns type="Object">
-        ///     The ActiveXObject instance. Null if ActiveX is not supported by the
-        ///     browser.
-        /// </returns>
-        if (window.ActiveXObject) {
-            return new window.ActiveXObject(progId);
-        }
-        return null;
-    };
-
-    var assigned = function (value) {
-        /// <summary>Checks whether the specified value is different from null and undefined.</summary>
-        /// <param name="value" mayBeNull="true" optional="true">Value to check.</param>
-        /// <returns type="Boolean">true if the value is assigned; false otherwise.</returns>
-        return value !== null && value !== undefined;
-    };
-
-    var contains = function (arr, item) {
-        /// <summary>Checks whether the specified item is in the array.</summary>
-        /// <param name="arr" type="Array" optional="false" mayBeNull="false">Array to check in.</param>
-        /// <param name="item">Item to look for.</param>
-        /// <returns type="Boolean">true if the item is contained, false otherwise.</returns>
-
-        var i, len;
-        for (i = 0, len = arr.length; i < len; i++) {
-            if (arr[i] === item) {
-                return true;
-            }
-        }
-
-        return false;
-    };
-
-    var defined = function (a, b) {
-        /// <summary>Given two values, picks the first one that is not undefined.</summary>
-        /// <param name="a">First value.</param>
-        /// <param name="b">Second value.</param>
-        /// <returns>a if it's a defined value; else b.</returns>
-        return (a !== undefined) ? a : b;
-    };
-
-    var delay = function (callback) {
-        /// <summary>Delays the invocation of the specified function until execution unwinds.</summary>
-        /// <param name="callback" type="Function">Callback function.</param>
-        if (arguments.length === 1) {
-            window.setTimeout(callback, 0);
-            return;
-        }
-
-        var args = Array.prototype.slice.call(arguments, 1);
-        window.setTimeout(function () {
-            callback.apply(this, args);
-        }, 0);
-    };
-
-
-    var extend = function (target, values) {
-        /// <summary>Extends the target with the specified values.</summary>
-        /// <param name="target" type="Object">Object to add properties to.</param>
-        /// <param name="values" type="Object">Object with properties to add into target.</param>
-        /// <returns type="Object">The target object.</returns>
-
-        for (var name in values) {
-            target[name] = values[name];
-        }
-
-        return target;
-    };
-
-    var find = function (arr, callback) {
-        /// <summary>Returns the first item in the array that makes the callback function true.</summary>
-        /// <param name="arr" type="Array" optional="false" mayBeNull="true">Array to check in.</param>
-        /// <param name="callback" type="Function">Callback function to invoke once per item in the array.</param>
-        /// <returns>The first item that makes the callback return true; null otherwise or if the array is null.</returns>
-
-        if (arr) {
-            var i, len;
-            for (i = 0, len = arr.length; i < len; i++) {
-                if (callback(arr[i])) {
-                    return arr[i];
-                }
-            }
-        }
-        return null;
-    };
-
-    var isArray = function (value) {
-        /// <summary>Checks whether the specified value is an array object.</summary>
-        /// <param name="value">Value to check.</param>
-        /// <returns type="Boolean">true if the value is an array object; false otherwise.</returns>
-
-        return Object.prototype.toString.call(value) === "[object Array]";
-    };
-
-    var isDate = function (value) {
-        /// <summary>Checks whether the specified value is a Date object.</summary>
-        /// <param name="value">Value to check.</param>
-        /// <returns type="Boolean">true if the value is a Date object; false otherwise.</returns>
-
-        return Object.prototype.toString.call(value) === "[object Date]";
-    };
-
-    var isObject = function (value) {
-        /// <summary>Tests whether a value is an object.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <remarks>
-        ///     Per javascript rules, null and array values are objects and will cause this function to return true.
-        /// </remarks>
-        /// <returns type="Boolean">True is the value is an object; false otherwise.</returns>
-
-        return typeof value === "object";
-    };
-
-    var parseInt10 = function (value) {
-        /// <summary>Parses a value in base 10.</summary>
-        /// <param name="value" type="String">String value to parse.</param>
-        /// <returns type="Number">The parsed value, NaN if not a valid value.</returns>
-
-        return parseInt(value, 10);
-    };
-
-    var renameProperty = function (obj, oldName, newName) {
-        /// <summary>Renames a property in an object.</summary>
-        /// <param name="obj" type="Object">Object in which the property will be renamed.</param>
-        /// <param name="oldName" type="String">Name of the property that will be renamed.</param>
-        /// <param name="newName" type="String">New name of the property.</param>
-        /// <remarks>
-        ///    This function will not do anything if the object doesn't own a property with the specified old name.
-        /// </remarks>
-
-        if (obj.hasOwnProperty(oldName)) {
-            obj[newName] = obj[oldName];
-            delete obj[oldName];
-        }
-    };
-
-    var throwErrorCallback = function (error) {
-        /// <summary>Default error handler.</summary>
-        /// <param name="error" type="Object">Error to handle.</param>
-        throw error;
-    };
-
-    var trimString = function (str) {
-        /// <summary>Removes leading and trailing whitespaces from a string.</summary>
-        /// <param name="str" type="String" optional="false" mayBeNull="false">String to trim</param>
-        /// <returns type="String">The string with no leading or trailing whitespace.</returns>
-
-        if (str.trim) {
-            return str.trim();
-        }
-
-        return str.replace(/^\s+|\s+$/g, '');
-    };
-
-    var undefinedDefault = function (value, defaultValue) {
-        /// <summary>Returns a default value in place of undefined.</summary>
-        /// <param name="value" mayBeNull="true" optional="true">Value to check.</param>
-        /// <param name="defaultValue">Value to return if value is undefined.</param>
-        /// <returns>value if it's defined; defaultValue otherwise.</returns>
-        /// <remarks>
-        /// This should only be used for cases where falsy values are valid;
-        /// otherwise the pattern should be 'x = (value) ? value : defaultValue;'.
-        /// </remarks>
-        return (value !== undefined) ? value : defaultValue;
-    };
-
-    // Regular expression that splits a uri into its components:
-    // 0 - is the matched string.
-    // 1 - is the scheme.
-    // 2 - is the authority.
-    // 3 - is the path.
-    // 4 - is the query.
-    // 5 - is the fragment.
-    var uriRegEx = /^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#:]+)?(\?[^#]*)?(#.*)?/;
-    var uriPartNames = ["scheme", "authority", "path", "query", "fragment"];
-
-    var getURIInfo = function (uri) {
-        /// <summary>Gets information about the components of the specified URI.</summary>
-        /// <param name="uri" type="String">URI to get information from.</param>
-        /// <returns type="Object">
-        /// An object with an isAbsolute flag and part names (scheme, authority, etc.) if available.
-        /// </returns>
-
-        var result = { isAbsolute: false };
-
-        if (uri) {
-            var matches = uriRegEx.exec(uri);
-            if (matches) {
-                var i, len;
-                for (i = 0, len = uriPartNames.length; i < len; i++) {
-                    if (matches[i + 1]) {
-                        result[uriPartNames[i]] = matches[i + 1];
-                    }
-                }
-            }
-            if (result.scheme) {
-                result.isAbsolute = true;
-            }
-        }
-
-        return result;
-    };
-
-    var getURIFromInfo = function (uriInfo) {
-        /// <summary>Builds a URI string from its components.</summary>
-        /// <param name="uriInfo" type="Object"> An object with uri parts (scheme, authority, etc.).</param>
-        /// <returns type="String">URI string.</returns>
-
-        return "".concat(
-            uriInfo.scheme || "",
-            uriInfo.authority || "",
-            uriInfo.path || "",
-            uriInfo.query || "",
-            uriInfo.fragment || "");
-    };
-
-    // Regular expression that splits a uri authority into its subcomponents:
-    // 0 - is the matched string.
-    // 1 - is the userinfo subcomponent.
-    // 2 - is the host subcomponent.
-    // 3 - is the port component.
-    var uriAuthorityRegEx = /^\/{0,2}(?:([^@]*)@)?([^:]+)(?::{1}(\d+))?/;
-
-    // Regular expression that matches percentage enconded octects (i.e %20 or %3A);
-    var pctEncodingRegEx = /%[0-9A-F]{2}/ig;
-
-    var normalizeURICase = function (uri) {
-        /// <summary>Normalizes the casing of a URI.</summary>
-        /// <param name="uri" type="String">URI to normalize, absolute or relative.</param>
-        /// <returns type="String">The URI normalized to lower case.</returns>
-
-        var uriInfo = getURIInfo(uri);
-        var scheme = uriInfo.scheme;
-        var authority = uriInfo.authority;
-
-        if (scheme) {
-            uriInfo.scheme = scheme.toLowerCase();
-            if (authority) {
-                var matches = uriAuthorityRegEx.exec(authority);
-                if (matches) {
-                    uriInfo.authority = "//" +
-                    (matches[1] ? matches[1] + "@" : "") +
-                    (matches[2].toLowerCase()) +
-                    (matches[3] ? ":" + matches[3] : "");
-                }
-            }
-        }
-
-        uri = getURIFromInfo(uriInfo);
-
-        return uri.replace(pctEncodingRegEx, function (str) {
-            return str.toLowerCase();
-        });
-    };
-
-    var normalizeURI = function (uri, base) {
-        /// <summary>Normalizes a possibly relative URI with a base URI.</summary>
-        /// <param name="uri" type="String">URI to normalize, absolute or relative.</param>
-        /// <param name="base" type="String" mayBeNull="true">Base URI to compose with.</param>
-        /// <returns type="String">The composed URI if relative; the original one if absolute.</returns>
-
-        if (!base) {
-            return uri;
-        }
-
-        var uriInfo = getURIInfo(uri);
-        if (uriInfo.isAbsolute) {
-            return uri;
-        }
-
-        var baseInfo = getURIInfo(base);
-        var normInfo = {};
-        var path;
-
-        if (uriInfo.authority) {
-            normInfo.authority = uriInfo.authority;
-            path = uriInfo.path;
-            normInfo.query = uriInfo.query;
-        } else {
-            if (!uriInfo.path) {
-                path = baseInfo.path;
-                normInfo.query = uriInfo.query || baseInfo.query;
-            } else {
-                if (uriInfo.path.charAt(0) === '/') {
-                    path = uriInfo.path;
-                } else {
-                    path = mergeUriPathWithBase(uriInfo.path, baseInfo.path);
-                }
-                normInfo.query = uriInfo.query;
-            }
-            normInfo.authority = baseInfo.authority;
-        }
-
-        normInfo.path = removeDotsFromPath(path);
-
-        normInfo.scheme = baseInfo.scheme;
-        normInfo.fragment = uriInfo.fragment;
-
-        return getURIFromInfo(normInfo);
-    };
-
-    var mergeUriPathWithBase = function (uriPath, basePath) {
-        /// <summary>Merges the path of a relative URI and a base URI.</summary>
-        /// <param name="uriPath" type="String>Relative URI path.</param>
-        /// <param name="basePath" type="String">Base URI path.</param>
-        /// <returns type="String">A string with the merged path.</returns>
-
-        var path = "/";
-        var end;
-
-        if (basePath) {
-            end = basePath.lastIndexOf("/");
-            path = basePath.substring(0, end);
-
-            if (path.charAt(path.length - 1) !== "/") {
-                path = path + "/";
-            }
-        }
-
-        return path + uriPath;
-    };
-
-    var removeDotsFromPath = function (path) {
-        /// <summary>Removes the special folders . and .. from a URI's path.</summary>
-        /// <param name="path" type="string">URI path component.</param>
-        /// <returns type="String">Path without any . and .. folders.</returns>
-
-        var result = "";
-        var segment = "";
-        var end;
-
-        while (path) {
-            if (path.indexOf("..") === 0 || path.indexOf(".") === 0) {
-                path = path.replace(/^\.\.?\/?/g, "");
-            } else if (path.indexOf("/..") === 0) {
-                path = path.replace(/^\/\..\/?/g, "/");
-                end = result.lastIndexOf("/");
-                if (end === -1) {
-                    result = "";
-                } else {
-                    result = result.substring(0, end);
-                }
-            } else if (path.indexOf("/.") === 0) {
-                path = path.replace(/^\/\.\/?/g, "/");
-            } else {
-                segment = path;
-                end = path.indexOf("/", 1);
-                if (end !== -1) {
-                    segment = path.substring(0, end);
-                }
-                result = result + segment;
-                path = path.replace(segment, "");
-            }
-        }
-        return result;
-    };
-
-    var convertByteArrayToHexString = function (str) {
-        var arr = [];
-        if (window.atob === undefined) {
-            arr = decodeBase64(str);
-        } else {
-            var binaryStr = window.atob(str);
-            for (var i = 0; i < binaryStr.length; i++) {
-                arr.push(binaryStr.charCodeAt(i));
-            }
-        }
-        var hexValue = "";
-        var hexValues = "0123456789ABCDEF";
-        for (var j = 0; j < arr.length; j++) {
-            var t = arr[j];
-            hexValue += hexValues[t >> 4];
-            hexValue += hexValues[t & 0x0F];
-        }
-        return hexValue;
-    };
-
-    var decodeBase64 = function (str) {
-        var binaryString = "";
-        for (var i = 0; i < str.length; i++) {
-            var base65IndexValue = getBase64IndexValue(str[i]);
-            var binaryValue = "";
-            if (base65IndexValue !== null) {
-                binaryValue = base65IndexValue.toString(2);
-                binaryString += addBase64Padding(binaryValue);
-            }
-        }
-        var byteArray = [];
-        var numberOfBytes = parseInt(binaryString.length / 8, 10);
-        for (i = 0; i < numberOfBytes; i++) {
-            var intValue = parseInt(binaryString.substring(i * 8, (i + 1) * 8), 2);
-            byteArray.push(intValue);
-        }
-        return byteArray;
-    };
-
-    var getBase64IndexValue = function (character) {
-        var asciiCode = character.charCodeAt(0);
-        var asciiOfA = 65;
-        var differenceBetweenZanda = 6;
-        if (asciiCode >= 65 && asciiCode <= 90) {           // between "A" and "Z" inclusive
-            return asciiCode - asciiOfA;
-        } else if (asciiCode >= 97 && asciiCode <= 122) {   // between 'a' and 'z' inclusive
-            return asciiCode - asciiOfA - differenceBetweenZanda;
-        } else if (asciiCode >= 48 && asciiCode <= 57) {    // between '0' and '9' inclusive
-            return asciiCode + 4;
-        } else if (character == "+") {
-            return 62;
-        } else if (character == "/") {
-            return 63;
-        } else {
-            return null;
-        }
-    };
-
-    var addBase64Padding = function (binaryString) {
-        while (binaryString.length < 6) {
-            binaryString = "0" + binaryString;
-        }
-        return binaryString;
-    };
-
-
-    // URI prefixes to generate smaller code.
-    var http = "http://";
-    var w3org = http + "www.w3.org/";               // http://www.w3.org/
-
-    var xhtmlNS = w3org + "1999/xhtml";             // http://www.w3.org/1999/xhtml
-    var xmlnsNS = w3org + "2000/xmlns/";            // http://www.w3.org/2000/xmlns/
-    var xmlNS = w3org + "XML/1998/namespace";       // http://www.w3.org/XML/1998/namespace
-
-    var mozillaParserErroNS = http + "www.mozilla.org/newlayout/xml/parsererror.xml";
-
-    var hasLeadingOrTrailingWhitespace = function (text) {
-        /// <summary>Checks whether the specified string has leading or trailing spaces.</summary>
-        /// <param name="text" type="String">String to check.</param>
-        /// <returns type="Boolean">true if text has any leading or trailing whitespace; false otherwise.</returns>
-
-        var re = /(^\s)|(\s$)/;
-        return re.test(text);
-    };
-
-    var isWhitespace = function (text) {
-        /// <summary>Determines whether the specified text is empty or whitespace.</summary>
-        /// <param name="text" type="String">Value to inspect.</param>
-        /// <returns type="Boolean">true if the text value is empty or all whitespace; false otherwise.</returns>
-
-        var ws = /^\s*$/;
-        return text === null || ws.test(text);
-    };
-
-    var isWhitespacePreserveContext = function (domElement) {
-        /// <summary>Determines whether the specified element has xml:space='preserve' applied.</summary>
-        /// <param name="domElement">Element to inspect.</param>
-        /// <returns type="Boolean">Whether xml:space='preserve' is in effect.</returns>
-
-        while (domElement !== null && domElement.nodeType === 1) {
-            var val = xmlAttributeValue(domElement, "space", xmlNS);
-            if (val === "preserve") {
-                return true;
-            } else if (val === "default") {
-                break;
-            } else {
-                domElement = domElement.parentNode;
-            }
-        }
-
-        return false;
-    };
-
-    var isXmlNSDeclaration = function (domAttribute) {
-        /// <summary>Determines whether the attribute is a XML namespace declaration.</summary>
-        /// <param name="domAttribute">Element to inspect.</param>
-        /// <returns type="Boolean">
-        ///    True if the attribute is a namespace declaration (its name is 'xmlns' or starts with 'xmlns:'; false otherwise.
-        /// </returns>
-
-        var nodeName = domAttribute.nodeName;
-        return nodeName == "xmlns" || nodeName.indexOf("xmlns:") === 0;
-    };
-
-    var safeSetProperty = function (obj, name, value) {
-        /// <summary>Safely set as property in an object by invoking obj.setProperty.</summary>
-        /// <param name="obj">Object that exposes a setProperty method.</param>
-        /// <param name="name" type="String" mayBeNull="false">Property name.</param>
-        /// <param name="value">Property value.</param>
-
-        try {
-            obj.setProperty(name, value);
-        } catch (_) { }
-    };
-
-    var msXmlDom3 = function () {
-        /// <summary>Creates an configures new MSXML 3.0 ActiveX object.</summary>
-        /// <remakrs>
-        ///    This function throws any exception that occurs during the creation
-        ///    of the MSXML 3.0 ActiveX object.
-        /// <returns type="Object">New MSXML 3.0 ActiveX object.</returns>
-
-        var msxml3 = activeXObject("Msxml2.DOMDocument.3.0");
-        if (msxml3) {
-            safeSetProperty(msxml3, "ProhibitDTD", true);
-            safeSetProperty(msxml3, "MaxElementDepth", 256);
-            safeSetProperty(msxml3, "AllowDocumentFunction", false);
-            safeSetProperty(msxml3, "AllowXsltScript", false);
-        }
-        return msxml3;
-    };
-
-    var msXmlDom = function () {
-        /// <summary>Creates an configures new MSXML 6.0 or MSXML 3.0 ActiveX object.</summary>
-        /// <remakrs>
-        ///    This function will try to create a new MSXML 6.0 ActiveX object. If it fails then
-        ///    it will fallback to create a new MSXML 3.0 ActiveX object. Any exception that
-        ///    happens during the creation of the MSXML 6.0 will be handled by the function while
-        ///    the ones that happend during the creation of the MSXML 3.0 will be thrown.
-        /// <returns type="Object">New MSXML 3.0 ActiveX object.</returns>
-
-        try {
-            var msxml = activeXObject("Msxml2.DOMDocument.6.0");
-            if (msxml) {
-                msxml.async = true;
-            }
-            return msxml;
-        } catch (_) {
-            return msXmlDom3();
-        }
-    };
-
-    var msXmlParse = function (text) {
-        /// <summary>Parses an XML string using the MSXML DOM.</summary>
-        /// <remakrs>
-        ///    This function throws any exception that occurs during the creation
-        ///    of the MSXML ActiveX object.  It also will throw an exception
-        ///    in case of a parsing error.
-        /// <returns type="Object">New MSXML DOMDocument node representing the parsed XML string.</returns>
-
-        var dom = msXmlDom();
-        if (!dom) {
-            return null;
-        }
-
-        dom.loadXML(text);
-        var parseError = dom.parseError;
-        if (parseError.errorCode !== 0) {
-            xmlThrowParserError(parseError.reason, parseError.srcText, text);
-        }
-        return dom;
-    };
-
-    var xmlThrowParserError = function (exceptionOrReason, srcText, errorXmlText) {
-        /// <summary>Throws a new exception containing XML parsing error information.</summary>
-        /// <param name="exceptionOrReason">
-        ///    String indicatin the reason of the parsing failure or
-        ///    Object detailing the parsing error.
-        /// </param>
-        /// <param name="srcText" type="String">
-        ///    String indicating the part of the XML string that caused the parsing error.
-        /// </param>
-        /// <param name="errorXmlText" type="String">XML string for wich the parsing failed.</param>
-
-        if (typeof exceptionOrReason === "string") {
-            exceptionOrReason = { message: exceptionOrReason };
-        }
-        throw extend(exceptionOrReason, { srcText: srcText || "", errorXmlText: errorXmlText || "" });
-    };
-
-    var xmlParse = function (text) {
-        /// <summary>Returns an XML DOM document from the specified text.</summary>
-        /// <param name="text" type="String">Document text.</param>
-        /// <returns>XML DOM document.</returns>
-        /// <remarks>This function will throw an exception in case of a parse error.</remarks>
-
-        var domParser = window.DOMParser && new window.DOMParser();
-        var dom;
-
-        if (!domParser) {
-            dom = msXmlParse(text);
-            if (!dom) {
-                xmlThrowParserError("XML DOM parser not supported");
-            }
-            return dom;
-        }
-
-        try {
-            dom = domParser.parseFromString(text, "text/xml");
-        } catch (e) {
-            xmlThrowParserError(e, "", text);
-        }
-
-        var element = dom.documentElement;
-        var nsURI = element.namespaceURI;
-        var localName = xmlLocalName(element);
-
-        // Firefox reports errors by returing the DOM for an xml document describing the problem.
-        if (localName === "parsererror" && nsURI === mozillaParserErroNS) {
-            var srcTextElement = xmlFirstChildElement(element, mozillaParserErroNS, "sourcetext");
-            var srcText = srcTextElement ? xmlNodeValue(srcTextElement) : "";
-            xmlThrowParserError(xmlInnerText(element) || "", srcText, text);
-        }
-
-        // Chrome (and maybe other webkit based browsers) report errors by injecting a header with an error message.
-        // The error may be localized, so instead we simply check for a header as the
-        // top element or descendant child of the document.
-        if (localName === "h3" && nsURI === xhtmlNS || xmlFirstDescendantElement(element, xhtmlNS, "h3")) {
-            var reason = "";
-            var siblings = [];
-            var cursor = element.firstChild;
-            while (cursor) {
-                if (cursor.nodeType === 1) {
-                    reason += xmlInnerText(cursor) || "";
-                }
-                siblings.push(cursor.nextSibling);
-                cursor = cursor.firstChild || siblings.shift();
-            }
-            reason += xmlInnerText(element) || "";
-            xmlThrowParserError(reason, "", text);
-        }
-
-        return dom;
-    };
-
-    var xmlQualifiedName = function (prefix, name) {
-        /// <summary>Builds a XML qualified name string in the form of "prefix:name".</summary>
-        /// <param name="prefix" type="String" maybeNull="true">Prefix string.</param>
-        /// <param name="name" type="String">Name string to qualify with the prefix.</param>
-        /// <returns type="String">Qualified name.</returns>
-
-        return prefix ? prefix + ":" + name : name;
-    };
-
-    var xmlAppendText = function (domNode, textNode) {
-        /// <summary>Appends a text node into the specified DOM element node.</summary>
-        /// <param name="domNode">DOM node for the element.</param>
-        /// <param name="text" type="String" mayBeNull="false">Text to append as a child of element.</param>
-        if (hasLeadingOrTrailingWhitespace(textNode.data)) {
-            var attr = xmlAttributeNode(domNode, xmlNS, "space");
-            if (!attr) {
-                attr = xmlNewAttribute(domNode.ownerDocument, xmlNS, xmlQualifiedName("xml", "space"));
-                xmlAppendChild(domNode, attr);
-            }
-            attr.value = "preserve";
-        }
-        domNode.appendChild(textNode);
-        return domNode;
-    };
-
-    var xmlAttributes = function (element, onAttributeCallback) {
-        /// <summary>Iterates through the XML element's attributes and invokes the callback function for each one.</summary>
-        /// <param name="element">Wrapped element to iterate over.</param>
-        /// <param name="onAttributeCallback" type="Function">Callback function to invoke with wrapped attribute nodes.</param>
-
-        var attributes = element.attributes;
-        var i, len;
-        for (i = 0, len = attributes.length; i < len; i++) {
-            onAttributeCallback(attributes.item(i));
-        }
-    };
-
-    var xmlAttributeValue = function (domNode, localName, nsURI) {
-        /// <summary>Returns the value of a DOM element's attribute.</summary>
-        /// <param name="domNode">DOM node for the owning element.</param>
-        /// <param name="localName" type="String">Local name of the attribute.</param>
-        /// <param name="nsURI" type="String">Namespace URI of the attribute.</param>
-        /// <returns type="String" maybeNull="true">The attribute value, null if not found.</returns>
-
-        var attribute = xmlAttributeNode(domNode, localName, nsURI);
-        return attribute ? xmlNodeValue(attribute) : null;
-    };
-
-    var xmlAttributeNode = function (domNode, localName, nsURI) {
-        /// <summary>Gets an attribute node from a DOM element.</summary>
-        /// <param name="domNode">DOM node for the owning element.</param>
-        /// <param name="localName" type="String">Local name of the attribute.</param>
-        /// <param name="nsURI" type="String">Namespace URI of the attribute.</param>
-        /// <returns>The attribute node, null if not found.</returns>
-
-        var attributes = domNode.attributes;
-        if (attributes.getNamedItemNS) {
-            return attributes.getNamedItemNS(nsURI || null, localName);
-        }
-
-        return attributes.getQualifiedItem(localName, nsURI) || null;
-    };
-
-    var xmlBaseURI = function (domNode, baseURI) {
-        /// <summary>Gets the value of the xml:base attribute on the specified element.</summary>
-        /// <param name="domNode">Element to get xml:base attribute value from.</param>
-        /// <param name="baseURI" mayBeNull="true" optional="true">Base URI used to normalize the value of the xml:base attribute.</param>
-        /// <returns type="String">Value of the xml:base attribute if found; the baseURI or null otherwise.</returns>
-
-        var base = xmlAttributeNode(domNode, "base", xmlNS);
-        return (base ? normalizeURI(base.value, baseURI) : baseURI) || null;
-    };
-
-
-    var xmlChildElements = function (domNode, onElementCallback) {
-        /// <summary>Iterates through the XML element's child DOM elements and invokes the callback function for each one.</summary>
-        /// <param name="element">DOM Node containing the DOM elements to iterate over.</param>
-        /// <param name="onElementCallback" type="Function">Callback function to invoke for each child DOM element.</param>
-
-        xmlTraverse(domNode, /*recursive*/false, function (child) {
-            if (child.nodeType === 1) {
-                onElementCallback(child);
-            }
-            // continue traversing.
-            return true;
-        });
-    };
-
-    var xmlFindElementByPath = function (root, namespaceURI, path) {
-        /// <summary>Gets the descendant element under root that corresponds to the specified path and namespace URI.</summary>
-        /// <param name="root">DOM element node from which to get the descendant element.</param>
-        /// <param name="namespaceURI" type="String">The namespace URI of the element to match.</param>
-        /// <param name="path" type="String">Path to the desired descendant element.</param>
-        /// <returns>The element specified by path and namespace URI.</returns>
-        /// <remarks>
-        ///     All the elements in the path are matched against namespaceURI.
-        ///     The function will stop searching on the first element that doesn't match the namespace and the path.
-        /// </remarks>
-
-        var parts = path.split("/");
-        var i, len;
-        for (i = 0, len = parts.length; i < len; i++) {
-            root = root && xmlFirstChildElement(root, namespaceURI, parts[i]);
-        }
-        return root || null;
-    };
-
-    var xmlFindNodeByPath = function (root, namespaceURI, path) {
-        /// <summary>Gets the DOM element or DOM attribute node under root that corresponds to the specified path and namespace URI.</summary>
-        /// <param name="root">DOM element node from which to get the descendant node.</param>
-        /// <param name="namespaceURI" type="String">The namespace URI of the node to match.</param>
-        /// <param name="path" type="String">Path to the desired descendant node.</param>
-        /// <returns>The node specified by path and namespace URI.</returns>
-        /// <remarks>
-        ///     This function will traverse the path and match each node associated to a path segement against the namespace URI.
-        ///     The traversal stops when the whole path has been exahusted or a node that doesn't belogong the specified namespace is encountered.
-        ///
-        ///     The last segment of the path may be decorated with a starting @ character to indicate that the desired node is a DOM attribute.
-        /// </remarks>
-
-        var lastSegmentStart = path.lastIndexOf("/");
-        var nodePath = path.substring(lastSegmentStart + 1);
-        var parentPath = path.substring(0, lastSegmentStart);
-
-        var node = parentPath ? xmlFindElementByPath(root, namespaceURI, parentPath) : root;
-        if (node) {
-            if (nodePath.charAt(0) === "@") {
-                return xmlAttributeNode(node, nodePath.substring(1), namespaceURI);
-            }
-            return xmlFirstChildElement(node, namespaceURI, nodePath);
-        }
-        return null;
-    };
-
-    var xmlFirstChildElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the first child DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the child DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's first child DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/false);
-    };
-
-    var xmlFirstDescendantElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the descendant DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        if (domNode.getElementsByTagNameNS) {
-            var result = domNode.getElementsByTagNameNS(namespaceURI, localName);
-            return result.length > 0 ? result[0] : null;
-        }
-        return xmlFirstElementMaybeRecursive(domNode, namespaceURI, localName, /*recursive*/true);
-    };
-
-    var xmlFirstElementMaybeRecursive = function (domNode, namespaceURI, localName, recursive) {
-        /// <summary>Returns the first descendant DOM element under the specified DOM node that matches the specified namespace URI and local name.</summary>
-        /// <param name="domNode">DOM node from which the descendant DOM element is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <param name="recursive" type="Boolean">
-        ///     True if the search should include all the descendants of the DOM node.
-        ///     False if the search should be scoped only to the direct children of the DOM node.
-        /// </param>
-        /// <returns>The node's first descendant DOM element that matches the specified namespace URI and local name; null otherwise.</returns>
-
-        var firstElement = null;
-        xmlTraverse(domNode, recursive, function (child) {
-            if (child.nodeType === 1) {
-                var isExpectedNamespace = !namespaceURI || xmlNamespaceURI(child) === namespaceURI;
-                var isExpectedNodeName = !localName || xmlLocalName(child) === localName;
-
-                if (isExpectedNamespace && isExpectedNodeName) {
-                    firstElement = child;
-                }
-            }
-            return firstElement === null;
-        });
-        return firstElement;
-    };
-
-    var xmlInnerText = function (xmlElement) {
-        /// <summary>Gets the concatenated value of all immediate child text and CDATA nodes for the specified element.</summary>
-        /// <param name="domElement">Element to get values for.</param>
-        /// <returns type="String">Text for all direct children.</returns>
-
-        var result = null;
-        var root = (xmlElement.nodeType === 9 && xmlElement.documentElement) ? xmlElement.documentElement : xmlElement;
-        var whitespaceAlreadyRemoved = root.ownerDocument.preserveWhiteSpace === false;
-        var whitespacePreserveContext;
-
-        xmlTraverse(root, false, function (child) {
-            if (child.nodeType === 3 || child.nodeType === 4) {
-                // isElementContentWhitespace indicates that this is 'ignorable whitespace',
-                // but it's not defined by all browsers, and does not honor xml:space='preserve'
-                // in some implementations.
-                //
-                // If we can't tell either way, we walk up the tree to figure out whether
-                // xml:space is set to preserve; otherwise we discard pure-whitespace.
-                //
-                // For example <a>  <b>1</b></a>. The space between <a> and <b> is usually 'ignorable'.
-                var text = xmlNodeValue(child);
-                var shouldInclude = whitespaceAlreadyRemoved || !isWhitespace(text);
-                if (!shouldInclude) {
-                    // Walk up the tree to figure out whether we are in xml:space='preserve' context
-                    // for the cursor (needs to happen only once).
-                    if (whitespacePreserveContext === undefined) {
-                        whitespacePreserveContext = isWhitespacePreserveContext(root);
-                    }
-
-                    shouldInclude = whitespacePreserveContext;
-                }
-
-                if (shouldInclude) {
-                    if (!result) {
-                        result = text;
-                    } else {
-                        result += text;
-                    }
-                }
-            }
-            // Continue traversing?
-            return true;
-        });
-        return result;
-    };
-
-    var xmlLocalName = function (domNode) {
-        /// <summary>Returns the localName of a XML node.</summary>
-        /// <param name="domNode">DOM node to get the value from.</param>
-        /// <returns type="String">localName of domNode.</returns>
-
-        return domNode.localName || domNode.baseName;
-    };
-
-    var xmlNamespaceURI = function (domNode) {
-        /// <summary>Returns the namespace URI of a XML node.</summary>
-        /// <param name="node">DOM node to get the value from.</param>
-        /// <returns type="String">Namespace URI of domNode.</returns>
-
-        return domNode.namespaceURI || null;
-    };
-
-    var xmlNodeValue = function (domNode) {
-        /// <summary>Returns the value or the inner text of a XML node.</summary>
-        /// <param name="node">DOM node to get the value from.</param>
-        /// <returns>Value of the domNode or the inner text if domNode represents a DOM element node.</returns>
-        
-        if (domNode.nodeType === 1) {
-            return xmlInnerText(domNode);
-        }
-        return domNode.nodeValue;
-    };
-
-    var xmlTraverse = function (domNode, recursive, onChildCallback) {
-        /// <summary>Walks through the descendants of the domNode and invokes a callback for each node.</summary>
-        /// <param name="domNode">DOM node whose descendants are going to be traversed.</param>
-        /// <param name="recursive" type="Boolean">
-        ///    True if the traversal should include all the descenants of the DOM node.
-        ///    False if the traversal should be scoped only to the direct children of the DOM node.
-        /// </param>
-        /// <returns type="String">Namespace URI of node.</returns>
-
-        var subtrees = [];
-        var child = domNode.firstChild;
-        var proceed = true;
-        while (child && proceed) {
-            proceed = onChildCallback(child);
-            if (proceed) {
-                if (recursive && child.firstChild) {
-                    subtrees.push(child.firstChild);
-                }
-                child = child.nextSibling || subtrees.shift();
-            }
-        }
-    };
-
-    var xmlSiblingElement = function (domNode, namespaceURI, localName) {
-        /// <summary>Returns the next sibling DOM element of the specified DOM node.</summary>
-        /// <param name="domNode">DOM node from which the next sibling is going to be retrieved.</param>
-        /// <param name="namespaceURI" type="String" optional="true">The namespace URI of the element to match.</param>
-        /// <param name="localName" type="String" optional="true">Name of the element to match.</param>
-        /// <returns>The node's next sibling DOM element, null if there is none.</returns>
-
-        var sibling = domNode.nextSibling;
-        while (sibling) {
-            if (sibling.nodeType === 1) {
-                var isExpectedNamespace = !namespaceURI || xmlNamespaceURI(sibling) === namespaceURI;
-                var isExpectedNodeName = !localName || xmlLocalName(sibling) === localName;
-
-                if (isExpectedNamespace && isExpectedNodeName) {
-                    return sibling;
-                }
-            }
-            sibling = sibling.nextSibling;
-        }
-        return null;
-    };
-
-    var xmlDom = function () {
-        /// <summary>Creates a new empty DOM document node.</summary>
-        /// <returns>New DOM document node.</returns>
-        /// <remarks>
-        ///    This function will first try to create a native DOM document using
-        ///    the browsers createDocument function.  If the browser doesn't
-        ///    support this but supports ActiveXObject, then an attempt to create
-        ///    an MSXML 6.0 DOM will be made. If this attempt fails too, then an attempt
-        ///    for creating an MXSML 3.0 DOM will be made.  If this last attemp fails or
-        ///    the browser doesn't support ActiveXObject then an exception will be thrown.
-        /// </remarks>
-
-        var implementation = window.document.implementation;
-        return (implementation && implementation.createDocument) ?
-           implementation.createDocument(null, null, null) :
-           msXmlDom();
-    };
-
-    var xmlAppendChildren = function (parent, children) {
-        /// <summary>Appends a collection of child nodes or string values to a parent DOM node.</summary>
-        /// <param name="parent">DOM node to which the children will be appended.</param>
-        /// <param name="children" type="Array">Array containing DOM nodes or string values that will be appended to the parent.</param>
-        /// <returns>The parent with the appended children or string values.</returns>
-        /// <remarks>
-        ///    If a value in the children collection is a string, then a new DOM text node is going to be created
-        ///    for it and then appended to the parent.
-        /// </remarks>
-
-        if (!isArray(children)) {
-            return xmlAppendChild(parent, children);
-        }
-
-        var i, len;
-        for (i = 0, len = children.length; i < len; i++) {
-            children[i] && xmlAppendChild(parent, children[i]);
-        }
-        return parent;
-    };
-
-    var xmlAppendChild = function (parent, child) {
-        /// <summary>Appends a child node or a string value to a parent DOM node.</summary>
-        /// <param name="parent">DOM node to which the child will be appended.</param>
-        /// <param name="child">Child DOM node or string value to append to the parent.</param>
-        /// <returns>The parent with the appended child or string value.</returns>
-        /// <remarks>
-        ///    If child is a string value, then a new DOM text node is going to be created
-        ///    for it and then appended to the parent.
-        /// </remarks>
-
-        if (child) {
-            if (typeof child === "string") {
-                return xmlAppendText(parent, xmlNewText(parent.ownerDocument, child));
-            }
-            if (child.nodeType === 2) {
-                parent.setAttributeNodeNS ? parent.setAttributeNodeNS(child) : parent.setAttributeNode(child);
-            } else {
-                parent.appendChild(child);
-            }
-        }
-        return parent;
-    };
-
-    var xmlNewAttribute = function (dom, namespaceURI, qualifiedName, value) {
-        /// <summary>Creates a new DOM attribute node.</summary>
-        /// <param name="dom">DOM document used to create the attribute.</param>
-        /// <param name="prefix" type="String">Namespace prefix.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI.</param>
-        /// <returns>DOM attribute node for the namespace declaration.</returns>
-
-        var attribute =
-            dom.createAttributeNS && dom.createAttributeNS(namespaceURI, qualifiedName) ||
-            dom.createNode(2, qualifiedName, namespaceURI || undefined);
-
-        attribute.value = value || "";
-        return attribute;
-    };
-
-    var xmlNewElement = function (dom, nampespaceURI, qualifiedName, children) {
-        /// <summary>Creates a new DOM element node.</summary>
-        /// <param name="dom">DOM document used to create the DOM element.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI of the new DOM element.</param>
-        /// <param name="qualifiedName" type="String">Qualified name in the form of "prefix:name" of the new DOM element.</param>
-        /// <param name="children" type="Array" optional="true">
-        ///     Collection of child DOM nodes or string values that are going to be appended to the new DOM element.
-        /// </param>
-        /// <returns>New DOM element.</returns>
-        /// <remarks>
-        ///    If a value in the children collection is a string, then a new DOM text node is going to be created
-        ///    for it and then appended to the new DOM element.
-        /// </remarks>
-
-        var element =
-            dom.createElementNS && dom.createElementNS(nampespaceURI, qualifiedName) ||
-            dom.createNode(1, qualifiedName, nampespaceURI || undefined);
-
-        return xmlAppendChildren(element, children || []);
-    };
-
-    var xmlNewNSDeclaration = function (dom, namespaceURI, prefix) {
-        /// <summary>Creates a namespace declaration attribute.</summary>
-        /// <param name="dom">DOM document used to create the attribute.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI.</param>
-        /// <param name="prefix" type="String">Namespace prefix.</param>
-        /// <returns>DOM attribute node for the namespace declaration.</returns>
-
-        return xmlNewAttribute(dom, xmlnsNS, xmlQualifiedName("xmlns", prefix), namespaceURI);
-    };
-
-    var xmlNewFragment = function (dom, text) {
-        /// <summary>Creates a new DOM document fragment node for the specified xml text.</summary>
-        /// <param name="dom">DOM document from which the fragment node is going to be created.</param>
-        /// <param name="text" type="String" mayBeNull="false">XML text to be represented by the XmlFragment.</param>
-        /// <returns>New DOM document fragment object.</returns>
-
-        var value = "<c>" + text + "</c>";
-        var tempDom = xmlParse(value);
-        var tempRoot = tempDom.documentElement;
-        var imported = ("importNode" in dom) ? dom.importNode(tempRoot, true) : tempRoot;
-        var fragment = dom.createDocumentFragment();
-
-        var importedChild = imported.firstChild;
-        while (importedChild) {
-            fragment.appendChild(importedChild);
-            importedChild = importedChild.nextSibling;
-        }
-        return fragment;
-    };
-
-    var xmlNewText = function (dom, text) {
-        /// <summary>Creates new DOM text node.</summary>
-        /// <param name="dom">DOM document used to create the text node.</param>
-        /// <param name="text" type="String">Text value for the DOM text node.</param>
-        /// <returns>DOM text node.</returns>
-
-        return dom.createTextNode(text);
-    };
-
-    var xmlNewNodeByPath = function (dom, root, namespaceURI, prefix, path) {
-        /// <summary>Creates a new DOM element or DOM attribute node as specified by path and appends it to the DOM tree pointed by root.</summary>
-        /// <param name="dom">DOM document used to create the new node.</param>
-        /// <param name="root">DOM element node used as root of the subtree on which the new nodes are going to be created.</param>
-        /// <param name="namespaceURI" type="String">Namespace URI of the new DOM element or attribute.</param>
-        /// <param name="namespacePrefix" type="String">Prefix used to qualify the name of the new DOM element or attribute.</param>
-        /// <param name="Path" type="String">Path string describing the location of the new DOM element or attribute from the root element.</param>
-        /// <returns>DOM element or attribute node for the last segment of the path.</returns>
-        /// <remarks>
-        ///     This function will traverse the path and will create a new DOM element with the specified namespace URI and prefix
-        ///     for each segment that doesn't have a matching element under root.
-        ///
-        ///     The last segment of the path may be decorated with a starting @ character. In this case a new DOM attribute node
-        ///     will be created.
-        /// </remarks>
-
-        var name = "";
-        var parts = path.split("/");
-        var xmlFindNode = xmlFirstChildElement;
-        var xmlNewNode = xmlNewElement;
-        var xmlNode = root;
-
-        var i, len;
-        for (i = 0, len = parts.length; i < len; i++) {
-            name = parts[i];
-            if (name.charAt(0) === "@") {
-                name = name.substring(1);
-                xmlFindNode = xmlAttributeNode;
-                xmlNewNode = xmlNewAttribute;
-            }
-
-            var childNode = xmlFindNode(xmlNode, namespaceURI, name);
-            if (!childNode) {
-                childNode = xmlNewNode(dom, namespaceURI, xmlQualifiedName(prefix, name));
-                xmlAppendChild(xmlNode, childNode);
-            }
-            xmlNode = childNode;
-        }
-        return xmlNode;
-    };
-
-    var xmlSerialize = function (domNode) {
-        /// <summary>
-        /// Returns the text representation of the document to which the specified node belongs.
-        /// </summary>
-        /// <param name="root">Wrapped element in the document to serialize.</param>
-        /// <returns type="String">Serialized document.</returns>
-
-        var xmlSerializer = window.XMLSerializer;
-        if (xmlSerializer) {
-            var serializer = new xmlSerializer();
-            return serializer.serializeToString(domNode);
-        }
-
-        if (domNode.xml) {
-            return domNode.xml;
-        }
-
-        throw { message: "XML serialization unsupported" };
-    };
-
-    var xmlSerializeDescendants = function (domNode) {
-        /// <summary>Returns the XML representation of the all the descendants of the node.</summary>
-        /// <param name="domNode" optional="false" mayBeNull="false">Node to serialize.</param>
-        /// <returns type="String">The XML representation of all the descendants of the node.</returns>
-
-        var children = domNode.childNodes;
-        var i, len = children.length;
-        if (len === 0) {
-            return "";
-        }
-
-        // Some implementations of the XMLSerializer don't deal very well with fragments that
-        // don't have a DOMElement as their first child. The work around is to wrap all the
-        // nodes in a dummy root node named "c", serialize it and then just extract the text between
-        // the <c> and the </c> substrings.
-
-        var dom = domNode.ownerDocument;
-        var fragment = dom.createDocumentFragment();
-        var fragmentRoot = dom.createElement("c");
-
-        fragment.appendChild(fragmentRoot);
-        // Move the children to the fragment tree.
-        for (i = 0; i < len; i++) {
-            fragmentRoot.appendChild(children[i]);
-        }
-
-        var xml = xmlSerialize(fragment);
-        xml = xml.substr(3, xml.length - 7);
-
-        // Move the children back to the original dom tree.
-        for (i = 0; i < len; i++) {
-            domNode.appendChild(fragmentRoot.childNodes[i]);
-        }
-
-        return xml;
-    };
-
-    var xmlSerializeNode = function (domNode) {
-        /// <summary>Returns the XML representation of the node and all its descendants.</summary>
-        /// <param name="domNode" optional="false" mayBeNull="false">Node to serialize.</param>
-        /// <returns type="String">The XML representation of the node and all its descendants.</returns>
-
-        var xml = domNode.xml;
-        if (xml !== undefined) {
-            return xml;
-        }
-
-        if (window.XMLSerializer) {
-            var serializer = new window.XMLSerializer();
-            return serializer.serializeToString(domNode);
-        }
-
-        throw { message: "XML serialization unsupported" };
-    };
-
-
-
-
-    var forwardCall = function (thisValue, name, returnValue) {
-        /// <summary>Creates a new function to forward a call.</summary>
-        /// <param name="thisValue" type="Object">Value to use as the 'this' object.</param>
-        /// <param name="name" type="String">Name of function to forward to.</param>
-        /// <param name="returnValue" type="Object">Return value for the forward call (helps keep identity when chaining calls).</param>
-        /// <returns type="Function">A new function that will forward a call.</returns>
-
-        return function () {
-            thisValue[name].apply(thisValue, arguments);
-            return returnValue;
-        };
-    };
-
-    var DjsDeferred = function () {
-        /// <summary>Initializes a new DjsDeferred object.</summary>
-        /// <remarks>
-        /// Compability Note A - Ordering of callbacks through chained 'then' invocations
-        ///
-        /// The Wiki entry at http://wiki.commonjs.org/wiki/Promises/A
-        /// implies that .then() returns a distinct object.
-        ////
-        /// For compatibility with http://api.jquery.com/category/deferred-object/
-        /// we return this same object. This affects ordering, as
-        /// the jQuery version will fire callbacks in registration
-        /// order regardless of whether they occur on the result
-        /// or the original object.
-        ///
-        /// Compability Note B - Fulfillment value
-        ///
-        /// The Wiki entry at http://wiki.commonjs.org/wiki/Promises/A
-        /// implies that the result of a success callback is the
-        /// fulfillment value of the object and is received by
-        /// other success callbacks that are chained.
-        ///
-        /// For compatibility with http://api.jquery.com/category/deferred-object/
-        /// we disregard this value instead.
-        /// </remarks>
-
-        this._arguments = undefined;
-        this._done = undefined;
-        this._fail = undefined;
-        this._resolved = false;
-        this._rejected = false;
-    };
-
-    DjsDeferred.prototype = {
-        then: function (fulfilledHandler, errorHandler /*, progressHandler */) {
-            /// <summary>Adds success and error callbacks for this deferred object.</summary>
-            /// <param name="fulfilledHandler" type="Function" mayBeNull="true" optional="true">Success callback.</param>
-            /// <param name="errorHandler" type="Function" mayBeNull="true" optional="true">Error callback.</param>
-            /// <remarks>See Compatibility Note A.</remarks>
-
-            if (fulfilledHandler) {
-                if (!this._done) {
-                    this._done = [fulfilledHandler];
-                } else {
-                    this._done.push(fulfilledHandler);
-                }
-            }
-
-            if (errorHandler) {
-                if (!this._fail) {
-                    this._fail = [errorHandler];
-                } else {
-                    this._fail.push(errorHandler);
-                }
-            }
-
-            //// See Compatibility Note A in the DjsDeferred constructor.
-            //// if (!this._next) {
-            ////    this._next = createDeferred();
-            //// }
-            //// return this._next.promise();
-
-            if (this._resolved) {
-                this.resolve.apply(this, this._arguments);
-            } else if (this._rejected) {
-                this.reject.apply(this, this._arguments);
-            }
-
-            return this;
-        },
-
-        resolve: function (/* args */) {
-            /// <summary>Invokes success callbacks for this deferred object.</summary>
-            /// <remarks>All arguments are forwarded to success callbacks.</remarks>
-
-
-            if (this._done) {
-                var i, len;
-                for (i = 0, len = this._done.length; i < len; i++) {
-                    //// See Compability Note B - Fulfillment value.
-                    //// var nextValue =
-                    this._done[i].apply(null, arguments);
-                }
-
-                //// See Compatibility Note A in the DjsDeferred constructor.
-                //// this._next.resolve(nextValue);
-                //// delete this._next;
-
-                this._done = undefined;
-                this._resolved = false;
-                this._arguments = undefined;
-            } else {
-                this._resolved = true;
-                this._arguments = arguments;
-            }
-        },
-
-        reject: function (/* args */) {
-            /// <summary>Invokes error callbacks for this deferred object.</summary>
-            /// <remarks>All arguments are forwarded to error callbacks.</remarks>
-            if (this._fail) {
-                var i, len;
-                for (i = 0, len = this._fail.length; i < len; i++) {
-                    this._fail[i].apply(null, arguments);
-                }
-
-                this._fail = undefined;
-                this._rejected = false;
-                this._arguments = undefined;
-            } else {
-                this._rejected = true;
-                this._arguments = arguments;
-            }
-        },
-
-        promise: function () {
-            /// <summary>Returns a version of this object that has only the read-only methods available.</summary>
-            /// <returns>An object with only the promise object.</returns>
-
-            var result = {};
-            result.then = forwardCall(this, "then", result);
-            return result;
-        }
-    };
-
-    var createDeferred = function () {
-        /// <summary>Creates a deferred object.</summary>
-        /// <returns type="DjsDeferred">
-        /// A new deferred object. If jQuery is installed, then a jQuery
-        /// Deferred object is returned, which provides a superset of features.
-        /// </returns>
-
-        if (window.jQuery && window.jQuery.Deferred) {
-            return new window.jQuery.Deferred();
-        } else {
-            return new DjsDeferred();
-        }
-    };
-
-
-
-
-    var dataItemTypeName = function (value, metadata) {
-        /// <summary>Gets the type name of a data item value that belongs to a feed, an entry, a complex type property, or a collection property.</summary>
-        /// <param name="value">Value of the data item from which the type name is going to be retrieved.</param>
-        /// <param name="metadata" type="object" optional="true">Object containing metadata about the data tiem.</param>
-        /// <remarks>
-        ///    This function will first try to get the type name from the data item's value itself if it is an object with a __metadata property; otherwise
-        ///    it will try to recover it from the metadata.  If both attempts fail, it will return null.
-        /// </remarks>
-        /// <returns type="String">Data item type name; null if the type name cannot be found within the value or the metadata</returns>
-
-        var valueTypeName = ((value && value.__metadata) || {}).type;
-        return valueTypeName || (metadata ? metadata.type : null);
-    };
-
-    var EDM = "Edm.";
-    var EDM_BINARY = EDM + "Binary";
-    var EDM_BOOLEAN = EDM + "Boolean";
-    var EDM_BYTE = EDM + "Byte";
-    var EDM_DATETIME = EDM + "DateTime";
-    var EDM_DATETIMEOFFSET = EDM + "DateTimeOffset";
-    var EDM_DECIMAL = EDM + "Decimal";
-    var EDM_DOUBLE = EDM + "Double";
-    var EDM_GUID = EDM + "Guid";
-    var EDM_INT16 = EDM + "Int16";
-    var EDM_INT32 = EDM + "Int32";
-    var EDM_INT64 = EDM + "Int64";
-    var EDM_SBYTE = EDM + "SByte";
-    var EDM_SINGLE = EDM + "Single";
-    var EDM_STRING = EDM + "String";
-    var EDM_TIME = EDM + "Time";
-
-    var EDM_GEOGRAPHY = EDM + "Geography";
-    var EDM_GEOGRAPHY_POINT = EDM_GEOGRAPHY + "Point";
-    var EDM_GEOGRAPHY_LINESTRING = EDM_GEOGRAPHY + "LineString";
-    var EDM_GEOGRAPHY_POLYGON = EDM_GEOGRAPHY + "Polygon";
-    var EDM_GEOGRAPHY_COLLECTION = EDM_GEOGRAPHY + "Collection";
-    var EDM_GEOGRAPHY_MULTIPOLYGON = EDM_GEOGRAPHY + "MultiPolygon";
-    var EDM_GEOGRAPHY_MULTILINESTRING = EDM_GEOGRAPHY + "MultiLineString";
-    var EDM_GEOGRAPHY_MULTIPOINT = EDM_GEOGRAPHY + "MultiPoint";
-
-    var EDM_GEOMETRY = EDM + "Geometry";
-    var EDM_GEOMETRY_POINT = EDM_GEOMETRY + "Point";
-    var EDM_GEOMETRY_LINESTRING = EDM_GEOMETRY + "LineString";
-    var EDM_GEOMETRY_POLYGON = EDM_GEOMETRY + "Polygon";
-    var EDM_GEOMETRY_COLLECTION = EDM_GEOMETRY + "Collection";
-    var EDM_GEOMETRY_MULTIPOLYGON = EDM_GEOMETRY + "MultiPolygon";
-    var EDM_GEOMETRY_MULTILINESTRING = EDM_GEOMETRY + "MultiLineString";
-    var EDM_GEOMETRY_MULTIPOINT = EDM_GEOMETRY + "MultiPoint";
-
-    var GEOJSON_POINT = "Point";
-    var GEOJSON_LINESTRING = "LineString";
-    var GEOJSON_POLYGON = "Polygon";
-    var GEOJSON_MULTIPOINT = "MultiPoint";
-    var GEOJSON_MULTILINESTRING = "MultiLineString";
-    var GEOJSON_MULTIPOLYGON = "MultiPolygon";
-    var GEOJSON_GEOMETRYCOLLECTION = "GeometryCollection";
-
-    var primitiveEdmTypes = [
-        EDM_STRING,
-        EDM_INT32,
-        EDM_INT64,
-        EDM_BOOLEAN,
-        EDM_DOUBLE,
-        EDM_SINGLE,
-        EDM_DATETIME,
-        EDM_DATETIMEOFFSET,
-        EDM_TIME,
-        EDM_DECIMAL,
-        EDM_GUID,
-        EDM_BYTE,
-        EDM_INT16,
-        EDM_SBYTE,
-        EDM_BINARY
-    ];
-
-    var geometryEdmTypes = [
-        EDM_GEOMETRY,
-        EDM_GEOMETRY_POINT,
-        EDM_GEOMETRY_LINESTRING,
-        EDM_GEOMETRY_POLYGON,
-        EDM_GEOMETRY_COLLECTION,
-        EDM_GEOMETRY_MULTIPOLYGON,
-        EDM_GEOMETRY_MULTILINESTRING,
-        EDM_GEOMETRY_MULTIPOINT
-    ];
-
-    var geographyEdmTypes = [
-        EDM_GEOGRAPHY,
-        EDM_GEOGRAPHY_POINT,
-        EDM_GEOGRAPHY_LINESTRING,
-        EDM_GEOGRAPHY_POLYGON,
-        EDM_GEOGRAPHY_COLLECTION,
-        EDM_GEOGRAPHY_MULTIPOLYGON,
-        EDM_GEOGRAPHY_MULTILINESTRING,
-        EDM_GEOGRAPHY_MULTIPOINT
-    ];
-
-    var forEachSchema = function (metadata, callback) {
-        /// <summary>Invokes a function once per schema in metadata.</summary>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <param name="callback" type="Function">Callback function to invoke once per schema.</param>
-        /// <returns>
-        /// The first truthy value to be returned from the callback; null or the last falsy value otherwise.
-        /// </returns>
-
-        if (!metadata) {
-            return null;
-        }
-
-        if (isArray(metadata)) {
-            var i, len, result;
-            for (i = 0, len = metadata.length; i < len; i++) {
-                result = forEachSchema(metadata[i], callback);
-                if (result) {
-                    return result;
-                }
-            }
-
-            return null;
-        } else {
-            if (metadata.dataServices) {
-                return forEachSchema(metadata.dataServices.schema, callback);
-            }
-
-            return callback(metadata);
-        }
-    };
-
-    var formatMilliseconds = function (ms, ns) {
-        /// <summary>Formats a millisecond and a nanosecond value into a single string.</summary>
-        /// <param name="ms" type="Number" mayBeNull="false">Number of milliseconds to format.</param>
-        /// <param name="ns" type="Number" mayBeNull="false">Number of nanoseconds to format.</param>
-        /// <returns type="String">Formatted text.</returns>
-        /// <remarks>If the value is already as string it's returned as-is.</remarks>
-
-        // Avoid generating milliseconds if not necessary.
-        if (ms === 0) {
-            ms = "";
-        } else {
-            ms = "." + formatNumberWidth(ms.toString(), 3);
-        }
-        if (ns > 0) {
-            if (ms === "") {
-                ms = ".000";
-            }
-            ms += formatNumberWidth(ns.toString(), 4);
-        }
-        return ms;
-    };
-
-    var formatDateTimeOffset = function (value) {
-        /// <summary>Formats a DateTime or DateTimeOffset value a string.</summary>
-        /// <param name="value" type="Date" mayBeNull="false">Value to format.</param>
-        /// <returns type="String">Formatted text.</returns>
-        /// <remarks>If the value is already as string it's returned as-is.</remarks>
-
-        if (typeof value === "string") {
-            return value;
-        }
-
-        var hasOffset = isDateTimeOffset(value);
-        var offset = getCanonicalTimezone(value.__offset);
-        if (hasOffset && offset !== "Z") {
-            // We're about to change the value, so make a copy.
-            value = new Date(value.valueOf());
-
-            var timezone = parseTimezone(offset);
-            var hours = value.getUTCHours() + (timezone.d * timezone.h);
-            var minutes = value.getUTCMinutes() + (timezone.d * timezone.m);
-
-            value.setUTCHours(hours, minutes);
-        } else if (!hasOffset) {
-            // Don't suffix a 'Z' for Edm.DateTime values.
-            offset = "";
-        }
-
-        var year = value.getUTCFullYear();
-        var month = value.getUTCMonth() + 1;
-        var sign = "";
-        if (year <= 0) {
-            year = -(year - 1);
-            sign = "-";
-        }
-
-        var ms = formatMilliseconds(value.getUTCMilliseconds(), value.__ns);
-
-        return sign +
-            formatNumberWidth(year, 4) + "-" +
-            formatNumberWidth(month, 2) + "-" +
-            formatNumberWidth(value.getUTCDate(), 2) + "T" +
-            formatNumberWidth(value.getUTCHours(), 2) + ":" +
-            formatNumberWidth(value.getUTCMinutes(), 2) + ":" +
-            formatNumberWidth(value.getUTCSeconds(), 2) +
-            ms + offset;
-    };
-
-    var formatDuration = function (value) {
-        /// <summary>Converts a duration to a string in xsd:duration format.</summary>
-        /// <param name="value" type="Object">Object with ms and __edmType properties.</param>
-        /// <returns type="String">String representation of the time object in xsd:duration format.</returns>
-
-        var ms = value.ms;
-
-        var sign = "";
-        if (ms < 0) {
-            sign = "-";
-            ms = -ms;
-        }
-
-        var days = Math.floor(ms / 86400000);
-        ms -= 86400000 * days;
-        var hours = Math.floor(ms / 3600000);
-        ms -= 3600000 * hours;
-        var minutes = Math.floor(ms / 60000);
-        ms -= 60000 * minutes;
-        var seconds = Math.floor(ms / 1000);
-        ms -= seconds * 1000;
-
-        return sign + "P" +
-               formatNumberWidth(days, 2) + "DT" +
-               formatNumberWidth(hours, 2) + "H" +
-               formatNumberWidth(minutes, 2) + "M" +
-               formatNumberWidth(seconds, 2) +
-               formatMilliseconds(ms, value.ns) + "S";
-    };
-
-    var formatNumberWidth = function (value, width, append) {
-        /// <summary>Formats the specified value to the given width.</summary>
-        /// <param name="value" type="Number">Number to format (non-negative).</param>
-        /// <param name="width" type="Number">Minimum width for number.</param>
-        /// <param name="append" type="Boolean">Flag indicating if the value is padded at the beginning (false) or at the end (true).</param>
-        /// <returns type="String">Text representation.</returns>
-        var result = value.toString(10);
-        while (result.length < width) {
-            if (append) {
-                result += "0";
-            } else {
-                result = "0" + result;
-            }
-        }
-
-        return result;
-    };
-
-    var getCanonicalTimezone = function (timezone) {
-        /// <summary>Gets the canonical timezone representation.</summary>
-        /// <param name="timezone" type="String">Timezone representation.</param>
-        /// <returns type="String">An 'Z' string if the timezone is absent or 0; the timezone otherwise.</returns>
-
-        return (!timezone || timezone === "Z" || timezone === "+00:00" || timezone === "-00:00") ? "Z" : timezone;
-    };
-
-    var getCollectionType = function (typeName) {
-        /// <summary>Gets the type of a collection type name.</summary>
-        /// <param name="typeName" type="String">Type name of the collection.</param>
-        /// <returns type="String">Type of the collection; null if the type name is not a collection type.</returns>
-
-        if (typeof typeName === "string") {
-            var end = typeName.indexOf(")", 10);
-            if (typeName.indexOf("Collection(") === 0 && end > 0) {
-                return typeName.substring(11, end);
-            }
-        }
-        return null;
-    };
-
-    var invokeRequest = function (request, success, error, handler, httpClient, context) {
-        /// <summary>Sends a request containing OData payload to a server.</summary>
-        /// <param name="request">Object that represents the request to be sent..</param>
-        /// <param name="success">Callback for a successful read operation.</param>
-        /// <param name="error">Callback for handling errors.</param>
-        /// <param name="handler">Handler for data serialization.</param>
-        /// <param name="httpClient">HTTP client layer.</param>
-        /// <param name="context">Context used for processing the request</param>
-
-        return httpClient.request(request, function (response) {
-            try {
-                if (response.headers) {
-                    normalizeHeaders(response.headers);
-                }
-
-                if (response.data === undefined && response.statusCode !== 204) {
-                    handler.read(response, context);
-                }
-            } catch (err) {
-                if (err.request === undefined) {
-                    err.request = request;
-                }
-                if (err.response === undefined) {
-                    err.response = response;
-                }
-                error(err);
-                return;
-            }
-
-            success(response.data, response);
-        }, error);
-    };
-
-    var isBatch = function (value) {
-        /// <summary>Tests whether a value is a batch object in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a batch object; false otherwise.</returns>
-
-        return isComplex(value) && isArray(value.__batchRequests);
-    };
-
-    // Regular expression used for testing and parsing for a collection type.
-    var collectionTypeRE = /Collection\((.*)\)/;
-
-    var isCollection = function (value, typeName) {
-        /// <summary>Tests whether a value is a collection value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <param name="typeName" type="Sting">Type name of the value. This is used to disambiguate from a collection property value.</param>
-        /// <returns type="Boolean">True is the value is a feed value; false otherwise.</returns>
-
-        var colData = value && value.results || value;
-        return !!colData &&
-            (isCollectionType(typeName)) ||
-            (!typeName && isArray(colData) && !isComplex(colData[0]));
-    };
-
-    var isCollectionType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a collection type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is the name of a collection type; false otherwise.</returns>
-        return collectionTypeRE.test(typeName);
-    };
-
-    var isComplex = function (value) {
-        /// <summary>Tests whether a value is a complex type value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a complex type value; false otherwise.</returns>
-
-        return !!value &&
-            isObject(value) &&
-            !isArray(value) &&
-            !isDate(value);
-    };
-
-    var isDateTimeOffset = function (value) {
-        /// <summary>Checks whether a Date object is DateTimeOffset value</summary>
-        /// <param name="value" type="Date" mayBeNull="false">Value to check.</param>
-        /// <returns type="Boolean">true if the value is a DateTimeOffset, false otherwise.</returns>
-        return (value.__edmType === "Edm.DateTimeOffset" || (!value.__edmType && value.__offset));
-    };
-
-    var isDeferred = function (value) {
-        /// <summary>Tests whether a value is a deferred navigation property in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a deferred navigation property; false otherwise.</returns>
-
-        if (!value && !isComplex(value)) {
-            return false;
-        }
-        var metadata = value.__metadata || {};
-        var deferred = value.__deferred || {};
-        return !metadata.type && !!deferred.uri;
-    };
-
-    var isEntry = function (value) {
-        /// <summary>Tests whether a value is an entry object in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is an entry object; false otherwise.</returns>
-
-        return isComplex(value) && value.__metadata && "uri" in value.__metadata;
-    };
-
-    var isFeed = function (value, typeName) {
-        /// <summary>Tests whether a value is a feed value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <param name="typeName" type="Sting">Type name of the value. This is used to disambiguate from a collection property value.</param>
-        /// <returns type="Boolean">True is the value is a feed value; false otherwise.</returns>
-
-        var feedData = value && value.results || value;
-        return isArray(feedData) && (
-            (!isCollectionType(typeName)) &&
-            (isComplex(feedData[0]))
-        );
-    };
-
-    var isGeographyEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a geography EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a geography EDM type; false otherwise.</returns>
-
-        return contains(geographyEdmTypes, typeName);
-    };
-
-    var isGeometryEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a geometry EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a geometry EDM type; false otherwise.</returns>
-
-        return contains(geometryEdmTypes, typeName);
-    };
-
-    var isNamedStream = function (value) {
-        /// <summary>Tests whether a value is a named stream value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <returns type="Boolean">True is the value is a named stream; false otherwise.</returns>
-
-        if (!value && !isComplex(value)) {
-            return false;
-        }
-        var metadata = value.__metadata;
-        var mediaResource = value.__mediaresource;
-        return !metadata && !!mediaResource && !!mediaResource.media_src;
-    };
-
-    var isPrimitive = function (value) {
-        /// <summary>Tests whether a value is a primitive type value in the library's internal representation.</summary>
-        /// <param name="value">Value to test.</param>
-        /// <remarks>
-        ///    Date objects are considered primitive types by the library.
-        /// </remarks>
-        /// <returns type="Boolean">True is the value is a primitive type value.</returns>
-
-        return isDate(value) ||
-            typeof value === "string" ||
-            typeof value === "number" ||
-            typeof value === "boolean";
-    };
-
-    var isPrimitiveEdmType = function (typeName) {
-        /// <summary>Checks whether the specified type name is a primitive EDM type.</summary>
-        /// <param name="typeName" type="String">Name of type to check.</param>
-        /// <returns type="Boolean">True if the type is a primitive EDM type; false otherwise.</returns>
-
-        return contains(primitiveEdmTypes, typeName);
-    };
-
-    var navigationPropertyKind = function (value, propertyModel) {
-        /// <summary>Gets the kind of a navigation property value.</summary>
-        /// <param name="value">Value of the navigation property.</param>
-        /// <param name="propertyModel" type="Object" optional="true">
-        ///     Object that describes the navigation property in an OData conceptual schema.
-        /// </param>
-        /// <remarks>
-        ///     The returned string is as follows
-        /// </remarks>
-        /// <returns type="String">String value describing the kind of the navigation property; null if the kind cannot be determined.</returns>
-
-        if (isDeferred(value)) {
-            return "deferred";
-        }
-        if (isEntry(value)) {
-            return "entry";
-        }
-        if (isFeed(value)) {
-            return "feed";
-        }
-        if (propertyModel && propertyModel.relationship) {
-            if (value === null || value === undefined || !isFeed(value)) {
-                return "entry";
-            }
-            return "feed";
-        }
-        return null;
-    };
-
-    var lookupProperty = function (properties, name) {
-        /// <summary>Looks up a property by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of property objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The property object; null if not found.</returns>
-
-        return find(properties, function (property) {
-            return property.name === name;
-        });
-    };
-
-    var lookupInMetadata = function (name, metadata, kind) {
-        /// <summary>Looks up a type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <param name="kind" type="String">Kind of object to look for as per EDM metadata.</param>
-        /// <returns>An type description if the name is found; null otherwise.</returns>
-
-        return (name) ? forEachSchema(metadata, function (schema) {
-            return lookupInSchema(name, schema, kind);
-        }) : null;
-    };
-
-    var lookupEntitySet = function (entitySets, name) {
-        /// <summary>Looks up a entity set by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of entity set objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The entity set object; null if not found.</returns>
-
-        return find(entitySets, function (entitySet) {
-            return entitySet.name === name;
-        });
-    };
-
-    var lookupComplexType = function (name, metadata) {
-        /// <summary>Looks up a complex type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>A complex type description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "complexType");
-    };
-
-    var lookupEntityType = function (name, metadata) {
-        /// <summary>Looks up an entity type object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity type description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "entityType");
-    };
-
-    var lookupDefaultEntityContainer = function (metadata) {
-        /// <summary>Looks up an</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity container description if the name is found; null otherwise.</returns>
-
-        return forEachSchema(metadata, function (schema) {
-            return find(schema.entityContainer, function (container) {
-                return parseBool(container.isDefaultEntityContainer);
-            });
-        });
-    };
-
-    var lookupEntityContainer = function (name, metadata) {
-        /// <summary>Looks up an entity container object by name.</summary>
-        /// <param name="name" type="String">Name, possibly null or empty.</param>
-        /// <param name="metadata">Metadata store; one of edmx, schema, or an array of any of them.</param>
-        /// <returns>An entity container description if the name is found; null otherwise.</returns>
-
-        return lookupInMetadata(name, metadata, "entityContainer");
-    };
-
-    var lookupFunctionImport = function (functionImports, name) {
-        /// <summary>Looks up a function import by name.</summary>
-        /// <param name="properties" type="Array" mayBeNull="true">Array of function import objects as per EDM metadata.</param>
-        /// <param name="name" type="String">Name to look for.</param>
-        /// <returns type="Object">The entity set object; null if not found.</returns>
-
-        return find(functionImports, function (functionImport) {
-            return functionImport.name === name;
-        });
-    };
-
-    var lookupNavigationPropertyType = function (navigationProperty, metadata) {
-        /// <summary>Looks up the target entity type for a navigation property.</summary>
-        /// <param name="navigationProperty" type="Object"></param>
-        /// <param name="metadata" type="Object"></param>
-        /// <returns type="String">The entity type name for the specified property, null if not found.</returns>
-
-        var result = null;
-        if (navigationProperty) {
-            var rel = navigationProperty.relationship;
-            var association = forEachSchema(metadata, function (schema) {
-                // The name should be the namespace qualified name in 'ns'.'type' format.
-                var nameOnly = removeNamespace(schema["namespace"], rel);
-                var associations = schema.association;
-                if (nameOnly && associations) {
-                    var i, len;
-                    for (i = 0, len = associations.length; i < len; i++) {
-                        if (associations[i].name === nameOnly) {
-                            return associations[i];
-                        }
-                    }
-                }
-                return null;
-            });
-
-            if (association) {
-                var end = association.end[0];
-                if (end.role !== navigationProperty.toRole) {
-                    end = association.end[1];
-                    // For metadata to be valid, end.role === navigationProperty.toRole now.
-                }
-                result = end.type;
-            }
-        }
-        return result;
-    };
-
-    var lookupNavigationPropertyEntitySet = function (navigationProperty, sourceEntitySetName, metadata) {
-        /// <summary>Looks up the target entityset name for a navigation property.</summary>
-        /// <param name="navigationProperty" type="Object"></param>
-        /// <param name="metadata" type="Object"></param>
-        /// <returns type="String">The entityset name for the specified property, null if not found.</returns>
-
-        if (navigationProperty) {
-            var rel = navigationProperty.relationship;
-            var associationSet = forEachSchema(metadata, function (schema) {
-                var containers = schema.entityContainer;
-                for (var i = 0; i < containers.length; i++) {
-                    var associationSets = containers[i].associationSet;
-                    if (associationSets) {
-                        for (var j = 0; j < associationSets.length; j++) {
-                            if (associationSets[j].association == rel) {
-                                return associationSets[j];
-                            }
-                        }
-                    }
-                }
-                return null;
-            });
-            if (associationSet && associationSet.end[0] && associationSet.end[1]) {
-                return (associationSet.end[0].entitySet == sourceEntitySetName) ? associationSet.end[1].entitySet : associationSet.end[0].entitySet;
-            }
-        }
-        return null;
-    };
-
-    var getEntitySetInfo = function (entitySetName, metadata) {
-        /// <summary>Gets the entitySet info, container name and functionImports for an entitySet</summary>
-        /// <param name="navigationProperty" type="Object"></param>
-        /// <param name="metadata" type="Object"></param>
-        /// <returns type="Object">The info about the entitySet.</returns>
-
-        var info = forEachSchema(metadata, function (schema) {
-            var contai

<TRUNCATED>