text: /**
   * @license
   * Copyright (c) 2014, 2021, Oracle and/or its affiliates.
   * Licensed under The Universal Permissive License (UPL), Version 1.0
   * as shown at https://oss.oracle.com/licenses/upl/
   * @ignore
   */
  define(["exports","ojs/ojcore-base","ojs/ojeventtarget"],function(t,e,r){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,
  /**
       * @preserve Copyright 2013 jQuery Foundation and other contributors
       * Released under the MIT license.
       * http://jquery.org/license
       */
  oj.DataProvider=function(){},function(t){let e;!function(t){t.$co="$co",t.$eq="$eq",t.$ew="$ew",t.$pr="$pr",t.$gt="$gt",t.$ge="$ge",t.$lt="$lt",t.$le="$le",t.$ne="$ne",t.$regex="$regex",t.$sw="$sw"}(e=t.AttributeOperator||(t.AttributeOperator={}))}(t.AttributeFilterOperator||(t.AttributeFilterOperator={})),e._registerLegacyNamespaceProp("AttributeFilterOperator",t.AttributeFilterOperator),function(t){let e;!function(t){t.$and="$and",t.$or="$or"}(e=t.CompoundOperator||(t.CompoundOperator={}))}(t.CompoundFilterOperator||(t.CompoundFilterOperator={})),e._registerLegacyNamespaceProp("CompoundFilterOperator",t.CompoundFilterOperator);class i{constructor(){this._handleMutationAdd=function(t){var r;const s=t[i._BEFOREKEYS],n=t[i._KEYS],o=[];n.forEach(t=>{o.push(t)});const a=t[i._DATA],c=t[i._METADATA],l=t[i._INDEXES];if(o&&o.length>0)if(l)o.forEach((t,e)=>{this._items.splice(l[e],0,new this.Item(c[e],a[e]))});else if(s){const n=Object.assign([],s),l=Object.assign(new Set,t[i._KEYS]),f=Object.assign([],t[i._DATA]),u=Object.assign([],t[i._METADATA]),h=[];let p,_,y;for(const t of s){if(p=t,y=!0,null!=p){for(const t of o)if(e.Object.compareValues(t,p)){y=!1;break}if(y)for(const t of this._items)if(e.Object.compareValues(null===(r=null==t?void 0:t.metadata)||void 0===r?void 0:r.key,p)){y=!1;break}}else y=!1;y&&h.push(p)}let m=s.length;for(;m>0;){for(const t of s)if(_=t,h.indexOf(_)>=0){h.push(_);break}m--}for(let t=n.length-1;t>=0;t--)h.indexOf(n[t])>=0&&(delete n[t],l.delete(n[t]),delete f[t],delete u[t]);n.forEach((t,r)=>{var i,s;if(null===t)this._items.push(new this.Item(c[r],a[r]));else for(let n=0;n<this._items.length;n++)if(e.Object.compareValues(null===(s=null===(i=this._items[n])||void 0===i?void 0:i.metadata)||void 0===s?void 0:s.key,t)){this._items.splice(n,0,new this.Item(c[r],a[r]));break}})}else if(this._fetchParams&&null!=this._fetchParams.sortCriteria){const t=this._fetchParams.sortCriteria;if(t){const e=this._getSortComparator(t);let r,i,s;const n=[];a.forEach((t,o)=>{for(r=0;r<this._items.length;r++)if(i=this._items[r].data,s=e(t,i),s<0){this._items.splice(r,0,new this.Item(c[o],a[o])),n.push(o);break}}),a.forEach((t,e)=>{n.indexOf(e)<0&&this._items.push(new this.Item(c[e],a[e]))})}}else a.forEach((t,e)=>{this._items.push(new this.Item(c[e],a[e]))})},this._handleMutationRemove=function(t){const r=t[i._KEYS];if(r&&r.size>0){let t;r.forEach(r=>{for(t=this._items.length-1;t>=0;t--)if(e.Object.compareValues(this._items[t].metadata.key,r)){this._items.splice(t,1);break}})}},this._handleMutationUpdate=function(t){const r=t[i._KEYS],s=t[i._DATA],n=t[i._METADATA];if(s&&s.length>0){let t,i=0;r.forEach(r=>{for(t=this._items.length-1;t>=0;t--)if(e.Object.compareValues(this._items[t].metadata.key,r)){this._items.splice(t,1,new this.Item(n[i],s[i]));break}i++})}},this.Item=class{constructor(t,e){this.metadata=t,this.data=e,this[i._METADATA]=t,this[i._DATA]=e}},this.FetchByKeysResults=class{constructor(t,e){this.fetchParameters=t,this.results=e,this[i._FETCHPARAMETERS]=t,this[i._RESULTS]=e}},this.FetchByOffsetResults=class{constructor(t,e,r){this.fetchParameters=t,this.results=e,this.done=r,this[i._FETCHPARAMETERS]=t,this[i._RESULTS]=e,this[i._DONE]=r}},this._items=[]}addListResult(t){const e=[];t.value.data.forEach((r,i)=>{e.push(new this.Item(t.value.metadata[i],r))}),this._items=this._items.concat(e),this._done=t.done}getDataList(t,e){this._fetchParams=t;let r=25;null!=t.size&&(r=-1===t.size?this.getSize():t.size);const i=this._items.slice(e,e+r),s=[],n=[];return i.forEach(t=>{s.push(t.data),n.push(t.metadata)}),{fetchParameters:t,data:s,metadata:n}}getDataByKeys(t){const e=new Map;return t&&t.keys&&t.keys.forEach(t=>{for(const r of this._items)if(r.metadata.key===t){e.set(t,r);break}}),new this.FetchByKeysResults(t,e)}getDataByOffset(t){let e=[];return t&&(e=this._items.slice(t.offset,t.offset+t.size)),new this.FetchByOffsetResults(t,e,!0)}processMutations(t){null!=t.remove&&this._handleMutationRemove(t.remove),null!=t.add&&this._handleMutationAdd(t.add),null!=t.update&&this._handleMutationUpdate(t.update)}reset(){this._items=[],this._done=!1}getSize(){return this._items.length}isDone(){return this._done}_getSortComparator(t){return(e,r)=>{let s,n,o,a;for(const c of t){s=c[i._DIRECTION],n=c[i._ATTRIBUTE],o=this._getVal(e,n),a=this._getVal(r,n);let t=0;const l="string"==typeof o?o:String(o).toString(),f="string"==typeof a?a:String(a).toString();if(t="ascending"===s?l.localeCompare(f,void 0,{numeric:!0,sensitivity:"base"}):f.localeCompare(l,void 0,{numeric:!0,sensitivity:"base"}),0!==t)return t}return 0}}_getVal(t,e){if("string"==typeof e){const r=e.indexOf(".");if(r>0){const i=e.substring(0,r),s=e.substring(r+1),n=t[i];if(n)return this._getVal(n,s)}}return"function"==typeof t[e]?t[e]():t[e]}}i._DATA="data",i._METADATA="metadata",i._ITEMS="items",i._BEFOREKEYS="addBeforeKeys",i._KEYS="keys",i._INDEXES="indexes",i._FROM="from",i._OFFSET="offset",i._REFRESH="refresh",i._MUTATE="mutate",i._SIZE="size",i._FETCHPARAMETERS="fetchParameters",i._SORTCRITERIA="sortCriteria",i._DIRECTION="direction",i._ATTRIBUTE="attribute",i._VALUE="value",i._DONE="done",i._RESULTS="results",i._CONTAINSPARAMETERS="containsParameters",i._DEFAULT_SIZE=25,i._CONTAINSKEYS="containsKeys",i._FETCHBYKEYS="fetchByKeys",i._FETCHBYOFFSET="fetchByOffset",i._FETCHFIRST="fetchFirst",i._FETCHATTRIBUTES="attributes",e._registerLegacyNamespaceProp("DataCache",i);class s extends r.GenericEvent{constructor(t){const e={};e[s._DETAIL]=t,super("mutate",e)}}s._DETAIL="detail",e._registerLegacyNamespaceProp("DataProviderMutationEvent",s);class n extends r.GenericEvent{constructor(t){const e={};e.detail=t,super("refresh",e)}}e._registerLegacyNamespaceProp("DataProviderRefreshEvent",n);class o{fetchByKeys(t){let e=0;const r=this.getIterationLimit?this.getIterationLimit():-1,i={size:25},s=new Map,n=this.fetchFirst(i)[Symbol.asyncIterator]();return function t(i,s,n){return s.next().then(function(o){const a=o.value,c=a.data,l=a.metadata,f=l.map(function(t){return t.key});let u=!0;return i.keys.forEach(function(t){n.has(t)||f.map(function(e,r){e===t&&n.set(e,{metadata:l[r],data:c[r]})}),n.has(t)||(u=!1)}),e+=c.length,u||o.done||-1!=r&&e>=r?n:t(i,s,n)})}(t,n,s).then(function(e){const r=new Map;return e.forEach(function(t,e){const i=[t];r.set(e,i[0])}),{fetchParameters:t,results:r}})}containsKeys(t){return this.fetchByKeys(t).then(function(e){const r=new Set;return t.keys.forEach(function(t){null!=e.results.get(t)&&r.add(t)}),Promise.resolve({containsParameters:t,results:r})})}getCapability(t){if("fetchByKeys"===t)return{implementation:"iteration"};let e=null;if(!0!==this._ojSkipLastCapability){this._ojSkipLastCapability=!0;let r=1;for(;this["_ojLastGetCapability"+r];)++r;for(--r;r>0&&(e=this["_ojLastGetCapability"+r](t),!e);r--);delete this._ojSkipLastCapability}return e}static applyMixin(t){const e=t.prototype.getCapability;if([o].forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{"constructor"!==r&&(t.prototype[r]=e.prototype[r])})}),e){let r=1;for(;t.prototype["_ojLastGetCapability"+r];)++r;t.prototype["_ojLastGetCapability"+r]=e}}}e._registerLegacyNamespaceProp("FetchByKeysMixin",o);class a{fetchByOffset(t){const e=t&&t.size>0?t.size:25,r=t?t.sortCriteria:null,i=t&&t.offset>0?t.offset:0;let s=0;const n=this.getIterationLimit?this.getIterationLimit():-1;let o=!1;const a={};a.size=e,a.sortCriteria=r;const c=new Array,l=this.fetchFirst(a)[Symbol.asyncIterator]();return function t(r,a,c){return a.next().then(function(l){o=l.done;const f=l.value,u=f.data,h=f.metadata,p=u.length;if(i<s+p){for(let t=i<=s?0:i-s;t<p&&c.length!==e;t++)c.push({metadata:h[t],data:u[t]})}return s+=p,c.length<e&&!o?-1!==n&&s>=n?c:t(r,a,c):c})}(t,l,c).then(function(e){return{fetchParameters:t,results:e,done:o}})}getCapability(t){if("fetchByOffset"===t)return{implementation:"iteration"};let e=null;if(!0!==this._ojSkipLastCapability){this._ojSkipLastCapability=!0;let r=1;for(;this["_ojLastGetCapability"+r];)++r;for(--r;r>0&&(e=this["_ojLastGetCapability"+r](t),!e);r--);delete this._ojSkipLastCapability}return e}static applyMixin(t){const e=t.prototype.getCapability;if([a].forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{"constructor"!==r&&(t.prototype[r]=e.prototype[r])})}),e){let r=1;for(;t.prototype["_ojLastGetCapability"+r];)++r;t.prototype["_ojLastGetCapability"+r]=e}}}var c;e._registerLegacyNamespaceProp("FetchByOffsetMixin",a),function(t){function e(t,e){let r=!1;for(const i in e)if(e.hasOwnProperty(i)){const n=e[i];if(r||!s(i))throw new Error("parsing error "+e);t.operator=i,t.right=n,r=!0}}function r(t,e,r){if("$lt"===t){const t=o(r,e);return(r=t[0])<(e=t[1])}if("$gt"===t){const t=o(r,e);return(r=t[0])>(e=t[1])}if("$lte"===t){const t=o(r,e);return(r=t[0])<=(e=t[1])}if("$gte"===t){const t=o(r,e);return(r=t[0])>=(e=t[1])}if("$eq"===t)return r===e;if("$ne"===t)return r!==e;if("$regex"===t){if(r){if("string"!=typeof r&&!(r instanceof String))if(r instanceof Object){if("[object Object]"==(r=r.toString()))return!1}else r=new String(r);return null!==r.match(e)}return!1}if("$exists"===t)return e?null!=r:null==r;throw new Error("not a valid operator! "+t)}function i(t){return"$and"===t||"$or"===t}function s(t){return"$lt"===t||"$gt"===t||"$lte"===t||"$gte"===t||"$eq"===t||"$ne"===t||"$regex"===t||"$exists"===t}function n(t){return null!=t&&(t instanceof String||"string"==typeof t)}function o(t,e){return n(t)&&null==e?e="":n(e)&&null==t&&(t=""),[t,e]}function a(t,e){const r=t.split(".");let i=e;for(const t of r)i=i[t];return i}t.satisfy=function(t,n){if(t){return function t(e,n){const o=e.operator;if(i(o)){if(!e.left&&e.array instanceof Array){let r;const i=e.array;for(const e of i){const i=t(e,n);if("$or"===o&&!0===i)return!0;if("$and"===o&&!1===i)return!1;r=i}return r}throw new Error("invalid expression tree!"+e)}if(s(o)){const t=e.right;let i;if("*"!=e.left)return i=a(e.left,n),r(o,t,i);{const e=Object.keys(n);for(const s of e)if(i=a(s,n),r(o,t,i))return!0;return!1}}throw new Error("not a valid expression!"+e)}(function t(r){let n;const o=[];for(const a in r)if(r.hasOwnProperty(a)){const c=r[a];if(0===a.indexOf("$")){if(i(a)){if(!(c instanceof Array))throw new Error("not a valid expression: "+r);n={operator:a,array:[]};for(const e of c){const r=t(e);n.array.push(r)}}else if(s(a))throw new Error("not a valid expression: "+r)}else if("object"!=typeof c)o.push({left:a,right:c,operator:"$eq"});else{const t={left:a};e(t,c),o.push(t)}}o.length>1?n={operator:"$and",array:o}:1===o.length&&(n=o[0]);return n}(t),n)}return!0}}(c||(c={}));class l{constructor(t){t=t||{},this._textFilterAttributes=t.filterOptions?t.filterOptions.textFilterAttributes:null;const e=t.filterDef;e&&(e.op?(this.op=e.op,e.value?(this.value=e.value,e.attribute&&(this.attribute=e.attribute)):e.criteria&&(this.criteria=e.criteria)):e.text&&(this.text=e.text))}filter(t,e,r){return c.satisfy(l._transformFilter(this),t)}static _transformFilter(t){let e;if(t){let r,i=t.op;if(t.text?i="$regex":"$le"===i?i="$lte":"$ge"===i?i="$gte":"$pr"===i&&(i="$exists"),"$and"!==i&&"$or"!==i){r=t.text?new RegExp(t.text.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&"),"i"):t.value,e={};const s=t.attribute;if(s){const t={};"$sw"!==i&&"$ew"!==i&&"$co"!==i||(i="$regex",r=l._fixStringExpr(i,r)),t[i]=r,e[s]=t}else if(t.text){const s={};if(s[i]=r,t._textFilterAttributes&&t._textFilterAttributes.length>0){const r=[];t._textFilterAttributes.forEach(function(t){const e={};e[t]=s,r.push(e)}),e.$or=r}else e["*"]=s}else{const t=[];l._transformObjectExpr(r,i,null,t),e.$and=t}}else{const r=[];t.criteria.forEach(function(e){e&&e.text&&t._textFilterAttributes&&(e._textFilterAttributes=t._textFilterAttributes),r.push(l._transformFilter(e))}),e={},e[i]=r}}return e}static _transformObjectExpr(t,e,r,i){if(Object.keys(t).length>0)Object.keys(t).forEach(function(s){let n=t[s];const o=r?r+"."+s:s;if(n instanceof Object)l._transformObjectExpr(n,e,o,i);else{const t={};"$sw"!==e&&"$ew"!==e&&"$co"!==e||(e="$regex",n=l._fixStringExpr(e,n)),t[e]=n;const r={};r[o]=t,i.push(r)}});else{const s={};s[e]=t;const n={};n[r]=s,i.push(n)}}static _fixStringExpr(t,e){return("string"==typeof e||e instanceof String)&&("$sw"===t?e="^"+e:"$ew"===t&&(e+="$")),e}}class f{static getFilter(t){return new l(t)}}e._registerLegacyNamespaceProp("FilterFactory",f),t.DataCache=i,t.DataProviderMutationEvent=s,t.DataProviderRefreshEvent=n,t.FetchByKeysMixin=o,t.FetchByOffsetMixin=a,t.FilterFactory=f,Object.defineProperty(t,"__esModule",{value:!0})});
  //# sourceMappingURL=ojdataprovider.js.map