text: /*!
   * OpenUI5
   * (c) Copyright 2009-2019 SAP SE or an SAP affiliate company.
   * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
   */
  sap.ui.define(["sap/base/assert","sap/base/Log","sap/ui/Device","sap/ui/thirdparty/jquery"],function(e,t,a,r){"use strict";var n={EnumMember:true,Path:true,PropertyPath:true,NavigationPropertyPath:true,AnnotationPath:true};var o={Binary:true,Bool:true,Date:true,DateTimeOffset:true,Decimal:true,Duration:true,Float:true,Guid:true,Int:true,String:true,TimeOfDay:true,LabelElementReference:true,EnumMember:true,Path:true,PropertyPath:true,NavigationPropertyPath:true,AnnotationPath:true};var i={And:true,Or:true,Eq:true,Ne:true,Gt:true,Ge:true,Lt:true,Le:true,If:true,Collection:true};function s(e){return e.getAttribute("Qualifier")||e.parentNode.nodeName==="Annotations"&&e.parentNode.getAttribute("Qualifier")}var l={merge:function(e,t){var a,r;var n=["annotationsAtArrays","propertyAnnotations","EntityContainer","annotationReferences"];for(a in t){if(n.indexOf(a)!==-1){continue}l._mergeAnnotation(a,t,e)}for(var o=1;o<n.length;++o){var i=n[o];e[i]=e[i]||{};for(a in t[i]){for(r in t[i][a]){e[i][a]=e[i][a]||{};l._mergeAnnotation(r,t[i][a],e[i][a])}}}if(t.annotationsAtArrays){e.annotationsAtArrays=(e.annotationsAtArrays||[]).concat(t.annotationsAtArrays)}},_mergeAnnotation:function(e,t,a){if(Array.isArray(t[e])){a[e]=t[e].slice(0)}else{a[e]=a[e]||{};for(var r in t[e]){a[e][r]=t[e][r]}}},parse:function(e,t,a){try{l._parserData={};l._oXPath=l.getXPath();return l._parse(e,t,a)}finally{delete l._parserData;delete l._oXPath}},_parse:function(e,t,a){var n={},o,i,p,u,f,d,c,m,h,y,v,g,A,N,P,x,_,D,T,b,V,E,X,C=[];l._parserData.metadataInstance=e;l._parserData.serviceMetadata=e.getServiceMetadata();l._parserData.xmlDocument=l._oXPath.setNameSpace(t);l._parserData.schema={};l._parserData.aliases={};l._parserData.url=a?a:"metadata document";l._parserData.annotationsAtArrays=C;o=l._oXPath.selectNodes("//d:Schema",l._parserData.xmlDocument);for(E=0;E<o.length;E+=1){i=l._oXPath.nextNode(o,E);l._parserData.schema.Alias=i.getAttribute("Alias");l._parserData.schema.Namespace=i.getAttribute("Namespace")}var S={};var O=l._parseReferences(S);if(O){n.annotationReferences=S;n.aliasDefinitions=l._parserData.aliases}p=l._oXPath.selectNodes("//d:Term",l._parserData.xmlDocument);if(p.length>0){u={};for(X=0;X<p.length;X+=1){f=l._oXPath.nextNode(p,X);d=l.replaceWithAlias(f.getAttribute("Type"));u["@"+l._parserData.schema.Alias+"."+f.getAttribute("Name")]=d}n.termDefinitions=u}l._parserData.metadataProperties=l.getAllPropertiesMetadata(l._parserData.serviceMetadata);if(l._parserData.metadataProperties.extensions){n.propertyExtensions=l._parserData.metadataProperties.extensions}c=l._oXPath.selectNodes("//d:Annotations ",l._parserData.xmlDocument);for(X=0;X<c.length;X+=1){m=l._oXPath.nextNode(c,X);if(m.hasChildNodes()===false){continue}h=m.getAttribute("Target");y=h.split(".")[0];if(y&&l._parserData.aliases[y]){h=h.replace(new RegExp(y,""),l._parserData.aliases[y])}v=h;g=null;var R=null;if(h.indexOf("/")>0){v=h.split("/")[0];var F=l._parserData.serviceMetadata.dataServices&&l._parserData.serviceMetadata.dataServices.schema&&l._parserData.serviceMetadata.dataServices.schema.length;if(F){for(var M=l._parserData.serviceMetadata.dataServices.schema.length-1;M>=0;M--){var W=l._parserData.serviceMetadata.dataServices.schema[M];if(W.entityContainer){var w=v.split(".");for(var k=W.entityContainer.length-1;k>=0;k--){if(W.entityContainer[k].name===w[w.length-1]){R=h.replace(v+"/","");break}}}}}if(!R){g=h.replace(v+"/","")}}if(g){if(!n.propertyAnnotations){n.propertyAnnotations={}}if(!n.propertyAnnotations[v]){n.propertyAnnotations[v]={}}if(!n.propertyAnnotations[v][g]){n.propertyAnnotations[v][g]={}}A=l._oXPath.selectNodes("./d:Annotation",m);for(var I=0;I<A.length;I+=1){N=l._oXPath.nextNode(A,I);P=l.replaceWithAlias(N.getAttribute("Term"));var L=s(N);if(L){P+="#"+L}if(N.hasChildNodes()===false){var j={};l.enrichFromPropertyValueAttributes(j,N);if(r.isEmptyObject(j)){j.Bool="true"}n.propertyAnnotations[v][g][P]=j}else{n.propertyAnnotations[v][g][P]=l.getPropertyValue(N)}}}else{var B;if(R){if(!n["EntityContainer"]){n["EntityContainer"]={}}if(!n["EntityContainer"][v]){n["EntityContainer"][v]={}}B=n["EntityContainer"][v]}else{if(!n[v]){n[v]={}}B=n[v]}x=v.replace(l._parserData.aliases[y],y);A=l._oXPath.selectNodes("./d:Annotation",m);for(var G=0;G<A.length;G+=1){N=l._oXPath.nextNode(A,G);var Q=B;if(R){if(!B[R]){B[R]={}}Q=B[R]}l._parseAnnotation(v,N,Q)}_=l._oXPath.selectNodes("//d:Annotations[contains(@Target, '"+x+"')]//d:PropertyValue[contains(@Path, '/')]//@Path",l._parserData.xmlDocument);for(E=0;E<_.length;E+=1){D=l._oXPath.nextNode(_,E);T=D.value;if(n.propertyAnnotations){if(n.propertyAnnotations[v]){if(n.propertyAnnotations[v][T]){continue}}}b=T.split("/");if(l.findNavProperty(v,b[0])){if(!n.expand){n.expand={}}if(!n.expand[v]){n.expand[v]={}}n.expand[v][b[0]]=b[0]}}V=l._oXPath.selectNodes("//d:Annotations[contains(@Target, '"+x+"')]//d:Path[contains(., '/')]",l._parserData.xmlDocument);for(E=0;E<V.length;E+=1){D=l._oXPath.nextNode(V,E);T=l._oXPath.getNodeText(D);if(n.propertyAnnotations&&n.propertyAnnotations[v]&&n.propertyAnnotations[v][T]){continue}if(!n.expand){n.expand={}}if(!n.expand[v]){n.expand[v]={}}b=T.split("/");if(l.findNavProperty(v,b[0])){if(!n.expand){n.expand={}}if(!n.expand[v]){n.expand[v]={}}n.expand[v][b[0]]=b[0]}}}}if(C.length){n.annotationsAtArrays=C.map(function(e){return l.backupAnnotationAtArray(e,n)})}return n},backupAnnotationAtArray:function(e,t){var a,r=[];function n(){return Array.prototype.filter.call(e.parentNode.childNodes,function(e){return e.nodeType===1}).indexOf(e)}while(e.nodeName!=="Annotations"){switch(e.nodeName){case"Annotation":a=s(e);r.unshift(e.getAttribute("Term")+(a?"#"+a:""));break;case"Collection":break;case"PropertyValue":r.unshift(e.getAttribute("Property"));break;case"Record":if(e.parentNode.nodeName==="Collection"){r.unshift(n())}break;default:if(e.parentNode.nodeName==="Apply"){r.unshift("Value");r.unshift(n());r.unshift("Parameters")}else{r.unshift(e.nodeName)}break}e=e.parentNode}r.unshift(e.getAttribute("Target"));r=r.map(function(e){return typeof e==="string"?l.replaceWithAlias(e):e});l.syncAnnotationsAtArrays(t,r,true);return r},restoreAnnotationsAtArrays:function(e){if(e.annotationsAtArrays){e.annotationsAtArrays.forEach(function(t){l.syncAnnotationsAtArrays(e,t)})}},syncAnnotationsAtArrays:function(e,a,r){var n,o=a.length-2,i=a[o+1],s=e,l=a[o],p=l+"@"+i;for(n=0;n<o;n+=1){s=s&&s[a[n]]}if(s&&Array.isArray(s[l])){if(!(p in s)){s[p]=s[l][i]}if(!(i in s[l])){s[l][i]=s[p]}}else if(r){t.warning("Wrong path to annotation at array",a,"sap.ui.model.odata.AnnotationParser")}},_parseAnnotation:function(e,t,a){var r=s(t);var n=l.replaceWithAlias(t.getAttribute("Term"));if(r){n+="#"+r}var o=l.getPropertyValue(t,e);o=l.setEdmTypes(o,l._parserData.metadataProperties.types,e,l._parserData.schema);a[n]=o;if(Array.isArray(a)){l._parserData.annotationsAtArrays.push(t)}},_parseReferences:function(e){var t=false;var a,r;var n=l._oXPath;var o="//edmx:Reference/edmx:Include[@Namespace and @Alias]";var i=n.selectNodes(o,l._parserData.xmlDocument);for(r=0;r<i.length;++r){t=true;a=n.nextNode(i,r);l._parserData.aliases[a.getAttribute("Alias")]=a.getAttribute("Namespace")}var s="//edmx:Reference[@Uri]/edmx:IncludeAnnotations[@TermNamespace]";var p=n.selectNodes(s,l._parserData.xmlDocument);for(r=0;r<p.length;++r){t=true;a=n.nextNode(p,r);var u=a.getAttribute("TermNamespace");var f=a.getAttribute("TargetNamespace");var d=a.parentNode.getAttribute("Uri");if(f){if(!e[f]){e[f]={}}e[f][u]=d}else{e[u]=d}}return t},getAllPropertiesMetadata:function(e){var t={},a={},r={},n=false,o,i,s,l={},p={},u={},f=false,d,c,m,h,y,v={types:a};if(!e.dataServices.schema){return v}for(var g=e.dataServices.schema.length-1;g>=0;g-=1){t=e.dataServices.schema[g];if(t.entityType){o=t.namespace;i=t.entityType;s=t.complexType;for(var A=0;A<i.length;A+=1){l=i[A];u={};p={};if(l.property){for(var N=0;N<l.property.length;N+=1){d=l.property[N];if(d.type.substring(0,o.length)===o){if(s){for(var P=0;P<s.length;P+=1){if(s[P].name===d.type.substring(o.length+1)){if(s[P].property){for(var x=0;x<s[P].property.length;x+=1){c=s[P].property[x];p[s[P].name+"/"+c.name]=c.type}}}}}}else{m=d.name;h=d.type;if(d.extensions){for(var _=0;_<d.extensions.length;_+=1){y=d.extensions[_];if(y.name==="display-format"&&y.value==="Date"){h="Edm.Date"}else{f=true;if(!u[m]){u[m]={}}if(y.namespace&&!u[m][y.namespace]){u[m][y.namespace]={}}u[m][y.namespace][y.name]=y.value}}}p[m]=h}}}if(!a[o+"."+l.name]){a[o+"."+l.name]={}}a[o+"."+l.name]=p;if(f){if(!r[o+"."+l.name]){n=true}r[o+"."+l.name]={};r[o+"."+l.name]=u}}}}if(n){v={types:a,extensions:r}}return v},setEdmTypes:function(e,t,a,r){function n(n){var o,i="";if(e[n]){o=e[n];if(o.Value&&o.Value.Path){i=l.getEdmType(o.Value.Path,t,a,r);if(i){e[n].EdmType=i}}else if(o.Path){i=l.getEdmType(o.Path,t,a,r);if(i){e[n].EdmType=i}}else if(o.Facets){e[n].Facets=l.setEdmTypes(o.Facets,t,a,r)}else if(o.Data){e[n].Data=l.setEdmTypes(o.Data,t,a,r)}else if(n==="Data"){e.Data=l.setEdmTypes(o,t,a,r)}else if(o.Value&&o.Value.Apply){e[n].Value.Apply.Parameters=l.setEdmTypes(o.Value.Apply.Parameters,t,a,r)}else if(o.Value&&o.Type&&o.Type==="Path"){i=l.getEdmType(o.Value,t,a,r);if(i){e[n].EdmType=i}}}}if(Array.isArray(e)){for(var o=0;o<e.length;o+=1){n(o)}}else{for(var i in e){n(i)}}return e},getEdmType:function(e,t,a,r){var n=e.indexOf("/");if(n>-1){var o=e.substr(0,n);var i=l.findNavProperty(a,o);if(i){var s=l._parserData.metadataInstance._getEntityTypeByNavPropertyObject(i);if(s){a=s.entityType;e=e.substr(n+1)}}}if(e.charAt(0)==="@"&&e.indexOf(r.Alias)===1){e=e.slice(r.Alias.length+2)}if(e.indexOf("/")>=0){if(t[e.slice(0,e.indexOf("/"))]){a=e.slice(0,e.indexOf("/"));e=e.slice(e.indexOf("/")+1)}}return t[a]&&t[a][e]},enrichFromPropertyValueAttributes:function(e,t){var a={Property:true,Qualifier:true,Term:true,xmlns:true};for(var r=0;r<t.attributes.length;r+=1){var n=t.attributes[r].name;if(!a[n]&&n.indexOf("xmlns:")!==0){var o=t.attributes[r].value;if(n==="EnumMember"&&o.indexOf(" ")>-1){var i=o.split(" ");e[n]=i.map(l.replaceWithAlias).join(" ")}else{e[n]=l.replaceWithAlias(o)}}}return e},_getRecordValues:function(e){var t=[];var a=l._oXPath;for(var r=0;r<e.length;++r){var n=a.nextNode(e,r);var o=l.getPropertyValues(n);var i=n.getAttribute("Type");if(i){o["RecordType"]=l.replaceWithAlias(i)}t.push(o)}return t},_getTextValues:function(e){var t=[];var a=l._oXPath;for(var r=0;r<e.length;r+=1){var n=a.nextNode(e,r);var o={};var i=a.getNodeText(n);o[n.nodeName]=l._parserData.aliases?l.replaceWithAlias(i):i;t.push(o)}return t},_getTextValue:function(e){var t=l._oXPath;var a="";if(e.nodeName in n){a=l.replaceWithAlias(t.getNodeText(e))}else{a=t.getNodeText(e)}if(e.nodeName!=="String"){a=a.trim()}return a},getPropertyValue:function(e,a){var r;var n=l._oXPath;var s=e.nodeName==="Collection"?[]:{};if(e.hasChildNodes()){var p=n.selectNodes("./d:Record",e);var u=l._getRecordValues(p);var f=n.selectNodes("./d:Collection/d:Record | ./d:Collection/d:If/d:Record",e);var d=l._getRecordValues(f);var c=u.concat(d);if(c.length>0){if(f.length===0&&p.length>0){s=c[0]}else{s=c}}else{var m=n.selectNodes("./d:Collection/d:AnnotationPath | ./d:Collection/d:NavigationPropertyPath | ./d:Collection/d:PropertyPath",e);if(m.length>0){s=l._getTextValues(m)}else{var h=n.selectNodes('./d:*[not(local-name() = "Annotation")]',e);if(h.length>0){for(r=0;r<h.length;r++){var y=n.nextNode(h,r);var v;var g=y.nodeName;var A=y.parentNode.nodeName;if(g==="Apply"){v=l.getApplyFunctions(y)}else{v=l.getPropertyValue(y)}if(i[A]){if(!Array.isArray(s)){s=[]}var N={};N[g]=v;s.push(N)}else if(g==="Collection"){s=v}else{if(s[g]){t.warning("Annotation contained multiple "+g+" values. Only the last "+"one will be stored: "+n.getPath(y))}s[g]=v}}l.enrichFromPropertyValueAttributes(s,e)}else if(e.nodeName in o){s=l._getTextValue(e)}else{l.enrichFromPropertyValueAttributes(s,e)}}}var P=n.selectNodes("./d:Annotation",e);if(P.length>0){for(r=0;r<P.length;r++){var x=n.nextNode(P,r);l._parseAnnotation(a,x,s)}}}else if(e.nodeName in o){s=l._getTextValue(e)}else if(e.nodeName.toLowerCase()==="null"){s=null}else{l.enrichFromPropertyValueAttributes(s,e)}return s},getPropertyValues:function(t){var a={},r;var n=l._oXPath;var o=n.selectNodes("./d:Annotation",t);var i=n.selectNodes("./d:PropertyValue",t);function s(e,t,a){var r,n=e;while(n.nodeName!=="Annotation"){n=n.parentNode}r=n.parentNode;return t+" '"+a+"' is defined twice; "+"Source = "+l._parserData.url+", Annotation Target = "+r.getAttribute("Target")+", Term = "+n.getAttribute("Term")}if(o.length===0&&i.length===0){a=l.getPropertyValue(t)}else{for(r=0;r<o.length;r++){var p=n.nextNode(o,r);var u=l.replaceWithAlias(p.getAttribute("Term"));e(!a[u],function(){return s(t,"Annotation",u)});a[u]=l.getPropertyValue(p)}for(r=0;r<i.length;r++){var f=n.nextNode(i,r);var d=f.getAttribute("Property");e(!a[d],function(){return s(t,"Property",d)});a[d]=l.getPropertyValue(f);var c=n.selectNodes("./d:Apply",f);for(var m=0;m<c.length;m+=1){var h=n.nextNode(c,m);a[d]={};a[d]["Apply"]=l.getApplyFunctions(h)}}}return a},getApplyFunctions:function(e){var t=l._oXPath;var a={Name:e.getAttribute("Function"),Parameters:[]};var r=t.selectNodes("./d:*",e);for(var n=0;n<r.length;n+=1){var o=t.nextNode(r,n);var s={Type:o.nodeName};if(o.nodeName==="Apply"){s.Value=l.getApplyFunctions(o)}else if(o.nodeName==="LabeledElement"){s.Value=l.getPropertyValue(o);s.Name=s.Value.Name;delete s.Value.Name}else if(i[o.nodeName]){s.Value=l.getPropertyValue(o)}else{s.Value=t.getNodeText(o)}a.Parameters.push(s)}return a},findNavProperty:function(e,t){var a=l._parserData.serviceMetadata;for(var r=a.dataServices.schema.length-1;r>=0;r-=1){var n=a.dataServices.schema[r];if(n.entityType){var o=n.namespace+".";var i=n.entityType;for(var s=i.length-1;s>=0;s-=1){if(o+i[s].name===e&&i[s].navigationProperty){for(var p=0;p<i[s].navigationProperty.length;p+=1){if(i[s].navigationProperty[p].name===t){return i[s].navigationProperty[p]}}}}}}return null},replaceWithAlias:function(e,t){if(t===undefined){t=1}for(var a in l._parserData.aliases){if(e.indexOf(a+".")>=0&&e.indexOf("."+a+".")<0){e=e.replace(a+".",l._parserData.aliases[a]+".");t--;if(t===0){return e}}}return e},getXPath:function(){var e={};var r=l._parserData;if(a.browser.msie){e={setNameSpace:function(e){e.setProperty("SelectionNamespaces",'xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:d="http://docs.oasis-open.org/odata/ns/edm"');e.setProperty("SelectionLanguage","XPath");return e},selectNodes:function(e,t){return t.selectNodes(e)},nextNode:function(e){return e.nextNode()},getNodeText:function(e){return e.text}}}else{e={setNameSpace:function(e){return e},nsResolver:function(e){var t={edmx:"http://docs.oasis-open.org/odata/ns/edmx",d:"http://docs.oasis-open.org/odata/ns/edm"};return t[e]||null},selectNodes:function(e,t){var a=r.xmlDocument.evaluate(e,t,this.nsResolver,7,null);a.length=a.snapshotLength;return a},nextNode:function(e,t){return e.snapshotItem(t)},getNodeText:function(e){return e.textContent}}}e.getPath=function(a){var r="";var n="getAttribute"in a?a.getAttribute("id"):"";var o=a.tagName?a.tagName:"";if(n){r='id("'+n+'")'}else if(a instanceof Document){r="/"}else if(o.toLowerCase()==="body"){r=o}else if(a.parentNode){var i=1;for(var s=0;s<a.parentNode.childNodes.length;++s){if(a.parentNode.childNodes[s]===a){r=e.getPath(a.parentNode)+"/"+o+"["+i+"]";break}else if(a.parentNode.childNodes[s].nodeType===1&&a.parentNode.childNodes[s].tagName===o){++i}}}else{t.error("Wrong Input node - cannot find XPath to it: "+o)}return r};return e}};return l});