UNPKG

ts-odatajs

Version:

The Olingo OData Client for JavaScript (and TypeScript) is a new cross-browser 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

20 lines (19 loc) 70.6 kB
/* * 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(){function t(e){return e=e.substring(e.lastIndexOf("/")+1,e.length-3).replace("-browser",""),r[e]||(r[e]={exports:{}},n[e].call(this,r[e].exports,r[e],t)),r[e].exports}var n={cache:function(e,t,n){"use strict";var U=n("./utils.js"),r=n("./deferred.js"),q=n("./store.js"),F=n("./cache/source.js"),H=U.assigned,V=U.delay,z=U.extend,J=U.djsassert,K=(U.isArray,U.normalizeURI,U.parseInt10),Y=U.undefinedDefault,X=r.createDeferred,$=r.DjsDeferred,Q=U.getJsonValueArraryLength,o=U.sliceJsonValueArray,i=U.concatJsonValueArray;function W(e,t){var n=function(e,t){var n,r=e.i+e.c,a=t.i+t.c,t=(e.i>t.i?e:t).i,a=r<a?r:a;t<=a&&(n={i:t,c:a-t});return n}(e,t),r=0,a=0;n&&(a=(r=n.i-t.i)+(e.c-Q(e.d))),e.d=i(e.d,o(t.d,r,a))}function Z(e,t){if(void 0===e||"number"!=typeof e)throw{message:"'"+t+"' must be a number."};if(isNaN(e)||e<0||!isFinite(e))throw{message:"'"+t+"' must be greater than or equal to zero."}}function a(e,t){if(void 0!==e&&("number"!=typeof e||isNaN(e)||!isFinite(e)))throw{message:"'"+t+"' must be a number."}}function ee(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return e.splice(n,1),!0;return!1}function te(e){var t=0,n=typeof e;if("object"==n&&e)for(var r in e)t+=2*r.length+te(e[r]);else t="string"==n?2*e.length:8;return t}function ne(e,t,n){return{i:e=Math.floor(e/n)*n,c:(t=Math.ceil((t+1)/n)*n)-e}}var re="destroy",ae="idle",oe="init",ie="read",le="prefetch",ue="write",se="cancel",ce="end",c="error",de="start",d="wait",fe="clear",pe="done",me="local",he="save",ye="source";function ve(a,e,t,n,r,o,i){var l,u,s=this;s.p=e,s.i=n,s.c=r,s.d=o,s.s=de,s.canceled=!1,s.pending=i,s.oncomplete=null,s.cancel=function(){var e;!t||(e=s.s)!==c&&e!==ce&&e!==se&&(s.canceled=!0,s.transition(se,l))},s.complete=function(){J(s.s!==ce,"DataCacheOperation.complete() - operation is in the end state",s),s.transition(ce,l)},s.error=function(e){s.canceled||(J(s.s!==ce,"DataCacheOperation.error() - operation is in the end state",s),J(s.s!==c,"DataCacheOperation.error() - operation is in the error state",s),s.transition(c,e))},s.run=function(e){u=e,s.transition(s.s,l)},s.wait=function(e){J(s.s!==ce,"DataCacheOperation.wait() - operation is in the end state",s),s.transition(d,e)};return s.transition=function(e,t){!function(e,t,n){switch(e){case de:t!==oe&&a(s,e,t,n);break;case d:a(s,e,t,n);break;case se:a(s,e,t,n),s.fireCanceled(),s.transition(ce);break;case c:a(s,e,t,n),s.canceled=!0,s.fireRejected(n),s.transition(ce);break;case ce:s.oncomplete&&s.oncomplete(s),s.canceled||s.fireResolved(),a(s,e,t,n);break;default:var r=a(s,e,t,n);J(r,"Bad operation state: "+e+" cacheState: "+t,this)}}(s.s=e,u,l=t)},s}function l(e){var o,i=oe,s={counts:0,netReads:0,prefetches:0,cacheReads:0},a=[],l=[],u=[],c=0,d=!1,f=Y(e.cacheSize,1048576),p=0,r=0,m=0,h=0===f,y=Y(e.pageSize,50),t=Y(e.prefetchSize,y),v="1.0",n=0,g=e.source;(g="string"==typeof g?new F.ODataCacheSource(e):g).options=e;var b=q.createStore(e.name,e.mechanism),D=this;D.onidle=e.idle,D.stats=s,D.count=function(){if(o)throw o;var t=X(),n=!1;if(d)return V(function(){t.resolve(p)}),t.promise();var r=g.count(function(e){r=null,s.counts++,t.resolve(e)},function(e){r=null,t.reject(z(e,{canceled:n}))});return z(t.promise(),{cancel:function(){r&&(n=!0,r.abort(),r=null)}})},D.clear=function(){if(o)throw o;if(0!==a.length)return a[0].p;var e=X(),t=new ve(G,e,!1);return C(t,a),e.promise()},D.filterForward=function(e,t,n){return S(e,t,n,!1)},D.filterBack=function(e,t,n){return S(e,t,n,!0)},D.readRange=function(e,t){if(Z(e,"index"),Z(t,"count"),o)throw o;var n=X(),r=new ve(k,n,!0,e,t,{},0);return C(r,l),z(n.promise(),{cancel:function(){r.cancel()}})},D.ToObservable=D.toObservable=function(){if(!U.inBrowser())throw{message:"Only in broser supported"};if(!window.Rx||!window.Rx.Observable)throw{message:"Rx library not available - include rx.js"};if(o)throw o;return new window.Rx.Observable(function(r){var a=!1,o=0,i=function(e){a||r.onError(e)},l=function(e){if(!a){for(var t=0,n=e.value.length;t<n;t++)r.onNext(e.value[t]);e.value.length<y?r.onCompleted():(o+=y,D.readRange(o,y).then(l,i))}};return D.readRange(o,y).then(l,i),{Dispose:function(){r.dispose(),a=!0}}})};function E(r){return function(e){var t,n;for(o={message:r,error:e},J(0===u.length,"prefetchOperations.length === 0"),t=0,n=l.length;t<n;t++)l[t].fireRejected(o);for(t=0,n=a.length;t<n;t++)a[t].fireRejected(o);l=a=null}}var T=function(e){if(e!==i){i=e;for(var t=a.concat(l,u),n=0,r=t.length;n<r;n++)t[n].run(i)}},N=function(){J(i===re||i===oe,"DataCache.clearStore() - cache is not on the destroy or initialize state, current sate = "+i);var t=new $;return b.clear(function(){d=!1,h=(m=r=p=c=0)===f,s={counts:0,netReads:0,prefetches:0,cacheReads:0},D.stats=s,b.close(),t.resolve()},function(e){t.reject(e)}),t},O=function(e){ee(a,e)||ee(l,e)||ee(u,e),n--,T(ae)},P=function(n){J(i!==re,"DataCache.fetchPage() - cache is on the destroy state"),J(i!==ae,"DataCache.fetchPage() - cache is on the idle state");var r=new $,e=g.read(n,y,function(e){var t=Q(e);r.resolve({i:n,c:t,d:e})},function(e){r.reject(e)});return z(r,{cancel:function(){e&&(e.abort(),e=null)}})},S=function(e,u,s,c){if(e=K(e),u=K(u),isNaN(e))throw{message:"'index' must be a valid number.",index:e};if(isNaN(u))throw{message:"'count' must be a valid number.",count:u};if(o)throw o;e=Math.max(e,0);function d(i,l){t||(0<u&&p.value.length>=u?f.resolve(p):n=D.readRange(i,l).then(function(e){e["@odata.context"]&&!p["@odata.context"]&&(p["@odata.context"]=e["@odata.context"]);for(var t,n=0,r=e.value.length;n<r&&(u<0||p.value.length<u);n++){var a=c?r-n-1:n,o=e.value[a];s(o)&&(o={index:i+a,item:o},c?p.value.unshift(o):p.value.push(o))}!c&&e.value.length<l||c&&i<=0?f.resolve(p):(t=c?Math.max(i-y,0):i+l,d(t,y))},function(e){f.reject(e)}))}var f=X(),p={value:[]},t=!1,n=null,r=ne(e,e,y),a=c?r.i:e,e=c?e-r.i+1:r.i+r.c-e;return d(a,e),z(f.promise(),{cancel:function(){n&&n.cancel(),t=!0}})},w=function(){D.onidle&&0===n&&D.onidle()},A=function(e){d||0===t||h||(J(i===ie,"DataCache.prefetch() - cache is not on the read state, current state: "+i),(0===u.length||u[0]&&-1!==u[0].c)&&(e=new ve(j,null,!0,e,t,null,t),C(e,u)))},C=function(e,t){e.oncomplete=O,t.push(e),n++,e.run(i)},x=function(t){J(i!==re,"DataCache.readPage() - cache is on the destroy state");var n=!1,r=z(new $,{cancel:function(){n=!0}}),a=M(r,"Read page from store failure");return b.contains(t,function(e){n||(e?b.read(t,function(e,t){n||r.resolve(void 0!==t,t)},a):r.resolve(!1))},a),r},I=function(e,t){J(i!==re,"DataCache.savePage() - cache is on the destroy state"),J(i!==ae,"DataCache.savePage() - cache is on the idle state");function n(){a.resolve(!0)}var r,a=z(new $,{cancel:function(){}}),o=M(a,"Save page to store failure");return 0<t.c?(r=te(t),(h=0<=f&&f<c+r)?n():b.addOrUpdate(e,t,function(){_(t,r),R(n,o)},o)):(_(t,0),R(n,o)),a},R=function(e,t){var n={actualCacheSize:c,allDataLocal:d,cacheSize:f,collectionCount:p,highestSavedPage:r,highestSavedPageSize:m,pageSize:y,sourceId:g.identifier,version:v};b.addOrUpdate("__settings",n,e,t)},M=function(e){return function(){e.resolve(!1)}},_=function(e,t){var n=e.c,e=e.i;0===n?r===e-y&&(p=r+m):((r=Math.max(r,e))===e&&(m=n),c+=t,n<y&&!p&&(p=e+n)),d||p!==r+m||(d=!0)},L=function(e,t,n,r){e=e.canceled&&t!==ce;return e&&t===se&&r&&r.cancel&&r.cancel(),e},G=function(e,t,n){var r=e.transition;if(n!==re)return T(re),!0;switch(t){case de:r(fe);break;case ce:w();break;case fe:N().then(function(){e.complete()}),e.wait();break;default:return!1}return!0},j=function(e,t,n,r){if(!L(e,t,n,r)){var a=e.transition;if(n!==le)return n===re?t!==se&&e.cancel():n===ae&&T(le),!0;switch(t){case de:u[0]===e&&a(me,e.i);break;case pe:var o=e.pending;0<o&&(o-=Math.min(o,r.c)),d||0===o||r.c<y||h?e.complete():(e.pending=o,a(me,r.i+y));break;default:return B(e,t,n,r,!0)}}return!0},k=function(e,t,n,r){if(!L(e,t,n,r)){var a=e.transition;if(n!==ie&&t!==de)return n===re?t!==de&&e.cancel():n!==ue&&(J(i==ae||i===le,"DataCache.readStateMachine() - cache is not on the read or idle state."),T(ie)),!0;switch(t){case de:n!==ae&&n!==le||(T(ie),0<=e.c?(o=ne(e.i,e.c,y),a(me,o.i)):a(pe,e));break;case pe:W(e,r);var o=Q(e.d);e.c===o||r.c<y?(s.cacheReads++,A(r.i+r.c),e.complete()):a(me,r.i+y);break;default:return B(e,t,n,r,!1)}}return!0},B=function(n,e,t,r,a){var o,i=n.error,l=n.transition,u=n.wait;switch(e){case ce:w();break;case me:o=x(r).then(function(e,t){n.canceled||(e?l(pe,t):l(ye,r))});break;case ye:o=P(r).then(function(e){n.canceled||(a?s.prefetches++:s.netReads++,l(he,e))},i);break;case he:t!==ue&&(T(ue),o=I(r.i,r).then(function(e){n.canceled||(!e&&a&&(n.pending=0),l(pe,r)),T(ae)}));break;default:return!1}return o&&(n.canceled?o.cancel():n.s===e&&u(o)),!0};return b.read("__settings",function(e,t){var n;H(t)?(n=t.version)&&0===n.indexOf("1.")?y!==t.pageSize||g.identifier!==t.sourceId?N().then(function(){T(ae)},E("Unable to clear store during initialization")):(c=t.actualCacheSize,d=t.allDataLocal,f=t.cacheSize,p=t.collectionCount,r=t.highestSavedPage,m=t.highestSavedPageSize,v=n,T(ae)):E("Unsupported cache store version "+n)():R(function(){T(ae)},E("Unable to write settings during initialization."))},E("Unable to read settings from store.")),D}ve.prototype.fireResolved=function(){var e=this.p;e&&(this.p=null,e.resolve(this.d))},ve.prototype.fireRejected=function(e){var t=this.p;t&&(this.p=null,t.reject(e))},ve.prototype.fireCanceled=function(){this.fireRejected({canceled:!0,message:"Operation canceled"})},e.estimateSize=te,e.createDataCache=function(e){if(!function(e,t){if(void 0!==e){if("number"!=typeof e)throw{message:"'"+t+"' must be a number."};if(isNaN(e)||e<=0||!isFinite(e))throw{message:"'"+t+"' must be greater than zero."}}}(e.pageSize,"pageSize"),a(e.cacheSize,"cacheSize"),a(e.prefetchSize,"prefetchSize"),!H(e.name))throw{message:"Undefined or null name",options:e};if(!H(e.source))throw{message:"Undefined source",options:e};return new l(e)}},source:function(e,t,n){"use strict";var r=n("./../utils.js"),d=n("./../odata.js"),s=r.parseInt10,a=r.normalizeURICase;function f(e,t){return{method:"GET",requestUri:e,user:t.user,password:t.password,enableJsonpCallback:t.enableJsonpCallback,callbackParameterName:t.callbackParameterName,formatQueryString:t.formatQueryString}}function o(e,t,n,r){return function a(o,i,l,u,s){var e=f(o,i);var c=d.request(e,function(e){var t,n=e["@odata.nextLink"];if(!n||-1!=(t=o.indexOf(".svc/",0))&&(n=o.substring(0,t+5)+n),l.value&&e.value)l.value=l.value.concat(e.value);else for(var r in e)"@odata.nextLink"!=r&&(l[r]=e[r]);n?c=a(n,i,l,u,s):u(l)},s,void 0,i.httpClient,i.metadata);return{abort:function(){c.abort()}}}(e,t,{},n,r)}e.ODataCacheSource=function(e){var l=this,u=e.source;return l.identifier=a(encodeURI(decodeURI(u))),l.options=e,l.count=function(t,n){var e,r,a,o,i=l.options;return d.request(f((r="$count",a=(e=u).indexOf("?"),o="",0<=a&&(o=e.substr(a),e=e.substr(0,a)),"/"!==e[e.length-1]&&(e+="/"),e+r+o),i),function(e){e=s(e.toString());isNaN(e)?n({message:"Count is NaN",count:e}):t(e)},n,void 0,i.httpClient,i.metadata)},l.read=function(e,t,n,r){var a;return o((a="$skip="+e+"&$top="+t,t=0<=(e=u).indexOf("?")?"&":"?",e+t+a),l.options,n,r)},l}},deferred:function(e,t,n){"use strict";function r(){this._arguments=void 0,this._done=void 0,this._fail=void 0,this._resolved=!1,this._rejected=!1}r.prototype={then:function(e,t){return e&&(this._done?this._done.push(e):this._done=[e]),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 e=0,t=this._done.length;e<t;e++)this._done[e].apply(null,arguments);this._done=void 0,this._resolved=!1,this._arguments=void 0}else this._resolved=!0,this._arguments=arguments},reject:function(){if(this._fail){for(var e=0,t=this._fail.length;e<t;e++)this._fail[e].apply(null,arguments);this._fail=void 0,this._rejected=!1,this._arguments=void 0}else this._rejected=!0,this._arguments=arguments},promise:function(){var e,t,n,r={};return r.then=(e=this,t="then",n=r,function(){return e[t].apply(e,arguments),n}),r}},e.createDeferred=function(){return new(window.jQuery&&window.jQuery.Deferred?window.jQuery.Deferred:r)},e.DjsDeferred=r},odata:function(i,e,t){"use strict";var l=t("./utils.js"),u=i.utils=t("./odata/odatautils.js"),n=i.handler=t("./odata/handler.js"),r=i.metadata=t("./odata/metadata.js"),a=i.netServer=t("./odata/net.js"),o=i.netBrowser=t("./odata/net-browser.js"),s=i.net=l.inBrowser()?o:a,c=i.json=t("./odata/json.js");i.batch=t("./odata/batch.js");var d=l.assigned,a=(l.defined,l.throwErrorCallback),t=(u.invokeRequest,n.MAX_DATA_SERVICE_VERSION),f=(u.prepareRequest,r.metadataParser),p=[c.jsonHandler,n.textHandler];function m(e,t,n){for(var r=0,a=p.length;r<a&&!p[r][e](t,n);r++);if(r===a)throw{message:"no handler for data"}}i.defaultSuccess=function(e){window.alert(window.JSON.stringify(e))},i.defaultError=a,i.defaultHandler={read:function(e,t){e&&d(e.body)&&e.headers["Content-Type"]&&m("read",e,t)},write:function(e,t){m("write",e,t)},maxDataServiceVersion:t,accept:"application/json;q=0.9, */*;q=0.1"},i.defaultMetadata=[],i.read=function(e,t,n,r,a,o){e=e instanceof String||"string"==typeof e?{requestUri:e}:e;return i.request(e,t,n,r,a,o)},i.request=function(e,t,n,r,a,o){t=t||i.defaultSuccess,n=n||i.defaultError,r=r||i.defaultHandler,a=a||s.defaultHttpClient,o=o||i.defaultMetadata,e.recognizeDates=l.defined(e.recognizeDates,c.jsonHandler.recognizeDates),e.callbackParameterName=l.defined(e.callbackParameterName,a.callbackParameterName,s.defaultHttpClient.callbackParameterName),e.formatQueryString=l.defined(e.formatQueryString,a.formatQueryString,s.defaultHttpClient.formatQueryString),e.enableJsonpCallback=l.defined(e.enableJsonpCallback,a.enableJsonpCallback,s.defaultHttpClient.enableJsonpCallback);o={metadata:o,recognizeDates:e.recognizeDates,callbackParameterName:e.callbackParameterName,formatQueryString:e.formatQueryString,enableJsonpCallback:e.enableJsonpCallback};try{return u.prepareRequest(e,r,o),u.invokeRequest(e,t,n,r,a,o)}catch(e){if(e.bIsSuccessHandlerError)throw e;n(e)}},i.parseMetadata=function(e){return f(null,e)},i.batch.batchHandler.partHandler=i.defaultHandler,i.metadataHandler=r.metadataHandler,i.jsonHandler=c.jsonHandler},batch:function(e,t,n){"use strict";var r=n("./../utils.js"),a=n("./odatautils.js"),n=n("./handler.js"),s=r.extend,c=r.isArray,u=(r.trimString,n.contentType),d=n.handler,l=a.isBatch,n=n.MAX_DATA_SERVICE_VERSION,i=a.normalizeHeaders,f=a.prepareRequest,p="multipart/mixed",m=/^HTTP\/1\.\d (\d{3}) (.*)$/i,h=/^([^()<>@,;:\\"\/[\]?={} \t]+)\s?:\s?(.*)/;function o(){return Math.floor(65536*(1+Math.random())).toString(16).substr(1)}function y(e){return e+o()+"-"+o()+"-"+o()}function v(e){return e.handler.partHandler}function g(e){e=e.boundaries;return e[e.length-1]}function b(e,t,n){if((n.contentType=n.contentType||u(p)).mediaType===p)return function(e,t){if(!l(e))throw{message:"Data is not a batch object."};var n,r,a=y("batch_"),o=e.__batchRequests,i="";for(n=0,r=o.length;n<r;n++)i+=O(a,!1)+function e(t,n,r){var a=t.__changeRequests;var o;if(c(a)){if(r)throw{message:"Not Supported: change set nested in other change set"};var i,l,u=y("changeset_");for(o="Content-Type: "+p+"; boundary="+u+"\r\n",i=0,l=a.length;i<l;i++)o+=O(u,!1)+e(a[i],n,!0);o+=O(u,!0)}else{o="Content-Type: application/http\r\nContent-Transfer-Encoding: binary\r\n\r\n";r=s({},n);r.handler=d,r.request=t,r.contentType=null,f(t,v(n),r),o+=P(t)}return o}(o[n],t);return i+=O(a,!0),t.contentType.properties.boundary=a,i}(t,n)}function D(e,t){for(var n,r,a,o={};a=t.position,r=T(e,t),null!==(n=h.exec(r))?o[n[1]]=n[2]:t.position=a,r&&n;);return i(o),o}function E(e,t,n){var r,a,o,i=t.position,l=m.exec(T(e,t));return l?(r=l[1],a=l[2],o=D(e,t),T(e,t)):t.position=i,{statusCode:r,statusText:a,headers:o,body:N(e,t,"\r\n"+n)}}function T(e,t){return N(e,t,"\r\n")}function N(e,t,n){var r=t.position||0,a=e.length;if(n){if(-1===(a=e.indexOf(n,r)))return null;t.position=a+n.length}else t.position=a;return e.substring(r,a)}function O(e,t){e="\r\n--"+e;return t&&(e+="--"),e+"\r\n"}function P(e){var t,n=(e.method||"GET")+" "+e.requestUri+" HTTP/1.1\r\n";for(t in e.headers)e.headers[t]&&(n=n+t+": "+e.headers[t]+"\r\n");return n+="\r\n",e.body&&(n+=e.body),n}e.batchHandler=d(function(e,t,n){return{__batchResponses:function e(t,n){var r="--"+g(n);N(t,n,r);T(t,n);var a=[];var o=null;for(;"--"!==o&&n.position<t.length;){var i,l=D(t,n),l=u(l["Content-Type"]);if(l&&l.mediaType===p){n.boundaries.push(l.properties.boundary);try{i=e(t,n)}catch(e){e.response=E(t,n,r),i=[e]}a.push({__changeResponses:i}),n.boundaries.pop(),N(t,n,"--"+g(n))}else{if(!l||"application/http"!==l.mediaType)throw{message:"invalid MIME part type "};T(t,n);l=E(t,n,r);try{200<=l.statusCode&&l.statusCode<=299?v(n.handlerContext).read(l,n.handlerContext):l={message:"HTTP request failed",response:l}}catch(e){l=e}a.push(l)}o=t.substr(n.position,2),T(t,n)}return a}(t,{boundaries:[n.contentType.properties.boundary],handlerContext:n})}},b,p,n),e.batchSerializer=b,e.writeRequest=P},handler:function(e,t,n){"use strict";var r=n("./../utils.js"),n=n("./odatautils.js"),l=r.assigned,o=r.extend,i=r.trimString,u=n.maxVersion;function a(e){if(!e)return null;for(var t=e.split(";"),n={},r=1,a=t.length;r<a;r++){var o=t[r].split("=");n[i(o[0])]=o[1]}return{mediaType:i(t[0]),properties:n}}function s(e){if(e){var t,n=e.mediaType;for(t in e.properties)n+=";"+t+"="+e.properties[t];return n}}function c(e,t,n,r){var a={};return o(a,n),o(a,{contentType:e,dataServiceVersion:t,handler:r}),a}function d(e,t,n){e&&((e=e.headers)[t]||(e[t]=n))}function f(e,t){e=e.headers;return e&&e[t]||void 0}function p(e){return a(f(e,"Content-Type"))}var m=/^\s?(\d+\.\d+);?.*$/;function h(e){e=f(e,"OData-Version");if(e){e=m.exec(e);if(e&&e.length)return e[1]}}function y(e,t){return 0<=e.accept.indexOf(t.mediaType)}function v(e,t,n,r){if(!n||!n.headers)return!1;var a=p(n),o=h(n);if(!a||y(e,a)){a=c(a,o,r,e);if((a.request=n).body=t(e,n.data,a),void 0!==n.body)return o=n,r=a.dataServiceVersion||"4.0",o&&(o=(t=o.headers)["OData-Version"],t["OData-Version"]=o?u(o,r):r),d(n,"Content-Type",s(a.contentType)),d(n,"OData-MaxVersion",e.maxDataServiceVersion),!0}return!1}function g(n,r,e,t){return{accept:e,maxDataServiceVersion:t,read:function(e,t){return function(e,t,n,r){if(!n||!n.headers)return!1;var a=p(n),o=h(n)||"",i=n.body;if(!l(i))return!1;if(y(e,a)){r=c(a,o,r,e);return(r.response=n).data=t(e,i,r),void 0!==n.data}return!1}(this,n,e,t)},write:function(e,t){return v(this,r,e,t)}}}e.textHandler=g(function(e,t){return t},function(e,t){if(l(t))return t.toString()},"text/plain","4.0"),e.contentType=a,e.contentTypeToString=s,e.handler=g,e.createReadWriteContext=c,e.fixRequestHeader=d,e.getRequestOrResponseHeader=f,e.getContentType=p,e.getDataServiceVersion=h,e.MAX_DATA_SERVICE_VERSION="4.0"},json:function(e,t,n){var f=n("./../utils.js"),p=n("./odatautils.js"),r=n("./handler.js"),o="@odata.context",u=f.assigned,m=f.defined,h=f.isArray,y=f.isObject,a=f.parseInt10,i=f.getFormatKind,l=f.convertByteArrayToHexString,s=(p.formatDateTimeOffset,p.formatDuration),c=p.formatNumberWidth,d=(p.getCanonicalTimezone,p.handler,p.isComplex,p.isPrimitive),v=p.isCollectionType,g=p.lookupComplexType,b=p.lookupEntityType,D=p.lookupSingleton,E=p.lookupEntitySet,T=p.lookupDefaultEntityContainer,N=p.lookupProperty,O=p.MAX_DATA_SERVICE_VERSION,P=p.maxVersion,S=p.isPrimitiveEdmType,w=p.isGeographyEdmType,A=p.isGeometryEdmType,C="f",x="e",I="p",R="c",M="s",_="erl",L="erls",G="v",j="f",k="de",B="l",U="dl",n="application/json",q=r.contentType(n),F=["@odata.id","@odata.type"];function H(e,t,n){var r=m(n.recognizeDates,e.recognizeDates),e=n.metadata,t="string"==typeof t?JSON.parse(t):t;u(n.contentType)&&u(n.contentType.properties)&&(a=n.contentType.properties["odata.metadata"]);var a=i(a,1);return 0===a?t:1===a?function(e,t,n){if(!u(t)||h(t))return e;var r=e[o],a=re(e,t);switch(a.detectedPayloadKind){case G:return null!==a.type?X(e,a,r,t,n):Z(e,"value",a.typeName);case C:return function(e,t,n,r,a){var o,i,l=[],u=e.value;for(o=0,i=u.length;o<i;o++){var s,c,d=u[o];d=m(d["@odata.type"])?(c=d["@odata.type"].substring(1),s=b(c,t),c={contentTypeOdata:n.contentTypeOdata,detectedPayloadKind:n.detectedPayloadKind,name:n.name,type:s,typeName:c},X(d,c,r,t,a)):X(d,n,r,t,a),l.push(d)}return e.value=l,e}(e,t,a,r,n);case x:return X(e,a,r,t,n);case R:return function(e,t,n,r,a){if(W(e,"",n.typeName),null!==n.type){var o,i,l=[],u=e.value;for(o=0,i=u.length;o<i;o++){var s,c,d=u[o];d=m(d["@odata.type"])?(c=d["@odata.type"].substring(1),s=b(c,t),c={contentTypeOdata:n.contentTypeOdata,detectedPayloadKind:n.detectedPayloadKind,name:n.name,type:s,typeName:c},X(d,c,r,t,a)):X(d,n,r,t,a),l.push(d)}e.value=l}return e}(e,t,a,r,n);case I:return null!==a.type?X(e,a,r,t,n):Z(e,"value",a.typeName);case M:return e}return e}(t,e,r):2===a?function e(t,n,r){var a;if(f.isObject(t))for(var o in t){var i;if(t.hasOwnProperty(o))if(-1===o.indexOf("@"))if(f.isArray(t[o]))for(var l=0;l<t[o].length;++l)e(t[o][l],n,r);else f.isObject(t[o])?null!==t[o]&&((a=t[o+"@odata.type"])?(a=a.substring(1),w(a)||A(a)||e(t[o],n,r)):e(t[o],n,r)):(a=t[o+"@odata.type"],u(a)?r&&ee(t,o,a.substring(1)):"string"==(i=typeof t[o])?Q(t,o,"String"):"boolean"==i?Q(t,o,"Boolean"):"number"==i&&(t[o]%1==0?Q(t,o,"Int32"):Q(t,o,"Decimal")))}return t}(t,e,r):t}function V(e,t){return t&&"Edm.Time"===t.__edmType?s(t):t}var z=/^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/;function J(e,t,n){var r=n.dataServiceVersion||"4.0",a=n.contentType=n.contentType||q;if(a&&a.mediaType===q.mediaType){n.dataServiceVersion=P(r,"4.0");t=function e(t){if(!t)return t;if(d(t))return t;if(h(t)){var n,r,a=[];for(n=0,r=t.length;n<r;n++)a[n]=e(t[n]);return a}var o={};for(var i in t)K(i)&&(o[i]=e(t[i]));return o}(t);if(t)return JSON.stringify(t,V)}}function K(e){if(!e)return!1;if(-1==e.indexOf("@odata."))return!0;for(var t=0,n=F.length;t<n;t++){var r=F[t];if(-1!=e.indexOf(r))return!0}return!1}function Y(e,t,n,r,a){for(var o in e)if(-1===o.indexOf("@")){for(var i=t,l=e[o],u=N(i.property,o);null===u&&void 0!==i.baseType;)i=b(i.baseType,r),u=N(i.property,o);if(h(l)){v(u.type)?W(e,o,u.type.substring(11,u.type.length-1)):Z(e,o,u.type);for(var s=0;s<l.length;s++)$(l[s],u,n,r,a)}else y(l)&&null!==l?$(l,u,n,r,a):(Z(e,o,u.type),a&&(c=e,d=o,"Edm.Date"===(f=u.type)?c[d]=p.parseDate(c[d],!0):"Edm.DateTimeOffset"===f?c[d]=p.parseDateTimeOffset(c[d],!0):"Edm.Duration"===f?c[d]=p.parseDuration(c[d],!0):"Edm.Time"===f&&(c[d]=p.parseTime(c[d],!0))))}var c,d,f}function X(e,t,n,r,a){Q(e,"",t.typeName);for(var o,i=t.type;m(i)&&void 0===i.key&&void 0!==i.baseType;)i=b(i.baseType,r);return void 0!==i.key&&(o=t.name+function(e,t){var n,r,a=t.key.propertyRef;if(n="(",1==a.length)r=N(t.property,a[0].name).type,n+=te(e[a[0].name],r);else for(var o=!0,i=0;i<a.length;i++)o?o=!1:n+=",",r=N(t.property,a[i].name).type,n+=a[i].name+"="+te(e[a[i].name],r);return n+=")"}(e,i),e["@odata.id"]=n.substring(0,n.lastIndexOf("$metadata"))+o,e["@odata.editLink"]=o),Y(e,t.type,n,r,a),e}function $(e,t,n,r,a){var o=t.type;v(t.type)&&(o=t.type.substring(11,t.type.length-1)),Q(e,"",t.type);o=g(o,r);null!==o&&Y(e,o,n,r,a)}function Q(e,t,n){t+="@odata.type";void 0===e[t]&&(e[t]="#"+n)}function W(e,t,n){t+="@odata.type";void 0===e[t]&&("Edm."===n.substring(0,4)?e[t]="#Collection("+n.substring(4)+")":e[t]="#Collection("+n+")")}function Z(e,t,n){t+="@odata.type";return void 0===e[t]&&("Edm."===n.substring(0,4)?e[t]="#"+n.substring(4):e[t]="#"+n),e}function ee(e,t,n){"Date"===n?e[t]=p.parseDate(e[t],!0):"DateTimeOffset"===n?e[t]=p.parseDateTimeOffset(e[t],!0):"Duration"===n?e[t]=p.parseDuration(e[t],!0):"Time"===n&&(e[t]=p.parseTime(e[t],!0))}function te(e,t){var n;switch(e=""+(n=e,"Edm.Binary"!==t?n:l(n)),e=encodeURIComponent(e.replace("'","''")),t){case"Edm.Binary":return"X'"+e+"'";case"Edm.DateTime":return"datetime'"+e+"'";case"Edm.DateTimeOffset":return"datetimeoffset'"+e+"'";case"Edm.Decimal":return e+"M";case"Edm.Guid":return"guid'"+e+"'";case"Edm.Int64":return e+"L";case"Edm.Float":return e+"f";case"Edm.Double":return e+"D";case"Edm.Geography":return"geography'"+e+"'";case"Edm.Geometry":return"geometry'"+e+"'";case"Edm.Time":return"time'"+e+"'";case"Edm.String":return"'"+e+"'";default:return e}}function ne(e,t){var n={};if(-1===e.indexOf("/")){if(0===e.length)return n.detectedPayloadKind=M,n;if("Edm.Null"===e)return n.detectedPayloadKind=G,n.isNullProperty=!0,n;if("Collection($ref)"===e)return n.detectedPayloadKind=L,n;if("$ref"===e)return n.detectedPayloadKind=_,n}n.type=void 0,n.typeName=void 0;for(var r,a=e.split("/"),o=0;o<a.length;++o){var i,l,u=a[o];if(void 0===n.typeName){if(-1!==u.indexOf("(")){for(var s=u.length-2,c=1;0<c&&0<s;--s)"("==u.charAt(s)?c--:")"==u.charAt(s)&&c++;var d=u.substring(s+2,u.length-1),u=u.substring(0,s+1);if(f.startsWith(u,"Collection")){if(n.detectedPayloadKind=R,n.typeName=d,null!==(r=b(n.typeName,t))){n.type=r;continue}if(null!==(r=g(n.typeName,t))){n.type=r;continue}n.type=null;continue}n.projection=d}S(d=u)||w(d)||A(d)?(n.typeName=u,n.type=null,n.detectedPayloadKind=G):(d=T(t),null===(l=E(d.entitySet,u))?null===(i=D(d.singleton,u))||(n.typeName=i.entityType,n.type=b(n.typeName,t),n.name=u,n.detectedPayloadKind=x):(n.typeName=l.entityType,n.type=b(n.typeName,t),n.name=u,n.detectedPayloadKind=C))}else if(f.endsWith(u,"$entity")&&n.detectedPayloadKind===C)n.detectedPayloadKind=x;else{if(-1!==u.indexOf(".")){if(n.typeName=u,null!==(r=b(n.typeName,t))){n.type=r;continue}if(null!==(r=g(n.typeName,t))){n.type=r;continue}}n.detectedPayloadKind!==C&&n.detectedPayloadKind!==x?"$delta"!==u?f.endsWith(u,"/$deletedEntity")?n.deltaKind=k:f.endsWith(u,"/$link")?n.deltaKind=B:f.endsWith(u,"/$deletedLink")&&(n.deltaKind=U):n.deltaKind=j:null!==(i=N(n.type.property,u))&&(n.typeName=i.type,f.startsWith(i.type,"Collection")?(n.detectedPayloadKind=R,l=i.type.substring(11,i.type.length-1),n.typeName=l,n.type=g(l,t),n.detectedPayloadKind=R):(n.type=g(i.type,t),n.detectedPayloadKind=I),n.name=u)}}return n}function re(e,t){var n=e[o];if(!n||"string"!=typeof n)return null;e=n.lastIndexOf("#");return-1===e?{kind:M,type:null}:ne(n.substring(e+1),t)}O=r.handler(H,J,n,O);O.recognizeDates=!1,e.createPayloadInfo=re,e.jsonHandler=O,e.jsonParser=H,e.jsonSerializer=J,e.parseJsonDateString=function(e){var t=e&&z.exec(e);if(t){var n=new Date(a(t[1]));if(t[2]&&(e=a(t[3]),"-"===t[2]&&(e=-e),t=n.getUTCMinutes(),n.setUTCMinutes(t-e),n.__edmType="Edm.DateTimeOffset",n.__offset=function(e){var t;e<0?(t="-",e=-e):t="+";var n=Math.floor(e/60);return e-=60*n,t+c(n,2)+":"+c(e,2)}(e)),!isNaN(n.valueOf()))return n}}},metadata:function(e,t,n){"use strict";var r=n("./../utils.js"),a=n("./../xml.js"),n=n("./handler.js"),i=r.contains,l=(r.normalizeURI,a.xmlAttributes),u=a.xmlChildElements,o=a.xmlFirstChildElement,s=a.xmlInnerText,c=a.xmlLocalName,d=a.xmlNamespaceURI,f=(a.xmlNS,a.xmlnsNS),p=a.xmlParse,r=a.http+"docs.oasis-open.org/odata/"+"ns",a=r+"/edmx",m=r+"/edm",h=r+"/metadata",r=n.MAX_DATA_SERVICE_VERSION;function y(e,t,n,r){return{attributes:e,elements:t,text:n||!1,ns:r}}var v={elements:{Action:y(["Name","IsBound","EntitySetPath"],["ReturnType","Parameter*","Annotation*"]),ActionImport:y(["Name","Action","EntitySet","Annotation*"]),Annotation:y(["Term","Qualifier","Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","AnnotationPath","NavigationPropertyPath","Path","PropertyPath","UrlRef"],["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),AnnotationPath:y(null,null,!0),Annotations:y(["Target","Qualifier"],["Annotation*"]),Apply:y(["Function"],["Binary*","Bool*","Date*","DateTimeOffset*","Decimal*","Duration*","EnumMember*","Float*","Guid*","Int*","String*","TimeOfDay*","And*","Or*","Not*","Eq*","Ne*","Gt*","Ge*","Lt*","Le*","AnnotationPath*","Apply*","Cast*","Collection*","If*","IsOf*","LabeledElement*","LabeledElementReference*","Null*","NavigationPropertyPath*","Path*","PropertyPath*","Record*","UrlRef*","Annotation*"]),And:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Or:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Not:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Eq:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Ne:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Gt:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Ge:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Lt:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Le:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Binary:y(null,null,!0),Bool:y(null,null,!0),Cast:y(["Type"],["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Collection:y(null,["Binary*","Bool*","Date*","DateTimeOffset*","Decimal*","Duration*","EnumMember*","Float*","Guid*","Int*","String*","TimeOfDay*","And*","Or*","Not*","Eq*","Ne*","Gt*","Ge*","Lt*","Le*","AnnotationPath*","Apply*","Cast*","Collection*","If*","IsOf*","LabeledElement*","LabeledElementReference*","Null*","NavigationPropertyPath*","Path*","PropertyPath*","Record*","UrlRef*"]),ComplexType:y(["Name","BaseType","Abstract","OpenType"],["Property*","NavigationProperty*","Annotation*"]),Date:y(null,null,!0),DateTimeOffset:y(null,null,!0),Decimal:y(null,null,!0),Duration:y(null,null,!0),EntityContainer:y(["Name","Extends"],["EntitySet*","Singleton*","ActionImport*","FunctionImport*","Annotation*"]),EntitySet:y(["Name","EntityType","IncludeInServiceDocument"],["NavigationPropertyBinding*","Annotation*"]),EntityType:y(["Name","BaseType","Abstract","OpenType","HasStream"],["Key","Property*","NavigationProperty*","Annotation*"]),EnumMember:y(null,null,!0),EnumType:y(["Name","UnderlyingType","IsFlags"],["Member*"]),Float:y(null,null,!0),Function:y(["Name","IsBound","IsComposable","EntitySetPath"],["ReturnType","Parameter*","Annotation*"]),FunctionImport:y(["Name","Function","EntitySet","IncludeInServiceDocument","Annotation*"]),Guid:y(null,null,!0),If:y(null,["Binary*","Bool*","Date*","DateTimeOffset*","Decimal*","Duration*","EnumMember*","Float*","Guid*","Int*","String*","TimeOfDay*","And*","Or*","Not*","Eq*","Ne*","Gt*","Ge*","Lt*","Le*","AnnotationPath*","Apply*","Cast*","Collection*","If*","IsOf*","LabeledElement*","LabeledElementReference*","Null*","NavigationPropertyPath*","Path*","PropertyPath*","Record*","UrlRef*","Annotation*"]),Int:y(null,null,!0),IsOf:y(["Type","MaxLength","Precision","Scale","SRID","Annotation*"],["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Key:y(null,["PropertyRef*"]),LabeledElement:y(["Name"],["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),LabeledElementReference:y(null,null,!0),Member:y(["Name","Value"],["Annotation*"]),NavigationProperty:y(["Name","Type","Nullable","Partner","ContainsTarget"],["ReferentialConstraint*","OnDelete","Annotation*"]),NavigationPropertyBinding:y(["Path","Target"]),NavigationPropertyPath:y(null,null,!0),Null:y(null,["Annotation*"]),OnDelete:y(["Action"],["Annotation*"]),Path:y(null,null,!0),Parameter:y(["Name","Type","Nullable","MaxLength","Precision","Scale","SRID"],["Annotation*"]),Property:y(["Name","Type","Nullable","MaxLength","Precision","Scale","Unicode","SRID","DefaultValue"],["Annotation*"]),PropertyPath:y(null,null,!0),PropertyRef:y(["Name","Alias"]),PropertyValue:y(["Property","Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","AnnotationPath","NavigationPropertyPath","Path","PropertyPath","UrlRef"],["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Record:y(null,["PropertyValue*","Annotation*"]),ReferentialConstraint:y(["Property","ReferencedProperty","Annotation*"]),ReturnType:y(["Type","Nullable","MaxLength","Precision","Scale","SRID"]),String:y(null,null,!0),Schema:y(["Namespace","Alias"],["Action*","Annotations*","Annotation*","ComplexType*","EntityContainer","EntityType*","EnumType*","Function*","Term*","TypeDefinition*","Annotation*"]),Singleton:y(["Name","Type"],["NavigationPropertyBinding*","Annotation*"]),Term:y(["Name","Type","BaseTerm","DefaultValue ","AppliesTo","Nullable","MaxLength","Precision","Scale","SRID"],["Annotation*"]),TimeOfDay:y(null,null,!0),TypeDefinition:y(["Name","UnderlyingType","MaxLength","Unicode","Precision","Scale","SRID"],["Annotation*"]),UrlRef:y(null,["Binary","Bool","Date","DateTimeOffset","Decimal","Duration","EnumMember","Float","Guid","Int","String","TimeOfDay","And","Or","Not","Eq","Ne","Gt","Ge","Lt","Le","AnnotationPath","Apply","Cast","Collection","If","IsOf","LabeledElement","LabeledElementReference","Null","NavigationPropertyPath","Path","PropertyPath","Record","UrlRef","Annotation*"]),Edmx:y(["Version"],["DataServices","Reference*"],!1,a),DataServices:y(["m:MaxDataServiceVersion","m:DataServiceVersion"],["Schema*"],!1,a),Reference:y(["Uri"],["Include*","IncludeAnnotations*","Annotation*"],!1,a),Include:y(["Namespace","Alias"],null,!1,a),IncludeAnnotations:y(["TermNamespace","Qualifier","TargetNamespace"],null,!1,a)}};function g(e){if(!e)return e;if(1<e.length){var t=e.substr(0,2);return t===t.toUpperCase()?e:e.charAt(0).toLowerCase()+e.substr(1)}return e.charAt(0).toLowerCase()}function b(e,t){var n,r,a=e.elements;if(!a)return null;for(n=0,r=a.length;n<r;n++){var o=a[n],i=!1;if("*"===o.charAt(o.length-1)&&(i=!0,o=o.substr(0,o.length-1)),t===o)return{isArray:i,propertyName:g(o)}}return null}function D(e){return e===m}function E(e){var t=c(e),n=d(e),r=v.elements[t];if(!r)return null;if(r.ns){if(n!==r.ns)return null}else if(!D(n))return null;var a={},o=r.attributes||[];return l(e,function(e){var t=c(e),n=d(e),r=e.value;n!==f&&(e=null,D(n)||null===n?e="":n===h&&(e="m:"),null!==e&&i(o,e+=t)&&(a[g(t)]=r))}),u(e,function(e){var t=c(e),n=b(r,t);n&&(n.isArray?((t=a[n.propertyName])||(a[n.propertyName]=t=[]),t.push(E(e))):a[n.propertyName]=E(e))}),r.text&&(a.text=s(e)),a}function T(e,t){t=p(t);return E(o(t))||void 0}e.metadataHandler=n.handler(T,null,"application/xml",r),e.schema=v,e.scriptCase=g,e.getChildSchema=b,e.parseConceptualModelElement=E,e.metadataParser=T},net:function(e,t,n){var n=n("./../utils.js"),y=n.defined,v=n.delay,g=0;function b(e){return!(e.method&&"GET"!==e.method)}function r(e){return 0===e.indexOf("http://")||0===e.indexOf("https://")||0===e.indexOf("file://")}function D(e){if(!r(e))return!0;var t=window.location,t=t.protocol+"//"+t.host+"/";return 0===e.indexOf(t)}function E(e){return e&&(T(e,""),e.parentNode.removeChild(e)),null}function T(e,t){e=(e.contentWindow||e.contentDocument).document;e.open(),e.write(t),e.close()}e.defaultHttpClient={callbackParameterName:"$callback",formatQueryString:"$format=json",enableJsonpCallback:!1,request:function(){var h=this;return function(r,a,o){var n,e={},i=null,l=!1;e.abort=function(){n=E(n),l||(l=!0,i&&(i.abort(),i=null),o({message:"Request aborted"}))};function t(){n=E(n),l||(l=!0,i=null,o({message:"Request timed out"}))}var u=r.requestUri,s=y(r.enableJsonpCallback,h.enableJsonpCallback),c=y(r.callbackParameterName,h.callbackParameterName),d=y(r.formatQueryString,h.formatQueryString);if(!s||D(u)){if((i=function(){if(window.XMLHttpRequest)return new window.XMLHttpRequest;var t;if(window.ActiveXObject)try{return new window.ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){try{return new window.ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){t=e}}else t={message:"XMLHttpRequest not supported"};throw t}()).onreadystatechange=function(){var e,t,n;l||null===i||4!==i.readyState||(e=i.statusText,1223===(t=i.status)&&(t=204,e="No Content"),function(e,t){for(var n,r=e.getAllResponseHeaders().split(/\r?\n/),a=0,o=r.length;a<o;a++)r[a]&&(t[(n=r[a].split(": "))[0]]=n[1])}(i,n=[]),n={requestUri:u,statusCode:t,statusText:e,headers:n,body:i.responseText},l=!0,i=null,200<=t&&t<=299?a(n):o({message:"HTTP request failed",request:r,response:n}))},i.open(r.method||"GET",u,!0,r.user,r.password),r.headers)for(p in r.headers)i.setRequestHeader(p,r.headers[p]);r.withCredentials&&(i.withCredentials=!0),r.timeoutMS&&(i.timeout=r.timeoutMS,i.ontimeout=t),void 0===r.body?i.send():i.send(r.body)}else{if(!b(r))throw{message:"Request is not local and cannot be done through JSONP."};var f=g;g+=1;var s=f.toString(),p="handleJSONP_"+s;window[p]=function(e){var t;n=E(n),l||(window.clearTimeout(m),function(t,n){try{delete window[t]}catch(e){window[t]=void 0,n===g-1&&--g}}(p,f),window.ActiveXObject&&(e=window.JSON.parse(window.JSON.stringify(e))),t=d&&"$format=json"!=d?{"Content-Type":d.substring(8),"OData-Version":"4.0"}:{"Content-Type":"application/json;odata.metadata=minimal","OData-Version":"4.0"},v(function(){E(n),a({body:e,statusCode:200,headers:t})}))};var s=r.timeoutMS||12e4,m=window.setTimeout(t,s),s=c+"=parent."+p;d&&(s+="&"+d);var c=u.indexOf("?");-1===c?u=u+"?"+s:c===u.length-1?u+=s:u=u+"&"+s,c=u,(s=window.document.createElement("IFRAME")).style.display="none",c='<html><head><script type="text/javascript" src="'+c.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")+'"><\/script></head><body></body></html>',window.document.getElementsByTagName("BODY")[0].appendChild(s),T(s,c),n=s}return e}}()},e.canUseJSONP=b,e.isAbsoluteUrl=r,e.isLocalUrl=D},odatautils:function(e,t,n){"use strict";var r=n("./../utils.js"),a=r.assigned,o=r.contains,i=r.find,l=r.isArray,u=r.isDate,s=r.isObject,f=r.parseInt10,c="Edm.",d=c+"Boolean",p=c+"Byte",m=c+"SByte",h=c+"Int16",y=c+"Int32",v=c+"Int64",g=c+"Single",b=c+"Double",D=c+"Decimal",E=c+"String",T=c+"Binary",N=c+"Date",O=c+"DateTimeOffset",P=c+"Duration",S=c+"Guid",w=c+"Time",A="Geography",C=c+A,x=C+"Point",I=C+"LineString",R=C+"Polygon",M=C+"Collection",_=C+"MultiPolygon",L=C+"MultiLineString",G=C+"MultiPoint",j="Geometry",k=c+j,B=k+"Point",U=k+"LineString",q=k+"Polygon",F=k+"Collection",n=k+"MultiPolygon",r=k+"MultiLineString",c=k+"MultiPoint",H=[E,y,v,d,b,g,N,O,P,w,D,S,p,h,m,T],V=[k,B,U,q,F,n,r,c],z=[j,"GeometryPoint","GeometryLineString","GeometryPolygon","GeometryCollection","GeometryMultiPolygon","GeometryMultiLineString","GeometryMultiPoint"],J=[C,x,I,R,M,_,L,G],K=[A,"GeographyPoint","GeographyLineString","GeographyPolygon","GeographyCollection","GeographyMultiPolygon","GeographyMultiLineString","GeographyMultiPoint"];function Y(e,t){if(!e)return null;if(l(e)){for(var n,r=0,a=e.length;r<a;r++)if(n=Y(e[r],t))return n;return null}return e.dataServices?Y(e.dataServices.schema,t):t(e)}function X(e,t){return e=0===e?"":"."+$(e.toString(),3),0<t&&(""===e&&(e=".000"),e+=$(t.toString(),4)),e}function $(e,t,n){for(var r=e.toString(10);r.length<t;)n?r+="0":r="0"+r;return r}function Q(e){return e&&"Z"!==e&&"+00:00"!==e&&"-00:00"!==e?e:"Z"}var W=/Collection\((.*)\)/;function Z(e){return W.test(e)}function ee(e){return!!e&&s(e)&&!l(e)&&!u(e)}function te(e){return"Edm.DateTimeOffset"===e.__edmType||!e.__edmType&&e.__offset}function ne(e){if(!e&&!ee(e))return!1;var t=e.__metadata||{},e=e.__deferred||{};return!t.type&&!!e.uri}function re(e){return ee(e)&&e.__metadata&&"uri"in e.__metadata}function ae(e,t){e=e&&e.results||e;return l(e)&&!Z(t)&&ee(e[0])}function oe(t,e,n){return t?Y(e,function(e){return le(t,e,n)}):null}function ie(e,t){return 0===t.indexOf(e)&&"."===t.charAt(e.length)?t.substr(e.length+1):null}function le(e,t,n){if(e&&t){var r=ie(t.namespace,e);if(r)return i(t[n],function(e){return e.name===r})}return null}var ue={"content-type":"Content-Type","content-encoding":"Content-Encoding","content-length":"Content-Length","odata-version":"OData-Version",accept:"Accept","accept-charset":"Accept-Charset","if-match":"If-Match","if-none-match":"If-None-Match","odata-isolation":"OData-Isolation","odata-maxversion":"OData-MaxVersion",prefer:"Prefer","content-id":"Content-ID","content-transfer-encoding":"Content-Transfer-Encoding",etag:"ETag",location:"Location","odata-entityid":"OData-EntityId","preference-applied":"Preference-Applied","retry-after":"Retry-After"};function se(e){for(var t in e){var n=t.toLowerCase(),r=ue[n];r&&t!==r&&(n=e[t],delete e[t],e[r]=n)}}var ce=/^(-?\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?(?:\.(\d+))?(.*)$/;var de=/^(\d+):(\d+)(:(\d+)(.(\d+))?)?$/;var fe=/^([+-])?P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d+))?S)?)?/;function pe(e){return{d:"+"===e.substring(0,1)?1:-1,h:f(e.substring(1)),m:f(e.substring(e.indexOf(":")+1))}}e.dataItemTypeName=function(e,t){return(e&&e.__metadata||{}).type||(t?t.type:null)},e.EDM_BINARY=T,e.EDM_BOOLEAN=d,e.EDM_BYTE=p,e.EDM_DATE=N,e.EDM_DATETIMEOFFSET=O,e.EDM_DURATION=P,e.EDM_DECIMAL=D,e.EDM_DOUBLE=b,e.EDM_GEOGRAPHY=C,e.EDM_GEOGRAPHY_POINT=x,e.EDM_GEOGRAPHY_LINESTRING=I,e.EDM_GEOGRAPHY_POLYGON=R,e.EDM_GEOGRAPHY_COLLECTION=M,e.EDM_GEOGRAPHY_MULTIPOLYGON=_,e.EDM_GEOGRAPHY_MULTILINESTRING=L,e.EDM_GEOGRAPHY_MULTIPOINT=G,e.EDM_GEOMETRY=k,e.EDM_GEOMETRY_POINT=B,e.EDM_GEOMETRY_LINESTRING=U,e.EDM_GEOMETRY_POLYGON=q,e.EDM_GEOMETRY_COLLECTION=F,e.EDM_GEOMETRY_MULTIPOLYGON=n,e.EDM_GEOMETRY_MULTILINESTRING=r,e.EDM_GEOMETRY_MULTIPOINT=c,e.EDM_GUID=S,e.EDM_INT16=h,e.EDM_INT32=y,e.EDM_INT64=v,e.EDM_SBYTE=m,e.EDM_SINGLE=g,e.EDM_STRING=E,e.EDM_TIMEOFDAY=w,e.GEOJSON_POINT="Point",e.GEOJSON_LINESTRING="LineString",e.GEOJSON_POLYGON="Polygon",e.GEOJSON_MULTIPOINT="MultiPoint",e.GEOJSON_MULTILINESTRING="MultiLineString",e.GEOJSON_MULTIPOLYGON="MultiPolygon",e.GEOJSON_GEOMETRYCOLLECTION="GeometryCollection",e.forEachSchema=Y,e.formatDateTimeOffset=function(e){if("string"==typeof e)return e;var t=te(e),n=Q(e.__offset);t&&"Z"!==n?(e=new Date(e.valueOf()),r=pe(n),a=e.getUTCHours()+r.d*r.h,o=e.getUTCMinutes()+r.d*r.m,e.setUTCHours(a,o)):t||(n="");var r=e.getUTCFullYear(),a=e.getUTCMonth()+1,o="";return r<=0&&(r=-(r-1),o="-"),t=X(e.getUTCMilliseconds(),e.__ns),o+$(r,4)+"-"+$(a,2)+"-"+$(e.getUTCDate(),2)+"T"+$(e.getUTCHours(),2)+":"+$(e.getUTCMinutes(),2)+":"+$(e.getUTCSeconds(),2)+t+n},e.formatDateTimeOffsetJSON=function(e){return"/Date("+e.getTime()+")/"},e.formatDuration=function(e){var t=e.ms,n="";t<0&&(n="-",t=-t);var r=Math.floor(t/864e5);t-=864e5*r;var a=Math.floor(t/36e5);t-=36e5*a;var o=Math.floor(t/6e4);t-=6e4*o;var i=Math.floor(t/1e3);return t-=1e3*i,n+"P"+$(r,2)+"DT"+$(a,2)+"H"+$(o,2)+"M"+$(i,2)+X(t,e.ns)+"S"},e.formatNumberWidth=$,e.getCanonicalTimezone=Q,e.getCollectionType=function(e){if("string"==typeof e){var t=e.indexOf(")",10);if(0===e.indexOf("Collection(")&&0<t)return e.substring(11,t)}return null},e.invokeRequest=function(n,e,r,a,t,o){return t.request(n,function(t){try{t.headers&&se(t.headers),void 0===t.data&&204!==t.statusCode&&a.read(t,o)}catch(e){return void 0===e.request&&(e.request=n),void 0===e.response&&(e.response=t),void r(e)}try{e(t.data,t)}catch(e){throw e.bIsSuccessHandlerError=!0,e}},r)},e.isBatch=function(e){return ee(e)&&l(e.__batchRequests)},e.isCollection=function(e,t){return!!(e=e&&e.results||e)&&Z(t)||!t&&l(e)&&!ee(e[0])},e.isCollectionType=Z,e.isComplex=ee,e.isDateTimeOffset=te,e.isDeferred=ne,e.isEntry=re,e.isFeed=ae,e.isGeographyEdmType=function(e){return o(J,e)||-1===e.indexOf(".")&&o(K,e)},e.isGeometryEdmType=function(e){return o(V,e)||-1===e.indexOf(".")&&o(z,e)},e.isNamedStream=function(e){if(!e&&!ee(e))return!1;var t=e.__metadata,e=e.__mediaresource;return!t&&!!e&&!!e.media_src},e.isPrimitive=function(e){return u(e)||"string"==typeof e||"number"==typeof e||"boolean"==typeof e},e.isPrimitiveEdmType=function(e){return o(H,e)},e.lookupComplexType=function(e,t){return oe(e,t,"complexType")},e.lookupDefaultEntityContainer=function(e){return Y(e,function(e){if(s(e.entityContainer))return e.entityContainer})},e.lookupEntityContainer=function(e,t){return oe(e,t,"entityContainer")},e.lookupEntitySet=function(e,t){return i(e,function(e){return e.name===t})},e.lookupSingleton=function(e,t){return i(e,function(e){return e.name===t})},e.lookupAction=function(e,t){return oe(e,t,"action")},e.lookupFunction=function(e,t){return oe(e,t,"function")},e.lookupEntityType=function(e,t){return oe(e,t,"entityType")},e.lookupActionImport=function(e,t){return i(e,function(e){return e.name===t})},e.lookupFunctionImport=function(e,t){return i(e,function(e){return e.name===t})},e.lookupNavigationPropertyType=function(e,t){var o,n,r=null;return e&&(o=e.relationship,(n=Y(t,function(e){var t=ie(e.namespace,o),n=e.association;if(t&&n)for(var r=0,a=n.length;r<a;r++)if(n[r].name===t)return n[r];return null}))&&(r=(t=(t=n.end[0]).role!==e.toRole?n.end[1]:t).type)),r},e.lookupNavigationPropertyEntitySet=function(e,t,n){if(e){var o=e.relationship,n=Y(n,function(e){for(var t=e.entityContainer,n=0;n<t.length;n++){var r=t[n].associationSet;if(r)for(var a=0;a<r.length;a++)if(r[a].association==o)return r[a]}return null});if(n&&n.end[0]&&n.end[1])return(n.end[0].entitySet==t?n.end[1]:n.end[0]).entitySet}return null},e.lookupInSchema=le,e.lookupProperty=function(e,t){return i(e,function(e){return e.name===t})},e.lookupInMetadata=oe,e.getEntitySetInfo=function(a,e){return Y(e,function(e){var t=e.entityContainer,n=t.entitySet;if(n)for(var r=0;r<n.length;r++)if(n[r].name==a)return{entitySet:n[r],containe