/*
 * 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.

 * datajs.js
 */
(function(w,u){var d=w.datajs||{};var o=w.OData||{};if(typeof define==='function'&&define.amd){define('datajs',d);define('OData',o);}else{w.datajs=d;w.OData=o;}var c=function(p){if(w.ActiveXObject){return new w.ActiveXObject(p);}return null;};var f=function(a){return a!==null&&a!==u;};var g=function(a,b){var i,e;for(i=0,e=a.length;i<e;i++){if(a[i]===b){return true;}}return false;};var h=function(a,b){return(a!==u)?a:b;};var j=function(a){if(arguments.length===1){w.setTimeout(a,0);return;}var b=Array.prototype.slice.call(arguments,1);w.setTimeout(function(){a.apply(this,b);},0);};var k=function(a,b){for(var e in b){a[e]=b[e];}return a;};var l=function(a,b){if(a){var i,e;for(i=0,e=a.length;i<e;i++){if(b(a[i])){return a[i];}}}return null;};var m=function(a){return Object.prototype.toString.call(a)==="[object Array]";};var n=function(a){return Object.prototype.toString.call(a)==="[object Date]";};var q=function(a){return typeof a==="object";};var r=function(a){return parseInt(a,10);};var s=function(a,b,e){if(a.hasOwnProperty(b)){a[e]=a[b];delete a[b];}};var t=function(e){throw e;};var v=function(a){if(a.trim){return a.trim();}return a.replace(/^\s+|\s+$/g,'');};var z=function(a,b){return(a!==u)?a:b;};var A=/^([^:\/?#]+:)?(\/\/[^\/?#]*)?([^?#:]+)?(\?[^#]*)?(#.*)?/;var B=["scheme","authority","path","query","fragment"];var C=function(a){var b={isAbsolute:false};if(a){var e=A.exec(a);if(e){var i,p;for(i=0,p=B.length;i<p;i++){if(e[i+1]){b[B[i]]=e[i+1];}}}if(b.scheme){b.isAbsolute=true;}}return b;};var D=function(a){return"".concat(a.scheme||"",a.authority||"",a.path||"",a.query||"",a.fragment||"");};var E=/^\/{0,2}(?:([^@]*)@)?([^:]+)(?::{1}(\d+))?/;var F=/%[0-9A-F]{2}/ig;var G=function(a){var b=C(a);var e=b.scheme;var i=b.authority;if(e){b.scheme=e.toLowerCase();if(i){var p=E.exec(i);if(p){b.authority="//"+(p[1]?p[1]+"@":"")+(p[2].toLowerCase())+(p[3]?":"+p[3]:"");}}}a=D(b);return a.replace(F,function(x){return x.toLowerCase();});};var H=function(a,b){if(!b){return a;}var e=C(a);if(e.isAbsolute){return a;}var i=C(b);var p={};var x;if(e.authority){p.authority=e.authority;x=e.path;p.query=e.query;}else{if(!e.path){x=i.path;p.query=e.query||i.query;}else{if(e.path.charAt(0)==='/'){x=e.path;}else{x=I(e.path,i.path);}p.query=e.query;}p.authority=i.authority;}p.path=J(x);p.scheme=i.scheme;p.fragment=e.fragment;return D(p);};var I=function(a,b){var p="/";var e;if(b){e=b.lastIndexOf("/");p=b.substring(0,e);if(p.charAt(p.length-1)!=="/"){p=p+"/";}}return p+a;};var J=function(p){var a="";var b="";var e;while(p){if(p.indexOf("..")===0||p.indexOf(".")===0){p=p.replace(/^\.\.?\/?/g,"");}else if(p.indexOf("/..")===0){p=p.replace(/^\/\..\/?/g,"/");e=a.lastIndexOf("/");if(e===-1){a="";}else{a=a.substring(0,e);}}else if(p.indexOf("/.")===0){p=p.replace(/^\/\.\/?/g,"/");}else{b=p;e=p.indexOf("/",1);if(e!==-1){b=p.substring(0,e);}a=a+b;p=p.replace(b,"");}}return a;};var K="http://";var L=K+"www.w3.org/";var M=L+"1999/xhtml";var N=L+"2000/xmlns/";var O=L+"XML/1998/namespace";var P=K+"www.mozilla.org/newlayout/xml/parsererror.xml";var Q=function(a){var b=/(^\s)|(\s$)/;return b.test(a);};var R=function(a){var b=/^\s*$/;return a===null||b.test(a);};var S=function(a){while(a!==null&&a.nodeType===1){var b=c1(a,"space",O);if(b==="preserve"){return true;}else if(b==="default"){break;}else{a=a.parentNode;}}return false;};var T=function(a){var b=a.nodeName;return b=="xmlns"||b.indexOf("xmlns:")==0;};var U=function(a,b,e){try{a.setProperty(b,e);}catch(_){}};var V=function(){var a=c("Msxml2.DOMDocument.3.0");if(a){U(a,"ProhibitDTD",true);U(a,"MaxElementDepth",256);U(a,"AllowDocumentFunction",false);U(a,"AllowXsltScript",false);}return a;};var W=function(){try{var a=c("Msxml2.DOMDocument.6.0");if(a){a.async=true;}return a;}catch(_){return V();}};var X=function(a){var b=W();if(!b){return null;}b.loadXML(a);var p=b.parseError;if(p.errorCode!==0){Y(p.reason,p.srcText,a);}return b;};var Y=function(e,a,b){if(typeof e==="string"){e={message:e};};throw k(e,{srcText:a||"",errorXmlText:b||""});};var Z=function(a){var b=w.DOMParser&&new w.DOMParser();var i;if(!b){i=X(a);if(!i){Y("XML DOM parser not supported");}return i;}try{i=b.parseFromString(a,"text/xml");}catch(e){Y(e,"",a);}var p=i.documentElement;var x=p.namespaceURI;var y=m1(p);if(y==="parsererror"&&x===P){var _=i1(p,P,"sourcetext");var k9=_?o1(_):"";Y(l1(p)||"",k9,a);}if(y==="h3"&&x===M||j1(p,M,"h3")){var l9="";var m9=[];var n9=p.firstChild;while(n9){if(n9.nodeType===1){l9+=l1(n9)||"";}m9.push(n9.nextSibling);n9=n9.firstChild||m9.shift();}l9+=l1(p)||"";Y(l9,"",a);}return i;};var $=function(p,a){return p?p+":"+a:a;};var a1=function(a,b){if(Q(b.data)){var e=d1(a,O,"space");if(!e){e=v1(a.ownerDocument,O,$("xml","space"));t1(a,e);}e.value="preserve";}a.appendChild(b);return a;};var b1=function(e,a){var b=e.attributes;var i,p;for(i=0,p=b.length;i<p;i++){a(b.item(i));}};var c1=function(a,b,e){var i=d1(a,b,e);return i?o1(i):null;};var d1=function(a,b,e){var i=a.attributes;if(i.getNamedItemNS){return i.getNamedItemNS(e||null,b);}return i.getQualifiedItem(b,e)||null;};var e1=function(a,b){var e=d1(a,"base",O);return(e?H(e.value,b):b)||null;};var f1=function(a,b){p1(a,false,function(e){if(e.nodeType===1){b(e);}return true;});};var g1=function(a,b,p){var e=p.split("/");var i,x;for(i=0,x=e.length;i<x;i++){a=a&&i1(a,b,e[i]);}return a||null;};var h1=function(a,b,p){var e=p.lastIndexOf("/");var i=p.substring(e+1);var x=p.substring(0,e);var y=x?g1(a,b,x):a;if(y){if(i.charAt(0)==="@"){return d1(y,i.substring(1),b);}return i1(y,b,i);}return null;};var i1=function(a,b,e){return k1(a,b,e,false);};var j1=function(a,b,e){if(a.getElementsByTagNameNS){var i=a.getElementsByTagNameNS(b,e);return i.length>0?i[0]:null;}return k1(a,b,e,true);};var k1=function(a,b,e,i){var p=null;p1(a,i,function(x){if(x.nodeType===1){var y=!b||n1(x)===b;var _=!e||m1(x)===e;if(y&&_){p=x;}}return p===null;});return p;};var l1=function(x){var a=null;var b=(x.nodeType===9&&x.documentElement)?x.documentElement:x;var e=b.ownerDocument.preserveWhiteSpace===false;var i;p1(b,false,function(p){if(p.nodeType===3||p.nodeType===4){var y=o1(p);var _=e||!R(y);if(!_){if(i===u){i=S(b);}_=i;}if(_){if(!a){a=y;}else{a+=y;}}}return true;});return a;};var m1=function(a){return a.localName||a.baseName;};var n1=function(a){return a.namespaceURI||null;};var o1=function(a){if(a.nodeType===1){return l1(a);}return a.nodeValue;};var p1=function(a,b,e){var i=[];var p=a.firstChild;var x=true;while(p&&x){x=e(p);if(x){if(b&&p.firstChild){i.push(p.firstChild);}p=p.nextSibling||i.shift();}}};var q1=function(a,b,e){var i=a.nextSibling;while(i){if(i.nodeType===1){var p=!b||n1(i)===b;var x=!e||m1(i)===e;if(p&&x){return i;}}i=i.nextSibling;}return null;};var r1=function(){var i=w.document.implementation;return(i&&i.createDocument)?i.createDocument(null,null,null):W();};var s1=function(p,a){if(!m(a)){return t1(p,a);}var i,b;for(i=0,b=a.length;i<b;i++){a[i]&&t1(p,a[i]);}return p;};var t1=function(p,a){if(a){if(typeof a==="string"){return a1(p,z1(p.ownerDocument,a));}if(a.nodeType===2){p.setAttributeNodeNS?p.setAttributeNodeNS(a):p.setAttributeNode(a);}else{p.appendChild(a);}}return p;};var u1=function(a,b){var e=document.createElement('dummy');e.setAttributeNS(a,b,'');var i=e.attributes[0];e.removeAttributeNode(i);return i;};var v1=function(a,b,e,i){var p=a.createAttributeNS&&a.createAttributeNS(b,e)||"createNode"in a&&a.createNode(2,e,b||u)||u1(b,e);p.value=i||"";return p;};var w1=function(a,b,e,i){var p=a.createElementNS&&a.createElementNS(b,e)||a.createNode(1,e,b||u);return s1(p,i||[]);};var x1=function(a,b,p){return v1(a,N,$("xmlns",p),b);};var y1=function(a,b){var e="<c>"+b+"</c>";var i=Z(e);var p=i.documentElement;var x=("importNode"in a)?a.importNode(p,true):p;var y=a.createDocumentFragment();var _=x.firstChild;while(_){y.appendChild(_);_=_.nextSibling;}return y;};var z1=function(a,b){return a.createTextNode(b);};var A1=function(a,b,e,p,x){var y="";var _=x.split("/");var k9=i1;var l9=w1;var m9=b;var i,n9;for(i=0,n9=_.length;i<n9;i++){y=_[i];if(y.charAt(0)==="@"){y=y.substring(1);k9=d1;l9=v1;}var o9=k9(m9,e,y);if(!o9){o9=l9(a,e,$(p,y));t1(m9,o9);}m9=o9;}return m9;};var B1=function(a){var x5=w.XMLSerializer;if(x5){var b=new x5();return b.serializeToString(a);}if(a.xml){return a.xml;}throw{message:"XML serialization unsupported"};};var C1=function(a){var b=a.childNodes;var i,e=b.length;if(e===0){return"";}var p=a.ownerDocument;var x=p.createDocumentFragment();var y=p.createElement("c");x.appendChild(y);for(i=0;i<e;i++){y.appendChild(b[i]);}var _=B1(x);_=_.substr(3,_.length-7);for(i=0;i<e;i++){a.appendChild(y.childNodes[i]);}return _;};var D1=function(a){var x=a.xml;if(x!==u){return x;}if(w.XMLSerializer){var b=new w.XMLSerializer();return b.serializeToString(a);}throw{message:"XML serialization unsupported"};};var E1=function(a,b,e){return function(){a[b].apply(a,arguments);return e;};};var F1=function(){this._arguments=u;this._done=u;this._fail=u;this._resolved=false;this._rejected=false;};F1.prototype={then:function(a,e){if(a){if(!this._done){this._done=[a];}else{this._done.push(a);}}if(e){if(!this._fail){this._fail=[e];}else{this._fail.push(e);}}if(this._resolved){this.resolve.apply(this,this._arguments);}else if(this._rejected){this.reject.apply(this,this._arguments);}return this;},resolve:function(){if(this._done){var i,a;for(i=0,a=this._done.length;i<a;i++){this._done[i].apply(null,arguments);}this._done=u;this._resolved=false;this._arguments=u;}else{this._resolved=true;this._arguments=arguments;}},reject:function(){if(this._fail){var i,a;for(i=0,a=this._fail.length;i<a;i++){this._fail[i].apply(null,arguments);}this._fail=u;this._rejected=false;this._arguments=u;}else{this._rejected=true;this._arguments=arguments;}},promise:function(){var a={};a.then=E1(this,"then",a);return a;}};var G1=function(){if(w.jQuery&&w.jQuery.Deferred){return new w.jQuery.Deferred();}else{return new F1();}};var H1=function(a,b){var e=((a&&a.__metadata)||{}).type;return e||(b?b.type:null);};var I1="Edm.";var J1=I1+"Binary";var K1=I1+"Boolean";var L1=I1+"Byte";var M1=I1+"DateTime";var N1=I1+"DateTimeOffset";var O1=I1+"Decimal";var P1=I1+"Double";var Q1=I1+"Guid";var R1=I1+"Int16";var S1=I1+"Int32";var T1=I1+"Int64";var U1=I1+"SByte";var V1=I1+"Single";var W1=I1+"String";var X1=I1+"Time";var Y1=I1+"Geography";var Z1=Y1+"Point";var $1=Y1+"LineString";var _1=Y1+"Polygon";var a2=Y1+"Collection";var b2=Y1+"MultiPolygon";var c2=Y1+"MultiLineString";var d2=Y1+"MultiPoint";var e2=I1+"Geometry";var f2=e2+"Point";var g2=e2+"LineString";var h2=e2+"Polygon";var i2=e2+"Collection";var j2=e2+"MultiPolygon";var k2=e2+"MultiLineString";var l2=e2+"MultiPoint";var m2="Point";var n2="LineString";var o2="Polygon";var p2="MultiPoint";var q2="MultiLineString";var r2="MultiPolygon";var s2="GeometryCollection";var t2=[W1,S1,T1,K1,P1,V1,M1,N1,X1,O1,Q1,L1,R1,U1,J1];var u2=[e2,f2,g2,h2,i2,j2,k2,l2];var v2=[Y1,Z1,$1,_1,a2,b2,c2,d2];var w2=function(a,b){if(!a){return null;}if(m(a)){var i,e,p;for(i=0,e=a.length;i<e;i++){p=w2(a[i],b);if(p){return p;}}return null;}else{if(a.dataServices){return w2(a.dataServices.schema,b);}return b(a);}};var x2=function(a,b){if(a===0){a="";}else{a="."+B2(a.toString(),3);}if(b>0){if(a===""){a=".000";}a+=B2(b.toString(),4);}return a;};var y2=function(a){return"\/Date("+a.getTime()+")\/";};var z2=function(a){if(typeof a==="string"){return a;}var b=K2(a);var e=C2(a.__offset);if(b&&e!=="Z"){a=new Date(a.valueOf());var i=o3(e);var p=a.getUTCHours()+(i.d*i.h);var x=a.getMinutes()+(i.d*i.m);a.setUTCHours(p,x);}else if(!b){e="";}var y=a.getUTCFullYear();var _=a.getUTCMonth()+1;var k9="";if(y<=0){y=-(y-1);k9="-";}var ms=x2(a.getUTCMilliseconds(),a.__ns);return k9+B2(y,4)+"-"+B2(_,2)+"-"+B2(a.getUTCDate(),2)+"T"+B2(a.getUTCHours(),2)+":"+B2(a.getUTCMinutes(),2)+":"+B2(a.getUTCSeconds(),2)+ms+e;};var A2=function(a){var b=a.ms;var e="";if(b<0){e="-";b=-b;}var i=Math.floor(b/86400000);b-=86400000*i;var p=Math.floor(b/3600000);b-=3600000*p;var x=Math.floor(b/60000);b-=60000*x;var y=Math.floor(b/1000);b-=y*1000;return e+"P"+B2(i,2)+"DT"+B2(p,2)+"H"+B2(x,2)+"M"+B2(y,2)+x2(b,a.ns)+"S";};var B2=function(a,b,e){var i=a.toString(10);while(i.length<b){if(e){i+="0";}else{i="0"+i;}}return i;};var C2=function(a){return(!a||a==="Z"||a==="+00:00"||a==="-00:00")?"Z":a;};var D2=function(a){if(typeof a==="string"){var e=a.indexOf(")",10);if(a.indexOf("Collection(")===0&&e>0){return a.substring(11,e);}}return null;};var E2=function(a,b,e,P3,i,p){return i.request(a,function(x){try{if(x.headers){f3(x.headers);}if(x.data===u&&x.statusCode!==204){P3.read(x,p);}}catch(y){if(y.request===u){y.request=a;}if(y.response===u){y.response=x;}e(y);return;}try{b(x.data,x);}catch(y){y.bIsSuccessHandlerError=true;throw y;}},e);};var F2=function(a){return J2(a)&&m(a.__batchRequests);};var G2=/Collection\((.*)\)/;var H2=function(a,b){var e=a&&a.results||a;return!!e&&(I2(b))||(!b&&m(e)&&!J2(e[0]));};var I2=function(a){return G2.test(a);};var J2=function(a){return!!a&&q(a)&&!m(a)&&!n(a);};var K2=function(a){return(a.__edmType==="Edm.DateTimeOffset"||(!a.__edmType&&a.__offset));};var L2=function(a){if(!a&&!J2(a)){return false;}var b=a.__metadata||{};var e=a.__deferred||{};return!b.type&&!!e.uri;};var M2=function(a){return J2(a)&&a.__metadata&&"uri"in a.__metadata;};var N2=function(a,b){var e=a&&a.results||a;return m(e)&&((!I2(b))&&(J2(e[0])));};var O2=function(a){return g(v2,a);};var P2=function(a){return g(u2,a);};var Q2=function(a){if(!a&&!J2(a)){return false;}var b=a.__metadata;var e=a.__mediaresource;return!b&&!!e&&!!e.media_src;};var R2=function(a){return n(a)||typeof a==="string"||typeof a==="number"||typeof a==="boolean";};var S2=function(a){return g(t2,a);};var T2=function(a,p){if(L2(a)){return"deferred";}if(M2(a)){return"entry";}if(N2(a)){return"feed";}if(p&&p.relationship){if(a===null||a===u||!N2(a)){return"entry";}return"feed";}return null;};var U2=function(p,a){return l(p,function(b){return b.name===a;});};var V2=function(a,b,e){return(a)?w2(b,function(y6){return c3(a,y6,e);}):null;};var W2=function(e,a){return l(e,function(b){return b.name===a;});};var X2=function(a,b){return V2(a,b,"complexType");};var Y2=function(a,b){return V2(a,b,"entityType");};var Z2=function(a){return w2(a,function(y6){return l(y6.entityContainer,function(b){return g3(b.isDefaultEntityContainer);});});};var $2=function(a,b){return V2(a,b,"entityContainer");};var _2=function(a,b){return l(a,function(e){return e.name===b;});};var a3=function(a,b){var e=null;if(a){var p=a.relationship;var x=w2(b,function(y6){var _=b3(y6["namespace"],p);var k9=y6.association;if(_&&k9){var i,l9;for(i=0,l9=k9.length;i<l9;i++){if(k9[i].name===_){return k9[i];}}}});if(x){var y=x.end[0];if(y.role!==a.toRole){y=x.end[1];}e=y.type;}}return e;};var b3=function(a,b){if(b.indexOf(a)===0&&b.charAt(a.length)==="."){return b.substr(a.length+1);}return null;};var c3=function(a,y6,b){if(a&&y6){var e=b3(y6["namespace"],a);if(e){return l(y6[b],function(i){return i.name===e;});}}return null;};var d3=function(a,b){if(a===b){return a;}var e=a.split(".");var p=b.split(".");var x=(e.length>=p.length)?e.length:p.length;for(var i=0;i<x;i++){var y=e[i]&&r(e[i]);var _=p[i]&&r(p[i]);if(y>_){return a;}if(y<_){return b;}}};var e3={"accept":"Accept","content-type":"Content-Type","dataserviceversion":"DataServiceVersion","maxdataserviceversion":"MaxDataServiceVersion"};var f3=function(a){for(var b in a){var e=b.toLowerCase();var i=e3[e];if(i&&b!==i){var p=a[b];delete a[b];a[i]=p;}}};var g3=function(p){if(typeof p==="boolean"){return p;}return typeof p==="string"&&p.toLowerCase()==="true";};var h3=/^(-?\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d+))?(.*)$/;var i3=function(a,b,e){var p=h3.exec(a);var i=(p)?C2(p[8]):null;if(!p||(!b&&i!=="Z")){if(e){return null;}throw{message:"Invalid date/time value"};}var y=r(p[1]);if(y<=0){y++;}var x=p[7];var _=0;if(!x){x=0;}else{if(x.length>7){if(e){return null;}throw{message:"Cannot parse date/time value to given precision."};}_=B2(x.substring(3),4,true);x=B2(x.substring(0,3),3,true);x=r(x);_=r(_);}var k9=r(p[4]);var l9=r(p[5]);var m9=r(p[6])||0;if(i!=="Z"){var n9=o3(i);var o9=-(n9.d);k9+=n9.h*o9;l9+=n9.m*o9;}var p9=new Date();p9.setUTCFullYear(y,r(p[2])-1,r(p[3]));p9.setUTCHours(k9,l9,m9,x);if(isNaN(p9.valueOf())){if(e){return null;}throw{message:"Invalid date/time value"};}if(b){p9.__edmType="Edm.DateTimeOffset";p9.__offset=i;}if(_){p9.__ns=_;}return p9;};var j3=function(p,a){return i3(p,false,a);};var k3=function(p,a){return i3(p,true,a);};var l3=/^([+-])?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d+))?S)?)?/;var m3=function(a){l3.test(a);};var n3=function(a){var p=l3.exec(a);if(p===null){throw{message:"Invalid duration value."};}var y=p[2]||"0";var b=p[3]||"0";var e=r(p[4]||0);var i=r(p[5]||0);var x=r(p[6]||0);var _=parseFloat(p[7]||0);if(y!=="0"||b!=="0"){throw{message:"Unsupported duration value."};}var ms=p[8];var ns=0;if(!ms){ms=0;}else{if(ms.length>7){throw{message:"Cannot parse duration value to given precision."};}ns=B2(ms.substring(3),4,true);ms=B2(ms.substring(0,3),3,true);ms=r(ms);ns=r(ns);}ms+=_*1000+x*60000+i*3600000+e*86400000;if(p[1]==="-"){ms=-ms;}var k9={ms:ms,__edmType:"Edm.Time"};if(ns){k9.ns=ns;}return k9;};var o3=function(a){var b=a.substring(0,1);b=(b==="+")?1:-1;var e=r(a.substring(1));var i=r(a.substring(a.indexOf(":")+1));return{d:b,h:e,m:i};};var p3=function(a,P3,b){if(!a.method){a.method="GET";}if(!a.headers){a.headers={};}else{f3(a.headers);}if(a.headers.Accept===u){a.headers.Accept=P3.accept;}if(f(a.data)&&a.body===u){P3.write(a,b);}if(!f(a.headers.MaxDataServiceVersion)){a.headers.MaxDataServiceVersion=P3.maxDataServiceVersion||"1.0";}if(a.async===u){a.async=true;}};var q3=function(i,a,b){if(i&&typeof i==="object"){for(var e in i){var p=i[e];var x=q3(p,e,b);x=b(e,x,a);if(x!==p){if(p===u){delete i[e];}else{i[e]=x;}}}}return i;};var r3=function(i,a){return a("",q3(i,"",a));};var s3=0;var t3=function(a){if(a.method&&a.method!=="GET"){return false;}return true;};var u3=function(a){var i=w.document.createElement("IFRAME");i.style.display="none";var b=a.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/\</g,"&lt;");var e="<html><head><script type=\"text/javascript\" src=\""+b+"\"><\/script><\/head><body><\/body><\/html>";var p=w.document.getElementsByTagName("BODY")[0];p.appendChild(i);B3(i,e);return i;};var v3=function(){if(w.XMLHttpRequest){return new w.XMLHttpRequest();}var a;if(w.ActiveXObject){try{return new w.ActiveXObject("Msxml2.XMLHTTP.6.0");}catch(_){try{return new w.ActiveXObject("Msxml2.XMLHTTP.3.0");}catch(e){a=e;}}}else{a={message:"XMLHttpRequest not supported"};}throw a;};var w3=function(a){return a.indexOf("http://")===0||a.indexOf("https://")===0||a.indexOf("file://")===0;};var x3=function(a){if(!w3(a)){return true;}var b=w.location;var e=b.protocol+"//"+b.host+"/";return(a.indexOf(e)===0);};var y3=function(a,b){try{delete w[a];}catch(e){w[a]=u;if(b===s3-1){s3-=1;}}};var z3=function(i){if(i){B3(i,"");i.parentNode.removeChild(i);}return null;};var A3=function(x,a){var b=x.getAllResponseHeaders();if(!b){var D3=x.getResponseHeader("Content-Type");var e=x.getResponseHeader("Content-Length");if(D3)a["Content-Type"]=D3;if(e)a["Content-Length"]=e;}else{b=b.split(/\r?\n/);var i,p;for(i=0,p=b.length;i<p;i++){if(b[i]){var y=b[i].match(/([^:]*):\s*((?:\s*\S+)+)?\s*/);a[y[1]]=y[2];}}}};var B3=function(i,a){var b=(i.contentWindow)?i.contentWindow.document:i.contentDocument.document;b.open();b.write(a);b.close();};o.defaultHttpClient={callbackParameterName:"$callback",formatQueryString:"$format=json",enableJsonpCallback:false,request:function(a,b,e){var i={};var x=null;var p=false;var y;i.abort=function(){y=z3(y);if(p){return;}p=true;if(x){x.abort();x=null;}e({message:"Request aborted"});};var _=function(){y=z3(y);if(!p){p=true;x=null;e({message:"Request timed out"});}};var k9;var l9=a.requestUri;var m9=h(a.enableJsonpCallback,this.enableJsonpCallback);var n9=h(a.callbackParameterName,this.callbackParameterName);var o9=h(a.formatQueryString,this.formatQueryString);if(!m9||x3(l9)){x=v3();var p9=function(){if(p||x===null||x.readyState!==4){return;}var x9=x.statusText;var y9=x.status;if(y9===1223){y9=204;x9="No Content";}var z9=[];A3(x,z9);var A9={requestUri:l9,statusCode:y9,statusText:x9,headers:z9,body:x.responseText};p=true;x=null;if(y9>=200&&y9<=299){b(A9);}else{f3(A9.headers);e({message:"HTTP request failed",request:a,response:A9});}};if(a.user&&a.password){x.open(a.method||"GET",l9,a.async,a.user,a.password);}else{x.open(a.method||"GET",l9,a.async);}if(a.withCredentials){x.withCredentials=true;}if(a.headers){for(k9 in a.headers){x.setRequestHeader(k9,a.headers[k9]);}}if(a.timeoutMS){x.timeout=a.timeoutMS;x.ontimeout=_;}if(a.async||(!a.async&&a.async!==false)){x.onreadystatechange=p9;}x.send(a.body);if(!a.async){p9();}}else{if(!t3(a)){throw{message:"Request is not local and cannot be done through JSONP."};}var q9=s3;s3+=1;var r9=q9.toString();var s9=false;var t9;k9="handleJSONP_"+r9;w[k9]=function(x9){y=z3(y);if(!p){s9=true;w.clearTimeout(t9);y3(k9,q9);if(w.ActiveXObject&&!w.DOMParser){x9=w.JSON.parse(w.JSON.stringify(x9));}j(b,{body:x9,statusCode:200,headers:{"Content-Type":"application/json"}});}};var u9=(a.timeoutMS)?a.timeoutMS:120000;t9=w.setTimeout(_,u9);var v9=n9+"=parent."+k9;if(this.formatQueryString){v9+="&"+o9;}var w9=l9.indexOf("?");if(w9===-1){l9=l9+"?"+v9;}else if(w9===l9.length-1){l9=l9+v9;}else{l9=l9+"&"+v9;}y=u3(l9);}return i;}};var C3="3.0";var D3=function(a){if(!a){return null;}var b=a.split(";");var p={};var i,e;for(i=1,e=b.length;i<e;i++){var x=b[i].split("=");p[v(x[0])]=x[1];}return{mediaType:v(b[0]),properties:p};};var E3=function(D3){if(!D3){return u;}var a=D3.mediaType;var p;for(p in D3.properties){a+=";"+p+"="+D3.properties[p];}return a;};var F3=function(D3,a,b,P3){var e={};k(e,b);k(e,{contentType:D3,dataServiceVersion:a,handler:P3});return e;};var G3=function(a,b,e){if(!a){return;}var i=a.headers;if(!i[b]){i[b]=e;}};var H3=function(a,b){if(a){var e=a.headers;var i=e["DataServiceVersion"];e["DataServiceVersion"]=i?d3(i,b):b;}};var I3=function(a,b){var e=a.headers;return(e&&e[b])||u;};var J3=function(a){return D3(I3(a,"Content-Type"));};var K3=/^\s?(\d+\.\d+);?.*$/;var L3=function(a){var b=I3(a,"DataServiceVersion");if(b){var e=K3.exec(b);if(e&&e.length){return e[1];}}};var M3=function(P3,a){return P3.accept.indexOf(a.mediaType)>=0;};var N3=function(P3,p,a,b){if(!a||!a.headers){return false;}var e=J3(a);var i=L3(a)||"";var x=a.body;if(!f(x)||!x){return false;}if(M3(P3,e)){var y=F3(e,i,b,P3);y.response=a;a.data=p(P3,x,y);return a.data!==u;}return false;};var O3=function(P3,a,b,e){if(!b||!b.headers){return false;}var i=J3(b);var p=L3(b);if(!i||M3(P3,i)){var x=F3(i,p,e,P3);x.request=b;b.body=a(P3,b.data,x);if(b.body!==u){H3(b,x.dataServiceVersion||"1.0");G3(b,"Content-Type",E3(x.contentType));G3(b,"MaxDataServiceVersion",P3.maxDataServiceVersion);return true;}}return false;};var P3=function(p,a,b,e){return{accept:b,maxDataServiceVersion:e,read:function(i,x){return N3(this,p,i,x);},write:function(i,x){return O3(this,a,i,x);}};};var Q3=function(P3,b){return b;};var R3=function(P3,a){if(f(a)){return a.toString();}else{return u;}};o.textHandler=P3(Q3,R3,"text/plain",C3);var S3=K+"www.opengis.net";var T3=S3+"/gml";var U3=S3+"/def/crs/EPSG/0/";var V3="gml";var W3=function(a,b,e){var i={type:a};i[b]=e;return i;};var X3=function(a){if(m(a)&&a.length>=2){var b=a[0];a[0]=a[1];a[1]=b;}return a;};var Y3=function(a,b,e,i,p,x){var y=Z3(a,e,i,p,x);return W3(b,"coordinates",y);};var Z3=function(a,b,e,i,p){var x=[];f1(a,function(y){if(n1(y)!==T3){return;}var _=m1(y);if(_===b){var k9=i1(y,T3);if(k9){var l9=i(k9,p);if(l9){x.push(l9);}}return;}if(_===e){f1(y,function(k9){if(n1(k9)!==T3){return;}var l9=i(k9,p);if(l9){x.push(l9);}});}});return x;};var $3=function(a,i){var b=Z3(a,"geometryMember","geometryMembers",m4,i);return W3(s2,"geometries",b);};var _3=function(a,i){return W3(n2,"coordinates",f4(a,i));};var a4=function(a,i){return Y3(a,q2,"curveMember","curveMembers",f4,i);};var b4=function(a,i){return Y3(a,p2,"pointMember","pointMembers",g4,i);};var c4=function(a,i){return Y3(a,r2,"surfaceMember","surfaceMembers",i4,i);};var d4=function(a,i){return W3(m2,"coordinates",g4(a,i));};var e4=function(a,i){return W3(o2,"coordinates",i4(a,i));};var f4=function(a,i){var b=[];f1(a,function(e){var p=n1(e);if(p!==T3){return;}var x=m1(e);if(x==="posList"){b=k4(e,i);return;}if(x==="pointProperty"){b.push(h4(e,i));return;}if(x==="pos"){b.push(l4(e,i));return;}});return b;};var g4=function(a,i){var p=i1(a,T3,"pos");return p?l4(p,i):[];};var h4=function(a,i){var p=i1(a,T3,"Point");return p?g4(p,i):[];};var i4=function(a,i){var b=[];var e=false;f1(a,function(p){if(n1(p)!==T3){return;}var x=m1(p);if(x==="exterior"){e=true;b.unshift(j4(p,i));return;}if(x==="interior"){b.push(j4(p,i));return;}});if(!e&&b.length>0){b.unshift([[]]);}return b;};var j4=function(a,i){var b=[];f1(a,function(e){if(n1(e)!==T3||m1(e)!=="LinearRing"){return;}b=f4(e,i);});return b;};var k4=function(a,b){var e=l4(a,false);var p=e.length;if(p%2!==0){throw{message:"GML posList element has an uneven number of numeric values"};}var x=[];for(var i=0;i<p;i+=2){var y=e.slice(i,i+2);x.push(b?X3(y):y);}return x;};var l4=function(a,i){var b=[];var e=" \t\r\n";var p=l1(a);if(p){var x=p.length;var y=0;var _=0;while(_<=x){if(e.indexOf(p.charAt(_))!==-1){var k9=p.substring(y,_);if(k9){b.push(parseFloat(k9));}y=_+1;}_++;}}return i?X3(b):b;};var m4=function(a,i){var b=m1(a);var e;switch(b){case"Point":e=d4;break;case"Polygon":e=e4;break;case"LineString":e=_3;break;case"MultiPoint":e=b4;break;case"MultiCurve":e=a4;break;case"MultiSurface":e=c4;break;case"MultiGeometry":e=$3;break;default:throw{message:"Unsupported element: "+b,element:a};}var p=e(a,i);var x=c1(a,"srsName",T3)||c1(a,"srsName");if(x){if(x.indexOf(U3)!==0){throw{message:"Unsupported srs name: "+x,element:a};}var y=x.substring(U3.length);if(y){p.crs={type:"name",properties:{name:"EPSG:"+y}};}}return p;};var n4=function(a,b,e,i){var p;switch(e){case m2:p=v4;break;case n2:p=w4;break;case o2:p=x4;break;case p2:p=z4;break;case q2:p=A4;break;case r2:p=B4;break;case s2:p=D4;break;default:return null;}var x=p(a,b,i);var y=b.crs;if(y){if(y.type==="name"){var _=y.properties;var k9=_&&_.name;if(k9&&k9.indexOf("ESPG:")===0&&k9.length>5){var l9=k9.substring(5);var m9=v1(a,null,"srsName",V3+l9);t1(x,m9);}}}return x;};var o4=function(a,b,e){return w1(a,T3,$(V3,b),e);};var p4=function(a,b,i){var p=m(b)?b:[];p=i?X3(p):p;return o4(a,"pos",p.join(" "));};var q4=function(a,b,e,p){var x=o4(a,b);if(m(e)){var i,y;for(i=0,y=e.length;i<y;i++){t1(x,p4(a,e[i],p));}if(y===0){t1(x,o4(a,"posList"));}}return x;};var r4=function(a,b,i){return o4(a,"Point",p4(a,b,i));};var s4=function(a,b,i){return q4(a,"LineString",b,i);};var t4=function(a,b,e,i){var p=o4(a,b);if(m(e)&&e.length>0){var x=q4(a,"LinearRing",e,i);t1(p,x);}return p;};var u4=function(a,b,e){var p=b&&b.length;var x=o4(a,"Polygon");if(m(b)&&p>0){t1(x,t4(a,"exterior",b[0],e));var i;for(i=1;i<p;i++){t1(x,t4(a,"interior",b[i],e));}}return x;};var v4=function(a,b,i){return r4(a,b.coordinates,i);};var w4=function(a,b,i){return s4(a,b.coordinates,i);};var x4=function(a,b,i){return u4(a,b.coordinates,i);};var y4=function(a,b,e,p,x,y){var _=p&&p.length;var k9=o4(a,b);if(m(p)&&_>0){var l9=o4(a,e);var i;for(i=0;i<_;i++){t1(l9,x(a,p[i],y));}t1(k9,l9);}return k9;};var z4=function(a,b,i){return y4(a,"MultiPoint","pointMembers",b.coordinates,r4,i);};var A4=function(a,b,i){return y4(a,"MultiCurve","curveMembers",b.coordinates,s4,i);};var B4=function(a,b,i){return y4(a,"MultiSurface","surfaceMembers",b.coordinates,u4,i);};var C4=function(a,b,i){return n4(a,b,b.type,i);};var D4=function(a,b,i){return y4(a,"MultiGeometry","geometryMembers",b.geometries,C4,i);};var E4="application/xml";var F4=K+"schemas.microsoft.com/ado/";var G4=F4+"2007/08/dataservices";var H4=F4+"2007/06/edmx";var I4=F4+"2006/04/edm";var J4=F4+"2007/05/edm";var K4=F4+"2008/01/edm";var L4=F4+"2008/09/edm";var M4=F4+"2009/08/edm";var N4=F4+"2009/11/edm";var O4=K+"docs.oasis-open.org/odata/ns/edm";var P4=G4;var Q4=G4+"/metadata";var R4=G4+"/related/";var S4=G4+"/scheme";var T4="d";var U4="m";var V4=function(a,b){var e={name:m1(a),value:a.value};e[b?"namespaceURI":"namespace"]=n1(a);return e;};var W4=function(a,b){var e=[];var p=[];var i,x;var y=a.attributes;for(i=0,x=y.length;i<x;i++){var _=y[i];if(n1(_)!==N){e.push(V4(_,b));}}var k9=a.firstChild;while(k9!=null){if(k9.nodeType===1){p.push(W4(k9,b));}k9=k9.nextSibling;};var l9={name:m1(a),value:l1(a),attributes:e,children:p};l9[b?"namespaceURI":"namespace"]=n1(a);return l9;};var X4=function(a){return n1(a)===P4&&m1(a)==="element";};var Y4=function(a,e){return{type:a,extensions:e};};var Z4=function(a){if(i1(a,T3)){return e2;}var b=i1(a,P4);if(!b){return W1;}if(X4(b)){var e=q1(b,P4);if(e&&X4(e)){return"Collection()";}}return null;};var $4=function(a){var b=null;var i=false;var e=[];b1(a,function(p){var x=n1(p);var y=m1(p);var _=o1(p);if(x===Q4){if(y==="null"){i=(_.toLowerCase()==="true");return;}if(y==="type"){b=_;return;}}if(x!==O&&x!==N){e.push(V4(p,true));return;}});return{type:(!b&&i?W1:b),isNull:i,extensions:e};};var _4=function(a){if(n1(a)!==P4){return null;};var p=m1(a);var b=$4(a);var e=b.isNull;var i=b.type;var x=Y4(i,b.extensions);var y=e?null:a5(a,i,x);return{name:p,value:y,metadata:x};};var a5=function(a,p,b){if(!p){p=Z4(a);b.type=p;}var i=O2(p);if(i||P2(p)){return b5(a,p,i);}if(S2(p)){return c5(a,p);}if(I2(p)){return e5(a,p,b);}return d5(a,p,b);};var b5=function(a,p,i){var b=i1(a,T3);var e=m4(b,i);e.__metadata={type:p};return e;};var c5=function(a,p){var b=o1(a)||"";switch(p){case K1:return g3(b);case J1:case O1:case Q1:case T1:case W1:return b;case L1:case R1:case S1:case U1:return r(b);case P1:case V1:return parseFloat(b);case X1:return n3(b);case M1:return j3(b);case N1:return k3(b);};return b;};var d5=function(a,p,b){var e={__metadata:{type:p}};f1(a,function(i){var x=_4(i);var y=x.name;b.properties=b.properties||{};b.properties[y]=x.metadata;e[y]=x.value;});return e;};var e5=function(a,p,b){var i=[];var e=b.elements=[];var x=D2(p);f1(a,function(y){if(X4(y)){var _=$4(y);var k9=_.extensions;var l9=_.type||x;var m9=Y4(l9,k9);var n9=a5(y,l9,m9);i.push(n9);e.push(m9);}});return{__metadata:{type:p==="Collection()"?null:p},results:i};};var f5=function(x,b){if(n1(x)===P4){b=e1(x,b);var a=m1(x);if(a==="links"){return g5(x,b);}if(a==="uri"){return h5(x,b);}}return u;};var g5=function(a,b){var e=[];f1(a,function(i){if(m1(i)==="uri"&&n1(i)===P4){e.push(h5(i,b));}});return{results:e};};var h5=function(a,b){var e=l1(a)||"";return{uri:H(e,b)};};var i5=function(a,e){if(e===e2||e===Y1){return a&&a.type;}if(e===f2||e===Z1){return m2;}if(e===g2||e===$1){return n2;}if(e===h2||e===_1){return o2;}if(e===i2||e===a2){return s2;}if(e===j2||e===b2){return r2;}if(e===k2||e===c2){return q2;}if(e===l2||e===d2){return p2;}return null;};var j5=function(a,b,e){return w1(a,Q4,$(U4,b),e);};var k5=function(a,b,e){return v1(a,Q4,$(U4,b),e);};var l5=function(a,b,e){return w1(a,P4,$(T4,b),e);};var m5=function(a,b){if(b===M1||b===N1||n(a)){return z2(a);}if(b===X1){return A2(a);}return a.toString();};var n5=function(a,b){return{element:a,dsv:b};};var o5=function(a,b,e,i){var p=e?k5(a,"type",e):null;var x=l5(a,b,p);return s1(x,i);};var p5=function(a,b,e,i){var p=m5(e,i);var x=o5(a,b,i,p);return n5(x,"1.0");};var q5=function(a,b,e,i){var p=k5(a,"null","true");var x=o5(a,b,e,p);var y=X2(e,i)?"2.0":"1.0";return n5(x,y);};var r5=function(a,b,e,p,x,y,_){var k9=D2(p);var l9=m(e)?e:e.results;var m9=p?{type:k9}:{};m9.properties=x.properties;var n9=o5(a,b,k9?p:null);var i,o9;for(i=0,o9=l9.length;i<o9;i++){var p9=l9[i];var q9=u5(a,"element",p9,m9,y,_);t1(n9,q9.element);}return n5(n9,"3.0");};var s5=function(a,b,e,i,p,x,y){var _=o5(a,b,i);var k9=p.properties||{};var l9=X2(i,y)||{};var m9="1.0";for(var n9 in e){if(n9!=="__metadata"){var o9=e[n9];var p9=U2(l9.property,n9);var q9=k9[n9]||{};var r9=u5(a,n9,o9,q9,p9,y);m9=d3(m9,r9.dsv);t1(_,r9.element);}};return n5(_,m9);};var t5=function(a,b,e,i,p){var x=i5(e,i);var y=n4(a,e,x,p);var _=o5(a,b,i,y);return n5(_,"3.0");};var u5=function(a,b,e,i,p,x){var y=H1(e,i,p);if(!y){y=H1(e,p);}if(R2(e)){return p5(a,b,e,y);}var _=O2(y);if(_||P2(y)){return t5(a,b,e,y,_);}if(H2(e,y)){return r5(a,b,e,y,i,p,x);}if(Q2(e)){return null;}var k9=T2(e,p);if(k9!==null){return null;}if(e===null){return q5(a,b,y);}return s5(a,b,e,y,i,p,x);};var v5=function(a){if(a&&q(a)){var b=r1();return t1(b,l5(b,"uri",a.uri));}};var w5=function(P3,a){if(a){var b=Z(a);var e=i1(b);if(e){return f5(e);}}};var x5=function(P3,a,b){var e=b.contentType=b.contentType||D3(E4);if(e&&e.mediaType===E4){return B1(v5(a));}return u;};o.xmlHandler=P3(w5,x5,E4,C3);var y5="a";var z5=L+"2005/Atom";var A5=L+"2007/app";var B5=G4+"/edit-media/";var C5=G4+"/mediaresource/";var D5=G4+"/relatedlinks/";var E5=["application/atom+xml","application/atomsvc+xml","application/xml"];var F5=E5[0];var G5=[z5,A5,O,N];var H5={SyndicationAuthorEmail:"author/email",SyndicationAuthorName:"author/name",SyndicationAuthorUri:"author/uri",SyndicationContributorEmail:"contributor/email",SyndicationContributorName:"contributor/name",SyndicationContributorUri:"contributor/uri",SyndicationPublished:"published",SyndicationRights:"rights",SyndicationSummary:"summary",SyndicationTitle:"title",SyndicationUpdated:"updated"};var I5=function(p){return H5[p]||p;};var J5=function(a){return!(g(G5,a));};var K5=function(a,e,b,p,i){i=i||"";var x=a["FC_TargetPath"+i];if(!x){return null;}var y=a["FC_SourcePath"+i];var _=I5(x);var k9=p?p+(y?"/"+y:""):y;var l9=k9&&Y5(b,e,k9);var m9=a["FC_NsUri"+i]||null;var n9=a["FC_NsPrefix"+i]||null;var o9=a["FC_KeepInContent"+i]||"";if(x!==_){m9=z5;n9=y5;}return{contentKind:a["FC_ContentKind"+i],keepInContent:o9.toLowerCase()==="true",nsPrefix:n9,nsURI:m9,propertyPath:k9,propertyType:l9,entryPath:_};};var L5=function(e,a,b){var p=[];while(e){var x=e.FC_SourcePath;var y=K5(e,e,a);if(y){b(y);}var _=e.property||[];var i,k9;for(i=0,k9=_.length;i<k9;i++){var l9=_[i];var m9=0;var n9="";while(y=K5(l9,e,a,l9.name,n9)){b(y);m9++;n9="_"+m9;};}e=Y2(e.baseType,a);}return p;};var M5=function(a){var e=[];b1(a,function(b){var i=n1(b);if(J5(i)){e.push(V4(b,true));}});return e;};var N5=function(a){return W4(a,true);};var O5=function(a,b,e){var i=n1(a);var p=m1(a);if(i===A5&&p==="service"){return j6(a,b);}if(i===z5){if(p==="feed"){return S5(a,b,e);}if(p==="entry"){return Z5(a,b,e);}}};var P5=function(a,b){var e=[];var i={extensions:e};b1(a,function(p){var x=m1(p);var y=n1(p);var _=o1(p);if(y===null){if(x==="title"||x==="metadata"){i[x]=_;return;}if(x==="target"){i.target=H(_,e1(a,b));return;}}if(J5(y)){e.push(V4(p,true));}});return i;};var Q5=function(a,b,p){var e=p.actions=p.actions||[];e.push(P5(a,b));};var R5=function(a,b,p){var e=p.functions=p.functions||[];e.push(P5(a,b));};var S5=function(a,b,e){var i=M5(a);var p={feed_extensions:i};var x=[];var y={__metadata:p,results:x};b=e1(a,b);f1(a,function(_){var k9=n1(_);var l9=m1(_);if(k9===Q4){if(l9==="count"){y.__count=parseInt(l1(_));return;}if(l9==="action"){Q5(_,b,p);return;}if(l9==="function"){R5(_,b,p);return;}}if(J5(k9)){i.push(W4(_));return;};if(l9==="entry"){x.push(Z5(_,b,e));return;}if(l9==="link"){T5(_,y,b);return;}if(l9==="id"){p.uri=H(l1(_),b);p.uri_extensions=M5(_);return;}if(l9==="title"){p.title=l1(_)||"";p.title_extensions=M5(_);return;}});return y;};var T5=function(a,b,e){var i=U5(a,e);var p=i.href;var x=i.rel;var y=i.extensions;var _=b.__metadata;if(x==="next"){b.__next=p;_.next_extensions=y;return;}if(x==="self"){_.self=p;_.self_extensions=y;return;}};var U5=function(a,b){b=e1(a,b);var e=[];var i={extensions:e,baseURI:b};b1(a,function(p){var x=n1(p);var y=m1(p);var _=p.value;if(y==="href"){i.href=H(_,b);return;}if(y==="type"||y==="rel"){i[y]=_;return;}if(J5(x)){e.push(V4(p,true));}});if(!i.href){throw{error:"href attribute missing on link element",element:a};}return i;};var V5=function(p,a){if(p.indexOf('/')===-1){return a[p];}else{var b=p.split('/');var i,e;for(i=0,e=b.length;i<e;i++){if(a===null){return u;}a=a[b[i]];if(a===u){return a;}}return a;}};var W5=function(p,a,b,e){var x;if(p.indexOf('/')===-1){a[p]=b;x=p;}else{var y=p.split('/');var i,_;for(i=0,_=(y.length-1);i<_;i++){var k9=a[y[i]];if(k9===u){k9={};a[y[i]]=k9;}else if(k9===null){return;}a=k9;}x=y[i];a[x]=b;}if(e){var l9=a.__metadata=a.__metadata||{};var m9=l9.properties=l9.properties||{};var n9=m9[x]=m9[x]||{};n9.type=e;}};var X5=function(a,b,e){var p=a.propertyPath;if(a.keepInContent||V5(p,e)===null){return;}var x=h1(b,a.nsURI,a.entryPath);if(!x){return;}var i=a.propertyType;var y;if(a.contentKind==="xhtml"){y=C1(x);}else{y=c5(x,i||"Edm.String");}W5(p,e,y,i);};var Y5=function(a,b,p){var e=p.split("/");var i,x;while(b){var y=b;for(i=0,x=e.length;i<x;i++){var _=y.property;if(!_){break;}var k9=U2(_,e[i]);if(!k9){break;}var l9=k9.type;if(!l9||S2(l9)){return l9||null;}y=X2(l9,a);if(!y){return null;}}b=Y2(b.baseType,a);}return null;};var Z5=function(a,b,e){var i={};var p={__metadata:i};var x=c1(a,"etag",Q4);if(x){i.etag=x;}b=e1(a,b);f1(a,function(_){var k9=n1(_);var l9=m1(_);if(k9===z5){if(l9==="id"){$5(_,i,b);return;}if(l9==="category"){_5(_,i);return;}if(l9==="content"){a6(_,p,i,b);return;}if(l9==="link"){b6(_,p,i,b,e);return;}return;}if(k9===Q4){if(l9==="properties"){i6(_,p,i);return;}if(l9==="action"){Q5(_,b,i);return;}if(l9==="function"){R5(_,b,i);return;}}});var y=Y2(i.type,e);L5(y,e,function(_){X5(_,a,p);});return p;};var $5=function(a,e,b){e.uri=H(l1(a),e1(a,b));e.uri_extensions=M5(a);};var _5=function(a,e){if(c1(a,"scheme")===S4){if(e.type){throw{message:"Invalid AtomPub document: multiple category elements defining the entry type were encounterd withing an entry",element:a};}var b=[];b1(a,function(i){var p=n1(i);var x=m1(i);if(!p){if(x!=="scheme"&&x!=="term"){b.push(V4(i,true));}return;}if(J5(p)){b.push(V4(i,true));}});e.type=c1(a,"term");e.type_extensions=b;}};var a6=function(a,e,b,i){var p=c1(a,"src");var x=c1(a,"type");if(p){if(!x){throw{message:"Invalid AtomPub document: content element must specify the type attribute if the src attribute is also specified",element:a};}b.media_src=H(p,e1(a,i));b.content_type=x;}f1(a,function(y){if(p){throw{message:"Invalid AtomPub document: content element must not have child elements if the src attribute is specified",element:a};}if(n1(y)===Q4&&m1(y)==="properties"){i6(y,e,b);}});};var b6=function(a,e,b,i,p){var x=U5(a,i);var y=x.rel;var _=x.href;var k9=x.extensions;if(y==="self"){b.self=_;b.self_link_extensions=k9;return;}if(y==="edit"){b.edit=_;b.edit_link_extensions=k9;return;}if(y==="edit-media"){b.edit_media=x.href;b.edit_media_extensions=k9;h6(x,b);return;}if(y.indexOf(B5)===0){e6(x,e,b);return;}if(y.indexOf(C5)===0){f6(x,e,b);return;}if(y.indexOf(R4)===0){d6(a,x,e,b,p);return;}if(y.indexOf(D5)===0){c6(x,b);return;}};var c6=function(a,e){var p=a.rel.substring(D5.length);e.properties=e.properties||{};var b=e.properties[p]=e.properties[p]||{};b.associationuri=a.href;b.associationuri_extensions=a.extensions;};var d6=function(a,b,e,i,p){var x;var y=i1(a,Q4,"inline");if(y){var _=i1(y);var k9=e1(y,b.baseURI);x=_?O5(_,k9,p):null;}else{x={__deferred:{uri:b.href}};}var l9=b.rel.substring(R4.length);e[l9]=x;i.properties=i.properties||{};var m9=i.properties[l9]=i.properties[l9]||{};m9.extensions=b.extensions;};var e6=function(a,e,b){var p=a.rel.substring(B5.length);var i=g6(p,e,b);var x=i.value;var y=i.metadata;var _=a.href;x.edit_media=_;x.content_type=a.type;y.edit_media_extensions=a.extensions;x.media_src=x.media_src||_;y.media_src_extensions=y.media_src_extensions||[];h6(a,x);};var f6=function(a,e,b){var p=a.rel.substring(C5.length);var i=g6(p,e,b);var x=i.value;var y=i.metadata;x.media_src=a.href;y.media_src_extensions=a.extensions;x.content_type=a.type;};var g6=function(a,e,b){b.properties=b.properties||{};var i=b.properties[a];var p=e[a]&&e[a].__mediaresource;if(!p){p={};e[a]={__mediaresource:p};b.properties[a]=i={};}return{value:p,metadata:i};};var h6=function(a,b){var e=a.extensions;var i,p;for(i=0,p=e.length;i<p;i++){if(e[i].namespaceURI===Q4&&e[i].name==="etag"){b.media_etag=e[i].value;e.splice(i,1);return;}}};var i6=function(a,p,b){f1(a,function(e){var i=_4(e);if(i){var x=i.name;var y=b.properties=b.properties||{};y[x]=i.metadata;p[x]=i.value;}});};var j6=function(a,b){var e=[];var i=[];b=e1(a,b);f1(a,function(p){if(n1(p)===A5&&m1(p)==="workspace"){e.push(k6(p,b));return;}i.push(W4(p));});if(e.length===0){throw{message:"Invalid AtomPub service document: No workspace element found.",element:a};}return{workspaces:e,extensions:i};};var k6=function(a,b){var e=[];var i=[];var p=u;b=e1(a,b);f1(a,function(x){var y=n1(x);var _=m1(x);if(y===z5){if(_==="title"){if(p!==u){throw{message:"Invalid AtomPub service document: workspace has more than one child title element",element:x};}p=l1(x);return;}}if(y===A5){if(_==="collection"){e.push(l6(x,b));}return;}i.push(N5(x));});return{title:p||"",collections:e,extensions:i};};var l6=function(a,b){var e=c1(a,"href");if(!e){throw{message:"Invalid AtomPub service document: collection has no href attribute",element:a};}b=e1(a,b);e=H(e,e1(a,b));var i=[];var p=u;f1(a,function(x){var y=n1(x);var _=m1(x);if(y===z5){if(_==="title"){if(p!==u){throw{message:"Invalid AtomPub service document: collection has more than one child title element",element:x};}p=l1(x);}return;}if(y!==A5){i.push(N5(a));}});if(!p){throw{message:"Invalid AtomPub service document: collection has no title element",element:a};}return{title:p,href:e,extensions:i};};var m6=function(a,b,e){return w1(a,z5,$(y5,b),e);};var n6=function(a,b,e){return v1(a,null,b,e);};var o6=function(p){if(p.childNodes.length>0){return false;}var a=true;var b=p.attributes;var i,e;for(i=0,e=b.length;i<e&&a;i++){var x=b[i];a=a&&T(x)||(n1(x)==Q4&&m1(x)==="type");}return a;};var p6=function(a,b,e,i,p){var x=null;var y=null;var _=null;var k9="";if(e!=="deferred"){x=n6(a,"type","application/atom+xml;type="+e);y=j5(a,"inline");if(i){k9=i.__metadata&&i.__metadata.uri||"";_=t6(a,i,p)||s6(a,i,p);t1(y,_.element);}}else{k9=i.__deferred.uri;};var l9=m6(a,"link",[n6(a,"href",k9),n6(a,"rel",H(b,R4)),x,y]);return n5(l9,_?_.dsv:"1.0");};var q6=function(a,b,e,i,p,x){if(Q2(e)){return null;}var y=u5(a,b,e,i,p,x);if(!y){var _=T2(e,p);y=p6(a,b,_,e,x);}return y;};var r6=function(a,e,b,i){var p=g1(b,P4,i.propertyPath);var x=p&&d1(p,"null",Q4);var y;var _="1.0";if(x&&x.value==="true"){return _;}if(p){y=l1(p)||"";if(!i.keepInContent){_="2.0";var k9=p.parentNode;var l9=k9;k9.removeChild(p);while(l9!==b&&o6(l9)){k9=l9.parentNode;k9.removeChild(l9);l9=k9;}}}var m9=A1(a,e,i.nsURI,i.nsPrefix,i.entryPath);if(m9.nodeType===2){m9.value=y;return _;}var n9=i.contentKind;s1(m9,[n9&&v1(a,null,"type",n9),n9==="xhtml"?y1(a,y):y]);return _;};var s6=function(a,b,e){var p=b.__metadata||{};var i=p.properties||{};var x=p.etag;var y=p.uri;var _=p.type;var k9=Y2(_,e);var l9=j5(a,"properties");var m9=m6(a,"entry",[m6(a,"author",m6(a,"name")),x&&k5(a,"etag",x),y&&m6(a,"id",y),_&&m6(a,"category",[n6(a,"term",_),n6(a,"scheme",S4)]),m6(a,"content",[n6(a,"type","application/xml"),l9])]);var n9="1.0";for(var o9 in b){if(o9!=="__metadata"){var p9=i[o9]||{};var q9=k9&&(U2(k9.property,o9)||U2(k9.navigationProperty,o9));var r9=q6(a,o9,b[o9],p9,q9,e);if(r9){var s9=r9.element;var t9=(n1(s9)===z5)?m9:l9;t1(t9,s9);n9=d3(n9,r9.dsv);}}};L5(k9,e,function(u9){var v9=r6(a,m9,l9,u9);n9=d3(n9,v9);});return n5(m9,n9);};var t6=function(a,b,e){var p=m(b)?b:b.results;if(!p){return null;}var x="1.0";var y=m6(a,"feed");var i,_;for(i=0,_=p.length;i<_;i++){var k9=s6(a,p[i],e);t1(y,k9.element);x=d3(x,k9.dsv);}return n5(y,x);};var u6=function(a,b){if(a){var e=N2(a)&&t6||q(a)&&s6;if(e){var i=r1();var p=e(i,a,b);if(p){var x=p.element;s1(x,[x1(i,Q4,U4),x1(i,P4,T4)]);return n5(t1(i,x),p.dsv);}}}return null;};var v6=function(P3,a,b){if(a){var e=Z(a);var i=i1(e);if(i){return O5(i,null,b.metadata);}}};var w6=function(P3,a,b){var e=b.contentType=b.contentType||D3(F5);if(e&&e.mediaType===F5){var i=u6(a,b.metadata);if(i){b.dataServiceVersion=d3(b.dataServiceVersion||"1.0",i.dsv);return B1(i.element);}}};o.atomHandler=P3(v6,w6,E5.join(","),C3);var x6=function(a,e,b,i){return{attributes:a,elements:e,text:b||false,ns:i};};var y6={elements:{Annotations:x6(["Target","Qualifier"],["Annotation*","TypeAnnotation*","ValueAnnotation*"]),Annotation:x6(["Term"],["Record","Collection"]),Association:x6(["Name"],["End*","ReferentialConstraint","TypeAnnotation*","ValueAnnotation*"]),AssociationSet:x6(["Name","Association"],["End*","TypeAnnotation*","ValueAnnotation*"]),Binary:x6(null,null,true),Bool:x6(null,null,true),Collection:x6(null,["String*","Int*","Float*","Decimal*","Bool*","DateTime*","DateTimeOffset*","Guid*","Binary*","Time*","Collection*","Record*"]),CollectionType:x6(["ElementType","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"]["CollectionType","ReferenceType","RowType","TypeRef"]),ComplexType:x6(["Name","BaseType","Abstract"],["Property*","TypeAnnotation*","ValueAnnotation*"]),DateTime:x6(null,null,true),DateTimeOffset:x6(null,null,true),Decimal:x6(null,null,true),DefiningExpression:x6(null,null,true),Dependent:x6(["Role"],["PropertyRef*"]),Documentation:x6(null,null,true),End:x6(["Type","Role","Multiplicity","EntitySet"],["OnDelete"]),EntityContainer:x6(["Name","Extends"],["EntitySet*","AssociationSet*","FunctionImport*","TypeAnnotation*","ValueAnnotation*"]),EntitySet:x6(["Name","EntityType"],["TypeAnnotation*","ValueAnnotation*"]),EntityType:x6(["Name","BaseType","Abstract","OpenType"],["Key","Property*","NavigationProperty*","TypeAnnotation*","ValueAnnotation*"]),EnumType:x6(["Name","UnderlyingType","IsFlags"],["Member*"]),Float:x6(null,null,true),Function:x6(["Name","ReturnType"],["Parameter*","DefiningExpression","ReturnType","TypeAnnotation*","ValueAnnotation*"]),FunctionImport:x6(["Name","ReturnType","EntitySet","IsSideEffecting","IsComposable","IsBindable","EntitySetPath"],["Parameter*","ReturnType","TypeAnnotation*","ValueAnnotation*"]),Guid:x6(null,null,true),Int:x6(null,null,true),Key:x6(null,["PropertyRef*"]),LabeledElement:x6(["Name"],["Path","String","Int","Float","Decimal","Bool","DateTime","DateTimeOffset","Guid","Binary","Time","Collection","Record","LabeledElement","Null"]),Member:x6(["Name","Value"]),NavigationProperty:x6(["Name","Relationship","ToRole","FromRole","ContainsTarget"],["TypeAnnotation*","ValueAnnotation*"]),Null:x6(null,null),OnDelete:x6(["Action"]),Path:x6(null,null,true),Parameter:x6(["Name","Type","Mode","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","SRID"],["CollectionType","ReferenceType","RowType","TypeRef","TypeAnnotation*","ValueAnnotation*"]),Principal:x6(["Role"],["PropertyRef*"]),Property:x6(["Name","Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","ConcurrencyMode","CollectionKind","SRID"],["CollectionType","ReferenceType","RowType","TypeAnnotation*","ValueAnnotation*"]),PropertyRef:x6(["Name"]),PropertyValue:x6(["PropertyPath","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"]),Record:x6(["Type"],["PropertyValue*"]),ReferenceType:x6(["Type"]),ReferentialConstraint:x6(null,["Principal","Dependent"]),ReturnType:x6(["ReturnType","Type","EntitySet"],["CollectionType","ReferenceType","RowType"]),RowType:x6(["Property*"]),String:x6(null,null,true),Schema:x6(["Namespace","Alias"],["Using*","EntityContainer*","EntityType*","Association*","ComplexType*","Function*","ValueTerm*","Annotations*"]),Time:x6(null,null,true),TypeAnnotation:x6(["Term","Qualifier"],["PropertyValue*"]),TypeRef:x6(["Type","Nullable","DefaultValue","MaxLength","FixedLength","Precision","Scale","Unicode","Collation","SRID"]),Using:x6(["Namespace","Alias"]),ValueAnnotation:x6(["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:x6(["Name","Type"],["TypeAnnotation*","ValueAnnotation*"]),Edmx:x6(["Version"],["DataServices","Reference*","AnnotationsReference*"],false,H4),DataServices:x6(null,["Schema*"],false,H4)}};var z6=["m:FC_ContentKind","m:FC_KeepInContent","m:FC_NsPrefix","m:FC_NsUri","m:FC_SourcePath","m:FC_TargetPath"];y6.elements.Property.attributes=y6.elements.Property.attributes.concat(z6);y6.elements.EntityType.attributes=y6.elements.EntityType.attributes.concat(z6);y6.elements.Edmx={attributes:["Version"],elements:["DataServices"],ns:H4};y6.elements.DataServices={elements:["Schema*"],ns:H4};y6.elements.EntityContainer.attributes.push("m:IsDefaultEntityContainer");y6.elements.Property.attributes.push("m:MimeType");y6.elements.FunctionImport.attributes.push("m:HttpMethod");y6.elements.FunctionImport.attributes.push("m:IsAlwaysBindable");y6.elements.EntityType.attributes.push("m:HasStream");y6.elements.DataServices.attributes=["m:DataServiceVersion","m:MaxDataServiceVersion"];var A6=function(a){if(!a){return a;}if(a.length>1){var b=a.substr(0,2);if(b===b.toUpperCase()){return a;}return a.charAt(0).toLowerCase()+a.substr(1);}return a.charAt(0).toLowerCase();};var B6=function(p,a){if(a==="Documentation"){return{isArray:true,propertyName:"documentation"};}var e=p.elements;if(!e){return null;}var i,b;for(i=0,b=e.length;i<b;i++){var x=e[i];var y=false;if(x.charAt(x.length-1)==="*"){y=true;x=x.substr(0,x.length-1);}if(a===x){var _=A6(x);return{isArray:y,propertyName:_};}}return null;};var C6=/^(m:FC_.*)_[0-9]+$/;var D6=function(a){return a===I4||a===J4||a===K4||a===L4||a===M4||a===N4||a===O4};var E6=function(e){var a=m1(e);var b=n1(e);var i=y6.elements[a];if(!i){return null;}if(i.ns){if(b!==i.ns){return null;}}else if(!D6(b)){return null;}var p={};var x=[];var y=i.attributes||[];b1(e,function(_){var a=m1(_);var b=n1(_);var k9=_.value;if(b===N){return;}var l9=null;var m9=false;if(D6(b)||b===null){l9="";}else if(b===Q4){l9="m:";}if(l9!==null){l9+=a;var n9=C6.exec(l9);if(n9){l9=n9[1];}if(g(y,l9)){m9=true;p[A6(a)]=k9;}}if(!m9){x.push(V4(_));}});f1(e,function(_){var a=m1(_);var k9=B6(i,a);if(k9){if(k9.isArray){var l9=p[k9.propertyName];if(!l9){l9=[];p[k9.propertyName]=l9;}l9.push(E6(_));}else{p[k9.propertyName]=E6(_);}}else{x.push(W4(_));}});if(i.text){p.text=l1(e);}if(x.length){p.extensions=x;}return p;};var F6=function(P3,a){var b=Z(a);var e=i1(b);return E6(e)||u;};o.metadataHandler=P3(F6,null,E4,C3);var G6="o";var H6="f";var I6="p";var J6="c";var K6="s";var L6="l";var M6="odata";var N6=M6+".";var O6="@"+N6+"bind";var P6=N6+"metadata";var Q6=N6+"navigationLinkUrl";var R6=N6+"type";var S6={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"};var T6=function(a){if(a.indexOf(".")>0){var b=a.indexOf("@");var e=b>-1?a.substring(0,b):null;var i=a.substring(b+1);return{target:e,name:i,isOData:i.indexOf(N6)===0};}return null;};var U6=function(a,b,e,i,p){return(J2(b)&&b[R6])||(e&&e[a+"@"+R6])||(i&&i.type)||(a3(i,p))||null;};var V6=function(a,b){if(b){return U2(b.property,a)||U2(b.navigationProperty,a);}return null;};var W6=function(a){return J2(a)&&a.hasOwnProperty(N6+"id");};var X6=function(a,b,e){if(!!b[a+"@"+Q6]||(e&&e.relationship)){return true;}var i=m(b[a])?b[a][0]:b[a];return W6(i);};var Y6=function(a){return S2(a)||O2(a)||P2(a);};var Z6=function(a,b,e,i,p){for(var x in a){if(x.indexOf(".")>0&&x.charAt(0)!=="#"){var y=T6(x);if(y){var _=y.name;var k9=y.target;var l9=null;var m9=null;if(k9){l9=V6(k9,i);m9=U6(k9,a[k9],a,l9,p);}if(y.isOData){$6(_,k9,m9,a[x],a,b,e);}else{b[x]=a[x];}}}}return b;};5;var $6=function(a,b,e,i,p,x,y){var _=a.substring(N6.length);switch(_){case"navigationLinkUrl":c7(_,b,e,i,p,x,y);return;case"nextLink":case"count":a7(_,b,i,x,y);return;case"mediaReadLink":case"mediaEditLink":case"mediaContentType":case"mediaETag":b7(_,b,e,i,x,y);return;default:_6(_,b,i,x,y);return;}};var _6=function(a,b,e,i,p){var x=i.__metadata=i.__metadata||{};var y=S6[a]||a;if(a==="editLink"){x.uri=H(e,p);x[y]=x.uri;return;}if(a==="readLink"||a==="associationLinkUrl"){e=H(e,p);}if(b){var _=x.properties=x.properties||{};var k9=_[b]=_[b]||{};if(a==="type"){k9[y]=k9[y]||e;return;}k9[y]=e;return;}x[y]=e;};var a7=function(a,b,e,i,p){var x=S6[a];var y=b?i[b]:i;y[x]=(a==="nextLink")?H(e,p):e;};var b7=function(a,b,e,i,p,x){var y=p.__metadata=p.__metadata||{};var _=S6[a];if(a==="mediaReadLink"||a==="mediaEditLink"){i=H(i,x);}if(b){var k9=y.properties=y.properties||{};var l9=k9[b]=k9[b]||{};l9.type=l9.type||e;p.__metadata=y;p[b]=p[b]||{__mediaresource:{}};p[b].__mediaresource[_]=i;return;}y[_]=i;};var c7=function(a,b,e,i,p,x,y){var _=x.__metadata=x.__metadata||{};var k9=_.properties=_.properties||{};var l9=k9[b]=k9[b]||{};var m9=H(i,y);if(p.hasOwnProperty(b)){l9.navigationLinkUrl=m9;return;}x[b]={__deferred:{uri:m9}};l9.type=l9.type||e;};var d7=function(a,b,e,i,p,x,y){if(typeof a==="string"){return e7(a,b,y);}if(!Y6(b)){if(m(a)){return f7(a,b,e,i,x,y);}if(J2(a)){return g7(a,b,e,i,x,y);}}return a;};var e7=function(a,p,b){switch(p){case X1:return n3(a);case M1:return j3(a,false);case N1:return k3(a,false);}if(b){return j3(a,true)||k3(a,true)||a;}return a;};var f7=function(a,p,b,e,x,y){var _=D2(p);var k9=[];var l9=[];var i,m9;for(i=0,m9=a.length;i<m9;i++){var n9=U6(null,a[i])||_;var o9={type:n9};var p9=d7(a[i],n9,o9,e,null,x,y);if(!Y6(n9)&&!R2(a[i])){k9.push(o9);}l9.push(p9);}if(k9.length>0){b.elements=k9;}return{__metadata:{type:p},results:l9};};var g7=function(a,p,b,e,i,x){var y=i7(a,p,e,i,x);var _=y.__metadata;var k9=_.properties;if(k9){b.properties=k9;delete _.properties;}return y;};var h7=function(a,p,b,e,i){if(m(a)){return k7(a,p,b,e,i);}if(J2(a)){return i7(a,p,b,e,i);}return null;};var i7=function(a,b,e,i,p){var x=a[R6]||b;var y=Y2(x,i)||X2(x,i);var _={type:x};var k9={__metadata:_};var l9={};for(var m9 in a){if(m9.indexOf("#")===0){j7(m9.substring(1),a[m9],k9,e,i);}else{if(m9.indexOf(".")===-1){if(!_.properties){_.properties=l9;}var n9=a[m9];var o9=V6(m9,y);var p9=X6(m9,a,o9);var q9=U6(m9,n9,a,o9,i);var r9=l9[m9]=l9[m9]||{type:q9};k9[m9]=p9?h7(n9,q9,e,i,p):d7(n9,q9,r9,e,o9,i,p);}}}return Z6(a,k9,e,y,i);};var j7=function(a,b,e,p,x){if(!a||!m(b)&&!J2(b)){return;}var y=false;var _=a.lastIndexOf(".");var k9=a.substring(_+1);var l9=(_>-1)?a.substring(0,_):"";var m9=(k9===a||l9.indexOf(".")===-1)?Z2(x):$2(l9,x);if(m9){var n9=_2(m9.functionImport,k9);if(n9&&!!n9.isSideEffecting){y=!g3(n9.isSideEffecting);}};var o9=e.__metadata;var p9=y?"functions":"actions";var q9=H(a,p);var r9=(m(b))?b:[b];var i,s9;for(i=0,s9=r9.length;i<s9;i++){var t9=r9[i];if(t9){var u9=o9[p9]=o9[p9]||[];var v9={metadata:q9,title:t9.title,target:H(t9.target,p)};u9.push(v9);}}};var k7=function(a,b,e,p,x){var y=m(a)?a:a.value;var _=[];var i,k9;for(i=0,k9=y.length;i<k9;i++){_.push(i7(y[i],b,e,p,x));}var l9={results:_};if(J2(a)){for(var m9 in a){if(m9.indexOf("#")===0){l9.__metadata=l9.__metadata||{};j7(m9.substring(1),a[m9],l9,e,p);}}l9=Z6(a,l9,e);}return l9;};var l7=function(a,b,e,i){var p={type:b};var x=d7(a.value,b,p,e,null,null,i);return Z6(a,{__metadata:p,value:x},e);};var m7=function(a,b,e,i,p){var x={};var y=f7(a.value,b,x,e,i,p);k(y.__metadata,x);return Z6(a,y,e);};var n7=function(a,b){var e=a.value;if(!m(e)){return o7(a,b);}var p=[];var i,x;for(i=0,x=e.length;i<x;i++){p.push(o7(e[i],b));}var y={results:p};return Z6(a,y,b);};var o7=function(a,b){var e={uri:H(a.url,b)};e=Z6(a,e,b);var i=e.__metadata||{};var p=i.properties||{};p7(p.url);s(p,"url","uri");return e;};var p7=function(p){if(p){delete p.type;}};var q7=function(a,b){var e=a.value;var p=[];var x=Z6(a,{collections:p},b);var y=x.__metadata||{};var _=y.properties||{};p7(_.value);s(_,"value","collections");var i,k9;for(i=0,k9=e.length;i<k9;i++){var l9=e[i];var m9={title:l9.name,href:H(l9.url,b)};m9=Z6(l9,m9,b);y=m9.__metadata||{};_=y.properties||{};p7(_.name);p7(_.url);s(_,"name","title");s(_,"url","href");p.push(m9);}return{workspaces:[x]};};var r7=function(a,b){return{kind:a,type:b||null};};var s7=function(a,b,i){var e=a[P6];if(!e||typeof e!=="string"){return null;}var p=e.lastIndexOf("#");if(p===-1){return r7(K6);}var x=e.indexOf("@Element",p);var y=x-1;if(y<0){y=e.indexOf("?",p);if(y===-1){y=e.length;}}var _=e.substring(p+1,y);if(_.indexOf("/$links/")>0){return r7(L6);}var k9=_.split("/");if(k9.length>=0){var l9=k9[0];var m9=k9[1];if(Y6(l9)){return r7(I6,l9);}if(I2(l9)){return r7(J6,l9);}var n9=m9;if(!m9){var o9=l9.lastIndexOf(".");var p9=l9.substring(o9+1);var q9=(p9===l9)?Z2(b):$2(l9.substring(0,o9),b);if(q9){var r9=W2(q9.entitySet,p9);n9=!!r9?r9.entityType:null}}if(x>0){return r7(G6,n9);}if(n9){return r7(H6,n9);}if(m(a.value)&&!X2(l9,b)){var s9=a.value[0];if(!R2(s9)){if(W6(s9)||!i){return r7(H6,null);}}}return r7(G6,l9);}return null;};var t7=function(a,b,e,i){if(!J2(a)){return a;}var p=a[P6];var x=s7(a,b,i);var y=null;if(x){delete a[P6];y=x.type;switch(x.kind){case H6:return k7(a,y,p,b,e);case J6:return m7(a,y,p,b,e);case I6:return l7(a,y,p,e);case K6:return q7(a,p);case L6:return n7(a,p);}}return i7(a,y,p,b,e);};var u7=["type","etag","media_src","edit_media","content_type","media_etag"];var v7=function(a,b){var e=/\/\$links\//;var i={};var p=a.__metadata;var x=b&&e.test(b.request.requestUri);x7(a,(p&&p.properties),i,x);return i;};var w7=function(a,b){if(a){var i,e;for(i=0,e=u7.length;i<e;i++){var p=u7[i];var x=N6+(S6[p]||p);F7(x,null,a[p],b);}}};var x7=function(a,p,b,i){for(var e in a){var x=a[e];if(e==="__metadata"){w7(x,b);}else if(e.indexOf(".")===-1){if(i&&e==="uri"){z7(x,b);}else{y7(e,x,p,b,i);}}else{b[e]=x;}}};var y7=function(a,b,p,e){var i=p&&p[a]||{properties:u,type:u};var x=H1(b,i);if(R2(b)||!b){F7(R6,a,x,e);e[a]=b;return;}if(N2(b,x)||M2(b)){C7(a,b,e);return;}if(!x&&L2(b)){A7(a,b,e);return;}if(H2(b,x)){if(D2(x)){F7(R6,a,x,e);}B7(a,b,e);return;}e[a]={};F7(R6,null,x,e[a]);x7(b,i.properties,e[a]);};var z7=function(a,b){b.url=a;};var A7=function(a,b,e){F7(Q6,a,b.__deferred.uri,e);};var B7=function(a,b,e){e[a]=[];var i=m(b)?b:b.results;x7(i,null,e[a]);};var C7=function(a,b,e){if(N2(b)){e[a]=[];var p=m(b)?b:b.results;var i,x;for(i=0,x=p.length;i<x;i++){D7(a,p[i],true,e);}return;}D7(a,b,false,e);};var D7=function(a,b,i,e){var p=b.__metadata&&b.__metadata.uri;if(p){E7(a,p,i,e);return;}var x=v7(b);if(i){e[a].push(x);return;}e[a]=x;};var E7=function(a,b,i,e){var p=a+O6;if(i){e[p]=e[p]||[];e[p].push(b);return;}e[p]=b;};var F7=function(a,b,e,i){if(e!==u){b?i[b+"@"+a]=e:i[a]=e;}};var G7="application/json";var H7=D3(G7);var I7=function(a){var b=[];for(name in a){var i,e;for(i=0,e=a[name].length;i<e;i++){b.push(k({metadata:name},a[name][i]));}}return b;};var J7=function(a,b,e,p){if(a&&typeof a==="object"){var x;var y=a.__metadata;if(y){if(y.actions){y.actions=I7(y.actions);}if(y.functions){y.functions=I7(y.functions);}x=y&&y.type;}var _=Y2(x,b)||X2(x,b);if(_){var k9=_.property;if(k9){var i,l9;for(i=0,l9=k9.length;i<l9;i++){var m9=k9[i];var n9=m9.name;var o9=a[n9];if(m9.type==="Edm.DateTime"||m9.type==="Edm.DateTimeOffset"){if(o9){o9=e(o9);if(!o9){throw{message:"Invalid date/time value"};}a[n9]=o9;}}else if(m9.type==="Edm.Time"){if(o9){a[n9]=n3(o9);}}}}}else if(p){for(var p9 in a){o9=a[p9];if(typeof o9==="string"){a[p9]=e(o9)||o9;}}}}return a;};var K7=function(D3){if(D3){var o=D3.properties.odata;return o==="nometadata"||o==="minimalmetadata"||o==="fullmetadata";}return false;};var L7=function(a,b){var e={collections:[]};var i,p;for(i=0,p=a.EntitySets.length;i<p;i++){var x=a.EntitySets[i];var y={title:x,href:H(x,b)};e.collections.push(y);}return{workspaces:[e]};};var M7=/^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/;var N7=function(a){var b;if(a<0){b="-";a=-a;}else{b="+";}var e=Math.floor(a/60);a=a-(60*e);return b+B2(e,2)+":"+B2(a,2);};var O7=function(a){var b=a&&M7.exec(a);if(b){var e=new Date(r(b[1]));if(b[2]){var i=r(b[3]);if(b[2]==="-"){i=-i;}var p=e.getUTCMinutes();e.setUTCMinutes(p-i);e.__edmType="Edm.DateTimeOffset";e.__offset=N7(i);}if(!isNaN(e.valueOf())){return e;}}};var P7=function(P3,a,b){var e=h(b.recognizeDates,P3.recognizeDates);var i=h(b.inferJsonLightFeedAsObject,P3.inferJsonLightFeedAsObject);var p=b.metadata;var x=b.dataServiceVersion;var y=O7;var _=(typeof a==="string")?w.JSON.parse(a):a;if((d3("3.0",x)===x)){if(K7(b.contentType)){return t7(_,p,e,i);}y=j3;}_=r3(_.d,function(k9,l9){return J7(l9,p,y,e);});_=U7(_,b.dataServiceVersion);return T7(_,b.response.requestUri);};var Q7=function(a){var b=u;var e=Date.prototype.toJSON;try{Date.prototype.toJSON=function(){return y2(this);};b=w.JSON.stringify(a,S7);b=b.replace(/\/Date\(([0-9.+-]+)\)\//g,"\\/Date($1)\\/");}finally{Date.prototype.toJSON=e;}return b;};var R7=function(P3,a,b){var e=b.dataServiceVersion||"1.0";var i=h(b.useJsonLight,P3.useJsonLight);var p=b.contentType=b.contentType||H7;if(p&&p.mediaType===H7.mediaType){var x=a;if(i||K7(p)){b.dataServiceVersion=d3(e,"3.0");x=v7(a,b);return Q7(x);}if(d3("3.0",e)===e){p.properties.odata="verbose";b.contentType=p;}return Q7(x);}return u;};var S7=function(_,a){if(a&&a.__edmType==="Edm.Time"){return A2(a);}else{return a;}};var T7=function(a,b){var i=J2(a)&&!a.__metadata&&m(a.EntitySets);return i?L7(a,b):a;};var U7=function(a,b){if(b&&b.lastIndexOf(";")===b.length-1){b=b.substr(0,b.length-1);}if(!b||b==="1.0"){if(m(a)){a={results:a};}}return a;};var V7=P3(P7,R7,G7,C3);V7.recognizeDates=false;V7.useJsonLight=false;V7.inferJsonLightFeedAsObject=false;o.jsonHandler=V7;var W7="multipart/mixed";var X7=/^HTTP\/1\.\d (\d{3}) (.*)$/i;var Y7=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/;var Z7=function(){return Math.floor((1+Math.random())*0x10000).toString(16).substr(1);};var $7=function(p){return p+Z7()+"-"+Z7()+"-"+Z7();};var _7=function(a){return a.handler.partHandler;};var a8=function(a){var b=a.boundaries;return b[b.length-1];};var b8=function(P3,a,b){var e=b.contentType.properties["boundary"];return{__batchResponses:d8(a,{boundaries:[e],handlerContext:b})};};var c8=function(P3,a,b){var e=b.contentType=b.contentType||D3(W7);if(e.mediaType===W7){return i8(a,b);}};var d8=function(a,b){var i="--"+a8(b);h8(a,b,i);g8(a,b);var p=[];var x;while(x!=="--"&&b.position<a.length){var y=e8(a,b);var _=D3(y["Content-Type"]);if(_&&_.mediaType===W7){b.boundaries.push(_.properties["boundary"]);try{var k9=d8(a,b);}catch(e){e.response=f8(a,b,i);k9=[e];}p.push({__changeResponses:k9});b.boundaries.pop();h8(a,b,"--"+a8(b));}else{if(!_||_.mediaType!=="application/http"){throw{message:"invalid MIME part type "};}g8(a,b);var l9=f8(a,b,i);try{if(l9.statusCode>=200&&l9.statusCode<=299){_7(b.handlerContext).read(l9,b.handlerContext);}else{l9={message:"HTTP request failed",response:l9};}}catch(e){l9=e;}p.push(l9);}x=a.substr(b.position,2);g8(a,b);}return p;};var e8=function(a,b){var e={};var p;var i;var x;do{x=b.position;i=g8(a,b);p=Y7.exec(i);if(p!==null){e[p[1]]=p[2];}else{b.position=x;}}while(i&&p);f3(e);return e;};var f8=function(a,b,e){var p=b.position;var i=X7.exec(g8(a,b));var x;var y;var _;if(i){x=i[1];y=i[2];_=e8(a,b);g8(a,b);}else{b.position=p;}return{statusCode:x,statusText:y,headers:_,body:h8(a,b,"\r\n"+e)};};var g8=function(a,b){return h8(a,b,"\r\n");};var h8=function(a,b,e){var i=b.position||0;var p=a.length;if(e){p=a.indexOf(e,i);if(p===-1){return null;}b.position=p+e.length;}else{b.position=p;}return a.substring(i,p);};var i8=function(a,b){if(!F2(a)){throw{message:"Data is not a batch object."};}var e=$7("batch_");var p=a.__batchRequests;var x="";var i,y;for(i=0,y=p.length;i<y;i++){x+=j8(e,false)+k8(p[i],b);}x+=j8(e,true);var _=b.contentType.properties;_.boundary=e;return x;};var j8=function(b,a){var e="\r\n--"+b;if(a){e+="--";}return e+"\r\n";};var k8=function(p,a,b){var e=p.__changeRequests;var x;if(m(e)){if(b){throw{message:"Not Supported: change set nested in other change set"};}var y=$7("changeset_");x="Content-Type: "+W7+"; boundary="+y+"\r\n";var i,_;for(i=0,_=e.length;i<_;i++){x+=j8(y,false)+k8(e[i],a,true);}x+=j8(y,true);}else{x="Content-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\n";var k9=k({},a);k9.handler=P3;k9.request=p;k9.contentType=null;p3(p,_7(a),k9);x+=l8(p);}return x;};var l8=function(a){var b=(a.method?a.method:"GET")+" "+a.requestUri+" HTTP/1.1\r\n";for(var e in a.headers){if(a.headers[e]){b=b+e+": "+a.headers[e]+"\r\n";}}if(a.body){function p(i){if(i<=0x7F)return 1;if(i<=0x7FF)return 2;if(i<=0xFFFF)return 3;if(i<=0x1FFFFF)return 4;if(i<=0x3FFFFFF)return 5;if(i<=0x7FFFFFFF)return 6;throw new Error("Illegal argument: "+i);};function x(y){var _=0;for(var i=0;i<y.length;i++){var ch=y.charCodeAt(i);_+=p(ch);}return _;};b+="Content-Length: "+x(a.body)+"\r\n";}b+="\r\n";if(a.body){b+=a.body;}return b;};o.batchHandler=P3(b8,c8,W7,C3);var m8=[o.jsonHandler,o.atomHandler,o.xmlHandler,o.textHandler];var n8=function(a,b,e){var i,p;for(i=0,p=m8.length;i<p&&!m8[i][a](b,e);i++){}if(i===p){throw{message:"no handler for data"};}};o.defaultSuccess=function(a){w.alert(w.JSON.stringify(a));};o.defaultError=t;o.defaultHandler={read:function(a,b){if(a&&a.body&&a.headers["Content-Type"]){n8("read",a,b);}},write:function(a,b){n8("write",a,b);},maxDataServiceVersion:C3,accept:"application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1"};o.defaultMetadata=[];o.read=function(a,b,e,P3,i,p){var x;if(a instanceof String||typeof a==="string"){x={requestUri:a};}else{x=a;}return o.request(x,b,e,P3,i,p);};o.request=function(a,b,e,P3,i,p){b=b||o.defaultSuccess;e=e||o.defaultError;P3=P3||o.defaultHandler;i=i||o.defaultHttpClient;p=p||o.defaultMetadata;a.recognizeDates=h(a.recognizeDates,o.jsonHandler.recognizeDates);a.callbackParameterName=h(a.callbackParameterName,o.defaultHttpClient.callbackParameterName);a.formatQueryString=h(a.formatQueryString,o.defaultHttpClient.formatQueryString);a.enableJsonpCallback=h(a.enableJsonpCallback,o.defaultHttpClient.enableJsonpCallback);a.useJsonLight=h(a.useJsonLight,o.jsonHandler.enableJsonpCallback);a.inferJsonLightFeedAsObject=h(a.inferJsonLightFeedAsObject,o.jsonHandler.inferJsonLightFeedAsObject);var x={metadata:p,recognizeDates:a.recognizeDates,callbackParameterName:a.callbackParameterName,formatQueryString:a.formatQueryString,enableJsonpCallback:a.enableJsonpCallback,useJsonLight:a.useJsonLight,inferJsonLightFeedAsObject:a.inferJsonLightFeedAsObject};try{p3(a,P3,x);return E2(a,b,e,P3,i,x);}catch(y){if(y.bIsSuccessHandlerError){throw y;}else{e(y);}}};o.batchHandler.partHandler=o.defaultHandler;var o8=null;var p8=function(){var a={v:this.valueOf(),t:"[object Date]"};for(var b in this){a[b]=this[b];}return a;};var q8=function(_,a){if(a&&a.t==="[object Date]"){var b=new Date(a.v);for(var e in a){if(e!=="t"&&e!=="v"){b[e]=a[e];}}a=b;}return a;};var r8=function(a,b){return a.name+"#!#"+b;};var s8=function(a,b){return b.replace(a.name+"#!#","");};var t8=function(a){this.name=a;};t8.create=function(a){if(t8.isSupported()){o8=o8||w.localStorage;return new t8(a);}throw{message:"Web Storage not supported by the browser"};};t8.isSupported=function(){return!!w.localStorage;};t8.prototype.add=function(a,b,e,i){i=i||this.defaultError;var p=this;this.contains(a,function(x){if(!x){p.addOrUpdate(a,b,e,i);}else{j(i,{message:"key already exists",key:a});}},i);};t8.prototype.addOrUpdate=function(a,b,i,p){p=p||this.defaultError;if(a instanceof Array){p({message:"Array of keys not supported"});}else{var x=r8(this,a);var y=Date.prototype.toJSON;try{var _=b;if(_!==u){Date.prototype.toJSON=p8;_=w.JSON.stringify(b);}o8.setItem(x,_);j(i,a,b);}catch(e){if(e.code===22||e.number===0x8007000E){j(p,{name:"QUOTA_EXCEEDED_ERR",error:e});}else{j(p,e);}}finally{Date.prototype.toJSON=y;}}};t8.prototype.clear=function(a,b){b=b||this.defaultError;try{var i=0,p=o8.length;while(p>0&&i<p){var x=o8.key(i);var y=s8(this,x);if(x!==y){o8.removeItem(x);p=o8.length;}else{i++;}};j(a);}catch(e){j(b,e);}};t8.prototype.close=function(){};t8.prototype.contains=function(a,b,i){i=i||this.defaultError;try{var p=r8(this,a);var x=o8.getItem(p);j(b,x!==null);}catch(e){j(i,e);}};t8.prototype.defaultError=t;t8.prototype.getAllKeys=function(a,b){b=b||this.defaultError;var p=[];var i,x;try{for(i=0,x=o8.length;i<x;i++){var y=o8.key(i);var _=s8(this,y);if(y!==_){p.push(_);}}j(a,p);}catch(e){j(b,e);}};t8.prototype.mechanism="dom";t8.prototype.read=function(a,b,i){i=i||this.defaultError;if(a instanceof Array){i({message:"Array of keys not supported"});}else{try{var p=r8(this,a);var x=o8.getItem(p);if(x!==null&&x!=="undefined"){x=w.JSON.parse(x,q8);}else{x=u;}j(b,a,x);}catch(e){j(i,e);}}};t8.prototype.remove=function(a,b,i){i=i||this.defaultError;if(a instanceof Array){i({message:"Batches not supported"});}else{try{var p=r8(this,a);o8.removeItem(p);j(b);}catch(e){j(i,e);}}};t8.prototype.update=function(a,b,e,i){i=i||this.defaultError;var p=this;this.contains(a,function(x){if(x){p.addOrUpdate(a,b,e,i);}else{j(i,{message:"key not found",key:a});}},i);};var u8=w.mozIndexedDB||w.webkitIndexedDB||w.msIndexedDB||w.indexedDB;var v8=w.IDBKeyRange||w.webkitIDBKeyRange;var w8=w.IDBTransaction||w.webkitIDBTransaction||{};var x8=w8.READ_ONLY||"readonly";var y8=w8.READ_WRITE||"readwrite";var z8=function(a,b){return function(e){var i=a||b;if(!i){return;}if(Object.prototype.toString.call(e)==="[object IDBDatabaseException]"){if(e.code===11){i({name:"QuotaExceededError",error:e});return;}i(e);return;}var p;try{var x=e.target.error||e;p=x.name;}catch(y){p=(e.type==="blocked")?"IndexedDBBlocked":"UnknownError";}i({name:p,error:e});};};var A8=function(a,b,e){var i=a.name;var p="_datajs_"+i;var x=u8.open(p);x.onblocked=e;x.onerror=e;x.onupgradeneeded=function(){var y=x.result;if(!y.objectStoreNames.contains(i)){y.createObjectStore(i);}};x.onsuccess=function(y){var _=x.result;if(!_.objectStoreNames.contains(i)){if("setVersion"in _){var k9=_.setVersion("1.0");k9.onsuccess=function(){var l9=k9.transaction;l9.oncomplete=function(){b(_);};_.createObjectStore(i,null,false);};k9.onerror=e;k9.onblocked=e;return;}y.target.error={name:"DBSchemaMismatch"};e(y);return;}_.onversionchange=function(y){y.target.close();};b(_);};};var B8=function(a,b,e,i){var p=a.name;var x=a.db;var y=z8(i,a.defaultError);if(x){e(x.transaction(p,b));return;}A8(a,function(_){a.db=_;e(_.transaction(p,b));},y);};var C8=function(a){this.name=a;};C8.create=function(a){if(C8.isSupported()){return new C8(a);}throw{message:"IndexedDB is not supported on this browser"};};C8.isSupported=function(){return!!u8;};C8.prototype.add=function(a,b,e,p){var x=this.name;var y=this.defaultError;var _=[];var k9=[];if(a instanceof Array){_=a;k9=b;}else{_=[a];k9=[b];}B8(this,y8,function(l9){l9.onabort=z8(p,y,a,"add");l9.oncomplete=function(){if(a instanceof Array){e(_,k9);}else{e(a,b);}};for(var i=0;i<_.length&&i<k9.length;i++){l9.objectStore(x).add({v:k9[i]},_[i]);}},p);};C8.prototype.addOrUpdate=function(a,b,e,p){var x=this.name;var y=this.defaultError;var _=[];var k9=[];if(a instanceof Array){_=a;k9=b;}else{_=[a];k9=[b];}B8(this,y8,function(l9){l9.onabort=z8(p,y);l9.oncomplete=function(){if(a instanceof Array){e(_,k9);}else{e(a,b);}};for(var i=0;i<_.length&&i<k9.length;i++){var m9={v:k9[i]};l9.objectStore(x).put(m9,_[i]);}},p);};C8.prototype.clear=function(a,e){var b=this.name;var i=this.defaultError;B8(this,y8,function(p){p.onerror=z8(e,i);p.oncomplete=function(){a();};p.objectStore(b).clear();},e);};C8.prototype.close=function(){if(this.db){this.db.close();this.db=null;}};C8.prototype.contains=function(a,b,e){var i=this.name;var p=this.defaultError;B8(this,x8,function(x){var y=x.objectStore(i);var _=y["get"](a);x.oncomplete=function(){b(!!_.result);};x.onerror=z8(e,p);},e);};C8.prototype.defaultError=t;C8.prototype.getAllKeys=function(a,e){var b=this.name;var i=this.defaultError;B8(this,y8,function(p){var x=[];p.oncomplete=function(){a(x);};var y=p.objectStore(b).openCursor();y.onerror=z8(e,i);y.onsuccess=function(_){var k9=_.target.result;if(k9){x.push(k9.key);k9["continue"].call(k9);}};},e);};C8.prototype.mechanism="indexeddb";C8.prototype.read=function(a,b,e){var p=this.name;var x=this.defaultError;var y=(a instanceof Array)?a:[a];B8(this,x8,function(_){var k9=[];_.onerror=z8(e,x,a,"read");_.oncomplete=function(){if(a instanceof Array){b(y,k9);}else{b(y[0],k9[0]);}};for(var i=0;i<y.length;i++){var l9=_.objectStore(p);var m9=l9["get"].call(l9,y[i]);m9.onsuccess=function(n9){var o9=n9.target.result;k9.push(o9?o9.v:u);};}},e);};C8.prototype.remove=function(a,b,e){var p=this.name;var x=this.defaultError;var y=(a instanceof Array)?a:[a];B8(this,y8,function(_){_.onerror=z8(e,x);_.oncomplete=function(){b();};for(var i=0;i<y.length;i++){var k9=_.objectStore(p);k9["delete"].call(k9,y[i]);}},e);};C8.prototype.update=function(a,b,e,p){var x=this.name;var y=this.defaultError;var _=[];var k9=[];if(a instanceof Array){_=a;k9=b;}else{_=[a];k9=[b];}B8(this,y8,function(l9){l9.onabort=z8(p,y);l9.oncomplete=function(){if(a instanceof Array){e(_,k9);}else{e(a,b);}};for(var i=0;i<_.length&&i<k9.length;i++){var m9=l9.objectStore(x).openCursor(v8.only(_[i]));var n9={v:k9[i]};m9.pair={key:_[i],value:n9};m9.onsuccess=function(o9){var p9=o9.target.result;if(p9){p9.update(o9.target.pair.value);}else{l9.abort();}};}},p);};var D8=function(a){var b=[];var i=[];var e={};this.name=a;var p=function(y){return y||this.defaultError;};var x=function(y,_){var k9;if(y instanceof Array){k9="Array of keys not supported";}if(y===u||y===null){k9="Invalid key";}if(k9){j(_,{message:k9});return false;}return true;};this.add=function(y,_,k9,l9){l9=p(l9);if(x(y,l9)){if(!e.hasOwnProperty(y)){this.addOrUpdate(y,_,k9,l9);}else{l9({message:"key already exists",key:y});}}};this.addOrUpdate=function(y,_,k9,l9){l9=p(l9);if(x(y,l9)){var m9=e[y];if(m9===u){if(b.length>0){m9=b.splice(0,1);}else{m9=i.length;}}i[m9]=_;e[y]=m9;j(k9,y,_);}};this.clear=function(y){i=[];e={};b=[];j(y);};this.contains=function(y,_){var k9=e.hasOwnProperty(y);j(_,k9);};this.getAllKeys=function(y){var _=[];for(var a in e){_.push(a);}j(y,_);};this.read=function(y,_,k9){k9=p(k9);if(x(y,k9)){var l9=e[y];j(_,y,i[l9]);}};this.remove=function(y,_,k9){k9=p(k9);if(x(y,k9)){var l9=e[y];if(l9!==u){if(l9===i.length-1){i.pop();}else{i[l9]=u;b.push(l9);}delete e[y];if(i.length===0){b=[];}}j(_);}};this.update=function(y,_,k9,l9){l9=p(l9);if(x(y,l9)){if(e.hasOwnProperty(y)){this.addOrUpdate(y,_,k9,l9);}else{l9({message:"key not found",key:y});}}};};D8.create=function(a){return new D8(a);};D8.isSupported=function(){return true;};D8.prototype.close=function(){};D8.prototype.defaultError=t;D8.prototype.mechanism="memory";var E8={indexeddb:C8,dom:t8,memory:D8};d.defaultStoreMechanism="best";d.createStore=function(a,b){if(!b){b=d.defaultStoreMechanism;}if(b==="best"){b=(t8.isSupported())?"dom":"memory";}var e=E8[b];if(e){return e.create(a);}throw{message:"Failed to create store",name:a,mechanism:b};};var F8=function(a,b){var e=(a.indexOf("?")>=0)?"&":"?";return a+e+b;};var G8=function(a,b){var i=a.indexOf("?");var e="";if(i>=0){e=a.substr(i);a=a.substr(0,i);}if(a[a.length-1]!=="/"){a+="/";}return a+b+e;};var H8=function(a,b){return{method:"GET",requestUri:a,user:b.user,password:b.password,withCredentials:b.withCredentials,enableJsonpCallback:b.enableJsonpCallback,callbackParameterName:b.callbackParameterName,formatQueryString:b.formatQueryString};};var I8=function(a,b){var e=-1;var i=a.indexOf("?");if(i!==-1){var p=a.indexOf("?"+b+"=",i);if(p===-1){p=a.indexOf("&"+b+"=",i);}if(p!==-1){e=p+b.length+2;}}return e;};var J8=function(a,b,e,i){var p=K8(a,b,[],e,i);return p;};var K8=function(a,b,e,i,p){var x=H8(a,b);var y=o.request(x,function(_){var k9=_.__next;var l9=_.results;e=e.concat(l9);if(k9){y=K8(k9,b,e,i,p);}else{i(e);}},p,u,b.httpClient,b.metadata);return{abort:function(){y.abort();}};};var L8=function(a){var b=this;var e=a.source;b.identifier=G(encodeURI(decodeURI(e)));b.options=a;b.count=function(i,p){var a=b.options;return o.request(H8(G8(e,"$count"),a),function(x){var y=r(x.toString());if(isNaN(y)){p({message:"Count is NaN",count:y});}else{i(y);}},p,u,a.httpClient,a.metadata);};b.read=function(i,p,x,y){var _="$skip="+i+"&$top="+p;return J8(F8(e,_),b.options,x,y);};return b;};var M8=function(a,p){var i=N8(a,p);if(i){var b=i.i-p.i;var e=b+(a.c-a.d.length);a.d=a.d.concat(p.d.slice(b,e));}};var N8=function(x,y){var a=x.i+x.c;var b=y.i+y.c;var e=(x.i>y.i)?x.i:y.i;var i=(a<b)?a:b;var p;if(i>=e){p={i:e,c:i-e};}return p;};var O8=function(a,b){if(a===u||typeof a!=="number"){throw{message:"'"+b+"' must be a number."};}if(isNaN(a)||a<0||!isFinite(a)){throw{message:"'"+b+"' must be greater than or equal to zero."};}};var P8=function(a,b){if(a!==u){if(typeof a!=="number"){throw{message:"'"+b+"' must be a number."};}if(isNaN(a)||a<=0||!isFinite(a)){throw{message:"'"+b+"' must be greater than zero."};}}};var Q8=function(a,b){if(a!==u&&(typeof a!=="number"||isNaN(a)||!isFinite(a))){throw{message:"'"+b+"' must be a number."};}};var R8=function(a,b){var i,e;for(i=0,e=a.length;i<e;i++){if(a[i]===b){a.splice(i,1);return true;}}return false;};var S8=function(a){var b=0;var e=typeof a;if(e==="object"&&a){for(var i in a){b+=i.length*2+S8(a[i]);}}else if(e==="string"){b=a.length*2;}else{b=8;}return b;};var T8=function(a,b,p){a=Math.floor(a/p)*p;b=Math.ceil((b+1)/p)*p;return{i:a,c:b-a};};var U8="destroy";var V8="idle";var W8="init";var X8="read";var Y8="prefetch";var Z8="write";var $8="cancel";var _8="end";var a9="error";var b9="start";var c9="wait";var d9="clear";var e9="done";var f9="local";var g9="save";var h9="source";var i9=function(a,p,i,b,e,x,y){var _;var k9;var l9=this;l9.p=p;l9.i=b;l9.c=e;l9.d=x;l9.s=b9;l9.canceled=false;l9.pending=y;l9.oncomplete=null;l9.cancel=function(){if(!i){return;}var o9=l9.s;if(o9!==a9&&o9!==_8&&o9!==$8){l9.canceled=true;n9($8,_);}};l9.complete=function(){n9(_8,_);};l9.error=function(o9){if(!l9.canceled){n9(a9,o9);}};l9.run=function(o9){k9=o9;l9.transition(l9.s,_);};l9.wait=function(x){n9(c9,x);};var m9=function(o9,k9,x){switch(o9){case b9:if(k9!==W8){a(l9,o9,k9,x);}break;case c9:a(l9,o9,k9,x);break;case $8:a(l9,o9,k9,x);l9.fireCanceled();n9(_8);break;case a9:a(l9,o9,k9,x);l9.canceled=true;l9.fireRejected(x);n9(_8);break;case _8:if(l9.oncomplete){l9.oncomplete(l9);}if(!l9.canceled){l9.fireResolved();}a(l9,o9,k9,x);break;default:a(l9,o9,k9,x);break;}};var n9=function(o9,x){l9.s=o9;_=x;m9(o9,k9,x);};l9.transition=n9;return l9;};i9.prototype.fireResolved=function(){var p=this.p;if(p){this.p=null;p.resolve(this.d);}};i9.prototype.fireRejected=function(a){var p=this.p;if(p){this.p=null;p.reject(a);}};i9.prototype.fireCanceled=function(){this.fireRejected({canceled:true,message:"Operation canceled"});};var j9=function(a){var b=W8;var e={counts:0,netReads:0,prefetches:0,cacheReads:0};var p=[];var x=[];var y=[];var k9=0;var l9=false;var m9=z(a.cacheSize,1048576);var n9=0;var o9=0;var p9=0;var q9=m9===0;var r9=z(a.pageSize,50);var s9=z(a.prefetchSize,r9);var t9="1.0";var u9;var v9=0;var w9=a.source;if(typeof w9==="string"){w9=new L8(a);}w9.options=a;var x9=d.createStore(a.name,a.mechanism);var y9=this;y9.onidle=a.idle;y9.stats=e;y9.count=function(){if(u9){throw u9;}var i=G1();var _=false;if(l9){j(function(){i.resolve(n9);});return i.promise();}var S9=w9.count(function(T9){S9=null;e.counts++;i.resolve(T9);},function(T9){S9=null;i.reject(k(T9,{canceled:_}));});return k(i.promise(),{cancel:function(){if(S9){_=true;S9.abort();S9=null;}}});};y9.clear=function(){if(u9){throw u9;}if(p.length===0){var i=G1();var _=new i9(O9,i,false);H9(_,p);return i.promise();}return p[0].p;};y9.filterForward=function(i,_,S9){return E9(i,_,S9,false);};y9.filterBack=function(i,_,S9){return E9(i,_,S9,true);};y9.readRange=function(i,_){O8(i,"index");O8(_,"count");if(u9){throw u9;}var S9=G1();var op=new i9(Q9,S9,true,i,_,[],0);H9(op,x);return k(S9.promise(),{cancel:function(){op.cancel();}});};y9.ToObservable=y9.toObservable=function(){if(!w.Rx||!w.Rx.Observable){throw{message:"Rx library not available - include rx.js"};}if(u9){throw u9;}return w.Rx.Observable.CreateWithDisposable(function(_){var S9=false;var T9=0;var U9=function(i){if(!S9){_.OnError(i);}};var V9=function(W9){if(!S9){var i,X9;for(i=0,X9=W9.length;i<X9;i++){_.OnNext(W9[i]);}if(W9.length<r9){_.OnCompleted();}else{T9+=r9;y9.readRange(T9,r9).then(V9,U9);}}};y9.readRange(T9,r9).then(V9,U9);return{Dispose:function(){S9=true;}};});};var z9=function(_){return function(S9){u9={message:_,error:S9};var i,T9;for(i=0,T9=x.length;i<T9;i++){x[i].fireRejected(u9);}for(i=0,T9=p.length;i<T9;i++){p[i].fireRejected(u9);}x=p=null;};};var A9=function(_){if(_!==b){b=_;var S9=p.concat(x,y);var i,T9;for(i=0,T9=S9.length;i<T9;i++){S9[i].run(b);}}};var B9=function(){var i=new F1();x9.clear(function(){k9=0;l9=false;n9=0;o9=0;p9=0;q9=m9===0;e={counts:0,netReads:0,prefetches:0,cacheReads:0};y9.stats=e;x9.close();i.resolve();},function(_){i.reject(_);});return i;};var C9=function(i){var _=R8(p,i);if(!_){_=R8(x,i);if(!_){R8(y,i);}}v9--;A9(V8);};var D9=function(i){var _=new F1();var S9=false;var T9=w9.read(i,r9,function(U9){var V9={i:i,c:U9.length,d:U9};_.resolve(V9);},function(U9){_.reject(U9);});return k(_,{cancel:function(){if(T9){T9.abort();S9=true;T9=null;}}});};var E9=function(_,S9,T9,U9){_=r(_);S9=r(S9);if(isNaN(_)){throw{message:"'index' must be a valid number.",index:_};}if(isNaN(S9)){throw{message:"'count' must be a valid number.",count:S9};}if(u9){throw u9;}_=Math.max(_,0);var V9=G1();var W9=[];var X9=false;var Y9=null;var Z9=function(ba,ca){if(!X9){if(S9>=0&&W9.length>=S9){V9.resolve(W9);}else{Y9=y9.readRange(ba,ca).then(function(da){for(var i=0,ea=da.length;i<ea&&(S9<0||W9.length<S9);i++){var fa=U9?ea-i-1:i;var ga=da[fa];if(T9(ga)){var ha={index:ba+fa,item:ga};U9?W9.unshift(ha):W9.push(ha);}}if((!U9&&da.length<ca)||(U9&&ba<=0)){V9.resolve(W9);}else{var ia=U9?Math.max(ba-r9,0):ba+ca;Z9(ia,r9);}},function(i){V9.reject(i);});}}};var $9=T8(_,_,r9);var _9=U9?$9.i:_;var aa=U9?_-$9.i+1:$9.i+$9.c-_;Z9(_9,aa);return k(V9.promise(),{cancel:function(){if(Y9){Y9.cancel();}X9=true;}});};var F9=function(){if(y9.onidle&&v9===0){y9.onidle();}};var G9=function(i){if(l9||s9===0||q9){return;}if(y.length===0||(y[0]&&y[0].c!==-1)){var _=new i9(P9,null,true,i,s9,null,s9);H9(_,y);}};var H9=function(i,_){i.oncomplete=C9;_.push(i);v9++;i.run(b);};var I9=function(i){var S9=false;var T9=k(new F1(),{cancel:function(){S9=true;}});var U9=L9(T9,"Read page from store failure");x9.contains(i,function(V9){if(S9){return;}if(V9){x9.read(i,function(_,W9){if(!S9){T9.resolve(W9!==u,W9);}},U9);return;}T9.resolve(false);},U9);return T9;};var J9=function(i,_){var S9=false;var T9=k(new F1(),{cancel:function(){S9=true;}});var U9=L9(T9,"Save page to store failure");var V9=function(){T9.resolve(true);};if(_.c>0){var W9=S8(_);q9=m9>=0&&m9<k9+W9;if(!q9){x9.addOrUpdate(i,_,function(){M9(_,W9);K9(V9,U9);},U9);}else{V9();}}else{M9(_,0);K9(V9,U9);}return T9;};var K9=function(i,_){var S9={actualCacheSize:k9,allDataLocal:l9,cacheSize:m9,collectionCount:n9,highestSavedPage:o9,highestSavedPageSize:p9,pageSize:r9,sourceId:w9.identifier,version:t9};x9.addOrUpdate("__settings",S9,i,_);};var L9=function(i){return function(){i.resolve(false);};};var M9=function(i,_){var S9=i.c;var T9=i.i;if(S9===0){if(o9===T9-r9){n9=o9+p9;}}else{o9=Math.max(o9,T9);if(o9===T9){p9=S9;}k9+=_;if(S9<r9&&!n9){n9=T9+S9;}}if(!l9&&n9===o9+p9){l9=true;}};var N9=function(i,_,S9,T9){var U9=i.canceled&&_!==_8;if(U9){if(_===$8){if(T9&&T9.cancel){T9.cancel();}}}return U9;};var O9=function(i,_,S9){var T9=i.transition;if(S9!==U8){A9(U8);return true;}switch(_){case b9:T9(d9);break;case _8:F9();break;case d9:B9().then(function(){i.complete();});i.wait();break;default:return false;}return true;};var P9=function(i,_,S9,T9){if(!N9(i,_,S9,T9)){var U9=i.transition;if(S9!==Y8){if(S9===U8){if(_!==$8){i.cancel();}}else if(S9===V8){A9(Y8);}return true;}switch(_){case b9:if(y[0]===i){U9(f9,i.i);}break;case e9:var V9=i.pending;if(V9>0){V9-=Math.min(V9,T9.c);}if(l9||V9===0||T9.c<r9||q9){i.complete();}else{i.pending=V9;U9(f9,T9.i+r9);}break;default:return R9(i,_,S9,T9,true);}}return true;};var Q9=function(i,_,S9,T9){if(!N9(i,_,S9,T9)){var U9=i.transition;if(S9!==X8&&_!==b9){if(S9===U8){if(_!==b9){i.cancel();}}else if(S9!==Z8){A9(X8);}return true;}switch(_){case b9:if(S9===V8||S9===Y8){A9(X8);if(i.c>0){var V9=T8(i.i,i.c,r9);U9(f9,V9.i);}else{U9(e9,i);}}break;case e9:M8(i,T9);var W9=i.d.length;if(i.c===W9||T9.c<r9){e.cacheReads++;G9(T9.i+T9.c);i.complete();}else{U9(f9,T9.i+r9);}break;default:return R9(i,_,S9,T9,false);}}return true;};var R9=function(i,_,S9,T9,U9){var V9=i.error;var W9=i.transition;var X9=i.wait;var Y9;switch(_){case _8:F9();break;case f9:Y9=I9(T9).then(function(Z9,$9){if(!i.canceled){if(Z9){W9(e9,$9);}else{W9(h9,T9);}}});break;case h9:Y9=D9(T9).then(function(Z9){if(!i.canceled){if(U9){e.prefetches++;}else{e.netReads++;}W9(g9,Z9);}},V9);break;case g9:if(S9!==Z8){A9(Z8);Y9=J9(T9.i,T9).then(function(Z9){if(!i.canceled){if(!Z9&&U9){i.pending=0;}W9(e9,T9);}A9(V8);});}break;default:return false;}if(Y9){if(i.canceled){Y9.cancel();}else if(i.s===_){X9(Y9);}}return true;};x9.read("__settings",function(_,i){if(f(i)){var S9=i.version;if(!S9||S9.indexOf("1.")!==0){z9("Unsupported cache store version "+S9)();return;}if(r9!==i.pageSize||w9.identifier!==i.sourceId){B9().then(function(){A9(V8);},z9("Unable to clear store during initialization"));}else{k9=i.actualCacheSize;l9=i.allDataLocal;m9=i.cacheSize;n9=i.collectionCount;o9=i.highestSavedPage;p9=i.highestSavedPageSize;t9=S9;A9(V8);}}else{K9(function(){A9(V8);},z9("Unable to write settings during initialization."));}},z9("Unable to read settings from store."));return y9;};d.createDataCache=function(a){P8(a.pageSize,"pageSize");Q8(a.cacheSize,"cacheSize");Q8(a.prefetchSize,"prefetchSize");if(!f(a.name)){throw{message:"Undefined or null name",options:a};}if(!f(a.source)){throw{message:"Undefined source",options:a};}return new j9(a);};})(window);
